bukesiyi-cli 0.5.0 → 0.7.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 +54 -3
- package/dist/main.js +1866 -406
- package/package.json +3 -2
- package/skills/buke/SKILL.md +52 -0
package/dist/main.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/main.ts
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
2
3
|
import { homedir } from "node:os";
|
|
3
4
|
|
|
4
5
|
// src/commands/graphic.ts
|
|
@@ -393,33 +394,33 @@ function readHiddenLine(stdin, signal) {
|
|
|
393
394
|
stdin.resume();
|
|
394
395
|
});
|
|
395
396
|
}
|
|
396
|
-
async function promptHidden(
|
|
397
|
-
|
|
397
|
+
async function promptHidden(io2, setRawMode) {
|
|
398
|
+
io2.stderr.write("\u8BF7\u7C98\u8D34 API \u5BC6\u94A5\uFF08\u8F93\u5165\u4E0D\u4F1A\u663E\u793A\uFF09\uFF0C\u56DE\u8F66\u786E\u8BA4\uFF1A");
|
|
398
399
|
try {
|
|
399
|
-
setRawMode.call(
|
|
400
|
-
return (await readHiddenLine(
|
|
400
|
+
setRawMode.call(io2.stdin, true);
|
|
401
|
+
return (await readHiddenLine(io2.stdin, io2.signal)).trim();
|
|
401
402
|
} finally {
|
|
402
403
|
try {
|
|
403
|
-
setRawMode.call(
|
|
404
|
+
setRawMode.call(io2.stdin, false);
|
|
404
405
|
} catch {
|
|
405
406
|
}
|
|
406
|
-
release(
|
|
407
|
-
|
|
407
|
+
release(io2.stdin);
|
|
408
|
+
io2.stderr.write("\n");
|
|
408
409
|
}
|
|
409
410
|
}
|
|
410
|
-
function willPromptForKey(
|
|
411
|
-
return keyFromEnv(
|
|
411
|
+
function willPromptForKey(io2) {
|
|
412
|
+
return keyFromEnv(io2.env) === null && io2.stdin.isTTY === true && typeof io2.stdin.setRawMode === "function";
|
|
412
413
|
}
|
|
413
|
-
async function readNewKey(
|
|
414
|
-
const fromEnv = keyFromEnv(
|
|
414
|
+
async function readNewKey(io2) {
|
|
415
|
+
const fromEnv = keyFromEnv(io2.env);
|
|
415
416
|
if (fromEnv !== null) {
|
|
416
417
|
assertKeyFormat(fromEnv);
|
|
417
418
|
return { key: fromEnv, source: "env" };
|
|
418
419
|
}
|
|
419
|
-
if (
|
|
420
|
-
const setRawMode =
|
|
421
|
-
const interactive =
|
|
422
|
-
const key = interactive ? await promptHidden(
|
|
420
|
+
if (io2.signal?.aborted) throw interruptedError(CANCELLED);
|
|
421
|
+
const setRawMode = io2.stdin.setRawMode;
|
|
422
|
+
const interactive = io2.stdin.isTTY === true && typeof setRawMode === "function";
|
|
423
|
+
const key = interactive ? await promptHidden(io2, setRawMode) : await readToEnd(io2.stdin, io2.stdinTimeoutMs ?? DEFAULT_STDIN_TIMEOUT_MS, io2.signal);
|
|
423
424
|
if (key === "") throw missingKey(NO_KEY_READ);
|
|
424
425
|
assertKeyFormat(key);
|
|
425
426
|
return { key, source: interactive ? "terminal" : "stdin" };
|
|
@@ -427,7 +428,7 @@ async function readNewKey(io) {
|
|
|
427
428
|
|
|
428
429
|
// package.json
|
|
429
430
|
var name = "bukesiyi-cli";
|
|
430
|
-
var version = "0.
|
|
431
|
+
var version = "0.7.0";
|
|
431
432
|
|
|
432
433
|
// src/version.ts
|
|
433
434
|
var PACKAGE_NAME = name;
|
|
@@ -773,14 +774,14 @@ async function requestJson(baseUrl, apiKey, plan, deps) {
|
|
|
773
774
|
const origin = normalizeBaseUrl(baseUrl);
|
|
774
775
|
assertKeyFormat(apiKey);
|
|
775
776
|
assertReachedDirectly(origin, deps.env);
|
|
776
|
-
const
|
|
777
|
-
if ("redirectedTo" in
|
|
778
|
-
const parsed = parseJson(
|
|
779
|
-
if (
|
|
780
|
-
if (!parsed) throw unreadableResponse(
|
|
781
|
-
return { status:
|
|
777
|
+
const result4 = await exchange(`${origin}${plan.path}`, apiKey, plan, deps, origin);
|
|
778
|
+
if ("redirectedTo" in result4) throw redirectError(result4.redirectedTo);
|
|
779
|
+
const parsed = parseJson(result4.text);
|
|
780
|
+
if (result4.status >= 200 && result4.status < 300) {
|
|
781
|
+
if (!parsed) throw unreadableResponse(result4.status);
|
|
782
|
+
return { status: result4.status, body: parsed.value };
|
|
782
783
|
}
|
|
783
|
-
throw (parsed && serverError(
|
|
784
|
+
throw (parsed && serverError(result4.status, parsed.value, apiKey)) ?? unreadableResponse(result4.status);
|
|
784
785
|
}
|
|
785
786
|
async function getJson(baseUrl, apiKey, path, deps) {
|
|
786
787
|
return requestJson(baseUrl, apiKey, { method: "GET", path }, deps);
|
|
@@ -806,9 +807,9 @@ async function downloadFile(baseUrl, apiKey, path, deps) {
|
|
|
806
807
|
const origin = normalizeBaseUrl(baseUrl);
|
|
807
808
|
assertKeyFormat(apiKey);
|
|
808
809
|
assertReachedDirectly(origin, deps.env);
|
|
809
|
-
const
|
|
810
|
-
if ("redirectedTo" in
|
|
811
|
-
if (
|
|
810
|
+
const result4 = await exchange(`${origin}${path}`, apiKey, downloadPlan(path, deps), deps, origin);
|
|
811
|
+
if ("redirectedTo" in result4) throw redirectError(result4.redirectedTo);
|
|
812
|
+
if (result4.status === 202) {
|
|
812
813
|
throw new CliError({
|
|
813
814
|
code: "CLI_DOWNLOAD_NOT_READY",
|
|
814
815
|
exitCode: EXIT.RETRY_LATER,
|
|
@@ -817,44 +818,44 @@ async function downloadFile(baseUrl, apiKey, path, deps) {
|
|
|
817
818
|
message: "\u6210\u7247\u4E0B\u8F7D\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u7A0D\u540E\u91CD\u65B0\u6267\u884C\u4E0B\u8F7D\u547D\u4EE4\u3002\u672C\u6B21\u672A\u4FDD\u5B58\u6587\u4EF6\u3002"
|
|
818
819
|
});
|
|
819
820
|
}
|
|
820
|
-
if (
|
|
821
|
-
const text =
|
|
821
|
+
if (result4.status < 200 || result4.status >= 300) {
|
|
822
|
+
const text = result4.bytes.toString("utf8");
|
|
822
823
|
const parsed = parseJson(text);
|
|
823
|
-
throw (parsed && serverError(
|
|
824
|
+
throw (parsed && serverError(result4.status, parsed.value, apiKey)) ?? unreadableResponse(result4.status);
|
|
824
825
|
}
|
|
825
|
-
const mime =
|
|
826
|
+
const mime = result4.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase();
|
|
826
827
|
const quickTimeVideo = mime === "video/quicktime" && /^\/api\/open\/v1\/videos\/[^/?#]+\/download(?:\?[^#]*)?$/u.test(path);
|
|
827
|
-
if (
|
|
828
|
-
throw unreadableResponse(
|
|
828
|
+
if (result4.status !== 200 || result4.bytes.length === 0 || mime !== "video/mp4" && !quickTimeVideo) {
|
|
829
|
+
throw unreadableResponse(result4.status);
|
|
829
830
|
}
|
|
830
|
-
return { bytes:
|
|
831
|
+
return { bytes: result4.bytes, filename: filenameFromDisposition(result4.headers.get("content-disposition")) };
|
|
831
832
|
}
|
|
832
833
|
async function downloadAssetFile(baseUrl, apiKey, path, deps, options) {
|
|
833
834
|
if (!/^\/api\/open\/v1\//u.test(path) || path.includes("#")) throw unreadableResponse(0);
|
|
834
835
|
const origin = normalizeBaseUrl(baseUrl);
|
|
835
836
|
assertKeyFormat(apiKey);
|
|
836
837
|
assertReachedDirectly(origin, deps.env);
|
|
837
|
-
const
|
|
838
|
-
if ("redirectedTo" in
|
|
839
|
-
if (
|
|
838
|
+
const result4 = await exchange(`${origin}${path}`, apiKey, downloadPlan(path, deps), deps, origin);
|
|
839
|
+
if ("redirectedTo" in result4) throw redirectError(result4.redirectedTo);
|
|
840
|
+
if (result4.status === 202) throw new CliError({
|
|
840
841
|
code: "CLI_DOWNLOAD_NOT_READY",
|
|
841
842
|
exitCode: EXIT.RETRY_LATER,
|
|
842
843
|
retryable: true,
|
|
843
844
|
httpStatus: 202,
|
|
844
845
|
message: "\u4E0B\u8F7D\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002\u672C\u6B21\u672A\u4FDD\u5B58\u6587\u4EF6\u3002"
|
|
845
846
|
});
|
|
846
|
-
if (
|
|
847
|
-
const parsed = parseJson(
|
|
848
|
-
throw (parsed && serverError(
|
|
849
|
-
}
|
|
850
|
-
const mime =
|
|
851
|
-
if (
|
|
852
|
-
const declaredLength =
|
|
853
|
-
if (declaredLength !== null && (!/^\d+$/u.test(declaredLength) || Number(declaredLength) !==
|
|
854
|
-
const sha256 =
|
|
855
|
-
if (options.requireSha256 && !sha256 || sha256 !== null && (!/^[a-f0-9]{64}$/iu.test(sha256) || createHash("sha256").update(
|
|
856
|
-
if (!assetMimeMatchesBytes(mime,
|
|
857
|
-
return { bytes:
|
|
847
|
+
if (result4.status < 200 || result4.status >= 300) {
|
|
848
|
+
const parsed = parseJson(result4.bytes.toString("utf8"));
|
|
849
|
+
throw (parsed && serverError(result4.status, parsed.value, apiKey)) ?? unreadableResponse(result4.status);
|
|
850
|
+
}
|
|
851
|
+
const mime = result4.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase();
|
|
852
|
+
if (result4.status !== 200 || result4.bytes.length === 0 || !mime || !options.allowedMimeTypes.includes(mime)) throw unreadableResponse(result4.status);
|
|
853
|
+
const declaredLength = result4.headers.get("content-length");
|
|
854
|
+
if (declaredLength !== null && (!/^\d+$/u.test(declaredLength) || Number(declaredLength) !== result4.bytes.byteLength)) throw unreadableResponse(result4.status);
|
|
855
|
+
const sha256 = result4.headers.get("x-content-sha256");
|
|
856
|
+
if (options.requireSha256 && !sha256 || sha256 !== null && (!/^[a-f0-9]{64}$/iu.test(sha256) || createHash("sha256").update(result4.bytes).digest("hex") !== sha256.toLowerCase())) throw unreadableResponse(result4.status);
|
|
857
|
+
if (!assetMimeMatchesBytes(mime, result4.bytes)) throw unreadableResponse(result4.status);
|
|
858
|
+
return { bytes: result4.bytes, filename: filenameFromDisposition(result4.headers.get("content-disposition")) };
|
|
858
859
|
}
|
|
859
860
|
function assetMimeMatchesBytes(mime, bytes) {
|
|
860
861
|
if (mime === "image/png") return bytes.length >= 8 && bytes.subarray(0, 8).toString("hex") === "89504e470d0a1a0a";
|
|
@@ -1596,17 +1597,17 @@ function absoluteOnly(value) {
|
|
|
1596
1597
|
function configDirError(message2) {
|
|
1597
1598
|
return new CliError({ code: "CLI_CONFIG_DIR_INVALID", exitCode: EXIT.USAGE, message: message2 });
|
|
1598
1599
|
}
|
|
1599
|
-
function expandHome(value,
|
|
1600
|
-
if (value === "~") return
|
|
1601
|
-
if (value.startsWith("~/") ||
|
|
1602
|
-
return join(
|
|
1600
|
+
function expandHome(value, io2) {
|
|
1601
|
+
if (value === "~") return io2.homedir();
|
|
1602
|
+
if (value.startsWith("~/") || io2.platform === "win32" && value.startsWith("~\\")) {
|
|
1603
|
+
return join(io2.homedir(), value.slice(2));
|
|
1603
1604
|
}
|
|
1604
1605
|
return value;
|
|
1605
1606
|
}
|
|
1606
|
-
function locate(
|
|
1607
|
-
const chosen = nonEmpty3(
|
|
1607
|
+
function locate(io2) {
|
|
1608
|
+
const chosen = nonEmpty3(io2.env.BUKE_CONFIG_DIR);
|
|
1608
1609
|
if (chosen !== void 0) {
|
|
1609
|
-
const dir = expandHome(chosen,
|
|
1610
|
+
const dir = expandHome(chosen, io2);
|
|
1610
1611
|
if (!isAbsolute(dir)) {
|
|
1611
1612
|
throw configDirError(
|
|
1612
1613
|
"BUKE_CONFIG_DIR \u8981\u5199\u7EDD\u5BF9\u8DEF\u5F84\uFF08\u53EF\u4EE5\u7528 ~/ \u5F00\u5934\u8868\u793A\u5BB6\u76EE\u5F55\uFF09\u3002\u76F8\u5BF9\u8DEF\u5F84\u4F1A\u8BA9\u51ED\u636E\u843D\u5728\u5F53\u524D\u76EE\u5F55\u91CC\uFF0C\u6240\u4EE5\u6CA1\u6709\u4F7F\u7528"
|
|
@@ -1614,19 +1615,19 @@ function locate(io) {
|
|
|
1614
1615
|
}
|
|
1615
1616
|
return { dir, ours: false };
|
|
1616
1617
|
}
|
|
1617
|
-
const base = absoluteOnly(nonEmpty3(
|
|
1618
|
+
const base = absoluteOnly(nonEmpty3(io2.env.XDG_CONFIG_HOME)) ?? (io2.platform === "win32" ? absoluteOnly(nonEmpty3(io2.env.APPDATA)) : void 0);
|
|
1618
1619
|
if (base !== void 0) return { dir: join(base, "buke"), ours: true };
|
|
1619
|
-
const home =
|
|
1620
|
+
const home = io2.homedir();
|
|
1620
1621
|
if (!isAbsolute(home)) {
|
|
1621
1622
|
throw configDirError("\u627E\u4E0D\u5230\u5BB6\u76EE\u5F55\uFF0C\u6CA1\u6CD5\u51B3\u5B9A\u51ED\u636E\u4FDD\u5B58\u5728\u54EA\u91CC\u3002\u8BF7\u7528 BUKE_CONFIG_DIR \u6307\u5B9A\u4E00\u4E2A\u7EDD\u5BF9\u8DEF\u5F84");
|
|
1622
1623
|
}
|
|
1623
1624
|
return { dir: join(home, ".config", "buke"), ours: true };
|
|
1624
1625
|
}
|
|
1625
|
-
function credentialsDir(
|
|
1626
|
-
return locate(
|
|
1626
|
+
function credentialsDir(io2) {
|
|
1627
|
+
return locate(io2).dir;
|
|
1627
1628
|
}
|
|
1628
|
-
function credentialsPath(
|
|
1629
|
-
return join(locate(
|
|
1629
|
+
function credentialsPath(io2) {
|
|
1630
|
+
return join(locate(io2).dir, FILE_NAME);
|
|
1630
1631
|
}
|
|
1631
1632
|
function errorCode(error) {
|
|
1632
1633
|
const code2 = typeof error === "object" && error !== null ? error.code : void 0;
|
|
@@ -1649,8 +1650,8 @@ async function ensureDir(dir) {
|
|
|
1649
1650
|
return false;
|
|
1650
1651
|
}
|
|
1651
1652
|
}
|
|
1652
|
-
async function guardDir(
|
|
1653
|
-
if (
|
|
1653
|
+
async function guardDir(io2, { dir, ours }, tighten, warn) {
|
|
1654
|
+
if (io2.platform === "win32") return;
|
|
1654
1655
|
let mode;
|
|
1655
1656
|
try {
|
|
1656
1657
|
mode = (await stat(dir)).mode;
|
|
@@ -1687,8 +1688,8 @@ async function sweepStaleTemps(dir) {
|
|
|
1687
1688
|
}
|
|
1688
1689
|
}
|
|
1689
1690
|
}
|
|
1690
|
-
async function writeCredentials(
|
|
1691
|
-
const location = locate(
|
|
1691
|
+
async function writeCredentials(io2, credentials, warn = SILENT) {
|
|
1692
|
+
const location = locate(io2);
|
|
1692
1693
|
const { dir } = location;
|
|
1693
1694
|
const path = join(dir, FILE_NAME);
|
|
1694
1695
|
const temp = join(dir, `.${FILE_NAME}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`);
|
|
@@ -1703,7 +1704,7 @@ async function writeCredentials(io, credentials, warn = SILENT) {
|
|
|
1703
1704
|
try {
|
|
1704
1705
|
const created = await ensureDir(dir);
|
|
1705
1706
|
if (!created) {
|
|
1706
|
-
await guardDir(
|
|
1707
|
+
await guardDir(io2, location, true, warn);
|
|
1707
1708
|
await sweepStaleTemps(dir);
|
|
1708
1709
|
}
|
|
1709
1710
|
const handle = await open(temp, "wx", OWNER_ONLY_FILE);
|
|
@@ -1741,7 +1742,7 @@ function cannotRead(path, reason) {
|
|
|
1741
1742
|
message: `\u51ED\u636E\u6587\u4EF6\u8BFB\u4E0D\u4E86\uFF1A${path}\uFF08${reason}\uFF09\u3002\u5220\u6389\u5B83\u540E\u91CD\u65B0 buke login`
|
|
1742
1743
|
});
|
|
1743
1744
|
}
|
|
1744
|
-
async function readOwnFile(
|
|
1745
|
+
async function readOwnFile(io2, path, warn) {
|
|
1745
1746
|
const notRegular = "\u4E0D\u662F\u4E00\u4E2A\u666E\u901A\u6587\u4EF6";
|
|
1746
1747
|
if (!(await lstat(path)).isFile()) throw cannotRead(path, notRegular);
|
|
1747
1748
|
const handle = await open(path, constants.O_RDONLY | NO_FOLLOW | NON_BLOCKING);
|
|
@@ -1749,7 +1750,7 @@ async function readOwnFile(io, path, warn) {
|
|
|
1749
1750
|
const info = await handle.stat();
|
|
1750
1751
|
if (!info.isFile()) throw cannotRead(path, notRegular);
|
|
1751
1752
|
if (info.size > MAX_FILE_BYTES) throw unreadable(path);
|
|
1752
|
-
if (
|
|
1753
|
+
if (io2.platform !== "win32" && (info.mode & GROUP_OR_OTHERS) !== 0) {
|
|
1753
1754
|
try {
|
|
1754
1755
|
await handle.chmod(OWNER_ONLY_FILE);
|
|
1755
1756
|
warn(`\u51ED\u636E\u6587\u4EF6\u7684\u6743\u9650\u8FC7\u5BBD\uFF0C\u5DF2\u6536\u7D27\u4E3A\u53EA\u6709\u672C\u4EBA\u53EF\u8BFB\u5199\uFF1A${path}`);
|
|
@@ -1782,24 +1783,24 @@ function parseStored(text) {
|
|
|
1782
1783
|
return null;
|
|
1783
1784
|
}
|
|
1784
1785
|
}
|
|
1785
|
-
async function readCredentials(
|
|
1786
|
-
const location = locate(
|
|
1786
|
+
async function readCredentials(io2, warn = SILENT) {
|
|
1787
|
+
const location = locate(io2);
|
|
1787
1788
|
const path = join(location.dir, FILE_NAME);
|
|
1788
1789
|
let text;
|
|
1789
1790
|
try {
|
|
1790
|
-
text = await readOwnFile(
|
|
1791
|
+
text = await readOwnFile(io2, path, warn);
|
|
1791
1792
|
} catch (error) {
|
|
1792
1793
|
if (error instanceof CliError) throw error;
|
|
1793
1794
|
if (isMissing(error)) return null;
|
|
1794
1795
|
throw cannotRead(path, systemReason(error));
|
|
1795
1796
|
}
|
|
1796
|
-
await guardDir(
|
|
1797
|
+
await guardDir(io2, location, false, warn);
|
|
1797
1798
|
const stored = parseStored(text);
|
|
1798
1799
|
if (!stored) throw unreadable(path);
|
|
1799
1800
|
return stored;
|
|
1800
1801
|
}
|
|
1801
|
-
async function deleteCredentials(
|
|
1802
|
-
const { dir } = locate(
|
|
1802
|
+
async function deleteCredentials(io2, warn = SILENT) {
|
|
1803
|
+
const { dir } = locate(io2);
|
|
1803
1804
|
const path = join(dir, FILE_NAME);
|
|
1804
1805
|
let removed = false;
|
|
1805
1806
|
try {
|
|
@@ -1825,16 +1826,99 @@ async function deleteCredentials(io, warn = SILENT) {
|
|
|
1825
1826
|
return removed;
|
|
1826
1827
|
}
|
|
1827
1828
|
|
|
1829
|
+
// src/keychain.ts
|
|
1830
|
+
var KEYCHAIN_SERVICE = "bukesiyi-cli";
|
|
1831
|
+
var KEYCHAIN_ACCOUNT = "api-key";
|
|
1832
|
+
var KEYCHAIN_TIMEOUT_MS = 2e3;
|
|
1833
|
+
function keychainAvailable(io2) {
|
|
1834
|
+
if (io2.platform !== "darwin") return false;
|
|
1835
|
+
if (io2.env.BUKE_DISABLE_KEYCHAIN === "1") return false;
|
|
1836
|
+
return io2.spawnCapture !== void 0;
|
|
1837
|
+
}
|
|
1838
|
+
async function saveKeychainCredentials(io2, credentials) {
|
|
1839
|
+
if (!keychainAvailable(io2) || !io2.spawnCapture) return { ok: false, reason: "\u94A5\u5319\u4E32\u4E0D\u53EF\u7528" };
|
|
1840
|
+
try {
|
|
1841
|
+
const run2 = await io2.spawnCapture(
|
|
1842
|
+
"security",
|
|
1843
|
+
[
|
|
1844
|
+
"add-generic-password",
|
|
1845
|
+
"-U",
|
|
1846
|
+
"-s",
|
|
1847
|
+
KEYCHAIN_SERVICE,
|
|
1848
|
+
"-a",
|
|
1849
|
+
KEYCHAIN_ACCOUNT,
|
|
1850
|
+
"-w",
|
|
1851
|
+
JSON.stringify(credentials)
|
|
1852
|
+
],
|
|
1853
|
+
{ timeoutMs: KEYCHAIN_TIMEOUT_MS }
|
|
1854
|
+
);
|
|
1855
|
+
if (run2.timedOut) return { ok: false, reason: "security \u8D85\u65F6\uFF08\u53EF\u80FD\u5F39\u4E86\u6388\u6743\u6846\u6CA1\u56DE\u5E94\uFF09" };
|
|
1856
|
+
if (run2.code !== 0) return { ok: false, reason: `security \u9000\u51FA\u7801 ${String(run2.code)}` };
|
|
1857
|
+
return { ok: true, value: { saved: true } };
|
|
1858
|
+
} catch {
|
|
1859
|
+
return { ok: false, reason: "security \u65E0\u6CD5\u542F\u52A8" };
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
async function loadKeychainCredentials(io2) {
|
|
1863
|
+
if (!keychainAvailable(io2) || !io2.spawnCapture) return { ok: true, value: null };
|
|
1864
|
+
try {
|
|
1865
|
+
const run2 = await io2.spawnCapture(
|
|
1866
|
+
"security",
|
|
1867
|
+
["find-generic-password", "-s", KEYCHAIN_SERVICE, "-a", KEYCHAIN_ACCOUNT, "-w"],
|
|
1868
|
+
{ timeoutMs: KEYCHAIN_TIMEOUT_MS }
|
|
1869
|
+
);
|
|
1870
|
+
if (run2.timedOut) return { ok: false, reason: "security \u8D85\u65F6\uFF08\u53EF\u80FD\u5F39\u4E86\u6388\u6743\u6846\u6CA1\u56DE\u5E94\uFF09" };
|
|
1871
|
+
if (run2.code !== 0) {
|
|
1872
|
+
if (run2.code === 44) return { ok: true, value: null };
|
|
1873
|
+
return { ok: false, reason: `security \u9000\u51FA\u7801 ${String(run2.code)}` };
|
|
1874
|
+
}
|
|
1875
|
+
const stored = parseStored(run2.stdout);
|
|
1876
|
+
if (!stored) return { ok: false, reason: "\u94A5\u5319\u4E32\u91CC\u7684\u5185\u5BB9\u8BFB\u4E0D\u61C2\uFF0C\u8BF7\u91CD\u65B0 buke login" };
|
|
1877
|
+
return { ok: true, value: stored };
|
|
1878
|
+
} catch {
|
|
1879
|
+
return { ok: false, reason: "security \u65E0\u6CD5\u542F\u52A8" };
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
async function deleteKeychainCredentials(io2) {
|
|
1883
|
+
if (!keychainAvailable(io2) || !io2.spawnCapture) return { ok: true, value: { existed: false } };
|
|
1884
|
+
try {
|
|
1885
|
+
const run2 = await io2.spawnCapture(
|
|
1886
|
+
"security",
|
|
1887
|
+
["delete-generic-password", "-s", KEYCHAIN_SERVICE, "-a", KEYCHAIN_ACCOUNT],
|
|
1888
|
+
{ timeoutMs: KEYCHAIN_TIMEOUT_MS }
|
|
1889
|
+
);
|
|
1890
|
+
if (run2.timedOut) return { ok: false, reason: "security \u8D85\u65F6\uFF08\u53EF\u80FD\u5F39\u4E86\u6388\u6743\u6846\u6CA1\u56DE\u5E94\uFF09" };
|
|
1891
|
+
if (run2.code === 0) return { ok: true, value: { existed: true } };
|
|
1892
|
+
if (run2.code === 44) return { ok: true, value: { existed: false } };
|
|
1893
|
+
return { ok: false, reason: `security \u9000\u51FA\u7801 ${String(run2.code)}` };
|
|
1894
|
+
} catch {
|
|
1895
|
+
return { ok: false, reason: "security \u65E0\u6CD5\u542F\u52A8" };
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1828
1899
|
// src/resolve.ts
|
|
1829
|
-
async function resolveApiKey({ io, out, baseUrl: flag }) {
|
|
1830
|
-
const explicit = explicitBaseUrl(flag,
|
|
1831
|
-
const fromEnv = keyFromEnv(
|
|
1900
|
+
async function resolveApiKey({ io: io2, out, baseUrl: flag }) {
|
|
1901
|
+
const explicit = explicitBaseUrl(flag, io2.env);
|
|
1902
|
+
const fromEnv = keyFromEnv(io2.env);
|
|
1832
1903
|
if (fromEnv !== null) {
|
|
1833
1904
|
assertKeyFormat(fromEnv);
|
|
1834
1905
|
out.protect(fromEnv);
|
|
1835
1906
|
return { apiKey: fromEnv, baseUrl: explicit ?? DEFAULT_BASE_URL, source: "env" };
|
|
1836
1907
|
}
|
|
1837
|
-
const
|
|
1908
|
+
const fromKeychain = await loadKeychainCredentials(io2);
|
|
1909
|
+
const inKeychain = fromKeychain.ok ? fromKeychain.value : null;
|
|
1910
|
+
if (inKeychain) {
|
|
1911
|
+
out.protect(inKeychain.apiKey);
|
|
1912
|
+
if (explicit !== null && explicit !== inKeychain.baseUrl) {
|
|
1913
|
+
throw new CliError({
|
|
1914
|
+
code: "CLI_BASE_URL_MISMATCH",
|
|
1915
|
+
exitCode: EXIT.USAGE,
|
|
1916
|
+
message: `\u672C\u673A\u4FDD\u5B58\u7684\u5BC6\u94A5\u662F\u7ED9 ${inKeychain.baseUrl} \u7528\u7684\uFF0C\u4E0D\u4F1A\u53D1\u5230 ${explicit}\u3002\u8981\u6362\u5730\u5740\u8BF7\u91CD\u65B0\u8FD0\u884C buke login --base-url ${explicit}`
|
|
1917
|
+
});
|
|
1918
|
+
}
|
|
1919
|
+
return { apiKey: inKeychain.apiKey, baseUrl: inKeychain.baseUrl, source: "keychain" };
|
|
1920
|
+
}
|
|
1921
|
+
const stored = await readCredentials(io2, (line) => out.notice(line));
|
|
1838
1922
|
if (!stored) {
|
|
1839
1923
|
throw new CliError({
|
|
1840
1924
|
code: "CLI_NOT_LOGGED_IN",
|
|
@@ -1850,10 +1934,12 @@ async function resolveApiKey({ io, out, baseUrl: flag }) {
|
|
|
1850
1934
|
message: `\u672C\u673A\u4FDD\u5B58\u7684\u5BC6\u94A5\u662F\u7ED9 ${stored.baseUrl} \u7528\u7684\uFF0C\u4E0D\u4F1A\u53D1\u5230 ${explicit}\u3002\u8981\u6362\u5730\u5740\u8BF7\u91CD\u65B0\u8FD0\u884C buke login --base-url ${explicit}`
|
|
1851
1935
|
});
|
|
1852
1936
|
}
|
|
1853
|
-
return { apiKey: stored.apiKey, baseUrl: stored.baseUrl, source: "file", credentialsPath: credentialsPath(
|
|
1937
|
+
return { apiKey: stored.apiKey, baseUrl: stored.baseUrl, source: "file", credentialsPath: credentialsPath(io2) };
|
|
1854
1938
|
}
|
|
1855
1939
|
function keySourceLine(resolved) {
|
|
1856
|
-
|
|
1940
|
+
if (resolved.source === "env") return "\u5BC6\u94A5\u6765\u81EA\uFF1A\u73AF\u5883\u53D8\u91CF BUKE_API_KEY";
|
|
1941
|
+
if (resolved.source === "keychain") return `\u5BC6\u94A5\u6765\u81EA\uFF1AmacOS \u94A5\u5319\u4E32\uFF08bukesiyi-cli/api-key\uFF09`;
|
|
1942
|
+
return `\u5BC6\u94A5\u6765\u81EA\uFF1A${resolved.credentialsPath}`;
|
|
1857
1943
|
}
|
|
1858
1944
|
|
|
1859
1945
|
// src/commands/shared.ts
|
|
@@ -1880,13 +1966,13 @@ function timeoutSecondsOf(values, fallbackSeconds) {
|
|
|
1880
1966
|
}
|
|
1881
1967
|
return parsed;
|
|
1882
1968
|
}
|
|
1883
|
-
async function readPropsArgument(
|
|
1969
|
+
async function readPropsArgument(io2, ref, what) {
|
|
1884
1970
|
if (ref === void 0) {
|
|
1885
1971
|
throw usageError("\u8981\u7ED9 --props\uFF1A\u4E00\u4E2A JSON \u6587\u4EF6\uFF0C\u6216 - \u8868\u793A\u4ECE\u6807\u51C6\u8F93\u5165\u8BFB");
|
|
1886
1972
|
}
|
|
1887
1973
|
let text;
|
|
1888
1974
|
if (ref === "-") {
|
|
1889
|
-
text = await readStdinAll(
|
|
1975
|
+
text = await readStdinAll(io2, MAX_PROPS_BYTES, what);
|
|
1890
1976
|
} else {
|
|
1891
1977
|
let bytes;
|
|
1892
1978
|
try {
|
|
@@ -1914,9 +2000,9 @@ async function readPropsArgument(io, ref, what) {
|
|
|
1914
2000
|
}
|
|
1915
2001
|
return parsed;
|
|
1916
2002
|
}
|
|
1917
|
-
async function readStdinAll(
|
|
1918
|
-
if (
|
|
1919
|
-
const stdin =
|
|
2003
|
+
async function readStdinAll(io2, maxBytes, what) {
|
|
2004
|
+
if (io2.signal?.aborted) throw interruptedError();
|
|
2005
|
+
const stdin = io2.stdin;
|
|
1920
2006
|
if (stdin.readableEnded === true) return "";
|
|
1921
2007
|
const chunks = [];
|
|
1922
2008
|
let size = 0;
|
|
@@ -1928,7 +2014,7 @@ async function readStdinAll(io, maxBytes, what) {
|
|
|
1928
2014
|
const timer = setTimeout(() => {
|
|
1929
2015
|
cleanup();
|
|
1930
2016
|
reject(new CliError({ code: "CLI_STDIN_TIMEOUT", exitCode: EXIT.USAGE, message: `${what}\u6807\u51C6\u8F93\u5165\u7B49\u5F85\u8D85\u65F6\uFF0C\u8BF7\u63D0\u4F9B\u5B8C\u6574 JSON \u5E76\u5173\u95ED\u8F93\u5165\u6D41` }));
|
|
1931
|
-
},
|
|
2017
|
+
}, io2.stdinTimeoutMs ?? DEFAULT_STDIN_TIMEOUT_MS);
|
|
1932
2018
|
const toBuffer2 = (chunk) => typeof chunk === "string" ? Buffer.from(chunk, "utf8") : Buffer.from(chunk);
|
|
1933
2019
|
const onData = (chunk) => {
|
|
1934
2020
|
const piece = toBuffer2(chunk);
|
|
@@ -1951,7 +2037,7 @@ async function readStdinAll(io, maxBytes, what) {
|
|
|
1951
2037
|
const onClose = () => onError(new Error("\u6807\u51C6\u8F93\u5165\u63D0\u524D\u5173\u95ED"));
|
|
1952
2038
|
const cleanup = () => {
|
|
1953
2039
|
clearTimeout(timer);
|
|
1954
|
-
|
|
2040
|
+
io2.signal?.removeEventListener("abort", onAbort);
|
|
1955
2041
|
stdin.removeListener("data", onData);
|
|
1956
2042
|
stdin.removeListener("end", onEnd);
|
|
1957
2043
|
stdin.removeListener("error", onError);
|
|
@@ -1962,27 +2048,27 @@ async function readStdinAll(io, maxBytes, what) {
|
|
|
1962
2048
|
stdin.on("end", onEnd);
|
|
1963
2049
|
stdin.on("error", onError);
|
|
1964
2050
|
stdin.on("close", onClose);
|
|
1965
|
-
|
|
2051
|
+
io2.signal?.addEventListener("abort", onAbort, { once: true });
|
|
1966
2052
|
stdin.resume();
|
|
1967
2053
|
});
|
|
1968
2054
|
return Buffer.concat(chunks).toString("utf8");
|
|
1969
2055
|
}
|
|
1970
|
-
async function sleepFor(
|
|
1971
|
-
if (
|
|
2056
|
+
async function sleepFor(io2, ms) {
|
|
2057
|
+
if (io2.signal?.aborted) throw interruptedError();
|
|
1972
2058
|
let timer;
|
|
1973
2059
|
let stop = () => void 0;
|
|
1974
2060
|
const interrupted = new Promise((_resolve, reject) => {
|
|
1975
2061
|
stop = () => reject(interruptedError());
|
|
1976
|
-
|
|
2062
|
+
io2.signal?.addEventListener("abort", stop, { once: true });
|
|
1977
2063
|
});
|
|
1978
|
-
const sleeping =
|
|
2064
|
+
const sleeping = io2.sleep ? io2.sleep(ms) : new Promise((resolve3) => {
|
|
1979
2065
|
timer = setTimeout(resolve3, ms);
|
|
1980
2066
|
});
|
|
1981
2067
|
try {
|
|
1982
2068
|
await Promise.race([sleeping, interrupted]);
|
|
1983
2069
|
} finally {
|
|
1984
2070
|
clearTimeout(timer);
|
|
1985
|
-
|
|
2071
|
+
io2.signal?.removeEventListener("abort", stop);
|
|
1986
2072
|
}
|
|
1987
2073
|
}
|
|
1988
2074
|
async function readImageFile(path) {
|
|
@@ -2028,7 +2114,7 @@ async function readUploadFile(path) {
|
|
|
2028
2114
|
// src/commands/shorts.ts
|
|
2029
2115
|
import { createHash as createHash2 } from "node:crypto";
|
|
2030
2116
|
import { writeFile } from "node:fs/promises";
|
|
2031
|
-
var SUBCOMMANDS = "catalog\u3001upload\u3001quote\u3001order\u3001status\u3001download \u548C cancel";
|
|
2117
|
+
var SUBCOMMANDS = "catalog\u3001upload\u3001quote\u3001order\u3001result\u3001status\u3001download \u548C cancel";
|
|
2032
2118
|
async function shorts(context) {
|
|
2033
2119
|
timeoutSecondsOf(context.values, DEFAULT_WAIT_TIMEOUT_MS / 1e3);
|
|
2034
2120
|
const { args } = context;
|
|
@@ -2040,6 +2126,7 @@ async function shorts(context) {
|
|
|
2040
2126
|
if (subcommand === "upload") return upload(context, args[1]);
|
|
2041
2127
|
if (subcommand === "quote") return quote(context);
|
|
2042
2128
|
if (subcommand === "order") return order(context);
|
|
2129
|
+
if (subcommand === "result") return result(context, args[1]);
|
|
2043
2130
|
if (subcommand === "status") return status(context, args[1]);
|
|
2044
2131
|
if (subcommand === "download") return download(context, args[1]);
|
|
2045
2132
|
if (subcommand === "cancel") return cancel(context, args[1]);
|
|
@@ -2058,11 +2145,11 @@ function templateOf(values) {
|
|
|
2058
2145
|
}
|
|
2059
2146
|
return templateId;
|
|
2060
2147
|
}
|
|
2061
|
-
function waitControls(
|
|
2148
|
+
function waitControls(io2, values, note) {
|
|
2062
2149
|
return {
|
|
2063
2150
|
timeoutMs: timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3) * 1e3,
|
|
2064
|
-
now:
|
|
2065
|
-
sleep: (ms) => sleepFor(
|
|
2151
|
+
now: io2.now ?? (() => /* @__PURE__ */ new Date()),
|
|
2152
|
+
sleep: (ms) => sleepFor(io2, ms),
|
|
2066
2153
|
note
|
|
2067
2154
|
};
|
|
2068
2155
|
}
|
|
@@ -2099,9 +2186,9 @@ function orderLines(order2) {
|
|
|
2099
2186
|
];
|
|
2100
2187
|
}
|
|
2101
2188
|
async function catalog(context) {
|
|
2102
|
-
const { io, out } = context;
|
|
2189
|
+
const { io: io2, out } = context;
|
|
2103
2190
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2104
|
-
const { view, raw } = await getTemplateShortCatalog(baseUrl, apiKey,
|
|
2191
|
+
const { view, raw } = await getTemplateShortCatalog(baseUrl, apiKey, io2);
|
|
2105
2192
|
out.result(
|
|
2106
2193
|
[
|
|
2107
2194
|
`${singleLine(view.category.name)}\uFF08${singleLine(view.category.badge)}\uFF0C\u5171 ${view.templates.length} \u4E2A\u6A21\u677F\uFF09`,
|
|
@@ -2115,14 +2202,14 @@ async function catalog(context) {
|
|
|
2115
2202
|
);
|
|
2116
2203
|
}
|
|
2117
2204
|
async function upload(context, rawPath) {
|
|
2118
|
-
const { io, out } = context;
|
|
2205
|
+
const { io: io2, out } = context;
|
|
2119
2206
|
if (rawPath === void 0 || rawPath.trim() === "") {
|
|
2120
2207
|
throw usageError("\u8981\u7ED9\u56FE\u7247\u6587\u4EF6\u8DEF\u5F84");
|
|
2121
2208
|
}
|
|
2122
2209
|
const image = await readImageFile(rawPath);
|
|
2123
2210
|
const idempotencyKey = idempotencyKeyOf(context.values);
|
|
2124
2211
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2125
|
-
const { view, raw } = await uploadTemplateShortAsset(baseUrl, apiKey, image.bytes, image.contentType, idempotencyKey,
|
|
2212
|
+
const { view, raw } = await uploadTemplateShortAsset(baseUrl, apiKey, image.bytes, image.contentType, idempotencyKey, io2);
|
|
2126
2213
|
out.result(
|
|
2127
2214
|
[
|
|
2128
2215
|
`\u5DF2\u4E0A\u4F20\uFF1A${singleLine(view.url)}`,
|
|
@@ -2133,12 +2220,12 @@ async function upload(context, rawPath) {
|
|
|
2133
2220
|
);
|
|
2134
2221
|
}
|
|
2135
2222
|
async function quote(context) {
|
|
2136
|
-
const { io, out, values } = context;
|
|
2223
|
+
const { io: io2, out, values } = context;
|
|
2137
2224
|
const templateId = templateOf(values);
|
|
2138
|
-
const props = await readPropsArgument(
|
|
2225
|
+
const props = await readPropsArgument(io2, textOption(values, "props"), "\u6A21\u677F\u53C2\u6570\uFF08--props\uFF09");
|
|
2139
2226
|
const idempotencyKey = idempotencyKeyOf(values);
|
|
2140
2227
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2141
|
-
const { view, raw } = await quoteTemplateShort(baseUrl, apiKey, templateId, props, idempotencyKey,
|
|
2228
|
+
const { view, raw } = await quoteTemplateShort(baseUrl, apiKey, templateId, props, idempotencyKey, io2);
|
|
2142
2229
|
out.result(
|
|
2143
2230
|
[
|
|
2144
2231
|
`\u6A21\u677F\uFF1A${singleLine(view.templateId)}\uFF0C\u65F6\u957F ${Math.round(view.durationMilliseconds / 100) / 10} \u79D2`,
|
|
@@ -2151,23 +2238,23 @@ async function quote(context) {
|
|
|
2151
2238
|
);
|
|
2152
2239
|
}
|
|
2153
2240
|
async function order(context) {
|
|
2154
|
-
const { io, out, values } = context;
|
|
2241
|
+
const { io: io2, out, values } = context;
|
|
2155
2242
|
const templateId = templateOf(values);
|
|
2156
|
-
const props = await readPropsArgument(
|
|
2243
|
+
const props = await readPropsArgument(io2, textOption(values, "props"), "\u6A21\u677F\u53C2\u6570\uFF08--props\uFF09");
|
|
2157
2244
|
const quoteHash = textOption(values, "quote-hash");
|
|
2158
2245
|
const idempotencyKey = idempotencyKeyOf(values);
|
|
2159
2246
|
const shouldWait = values.wait === true;
|
|
2160
|
-
const controls = shouldWait ? waitControls(
|
|
2247
|
+
const controls = shouldWait ? waitControls(io2, values, (line) => out.notice(line)) : void 0;
|
|
2161
2248
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2162
2249
|
const accepted = await retainSubmissionOnError(
|
|
2163
2250
|
"shorts",
|
|
2164
2251
|
idempotencyKey,
|
|
2165
2252
|
baseUrl,
|
|
2166
|
-
() => createTemplateShortOrder(baseUrl, apiKey, templateId, props, quoteHash, idempotencyKey,
|
|
2253
|
+
() => createTemplateShortOrder(baseUrl, apiKey, templateId, props, quoteHash, idempotencyKey, io2)
|
|
2167
2254
|
);
|
|
2168
2255
|
const final = shouldWait ? await retainTaskOnError(
|
|
2169
2256
|
() => ({ ...taskRecovery("shorts", accepted.view.id, accepted.view.status, baseUrl), idempotencyKey }),
|
|
2170
|
-
async () => settleOrder(await awaitTemplateShortOrder(baseUrl, apiKey, accepted,
|
|
2257
|
+
async () => settleOrder(await awaitTemplateShortOrder(baseUrl, apiKey, accepted, io2, controls), baseUrl)
|
|
2171
2258
|
) : accepted;
|
|
2172
2259
|
out.result([...orderLines(final.view), `\u5E42\u7B49\u952E\uFF1A${idempotencyKey}`], {
|
|
2173
2260
|
order: final.raw.order,
|
|
@@ -2176,34 +2263,58 @@ async function order(context) {
|
|
|
2176
2263
|
});
|
|
2177
2264
|
}
|
|
2178
2265
|
async function status(context, rawId) {
|
|
2179
|
-
const { io, out, values } = context;
|
|
2266
|
+
const { io: io2, out, values } = context;
|
|
2180
2267
|
const orderId = orderIdOf(rawId);
|
|
2181
2268
|
const shouldWait = values.wait === true;
|
|
2182
|
-
const controls = shouldWait ? waitControls(
|
|
2269
|
+
const controls = shouldWait ? waitControls(io2, values, (line) => out.notice(line)) : void 0;
|
|
2183
2270
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2184
|
-
const current = await getTemplateShortOrder(baseUrl, apiKey, orderId,
|
|
2185
|
-
const final = shouldWait ? settleOrder(await awaitTemplateShortOrder(baseUrl, apiKey, current,
|
|
2271
|
+
const current = await getTemplateShortOrder(baseUrl, apiKey, orderId, io2);
|
|
2272
|
+
const final = shouldWait ? settleOrder(await awaitTemplateShortOrder(baseUrl, apiKey, current, io2, controls), baseUrl) : current;
|
|
2186
2273
|
out.result(orderLines(final.view), { order: final.raw.order, ...shouldWait ? { waited: true } : {} });
|
|
2187
2274
|
}
|
|
2275
|
+
async function result(context, rawId) {
|
|
2276
|
+
const { io: io2, out, values } = context;
|
|
2277
|
+
const orderId = orderIdOf(rawId);
|
|
2278
|
+
const shouldWait = values.wait === true;
|
|
2279
|
+
const controls = shouldWait ? waitControls(io2, values, (line) => out.notice(line)) : void 0;
|
|
2280
|
+
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2281
|
+
const current = await getTemplateShortOrder(baseUrl, apiKey, orderId, io2);
|
|
2282
|
+
const final = settleOrder(shouldWait ? await awaitTemplateShortOrder(baseUrl, apiKey, current, io2, controls) : { value: current, timedOut: false }, baseUrl);
|
|
2283
|
+
if (final.view.status !== "succeeded") {
|
|
2284
|
+
out.result(orderLines(final.view), { order: final.raw.order, ...shouldWait ? { waited: true } : {} });
|
|
2285
|
+
return;
|
|
2286
|
+
}
|
|
2287
|
+
const media = await downloadTemplateShort(baseUrl, apiKey, orderId, io2);
|
|
2288
|
+
const defaultName = `template-short-${orderId}.mp4`;
|
|
2289
|
+
const saved = await saveDownload(textOption(values, "out") ?? defaultName, media.bytes);
|
|
2290
|
+
out.result(
|
|
2291
|
+
[...orderLines(final.view), `\u5DF2\u4E0B\u8F7D\uFF1A${saved.path}`, `\u5927\u5C0F\uFF1A${saved.bytes} \u5B57\u8282`, `\u6821\u9A8C\uFF1Asha256 ${saved.sha256}`],
|
|
2292
|
+
{
|
|
2293
|
+
order: final.raw.order,
|
|
2294
|
+
download: { ...saved, filename: media.filename ?? defaultName },
|
|
2295
|
+
...shouldWait ? { waited: true } : {}
|
|
2296
|
+
}
|
|
2297
|
+
);
|
|
2298
|
+
}
|
|
2188
2299
|
async function cancel(context, rawId) {
|
|
2189
|
-
const { io, out, values } = context;
|
|
2300
|
+
const { io: io2, out, values } = context;
|
|
2190
2301
|
const orderId = orderIdOf(rawId);
|
|
2191
2302
|
const idempotencyKey = idempotencyKeyOf(values);
|
|
2192
2303
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2193
|
-
const canceled = await cancelTemplateShortOrder(baseUrl, apiKey, orderId, idempotencyKey,
|
|
2304
|
+
const canceled = await cancelTemplateShortOrder(baseUrl, apiKey, orderId, idempotencyKey, io2);
|
|
2194
2305
|
out.result([...orderLines(canceled.view), `\u5E42\u7B49\u952E\uFF1A${idempotencyKey}`], { order: canceled.raw.order, idempotencyKey });
|
|
2195
2306
|
}
|
|
2196
2307
|
async function download(context, rawId) {
|
|
2197
|
-
const { io, out, values } = context;
|
|
2308
|
+
const { io: io2, out, values } = context;
|
|
2198
2309
|
const orderId = orderIdOf(rawId);
|
|
2199
2310
|
const defaultName = `template-short-${orderId}.mp4`;
|
|
2200
2311
|
const target = textOption(values, "out") ?? defaultName;
|
|
2201
2312
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2202
|
-
const
|
|
2203
|
-
const saved = await saveDownload(target,
|
|
2313
|
+
const result4 = await downloadTemplateShort(baseUrl, apiKey, orderId, io2);
|
|
2314
|
+
const saved = await saveDownload(target, result4.bytes);
|
|
2204
2315
|
out.result(
|
|
2205
2316
|
[`\u5DF2\u4E0B\u8F7D\uFF1A${saved.path}`, `\u5927\u5C0F\uFF1A${saved.bytes} \u5B57\u8282`, `\u6821\u9A8C\uFF1Asha256 ${saved.sha256}`],
|
|
2206
|
-
{ download: { ...saved, filename:
|
|
2317
|
+
{ download: { ...saved, filename: result4.filename ?? defaultName } }
|
|
2207
2318
|
);
|
|
2208
2319
|
}
|
|
2209
2320
|
async function saveDownload(target, bytes) {
|
|
@@ -2230,6 +2341,7 @@ var graphicCommand = {
|
|
|
2230
2341
|
"",
|
|
2231
2342
|
"create --text <\u5236\u4F5C\u8981\u6C42> [--product <\u4EA7\u54C1ID>] [--model <\u6A21\u578B>] [--aspect-ratio <\u753B\u5E45>] [--wait]",
|
|
2232
2343
|
"list | templates | status <\u9879\u76EEID> [--wait] | plan <\u9879\u76EEID> | versions <\u9879\u76EEID>",
|
|
2344
|
+
"result <\u9879\u76EEID> [--wait] [--timeout <\u79D2>] [--out <\u76EE\u5F55>]\uFF1A\u67E5\u72B6\u6001\uFF0C\u5DF2\u6709\u56FE\u7247\u65F6\u81EA\u52A8\u4E0B\u8F7D\u5168\u90E8\u56FE\u7247",
|
|
2233
2345
|
"message <\u9879\u76EEID> --text <\u8981\u6C42> [--attachment-ids <ID,ID>] [--edit-image <\u56FE\u7247ID>] [--source-image <\u56FE\u7247ID>] [--choice <\u9009\u9879ID>] [--wait]",
|
|
2234
2346
|
"retry <\u9879\u76EEID> <\u6D88\u606FID> [--wait]\uFF1A\u91CD\u8BD5\u539F\u514D\u8D39\u6587\u6848\u56DE\u5408\u3002\u6D88\u606F\u4E0D\u4F1A\u81EA\u52A8\u6388\u6743\u51FA\u56FE\u3002",
|
|
2235
2347
|
"quote <\u9879\u76EEID> [--image-indexes <1,2>]\uFF1A\u8BFB\u53D6\u6240\u9009\u65B9\u6848\u62A5\u4EF7\u3002",
|
|
@@ -2253,9 +2365,9 @@ function required2(value, label) {
|
|
|
2253
2365
|
}
|
|
2254
2366
|
function indexes(value) {
|
|
2255
2367
|
if (value === void 0) return void 0;
|
|
2256
|
-
const
|
|
2257
|
-
if (!
|
|
2258
|
-
return
|
|
2368
|
+
const result4 = value.split(",").map((item) => Number(item.trim()));
|
|
2369
|
+
if (!result4.length || result4.some((item) => !Number.isInteger(item) || item < 1) || new Set(result4).size !== result4.length) throw usageError("--image-indexes \u5FC5\u987B\u662F\u4E0D\u91CD\u590D\u7684\u6B63\u6574\u6570\uFF0C\u4EE5\u9017\u53F7\u5206\u9694");
|
|
2370
|
+
return result4;
|
|
2259
2371
|
}
|
|
2260
2372
|
function selection(context) {
|
|
2261
2373
|
const editImage = textOption(context.values, "edit-image");
|
|
@@ -2306,10 +2418,10 @@ async function uploadFile(path) {
|
|
|
2306
2418
|
return bytes;
|
|
2307
2419
|
}
|
|
2308
2420
|
async function graphic(context) {
|
|
2309
|
-
const { args, values, io, out } = context;
|
|
2421
|
+
const { args, values, io: io2, out } = context;
|
|
2310
2422
|
timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3);
|
|
2311
2423
|
const command = required2(args[0], "\u56FE\u6587\u5B50\u547D\u4EE4\uFF1B\u8FD0\u884C buke graphic --help \u67E5\u770B\u8BF4\u660E");
|
|
2312
|
-
const known = ["create", "list", "templates", "status", "message", "retry", "plan", "quote", "generate", "model", "quality", "bind-product", "attachments", "upload", "versions", "download", "save-edit", "mask", "cancel"];
|
|
2424
|
+
const known = ["create", "list", "templates", "status", "result", "message", "retry", "plan", "quote", "generate", "model", "quality", "bind-product", "attachments", "upload", "versions", "download", "save-edit", "mask", "cancel"];
|
|
2313
2425
|
if (!known.includes(command)) throw usageError(`\u672A\u77E5\u56FE\u6587\u5B50\u547D\u4EE4\uFF1A${command}`);
|
|
2314
2426
|
const id = ["create", "list", "templates"].includes(command) ? void 0 : required2(args[1], "\u56FE\u6587\u9879\u76EE ID");
|
|
2315
2427
|
if (["quote", "generate"].includes(command)) {
|
|
@@ -2325,9 +2437,9 @@ async function graphic(context) {
|
|
|
2325
2437
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2326
2438
|
const path = id ? graphicPath(id) : "/api/open/v1/graphic/runs";
|
|
2327
2439
|
if (["list", "templates"].includes(command)) {
|
|
2328
|
-
const
|
|
2329
|
-
const rows =
|
|
2330
|
-
out.result([...rows.map((row) => `${singleLine(String(row.id ?? row.slug))} ${singleLine(String(row.title ?? row.name ?? ""))} ${singleLine(String(row.status ?? ""))}`), ...typeof
|
|
2440
|
+
const result4 = graphicDocument((await getJson(baseUrl, apiKey, command === "list" ? `${path}?${new URLSearchParams(Object.fromEntries(["limit", "cursor"].flatMap((name2) => textOption(values, name2) ? [[name2, textOption(values, name2)]] : []))).toString()}` : "/api/open/v1/graphic/templates", io2)).body);
|
|
2441
|
+
const rows = result4[command === "list" ? "runs" : "templates"] ?? [];
|
|
2442
|
+
out.result([...rows.map((row) => `${singleLine(String(row.id ?? row.slug))} ${singleLine(String(row.title ?? row.name ?? ""))} ${singleLine(String(row.status ?? ""))}`), ...typeof result4.nextCursor === "string" ? [`\u4E0B\u4E00\u9875\uFF1Abuke graphic list --cursor ${singleLine(result4.nextCursor)}`] : []], result4);
|
|
2331
2443
|
return;
|
|
2332
2444
|
}
|
|
2333
2445
|
if (command === "create") {
|
|
@@ -2339,9 +2451,32 @@ async function graphic(context) {
|
|
|
2339
2451
|
aspectRatio: textOption(values, "aspect-ratio"),
|
|
2340
2452
|
templateId: textOption(values, "template")
|
|
2341
2453
|
};
|
|
2342
|
-
const initial = await retainSubmissionOnError("graphic", key, baseUrl, async () => graphicRun((await postJson(baseUrl, apiKey, path, request, key,
|
|
2454
|
+
const initial = await retainSubmissionOnError("graphic", key, baseUrl, async () => graphicRun((await postJson(baseUrl, apiKey, path, request, key, io2)).body));
|
|
2343
2455
|
const run2 = await retainTaskOnError(() => ({ ...taskRecovery("graphic", initial.id, initial.status, baseUrl), idempotencyKey: key }), () => wait(context, baseUrl, apiKey, initial));
|
|
2344
|
-
|
|
2456
|
+
const webLink = `${baseUrl}/graphic/runs/${encodeURIComponent(run2.id)}`;
|
|
2457
|
+
out.result([...lines(run2), `\u5E42\u7B49\u952E\uFF1A${key}`, `\u7F51\u9875\u67E5\u770B\uFF1A${webLink}`], { run: run2, idempotencyKey: key, webLink });
|
|
2458
|
+
return;
|
|
2459
|
+
}
|
|
2460
|
+
if (command === "result") {
|
|
2461
|
+
const run2 = await wait(context, baseUrl, apiKey, await getGraphicRun(baseUrl, apiKey, id, io2));
|
|
2462
|
+
const webLink = `${baseUrl}/graphic/runs/${encodeURIComponent(run2.id)}`;
|
|
2463
|
+
const waited = values.wait === true;
|
|
2464
|
+
if (!run2.images.length) {
|
|
2465
|
+
out.result([...lines(run2), `\u7F51\u9875\u67E5\u770B\uFF1A${webLink}`], { run: run2, ...waited ? { waited: true } : {}, webLink });
|
|
2466
|
+
return;
|
|
2467
|
+
}
|
|
2468
|
+
const directory = resolve(textOption(values, "out") ?? `graphic-${run2.id}`);
|
|
2469
|
+
await mkdir2(directory, { recursive: true });
|
|
2470
|
+
const downloads = [];
|
|
2471
|
+
for (const image of run2.images) {
|
|
2472
|
+
const imageId = required2(typeof image.id === "string" ? image.id : void 0, "\u56FE\u7247 ID");
|
|
2473
|
+
const file = await downloadAssetFile(baseUrl, apiKey, `${path}/images/${encodeURIComponent(imageId)}/download`, io2, { allowedMimeTypes: imageMimes, requireSha256: true });
|
|
2474
|
+
downloads.push(await saveDownload(join2(directory, basename(file.filename ?? `${imageId}.png`)), file.bytes));
|
|
2475
|
+
}
|
|
2476
|
+
out.result(
|
|
2477
|
+
[...lines(run2), ...downloads.map((item) => `\u5DF2\u4E0B\u8F7D\uFF1A${item.path}\uFF08${item.bytes} \u5B57\u8282\uFF09`), `\u7F51\u9875\u67E5\u770B\uFF1A${webLink}`],
|
|
2478
|
+
{ run: run2, downloads, ...waited ? { waited: true } : {}, webLink }
|
|
2479
|
+
);
|
|
2345
2480
|
return;
|
|
2346
2481
|
}
|
|
2347
2482
|
if (command === "download") {
|
|
@@ -2350,20 +2485,20 @@ async function graphic(context) {
|
|
|
2350
2485
|
const results = [];
|
|
2351
2486
|
if (values.all === true) {
|
|
2352
2487
|
const directory = resolve(required2(textOption(values, "out"), " --out <\u76EE\u5F55>"));
|
|
2353
|
-
const run2 = await getGraphicRun(baseUrl, apiKey, id,
|
|
2488
|
+
const run2 = await getGraphicRun(baseUrl, apiKey, id, io2);
|
|
2354
2489
|
if (!run2.images.length) throw usageError("\u8BE5\u9879\u76EE\u6682\u65E0\u53EF\u4E0B\u8F7D\u7684\u56FE\u7247");
|
|
2355
2490
|
await mkdir2(directory, { recursive: true });
|
|
2356
2491
|
for (const image of run2.images) {
|
|
2357
2492
|
const imageId = required2(typeof image.id === "string" ? image.id : void 0, "\u56FE\u7247 ID");
|
|
2358
|
-
const file = await downloadAssetFile(baseUrl, apiKey, `${path}/images/${encodeURIComponent(imageId)}/download`,
|
|
2493
|
+
const file = await downloadAssetFile(baseUrl, apiKey, `${path}/images/${encodeURIComponent(imageId)}/download`, io2, { allowedMimeTypes: imageMimes, requireSha256: true });
|
|
2359
2494
|
results.push(await saveDownload(join2(directory, basename(file.filename ?? `${imageId}.png`)), file.bytes));
|
|
2360
2495
|
}
|
|
2361
2496
|
} else {
|
|
2362
2497
|
const imageId = attachment ?? required2(args[2], "\u56FE\u7247 ID\uFF0C\u6216\u4F7F\u7528 --all");
|
|
2363
|
-
const file = await downloadAssetFile(baseUrl, apiKey, `${path}/${attachment ? "attachments" : "images"}/${encodeURIComponent(imageId)}/download`,
|
|
2498
|
+
const file = await downloadAssetFile(baseUrl, apiKey, `${path}/${attachment ? "attachments" : "images"}/${encodeURIComponent(imageId)}/download`, io2, { allowedMimeTypes: attachment ? documentMimes : imageMimes, requireSha256: !attachment });
|
|
2364
2499
|
results.push(await saveDownload(resolve(textOption(values, "out") ?? basename(file.filename ?? `${imageId}.png`)), file.bytes));
|
|
2365
2500
|
}
|
|
2366
|
-
out.result(results.map((
|
|
2501
|
+
out.result(results.map((result4) => `\u5DF2\u4E0B\u8F7D\uFF1A${result4.path}\uFF08${result4.bytes} \u5B57\u8282\uFF09`), { downloads: results });
|
|
2367
2502
|
return;
|
|
2368
2503
|
}
|
|
2369
2504
|
if (["quote", "generate"].includes(command)) {
|
|
@@ -2371,8 +2506,8 @@ async function graphic(context) {
|
|
|
2371
2506
|
let submitted = false;
|
|
2372
2507
|
let accepted = false;
|
|
2373
2508
|
try {
|
|
2374
|
-
current = await getGraphicRun(baseUrl, apiKey, id,
|
|
2375
|
-
const quote3 = await getGraphicQuote(baseUrl, apiKey, id, selected, key,
|
|
2509
|
+
current = await getGraphicRun(baseUrl, apiKey, id, io2);
|
|
2510
|
+
const quote3 = await getGraphicQuote(baseUrl, apiKey, id, selected, key, io2);
|
|
2376
2511
|
if (expectedQuoteHash !== void 0 && expectedQuoteHash !== quote3.quoteHash) throw new CliError({ code: "OPEN_API_QUOTE_CHANGED", exitCode: EXIT.QUOTE_CHANGED, message: "\u62A5\u4EF7\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u67E5\u770B\u5F53\u524D\u62A5\u4EF7\u540E\u786E\u8BA4" });
|
|
2377
2512
|
if (command === "quote" || values.yes !== true) {
|
|
2378
2513
|
out.result([
|
|
@@ -2384,11 +2519,12 @@ async function graphic(context) {
|
|
|
2384
2519
|
return;
|
|
2385
2520
|
}
|
|
2386
2521
|
submitted = true;
|
|
2387
|
-
const initial = graphicRun((await postJson(baseUrl, apiKey, `${path}/generate`, { ...selected, quoteHash: quote3.quoteHash, confirmed: true }, key,
|
|
2522
|
+
const initial = graphicRun((await postJson(baseUrl, apiKey, `${path}/generate`, { ...selected, quoteHash: quote3.quoteHash, confirmed: true }, key, io2)).body);
|
|
2388
2523
|
current = initial;
|
|
2389
2524
|
accepted = true;
|
|
2390
2525
|
const run2 = await wait(context, baseUrl, apiKey, initial);
|
|
2391
|
-
|
|
2526
|
+
const webLink = `${baseUrl}/graphic/runs/${encodeURIComponent(run2.id)}`;
|
|
2527
|
+
out.result([...lines(run2), `\u5E42\u7B49\u952E\uFF1A${key}`, `\u7F51\u9875\u67E5\u770B\uFF1A${webLink}`], { run: run2, idempotencyKey: key, webLink });
|
|
2392
2528
|
return;
|
|
2393
2529
|
} catch (error) {
|
|
2394
2530
|
const failure = toCliError(error);
|
|
@@ -2406,23 +2542,26 @@ async function graphic(context) {
|
|
|
2406
2542
|
await retainTaskOnError(() => ({ ...taskRecovery("graphic", id, void 0, baseUrl), acceptance: "unknown", idempotencyKey: key }), async () => {
|
|
2407
2543
|
let body;
|
|
2408
2544
|
if (["status", "plan", "versions"].includes(command)) {
|
|
2409
|
-
const run2 = await wait(context, baseUrl, apiKey, await getGraphicRun(baseUrl, apiKey, id,
|
|
2545
|
+
const run2 = await wait(context, baseUrl, apiKey, await getGraphicRun(baseUrl, apiKey, id, io2));
|
|
2410
2546
|
if (command === "plan") out.result([`\u65B9\u6848\u7248\u672C\uFF1A${run2.planVersion}`, ...run2.imagePlan.map((item) => `\u7B2C ${item.position} \u5F20\uFF1A${item.aspectRatio} ${singleLine(String(item.textOnImage ?? ""))}`)], { id, planVersion: run2.planVersion, copy: run2.copy, imagePlan: run2.imagePlan });
|
|
2411
2547
|
else if (command === "versions") out.result(run2.images.map((image) => `${image.id} ${image.currentVersion ? "\u5F53\u524D\u7248\u672C" : "\u5386\u53F2\u7248\u672C"} ${image.width}\xD7${image.height}`), { id, images: run2.images });
|
|
2412
|
-
else
|
|
2548
|
+
else {
|
|
2549
|
+
const webLink = `${baseUrl}/graphic/runs/${encodeURIComponent(run2.id)}`;
|
|
2550
|
+
out.result([...lines(run2), `\u7F51\u9875\u67E5\u770B\uFF1A${webLink}`], { run: run2, webLink });
|
|
2551
|
+
}
|
|
2413
2552
|
return;
|
|
2414
2553
|
}
|
|
2415
2554
|
if (command === "message") {
|
|
2416
2555
|
const attachmentIds = textOption(values, "attachment-ids")?.split(",").map((item) => item.trim()).filter(Boolean);
|
|
2417
2556
|
const message2 = textOption(values, "text");
|
|
2418
2557
|
if (!message2 && !attachmentIds?.length) throw usageError("\u8BF7\u63D0\u4F9B --text \u6216 --attachment-ids");
|
|
2419
|
-
body = (await postJson(baseUrl, apiKey, `${path}/messages`, { text: message2, attachmentIds, templateId: textOption(values, "template"), editImageId: textOption(values, "edit-image"), sourceImageId: textOption(values, "source-image"), choice: textOption(values, "choice") }, key,
|
|
2420
|
-
} else if (command === "retry") body = (await postJson(baseUrl, apiKey, `${path}/messages/${encodeURIComponent(required2(args[2], "\u6D88\u606F ID"))}/retry`, {}, key,
|
|
2558
|
+
body = (await postJson(baseUrl, apiKey, `${path}/messages`, { text: message2, attachmentIds, templateId: textOption(values, "template"), editImageId: textOption(values, "edit-image"), sourceImageId: textOption(values, "source-image"), choice: textOption(values, "choice") }, key, io2)).body;
|
|
2559
|
+
} else if (command === "retry") body = (await postJson(baseUrl, apiKey, `${path}/messages/${encodeURIComponent(required2(args[2], "\u6D88\u606F ID"))}/retry`, {}, key, io2)).body;
|
|
2421
2560
|
else if (["model", "quality", "bind-product"].includes(command)) {
|
|
2422
2561
|
const option = command === "bind-product" ? "product" : command;
|
|
2423
2562
|
const field = command === "bind-product" ? "productId" : command === "model" ? "imageModel" : "quality";
|
|
2424
|
-
body = (await patchJson(baseUrl, apiKey, path, { [field]: required2(textOption(values, option), ` --${option}`) }, key,
|
|
2425
|
-
} else if (command === "cancel") body = (await postJson(baseUrl, apiKey, `${path}/generation-orders/${encodeURIComponent(required2(textOption(values, "generation-order"), " --generation-order <\u8BA2\u5355ID>"))}/cancel`, {}, key,
|
|
2563
|
+
body = (await patchJson(baseUrl, apiKey, path, { [field]: required2(textOption(values, option), ` --${option}`) }, key, io2)).body;
|
|
2564
|
+
} else if (command === "cancel") body = (await postJson(baseUrl, apiKey, `${path}/generation-orders/${encodeURIComponent(required2(textOption(values, "generation-order"), " --generation-order <\u8BA2\u5355ID>"))}/cancel`, {}, key, io2)).body;
|
|
2426
2565
|
else if (command === "attachments") {
|
|
2427
2566
|
const params = new URLSearchParams();
|
|
2428
2567
|
for (const id2 of textOption(values, "attachment-ids")?.split(",") ?? []) params.append("attachmentId", id2.trim());
|
|
@@ -2430,12 +2569,12 @@ async function graphic(context) {
|
|
|
2430
2569
|
const value = textOption(values, name2);
|
|
2431
2570
|
if (value !== void 0) params.set(name2, value);
|
|
2432
2571
|
}
|
|
2433
|
-
body = (await getJson(baseUrl, apiKey, `${path}/attachments${params.size ? `?${params}` : ""}`,
|
|
2572
|
+
body = (await getJson(baseUrl, apiKey, `${path}/attachments${params.size ? `?${params}` : ""}`, io2)).body;
|
|
2434
2573
|
} else {
|
|
2435
2574
|
const filename = required2(textOption(values, "file"), " --file <\u6587\u4EF6\u8DEF\u5F84>");
|
|
2436
2575
|
const bytes = await uploadFile(filename);
|
|
2437
|
-
if (command === "upload") body = (await putRaw(baseUrl, apiKey, `${path}/attachments?name=${encodeURIComponent(basename(filename))}`, bytes, textOption(values, "mime") ?? "application/octet-stream", key,
|
|
2438
|
-
else body = (await postRaw(baseUrl, apiKey, `${path}/images/${encodeURIComponent(required2(args[2], "\u56FE\u7247 ID"))}/${command === "mask" ? "masks" : "edits"}`, bytes, textOption(values, "mime"), key,
|
|
2576
|
+
if (command === "upload") body = (await putRaw(baseUrl, apiKey, `${path}/attachments?name=${encodeURIComponent(basename(filename))}`, bytes, textOption(values, "mime") ?? "application/octet-stream", key, io2)).body;
|
|
2577
|
+
else body = (await postRaw(baseUrl, apiKey, `${path}/images/${encodeURIComponent(required2(args[2], "\u56FE\u7247 ID"))}/${command === "mask" ? "masks" : "edits"}`, bytes, textOption(values, "mime"), key, io2)).body;
|
|
2439
2578
|
}
|
|
2440
2579
|
const document = graphicDocument(body);
|
|
2441
2580
|
if (document.run) {
|
|
@@ -2484,7 +2623,6 @@ var WEB_OPERATIONS = [
|
|
|
2484
2623
|
{ "id": "auth.emailAuthStatus", "method": "GET", "path": "/api/auth/email/status", "source": "web-src/src/lib/api.ts:1684", "group": "auth", "description": "\u767B\u5F55\uFF1A\u67E5\u8BE2\u90AE\u7BB1 / \u72B6\u6001", "public": true },
|
|
2485
2624
|
{ "id": "auth.login", "method": "POST", "path": "/api/auth/login", "source": "web-src/src/lib/api.ts:1674", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u8BA4\u8BC1 / \u767B\u5F55", "body": "json", "public": true, "sessionResponse": true },
|
|
2486
2625
|
{ "id": "auth.logout", "method": "POST", "path": "/api/auth/logout", "source": "web-src/src/lib/api.ts:1697", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u8BA4\u8BC1 / \u9000\u51FA\u767B\u5F55", "body": "json" },
|
|
2487
|
-
{ "id": "auth.register", "method": "POST", "path": "/api/auth/register", "source": "web-src/src/lib/api.ts:1677", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u8BA4\u8BC1 / \u6CE8\u518C", "body": "json", "public": true, "sessionResponse": true },
|
|
2488
2626
|
{ "id": "auth.registerWithEmail", "method": "POST", "path": "/api/auth/register/email", "source": "web-src/src/lib/api.ts:1688", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u6CE8\u518C / \u90AE\u7BB1", "body": "json", "public": true, "sessionResponse": true },
|
|
2489
2627
|
{ "id": "auth.registerWithSms", "method": "POST", "path": "/api/auth/register/sms", "source": "web-src/src/lib/api.ts:1682", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u6CE8\u518C / \u77ED\u4FE1", "body": "json", "public": true, "sessionResponse": true },
|
|
2490
2628
|
{ "id": "auth.sendRegistrationEmail", "method": "POST", "path": "/api/auth/email/register-code", "source": "web-src/src/lib/api.ts:1686", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u90AE\u7BB1 / \u6CE8\u518C\u9A8C\u8BC1\u7801", "body": "json", "public": true },
|
|
@@ -2804,21 +2942,888 @@ var WEB_OPERATIONS = [
|
|
|
2804
2942
|
{ "id": "videos.updateCommercialAdRootSettings", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/settings", "source": "web-src/src/lib/api.ts:2363", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u8BBE\u7F6E", "body": "json" },
|
|
2805
2943
|
{ "id": "videos.uploadCommercialAdAssetGap", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/gaps/:gapId/upload", "source": "web-src/src/lib/api.ts:2400", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u8BBE\u7F6E\u7D20\u6750\u7F3A\u53E3 / \u4E0A\u4F20", "body": "binary", "uploadPolicy": "image" },
|
|
2806
2944
|
{ "id": "videos.voiceCandidates.importSource", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/voice-candidates", "source": "web-src/src/lib/api.ts:2161", "group": "videos", "description": "\u4ECE\u5DF2\u6709\u6765\u6E90\u5BFC\u5165\u5546\u54C1\u89C6\u9891\u97F3\u8272\u53C2\u8003", "body": "json" },
|
|
2807
|
-
{ "id": "videos.voiceCandidates.upload", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/voice-candidates", "source": "web-src/src/lib/api.ts:2161", "group": "videos", "description": "\u4E0A\u4F20\u5546\u54C1\u89C6\u9891\u97F3\u8272\u53C2\u8003", "body": "multipart", "uploadPolicy": "voiceSource", "uploadField": "file" }
|
|
2945
|
+
{ "id": "videos.voiceCandidates.upload", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/voice-candidates", "source": "web-src/src/lib/api.ts:2161", "group": "videos", "description": "\u4E0A\u4F20\u5546\u54C1\u89C6\u9891\u97F3\u8272\u53C2\u8003", "body": "multipart", "uploadPolicy": "voiceSource", "uploadField": "file" },
|
|
2946
|
+
{ "id": "auth.smsLoginStatus", "method": "GET", "path": "/api/auth/sms/login/status", "source": "web-src/src/lib/api.ts:1803", "group": "auth", "description": "\u767B\u5F55\uFF1A\u67E5\u8BE2\u77ED\u4FE1\u767B\u5F55\u662F\u5426\u5F00\u653E", "public": true },
|
|
2947
|
+
{ "id": "auth.sendLoginSms", "method": "POST", "path": "/api/auth/sms/login-code", "source": "web-src/src/lib/api.ts:1805", "group": "auth", "description": "\u767B\u5F55\uFF1A\u53D1\u9001\u767B\u5F55\u9A8C\u8BC1\u7801", "body": "json", "public": true, "exampleBody": { "phone": "\u624B\u673A\u53F7" } },
|
|
2948
|
+
{ "id": "auth.loginWithSms", "method": "POST", "path": "/api/auth/login/sms", "source": "web-src/src/lib/api.ts:1808", "group": "auth", "description": "\u767B\u5F55\uFF1A\u4F7F\u7528\u77ED\u4FE1\u9A8C\u8BC1\u7801\u767B\u5F55\u5E76\u4FDD\u5B58\u4F1A\u8BDD", "body": "json", "public": true, "sessionResponse": true, "exampleBody": { "phone": "\u624B\u673A\u53F7", "code": "\u9A8C\u8BC1\u7801" } },
|
|
2949
|
+
{ "id": "auth.sendPasswordSetupSms", "method": "POST", "path": "/api/auth/password/setup-code", "source": "web-src/src/lib/api.ts:1847", "group": "auth", "description": "\u767B\u5F55\uFF1A\u5411\u5F53\u524D\u8D26\u53F7\u53D1\u9001\u9996\u6B21\u8BBE\u5BC6\u9A8C\u8BC1\u7801", "body": "json" },
|
|
2950
|
+
{ "id": "auth.setupPassword", "method": "POST", "path": "/api/auth/password/setup", "source": "web-src/src/lib/api.ts:1850", "group": "auth", "description": "\u767B\u5F55\uFF1A\u4F7F\u7528\u9A8C\u8BC1\u7801\u9996\u6B21\u8BBE\u7F6E\u5BC6\u7801", "body": "json", "exampleBody": { "code": "\u9A8C\u8BC1\u7801", "newPassword": "\u65B0\u5BC6\u7801" } },
|
|
2951
|
+
{ "id": "graphic.saveGraphicImageToLibrary", "method": "POST", "path": "/api/graphic/runs/:runId/images/:imageId/save-to-library", "source": "web-src/src/lib/api.ts:1477", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u5C06\u56FE\u7247\u4FDD\u5B58\u5230\u672C\u4EBA\u7D20\u6750\u5E93", "body": "json", "exampleBody": { "kind": "scene" } },
|
|
2952
|
+
{ "id": "graphic.attachGraphicRunAsset", "method": "POST", "path": "/api/graphic/runs/:runId/attachments/from-library", "source": "web-src/src/lib/api.ts:1558", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u5F15\u7528\u672C\u4EBA\u7D20\u6750\u5E93\u4E2D\u7684\u7D20\u6750", "body": "json", "exampleBody": { "assetId": "\u7D20\u6750\u7F16\u53F7" } },
|
|
2953
|
+
{ "id": "graphic.graphicImageSource", "method": "GET", "path": "/api/graphic/runs/:runId/images/:imageId/source", "source": "web-src/src/lib/api.ts:1491", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u4FDD\u5B58\u4F9B\u7F16\u8F91\u4F7F\u7528\u7684\u56FE\u7247\u539F\u4EF6\uFF1B\u9700\u8981 --out", "response": "file" },
|
|
2954
|
+
{ "id": "videos.commercialAdImageSource", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/images/:assetId/source", "source": "web-src/src/lib/api.ts:2396", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u4FDD\u5B58\u4F9B\u7F16\u8F91\u4F7F\u7528\u7684\u7D20\u6750\u539F\u56FE\uFF1B\u9700\u8981 --out", "response": "file" },
|
|
2955
|
+
{ "id": "videos.commercialAdStoryboardSource", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/storyboards/:imageKey/source", "source": "web-src/src/lib/api.ts:2396", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u4FDD\u5B58\u4F9B\u7F16\u8F91\u4F7F\u7528\u7684\u6545\u4E8B\u677F\u539F\u56FE\uFF1B\u9700\u8981 --out", "response": "file" },
|
|
2956
|
+
{ "id": "videos.commercialAdImageEditSource", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/image-edits/:editId/source", "source": "web-src/src/lib/api.ts:2396", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u4FDD\u5B58\u4F9B\u7EE7\u7EED\u7F16\u8F91\u4F7F\u7528\u7684\u4FEE\u6539\u540E\u539F\u56FE\uFF1B\u9700\u8981 --out", "response": "file" },
|
|
2957
|
+
{ "id": "videos.getCommercialAdEditTimeline", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/edit-timeline", "source": "web-src/src/lib/api.ts:2323", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u526A\u8F91\u65F6\u95F4\u7EBF" },
|
|
2958
|
+
{ "id": "videos.getCommercialAdRoughCut", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/rough-cut", "source": "web-src/src/features/director/canvas/rough-cut/rough-cut-api.ts:22", "group": "videos", "description": "\u89C6\u9891\uFF1A\u67E5\u8BE2\u53EF\u7C97\u526A\u7684\u6210\u7247\u6BB5\u843D" },
|
|
2959
|
+
{ "id": "videos.exportCommercialAdRoughCut", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/rough-cut/exports", "source": "web-src/src/features/director/canvas/rough-cut/rough-cut-api.ts:25", "group": "videos", "description": "\u89C6\u9891\uFF1A\u6309\u7C97\u526A\u7684\u6BB5\u5E8F\u4E0E\u8FDB\u51FA\u70B9\u51FA\u4E00\u7248\u526A\u8F91\u7248\uFF08\u4E0D\u6263\u5E03\uFF09", "body": "json" },
|
|
2960
|
+
{ "id": "drama.exportStoryRoughCut", "method": "POST", "path": "/api/projects/:projectId/director/rough-cut/exports", "source": "web-src/src/features/director/canvas/rough-cut/rough-cut-api.ts:32", "group": "drama", "description": "\u77ED\u5267\uFF1A\u6309\u526A\u8F91\u5DE5\u7A0B\u91CC\u7684\u6BB5\u5E8F\u4E0E\u8FDB\u51FA\u70B9\u51FA\u4E00\u7248\u526A\u8F91\u7248\uFF08\u4E0D\u6263\u5E03\uFF09", "body": "json" },
|
|
2961
|
+
{ "id": "drama.getStoryEditTimeline", "method": "GET", "path": "/api/projects/:projectId/director/edit-timeline", "source": "web-src/src/lib/api.ts:2800", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u526A\u8F91\u65F6\u95F4\u7EBF" },
|
|
2962
|
+
{ "id": "speech.health", "method": "GET", "path": "/api/speech/health", "source": "web-src/src/components/domain/voice-composer.tsx:45", "group": "speech", "description": "\u8BED\u97F3\uFF1A\u67E5\u8BE2\u8BC6\u522B\u670D\u52A1\u72B6\u6001" },
|
|
2963
|
+
{ "id": "speech.transcribe", "method": "POST", "path": "/api/speech/transcribe", "source": "web-src/src/components/domain/voice-composer.tsx:47", "group": "speech", "description": "\u8BED\u97F3\uFF1A\u5C06\u5F55\u97F3\u8F6C\u4E3A\u6587\u5B57\uFF1B--file \u97F3\u9891\uFF0C\u6700\u591A 2 MiB\u30010.5 \u81F3 60 \u79D2", "body": "binary", "uploadPolicy": "speechTranscription" },
|
|
2964
|
+
{ "id": "public.publicCommercialAdInspirations", "method": "GET", "path": "/api/public/showcase-inspirations", "source": "web-src/src/lib/api.ts:2964", "group": "public", "description": "\u516C\u5F00\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891\u521B\u610F\u53C2\u8003", "public": true },
|
|
2965
|
+
{ "id": "videos.showcaseEntryDefault", "method": "GET", "path": "/api/showcase-videos/entry-default", "source": "web-src/src/lib/api.ts:2971", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5F53\u524D\u8D26\u53F7\u7684\u521B\u5EFA\u9ED8\u8BA4\u503C" },
|
|
2966
|
+
{ "id": "graphic.attachGraphicRunProductImage", "method": "POST", "path": "/api/graphic/runs/:runId/attachments/from-product-image", "source": "web-src/src/lib/api.ts:1594", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u5F15\u7528\u5546\u54C1\u56FE\u4F5C\u4E3A\u9644\u4EF6", "body": "json", "exampleBody": { "imageId": "\u5546\u54C1\u56FE\u7F16\u53F7" } },
|
|
2967
|
+
{ "id": "videos.getCommercialAdNode", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/nodes/:thumbId", "source": "web-src/src/lib/api.ts:2468", "group": "videos", "description": "\u89C6\u9891\uFF1A\u67E5\u8BE2\u7D20\u6750\u8282\u70B9" },
|
|
2968
|
+
{ "id": "videos.quoteCommercialAdNode", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/nodes/:thumbId/quote", "source": "web-src/src/lib/api.ts:2472", "group": "videos", "description": "\u89C6\u9891\uFF1A\u7D20\u6750\u8282\u70B9 / \u53EA\u8BFB\u62A5\u4EF7", "body": "json" },
|
|
2969
|
+
{ "id": "videos.generateCommercialAdNode", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/nodes/:thumbId/generate", "source": "web-src/src/lib/api.ts:2477", "group": "videos", "description": "\u89C6\u9891\uFF1A\u7D20\u6750\u8282\u70B9 / \u6309\u62A5\u4EF7\u5236\u4F5C", "body": "json" },
|
|
2970
|
+
{ "id": "videos.restoreCommercialAdNodeVersion", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/nodes/:nodeId/versions/:version/restore", "source": "web-src/src/features/director/canvas/version-restore-api.ts:36", "group": "videos", "description": "\u89C6\u9891\uFF1A\u7D20\u6750\u8282\u70B9 / \u6062\u590D\u5386\u53F2\u7248\u672C", "body": "json" },
|
|
2971
|
+
{ "id": "videos.listCommercialAdPrevisFrames", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/previs-frames", "source": "web-src/src/features/director/canvas/previs/previs-frames-api.ts:38", "group": "videos", "description": "\u89C6\u9891\uFF1A\u67E5\u8BE2\u672C\u5355 3D \u9884\u6F14\u5FEB\u95E8\u7167\u7247" },
|
|
2972
|
+
{ "id": "videos.saveCommercialAdPrevisFrame", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/previs-frames", "source": "web-src/src/features/director/canvas/previs/previs-frames-api.ts:41", "group": "videos", "description": "\u89C6\u9891\uFF1A\u4FDD\u5B58 3D \u9884\u6F14\u5FEB\u95E8\u7167\u7247\uFF08PNG\uFF09", "body": "binary", "uploadPolicy": "image" },
|
|
2973
|
+
{ "id": "videos.stopCommercialAdStageTurn", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/stop-turn", "source": "web-src/src/lib/commercial-ad-stage-turn-stop.ts:8", "group": "videos", "description": "\u89C6\u9891\uFF1A\u4E2D\u6B62\u5F53\u524D\u5728\u98DE\u5BFC\u6F14\u56DE\u5408", "body": "json" },
|
|
2974
|
+
{ "id": "videos.getCommercialAdStageProductionStop", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/stage-production-stop", "source": "web-src/src/features/director/stage-stop.ts:40", "group": "videos", "description": "\u89C6\u9891\uFF1A\u67E5\u8BE2\u5F53\u524D\u751F\u6210\u4EFB\u52A1\u53EF\u505C\u6B62\u72B6\u6001\u4E0E\u5DF2\u53D1\u51FA/\u672A\u53D1\u51FA\u6570\u91CF" },
|
|
2975
|
+
{ "id": "videos.stopCommercialAdStageProduction", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/stage-production-stop", "source": "web-src/src/features/director/stage-stop.ts:44", "group": "videos", "description": "\u89C6\u9891\uFF1A\u505C\u6B62\u5F53\u524D\u51FA\u56FE\u6216\u89C6\u9891\u751F\u6210\uFF08\u672A\u53D1\u51FA\u7684\u505C\u53D1\u9000\u56DE\uFF0C\u5DF2\u53D1\u51FA\u7684\u7167\u6536\uFF09", "body": "json" },
|
|
2976
|
+
{ "id": "videos.listPracticeCases", "method": "GET", "path": "/api/practice-cases", "source": "web-src/src/lib/practice-case-api.ts:42", "group": "videos", "description": "\u5DE5\u4F5C\u53F0\uFF1A\u67E5\u8BE2\u6848\u4F8B\u505A\u6CD5\u76EE\u5F55" },
|
|
2977
|
+
{ "id": "videos.getPracticeCase", "method": "GET", "path": "/api/practice-cases/:id", "source": "web-src/src/lib/practice-case-api.ts:47", "group": "videos", "description": "\u5DE5\u4F5C\u53F0\uFF1A\u67E5\u8BE2\u5355\u6761\u6848\u4F8B\u505A\u6CD5\u8BE6\u60C5" },
|
|
2978
|
+
{ "id": "videos.reopenCommercialAdLegacyRun", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/reopen-as-new", "source": "web-src/src/lib/api.ts:2620", "group": "videos", "description": "\u89C6\u9891\uFF1A\u65E7\u4F5C\u54C1 / \u91CD\u5F00\u4E3A\u65B0\u4F5C\u54C1", "body": "json" },
|
|
2979
|
+
{ "id": "videos.attachCommercialAdRunAssets", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/attachments/from-assets", "source": "web-src/src/lib/api.ts:2752", "group": "videos", "description": "\u89C6\u9891\uFF1A\u5F15\u7528\u7D20\u6750\u4F5C\u4E3A\u9644\u4EF6", "body": "json", "exampleBody": { "assetIds": ["\u7D20\u6750\u7F16\u53F7"] } },
|
|
2980
|
+
{ "id": "videos.downloadCommercialAdSelectedAssetsZip", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/assets/download-zip", "source": "web-src/src/lib/api.ts:2782", "group": "videos", "description": "\u89C6\u9891\uFF1A\u4E0B\u8F7D\u6240\u9009\u7D20\u6750 / \u538B\u7F29\u5305", "body": "json", "exampleBody": { "assetIds": ["\u7D20\u6750\u7F16\u53F7"] } },
|
|
2981
|
+
{ "id": "videos.listAudioNodes", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/audio-nodes", "source": "web-src/src/lib/api-audio-nodes.ts:100", "group": "videos", "description": "\u89C6\u9891\uFF1A\u67E5\u8BE2\u753B\u5E03\u97F3\u9891\u8282\u70B9" },
|
|
2982
|
+
{ "id": "videos.createAudioNode", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/audio-nodes", "source": "web-src/src/lib/api-audio-nodes.ts:108", "group": "videos", "description": "\u89C6\u9891\uFF1A\u521B\u5EFA\u753B\u5E03\u97F3\u9891\u8282\u70B9", "body": "json" },
|
|
2983
|
+
{ "id": "videos.updateAudioNode", "method": "PATCH", "path": "/api/showcase-videos/runs/:rootRunId/audio-nodes/:nodeId", "source": "web-src/src/lib/api-audio-nodes.ts:121", "group": "videos", "description": "\u89C6\u9891\uFF1A\u66F4\u65B0\u753B\u5E03\u97F3\u9891\u8282\u70B9\u97F3\u91CF\u4E0E\u88C1\u526A", "body": "json" },
|
|
2984
|
+
{ "id": "videos.deleteAudioNode", "method": "DELETE", "path": "/api/showcase-videos/runs/:rootRunId/audio-nodes/:nodeId", "source": "web-src/src/lib/api-audio-nodes.ts:133", "group": "videos", "description": "\u89C6\u9891\uFF1A\u5220\u9664\u753B\u5E03\u97F3\u9891\u8282\u70B9", "body": "json" },
|
|
2985
|
+
{ "id": "videos.saveCharacterVoiceBindings", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/voice-bindings", "source": "web-src/src/lib/api-audio-nodes.ts:144", "group": "videos", "description": "\u89C6\u9891\uFF1A\u4FDD\u5B58\u4EBA\u7269\u56FA\u5B9A\u97F3\u8272\u7ED1\u5B9A", "body": "json" },
|
|
2986
|
+
{ "id": "videos.voicePresetSampleWav", "method": "GET", "path": "/api/showcase-videos/voice-presets/:voiceId/sample.wav", "source": "web-src/src/lib/api-audio-nodes.ts:152", "group": "videos", "description": "\u89C6\u9891\uFF1A\u8BFB\u53D6\u5185\u7F6E\u97F3\u8272\u8BD5\u542C\u6837\u97F3\uFF1B\u9700\u8981 --out", "response": "file" },
|
|
2987
|
+
{ "id": "videos.getCanvasWorkspace", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/canvas-workspace", "source": "web-src/src/lib/api-canvas-drafts.ts:112", "group": "videos", "description": "\u89C6\u9891\uFF1A\u67E5\u8BE2\u753B\u5E03\u8349\u7A3F\u3001\u7F16\u7EC4\u4E0E\u8BC4\u5206\u72B6\u6001" },
|
|
2988
|
+
{ "id": "videos.createCanvasDraft", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/canvas-drafts", "source": "web-src/src/lib/api-canvas-drafts.ts:128", "group": "videos", "description": "\u89C6\u9891\uFF1A\u65B0\u5EFA\u753B\u5E03\u8349\u7A3F\u6216\u6587\u5B57\u5361", "body": "json" },
|
|
2989
|
+
{ "id": "videos.updateCanvasDraft", "method": "PATCH", "path": "/api/showcase-videos/runs/:rootRunId/canvas-drafts/:draftId", "source": "web-src/src/lib/api-canvas-drafts.ts:140", "group": "videos", "description": "\u89C6\u9891\uFF1A\u66F4\u65B0\u753B\u5E03\u8349\u7A3F\u6216\u6587\u5B57\u5361", "body": "json" },
|
|
2990
|
+
{ "id": "videos.deleteCanvasDraft", "method": "DELETE", "path": "/api/showcase-videos/runs/:rootRunId/canvas-drafts/:draftId", "source": "web-src/src/lib/api-canvas-drafts.ts:154", "group": "videos", "description": "\u89C6\u9891\uFF1A\u5220\u9664\u753B\u5E03\u8349\u7A3F\u6216\u6587\u5B57\u5361", "body": "json" },
|
|
2991
|
+
{ "id": "videos.saveCanvasGroups", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/canvas-groups", "source": "web-src/src/lib/api-canvas-drafts.ts:164", "group": "videos", "description": "\u89C6\u9891\uFF1A\u4FDD\u5B58\u753B\u5E03\u7F16\u7EC4\u5E03\u5C40", "body": "json" },
|
|
2992
|
+
{ "id": "videos.setCanvasNodeRating", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/node-ratings/:nodeId", "source": "web-src/src/lib/api-canvas-drafts.ts:176", "group": "videos", "description": "\u89C6\u9891\uFF1A\u8BBE\u7F6E\u753B\u5E03\u8282\u70B9\u661F\u7EA7\u8BC4\u5206", "body": "json" },
|
|
2993
|
+
{ "id": "videos.getDirectorStagePrevis", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/stages/previs", "source": "web-src/src/lib/api-director-previs.ts:79", "group": "videos", "description": "\u89C6\u9891\uFF1A\u67E5\u8BE2\u672C\u5355 3D \u8D70\u4F4D\u9884\u6F14\u573A\u666F\u53C2\u6570" },
|
|
2994
|
+
{ "id": "videos.saveDirectorStagePrevis", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/stages/previs", "source": "web-src/src/lib/api-director-previs.ts:83", "group": "videos", "description": "\u89C6\u9891\uFF1A\u4FDD\u5B58\u672C\u5355 3D \u8D70\u4F4D\u9884\u6F14\u573A\u666F\u53C2\u6570", "body": "json" },
|
|
2995
|
+
{ "id": "templates.listStageTemplates", "method": "GET", "path": "/api/stage-templates", "source": "web-src/src/lib/api-director-templates.ts:159", "group": "templates", "description": "\u6A21\u677F\uFF1A\u67E5\u8BE2\u89C6\u9891\u9636\u6BB5\u6A21\u677F\u76EE\u5F55" },
|
|
2996
|
+
{ "id": "templates.startRunFromStageTemplate", "method": "POST", "path": "/api/stage-templates/:templateId/start", "source": "web-src/src/lib/api-director-templates.ts:168", "group": "templates", "description": "\u6A21\u677F\uFF1A\u57FA\u4E8E\u9636\u6BB5\u6A21\u677F\u65B0\u5EFA\u89C6\u9891\u4F5C\u54C1", "body": "json" },
|
|
2997
|
+
{ "id": "videos.getRunAutoConfirm", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/auto-confirm", "source": "web-src/src/lib/api-director-templates.ts:224", "group": "videos", "description": "\u89C6\u9891\uFF1A\u67E5\u8BE2\u672C\u5355\u53D7\u9650\u5168\u81EA\u52A8\u6388\u6743\u72B6\u6001" },
|
|
2998
|
+
{ "id": "videos.updateRunAutoConfirm", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/auto-confirm", "source": "web-src/src/lib/api-director-templates.ts:237", "group": "videos", "description": "\u89C6\u9891\uFF1A\u66F4\u65B0\u672C\u5355\u53D7\u9650\u5168\u81EA\u52A8\u9884\u7B97\u4E0A\u9650\u4E0E\u5F00\u5173", "body": "json" },
|
|
2999
|
+
{ "id": "videos.triggerRunAutoConfirm", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/auto-confirm/trigger", "source": "web-src/src/lib/api-director-templates.ts:261", "group": "videos", "description": "\u89C6\u9891\uFF1A\u6309\u53D7\u9650\u5168\u81EA\u52A8\u6388\u6743\u63A8\u8FDB\u5F53\u524D\u5F85\u786E\u8BA4\u6B65\u9AA4", "body": "json" },
|
|
3000
|
+
{ "id": "videos.fetchAttachmentFaceHints", "method": "POST", "path": "/api/face-checks/attachments", "source": "web-src/src/lib/api-face-checks.ts:71", "group": "videos", "description": "\u89C6\u9891\uFF1A\u67E5\u8BE2\u4EBA\u7269\u53C2\u8003\u9644\u4EF6\u4EBA\u8138\u8D28\u91CF\u63D0\u793A", "body": "json" },
|
|
3001
|
+
{ "id": "library.listProjectLibraryTrash", "method": "GET", "path": "/api/project-library/trash", "source": "web-src/src/lib/api-project-trash.ts:55", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u67E5\u8BE2\u56DE\u6536\u7AD9\u9879\u76EE\u5217\u8868" },
|
|
3002
|
+
{ "id": "library.trashProjectLibraryItems", "method": "POST", "path": "/api/project-library/trash", "source": "web-src/src/lib/api-project-trash.ts:63", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u5C06\u9879\u76EE\u79FB\u5165\u56DE\u6536\u7AD9", "body": "json" },
|
|
3003
|
+
{ "id": "library.restoreProjectLibraryTrash", "method": "POST", "path": "/api/project-library/trash/restore", "source": "web-src/src/lib/api-project-trash.ts:84", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u4ECE\u56DE\u6536\u7AD9\u6062\u590D\u9879\u76EE", "body": "json" },
|
|
3004
|
+
{ "id": "library.purgeProjectLibraryTrash", "method": "POST", "path": "/api/project-library/trash/purge", "source": "web-src/src/lib/api-project-trash.ts:95", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u6C38\u4E45\u5220\u9664\u56DE\u6536\u7AD9\u4E2D\u7684\u9879\u76EE", "body": "json" },
|
|
3005
|
+
{ "id": "videos.listImageDerivePresets", "method": "GET", "path": "/api/image-derive-presets", "source": "web-src/src/lib/api-vision-tools.ts:97", "group": "videos", "description": "\u89C6\u9891\uFF1A\u67E5\u8BE2\u753B\u5E03\u56FE\u7247\u884D\u751F\u9884\u8BBE\u76EE\u5F55" },
|
|
3006
|
+
{ "id": "videos.getVisionToolsQuota", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/vision-tools/quota", "source": "web-src/src/lib/api-vision-tools.ts:100", "group": "videos", "description": "\u89C6\u9891\uFF1A\u67E5\u8BE2\u672C\u5355\u514D\u8D39\u89C6\u89C9\u5DE5\u5177\u4ECA\u65E5\u4F59\u91CF" },
|
|
3007
|
+
{ "id": "videos.runVisionToolCutout", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/vision-tools/cutout", "source": "web-src/src/lib/api-vision-tools.ts:103", "group": "videos", "description": "\u89C6\u9891\uFF1A\u5BF9\u753B\u5E03\u56FE\u7247\u6267\u884C\u514D\u8D39\u4E00\u952E\u53BB\u80CC\u666F", "body": "json" },
|
|
3008
|
+
{ "id": "videos.runVisionToolPointMask", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/vision-tools/point-mask", "source": "web-src/src/lib/api-vision-tools.ts:114", "group": "videos", "description": "\u89C6\u9891\uFF1A\u6309\u70B9\u9009\u751F\u6210\u5C40\u90E8\u4FEE\u6539\u9009\u533A\u906E\u7F69", "body": "json" },
|
|
3009
|
+
{ "id": "account.realtimeConnection", "method": "POST", "path": "/api/realtime/connection", "source": "web-src/src/lib/realtime/job-status-push.ts:190", "group": "account", "description": "\u8D26\u53F7\uFF1A\u83B7\u53D6\u5B9E\u65F6\u4EFB\u52A1\u72B6\u6001\u8FDE\u63A5\u51ED\u8BC1", "body": "json" },
|
|
3010
|
+
{ "id": "account.realtimeSubscription", "method": "POST", "path": "/api/realtime/subscription", "source": "web-src/src/lib/realtime/job-status-push.ts:193", "group": "account", "description": "\u8D26\u53F7\uFF1A\u83B7\u53D6\u5B9E\u65F6\u4EFB\u52A1\u72B6\u6001\u9891\u9053\u8BA2\u9605\u51ED\u8BC1", "body": "json" },
|
|
3011
|
+
{ "id": "videos.getCanvasLayout", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/canvas-layout", "source": "web-src/src/lib/api-canvas-layout.ts:97", "group": "videos", "description": "\u89C6\u9891\uFF1A\u67E5\u8BE2\u753B\u5E03\u8282\u70B9\u4F4D\u7F6E\u4E0E\u663E\u793A\u504F\u597D" },
|
|
3012
|
+
{ "id": "videos.saveCanvasLayout", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/canvas-layout", "source": "web-src/src/lib/api-canvas-layout.ts:120", "group": "videos", "description": "\u89C6\u9891\uFF1A\u4FDD\u5B58\u753B\u5E03\u8282\u70B9\u4F4D\u7F6E\u4E0E\u663E\u793A\u504F\u597D", "body": "json" },
|
|
3013
|
+
{ "id": "videos.previewCustomVideoCut", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/custom-cut/preview", "source": "web-src/src/lib/api-custom-video-cut.ts:70", "group": "videos", "description": "\u89C6\u9891\uFF1A\u6309\u53E3\u8FF0\u8981\u6C42\u9884\u89C8\u89C6\u9891\u5FEB\u526A\u533A\u95F4", "body": "json" },
|
|
3014
|
+
{ "id": "videos.applyCustomVideoCut", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/custom-cut/apply", "source": "web-src/src/lib/api-custom-video-cut.ts:83", "group": "videos", "description": "\u89C6\u9891\uFF1A\u6309\u786E\u8BA4\u533A\u95F4\u63D0\u4EA4\u89C6\u9891\u5FEB\u526A\u91CD\u62FC", "body": "json" },
|
|
3015
|
+
{ "id": "public.getSharedRecipe", "method": "GET", "path": "/api/public/recipes/:shareCode", "source": "web-src/src/lib/api-recipe-clone.ts:82", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u67E5\u8BE2\u516C\u5F00\u5206\u4EAB\u7684\u5236\u4F5C\u6D41\u7A0B", "public": true },
|
|
3016
|
+
{ "id": "videos.getRunRecipeShareStatus", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/share-recipe", "source": "web-src/src/lib/api-recipe-clone.ts:100", "group": "videos", "description": "\u89C6\u9891\uFF1A\u67E5\u8BE2\u672C\u5355\u5236\u4F5C\u6D41\u7A0B\u5206\u4EAB\u72B6\u6001" },
|
|
3017
|
+
{ "id": "videos.shareRunRecipe", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/share-recipe", "source": "web-src/src/lib/api-recipe-clone.ts:115", "group": "videos", "description": "\u89C6\u9891\uFF1A\u751F\u6210\u672C\u5355\u5236\u4F5C\u6D41\u7A0B\u5206\u4EAB\u94FE\u63A5", "body": "json" },
|
|
3018
|
+
{ "id": "videos.revokeRunRecipe", "method": "DELETE", "path": "/api/showcase-videos/runs/:rootRunId/share-recipe", "source": "web-src/src/lib/api-recipe-clone.ts:123", "group": "videos", "description": "\u89C6\u9891\uFF1A\u64A4\u9500\u672C\u5355\u5236\u4F5C\u6D41\u7A0B\u5206\u4EAB\u94FE\u63A5", "body": "json" },
|
|
3019
|
+
{ "id": "videos.cloneOwnedRunRecipe", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/clone-recipe", "source": "web-src/src/lib/api-recipe-clone.ts:139", "group": "videos", "description": "\u89C6\u9891\uFF1A\u590D\u7528\u672C\u5355\u5236\u4F5C\u6D41\u7A0B\u65B0\u5EFA\u4F5C\u54C1", "body": "json" },
|
|
3020
|
+
{ "id": "videos.cloneSharedRecipe", "method": "POST", "path": "/api/recipes/:shareCode/clone", "source": "web-src/src/lib/api-recipe-clone.ts:160", "group": "videos", "description": "\u89C6\u9891\uFF1A\u5957\u7528\u516C\u5F00\u5206\u4EAB\u6D41\u7A0B\u65B0\u5EFA\u4F5C\u54C1", "body": "json" }
|
|
2808
3021
|
];
|
|
2809
3022
|
|
|
3023
|
+
// src/web-operation-fields.ts
|
|
3024
|
+
var WEB_OPERATION_FIELDS = {
|
|
3025
|
+
"account.realtimeSubscription": { "fields": [
|
|
3026
|
+
{ "name": "channel", "type": "unknown", "source": "observed" }
|
|
3027
|
+
] },
|
|
3028
|
+
"account.requestEmailVerification": { "fields": [
|
|
3029
|
+
{ "name": "email", "type": "string", "source": "observed" }
|
|
3030
|
+
] },
|
|
3031
|
+
"account.updateAgentSettings": { "fields": [
|
|
3032
|
+
{ "name": "aboutStore", "type": "string", "required": false, "source": "observed" },
|
|
3033
|
+
{ "name": "autoApproveMaxCredits", "type": "number|null", "required": false, "source": "observed" },
|
|
3034
|
+
{ "name": "autoStartKaipai", "type": "boolean", "required": true, "source": "observed" },
|
|
3035
|
+
{ "name": "autoStartMaxCredits", "type": "number|null", "required": false, "source": "observed" },
|
|
3036
|
+
{ "name": "customInstructions", "type": "string", "required": false, "source": "observed" },
|
|
3037
|
+
{ "name": "directorPersona", "type": "string", "enum": ["stepByStep", "planFirst", "brainstorm"], "required": true, "source": "observed" },
|
|
3038
|
+
{ "name": "directorStyle", "type": "string", "enum": ["quick", "opinionated", "meticulous"], "required": false, "source": "observed" },
|
|
3039
|
+
{ "name": "newRunDefaults", "type": "object", "required": false, "source": "observed" },
|
|
3040
|
+
{ "name": "rememberPreferences", "type": "boolean", "required": true, "source": "observed" },
|
|
3041
|
+
{ "name": "suggestNextMessage", "type": "boolean", "required": false, "source": "observed" },
|
|
3042
|
+
{ "name": "supportedLanes", "type": "Record", "required": false, "source": "observed" }
|
|
3043
|
+
] },
|
|
3044
|
+
"account.updateEmailPreferences": { "fields": [
|
|
3045
|
+
{ "name": "actionRequired", "type": "boolean", "required": true, "source": "observed" },
|
|
3046
|
+
{ "name": "activityDigest", "type": "boolean", "required": true, "source": "observed" },
|
|
3047
|
+
{ "name": "announcements", "type": "boolean", "required": true, "source": "observed" },
|
|
3048
|
+
{ "name": "deliveries", "type": "boolean", "required": true, "source": "observed" },
|
|
3049
|
+
{ "name": "marketing", "type": "boolean", "required": true, "source": "observed" },
|
|
3050
|
+
{ "name": "transactions", "type": "boolean", "required": true, "source": "observed" }
|
|
3051
|
+
] },
|
|
3052
|
+
"agent.agentApply": { "fields": [
|
|
3053
|
+
{ "name": "agreed", "type": "true", "required": true, "source": "observed" },
|
|
3054
|
+
{ "name": "contact", "type": "string", "required": true, "source": "observed" },
|
|
3055
|
+
{ "name": "kind", "type": "string", "enum": ["individual", "organization"], "required": true, "source": "observed" },
|
|
3056
|
+
{ "name": "orgName", "type": "string", "required": false, "source": "observed" },
|
|
3057
|
+
{ "name": "plan", "type": "string", "required": true, "source": "observed" }
|
|
3058
|
+
] },
|
|
3059
|
+
"agent.requestWithdrawal": { "fields": [
|
|
3060
|
+
{ "name": "amount", "type": "number", "source": "observed" }
|
|
3061
|
+
] },
|
|
3062
|
+
"agent.saveAgentPayoutProfile": { "fields": [
|
|
3063
|
+
{ "name": "account", "type": "string", "required": true, "source": "observed" },
|
|
3064
|
+
{ "name": "agreed", "type": "true", "required": true, "source": "observed" },
|
|
3065
|
+
{ "name": "bankName", "type": "string", "required": false, "source": "observed" },
|
|
3066
|
+
{ "name": "method", "type": "string", "enum": ["alipay", "bank"], "required": true, "source": "observed" },
|
|
3067
|
+
{ "name": "payeeKind", "type": "string", "enum": ["individual", "organization"], "required": true, "source": "observed" },
|
|
3068
|
+
{ "name": "payeeName", "type": "string", "required": true, "source": "observed" }
|
|
3069
|
+
] },
|
|
3070
|
+
"announcements.announcementReceipt": { "fields": [
|
|
3071
|
+
{ "name": "action", "type": "string", "enum": ["seen", "dismissed", "acknowledged"], "source": "observed" }
|
|
3072
|
+
] },
|
|
3073
|
+
"apiKeys.create": { "fields": [
|
|
3074
|
+
{ "name": "expiresInDays", "type": "number", "required": false, "source": "observed" },
|
|
3075
|
+
{ "name": "name", "type": "string", "required": true, "source": "observed" }
|
|
3076
|
+
] },
|
|
3077
|
+
"auth.changePassword": { "fields": [
|
|
3078
|
+
{ "name": "currentPassword", "type": "string", "required": true, "source": "observed" },
|
|
3079
|
+
{ "name": "newPassword", "type": "string", "required": true, "source": "observed" }
|
|
3080
|
+
] },
|
|
3081
|
+
"auth.completeAlipayLogin": { "fields": [
|
|
3082
|
+
{ "name": "ticket", "type": "string", "source": "observed" }
|
|
3083
|
+
] },
|
|
3084
|
+
"auth.login": { "fields": [
|
|
3085
|
+
{ "name": "password", "type": "string", "source": "observed" },
|
|
3086
|
+
{ "name": "username", "type": "string", "source": "observed" }
|
|
3087
|
+
] },
|
|
3088
|
+
"auth.loginWithSms": { "fields": [
|
|
3089
|
+
{ "name": "code", "type": "string", "source": "observed" },
|
|
3090
|
+
{ "name": "phone", "type": "string", "source": "observed" },
|
|
3091
|
+
{ "name": "referralCode", "type": "string", "source": "observed" }
|
|
3092
|
+
] },
|
|
3093
|
+
"auth.registerWithEmail": { "fields": [
|
|
3094
|
+
{ "name": "code", "type": "string", "source": "observed" },
|
|
3095
|
+
{ "name": "email", "type": "string", "source": "observed" },
|
|
3096
|
+
{ "name": "password", "type": "string", "source": "observed" },
|
|
3097
|
+
{ "name": "referralCode", "type": "string", "source": "observed" }
|
|
3098
|
+
] },
|
|
3099
|
+
"auth.registerWithSms": { "fields": [
|
|
3100
|
+
{ "name": "code", "type": "string", "source": "observed" },
|
|
3101
|
+
{ "name": "password", "type": "string", "source": "observed" },
|
|
3102
|
+
{ "name": "phone", "type": "string", "source": "observed" },
|
|
3103
|
+
{ "name": "referralCode", "type": "string", "source": "observed" }
|
|
3104
|
+
] },
|
|
3105
|
+
"auth.sendLoginSms": { "fields": [
|
|
3106
|
+
{ "name": "phone", "type": "string", "source": "observed" }
|
|
3107
|
+
] },
|
|
3108
|
+
"auth.sendRegistrationEmail": { "fields": [
|
|
3109
|
+
{ "name": "email", "type": "string", "source": "observed" }
|
|
3110
|
+
] },
|
|
3111
|
+
"auth.sendRegistrationSms": { "fields": [
|
|
3112
|
+
{ "name": "phone", "type": "string", "source": "observed" }
|
|
3113
|
+
] },
|
|
3114
|
+
"auth.setupPassword": { "fields": [
|
|
3115
|
+
{ "name": "code", "type": "string", "required": true, "source": "observed" },
|
|
3116
|
+
{ "name": "newPassword", "type": "string", "required": true, "source": "observed" }
|
|
3117
|
+
] },
|
|
3118
|
+
"commercialAds.recommendCommercialAds": { "fields": [
|
|
3119
|
+
{ "name": "campaignGoal", "type": "string", "enum": ["show-product", "prove-function", "show-usage", "tell-story", "build-brand", "launch", "explain-service"], "required": false, "source": "observed" },
|
|
3120
|
+
{ "name": "description", "type": "string", "required": false, "source": "observed" },
|
|
3121
|
+
{ "name": "productCategory", "type": "string", "required": true, "source": "observed" },
|
|
3122
|
+
{ "name": "requestedDurationSeconds", "type": "number", "required": false, "source": "observed" }
|
|
3123
|
+
] },
|
|
3124
|
+
"delivery.comment": { "fields": [
|
|
3125
|
+
{ "name": "authorName", "type": "string", "required": true, "source": "observed" },
|
|
3126
|
+
{ "name": "body", "type": "string", "required": true, "source": "observed" }
|
|
3127
|
+
] },
|
|
3128
|
+
"delivery.create": { "fields": [
|
|
3129
|
+
{ "name": "locale", "type": "UiLocale", "required": false, "source": "observed" },
|
|
3130
|
+
{ "name": "requestKey", "type": "string", "required": true, "source": "observed" },
|
|
3131
|
+
{ "name": "scope", "type": "string", "enum": ["full", "selected"], "required": false, "source": "observed" },
|
|
3132
|
+
{ "name": "sources", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "required": true, "source": "observed" },
|
|
3133
|
+
{ "name": "title", "type": "string", "required": false, "source": "observed" }
|
|
3134
|
+
] },
|
|
3135
|
+
"delivery.createShare": { "fields": [
|
|
3136
|
+
{ "name": "allowComment", "type": "boolean", "required": true, "source": "observed" },
|
|
3137
|
+
{ "name": "allowDownload", "type": "boolean", "required": true, "source": "observed" },
|
|
3138
|
+
{ "name": "allowPreview", "type": "boolean", "required": true, "source": "observed" },
|
|
3139
|
+
{ "name": "expiresInDays", "type": "number", "required": true, "source": "observed" }
|
|
3140
|
+
] },
|
|
3141
|
+
"delivery.downloadFile": { "fields": [
|
|
3142
|
+
{ "name": "fileId", "source": "observed" },
|
|
3143
|
+
{ "name": "volume", "type": "string", "source": "observed" }
|
|
3144
|
+
] },
|
|
3145
|
+
"drama.adoptStorySpeech": { "fields": [
|
|
3146
|
+
{ "name": "recoveryAdoptionId", "source": "zod", "required": false, "type": "string" },
|
|
3147
|
+
{ "name": "visualTailPolicy", "source": "zod", "required": true, "type": "string", "enum": ["reject", "hold_last_frame"] },
|
|
3148
|
+
{ "name": "contentSha256", "source": "zod", "required": true, "type": "string" },
|
|
3149
|
+
{ "name": "sourceEpisodeOutputId", "source": "zod", "required": false, "type": "string" },
|
|
3150
|
+
{ "name": "visualPlan", "source": "zod", "required": false, "type": "object", "note": "\u5D4C\u5957\u5B57\u6BB5\uFF1AsourceFingerprint\u3001segments" },
|
|
3151
|
+
{ "name": "sourceFingerprint", "source": "zod", "required": true, "type": "string" },
|
|
3152
|
+
{ "name": "segments", "source": "zod", "required": true, "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1AVideoEditSegmentSchema" }
|
|
3153
|
+
] },
|
|
3154
|
+
"drama.approveStorySpeech": { "fields": [
|
|
3155
|
+
{ "name": "contentSha256", "type": "string", "source": "observed" }
|
|
3156
|
+
] },
|
|
3157
|
+
"drama.bindStoryAssets": { "fields": [
|
|
3158
|
+
{ "name": "actorId", "type": "string", "required": false, "source": "observed" },
|
|
3159
|
+
{ "name": "characterName", "type": "string", "required": false, "source": "observed" },
|
|
3160
|
+
{ "name": "expectedProductionEpoch", "type": "number", "required": true, "source": "observed" },
|
|
3161
|
+
{ "name": "sceneId", "type": "string", "required": false, "source": "observed" },
|
|
3162
|
+
{ "name": "sceneNo", "type": "number", "required": false, "source": "observed" }
|
|
3163
|
+
] },
|
|
3164
|
+
"drama.cancelProjectGeneration": { "fields": [
|
|
3165
|
+
{ "name": "reason", "type": "string", "source": "observed" }
|
|
3166
|
+
] },
|
|
3167
|
+
"drama.cancelStoryDirectorAutoStart": { "fields": [
|
|
3168
|
+
{ "name": "confirmationId", "type": "string", "required": true, "source": "observed" }
|
|
3169
|
+
] },
|
|
3170
|
+
"drama.casting": { "fields": [
|
|
3171
|
+
{ "name": "expectedProductionEpoch", "type": "number", "source": "observed" },
|
|
3172
|
+
{ "name": "overrides", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "source": "observed" }
|
|
3173
|
+
] },
|
|
3174
|
+
"drama.confirmProductionRedo": { "fields": [
|
|
3175
|
+
{ "name": "confirmed", "type": "true", "required": true, "source": "observed" },
|
|
3176
|
+
{ "name": "redoPlanHash", "type": "string", "required": true, "source": "observed" },
|
|
3177
|
+
{ "name": "redoQuoteHash", "type": "string", "required": true, "source": "observed" },
|
|
3178
|
+
{ "name": "redoQuoteId", "type": "string", "required": true, "source": "observed" }
|
|
3179
|
+
] },
|
|
3180
|
+
"drama.confirmStitch": { "fields": [
|
|
3181
|
+
{ "name": "actionId", "type": "string", "required": true, "source": "observed" },
|
|
3182
|
+
{ "name": "contractVersion", "source": "observed" },
|
|
3183
|
+
{ "name": "issueSetHash", "type": "string", "required": true, "source": "observed" },
|
|
3184
|
+
{ "name": "policyVersion", "type": "string", "required": true, "source": "observed" },
|
|
3185
|
+
{ "name": "selections", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "required": true, "source": "observed" },
|
|
3186
|
+
{ "name": "subjectFingerprint", "type": "string", "required": true, "source": "observed" }
|
|
3187
|
+
] },
|
|
3188
|
+
"drama.confirmStoryDirector": { "fields": [
|
|
3189
|
+
{ "name": "cardId", "type": "string", "source": "observed" },
|
|
3190
|
+
{ "name": "confirmationId", "type": "string", "required": true, "source": "observed" },
|
|
3191
|
+
{ "name": "kind", "type": "string", "enum": ["confirm_script", "confirm_shot_replan", "confirm_storyboards", "confirm_image", "confirm_production", "confirm_topic_script", "confirm_speech", "confirm_film_pack", "confirm_production_redo"], "required": true, "source": "observed" },
|
|
3192
|
+
{ "name": "source", "type": "string", "enum": ["auto_approve"], "required": false, "source": "observed" }
|
|
3193
|
+
] },
|
|
3194
|
+
"drama.confirmStorySpeechLegacySource": { "fields": [
|
|
3195
|
+
{ "name": "episodeNumber", "source": "zod", "required": true, "type": "number" },
|
|
3196
|
+
{ "name": "expectedProductionEpoch", "source": "zod", "required": true, "type": "number" },
|
|
3197
|
+
{ "name": "expectedDocumentId", "source": "zod", "required": true, "type": "string" },
|
|
3198
|
+
{ "name": "expectedFingerprint", "source": "zod", "required": true, "type": "string" }
|
|
3199
|
+
] },
|
|
3200
|
+
"drama.create": { "fields": [
|
|
3201
|
+
{ "name": "brief", "source": "observed" },
|
|
3202
|
+
{ "name": "genreId", "type": "string", "source": "observed" },
|
|
3203
|
+
{ "name": "productId", "type": "string", "source": "observed" },
|
|
3204
|
+
{ "name": "productionProfile", "source": "observed" },
|
|
3205
|
+
{ "name": "selectedScriptAssetId", "type": "string", "source": "observed" }
|
|
3206
|
+
] },
|
|
3207
|
+
"drama.createProductionSignoff": { "fields": [
|
|
3208
|
+
{ "name": "acceptedReviewKeys", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Astring", "required": false, "source": "observed" },
|
|
3209
|
+
{ "name": "acceptedWarnings", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Astring", "required": false, "source": "observed" },
|
|
3210
|
+
{ "name": "expectedPacketHash", "type": "string", "required": true, "source": "observed" }
|
|
3211
|
+
] },
|
|
3212
|
+
"drama.exportStoryRoughCut": { "fields": [
|
|
3213
|
+
{ "name": "productionId", "type": "string", "required": false, "source": "observed" },
|
|
3214
|
+
{ "name": "segments", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "required": true, "source": "observed" },
|
|
3215
|
+
{ "name": "sourceToken", "type": "string", "required": true, "source": "observed" }
|
|
3216
|
+
] },
|
|
3217
|
+
"drama.generateStoryboard": { "fields": [
|
|
3218
|
+
{ "name": "redraw", "type": "boolean", "required": false, "source": "observed" },
|
|
3219
|
+
{ "name": "sceneNos", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Astring", "required": true, "source": "observed" }
|
|
3220
|
+
] },
|
|
3221
|
+
"drama.importStorySpeechRecordings": { "fields": [
|
|
3222
|
+
{ "name": "episodeNumber", "type": "number", "required": true, "source": "observed" },
|
|
3223
|
+
{ "name": "recordings", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "required": true, "source": "observed" },
|
|
3224
|
+
{ "name": "scriptFingerprint", "type": "string", "required": true, "source": "observed" }
|
|
3225
|
+
] },
|
|
3226
|
+
"drama.postStoryDirectorMessage": { "fields": [
|
|
3227
|
+
{ "name": "choiceSelection", "source": "observed" },
|
|
3228
|
+
{ "name": "optionIndices", "source": "observed" },
|
|
3229
|
+
{ "name": "sourceTurnId", "type": "string", "source": "observed" },
|
|
3230
|
+
{ "name": "text", "source": "observed" }
|
|
3231
|
+
] },
|
|
3232
|
+
"drama.quoteStorySpeech": { "fields": [
|
|
3233
|
+
{ "name": "emotions", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "required": false, "source": "observed" },
|
|
3234
|
+
{ "name": "episodeNumber", "type": "number", "required": false, "source": "observed" },
|
|
3235
|
+
{ "name": "pronunciations", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "required": false, "source": "observed" },
|
|
3236
|
+
{ "name": "speed", "type": "number", "required": false, "source": "observed" },
|
|
3237
|
+
{ "name": "voices", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "required": true, "source": "observed" }
|
|
3238
|
+
] },
|
|
3239
|
+
"drama.refineScreenplayScene": { "fields": [
|
|
3240
|
+
{ "name": "note", "type": "string", "source": "observed" }
|
|
3241
|
+
] },
|
|
3242
|
+
"drama.render": { "fields": [
|
|
3243
|
+
{ "name": "draftId", "source": "zod", "required": true, "type": "string" },
|
|
3244
|
+
{ "name": "style", "source": "zod", "required": false, "default": "clean", "type": "string", "enum": ["clean", "band", "highlight"] }
|
|
3245
|
+
] },
|
|
3246
|
+
"drama.restoreScreenplayVersion": { "fields": [
|
|
3247
|
+
{ "name": "expectedCurrentDocumentId", "type": "string", "required": true, "source": "observed" },
|
|
3248
|
+
{ "name": "productionEpoch", "type": "number", "required": true, "source": "observed" }
|
|
3249
|
+
] },
|
|
3250
|
+
"drama.resumeProductionPostprocess": { "fields": [
|
|
3251
|
+
{ "name": "inputFingerprint", "type": "string", "required": true, "source": "observed" },
|
|
3252
|
+
{ "name": "kind", "type": "string", "enum": ["video_qc", "direct_stitch"], "required": true, "source": "observed" },
|
|
3253
|
+
{ "name": "taskVersion", "type": "number", "required": true, "source": "observed" }
|
|
3254
|
+
] },
|
|
3255
|
+
"drama.retryShotGeneration": { "fields": [
|
|
3256
|
+
{ "name": "confirmationId", "type": "string", "source": "observed" }
|
|
3257
|
+
] },
|
|
3258
|
+
"drama.save": { "fields": [
|
|
3259
|
+
{ "name": "cues", "source": "zod", "required": true, "type": "unknown" }
|
|
3260
|
+
] },
|
|
3261
|
+
"drama.screenplay": { "fields": [
|
|
3262
|
+
{ "name": "contractVersion", "type": "string", "enum": ["1", "2"], "source": "observed" },
|
|
3263
|
+
{ "name": "force", "source": "observed" }
|
|
3264
|
+
] },
|
|
3265
|
+
"drama.selectScriptAsset": { "fields": [
|
|
3266
|
+
{ "name": "recompute", "source": "observed" },
|
|
3267
|
+
{ "name": "scriptAssetId", "type": "string", "source": "observed" }
|
|
3268
|
+
] },
|
|
3269
|
+
"drama.selectShotVersion": { "fields": [
|
|
3270
|
+
{ "name": "renderOutputId", "type": "string", "source": "observed" }
|
|
3271
|
+
] },
|
|
3272
|
+
"drama.setStoryDirectorProductionChoice": { "fields": [
|
|
3273
|
+
{ "name": "videoModel", "source": "zod", "required": false, "type": "string" },
|
|
3274
|
+
{ "name": "resolution", "source": "zod", "required": false, "type": "string" },
|
|
3275
|
+
{ "name": "imageModel", "source": "zod", "required": false, "type": "string" },
|
|
3276
|
+
{ "name": "burnInSubtitles", "source": "zod", "required": false, "type": "boolean" },
|
|
3277
|
+
{ "name": "subtitleScope", "source": "zod", "required": false, "type": "string", "enum": ["episode", "series"] }
|
|
3278
|
+
] },
|
|
3279
|
+
"drama.stitchDecision": { "fields": [
|
|
3280
|
+
{ "name": "selections", "type": 'ConfirmStitchInput["selections"]', "source": "observed" }
|
|
3281
|
+
] },
|
|
3282
|
+
"drama.switchProjectToLiveAction": { "fields": [
|
|
3283
|
+
{ "name": "visualStyle", "source": "observed" }
|
|
3284
|
+
] },
|
|
3285
|
+
"drama.updatePlacementIntensity": { "fields": [
|
|
3286
|
+
{ "name": "expectedProductionEpoch", "type": "number", "source": "observed" },
|
|
3287
|
+
{ "name": "placementIntensity", "type": "string", "enum": ["light_touch", "natural_blend", "plot_core"], "source": "observed" },
|
|
3288
|
+
{ "name": "preferredDramaRole", "type": "string|null", "source": "observed" }
|
|
3289
|
+
] },
|
|
3290
|
+
"email.unsubscribeEmail": { "fields": [
|
|
3291
|
+
{ "name": "token", "type": "string", "source": "observed" }
|
|
3292
|
+
] },
|
|
3293
|
+
"email.verifyEmail": { "fields": [
|
|
3294
|
+
{ "name": "token", "type": "string", "source": "observed" }
|
|
3295
|
+
] },
|
|
3296
|
+
"feedback.commentOnFeedback": { "fields": [
|
|
3297
|
+
{ "name": "message", "type": "string", "source": "observed" }
|
|
3298
|
+
] },
|
|
3299
|
+
"feedback.submitFeedback": { "fields": [
|
|
3300
|
+
{ "name": "anonymous", "type": "boolean", "required": false, "source": "observed" },
|
|
3301
|
+
{ "name": "attachments", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Astring", "required": false, "source": "observed" },
|
|
3302
|
+
{ "name": "body", "type": "string", "required": true, "source": "observed" },
|
|
3303
|
+
{ "name": "context", "type": "object", "required": false, "source": "observed" },
|
|
3304
|
+
{ "name": "kind", "type": "string", "enum": ["idea", "bug"], "required": true, "source": "observed" },
|
|
3305
|
+
{ "name": "title", "type": "string", "required": true, "source": "observed" }
|
|
3306
|
+
] },
|
|
3307
|
+
"graphic.attachGraphicRunAsset": { "fields": [
|
|
3308
|
+
{ "name": "assetId", "type": "string", "source": "observed" }
|
|
3309
|
+
] },
|
|
3310
|
+
"graphic.attachGraphicRunProductImage": { "fields": [
|
|
3311
|
+
{ "name": "imageId", "type": "string", "source": "observed" }
|
|
3312
|
+
] },
|
|
3313
|
+
"graphic.bindGraphicRunProduct": { "fields": [
|
|
3314
|
+
{ "name": "productId", "type": "string", "source": "observed" }
|
|
3315
|
+
] },
|
|
3316
|
+
"graphic.changeGraphicRunModel": { "fields": [
|
|
3317
|
+
{ "name": "imageModel", "type": "string", "source": "observed" }
|
|
3318
|
+
] },
|
|
3319
|
+
"graphic.changeGraphicRunQuality": { "fields": [
|
|
3320
|
+
{ "name": "quality", "type": "string", "source": "observed" }
|
|
3321
|
+
] },
|
|
3322
|
+
"graphic.create": { "fields": [
|
|
3323
|
+
{ "name": "aspectRatio", "type": "string", "required": false, "source": "observed" },
|
|
3324
|
+
{ "name": "aspectRatioSource", "type": "string", "enum": ["user", "remembered", "default"], "required": false, "source": "observed" },
|
|
3325
|
+
{ "name": "imageModel", "type": "string", "required": false, "source": "observed" },
|
|
3326
|
+
{ "name": "opening", "type": "object", "required": false, "source": "observed" },
|
|
3327
|
+
{ "name": "productId", "type": "string", "required": false, "source": "observed" },
|
|
3328
|
+
{ "name": "title", "type": "string", "required": false, "source": "observed" }
|
|
3329
|
+
] },
|
|
3330
|
+
"graphic.generateGraphicImages": { "fields": [
|
|
3331
|
+
{ "name": "aspectRatio", "type": "string", "required": false, "source": "observed" },
|
|
3332
|
+
{ "name": "cardId", "type": "string", "required": false, "source": "observed" },
|
|
3333
|
+
{ "name": "items", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "required": false, "source": "observed" },
|
|
3334
|
+
{ "name": "model", "type": "string", "required": false, "source": "observed" },
|
|
3335
|
+
{ "name": "quoteId", "type": "string", "required": false, "source": "observed" },
|
|
3336
|
+
{ "name": "quoteItemIndexes", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Anumber", "required": false, "source": "observed" },
|
|
3337
|
+
{ "name": "quotedCredits", "type": "number", "required": false, "source": "observed" }
|
|
3338
|
+
] },
|
|
3339
|
+
"graphic.quoteGraphicImages": { "fields": [
|
|
3340
|
+
{ "name": "items", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "source": "observed" }
|
|
3341
|
+
] },
|
|
3342
|
+
"graphic.releaseGraphicOpening": { "fields": [
|
|
3343
|
+
{ "name": "attachmentIds", "type": "readonly string[]", "source": "observed" }
|
|
3344
|
+
] },
|
|
3345
|
+
"graphic.saveGraphicImageToLibrary": { "fields": [
|
|
3346
|
+
{ "name": "kind", "type": "string", "enum": ["character", "scene", "prop"], "source": "observed" }
|
|
3347
|
+
] },
|
|
3348
|
+
"graphic.sendGraphicMessage": { "fields": [
|
|
3349
|
+
{ "name": "answers", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "source": "observed" },
|
|
3350
|
+
{ "name": "attachmentIds", "type": "readonly string[]", "source": "observed" },
|
|
3351
|
+
{ "name": "cardId", "type": "string", "source": "observed" },
|
|
3352
|
+
{ "name": "choiceSelection", "source": "observed" },
|
|
3353
|
+
{ "name": "choiceSelectionPresent", "source": "observed" },
|
|
3354
|
+
{ "name": "editImageId", "type": "string", "source": "observed" },
|
|
3355
|
+
{ "name": "length", "source": "observed" },
|
|
3356
|
+
{ "name": "optionIds", "source": "observed" },
|
|
3357
|
+
{ "name": "sourceImageId", "type": "string", "source": "observed" },
|
|
3358
|
+
{ "name": "sourceTurnId", "type": "string", "source": "observed" },
|
|
3359
|
+
{ "name": "templateId", "type": "string|null", "source": "observed" },
|
|
3360
|
+
{ "name": "text", "type": "string", "source": "observed" },
|
|
3361
|
+
{ "name": "uiLocale", "type": "UiLocale", "source": "observed" },
|
|
3362
|
+
{ "name": "workspaceLabels", "type": "Record", "source": "observed" }
|
|
3363
|
+
] },
|
|
3364
|
+
"library.executeProjectLibraryBatch": { "fields": [
|
|
3365
|
+
{ "name": "acknowledgeWaitingRuns", "source": "observed" },
|
|
3366
|
+
{ "name": "confirmPermanentDelete", "source": "observed" },
|
|
3367
|
+
{ "name": "snapshotHash", "type": "string", "required": true, "source": "observed" }
|
|
3368
|
+
] },
|
|
3369
|
+
"library.preflightProjectLibraryBatch": { "fields": [
|
|
3370
|
+
{ "name": "action", "type": "string", "enum": ["download_zip", "retry", "archive", "permanent_delete"], "source": "observed" },
|
|
3371
|
+
{ "name": "selection", "source": "observed" }
|
|
3372
|
+
] },
|
|
3373
|
+
"library.renameLibraryProject": { "fields": [
|
|
3374
|
+
{ "name": "name", "type": "string|null", "source": "observed" }
|
|
3375
|
+
] },
|
|
3376
|
+
"library.trashProjectLibraryItems": { "fields": [
|
|
3377
|
+
{ "name": "items", "type": "readonly ProjectTrashTarget[]", "source": "observed" },
|
|
3378
|
+
{ "name": "kind", "type": "string", "enum": ["commercial_ad", "episode", "graphic"], "required": true, "source": "observed" },
|
|
3379
|
+
{ "name": "originFolderId", "type": "string|null", "required": false, "source": "observed" },
|
|
3380
|
+
{ "name": "sourceId", "type": "string", "required": true, "source": "observed" }
|
|
3381
|
+
] },
|
|
3382
|
+
"membership.orders.create": { "fields": [
|
|
3383
|
+
{ "name": "planVersion", "source": "zod", "required": true, "type": "membershipId", "note": "\u81EA\u5B9A\u4E49\u6821\u9A8C" },
|
|
3384
|
+
{ "name": "intent", "source": "zod", "required": true, "type": "string", "enum": ["purchase", "renew", "upgrade"] },
|
|
3385
|
+
{ "name": "idempotencyKey", "source": "zod", "required": true, "type": "membershipId", "note": "\u81EA\u5B9A\u4E49\u6821\u9A8C" }
|
|
3386
|
+
] },
|
|
3387
|
+
"membership.payments.checkout": { "fields": [
|
|
3388
|
+
{ "name": "appChannel", "type": "string", "required": false, "source": "observed" },
|
|
3389
|
+
{ "name": "channel", "type": "string", "enum": ["shouqianba", "stripe"], "source": "observed" },
|
|
3390
|
+
{ "name": "clientPlatform", "type": "string", "enum": ["android", "web"], "required": false, "source": "observed" }
|
|
3391
|
+
] },
|
|
3392
|
+
"membership.refund": { "fields": [
|
|
3393
|
+
{ "name": "segmentIds", "source": "zod", "required": false, "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1AmembershipId" },
|
|
3394
|
+
{ "name": "idempotencyKey", "source": "zod", "required": true, "type": "membershipId", "note": "\u81EA\u5B9A\u4E49\u6821\u9A8C" },
|
|
3395
|
+
{ "name": "reason", "source": "zod", "required": false, "type": "string" }
|
|
3396
|
+
] },
|
|
3397
|
+
"membership.refundQuote": { "fields": [
|
|
3398
|
+
{ "name": "segmentIds", "source": "zod", "required": false, "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1AmembershipId" }
|
|
3399
|
+
] },
|
|
3400
|
+
"membership.render": { "fields": [
|
|
3401
|
+
{ "name": "brandId", "type": "string", "required": false, "source": "observed" },
|
|
3402
|
+
{ "name": "expectedQuoteHash", "type": "string", "required": true, "source": "observed" },
|
|
3403
|
+
{ "name": "overlays", "type": "object", "required": true, "source": "observed" },
|
|
3404
|
+
{ "name": "sizes", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "required": false, "source": "observed" },
|
|
3405
|
+
{ "name": "sources", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "required": false, "source": "observed" },
|
|
3406
|
+
{ "name": "variants", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "required": false, "source": "observed" }
|
|
3407
|
+
] },
|
|
3408
|
+
"membership.renderPreview": { "fields": [
|
|
3409
|
+
{ "name": "brandId", "type": "string", "required": false, "source": "observed" },
|
|
3410
|
+
{ "name": "overlays", "type": "object", "required": true, "source": "observed" },
|
|
3411
|
+
{ "name": "sizes", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "required": false, "source": "observed" },
|
|
3412
|
+
{ "name": "sources", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "required": false, "source": "observed" },
|
|
3413
|
+
{ "name": "variants", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "required": false, "source": "observed" }
|
|
3414
|
+
] },
|
|
3415
|
+
"membership.renderQuote": { "fields": [
|
|
3416
|
+
{ "name": "brandId", "type": "string", "required": false, "source": "observed" },
|
|
3417
|
+
{ "name": "overlays", "type": "object", "required": true, "source": "observed" },
|
|
3418
|
+
{ "name": "sizes", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "required": false, "source": "observed" },
|
|
3419
|
+
{ "name": "sources", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "required": false, "source": "observed" },
|
|
3420
|
+
{ "name": "variants", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "required": false, "source": "observed" }
|
|
3421
|
+
] },
|
|
3422
|
+
"membership.saveBrand": { "fields": [
|
|
3423
|
+
{ "name": "id", "type": "string", "required": false, "source": "observed" },
|
|
3424
|
+
{ "name": "name", "type": "string", "required": true, "source": "observed" },
|
|
3425
|
+
{ "name": "overlays", "type": "object", "required": true, "source": "observed" }
|
|
3426
|
+
] },
|
|
3427
|
+
"notifications.markNotificationsRead": { "fields": [
|
|
3428
|
+
{ "name": "ids", "type": "readonly string[]", "source": "observed" }
|
|
3429
|
+
] },
|
|
3430
|
+
"notifications.subscribePush": { "fields": [
|
|
3431
|
+
{ "name": "endpoint", "type": "string", "required": true, "source": "observed" },
|
|
3432
|
+
{ "name": "keys", "type": "object", "required": true, "source": "observed" }
|
|
3433
|
+
] },
|
|
3434
|
+
"notifications.unsubscribePush": { "fields": [
|
|
3435
|
+
{ "name": "endpoint", "type": "string", "source": "observed" }
|
|
3436
|
+
] },
|
|
3437
|
+
"products.confirmProductLock": { "fields": [
|
|
3438
|
+
{ "name": "applyCategoryCorrection", "type": "boolean", "required": false, "source": "observed" },
|
|
3439
|
+
{ "name": "productLock", "type": "object", "required": false, "source": "observed" }
|
|
3440
|
+
] },
|
|
3441
|
+
"products.create": { "fields": [
|
|
3442
|
+
{ "name": "category", "type": "string", "enum": ["apparel", "beauty", "food", "home", "digital", "maternity"], "required": false, "source": "observed" },
|
|
3443
|
+
{ "name": "classificationHint", "type": "string", "required": false, "source": "observed" },
|
|
3444
|
+
{ "name": "intelligence", "type": "object|null", "required": false, "source": "observed" },
|
|
3445
|
+
{ "name": "name", "type": "string", "required": true, "source": "observed" },
|
|
3446
|
+
{ "name": "productLock", "type": "object", "required": false, "source": "observed" },
|
|
3447
|
+
{ "name": "sku", "type": "string", "required": false, "source": "observed" }
|
|
3448
|
+
] },
|
|
3449
|
+
"products.createSeries": { "fields": [
|
|
3450
|
+
{ "name": "mainLine", "type": "string", "required": false, "source": "observed" },
|
|
3451
|
+
{ "name": "projectId", "type": "string", "required": true, "source": "observed" },
|
|
3452
|
+
{ "name": "title", "type": "string", "required": false, "source": "observed" }
|
|
3453
|
+
] },
|
|
3454
|
+
"products.mergeProducts": { "fields": [
|
|
3455
|
+
{ "name": "sourceProductIds", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Astring", "source": "observed" }
|
|
3456
|
+
] },
|
|
3457
|
+
"products.recognizeProductLock": { "fields": [
|
|
3458
|
+
{ "name": "force", "type": "boolean", "required": false, "source": "observed" }
|
|
3459
|
+
] },
|
|
3460
|
+
"products.renameProduct": { "fields": [
|
|
3461
|
+
{ "name": "name", "type": "string", "source": "observed" }
|
|
3462
|
+
] },
|
|
3463
|
+
"public.checkReferralCode": { "fields": [
|
|
3464
|
+
{ "name": "code", "type": "string", "source": "observed" }
|
|
3465
|
+
] },
|
|
3466
|
+
"public.recordReferralVisit": { "fields": [
|
|
3467
|
+
{ "name": "code", "type": "string", "source": "observed" }
|
|
3468
|
+
] },
|
|
3469
|
+
"public.submitTrialRequest": { "fields": [
|
|
3470
|
+
{ "name": "brief", "type": "string", "required": false, "source": "observed" },
|
|
3471
|
+
{ "name": "category", "type": "string", "required": true, "source": "observed" },
|
|
3472
|
+
{ "name": "company", "type": "string", "required": true, "source": "observed" },
|
|
3473
|
+
{ "name": "contact", "type": "string", "required": true, "source": "observed" },
|
|
3474
|
+
{ "name": "language", "type": "string", "required": true, "source": "observed" },
|
|
3475
|
+
{ "name": "market", "type": "string", "required": true, "source": "observed" },
|
|
3476
|
+
{ "name": "source", "type": "string", "enum": ["public-access", "agent-application"], "required": false, "source": "observed" },
|
|
3477
|
+
{ "name": "style", "type": "string", "required": true, "source": "observed" }
|
|
3478
|
+
] },
|
|
3479
|
+
"series.createEpisode": { "fields": [
|
|
3480
|
+
{ "name": "logline", "type": "string", "required": false, "source": "observed" },
|
|
3481
|
+
{ "name": "title", "type": "string", "required": false, "source": "observed" }
|
|
3482
|
+
] },
|
|
3483
|
+
"templates.createTemplateShortOrder": { "fields": [
|
|
3484
|
+
{ "name": "expectedQuoteHash", "type": "string", "required": true, "source": "observed" },
|
|
3485
|
+
{ "name": "props", "type": "Record", "required": true, "source": "observed" },
|
|
3486
|
+
{ "name": "templateId", "type": "string", "required": true, "source": "observed" }
|
|
3487
|
+
] },
|
|
3488
|
+
"templates.quoteTemplateShortOrder": { "fields": [
|
|
3489
|
+
{ "name": "props", "type": "Record", "required": true, "source": "observed" },
|
|
3490
|
+
{ "name": "templateId", "type": "string", "required": true, "source": "observed" }
|
|
3491
|
+
] },
|
|
3492
|
+
"templates.startRunFromStageTemplate": { "fields": [
|
|
3493
|
+
{ "name": "intent", "type": "string", "required": false, "source": "observed" },
|
|
3494
|
+
{ "name": "preferences", "type": "object", "required": false, "source": "observed" },
|
|
3495
|
+
{ "name": "productId", "type": "string", "required": true, "source": "observed" }
|
|
3496
|
+
] },
|
|
3497
|
+
"upscale.createUpscaleOrder": { "fields": [
|
|
3498
|
+
{ "name": "quoteId", "source": "zod", "required": true, "type": "string" },
|
|
3499
|
+
{ "name": "quoteHash", "source": "zod", "required": true, "type": "string" }
|
|
3500
|
+
] },
|
|
3501
|
+
"upscale.quoteUpscale": { "fields": [
|
|
3502
|
+
{ "name": "source", "source": "zod", "required": true, "type": "upscaleSourceSchema", "note": "\u81EA\u5B9A\u4E49\u6821\u9A8C" },
|
|
3503
|
+
{ "name": "tier", "source": "zod", "required": true, "type": "string", "enum": ["1080p", "4k"] }
|
|
3504
|
+
] },
|
|
3505
|
+
"videos.adoptCommercialAdAssetGapUploaded": { "fields": [
|
|
3506
|
+
{ "name": "id", "type": "string", "required": true, "source": "observed" },
|
|
3507
|
+
{ "name": "kind", "type": "string", "enum": ["product_image", "attachment"], "required": true, "source": "observed" }
|
|
3508
|
+
] },
|
|
3509
|
+
"videos.applyCommercialAdMusic": { "fields": [
|
|
3510
|
+
{ "name": "placement", "type": "CommercialAdMusicPlacement", "required": false, "source": "observed" },
|
|
3511
|
+
{ "name": "trackIndex", "type": "number", "required": true, "source": "observed" }
|
|
3512
|
+
] },
|
|
3513
|
+
"videos.applyCustomVideoCut": { "fields": [
|
|
3514
|
+
{ "name": "durationSeconds", "type": "number", "required": false, "source": "observed" },
|
|
3515
|
+
{ "name": "instruction", "type": "string", "required": true, "source": "observed" },
|
|
3516
|
+
{ "name": "locale", "type": "string", "required": false, "source": "observed" },
|
|
3517
|
+
{ "name": "segmentNumber", "type": "number", "required": false, "source": "observed" }
|
|
3518
|
+
] },
|
|
3519
|
+
"videos.attachCommercialAdRunAssets": { "fields": [
|
|
3520
|
+
{ "name": "assetIds", "source": "observed" }
|
|
3521
|
+
] },
|
|
3522
|
+
"videos.cloneSharedRecipe": { "fields": [
|
|
3523
|
+
{ "name": "intent", "type": "string", "required": false, "source": "observed" },
|
|
3524
|
+
{ "name": "preferences", "type": "object", "required": false, "source": "observed" },
|
|
3525
|
+
{ "name": "productId", "type": "string", "required": true, "source": "observed" }
|
|
3526
|
+
] },
|
|
3527
|
+
"videos.confirmCommercialAdAreaEdit": { "fields": [
|
|
3528
|
+
{ "name": "quoteId", "type": "string", "source": "observed" }
|
|
3529
|
+
] },
|
|
3530
|
+
"videos.confirmCommercialAdDirectorImage": { "fields": [
|
|
3531
|
+
{ "name": "confirmation", "type": "Omit<CommercialAdRootProductionConfirmat", "required": false, "source": "observed" },
|
|
3532
|
+
{ "name": "expectedVersion", "type": "number", "required": true, "source": "observed" },
|
|
3533
|
+
{ "name": "source", "type": "string", "enum": ["user", "auto_approve"], "required": false, "source": "observed" }
|
|
3534
|
+
] },
|
|
3535
|
+
"videos.confirmCommercialAdRootProductLock": { "fields": [
|
|
3536
|
+
{ "name": "applyCategoryCorrection", "type": "boolean", "required": true, "source": "observed" },
|
|
3537
|
+
{ "name": "expectedVersion", "type": "number", "required": true, "source": "observed" }
|
|
3538
|
+
] },
|
|
3539
|
+
"videos.confirmCommercialAdRootProduction": { "fields": [
|
|
3540
|
+
{ "name": "confirmation", "type": "object", "required": false, "source": "observed" },
|
|
3541
|
+
{ "name": "expectedVersion", "type": "number", "required": true, "source": "observed" },
|
|
3542
|
+
{ "name": "previewHash", "type": "string", "required": false, "source": "observed" },
|
|
3543
|
+
{ "name": "source", "type": "string", "enum": ["auto_start", "auto_approve"], "required": false, "source": "observed" }
|
|
3544
|
+
] },
|
|
3545
|
+
"videos.confirmShowcaseVideo": { "fields": [
|
|
3546
|
+
{ "name": "expectedCredits", "type": "number", "required": true, "source": "observed" },
|
|
3547
|
+
{ "name": "skipStoryboard", "type": "boolean", "required": false, "source": "observed" }
|
|
3548
|
+
] },
|
|
3549
|
+
"videos.continueCommercialAdVoiceSelection": { "fields": [
|
|
3550
|
+
{ "name": "expectedVersion", "type": "number", "required": true, "source": "observed" }
|
|
3551
|
+
] },
|
|
3552
|
+
"videos.createAudioNode": { "fields": [
|
|
3553
|
+
{ "name": "audioUrl", "type": "string|null", "required": false, "source": "observed" },
|
|
3554
|
+
{ "name": "characterAnchorId", "type": "string|null", "required": false, "source": "observed" },
|
|
3555
|
+
{ "name": "mode", "type": "string", "enum": ["voiceover", "music", "sfx", "lipsync"], "required": false, "source": "observed" },
|
|
3556
|
+
{ "name": "posX", "type": "number", "required": false, "source": "observed" },
|
|
3557
|
+
{ "name": "posY", "type": "number", "required": false, "source": "observed" },
|
|
3558
|
+
{ "name": "prompt", "type": "string", "required": false, "source": "observed" },
|
|
3559
|
+
{ "name": "targetSegmentId", "type": "string|null", "required": false, "source": "observed" },
|
|
3560
|
+
{ "name": "title", "type": "string", "required": false, "source": "observed" },
|
|
3561
|
+
{ "name": "trim", "type": "object|null", "required": false, "source": "observed" },
|
|
3562
|
+
{ "name": "voiceId", "type": "string|null", "required": false, "source": "observed" }
|
|
3563
|
+
] },
|
|
3564
|
+
"videos.createCanvasDraft": { "fields": [
|
|
3565
|
+
{ "name": "aspectRatio", "type": "string", "required": false, "source": "observed" },
|
|
3566
|
+
{ "name": "body", "type": "string", "required": false, "source": "observed" },
|
|
3567
|
+
{ "name": "height", "type": "number", "required": false, "source": "observed" },
|
|
3568
|
+
{ "name": "id", "type": "string", "required": false, "source": "observed" },
|
|
3569
|
+
{ "name": "kind", "type": "string", "enum": ["note", "image"], "required": false, "source": "observed" },
|
|
3570
|
+
{ "name": "modelChoice", "type": "string|null", "required": false, "source": "observed" },
|
|
3571
|
+
{ "name": "posX", "type": "number", "required": false, "source": "observed" },
|
|
3572
|
+
{ "name": "posY", "type": "number", "required": false, "source": "observed" },
|
|
3573
|
+
{ "name": "referenceNodeIds", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Astring", "required": false, "source": "observed" },
|
|
3574
|
+
{ "name": "sourceDraftId", "type": "string", "required": false, "source": "observed" },
|
|
3575
|
+
{ "name": "title", "type": "string", "required": false, "source": "observed" },
|
|
3576
|
+
{ "name": "width", "type": "number", "required": false, "source": "observed" }
|
|
3577
|
+
] },
|
|
3578
|
+
"videos.createCommercialAdPresetVoiceSample": { "fields": [
|
|
3579
|
+
{ "name": "retryFailed", "type": "boolean", "required": false, "source": "observed" },
|
|
3580
|
+
{ "name": "roleKey", "type": "string", "required": false, "source": "observed" },
|
|
3581
|
+
{ "name": "useSample", "type": "boolean", "required": false, "source": "observed" },
|
|
3582
|
+
{ "name": "voiceId", "type": "string", "required": true, "source": "observed" }
|
|
3583
|
+
] },
|
|
3584
|
+
"videos.createShowcaseVideo": { "fields": [
|
|
3585
|
+
{ "name": "aspectRatio", "type": "string", "required": false, "source": "observed" },
|
|
3586
|
+
{ "name": "assetRebindings", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "required": false, "source": "observed" },
|
|
3587
|
+
{ "name": "creativePlanId", "type": "string", "required": false, "source": "observed" },
|
|
3588
|
+
{ "name": "description", "type": "string", "required": true, "source": "observed" },
|
|
3589
|
+
{ "name": "durationSeconds", "type": "number", "required": false, "source": "observed" },
|
|
3590
|
+
{ "name": "hookMethod", "type": "string", "required": false, "source": "observed" },
|
|
3591
|
+
{ "name": "imageModel", "type": "string", "required": false, "source": "observed" },
|
|
3592
|
+
{ "name": "material", "type": "string", "required": false, "source": "observed" },
|
|
3593
|
+
{ "name": "narrativeStructure", "type": "string", "required": false, "source": "observed" },
|
|
3594
|
+
{ "name": "planReceiptHash", "type": "string", "required": false, "source": "observed" },
|
|
3595
|
+
{ "name": "planReceiptId", "type": "string", "required": false, "source": "observed" },
|
|
3596
|
+
{ "name": "primaryContent", "type": "string", "required": false, "source": "observed" },
|
|
3597
|
+
{ "name": "productId", "type": "string", "required": true, "source": "observed" },
|
|
3598
|
+
{ "name": "promptOverride", "type": "string", "required": false, "source": "observed" },
|
|
3599
|
+
{ "name": "resolution", "type": "string", "required": false, "source": "observed" },
|
|
3600
|
+
{ "name": "speed", "type": "string", "required": false, "source": "observed" },
|
|
3601
|
+
{ "name": "stylePreset", "type": "string", "required": false, "source": "observed" },
|
|
3602
|
+
{ "name": "usage", "type": "string", "required": false, "source": "observed" },
|
|
3603
|
+
{ "name": "visualStyle", "type": "string", "required": false, "source": "observed" },
|
|
3604
|
+
{ "name": "withStoryboard", "type": "boolean", "required": false, "source": "observed" }
|
|
3605
|
+
] },
|
|
3606
|
+
"videos.decideCommercialAdPublicReferenceCandidate": { "fields": [
|
|
3607
|
+
{ "name": "decision", "type": "string", "enum": ["accept", "reject"], "required": true, "source": "observed" },
|
|
3608
|
+
{ "name": "expectedVersion", "type": "number", "required": true, "source": "observed" },
|
|
3609
|
+
{ "name": "roleName", "type": "string", "required": false, "source": "observed" }
|
|
3610
|
+
] },
|
|
3611
|
+
"videos.downloadCommercialAdSelectedAssetsZip": { "fields": [
|
|
3612
|
+
{ "name": "assetIds", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Astring", "source": "observed" }
|
|
3613
|
+
] },
|
|
3614
|
+
"videos.exportCommercialAdRoughCut": { "fields": [
|
|
3615
|
+
{ "name": "productionId", "type": "string", "required": false, "source": "observed" },
|
|
3616
|
+
{ "name": "segments", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "required": true, "source": "observed" },
|
|
3617
|
+
{ "name": "sourceToken", "type": "string", "required": true, "source": "observed" }
|
|
3618
|
+
] },
|
|
3619
|
+
"videos.fetchAttachmentFaceHints": { "fields": [
|
|
3620
|
+
{ "name": "attachmentIds", "type": "readonly string[]", "source": "observed" }
|
|
3621
|
+
] },
|
|
3622
|
+
"videos.generateCommercialAdAsset": { "fields": [
|
|
3623
|
+
{ "name": "description", "type": "string", "required": true, "source": "observed" },
|
|
3624
|
+
{ "name": "kind", "type": "string", "enum": ["character", "scene"], "required": true, "source": "observed" },
|
|
3625
|
+
{ "name": "productId", "type": "string", "required": true, "source": "observed" }
|
|
3626
|
+
] },
|
|
3627
|
+
"videos.generateCommercialAdNode": { "fields": [
|
|
3628
|
+
{ "name": "credits", "type": "number", "required": true, "source": "observed" },
|
|
3629
|
+
{ "name": "imageModel", "type": "string", "required": false, "source": "observed" },
|
|
3630
|
+
{ "name": "prompt", "type": "string", "required": false, "source": "observed" },
|
|
3631
|
+
{ "name": "quoteStamp", "type": "string", "required": true, "source": "observed" }
|
|
3632
|
+
] },
|
|
3633
|
+
"videos.planShowcaseDuration": { "fields": [
|
|
3634
|
+
{ "name": "category", "type": "string", "required": false, "source": "observed" },
|
|
3635
|
+
{ "name": "description", "type": "string", "required": false, "source": "observed" },
|
|
3636
|
+
{ "name": "material", "type": "string", "required": false, "source": "observed" },
|
|
3637
|
+
{ "name": "productName", "type": "string", "required": false, "source": "observed" },
|
|
3638
|
+
{ "name": "stylePreset", "type": "string", "required": false, "source": "observed" },
|
|
3639
|
+
{ "name": "usage", "type": "string", "required": false, "source": "observed" }
|
|
3640
|
+
] },
|
|
3641
|
+
"videos.pollShowcaseAiPrompt": { "fields": [
|
|
3642
|
+
{ "name": "angles", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Astring", "required": false, "source": "observed" },
|
|
3643
|
+
{ "name": "aspectRatio", "type": "string", "required": false, "source": "observed" },
|
|
3644
|
+
{ "name": "autoDuration", "type": "boolean", "required": false, "source": "observed" },
|
|
3645
|
+
{ "name": "category", "type": "string", "required": false, "source": "observed" },
|
|
3646
|
+
{ "name": "creativePlanId", "type": "string", "required": false, "source": "observed" },
|
|
3647
|
+
{ "name": "description", "type": "string", "required": true, "source": "observed" },
|
|
3648
|
+
{ "name": "durationMode", "type": "string", "enum": ["auto", "manual"], "required": false, "source": "observed" },
|
|
3649
|
+
{ "name": "durationSeconds", "type": "number", "required": false, "source": "observed" },
|
|
3650
|
+
{ "name": "hookMethod", "type": "string", "required": false, "source": "observed" },
|
|
3651
|
+
{ "name": "material", "type": "string", "required": false, "source": "observed" },
|
|
3652
|
+
{ "name": "narrativeStructure", "type": "string", "required": false, "source": "observed" },
|
|
3653
|
+
{ "name": "primaryContent", "type": "string", "required": false, "source": "observed" },
|
|
3654
|
+
{ "name": "productId", "type": "string", "required": false, "source": "observed" },
|
|
3655
|
+
{ "name": "productName", "type": "string", "required": true, "source": "observed" },
|
|
3656
|
+
{ "name": "resolution", "type": "string", "required": false, "source": "observed" },
|
|
3657
|
+
{ "name": "speed", "type": "string", "required": false, "source": "observed" },
|
|
3658
|
+
{ "name": "stylePreset", "type": "string", "required": false, "source": "observed" },
|
|
3659
|
+
{ "name": "usage", "type": "string", "required": false, "source": "observed" },
|
|
3660
|
+
{ "name": "visualStyle", "type": "string", "required": false, "source": "observed" }
|
|
3661
|
+
] },
|
|
3662
|
+
"videos.postCommercialAdRootMessage": { "fields": [
|
|
3663
|
+
{ "name": "attachmentIds", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Astring", "required": false, "source": "observed" },
|
|
3664
|
+
{ "name": "choiceSelection", "type": "object|null", "required": false, "source": "observed" },
|
|
3665
|
+
{ "name": "expectedVersion", "type": "number", "required": false, "source": "observed" },
|
|
3666
|
+
{ "name": "settingsPatch", "type": "object", "required": false, "source": "observed" },
|
|
3667
|
+
{ "name": "skipped", "type": "boolean", "required": false, "source": "observed" },
|
|
3668
|
+
{ "name": "stageAction", "type": "object", "required": false, "source": "observed" },
|
|
3669
|
+
{ "name": "text", "type": "string", "required": true, "source": "observed" }
|
|
3670
|
+
] },
|
|
3671
|
+
"videos.previewCustomVideoCut": { "fields": [
|
|
3672
|
+
{ "name": "durationSeconds", "type": "number", "required": false, "source": "observed" },
|
|
3673
|
+
{ "name": "instruction", "type": "string", "required": true, "source": "observed" },
|
|
3674
|
+
{ "name": "locale", "type": "string", "required": false, "source": "observed" },
|
|
3675
|
+
{ "name": "segmentNumber", "type": "number", "required": false, "source": "observed" }
|
|
3676
|
+
] },
|
|
3677
|
+
"videos.quoteCommercialAdNode": { "fields": [
|
|
3678
|
+
{ "name": "imageModel", "type": "string", "required": false, "source": "observed" },
|
|
3679
|
+
{ "name": "prompt", "type": "string", "required": false, "source": "observed" }
|
|
3680
|
+
] },
|
|
3681
|
+
"videos.redoShowcaseStoryboard": { "fields": [
|
|
3682
|
+
{ "name": "expectedCredits", "type": "number", "required": true, "source": "observed" }
|
|
3683
|
+
] },
|
|
3684
|
+
"videos.renameCommercialAdAsset": { "fields": [
|
|
3685
|
+
{ "name": "kind", "type": "string", "enum": ["character", "scene", "prop"], "required": false, "source": "observed" },
|
|
3686
|
+
{ "name": "name", "type": "string", "source": "observed", "required": false }
|
|
3687
|
+
] },
|
|
3688
|
+
"videos.resolveCommercialAdAssetGap": { "fields": [
|
|
3689
|
+
{ "name": "action", "type": "string", "enum": ["use_existing"], "required": true, "source": "observed" },
|
|
3690
|
+
{ "name": "assetId", "type": "string", "required": true, "source": "observed" },
|
|
3691
|
+
{ "name": "expectedVersion", "type": "number", "required": true, "source": "observed" }
|
|
3692
|
+
] },
|
|
3693
|
+
"videos.resolveCommercialAdAssetGaps": { "fields": [
|
|
3694
|
+
{ "name": "expectedVersion", "type": "number", "required": true, "source": "observed" },
|
|
3695
|
+
{ "name": "items", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "required": true, "source": "observed" }
|
|
3696
|
+
] },
|
|
3697
|
+
"videos.restoreCommercialAdNodeVersion": { "fields": [
|
|
3698
|
+
{ "name": "assetId", "type": "string", "required": false, "source": "observed" },
|
|
3699
|
+
{ "name": "thumbId", "type": "string", "required": false, "source": "observed" },
|
|
3700
|
+
{ "name": "url", "type": "string", "required": false, "source": "observed" }
|
|
3701
|
+
] },
|
|
3702
|
+
"videos.restoreCommercialAdRunFileVersion": { "fields": [
|
|
3703
|
+
{ "name": "expectedCurrentVersionId", "type": "string", "source": "observed" }
|
|
3704
|
+
] },
|
|
3705
|
+
"videos.resumeCommercialAdRootAfterProductImage": { "fields": [
|
|
3706
|
+
{ "name": "expectedVersion", "type": "number", "source": "observed" }
|
|
3707
|
+
] },
|
|
3708
|
+
"videos.retryCommercialAdRootFailedStep": { "fields": [
|
|
3709
|
+
{ "name": "expectedCredits", "type": "number", "required": false, "source": "observed" },
|
|
3710
|
+
{ "name": "expectedVersion", "type": "number", "required": true, "source": "observed" },
|
|
3711
|
+
{ "name": "storyboardTaskId", "type": "string", "required": false, "source": "observed" }
|
|
3712
|
+
] },
|
|
3713
|
+
"videos.runVisionToolCutout": { "fields": [
|
|
3714
|
+
{ "name": "idempotencyKey", "type": "string", "required": true, "source": "observed" },
|
|
3715
|
+
{ "name": "imageBase64", "type": "string", "required": false, "source": "observed" },
|
|
3716
|
+
{ "name": "nodeId", "type": "string", "required": true, "source": "observed" }
|
|
3717
|
+
] },
|
|
3718
|
+
"videos.runVisionToolPointMask": { "fields": [
|
|
3719
|
+
{ "name": "height", "type": "number", "required": true, "source": "observed" },
|
|
3720
|
+
{ "name": "idempotencyKey", "type": "string", "required": true, "source": "observed" },
|
|
3721
|
+
{ "name": "negativePoints", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "required": false, "source": "observed" },
|
|
3722
|
+
{ "name": "nodeId", "type": "string", "required": true, "source": "observed" },
|
|
3723
|
+
{ "name": "positivePoints", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Aobject", "required": true, "source": "observed" },
|
|
3724
|
+
{ "name": "width", "type": "number", "required": true, "source": "observed" }
|
|
3725
|
+
] },
|
|
3726
|
+
"videos.saveCanvasGroups": { "fields": [
|
|
3727
|
+
{ "name": "groups", "type": "readonly SaveCanvasGroupItemInput[]", "required": true, "source": "observed" }
|
|
3728
|
+
] },
|
|
3729
|
+
"videos.saveCanvasLayout": { "fields": [
|
|
3730
|
+
{ "name": "baseRevision", "type": "number", "required": false, "source": "observed" },
|
|
3731
|
+
{ "name": "hiddenIds", "source": "observed" },
|
|
3732
|
+
{ "name": "positions", "type": "Record", "required": true, "source": "observed" },
|
|
3733
|
+
{ "name": "prefs", "type": "object", "required": false, "source": "observed" }
|
|
3734
|
+
] },
|
|
3735
|
+
"videos.saveCharacterVoiceBindings": { "fields": [
|
|
3736
|
+
{ "name": "voiceBindings", "type": "Record", "required": true, "source": "observed" }
|
|
3737
|
+
] },
|
|
3738
|
+
"videos.saveDirectorStagePrevis": { "fields": [
|
|
3739
|
+
{ "name": "poses", "type": "PrevisShotPoses|null", "required": true, "source": "observed" },
|
|
3740
|
+
{ "name": "shotNumber", "type": "number", "required": true, "source": "observed" }
|
|
3741
|
+
] },
|
|
3742
|
+
"videos.selectCommercialAdVoiceCandidate": { "fields": [
|
|
3743
|
+
{ "name": "candidateId", "type": "string|null", "required": true, "source": "observed" },
|
|
3744
|
+
{ "name": "expectedVersion", "type": "number", "required": true, "source": "observed" },
|
|
3745
|
+
{ "name": "roleKey", "type": "string", "required": true, "source": "observed" },
|
|
3746
|
+
{ "name": "roleName", "type": "string", "required": false, "source": "observed" }
|
|
3747
|
+
] },
|
|
3748
|
+
"videos.setCanvasNodeRating": { "fields": [
|
|
3749
|
+
{ "name": "stars", "type": "string", "source": "observed" }
|
|
3750
|
+
] },
|
|
3751
|
+
"videos.setCommercialAdSubtitles": { "fields": [
|
|
3752
|
+
{ "name": "enabled", "type": "boolean", "source": "observed" }
|
|
3753
|
+
] },
|
|
3754
|
+
"videos.shareRunRecipe": { "fields": [
|
|
3755
|
+
{ "name": "title", "type": "string", "required": false, "source": "observed" }
|
|
3756
|
+
] },
|
|
3757
|
+
"videos.startCommercialAdRun": { "fields": [
|
|
3758
|
+
{ "name": "budgetLimitCredits", "type": "number", "required": false, "source": "observed" },
|
|
3759
|
+
{ "name": "createNewOrder", "type": "boolean", "required": false, "source": "observed" },
|
|
3760
|
+
{ "name": "inspiration", "type": "object", "required": false, "source": "observed" },
|
|
3761
|
+
{ "name": "intent", "type": "string", "required": true, "source": "observed" },
|
|
3762
|
+
{ "name": "playPreference", "type": "object", "required": false, "source": "observed" },
|
|
3763
|
+
{ "name": "preferences", "type": "object", "required": false, "source": "observed" },
|
|
3764
|
+
{ "name": "productId", "type": "string", "required": true, "source": "observed" }
|
|
3765
|
+
] },
|
|
3766
|
+
"videos.streamCommercialAdRootMessage": { "fields": [
|
|
3767
|
+
{ "name": "attachmentIds", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Astring", "required": false, "source": "observed" },
|
|
3768
|
+
{ "name": "choiceSelection", "type": "object|null", "required": false, "source": "observed" },
|
|
3769
|
+
{ "name": "expectedVersion", "type": "number", "required": false, "source": "observed" },
|
|
3770
|
+
{ "name": "settingsPatch", "type": "object", "required": false, "source": "observed" },
|
|
3771
|
+
{ "name": "skipped", "type": "boolean", "required": false, "source": "observed" },
|
|
3772
|
+
{ "name": "stageAction", "type": "object", "required": false, "source": "observed" },
|
|
3773
|
+
{ "name": "text", "type": "string", "required": true, "source": "observed" }
|
|
3774
|
+
] },
|
|
3775
|
+
"videos.triggerRunAutoConfirm": { "fields": [
|
|
3776
|
+
{ "name": "cardId", "type": "string", "required": false, "source": "observed" },
|
|
3777
|
+
{ "name": "confirmation", "type": "object|Omit<CommercialAdRootProductionConfirmat", "required": false, "source": "observed" },
|
|
3778
|
+
{ "name": "quoteVersion", "type": "string", "required": false, "source": "observed" }
|
|
3779
|
+
] },
|
|
3780
|
+
"videos.updateAudioNode": { "fields": [
|
|
3781
|
+
{ "name": "audioUrl", "type": "string|unknown", "required": false, "source": "observed" },
|
|
3782
|
+
{ "name": "characterAnchorId", "type": "string|unknown", "required": false, "source": "observed" },
|
|
3783
|
+
{ "name": "mode", "type": "string", "enum": ["voiceover", "music", "sfx", "lipsync"], "required": false, "source": "observed" },
|
|
3784
|
+
{ "name": "posX", "type": "number", "required": false, "source": "observed" },
|
|
3785
|
+
{ "name": "posY", "type": "number", "required": false, "source": "observed" },
|
|
3786
|
+
{ "name": "prompt", "type": "string", "required": false, "source": "observed" },
|
|
3787
|
+
{ "name": "targetSegmentId", "type": "string|unknown", "required": false, "source": "observed" },
|
|
3788
|
+
{ "name": "title", "type": "string", "required": false, "source": "observed" },
|
|
3789
|
+
{ "name": "trim", "type": "unknown", "required": false, "source": "observed" },
|
|
3790
|
+
{ "name": "voiceId", "type": "string|unknown", "required": false, "source": "observed" }
|
|
3791
|
+
] },
|
|
3792
|
+
"videos.updateCanvasDraft": { "fields": [
|
|
3793
|
+
{ "name": "aspectRatio", "type": "string", "required": false, "source": "observed" },
|
|
3794
|
+
{ "name": "body", "type": "string", "required": false, "source": "observed" },
|
|
3795
|
+
{ "name": "height", "type": "number", "required": false, "source": "observed" },
|
|
3796
|
+
{ "name": "modelChoice", "type": "string|null", "required": false, "source": "observed" },
|
|
3797
|
+
{ "name": "posX", "type": "number", "required": false, "source": "observed" },
|
|
3798
|
+
{ "name": "posY", "type": "number", "required": false, "source": "observed" },
|
|
3799
|
+
{ "name": "referenceNodeIds", "type": "array", "note": "\u5143\u7D20\u7C7B\u578B\uFF1Astring", "required": false, "source": "observed" },
|
|
3800
|
+
{ "name": "title", "type": "string", "required": false, "source": "observed" },
|
|
3801
|
+
{ "name": "width", "type": "number", "required": false, "source": "observed" }
|
|
3802
|
+
] },
|
|
3803
|
+
"videos.updateCommercialAdRootSettings": { "fields": [
|
|
3804
|
+
{ "name": "expectedVersion", "type": "number", "required": true, "source": "observed" },
|
|
3805
|
+
{ "name": "patch", "type": "object", "required": true, "source": "observed" }
|
|
3806
|
+
] },
|
|
3807
|
+
"videos.updateRunAutoConfirm": { "fields": [
|
|
3808
|
+
{ "name": "enabled", "type": "boolean", "required": true, "source": "observed" },
|
|
3809
|
+
{ "name": "expectedVersion", "type": "number", "required": false, "source": "observed" },
|
|
3810
|
+
{ "name": "maxAutoBu", "type": "number", "required": false, "source": "observed" },
|
|
3811
|
+
{ "name": "updatedBy", "type": "string", "enum": ["user_toggle", "banner_off", "system_reset"], "required": false, "source": "observed" }
|
|
3812
|
+
] }
|
|
3813
|
+
};
|
|
3814
|
+
|
|
2810
3815
|
// src/web-operation-contract.ts
|
|
2811
3816
|
import { extname } from "node:path";
|
|
2812
3817
|
var BUSINESS_HEADERS = /* @__PURE__ */ new Set(["prefer", "x-script-fingerprint", "x-attachment-delivery", "x-attachment-name"]);
|
|
2813
3818
|
function buildBusinessHeaders(operation, supplied = {}, filename) {
|
|
2814
3819
|
const rules = operation.businessHeaders ?? {};
|
|
2815
|
-
const
|
|
3820
|
+
const result4 = {};
|
|
2816
3821
|
for (const [name2, rule] of Object.entries(rules)) {
|
|
2817
3822
|
if (!BUSINESS_HEADERS.has(name2)) throw usageError(`\u64CD\u4F5C ${operation.id} \u7684\u4E1A\u52A1\u5934\u914D\u7F6E\u65E0\u6548`);
|
|
2818
|
-
if (rule.default !== void 0)
|
|
3823
|
+
if (rule.default !== void 0) result4[name2] = rule.default;
|
|
2819
3824
|
if (rule.fromFilename && filename) {
|
|
2820
3825
|
try {
|
|
2821
|
-
|
|
3826
|
+
result4[name2] = encodeURIComponent(filename);
|
|
2822
3827
|
} catch {
|
|
2823
3828
|
}
|
|
2824
3829
|
}
|
|
@@ -2830,14 +3835,14 @@ function buildBusinessHeaders(operation, supplied = {}, filename) {
|
|
|
2830
3835
|
if (seen.has(name2)) throw usageError(`\u8BF7\u6C42\u5934 ${raw} \u91CD\u590D`);
|
|
2831
3836
|
seen.add(name2);
|
|
2832
3837
|
if (typeof value !== "string" || !value.trim() || value.length > 4096 || /[^\x20-\x7e]/u.test(value)) throw usageError(`\u8BF7\u6C42\u5934 ${raw} \u5FC5\u987B\u662F\u6709\u6548\u7684 ASCII \u5B57\u7B26\u4E32\uFF1B\u6587\u4EF6\u540D\u8BF7\u5148 URL \u7F16\u7801`);
|
|
2833
|
-
|
|
3838
|
+
result4[name2] = value;
|
|
2834
3839
|
}
|
|
2835
3840
|
for (const [name2, rule] of Object.entries(rules)) {
|
|
2836
|
-
const value =
|
|
3841
|
+
const value = result4[name2];
|
|
2837
3842
|
if (rule.required && !value) throw usageError(`\u64CD\u4F5C ${operation.id} \u9700\u8981\u901A\u8FC7 --headers \u63D0\u4F9B ${name2}`);
|
|
2838
3843
|
if (value && rule.values && !rule.values.includes(value)) throw usageError(`\u8BF7\u6C42\u5934 ${name2} \u53EA\u652F\u6301 ${rule.values.join("\u3001")}`);
|
|
2839
3844
|
}
|
|
2840
|
-
return
|
|
3845
|
+
return result4;
|
|
2841
3846
|
}
|
|
2842
3847
|
var MIB = 1024 * 1024;
|
|
2843
3848
|
var IMAGE = ["image/png", "image/jpeg", "image/webp"];
|
|
@@ -2871,9 +3876,14 @@ var MIME_BY_EXTENSION = {
|
|
|
2871
3876
|
function webUploadPolicy(operation, filename) {
|
|
2872
3877
|
const extension = extname(filename).toLowerCase();
|
|
2873
3878
|
const policy = operation.uploadPolicy;
|
|
2874
|
-
const
|
|
3879
|
+
const audioRecording = policy === "storySpeech" || policy === "speechTranscription";
|
|
3880
|
+
const mime = audioRecording && extension === ".webm" ? "audio/webm" : policy === "speechTranscription" && extension === ".mp4" ? "audio/mp4" : MIME_BY_EXTENSION[extension];
|
|
2875
3881
|
const unsupported = () => usageError(`\u64CD\u4F5C ${operation.id} \u4E0D\u652F\u6301\u6B64\u6587\u4EF6\u7C7B\u578B\uFF1A${extension || "\u65E0\u6269\u5C55\u540D"}`);
|
|
2876
3882
|
if (!mime || !policy) throw unsupported();
|
|
3883
|
+
if (policy === "speechTranscription") {
|
|
3884
|
+
if (!SPEECH.includes(mime) && !["audio/aac", "audio/flac"].includes(mime)) throw unsupported();
|
|
3885
|
+
return { mime, maxBytes: 2 * MIB };
|
|
3886
|
+
}
|
|
2877
3887
|
if (policy === "storySpeech") {
|
|
2878
3888
|
if (!SPEECH.includes(mime)) throw unsupported();
|
|
2879
3889
|
return { mime, maxBytes: 20 * MIB };
|
|
@@ -2903,6 +3913,7 @@ var MAX_DOWNLOAD_BYTES2 = 1024 * 1024 * 1024;
|
|
|
2903
3913
|
var secretFields = /* @__PURE__ */ new Set(["token", "sessiontoken", "accesstoken", "refreshtoken", "password", "currentpassword", "newpassword", "secret", "clientsecret", "authorization", "cookie", "privatekey", "rawkey"]);
|
|
2904
3914
|
function redactWebValue(value, secrets = []) {
|
|
2905
3915
|
if (typeof value === "string") return secrets.reduce((text, secret) => secret ? text.split(secret).join("[redacted]") : text, redactKeys(value));
|
|
3916
|
+
if (typeof value === "number" && secrets.includes(String(value))) return "[redacted]";
|
|
2906
3917
|
if (Array.isArray(value)) return value.map((item) => redactWebValue(item, secrets));
|
|
2907
3918
|
if (!value || typeof value !== "object") return value;
|
|
2908
3919
|
return Object.fromEntries(Object.entries(value).map(([key, item]) => [
|
|
@@ -3054,12 +4065,12 @@ function mediaPrefixValid(mime, prefix) {
|
|
|
3054
4065
|
if (["text/plain", "text/markdown", "text/csv"].includes(mime)) return !prefix.includes(0);
|
|
3055
4066
|
return true;
|
|
3056
4067
|
}
|
|
3057
|
-
async function requestWeb(
|
|
4068
|
+
async function requestWeb(io2, request) {
|
|
3058
4069
|
const baseUrl = normalizeBaseUrl(request.baseUrl);
|
|
3059
|
-
assertReachedDirectly(baseUrl,
|
|
4070
|
+
assertReachedDirectly(baseUrl, io2.env);
|
|
3060
4071
|
if (!request.path.startsWith("/api/") || request.path.includes("#") || request.path.includes("\\") || new URL(request.path, baseUrl).origin !== baseUrl || new URL(request.path, baseUrl).pathname !== request.path.split("?")[0]) throw usageError("\u7F51\u9875\u64CD\u4F5C\u8DEF\u5F84\u65E0\u6548");
|
|
3061
4072
|
if (request.token?.startsWith("bk_")) throw usageError("API \u5BC6\u94A5\u4E0D\u80FD\u7528\u4E8E\u7F51\u9875\u63A5\u53E3");
|
|
3062
|
-
if (
|
|
4073
|
+
if (io2.signal?.aborted) throw interruptedError();
|
|
3063
4074
|
const controller = new AbortController();
|
|
3064
4075
|
const secrets = [...request.secrets ?? [], ...request.token ? [request.token] : []];
|
|
3065
4076
|
const headers = new Headers({ Accept: "application/json, text/event-stream, */*", "User-Agent": "bukesiyi-cli/web" });
|
|
@@ -3071,7 +4082,7 @@ async function requestWeb(io, request) {
|
|
|
3071
4082
|
if (!["prefer", "x-script-fingerprint", "x-attachment-delivery", "x-attachment-name"].includes(name2.toLowerCase()) || typeof value !== "string" || !value || /[^\x20-\x7e]/u.test(value) || value.length > 4096) throw usageError("\u7F51\u9875\u4E1A\u52A1\u8BF7\u6C42\u5934\u4E0D\u5728\u5141\u8BB8\u8303\u56F4\uFF0C\u64CD\u4F5C\u672A\u63D0\u4EA4");
|
|
3072
4083
|
headers.set(name2, value);
|
|
3073
4084
|
}
|
|
3074
|
-
const timeoutMs = request.timeoutMs ??
|
|
4085
|
+
const timeoutMs = request.timeoutMs ?? io2.requestTimeoutMs ?? 12e4;
|
|
3075
4086
|
let timer;
|
|
3076
4087
|
let responseReceived = false;
|
|
3077
4088
|
let interrupt2 = () => void 0;
|
|
@@ -3081,7 +4092,7 @@ async function requestWeb(io, request) {
|
|
|
3081
4092
|
controller.abort(error);
|
|
3082
4093
|
reject(error);
|
|
3083
4094
|
};
|
|
3084
|
-
|
|
4095
|
+
io2.signal?.addEventListener("abort", interrupt2, { once: true });
|
|
3085
4096
|
timer = setTimeout(() => {
|
|
3086
4097
|
const error = new CliError({ code: "CLI_TIMEOUT", exitCode: EXIT.SERVER, retryable: true, message: `\u7F51\u9875\u8BF7\u6C42\u7B49\u5F85\u8D85\u65F6\uFF08${timeoutMs / 1e3} \u79D2\uFF09\uFF1B\u8BF7\u67E5\u8BE2\u539F\u64CD\u4F5C\u7ED3\u679C` });
|
|
3087
4098
|
controller.abort(error);
|
|
@@ -3089,7 +4100,7 @@ async function requestWeb(io, request) {
|
|
|
3089
4100
|
}, timeoutMs);
|
|
3090
4101
|
});
|
|
3091
4102
|
const work = (async () => {
|
|
3092
|
-
const response = await
|
|
4103
|
+
const response = await io2.fetch(`${baseUrl}${request.path}`, {
|
|
3093
4104
|
method: request.method,
|
|
3094
4105
|
headers,
|
|
3095
4106
|
...request.body === void 0 ? {} : { body: request.body },
|
|
@@ -3111,7 +4122,16 @@ async function requestWeb(io, request) {
|
|
|
3111
4122
|
throw serverFailure(response.status, body, secrets);
|
|
3112
4123
|
}
|
|
3113
4124
|
const mime = response.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase() ?? "";
|
|
4125
|
+
const sessionResponse = request.method === "POST" && (request.path === "/api/auth/login" || request.sessionResponse === true);
|
|
4126
|
+
if (sessionResponse && (!mime.includes("json") || ![200, 201].includes(response.status))) {
|
|
4127
|
+
await response.body?.cancel().catch(() => void 0);
|
|
4128
|
+
throw badResponse(response.status);
|
|
4129
|
+
}
|
|
3114
4130
|
if (mime === "text/event-stream") {
|
|
4131
|
+
if (request.expectedFile) {
|
|
4132
|
+
await response.body?.cancel().catch(() => void 0);
|
|
4133
|
+
throw badResponse(response.status);
|
|
4134
|
+
}
|
|
3115
4135
|
const decoder = new TextDecoder();
|
|
3116
4136
|
let buffer = "", eventCount = 0, completed = false;
|
|
3117
4137
|
const events = [];
|
|
@@ -3163,15 +4183,16 @@ async function requestWeb(io, request) {
|
|
|
3163
4183
|
retryable: true,
|
|
3164
4184
|
message: "\u7F51\u9875\u4E8B\u4EF6\u6D41\u5728\u5B8C\u6210\u6807\u8BB0\u524D\u7ED3\u675F\uFF1B\u64CD\u4F5C\u7ED3\u679C\u5C1A\u672A\u786E\u8BA4\uFF0C\u8BF7\u4F7F\u7528\u539F\u5E42\u7B49\u952E\u67E5\u8BE2\u539F\u64CD\u4F5C"
|
|
3165
4185
|
});
|
|
3166
|
-
const
|
|
3167
|
-
if (request.outPath) return { ...
|
|
4186
|
+
const result4 = { status: response.status, events, eventCount };
|
|
4187
|
+
if (request.outPath) return { ...result4, download: await atomicWebOutput(request.outPath, controller.signal, (write) => write(Buffer.from(`${JSON.stringify(result4, null, 2)}
|
|
3168
4188
|
`))) };
|
|
3169
|
-
return
|
|
4189
|
+
return result4;
|
|
3170
4190
|
}
|
|
3171
4191
|
if (mime.includes("json") || response.status === 204) {
|
|
3172
4192
|
const data = await jsonBody(response, controller.signal);
|
|
3173
4193
|
secrets.push(...webSecrets(data));
|
|
3174
|
-
if (
|
|
4194
|
+
if (sessionResponse) {
|
|
4195
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) throw badResponse(response.status);
|
|
3175
4196
|
const token = data.token;
|
|
3176
4197
|
if (typeof token === "string") secrets.push(token);
|
|
3177
4198
|
request.onLogin?.(data);
|
|
@@ -3229,11 +4250,11 @@ async function requestWeb(io, request) {
|
|
|
3229
4250
|
clearTimeout(cleanupTimer);
|
|
3230
4251
|
}
|
|
3231
4252
|
if (error instanceof CliError) throw error;
|
|
3232
|
-
if (
|
|
4253
|
+
if (io2.signal?.aborted) throw interruptedError();
|
|
3233
4254
|
throw new CliError({ code: "CLI_NETWORK", exitCode: EXIT.SERVER, retryable: true, message: "\u7F51\u9875\u8BF7\u6C42\u8FDE\u63A5\u5931\u8D25\uFF0C\u8BF7\u67E5\u8BE2\u539F\u64CD\u4F5C\u7ED3\u679C\u540E\u518D\u51B3\u5B9A\u662F\u5426\u91CD\u8BD5" });
|
|
3234
4255
|
} finally {
|
|
3235
4256
|
clearTimeout(timer);
|
|
3236
|
-
|
|
4257
|
+
io2.signal?.removeEventListener("abort", interrupt2);
|
|
3237
4258
|
}
|
|
3238
4259
|
}
|
|
3239
4260
|
|
|
@@ -3256,9 +4277,9 @@ function validateSessionToken(value) {
|
|
|
3256
4277
|
}
|
|
3257
4278
|
return value;
|
|
3258
4279
|
}
|
|
3259
|
-
function webStatePath(
|
|
4280
|
+
function webStatePath(io2, name2 = "session.json") {
|
|
3260
4281
|
if (!stateNames.has(name2) && !/^web-(?:request|fingerprint)-[a-f0-9]{64}\.json$/u.test(name2) && !/^web-lock-[a-f0-9]{64}-\d+-[a-f0-9]{32}\.json$/u.test(name2)) throw stateError("\u4E0D\u652F\u6301\u7684\u7F51\u9875\u72B6\u6001\u6587\u4EF6");
|
|
3261
|
-
return join4(credentialsDir(
|
|
4282
|
+
return join4(credentialsDir(io2), name2);
|
|
3262
4283
|
}
|
|
3263
4284
|
async function guardAncestors(path) {
|
|
3264
4285
|
let current = path;
|
|
@@ -3273,26 +4294,26 @@ async function guardAncestors(path) {
|
|
|
3273
4294
|
current = dirname3(current);
|
|
3274
4295
|
}
|
|
3275
4296
|
}
|
|
3276
|
-
async function guardStateFile(path,
|
|
4297
|
+
async function guardStateFile(path, io2, transientTicket = false) {
|
|
3277
4298
|
try {
|
|
3278
4299
|
const info = await lstat3(path);
|
|
3279
|
-
if (transientTicket && info.isFile() && info.nlink === 0) return await guardStateFile(path,
|
|
4300
|
+
if (transientTicket && info.isFile() && info.nlink === 0) return await guardStateFile(path, io2, true);
|
|
3280
4301
|
if (info.isSymbolicLink() || !info.isFile() || info.nlink !== 1) throw stateError("\u7F51\u9875\u72B6\u6001\u6587\u4EF6\u5FC5\u987B\u662F\u666E\u901A\u6587\u4EF6\uFF0C\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5\u6216\u786C\u94FE\u63A5");
|
|
3281
|
-
if (
|
|
4302
|
+
if (io2.platform !== "win32" && (info.mode & 63) !== 0) throw stateError("\u7F51\u9875\u72B6\u6001\u6587\u4EF6\u6743\u9650\u8FC7\u5BBD\uFF0C\u8BF7\u5148\u8BBE\u7F6E\u4E3A 0600");
|
|
3282
4303
|
} catch (error) {
|
|
3283
4304
|
if (!missing(error)) throw error;
|
|
3284
4305
|
}
|
|
3285
4306
|
}
|
|
3286
|
-
async function readWebState(
|
|
3287
|
-
const path = webStatePath(
|
|
4307
|
+
async function readWebState(io2, name2) {
|
|
4308
|
+
const path = webStatePath(io2, name2);
|
|
3288
4309
|
try {
|
|
3289
4310
|
await guardAncestors(dirname3(path));
|
|
3290
|
-
await guardStateFile(path,
|
|
4311
|
+
await guardStateFile(path, io2, name2.startsWith("web-lock-"));
|
|
3291
4312
|
const handle = await open3(path, constants3.O_RDONLY | noFollow | nonBlock);
|
|
3292
4313
|
try {
|
|
3293
4314
|
const info = await handle.stat();
|
|
3294
|
-
if (info.nlink === 0 && name2.startsWith("web-lock-")) return await readWebState(
|
|
3295
|
-
if (!info.isFile() || info.nlink !== 1 || info.size > 64 * 1024 ||
|
|
4315
|
+
if (info.nlink === 0 && name2.startsWith("web-lock-")) return await readWebState(io2, name2);
|
|
4316
|
+
if (!info.isFile() || info.nlink !== 1 || info.size > 64 * 1024 || io2.platform !== "win32" && (info.mode & 63) !== 0) throw stateError("\u7F51\u9875\u72B6\u6001\u6587\u4EF6\u65E0\u6548");
|
|
3296
4317
|
const value = JSON.parse(await handle.readFile("utf8"));
|
|
3297
4318
|
if (!value || typeof value !== "object" || Array.isArray(value)) throw stateError("\u7F51\u9875\u72B6\u6001\u6587\u4EF6\u683C\u5F0F\u65E0\u6548");
|
|
3298
4319
|
return value;
|
|
@@ -3305,16 +4326,16 @@ async function readWebState(io, name2) {
|
|
|
3305
4326
|
throw stateError("\u65E0\u6CD5\u8BFB\u53D6\u7F51\u9875\u72B6\u6001\u6587\u4EF6\uFF0C\u8BF7\u68C0\u67E5\u76EE\u5F55\u4E0E\u6587\u4EF6\u6743\u9650");
|
|
3306
4327
|
}
|
|
3307
4328
|
}
|
|
3308
|
-
async function writeWebState(
|
|
3309
|
-
const path = webStatePath(
|
|
4329
|
+
async function writeWebState(io2, name2, value) {
|
|
4330
|
+
const path = webStatePath(io2, name2), dir = dirname3(path);
|
|
3310
4331
|
const temp = join4(dir, `.${name2}.${process.pid}.${randomBytes3(8).toString("hex")}.tmp`);
|
|
3311
4332
|
let created = false;
|
|
3312
4333
|
try {
|
|
3313
4334
|
await guardAncestors(dir);
|
|
3314
4335
|
await mkdir3(dir, { recursive: true, mode: 448 });
|
|
3315
4336
|
await guardAncestors(dir);
|
|
3316
|
-
if (
|
|
3317
|
-
await guardStateFile(path,
|
|
4337
|
+
if (io2.platform !== "win32" && ((await lstat3(dir)).mode & 63) !== 0) throw stateError("\u7F51\u9875\u51ED\u636E\u76EE\u5F55\u6743\u9650\u8FC7\u5BBD\uFF0C\u8BF7\u5148\u8BBE\u7F6E\u4E3A 0700");
|
|
4338
|
+
await guardStateFile(path, io2);
|
|
3318
4339
|
const handle = await open3(temp, constants3.O_CREAT | constants3.O_EXCL | constants3.O_WRONLY | noFollow, 384);
|
|
3319
4340
|
created = true;
|
|
3320
4341
|
try {
|
|
@@ -3324,7 +4345,7 @@ async function writeWebState(io, name2, value) {
|
|
|
3324
4345
|
} finally {
|
|
3325
4346
|
await handle.close();
|
|
3326
4347
|
}
|
|
3327
|
-
await guardStateFile(path,
|
|
4348
|
+
await guardStateFile(path, io2);
|
|
3328
4349
|
await rename2(temp, path);
|
|
3329
4350
|
created = false;
|
|
3330
4351
|
await chmod2(path, 384);
|
|
@@ -3335,30 +4356,30 @@ async function writeWebState(io, name2, value) {
|
|
|
3335
4356
|
throw stateError("\u7F51\u9875\u72B6\u6001\u672A\u80FD\u4FDD\u5B58\uFF0C\u539F\u6587\u4EF6\u4FDD\u6301\u4E0D\u53D8\uFF1B\u8BF7\u68C0\u67E5\u76EE\u5F55\u6743\u9650\u4E0E\u78C1\u76D8\u7A7A\u95F4");
|
|
3336
4357
|
}
|
|
3337
4358
|
}
|
|
3338
|
-
async function deleteWebSession(
|
|
3339
|
-
const current = await readWebState(
|
|
4359
|
+
async function deleteWebSession(io2, expected) {
|
|
4360
|
+
const current = await readWebState(io2, "session.json");
|
|
3340
4361
|
if (current?.token !== expected.token || current?.baseUrl !== expected.baseUrl) return;
|
|
3341
|
-
await unlink3(webStatePath(
|
|
4362
|
+
await unlink3(webStatePath(io2)).catch((error) => {
|
|
3342
4363
|
if (!missing(error)) throw stateError("\u670D\u52A1\u7AEF\u5DF2\u9000\u51FA\uFF0C\u4F46\u672C\u5730\u4F1A\u8BDD\u6587\u4EF6\u5220\u9664\u5931\u8D25");
|
|
3343
4364
|
});
|
|
3344
4365
|
}
|
|
3345
|
-
async function lockWebRequest(
|
|
4366
|
+
async function lockWebRequest(io2, hash) {
|
|
3346
4367
|
if (!/^[a-f0-9]{64}$/u.test(hash)) throw stateError("\u7F51\u9875\u8BF7\u6C42\u9501\u6807\u8BC6\u65E0\u6548");
|
|
3347
4368
|
const nonce = randomBytes3(16).toString("hex"), prefix = `web-lock-${hash}-`;
|
|
3348
4369
|
const name2 = `${prefix}${process.pid}-${nonce}.json`;
|
|
3349
4370
|
const mine = { version: 1, pid: process.pid, nonce, choosing: true, ticket: 0 };
|
|
3350
4371
|
const release2 = async () => {
|
|
3351
|
-
const current = await readWebState(
|
|
3352
|
-
if (current?.nonce === nonce && current.pid === process.pid) await unlink3(webStatePath(
|
|
4372
|
+
const current = await readWebState(io2, name2);
|
|
4373
|
+
if (current?.nonce === nonce && current.pid === process.pid) await unlink3(webStatePath(io2, name2)).catch((error) => {
|
|
3353
4374
|
if (!missing(error)) throw error;
|
|
3354
4375
|
});
|
|
3355
4376
|
};
|
|
3356
4377
|
const participants = async () => {
|
|
3357
|
-
await guardAncestors(credentialsDir(
|
|
3358
|
-
const names = (await readdir2(credentialsDir(
|
|
4378
|
+
await guardAncestors(credentialsDir(io2));
|
|
4379
|
+
const names = (await readdir2(credentialsDir(io2))).filter((candidate) => candidate.startsWith(prefix) && /^web-lock-[a-f0-9]{64}-\d+-[a-f0-9]{32}\.json$/u.test(candidate));
|
|
3359
4380
|
const records = [];
|
|
3360
4381
|
for (const candidate of names) {
|
|
3361
|
-
const value = await readWebState(
|
|
4382
|
+
const value = await readWebState(io2, candidate);
|
|
3362
4383
|
if (!value) continue;
|
|
3363
4384
|
if (value.version !== 1 || !Number.isSafeInteger(value.pid) || Number(value.pid) <= 0 || typeof value.nonce !== "string" || candidate !== `${prefix}${value.pid}-${value.nonce}.json` || typeof value.choosing !== "boolean" || !Number.isSafeInteger(value.ticket) || Number(value.ticket) < 0) throw stateError("\u7F51\u9875\u8BF7\u6C42\u9501\u7968\u636E\u65E0\u6548\uFF0C\u64CD\u4F5C\u672A\u63D0\u4EA4");
|
|
3364
4385
|
let alive = true;
|
|
@@ -3368,23 +4389,23 @@ async function lockWebRequest(io, hash) {
|
|
|
3368
4389
|
if (error.code === "ESRCH") alive = false;
|
|
3369
4390
|
}
|
|
3370
4391
|
if (!alive) {
|
|
3371
|
-
await unlink3(webStatePath(
|
|
4392
|
+
await unlink3(webStatePath(io2, candidate)).catch((error) => {
|
|
3372
4393
|
if (!missing(error)) throw error;
|
|
3373
4394
|
});
|
|
3374
4395
|
} else records.push({ name: candidate, ticket: Number(value.ticket), choosing: value.choosing });
|
|
3375
4396
|
}
|
|
3376
4397
|
return records;
|
|
3377
4398
|
};
|
|
3378
|
-
await writeWebState(
|
|
4399
|
+
await writeWebState(io2, name2, mine);
|
|
3379
4400
|
try {
|
|
3380
4401
|
const others = await participants();
|
|
3381
4402
|
mine.ticket = Math.max(0, ...others.map((value) => value.ticket)) + 1;
|
|
3382
4403
|
if (!Number.isSafeInteger(mine.ticket)) throw stateError("\u7F51\u9875\u8BF7\u6C42\u9501\u7968\u53F7\u8D85\u51FA\u8303\u56F4");
|
|
3383
4404
|
mine.choosing = false;
|
|
3384
|
-
await writeWebState(
|
|
4405
|
+
await writeWebState(io2, name2, mine);
|
|
3385
4406
|
const deadline = Date.now() + 12e4;
|
|
3386
4407
|
for (; ; ) {
|
|
3387
|
-
if (
|
|
4408
|
+
if (io2.signal?.aborted) throw interruptedError();
|
|
3388
4409
|
const blocked = (await participants()).some((other) => other.name !== name2 && (other.choosing || other.ticket < mine.ticket || other.ticket === mine.ticket && other.name < name2));
|
|
3389
4410
|
if (!blocked) return release2;
|
|
3390
4411
|
if (Date.now() >= deadline) throw new CliError({
|
|
@@ -3399,15 +4420,15 @@ async function lockWebRequest(io, hash) {
|
|
|
3399
4420
|
throw error;
|
|
3400
4421
|
}
|
|
3401
4422
|
}
|
|
3402
|
-
async function fingerprintWebRequest(
|
|
4423
|
+
async function fingerprintWebRequest(io2, scope, value) {
|
|
3403
4424
|
const scopeHash = createHash4("sha256").update(JSON.stringify(scope)).digest("hex");
|
|
3404
4425
|
const name2 = `web-fingerprint-${scopeHash}.json`;
|
|
3405
|
-
const release2 = await lockWebRequest(
|
|
4426
|
+
const release2 = await lockWebRequest(io2, createHash4("sha256").update(`fingerprint:${scopeHash}`).digest("hex"));
|
|
3406
4427
|
try {
|
|
3407
|
-
let stored = await readWebState(
|
|
4428
|
+
let stored = await readWebState(io2, name2);
|
|
3408
4429
|
if (!stored) {
|
|
3409
4430
|
stored = { version: 1, key: randomBytes3(32).toString("hex") };
|
|
3410
|
-
await writeWebState(
|
|
4431
|
+
await writeWebState(io2, name2, stored);
|
|
3411
4432
|
}
|
|
3412
4433
|
if (stored.version !== 1 || typeof stored.key !== "string" || !/^[a-f0-9]{64}$/u.test(stored.key)) throw stateError("\u7F51\u9875\u8BF7\u6C42\u6458\u8981\u5BC6\u94A5\u65E0\u6548\uFF0C\u64CD\u4F5C\u672A\u63D0\u4EA4");
|
|
3413
4434
|
return createHmac("sha256", Buffer.from(stored.key, "hex")).update(JSON.stringify(value)).digest("hex");
|
|
@@ -3442,17 +4463,17 @@ async function resolveWebSession(context) {
|
|
|
3442
4463
|
...typeof stored.expiresAt === "string" ? { expiresAt: stored.expiresAt } : {}
|
|
3443
4464
|
};
|
|
3444
4465
|
}
|
|
3445
|
-
async function readWebPassword(
|
|
3446
|
-
if (
|
|
3447
|
-
const fromEnv =
|
|
4466
|
+
async function readWebPassword(io2) {
|
|
4467
|
+
if (io2.signal?.aborted) throw interruptedError();
|
|
4468
|
+
const fromEnv = io2.env.BUKE_PASSWORD;
|
|
3448
4469
|
if (fromEnv !== void 0) {
|
|
3449
4470
|
if (!fromEnv || fromEnv.length > 8192 || /[\r\n\0]/u.test(fromEnv)) throw usageError("BUKE_PASSWORD \u4E0D\u80FD\u4E3A\u7A7A\u6216\u542B\u6362\u884C");
|
|
3450
4471
|
return fromEnv;
|
|
3451
4472
|
}
|
|
3452
|
-
const stream =
|
|
4473
|
+
const stream = io2.stdin;
|
|
3453
4474
|
const tty = stream.isTTY === true;
|
|
3454
4475
|
if (tty && typeof stream.setRawMode !== "function") throw usageError("\u5F53\u524D\u7EC8\u7AEF\u4E0D\u80FD\u9690\u85CF\u5BC6\u7801\u8F93\u5165\uFF0C\u8BF7\u4F7F\u7528 BUKE_PASSWORD \u6216\u7BA1\u9053");
|
|
3455
|
-
if (tty)
|
|
4476
|
+
if (tty) io2.stderr.write("\u7F51\u9875\u767B\u5F55\u5BC6\u7801\uFF08\u8F93\u5165\u4E0D\u663E\u793A\uFF09\uFF1A");
|
|
3456
4477
|
const password = await new Promise((resolve3, reject) => {
|
|
3457
4478
|
let value = "", done = false;
|
|
3458
4479
|
const decoder = new StringDecoder("utf8");
|
|
@@ -3461,10 +4482,10 @@ async function readWebPassword(io) {
|
|
|
3461
4482
|
done = true;
|
|
3462
4483
|
clearTimeout(timer);
|
|
3463
4484
|
for (const [name2, handler] of [["data", onData], ["end", onEnd], ["close", onEnd], ["error", onError]]) stream.removeListener(name2, handler);
|
|
3464
|
-
|
|
4485
|
+
io2.signal?.removeEventListener("abort", onAbort);
|
|
3465
4486
|
if (tty) {
|
|
3466
4487
|
stream.setRawMode(false);
|
|
3467
|
-
|
|
4488
|
+
io2.stderr.write("\n");
|
|
3468
4489
|
}
|
|
3469
4490
|
stream.pause();
|
|
3470
4491
|
if (error) reject(error);
|
|
@@ -3494,12 +4515,12 @@ async function readWebPassword(io) {
|
|
|
3494
4515
|
} else value += text;
|
|
3495
4516
|
if (Buffer.byteLength(value) > 8192) finish(usageError("\u5BC6\u7801\u8F93\u5165\u8FC7\u957F"));
|
|
3496
4517
|
};
|
|
3497
|
-
const timer = setTimeout(() => finish(usageError("\u7B49\u5F85\u5BC6\u7801\u8F93\u5165\u8D85\u65F6")),
|
|
4518
|
+
const timer = setTimeout(() => finish(usageError("\u7B49\u5F85\u5BC6\u7801\u8F93\u5165\u8D85\u65F6")), io2.stdinTimeoutMs ?? 3e4);
|
|
3498
4519
|
stream.on("data", onData);
|
|
3499
4520
|
stream.on("end", onEnd);
|
|
3500
4521
|
stream.on("close", onEnd);
|
|
3501
4522
|
stream.on("error", onError);
|
|
3502
|
-
|
|
4523
|
+
io2.signal?.addEventListener("abort", onAbort, { once: true });
|
|
3503
4524
|
if (tty) stream.setRawMode(true);
|
|
3504
4525
|
stream.resume();
|
|
3505
4526
|
});
|
|
@@ -3511,13 +4532,14 @@ async function readWebPassword(io) {
|
|
|
3511
4532
|
var webCommand = {
|
|
3512
4533
|
run: web,
|
|
3513
4534
|
acceptsBaseUrl: true,
|
|
3514
|
-
options: ["username", "group", "params", "query", "data", "headers", "file", "files", "yes", "out", "timeout", "workspace", "idempotency-key"],
|
|
4535
|
+
options: ["username", "group", "describe", "params", "query", "data", "headers", "file", "files", "yes", "out", "timeout", "workspace", "idempotency-key"],
|
|
3515
4536
|
positionals: ["\u5B50\u547D\u4EE4", "\u64CD\u4F5C\u7F16\u53F7"],
|
|
3516
4537
|
help: [
|
|
3517
4538
|
"\u7528\u6CD5\uFF1A",
|
|
3518
4539
|
" buke web login --username <\u8D26\u53F7>\uFF1A\u5BC6\u7801\u901A\u8FC7 BUKE_PASSWORD\u3001\u7BA1\u9053\u6216\u9690\u85CF\u7EC8\u7AEF\u8F93\u5165\u63D0\u4F9B\u3002",
|
|
3519
4540
|
" buke web whoami [--workspace <\u5DE5\u4F5C\u533AID>] | logout",
|
|
3520
4541
|
" buke web operations [--group <\u5206\u7EC4>]\uFF1A\u67E5\u770B\u56FA\u5B9A\u64CD\u4F5C\u76EE\u5F55\u3002",
|
|
4542
|
+
" buke web operations --describe <\u64CD\u4F5C\u7F16\u53F7>\uFF1A\u67E5\u770B\u5355\u4E2A\u64CD\u4F5C\u7684\u8DEF\u5F84\u53C2\u6570\u3001\u8BF7\u6C42\u4F53\u5B57\u6BB5\u4E0E\u8C03\u7528\u5408\u540C\u3002",
|
|
3521
4543
|
" buke web call <\u64CD\u4F5C\u7F16\u53F7> [--params <JSON\u6587\u4EF6|->] [--query <JSON\u6587\u4EF6>] [--data <JSON\u6587\u4EF6>]",
|
|
3522
4544
|
" [--file <\u6587\u4EF6> | --files <\u5B57\u6BB5\u540D\u5230\u6587\u4EF6\u8DEF\u5F84\u7684JSON\u6587\u4EF6>] [--yes] [--out <\u65B0\u6587\u4EF6>]",
|
|
3523
4545
|
" [--headers <\u4E1A\u52A1\u8BF7\u6C42\u5934JSON\u6587\u4EF6>] [--workspace <\u5DE5\u4F5C\u533AID>] [--idempotency-key <\u539F\u952E>] [--timeout <\u79D2>] [--json]",
|
|
@@ -3533,12 +4555,13 @@ function object(value) {
|
|
|
3533
4555
|
}
|
|
3534
4556
|
function issuedSession(context, baseUrl, data) {
|
|
3535
4557
|
const user = data.user && typeof data.user === "object" && !Array.isArray(data.user) ? data.user : {};
|
|
3536
|
-
|
|
4558
|
+
const now = context.io.now?.() ?? /* @__PURE__ */ new Date();
|
|
4559
|
+
if (data.ok !== true || typeof data.expiresAt !== "string" || !Number.isFinite(Date.parse(data.expiresAt)) || Date.parse(data.expiresAt) <= now.getTime() || typeof user.id !== "string" || !user.id || typeof user.username !== "string" || !user.username || typeof user.workspaceId !== "string" || !user.workspaceId || !Array.isArray(user.workspaces) || !user.workspaces.some((item) => item && typeof item === "object" && item.id === user.workspaceId)) {
|
|
3537
4560
|
throw new CliError({ code: "CLI_BAD_RESPONSE", exitCode: EXIT.SERVER, message: "\u8BA4\u8BC1\u54CD\u5E94\u7F3A\u5C11\u5B8C\u6574\u4F1A\u8BDD\u6216\u7528\u6237\u8EAB\u4EFD\uFF0C\u539F\u4F1A\u8BDD\u4FDD\u6301\u4E0D\u53D8" });
|
|
3538
4561
|
}
|
|
3539
4562
|
const token = validateSessionToken(data.token);
|
|
3540
4563
|
context.out.protect(token);
|
|
3541
|
-
return { version: 1, baseUrl, token, savedAt:
|
|
4564
|
+
return { version: 1, baseUrl, token, savedAt: now.toISOString(), expiresAt: data.expiresAt };
|
|
3542
4565
|
}
|
|
3543
4566
|
async function optionData(context, name2) {
|
|
3544
4567
|
const file = textOption(context.values, name2);
|
|
@@ -3574,7 +4597,7 @@ function operationPath(operation, params, query) {
|
|
|
3574
4597
|
}
|
|
3575
4598
|
function fileOperation(operation) {
|
|
3576
4599
|
if (operation.method !== "GET") return false;
|
|
3577
|
-
return /\/(?:download(?:\.zip)?|video|audio|clip|subtitles\.srt)$/u.test(operation.path) || /\/edits\/:[^/]+\/subtitles$/u.test(operation.path) || /\/attachments\/:[^/]+\/file$/u.test(operation.path) || /^\/api\/delivery\/(?:packages|shared)\/:[^/]+\/files\/:[^/]+$/u.test(operation.path) || /^\/api\/membership\/renders\/:[^/]+\/output$/u.test(operation.path) || operation.path === "/api/graphic/runs/:runId/preview" || /^\/api\/showcase-videos\/runs\/:[^/]+\/image-edits\/area\/:[^/]+\/preview$/u.test(operation.path);
|
|
4600
|
+
return operation.response === "file" || /\/(?:download(?:\.zip)?|video|audio|clip|subtitles\.srt)$/u.test(operation.path) || /\/edits\/:[^/]+\/subtitles$/u.test(operation.path) || /\/attachments\/:[^/]+\/file$/u.test(operation.path) || /^\/api\/delivery\/(?:packages|shared)\/:[^/]+\/files\/:[^/]+$/u.test(operation.path) || /^\/api\/membership\/renders\/:[^/]+\/output$/u.test(operation.path) || operation.path === "/api/graphic/runs/:runId/preview" || /^\/api\/showcase-videos\/runs\/:[^/]+\/image-edits\/area\/:[^/]+\/preview$/u.test(operation.path);
|
|
3578
4601
|
}
|
|
3579
4602
|
async function upload2(path, operation) {
|
|
3580
4603
|
try {
|
|
@@ -3626,16 +4649,93 @@ async function requestBody(context, operation, data) {
|
|
|
3626
4649
|
return { body: JSON.stringify(data), contentType: "application/json", identity: data };
|
|
3627
4650
|
}
|
|
3628
4651
|
async function webIdentity(context, session, workspace, timeoutMs) {
|
|
3629
|
-
const
|
|
3630
|
-
const user = object(object(
|
|
4652
|
+
const result4 = await requestWeb(context.io, { baseUrl: session.baseUrl, token: session.token, method: "GET", path: "/api/me", workspaceId: workspace, timeoutMs });
|
|
4653
|
+
const user = object(object(result4.data).user);
|
|
3631
4654
|
if (typeof user.id !== "string" || !user.id || typeof user.workspaceId !== "string" || !user.workspaceId || workspace && (user.workspaceId !== workspace || !Array.isArray(user.workspaces) || !user.workspaces.some((item) => item && typeof item === "object" && item.id === workspace))) {
|
|
3632
4655
|
throw new CliError({ code: "CLI_WEB_WORKSPACE_FORBIDDEN", exitCode: EXIT.AUTH, message: "\u670D\u52A1\u7AEF\u672A\u786E\u8BA4\u8BE5\u5DE5\u4F5C\u533A\u7684\u6210\u5458\u6743\u9650\uFF0C\u672C\u6B21\u64CD\u4F5C\u672A\u63D0\u4EA4" });
|
|
3633
4656
|
}
|
|
3634
|
-
return { result, userId: user.id, workspaceId: user.workspaceId };
|
|
4657
|
+
return { result: result4, userId: user.id, workspaceId: user.workspaceId };
|
|
4658
|
+
}
|
|
4659
|
+
function commonPrefixLength(left, right) {
|
|
4660
|
+
let index = 0;
|
|
4661
|
+
while (index < left.length && index < right.length && left[index] === right[index]) index += 1;
|
|
4662
|
+
return index;
|
|
4663
|
+
}
|
|
4664
|
+
function fieldLine(field) {
|
|
4665
|
+
const parts = [` ${field.name}`];
|
|
4666
|
+
if (field.type) parts.push(`\u7C7B\u578B ${field.type}`);
|
|
4667
|
+
if (field.enum?.length) parts.push(`\u53EF\u9009\u503C\uFF1A${field.enum.join("\u3001")}`);
|
|
4668
|
+
if (field.default !== void 0) parts.push(`\u7F3A\u7701 ${String(field.default)}`);
|
|
4669
|
+
if (field.example !== void 0) parts.push(`\u793A\u4F8B ${JSON.stringify(field.example)}`);
|
|
4670
|
+
if (field.note) parts.push(field.note);
|
|
4671
|
+
if (field.required === true) parts.push("\u5FC5\u586B");
|
|
4672
|
+
else if (field.required === false) parts.push("\u53EF\u9009");
|
|
4673
|
+
return parts.join(" ");
|
|
4674
|
+
}
|
|
4675
|
+
function describeOperation(context, id) {
|
|
4676
|
+
const { out } = context;
|
|
4677
|
+
const operation = WEB_OPERATIONS.find((item) => item.id === id);
|
|
4678
|
+
if (!operation) {
|
|
4679
|
+
const close = WEB_OPERATIONS.map((item) => item.id).map((candidate) => ({ candidate, prefix: commonPrefixLength(id, candidate) })).filter((item) => item.prefix > 0).sort((left, right) => right.prefix - left.prefix || (left.candidate < right.candidate ? -1 : 1)).slice(0, 3).map((item) => item.candidate);
|
|
4680
|
+
throw usageError(close.length ? `\u64CD\u4F5C ${id} \u4E0D\u5728\u7F51\u9875\u547D\u4EE4\u76EE\u5F55\u4E2D\uFF1B\u8BF7\u5148\u8FD0\u884C buke web operations\u3002\u7F16\u53F7\u76F8\u8FD1\u7684\u64CD\u4F5C\uFF1A${close.join("\u3001")}` : `\u64CD\u4F5C ${id} \u4E0D\u5728\u7F51\u9875\u547D\u4EE4\u76EE\u5F55\u4E2D\uFF1B\u8BF7\u5148\u8FD0\u884C buke web operations`);
|
|
4681
|
+
}
|
|
4682
|
+
const entry2 = WEB_OPERATION_FIELDS[operation.id];
|
|
4683
|
+
const fields3 = entry2?.fields ?? [];
|
|
4684
|
+
const pathParams = [...operation.path.matchAll(/:([A-Za-z][A-Za-z0-9_]*)/gu)].map((match) => match[1]);
|
|
4685
|
+
const contract = { replaySafe: operation.replaySafe === true };
|
|
4686
|
+
if (operation.body) contract.body = operation.body;
|
|
4687
|
+
if (operation.uploadPolicy) contract.uploadPolicy = operation.uploadPolicy;
|
|
4688
|
+
if (operation.uploadField) contract.uploadField = operation.uploadField;
|
|
4689
|
+
if (operation.response) contract.response = operation.response;
|
|
4690
|
+
if (operation.businessHeaders) contract.businessHeaders = operation.businessHeaders;
|
|
4691
|
+
if (operation.idempotencyBodyKey) contract.idempotencyBodyKey = operation.idempotencyBodyKey;
|
|
4692
|
+
if (operation.public === true) contract.public = true;
|
|
4693
|
+
if (operation.membershipPaymentOnly === true) contract.membershipPaymentOnly = true;
|
|
4694
|
+
if (operation.sensitiveOutput === true) contract.sensitiveOutput = true;
|
|
4695
|
+
if (operation.sessionResponse === true) contract.sessionResponse = true;
|
|
4696
|
+
const data = {
|
|
4697
|
+
id: operation.id,
|
|
4698
|
+
method: operation.method,
|
|
4699
|
+
path: operation.path,
|
|
4700
|
+
group: operation.group,
|
|
4701
|
+
description: operation.description,
|
|
4702
|
+
pathParams,
|
|
4703
|
+
contract,
|
|
4704
|
+
fields: fields3
|
|
4705
|
+
};
|
|
4706
|
+
if (operation.source) data.source = operation.source;
|
|
4707
|
+
if (operation.exampleBody) data.exampleBody = operation.exampleBody;
|
|
4708
|
+
const lines2 = [
|
|
4709
|
+
`${operation.method} ${operation.path}`,
|
|
4710
|
+
`${operation.id}\uFF08${operation.group}\uFF09${operation.description}`
|
|
4711
|
+
];
|
|
4712
|
+
if (pathParams.length) lines2.push(`\u8DEF\u5F84\u53C2\u6570\uFF1A${pathParams.join("\u3001")}\uFF08--params \u63D0\u4F9B\uFF09`);
|
|
4713
|
+
if (operation.body === "json") {
|
|
4714
|
+
if (fields3.length) {
|
|
4715
|
+
lines2.push("\u8BF7\u6C42\u4F53\u5B57\u6BB5\uFF08--data JSON\uFF1B\u6765\u6E90 zod=\u670D\u52A1\u7AEF\u6821\u9A8C observed=\u7F51\u9875\u8C03\u7528\u89C2\u5BDF\uFF09\uFF1A");
|
|
4716
|
+
lines2.push(...fields3.map(fieldLine));
|
|
4717
|
+
} else {
|
|
4718
|
+
lines2.push("\u8BF7\u6C42\u4F53\u5B57\u6BB5\uFF1A\u76EE\u5F55\u672A\u8BB0\u5F55\u952E\u540D\uFF08\u53EF\u80FD\u65E0\u6B63\u6587\u6216\u7531\u670D\u52A1\u5C42\u6821\u9A8C\uFF09\uFF0C\u53EF\u7528 buke web call \u914D\u5408\u7F51\u9875\u5B9E\u9645\u8F7D\u8377\u3002");
|
|
4719
|
+
}
|
|
4720
|
+
if (operation.idempotencyBodyKey) lines2.push(`\u5E42\u7B49\u952E\uFF1A\u8BF7\u6C42\u4F53 ${operation.idempotencyBodyKey}\uFF0C\u6216\u7528 --idempotency-key \u8986\u76D6`);
|
|
4721
|
+
}
|
|
4722
|
+
if (operation.body === "binary" || operation.body === "multipart") {
|
|
4723
|
+
lines2.push(`\u8BF7\u6C42\u4F53\uFF1A${operation.body === "binary" ? "\u539F\u59CB\u6587\u4EF6" : `multipart \u5B57\u6BB5 ${operation.uploadField ?? "file"}`}\uFF0C\u6309\u4E0A\u4F20\u7B56\u7565\u63D0\u4F9B --file`);
|
|
4724
|
+
}
|
|
4725
|
+
const flags = [];
|
|
4726
|
+
if (operation.method !== "GET") flags.push("\u5199\u64CD\u4F5C\u9700 --yes");
|
|
4727
|
+
if (operation.sensitiveOutput === true) flags.push("\u654F\u611F\u8F93\u51FA\u5FC5\u987B --out \u843D 0600 \u6587\u4EF6");
|
|
4728
|
+
if (operation.response === "file") flags.push("\u6587\u4EF6\u54CD\u5E94\u5FC5\u987B --out");
|
|
4729
|
+
if (operation.membershipPaymentOnly === true) flags.push("\u8BF7\u6C42\u524D\u987B\u6838\u5BF9\u4F1A\u5458\u4ED8\u6B3E\u5355\uFF08orderType=membership\uFF09");
|
|
4730
|
+
if (operation.replaySafe === true) flags.push("\u53EF\u5B89\u5168\u91CD\u653E");
|
|
4731
|
+
if (flags.length) lines2.push(`\u5408\u540C\uFF1A${flags.join("\uFF1B")}`);
|
|
4732
|
+
if (operation.exampleBody) lines2.push(`\u793A\u4F8B\u6B63\u6587\uFF1A${JSON.stringify(operation.exampleBody)}`);
|
|
4733
|
+
if (operation.source) lines2.push(`\u6765\u6E90\uFF1A${operation.source}${fields3.some((field) => field.source === "zod") ? "\uFF1B\u5B57\u6BB5\u76EE\u5F55\u542B\u670D\u52A1\u7AEF zod \u6821\u9A8C" : fields3.length ? "\uFF1B\u5B57\u6BB5\u76EE\u5F55\u6765\u81EA\u7F51\u9875\u8C03\u7528\u89C2\u5BDF" : ""}`);
|
|
4734
|
+
out.result(lines2, data);
|
|
3635
4735
|
}
|
|
3636
4736
|
async function web(context) {
|
|
3637
4737
|
const invocationStartedAt = performance.timeOrigin + performance.now();
|
|
3638
|
-
const { io, out, args, values } = context;
|
|
4738
|
+
const { io: io2, out, args, values } = context;
|
|
3639
4739
|
const timeoutSeconds = timeoutSecondsOf(values, 120);
|
|
3640
4740
|
if (timeoutSeconds > 2147483) throw usageError("--timeout \u8D85\u51FA\u652F\u6301\u8303\u56F4");
|
|
3641
4741
|
const timeoutMs = timeoutSeconds * 1e3;
|
|
@@ -3644,6 +4744,12 @@ async function web(context) {
|
|
|
3644
4744
|
if (action2 !== "call" && args[1] !== void 0) throw usageError("\u8BE5\u7F51\u9875\u5B50\u547D\u4EE4\u4E0D\u63A5\u53D7\u64CD\u4F5C\u7F16\u53F7");
|
|
3645
4745
|
if (["params", "query", "data", "files", "headers"].filter((name2) => values[name2] === "-").length > 1) throw usageError("\u4E00\u6B21\u547D\u4EE4\u53EA\u80FD\u6709\u4E00\u4E2A JSON \u53C2\u6570\u4ECE\u6807\u51C6\u8F93\u5165\u8BFB\u53D6");
|
|
3646
4746
|
if (action2 === "operations") {
|
|
4747
|
+
const describeId = textOption(values, "describe");
|
|
4748
|
+
if (describeId) {
|
|
4749
|
+
if (textOption(values, "group")) throw usageError("--describe \u4E0E --group \u53EA\u80FD\u4E8C\u9009\u4E00");
|
|
4750
|
+
describeOperation(context, describeId);
|
|
4751
|
+
return;
|
|
4752
|
+
}
|
|
3647
4753
|
const group = textOption(values, "group");
|
|
3648
4754
|
const operations = WEB_OPERATIONS.filter((operation2) => !group || operation2.group === group);
|
|
3649
4755
|
out.result(operations.map((operation2) => `${operation2.id} ${operation2.method} ${operation2.path} ${operation2.description}`), { operations });
|
|
@@ -3652,11 +4758,11 @@ async function web(context) {
|
|
|
3652
4758
|
if (action2 === "login") {
|
|
3653
4759
|
const username = textOption(values, "username");
|
|
3654
4760
|
if (!username) throw usageError("\u8BF7\u63D0\u4F9B --username <\u8D26\u53F7>");
|
|
3655
|
-
const baseUrl = explicitBaseUrl(context.baseUrl,
|
|
3656
|
-
const password = await readWebPassword(
|
|
4761
|
+
const baseUrl = explicitBaseUrl(context.baseUrl, io2.env) ?? DEFAULT_BASE_URL;
|
|
4762
|
+
const password = await readWebPassword(io2);
|
|
3657
4763
|
out.protect(password);
|
|
3658
4764
|
let session;
|
|
3659
|
-
const
|
|
4765
|
+
const result4 = await requestWeb(io2, {
|
|
3660
4766
|
baseUrl,
|
|
3661
4767
|
path: "/api/auth/login",
|
|
3662
4768
|
method: "POST",
|
|
@@ -3670,22 +4776,22 @@ async function web(context) {
|
|
|
3670
4776
|
}
|
|
3671
4777
|
});
|
|
3672
4778
|
if (!session) throw new CliError({ code: "CLI_BAD_RESPONSE", exitCode: EXIT.SERVER, message: "\u767B\u5F55\u54CD\u5E94\u6CA1\u6709\u6709\u6548\u4F1A\u8BDD\uFF0C\u672A\u4FDD\u5B58\u51ED\u636E" });
|
|
3673
|
-
const path = await writeWebState(
|
|
3674
|
-
out.result(["\u7F51\u9875\u767B\u5F55\u6210\u529F", `\u670D\u52A1\u5730\u5740\uFF1A${baseUrl}`, `\u4F1A\u8BDD\u6587\u4EF6\uFF1A${path}`], { ...object(
|
|
4779
|
+
const path = await writeWebState(io2, "session.json", session);
|
|
4780
|
+
out.result(["\u7F51\u9875\u767B\u5F55\u6210\u529F", `\u670D\u52A1\u5730\u5740\uFF1A${baseUrl}`, `\u4F1A\u8BDD\u6587\u4EF6\uFF1A${path}`], { ...object(result4.data), baseUrl, sessionPath: path });
|
|
3675
4781
|
return;
|
|
3676
4782
|
}
|
|
3677
4783
|
if (action2 === "whoami" || action2 === "logout") {
|
|
3678
4784
|
const session = await resolveWebSession(context), workspace2 = workspaceOf(context);
|
|
3679
4785
|
if (action2 === "whoami") {
|
|
3680
|
-
const { result } = await webIdentity(context, session, workspace2, timeoutMs);
|
|
3681
|
-
out.result([JSON.stringify(
|
|
4786
|
+
const { result: result4 } = await webIdentity(context, session, workspace2, timeoutMs);
|
|
4787
|
+
out.result([JSON.stringify(result4.data, null, 2)], { ...object(result4.data), baseUrl: session.baseUrl, source: session.source });
|
|
3682
4788
|
} else {
|
|
3683
4789
|
try {
|
|
3684
|
-
await requestWeb(
|
|
4790
|
+
await requestWeb(io2, { baseUrl: session.baseUrl, token: session.token, path: "/api/auth/logout", method: "POST", timeoutMs });
|
|
3685
4791
|
} catch (error) {
|
|
3686
4792
|
throw toCliError(error).withHint("\u9000\u51FA\u7ED3\u679C\u672A\u77E5\u6216\u88AB\u62D2\u7EDD\uFF0C\u672C\u5730\u4F1A\u8BDD\u4FDD\u7559\uFF1B\u8BF7\u786E\u8BA4\u670D\u52A1\u5730\u5740\u540E\u91CD\u8BD5\u9000\u51FA\u3002");
|
|
3687
4793
|
}
|
|
3688
|
-
await deleteWebSession(
|
|
4794
|
+
await deleteWebSession(io2, session);
|
|
3689
4795
|
out.result(["\u7F51\u9875\u4F1A\u8BDD\u5DF2\u9000\u51FA"], { loggedOut: true, source: session.source });
|
|
3690
4796
|
}
|
|
3691
4797
|
return;
|
|
@@ -3699,8 +4805,12 @@ async function web(context) {
|
|
|
3699
4805
|
const secretOutput = issueApiKey || operation.sensitiveOutput === true;
|
|
3700
4806
|
const output = textOption(values, "out");
|
|
3701
4807
|
if (secretOutput && !output) throw usageError("\u8BE5\u64CD\u4F5C\u7B7E\u53D1\u5BC6\u94A5\u6216\u79C1\u6709\u94FE\u63A5\uFF0C\u5FC5\u987B\u4F7F\u7528 --out <\u65B0\u6587\u4EF6>\uFF1B\u660E\u6587\u4E0D\u4F1A\u8F93\u51FA\u5230\u7EC8\u7AEF");
|
|
4808
|
+
if (operation.response === "file" && !output) throw usageError("\u8BE5\u64CD\u4F5C\u8FD4\u56DE\u56FE\u7247\u539F\u6587\u4EF6\uFF0C\u5FC5\u987B\u4F7F\u7528 --out <\u65B0\u6587\u4EF6> \u4FDD\u5B58");
|
|
3702
4809
|
if (output) await checkWebOutput(output);
|
|
3703
4810
|
const params = await optionData(context, "params"), query = await optionData(context, "query"), data = await optionData(context, "data");
|
|
4811
|
+
const authCodes = operation.group === "auth" && (typeof data.code === "string" || typeof data.code === "number") ? [String(data.code)] : [];
|
|
4812
|
+
const secrets = [...webSecrets(data), ...webSecrets(query), ...webSecrets(params), ...authCodes];
|
|
4813
|
+
for (const secret of secrets) out.protect(secret);
|
|
3704
4814
|
const bodyKey = operation.idempotencyBodyKey ? data[operation.idempotencyBodyKey] : void 0;
|
|
3705
4815
|
if (bodyKey !== void 0 && typeof bodyKey !== "string") throw usageError("\u6B63\u6587\u4E2D\u7684\u5E42\u7B49\u952E\u5FC5\u987B\u662F\u5B57\u7B26\u4E32");
|
|
3706
4816
|
if (suppliedKey && bodyKey !== void 0 && suppliedKey !== bodyKey) throw usageError("--idempotency-key \u4E0E\u6B63\u6587\u5E42\u7B49\u952E\u4E0D\u4E00\u81F4\uFF0C\u64CD\u4F5C\u672A\u63D0\u4EA4");
|
|
@@ -3714,19 +4824,17 @@ async function web(context) {
|
|
|
3714
4824
|
let caller;
|
|
3715
4825
|
if (operation.public) {
|
|
3716
4826
|
if (requestedWorkspace) throw usageError("\u516C\u5F00\u64CD\u4F5C\u4E0D\u63A5\u53D7\u5DE5\u4F5C\u533A\u53C2\u6570");
|
|
3717
|
-
caller = { baseUrl: explicitBaseUrl(context.baseUrl,
|
|
4827
|
+
caller = { baseUrl: explicitBaseUrl(context.baseUrl, io2.env) ?? DEFAULT_BASE_URL, userId: "public" };
|
|
3718
4828
|
} else {
|
|
3719
4829
|
const session = await resolveWebSession(context);
|
|
3720
4830
|
const identity = await webIdentity(context, session, requestedWorkspace, timeoutMs);
|
|
3721
4831
|
caller = { baseUrl: session.baseUrl, token: session.token, userId: identity.userId, workspaceId: identity.workspaceId };
|
|
3722
4832
|
}
|
|
3723
4833
|
const workspace = caller.workspaceId;
|
|
3724
|
-
const secrets = [...webSecrets(data), ...webSecrets(query), ...webSecrets(params)];
|
|
3725
|
-
for (const secret of secrets) out.protect(secret);
|
|
3726
4834
|
if (operation.membershipPaymentOnly) {
|
|
3727
4835
|
const id = target.params.id;
|
|
3728
4836
|
if (!id) throw usageError("\u4F1A\u5458\u652F\u4ED8\u64CD\u4F5C\u7F3A\u5C11\u8BA2\u5355\u7F16\u53F7");
|
|
3729
|
-
const checked = await requestWeb(
|
|
4837
|
+
const checked = await requestWeb(io2, {
|
|
3730
4838
|
baseUrl: caller.baseUrl,
|
|
3731
4839
|
token: caller.token,
|
|
3732
4840
|
workspaceId: workspace,
|
|
@@ -3737,14 +4845,14 @@ async function web(context) {
|
|
|
3737
4845
|
const order2 = object(object(checked.data).order);
|
|
3738
4846
|
if (order2.id !== id || order2.orderType !== "membership") throw usageError("\u8BE5\u8BA2\u5355\u4E0D\u662F\u4F1A\u5458\u8BA2\u5355\uFF1BCLI \u4E0D\u652F\u6301\u5145\u503C\u53CA\u5176\u652F\u4ED8\u64CD\u4F5C");
|
|
3739
4847
|
if (operation.method === "GET" && operation.path === "/api/payments/orders/:id") {
|
|
3740
|
-
const download4 = output ? await saveWebDocument(output, checked.data,
|
|
4848
|
+
const download4 = output ? await saveWebDocument(output, checked.data, io2.signal) : void 0;
|
|
3741
4849
|
out.result([JSON.stringify(checked.data, null, 2)], { ...checked, ...download4 ? { download: download4 } : {}, operationId: operation.id });
|
|
3742
4850
|
return;
|
|
3743
4851
|
}
|
|
3744
4852
|
}
|
|
3745
4853
|
const identityBody = operation.idempotencyBodyKey && body.identity && typeof body.identity === "object" && !Array.isArray(body.identity) ? { ...body.identity, [operation.idempotencyBodyKey]: void 0 } : body.identity;
|
|
3746
4854
|
const requestHash = mutating ? await fingerprintWebRequest(
|
|
3747
|
-
|
|
4855
|
+
io2,
|
|
3748
4856
|
{ baseUrl: caller.baseUrl, userId: caller.userId },
|
|
3749
4857
|
[caller.baseUrl, caller.userId, workspace ?? null, operation.id, target.path, identityBody, businessHeaders]
|
|
3750
4858
|
) : void 0;
|
|
@@ -3758,17 +4866,17 @@ async function web(context) {
|
|
|
3758
4866
|
requestHash,
|
|
3759
4867
|
params: redactWebValue(target.params, secrets),
|
|
3760
4868
|
operationOutcome: "not_submitted",
|
|
3761
|
-
...mutating ? { requestRecord: webStatePath(
|
|
4869
|
+
...mutating ? { requestRecord: webStatePath(io2, recordName) } : {}
|
|
3762
4870
|
};
|
|
3763
4871
|
let finishedAtMs;
|
|
3764
4872
|
const persist = async () => {
|
|
3765
|
-
await writeWebState(
|
|
3766
|
-
await writeWebState(
|
|
4873
|
+
await writeWebState(io2, recordName, { version: 1, ...recovery, finishedAtMs });
|
|
4874
|
+
await writeWebState(io2, "last-web-request.json", { version: 1, ...recovery, finishedAtMs });
|
|
3767
4875
|
};
|
|
3768
|
-
const release2 = mutating ? await lockWebRequest(
|
|
4876
|
+
const release2 = mutating ? await lockWebRequest(io2, requestHash) : void 0;
|
|
3769
4877
|
try {
|
|
3770
4878
|
if (mutating) {
|
|
3771
|
-
const previous = await readWebState(
|
|
4879
|
+
const previous = await readWebState(io2, recordName);
|
|
3772
4880
|
const explicitlyChosen = suppliedKey ?? bodyKey;
|
|
3773
4881
|
const concurrentCompletion = previous && typeof previous.finishedAtMs === "number" && previous.finishedAtMs >= invocationStartedAt;
|
|
3774
4882
|
const sameAttempt = explicitlyChosen === void 0 || explicitlyChosen === previous?.idempotencyKey;
|
|
@@ -3785,7 +4893,7 @@ async function web(context) {
|
|
|
3785
4893
|
}
|
|
3786
4894
|
try {
|
|
3787
4895
|
let authenticated;
|
|
3788
|
-
const
|
|
4896
|
+
const result4 = await requestWeb(io2, {
|
|
3789
4897
|
baseUrl: caller.baseUrl,
|
|
3790
4898
|
token: caller.token,
|
|
3791
4899
|
workspaceId: workspace,
|
|
@@ -3811,12 +4919,13 @@ async function web(context) {
|
|
|
3811
4919
|
if (!out.json) out.notice(singleLine(JSON.stringify(event)));
|
|
3812
4920
|
}
|
|
3813
4921
|
});
|
|
3814
|
-
if (authenticated)
|
|
3815
|
-
|
|
4922
|
+
if (operation.sessionResponse && !authenticated) throw new CliError({ code: "CLI_BAD_RESPONSE", exitCode: EXIT.SERVER, message: "\u8BA4\u8BC1\u54CD\u5E94\u6CA1\u6709\u6709\u6548\u4F1A\u8BDD\uFF0C\u539F\u4F1A\u8BDD\u4FDD\u6301\u4E0D\u53D8" });
|
|
4923
|
+
if (authenticated) await writeWebState(io2, "session.json", authenticated);
|
|
4924
|
+
recovery.operationOutcome = result4.status === 202 || recovery.operationOutcome === "accepted" ? "accepted" : "completed";
|
|
3816
4925
|
finishedAtMs = performance.timeOrigin + performance.now();
|
|
3817
4926
|
if (mutating) await persist().catch(() => out.notice("\u64CD\u4F5C\u5DF2\u5B8C\u6210\uFF0C\u4F46\u672C\u5730\u6062\u590D\u8BB0\u5F55\u66F4\u65B0\u5931\u8D25\uFF1B\u8BF7\u4FDD\u5B58\u672C\u6B21\u7ED3\u679C\u4E0E\u5E42\u7B49\u952E\u3002"));
|
|
3818
4927
|
const document = {
|
|
3819
|
-
...
|
|
4928
|
+
...result4,
|
|
3820
4929
|
...key ? { idempotencyKey: key } : {},
|
|
3821
4930
|
operationId: operation.id,
|
|
3822
4931
|
...recovery.taskId ? { taskId: recovery.taskId } : {}
|
|
@@ -3885,7 +4994,7 @@ async function dramaCreative(context) {
|
|
|
3885
4994
|
const [action2] = context.args;
|
|
3886
4995
|
const id = idOf(context);
|
|
3887
4996
|
const { baseUrl, apiKey } = await resolveApiKey(context);
|
|
3888
|
-
const { io, out, values } = context;
|
|
4997
|
+
const { io: io2, out, values } = context;
|
|
3889
4998
|
if (["context", "director", "document", "versions"].includes(action2)) {
|
|
3890
4999
|
let suffix2 = action2;
|
|
3891
5000
|
if (action2 === "document") {
|
|
@@ -3894,8 +5003,8 @@ async function dramaCreative(context) {
|
|
|
3894
5003
|
if (episode) query.set("episodeNumber", episode);
|
|
3895
5004
|
suffix2 += `?${query}`;
|
|
3896
5005
|
}
|
|
3897
|
-
const
|
|
3898
|
-
out.result([typeof
|
|
5006
|
+
const result5 = await getCreative(baseUrl, apiKey, "drama", id, suffix2, io2);
|
|
5007
|
+
out.result([typeof result5.content === "string" ? result5.content : JSON.stringify(result5, null, 2)], result5);
|
|
3899
5008
|
return;
|
|
3900
5009
|
}
|
|
3901
5010
|
const body = await creativeData(context);
|
|
@@ -3908,7 +5017,7 @@ async function dramaCreative(context) {
|
|
|
3908
5017
|
let kind = suppliedKind;
|
|
3909
5018
|
if (typeof kind !== "string") {
|
|
3910
5019
|
try {
|
|
3911
|
-
const current = await getCreative(baseUrl, apiKey, "drama", id, "director",
|
|
5020
|
+
const current = await getCreative(baseUrl, apiKey, "drama", id, "director", io2);
|
|
3912
5021
|
const director = creativeObject(current.director);
|
|
3913
5022
|
const pending = creativeObject(director.pendingInterrupt);
|
|
3914
5023
|
if (confirmationId !== pending.confirmationId) throw usageError("\u786E\u8BA4\u5361\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u67E5\u8BE2\uFF1B\u91CD\u653E\u539F\u8BF7\u6C42\u8BF7\u540C\u65F6\u63D0\u4F9B\u539F --kind \u548C --idempotency-key");
|
|
@@ -3921,8 +5030,8 @@ async function dramaCreative(context) {
|
|
|
3921
5030
|
}
|
|
3922
5031
|
if (typeof kind !== "string" || !kind) throw usageError("\u786E\u8BA4\u5361\u7F3A\u5C11\u6709\u6548 kind");
|
|
3923
5032
|
try {
|
|
3924
|
-
const
|
|
3925
|
-
out.result(["\u786E\u8BA4\u8BF7\u6C42\u5DF2\u5904\u7406", `\u5E42\u7B49\u952E\uFF1A${key2}`], { ...
|
|
5033
|
+
const result5 = await postCreative(baseUrl, apiKey, "drama", id, "director/confirm", { kind, confirmationId, confirmed: true }, key2, io2);
|
|
5034
|
+
out.result(["\u786E\u8BA4\u8BF7\u6C42\u5DF2\u5904\u7406", `\u5E42\u7B49\u952E\uFF1A${key2}`], { ...result5, idempotencyKey: key2 });
|
|
3926
5035
|
return;
|
|
3927
5036
|
} catch (error) {
|
|
3928
5037
|
const failure = toCliError(error);
|
|
@@ -3935,8 +5044,8 @@ async function dramaCreative(context) {
|
|
|
3935
5044
|
const required3 = ["redoQuoteId", "redoPlanHash", "redoQuoteHash"];
|
|
3936
5045
|
for (const field of required3) if (typeof quote3[field] !== "string") throw usageError(`--data \u5FC5\u987B\u5305\u542B\u6709\u6548\u62A5\u4EF7\u5B57\u6BB5 ${field}`);
|
|
3937
5046
|
const key2 = idempotencyKeyOf(values);
|
|
3938
|
-
const
|
|
3939
|
-
out.result(["\u8865\u505A\u8BF7\u6C42\u5DF2\u53D7\u7406", `\u5E42\u7B49\u952E\uFF1A${key2}`], { ...
|
|
5047
|
+
const result5 = await postCreative(baseUrl, apiKey, "drama", id, "redo", { redoQuoteId: quote3.redoQuoteId, redoPlanHash: quote3.redoPlanHash, redoQuoteHash: quote3.redoQuoteHash, confirmed: true }, key2, io2);
|
|
5048
|
+
out.result(["\u8865\u505A\u8BF7\u6C42\u5DF2\u53D7\u7406", `\u5E42\u7B49\u952E\uFF1A${key2}`], { ...result5, idempotencyKey: key2 });
|
|
3940
5049
|
return;
|
|
3941
5050
|
}
|
|
3942
5051
|
const epoch = textOption(values, "expected-epoch");
|
|
@@ -3963,14 +5072,14 @@ async function dramaCreative(context) {
|
|
|
3963
5072
|
suffix = "redo/quote";
|
|
3964
5073
|
}
|
|
3965
5074
|
const key = idempotencyKeyOf(values);
|
|
3966
|
-
const
|
|
3967
|
-
out.result([JSON.stringify(
|
|
5075
|
+
const result4 = await postCreative(baseUrl, apiKey, "drama", id, suffix, body, key, io2);
|
|
5076
|
+
out.result([JSON.stringify(result4, null, 2), `\u5E42\u7B49\u952E\uFF1A${key}`], { ...result4, idempotencyKey: key });
|
|
3968
5077
|
}
|
|
3969
5078
|
async function creativeDownload(context, resource, id, suffix) {
|
|
3970
5079
|
const { baseUrl, apiKey } = await resolveApiKey(context);
|
|
3971
|
-
const
|
|
3972
|
-
const filename =
|
|
3973
|
-
const saved = await saveDownload(textOption(context.values, "out") ?? filename,
|
|
5080
|
+
const result4 = await downloadCreative(baseUrl, apiKey, resource, id, suffix, context.io);
|
|
5081
|
+
const filename = result4.filename ?? `${resource}-${id}.mp4`;
|
|
5082
|
+
const saved = await saveDownload(textOption(context.values, "out") ?? filename, result4.bytes);
|
|
3974
5083
|
context.out.result([`\u5DF2\u4E0B\u8F7D\uFF1A${singleLine(saved.path)}`, `\u5927\u5C0F\uFF1A${saved.bytes} \u5B57\u8282`, `\u6821\u9A8C\uFF1Asha256 ${saved.sha256}`], { download: { ...saved, filename } });
|
|
3975
5084
|
}
|
|
3976
5085
|
|
|
@@ -4183,9 +5292,9 @@ async function tryStudioAction(resource, context) {
|
|
|
4183
5292
|
if (!response.body || typeof response.body !== "object" || Array.isArray(response.body)) throw new CliError({ code: "CLI_BAD_RESPONSE", message: "\u670D\u52A1\u7AEF\u6CA1\u6709\u8FD4\u56DE\u6709\u6548\u5BF9\u8C61", exitCode: EXIT.SERVER });
|
|
4184
5293
|
return response.body;
|
|
4185
5294
|
};
|
|
4186
|
-
const
|
|
4187
|
-
const output = { ...
|
|
4188
|
-
context.out.result([JSON.stringify(
|
|
5295
|
+
const result4 = key ? await retainMutationOnError(resource, id, key, baseUrl, perform) : await perform();
|
|
5296
|
+
const output = { ...result4, ...key ? { idempotencyKey: key } : {} };
|
|
5297
|
+
context.out.result([JSON.stringify(result4, null, 2), ...key ? [`\u5E42\u7B49\u952E\uFF1A${key}`] : []], output);
|
|
4189
5298
|
return true;
|
|
4190
5299
|
}
|
|
4191
5300
|
async function studioEvents(baseUrl, apiKey, path, method, body, key, context) {
|
|
@@ -4287,8 +5396,8 @@ async function series(context) {
|
|
|
4287
5396
|
const value = textOption(context.values, name2);
|
|
4288
5397
|
if (value) query.set(name2, value);
|
|
4289
5398
|
}
|
|
4290
|
-
const
|
|
4291
|
-
context.out.result([JSON.stringify(
|
|
5399
|
+
const result5 = await getCreative(baseUrl, apiKey, "series", action2 === "show" ? id : void 0, action2 === "list" && query.size ? `?${query}` : "", context.io);
|
|
5400
|
+
context.out.result([JSON.stringify(result5, null, 2)], result5);
|
|
4292
5401
|
return;
|
|
4293
5402
|
}
|
|
4294
5403
|
if (action2 !== "create" && action2 !== "episode-create") throw usageError("series \u652F\u6301 list\u3001show\u3001create\u3001episode-create");
|
|
@@ -4302,8 +5411,8 @@ async function series(context) {
|
|
|
4302
5411
|
if (epoch !== void 0) body.expectedProductionEpoch = Number(epoch);
|
|
4303
5412
|
if (!Number.isInteger(body.expectedProductionEpoch) || Number(body.expectedProductionEpoch) < 0) throw usageError("\u8BF7\u4ECE drama context \u6216 series show \u67E5\u8BE2\u7248\u672C\uFF0C\u5E76\u63D0\u4F9B --expected-epoch");
|
|
4304
5413
|
const key = idempotencyKeyOf(context.values);
|
|
4305
|
-
const
|
|
4306
|
-
context.out.result([JSON.stringify(
|
|
5414
|
+
const result4 = await postCreative(baseUrl, apiKey, "series", action2 === "episode-create" ? id : void 0, action2 === "episode-create" ? "episodes" : "", body, key, context.io);
|
|
5415
|
+
context.out.result([JSON.stringify(result4, null, 2), `\u5E42\u7B49\u952E\uFF1A${key}`], { ...result4, idempotencyKey: key });
|
|
4307
5416
|
}
|
|
4308
5417
|
|
|
4309
5418
|
// src/commands/assets.ts
|
|
@@ -4335,19 +5444,19 @@ function entry(value, status4) {
|
|
|
4335
5444
|
}
|
|
4336
5445
|
function catalogResponse(reply) {
|
|
4337
5446
|
if (!record(reply.body)) return bad(reply.status);
|
|
4338
|
-
const
|
|
5447
|
+
const result4 = {};
|
|
4339
5448
|
let hasData = false;
|
|
4340
5449
|
for (const key of ["product", "item", "asset"]) if (reply.body[key] !== void 0) {
|
|
4341
|
-
|
|
5450
|
+
result4[key] = entry(reply.body[key], reply.status);
|
|
4342
5451
|
hasData = true;
|
|
4343
5452
|
}
|
|
4344
5453
|
for (const key of ["products", "items", "assets"]) if (Array.isArray(reply.body[key])) {
|
|
4345
|
-
|
|
5454
|
+
result4[key] = reply.body[key].map((item) => entry(item, reply.status));
|
|
4346
5455
|
hasData = true;
|
|
4347
5456
|
}
|
|
4348
5457
|
if (!hasData) return bad(reply.status);
|
|
4349
|
-
for (const key of ["total", "nextOffset", "nextCursor", "hasMore", "replayed"]) if (["number", "string", "boolean"].includes(typeof reply.body[key]) || reply.body[key] === null)
|
|
4350
|
-
return
|
|
5458
|
+
for (const key of ["total", "nextOffset", "nextCursor", "hasMore", "replayed"]) if (["number", "string", "boolean"].includes(typeof reply.body[key]) || reply.body[key] === null) result4[key] = reply.body[key];
|
|
5459
|
+
return result4;
|
|
4351
5460
|
}
|
|
4352
5461
|
function catalogQuery(values, fields3) {
|
|
4353
5462
|
const query = new URLSearchParams();
|
|
@@ -4408,12 +5517,12 @@ async function assets(context) {
|
|
|
4408
5517
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
4409
5518
|
const key = listing || action2 === "show" ? void 0 : idempotencyKeyOf(context.values);
|
|
4410
5519
|
const path = listing ? `/api/open/v1/assets${catalogQuery(context.values, ["q", "kind", "source", "limit", "offset"])}` : `/api/open/v1/assets/${encodeURIComponent(rawId)}`;
|
|
4411
|
-
const
|
|
4412
|
-
const items = Array.isArray(
|
|
5520
|
+
const result4 = upload3 ? await catalogUpload(baseUrl, apiKey, `/api/open/v1/assets/uploads${query}`, upload3.bytes, upload3.contentType, key, context.io) : key ? await catalogWrite(baseUrl, apiKey, `${path}${action2 === "rename" ? "" : `/${action2}`}`, action2 === "rename" ? "PATCH" : "POST", action2 === "rename" ? { name: name2 } : {}, key, context.io) : await catalogGet(baseUrl, apiKey, listing ? path : `${path}?${new URLSearchParams({ source })}`, context.io);
|
|
5521
|
+
const items = Array.isArray(result4.assets) ? result4.assets : [result4.asset];
|
|
4413
5522
|
context.out.result(items.filter(Boolean).map((item) => {
|
|
4414
5523
|
const r = item;
|
|
4415
5524
|
return `${singleLine(String(r.id))} ${singleLine(String(r.name))} ${singleLine(String(r.source))}`;
|
|
4416
|
-
}), { ...
|
|
5525
|
+
}), { ...result4, ...key ? { idempotencyKey: key } : {} });
|
|
4417
5526
|
}
|
|
4418
5527
|
|
|
4419
5528
|
// src/commands/library.ts
|
|
@@ -4428,12 +5537,12 @@ async function library(context) {
|
|
|
4428
5537
|
if (action2 === "rename" && !name2) throw usageError("\u8BF7\u63D0\u4F9B --name <\u540D\u79F0>");
|
|
4429
5538
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
4430
5539
|
const key = listing || action2 === "show" ? void 0 : idempotencyKeyOf(context.values);
|
|
4431
|
-
const
|
|
4432
|
-
const items = Array.isArray(
|
|
5540
|
+
const result4 = key ? await catalogWrite(baseUrl, apiKey, `${path}${action2 === "rename" ? "" : `/${action2}`}`, action2 === "rename" ? "PATCH" : "POST", action2 === "rename" ? { name: name2 } : {}, key, context.io) : await catalogGet(baseUrl, apiKey, path, context.io);
|
|
5541
|
+
const items = Array.isArray(result4.items) ? result4.items : [result4.item];
|
|
4433
5542
|
context.out.result(items.filter(Boolean).map((item) => {
|
|
4434
5543
|
const r = item;
|
|
4435
5544
|
return `${singleLine(String(r.id))} ${singleLine(String(r.name))} ${singleLine(String(r.status))}`;
|
|
4436
|
-
}), { ...
|
|
5545
|
+
}), { ...result4, ...key ? { idempotencyKey: key } : {} });
|
|
4437
5546
|
}
|
|
4438
5547
|
|
|
4439
5548
|
// src/cli.ts
|
|
@@ -4441,9 +5550,9 @@ import { parseArgs } from "node:util";
|
|
|
4441
5550
|
|
|
4442
5551
|
// src/commands/balance.ts
|
|
4443
5552
|
async function balance(context) {
|
|
4444
|
-
const { io, out } = context;
|
|
5553
|
+
const { io: io2, out } = context;
|
|
4445
5554
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
4446
|
-
const { view, raw } = await getBalance(baseUrl, apiKey,
|
|
5555
|
+
const { view, raw } = await getBalance(baseUrl, apiKey, io2);
|
|
4447
5556
|
out.result(
|
|
4448
5557
|
[
|
|
4449
5558
|
`\u53EF\u7528\u4F59\u989D\uFF1A${view.available} ${singleLine(view.currency)}`,
|
|
@@ -4467,8 +5576,8 @@ async function creativeAttachments(context, resource) {
|
|
|
4467
5576
|
const offset = textOption(context.values, "offset");
|
|
4468
5577
|
if (offset) params.set("offset", offset);
|
|
4469
5578
|
for (const item of ids ?? []) params.append("attachmentId", item);
|
|
4470
|
-
const
|
|
4471
|
-
context.out.result([JSON.stringify(
|
|
5579
|
+
const result4 = await getCreative(baseUrl, apiKey, resource, id, `attachments${params.size ? `?${params}` : ""}`, context.io);
|
|
5580
|
+
context.out.result([JSON.stringify(result4, null, 2)], result4);
|
|
4472
5581
|
return;
|
|
4473
5582
|
}
|
|
4474
5583
|
if (action2 === "upload") {
|
|
@@ -4478,8 +5587,8 @@ async function creativeAttachments(context, resource) {
|
|
|
4478
5587
|
const key = idempotencyKeyOf(context.values);
|
|
4479
5588
|
const suffix = `attachments?${new URLSearchParams({ name: basename6(path) })}`;
|
|
4480
5589
|
try {
|
|
4481
|
-
const
|
|
4482
|
-
context.out.result([JSON.stringify(
|
|
5590
|
+
const result4 = creativeObject((await putRaw(baseUrl, apiKey, creativePath(resource, id, suffix), upload3.bytes, upload3.contentType, key, context.io)).body);
|
|
5591
|
+
context.out.result([JSON.stringify(result4, null, 2), `\u5E42\u7B49\u952E\uFF1A${key}`], { ...result4, idempotencyKey: key });
|
|
4483
5592
|
return;
|
|
4484
5593
|
} catch (error) {
|
|
4485
5594
|
const failure = toCliError(error);
|
|
@@ -4506,7 +5615,7 @@ async function creativeAttachments(context, resource) {
|
|
|
4506
5615
|
}
|
|
4507
5616
|
|
|
4508
5617
|
// src/commands/drama.ts
|
|
4509
|
-
var SUBCOMMANDS2 = "create\u3001status\u3001quote\u3001confirm\u3001cancel\u3001download\u3001context\u3001director\u3001document\u3001message\u3001director-confirm\u3001bindings\u3001spec\u3001shot-plan\u3001versions\u3001select-version\u3001redo-quote\u3001redo";
|
|
5618
|
+
var SUBCOMMANDS2 = "create\u3001result\u3001status\u3001quote\u3001confirm\u3001cancel\u3001download\u3001context\u3001director\u3001document\u3001message\u3001director-confirm\u3001bindings\u3001spec\u3001shot-plan\u3001versions\u3001select-version\u3001redo-quote\u3001redo";
|
|
4510
5619
|
var DURATION_KEYS = ["30s", "60s", "90s"];
|
|
4511
5620
|
async function drama2(context) {
|
|
4512
5621
|
timeoutSecondsOf(context.values, DEFAULT_WAIT_TIMEOUT_MS / 1e3);
|
|
@@ -4519,6 +5628,7 @@ async function drama2(context) {
|
|
|
4519
5628
|
if (["attachments", "upload", "attachment-download"].includes(subcommand)) return creativeAttachments(context, "drama");
|
|
4520
5629
|
if (subcommand === "create") return create(context);
|
|
4521
5630
|
if (subcommand === "status") return status2(context, args[1]);
|
|
5631
|
+
if (subcommand === "result") return result2(context, args[1]);
|
|
4522
5632
|
if (subcommand === "quote") return quote2(context, args[1]);
|
|
4523
5633
|
if (subcommand === "confirm") return confirm(context, args[1]);
|
|
4524
5634
|
if (subcommand === "cancel") return cancel2(context, args[1]);
|
|
@@ -4531,11 +5641,11 @@ function orderIdOf2(raw) {
|
|
|
4531
5641
|
}
|
|
4532
5642
|
return raw.trim();
|
|
4533
5643
|
}
|
|
4534
|
-
function waitControls2(
|
|
5644
|
+
function waitControls2(io2, values, note) {
|
|
4535
5645
|
return {
|
|
4536
5646
|
timeoutMs: timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3) * 1e3,
|
|
4537
|
-
now:
|
|
4538
|
-
sleep: (ms) => sleepFor(
|
|
5647
|
+
now: io2.now ?? (() => /* @__PURE__ */ new Date()),
|
|
5648
|
+
sleep: (ms) => sleepFor(io2, ms),
|
|
4539
5649
|
note
|
|
4540
5650
|
};
|
|
4541
5651
|
}
|
|
@@ -4602,7 +5712,6 @@ function guidanceLines(order2) {
|
|
|
4602
5712
|
function failureLines(order2) {
|
|
4603
5713
|
return (order2.failures ?? []).flatMap((failure) => [
|
|
4604
5714
|
`\u955C\u5934\u95EE\u9898\uFF1A${singleLine(failure.message)}`,
|
|
4605
|
-
...failure.reference?.assetIds.length ? [`\u7D20\u6750\u7F16\u53F7\uFF1A${failure.reference.assetIds.map(singleLine).join("\u3001")}`] : [],
|
|
4606
5715
|
`\u5904\u7406\u5EFA\u8BAE\uFF1A${singleLine(failure.suggestion)}`
|
|
4607
5716
|
]);
|
|
4608
5717
|
}
|
|
@@ -4647,9 +5756,9 @@ function quoteLines(orderId, quote3) {
|
|
|
4647
5756
|
];
|
|
4648
5757
|
}
|
|
4649
5758
|
async function create(context) {
|
|
4650
|
-
const { io, out, values } = context;
|
|
5759
|
+
const { io: io2, out, values } = context;
|
|
4651
5760
|
const dataRef = textOption(values, "data");
|
|
4652
|
-
const data = dataRef ? await readPropsArgument(
|
|
5761
|
+
const data = dataRef ? await readPropsArgument(io2, dataRef, "\u77ED\u5267\u53C2\u6570\uFF08--data\uFF09") : {};
|
|
4653
5762
|
for (const field of ["ownerId", "workspaceId", "allowPaidConfirmation"]) if (field in data) throw usageError(`--data \u4E0D\u80FD\u63D0\u4F9B ${field}`);
|
|
4654
5763
|
const productId = textOption(values, "product") ?? (typeof data.productId === "string" ? data.productId : void 0);
|
|
4655
5764
|
if (!productId?.trim()) {
|
|
@@ -4663,7 +5772,7 @@ async function create(context) {
|
|
|
4663
5772
|
const briefRef = textOption(values, "brief");
|
|
4664
5773
|
const videoModel = textOption(values, "model");
|
|
4665
5774
|
const resolution = textOption(values, "resolution");
|
|
4666
|
-
const brief = briefRef === void 0 ? void 0 : await readPropsArgument(
|
|
5775
|
+
const brief = briefRef === void 0 ? void 0 : await readPropsArgument(io2, briefRef, "\u6545\u4E8B\u8BBE\u5B9A\uFF08--brief\uFF09");
|
|
4667
5776
|
const idempotencyKey = idempotencyKeyOf(values);
|
|
4668
5777
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
4669
5778
|
const created = await createDramaOrder(
|
|
@@ -4679,32 +5788,69 @@ async function create(context) {
|
|
|
4679
5788
|
...resolution === void 0 ? {} : { resolution }
|
|
4680
5789
|
},
|
|
4681
5790
|
idempotencyKey,
|
|
4682
|
-
|
|
5791
|
+
io2
|
|
4683
5792
|
);
|
|
4684
5793
|
out.result(
|
|
4685
|
-
[
|
|
5794
|
+
[
|
|
5795
|
+
...orderLines2(created.view),
|
|
5796
|
+
`\u5E42\u7B49\u952E\uFF1A${idempotencyKey}`,
|
|
5797
|
+
`\u67E5\u8FDB\u5EA6\uFF1Abuke drama status ${created.view.id}`,
|
|
5798
|
+
`\u7F51\u9875\u67E5\u770B\uFF1A${baseUrl}/projects/${encodeURIComponent(created.view.projectId)}`
|
|
5799
|
+
],
|
|
4686
5800
|
// --json 按文档回服务端那份完整的 order;replayed 说明这次是新建还是同键重放。
|
|
4687
|
-
{ order: created.raw.order, replayed: created.replayed, idempotencyKey }
|
|
5801
|
+
{ order: created.raw.order, replayed: created.replayed, idempotencyKey, webLink: `${baseUrl}/projects/${encodeURIComponent(created.view.projectId)}` }
|
|
4688
5802
|
);
|
|
4689
5803
|
}
|
|
4690
5804
|
async function status2(context, rawId) {
|
|
4691
|
-
const { io, out, values } = context;
|
|
5805
|
+
const { io: io2, out, values } = context;
|
|
4692
5806
|
const orderId = orderIdOf2(rawId);
|
|
4693
5807
|
const shouldWait = values.wait === true;
|
|
4694
|
-
const controls = shouldWait ? waitControls2(
|
|
5808
|
+
const controls = shouldWait ? waitControls2(io2, values, (line) => out.notice(line)) : void 0;
|
|
4695
5809
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
4696
|
-
const current = await getDramaOrder(baseUrl, apiKey, orderId,
|
|
4697
|
-
const final = shouldWait ? settleOrder2(await awaitDramaOrder(baseUrl, apiKey, current,
|
|
4698
|
-
|
|
5810
|
+
const current = await getDramaOrder(baseUrl, apiKey, orderId, io2);
|
|
5811
|
+
const final = shouldWait ? settleOrder2(await awaitDramaOrder(baseUrl, apiKey, current, io2, controls), baseUrl) : current;
|
|
5812
|
+
const webLink = `${baseUrl}/projects/${encodeURIComponent(final.view.projectId)}`;
|
|
5813
|
+
out.result([...orderLines2(final.view), ...guidanceLines(final.view), `\u7F51\u9875\u67E5\u770B\uFF1A${webLink}`], {
|
|
4699
5814
|
order: final.raw.order,
|
|
4700
|
-
...shouldWait ? { waited: true } : {}
|
|
5815
|
+
...shouldWait ? { waited: true } : {},
|
|
5816
|
+
webLink
|
|
4701
5817
|
});
|
|
4702
5818
|
}
|
|
5819
|
+
async function result2(context, rawId) {
|
|
5820
|
+
const { io: io2, out, values } = context;
|
|
5821
|
+
const orderId = orderIdOf2(rawId);
|
|
5822
|
+
const shouldWait = values.wait === true;
|
|
5823
|
+
const controls = shouldWait ? waitControls2(io2, values, (line) => out.notice(line)) : void 0;
|
|
5824
|
+
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
5825
|
+
const current = await getDramaOrder(baseUrl, apiKey, orderId, io2);
|
|
5826
|
+
const final = settleOrder2(shouldWait ? await awaitDramaOrder(baseUrl, apiKey, current, io2, controls) : { value: current, timedOut: false }, baseUrl);
|
|
5827
|
+
const webLink = `${baseUrl}/projects/${encodeURIComponent(final.view.projectId)}`;
|
|
5828
|
+
if (final.view.status !== "delivered") {
|
|
5829
|
+
out.result(
|
|
5830
|
+
[...orderLines2(final.view), ...guidanceLines(final.view), `\u7F51\u9875\u67E5\u770B\uFF1A${webLink}`],
|
|
5831
|
+
{ order: final.raw.order, ...shouldWait ? { waited: true } : {}, webLink }
|
|
5832
|
+
);
|
|
5833
|
+
return;
|
|
5834
|
+
}
|
|
5835
|
+
const film = await downloadDramaFilm(baseUrl, apiKey, orderId, io2);
|
|
5836
|
+
const defaultName = film.filename ?? `drama-${orderId}.mp4`;
|
|
5837
|
+
const saved = await saveDownload(textOption(values, "out") ?? defaultName, film.bytes);
|
|
5838
|
+
out.result(
|
|
5839
|
+
[
|
|
5840
|
+
...orderLines2(final.view),
|
|
5841
|
+
`\u5DF2\u4E0B\u8F7D\uFF1A${saved.path}`,
|
|
5842
|
+
`\u5927\u5C0F\uFF1A${saved.bytes} \u5B57\u8282`,
|
|
5843
|
+
`\u6821\u9A8C\uFF1Asha256 ${saved.sha256}`,
|
|
5844
|
+
`\u7F51\u9875\u67E5\u770B\uFF1A${webLink}`
|
|
5845
|
+
],
|
|
5846
|
+
{ order: final.raw.order, download: { ...saved, filename: defaultName }, ...shouldWait ? { waited: true } : {}, webLink }
|
|
5847
|
+
);
|
|
5848
|
+
}
|
|
4703
5849
|
async function quote2(context, rawId) {
|
|
4704
|
-
const { io, out } = context;
|
|
5850
|
+
const { io: io2, out } = context;
|
|
4705
5851
|
const orderId = orderIdOf2(rawId);
|
|
4706
5852
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
4707
|
-
const { view, raw } = await getDramaQuote(baseUrl, apiKey, orderId,
|
|
5853
|
+
const { view, raw } = await getDramaQuote(baseUrl, apiKey, orderId, io2);
|
|
4708
5854
|
out.result(quoteLines(orderId, view), {
|
|
4709
5855
|
quote: raw.quote,
|
|
4710
5856
|
quoteHash: view.quoteHash,
|
|
@@ -4713,7 +5859,7 @@ async function quote2(context, rawId) {
|
|
|
4713
5859
|
});
|
|
4714
5860
|
}
|
|
4715
5861
|
async function confirm(context, rawId) {
|
|
4716
|
-
const { io, out, values } = context;
|
|
5862
|
+
const { io: io2, out, values } = context;
|
|
4717
5863
|
const orderId = orderIdOf2(rawId);
|
|
4718
5864
|
const quoteHash = textOption(values, "quote-hash");
|
|
4719
5865
|
if (quoteHash === void 0) {
|
|
@@ -4722,9 +5868,9 @@ async function confirm(context, rawId) {
|
|
|
4722
5868
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
4723
5869
|
const suppliedKey = textOption(values, "idempotency-key")?.trim();
|
|
4724
5870
|
const preflightRecovery = (status4) => dramaConfirmationRecovery(orderId, status4, baseUrl, suppliedKey, "not_submitted");
|
|
4725
|
-
const current = await retainTaskOnError(() => preflightRecovery(), () => getDramaOrder(baseUrl, apiKey, orderId,
|
|
5871
|
+
const current = await retainTaskOnError(() => preflightRecovery(), () => getDramaOrder(baseUrl, apiKey, orderId, io2));
|
|
4726
5872
|
const knownStatus = current.view.status;
|
|
4727
|
-
const quoted = current.view.status === "quotable" ? await retainTaskOnError(() => preflightRecovery(knownStatus), () => getDramaQuote(baseUrl, apiKey, orderId,
|
|
5873
|
+
const quoted = current.view.status === "quotable" ? await retainTaskOnError(() => preflightRecovery(knownStatus), () => getDramaQuote(baseUrl, apiKey, orderId, io2)) : null;
|
|
4728
5874
|
if (values.yes !== true) {
|
|
4729
5875
|
if (!out.json) {
|
|
4730
5876
|
out.result(
|
|
@@ -4740,29 +5886,32 @@ async function confirm(context, rawId) {
|
|
|
4740
5886
|
});
|
|
4741
5887
|
}
|
|
4742
5888
|
const idempotencyKey = idempotencyKeyOf(values);
|
|
4743
|
-
const confirmed = await confirmDramaOrder(baseUrl, apiKey, orderId, quoteHash, idempotencyKey,
|
|
5889
|
+
const confirmed = await confirmDramaOrder(baseUrl, apiKey, orderId, quoteHash, idempotencyKey, io2, knownStatus);
|
|
5890
|
+
const webLink = `${baseUrl}/projects/${encodeURIComponent(confirmed.view.projectId)}`;
|
|
4744
5891
|
out.result(
|
|
4745
5892
|
[
|
|
4746
5893
|
...orderLines2(confirmed.view),
|
|
4747
5894
|
confirmed.productionStarted ? quoted === null ? "\u5DF2\u786E\u8BA4\uFF1A\u6309\u539F\u6765\u6536\u4E0B\u7684\u62A5\u4EF7\u8865\u62CD\u7F3A\u7684\u955C\u5934" : `\u5DF2\u786E\u8BA4\uFF1A\u8FD9\u7B14\u6700\u591A ${quoted.view.totalCredits} \u5E03` : "\u5DF2\u786E\u8BA4\uFF1A\u8FD9\u6B21\u6CA1\u6709\u5F00\u65B0\u4EFB\u52A1\uFF08\u5B83\u53EF\u80FD\u5DF2\u7ECF\u5728\u62CD\uFF0C\u6216\u5DF2\u7ECF\u62CD\u597D\u7B49\u62FC\u63A5\uFF09",
|
|
4748
5895
|
...guidanceLines(confirmed.view),
|
|
4749
|
-
`\u5E42\u7B49\u952E\uFF1A${idempotencyKey}
|
|
5896
|
+
`\u5E42\u7B49\u952E\uFF1A${idempotencyKey}`,
|
|
5897
|
+
`\u7F51\u9875\u67E5\u770B\uFF1A${webLink}`
|
|
4750
5898
|
],
|
|
4751
5899
|
{
|
|
4752
5900
|
order: confirmed.raw.order,
|
|
4753
5901
|
productionStarted: confirmed.productionStarted,
|
|
4754
5902
|
// 计价的那一份:可报价时是刚取回的报价;续拍按原签字走,没有当前报价。
|
|
4755
5903
|
confirmed: { totalCredits: quoted === null ? null : quoted.view.totalCredits, quoteHash },
|
|
4756
|
-
idempotencyKey
|
|
5904
|
+
idempotencyKey,
|
|
5905
|
+
webLink
|
|
4757
5906
|
}
|
|
4758
5907
|
);
|
|
4759
5908
|
}
|
|
4760
5909
|
async function cancel2(context, rawId) {
|
|
4761
|
-
const { io, out, values } = context;
|
|
5910
|
+
const { io: io2, out, values } = context;
|
|
4762
5911
|
const orderId = orderIdOf2(rawId);
|
|
4763
5912
|
const idempotencyKey = idempotencyKeyOf(values);
|
|
4764
5913
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
4765
|
-
const canceled = await cancelDramaOrder(baseUrl, apiKey, orderId, idempotencyKey,
|
|
5914
|
+
const canceled = await cancelDramaOrder(baseUrl, apiKey, orderId, idempotencyKey, io2);
|
|
4766
5915
|
out.result(
|
|
4767
5916
|
[
|
|
4768
5917
|
...orderLines2(canceled.view),
|
|
@@ -4773,7 +5922,7 @@ async function cancel2(context, rawId) {
|
|
|
4773
5922
|
);
|
|
4774
5923
|
}
|
|
4775
5924
|
async function download2(context, rawId) {
|
|
4776
|
-
const { io, out, values } = context;
|
|
5925
|
+
const { io: io2, out, values } = context;
|
|
4777
5926
|
const orderId = orderIdOf2(rawId);
|
|
4778
5927
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
4779
5928
|
const outputId = textOption(values, "output-id");
|
|
@@ -4782,10 +5931,10 @@ async function download2(context, rawId) {
|
|
|
4782
5931
|
if ([outputId, editId, sourceId].filter(Boolean).length > 1) throw usageError("--output-id\u3001--edit-id \u4E0E --source-output-id \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528");
|
|
4783
5932
|
if (outputId) return creativeDownload(context, "drama", orderId, `renders/${encodeURIComponent(outputId)}/download`);
|
|
4784
5933
|
if (editId || sourceId) return creativeDownload(context, "drama", orderId, `${editId ? "edit" : "history"}/${encodeURIComponent(editId ?? sourceId)}/download`);
|
|
4785
|
-
const
|
|
4786
|
-
const defaultName =
|
|
5934
|
+
const result4 = await downloadDramaFilm(baseUrl, apiKey, orderId, io2);
|
|
5935
|
+
const defaultName = result4.filename ?? `drama-${orderId}.mp4`;
|
|
4787
5936
|
const target = textOption(values, "out") ?? defaultName;
|
|
4788
|
-
const saved = await saveDownload(target,
|
|
5937
|
+
const saved = await saveDownload(target, result4.bytes);
|
|
4789
5938
|
out.result(
|
|
4790
5939
|
[`\u5DF2\u4E0B\u8F7D\uFF1A${saved.path}`, `\u5927\u5C0F\uFF1A${saved.bytes} \u5B57\u8282`, `\u6821\u9A8C\uFF1Asha256 ${saved.sha256}`],
|
|
4791
5940
|
{ download: { ...saved, filename: defaultName } }
|
|
@@ -4902,50 +6051,61 @@ function identityLines(me, displayPrefix) {
|
|
|
4902
6051
|
}
|
|
4903
6052
|
|
|
4904
6053
|
// src/commands/login.ts
|
|
4905
|
-
async function login({ io, out, baseUrl: flag }) {
|
|
4906
|
-
const explicit = explicitBaseUrl(flag,
|
|
6054
|
+
async function login({ io: io2, out, baseUrl: flag }) {
|
|
6055
|
+
const explicit = explicitBaseUrl(flag, io2.env);
|
|
4907
6056
|
const baseUrl = explicit ?? DEFAULT_BASE_URL;
|
|
4908
|
-
credentialsPath(
|
|
4909
|
-
assertReachedDirectly(baseUrl,
|
|
6057
|
+
credentialsPath(io2);
|
|
6058
|
+
assertReachedDirectly(baseUrl, io2.env);
|
|
4910
6059
|
const fromEnv = flag === void 0 && explicit !== null;
|
|
4911
6060
|
const origin = flag !== void 0 ? "\uFF08\u5730\u5740\u6765\u81EA --base-url\uFF09" : fromEnv ? "\uFF08\u5730\u5740\u6765\u81EA\u73AF\u5883\u53D8\u91CF BUKE_BASE_URL\uFF09" : "";
|
|
4912
|
-
if (willPromptForKey(
|
|
6061
|
+
if (willPromptForKey(io2) || fromEnv && baseUrl !== DEFAULT_BASE_URL) {
|
|
4913
6062
|
out.notice(`\u5C06\u767B\u5F55 ${baseUrl}${origin}`);
|
|
4914
6063
|
}
|
|
4915
|
-
const { key, source } = await readNewKey(
|
|
6064
|
+
const { key, source } = await readNewKey(io2);
|
|
4916
6065
|
out.protect(key);
|
|
4917
|
-
const me = await getMe(baseUrl, key,
|
|
4918
|
-
const
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
},
|
|
4927
|
-
(line) => out.notice(line)
|
|
4928
|
-
);
|
|
6066
|
+
const me = await getMe(baseUrl, key, io2);
|
|
6067
|
+
const credentials = {
|
|
6068
|
+
version: 1,
|
|
6069
|
+
baseUrl,
|
|
6070
|
+
apiKey: key,
|
|
6071
|
+
keyId: me.key.id,
|
|
6072
|
+
savedAt: (io2.now?.() ?? /* @__PURE__ */ new Date()).toISOString()
|
|
6073
|
+
};
|
|
6074
|
+
const inKeychain = await saveKeychainCredentials(io2, credentials);
|
|
4929
6075
|
const displayPrefix = displayPrefixOf(key, me.key.id);
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
{
|
|
4934
|
-
|
|
4935
|
-
|
|
6076
|
+
let savedLine;
|
|
6077
|
+
let document;
|
|
6078
|
+
if (inKeychain.ok) {
|
|
6079
|
+
try {
|
|
6080
|
+
await deleteCredentials(io2, SILENT);
|
|
6081
|
+
} catch {
|
|
6082
|
+
}
|
|
6083
|
+
savedLine = "\u51ED\u636E\u4FDD\u5B58\u5728 macOS \u94A5\u5319\u4E32\uFF08bukesiyi-cli/api-key\uFF09";
|
|
6084
|
+
document = { ...identityDocument(baseUrl, me, displayPrefix), storedIn: "keychain" };
|
|
6085
|
+
} else {
|
|
6086
|
+
const savedTo = await writeCredentials(io2, credentials, (line) => out.notice(line));
|
|
6087
|
+
savedLine = io2.platform === "win32" ? `\u51ED\u636E\u4FDD\u5B58\u5728 ${savedTo}` : `\u51ED\u636E\u4FDD\u5B58\u5728 ${savedTo}\uFF08\u53EA\u6709\u672C\u4EBA\u53EF\u8BFB\u5199\uFF09`;
|
|
6088
|
+
document = { ...identityDocument(baseUrl, me, displayPrefix), credentialsPath: savedTo };
|
|
6089
|
+
}
|
|
6090
|
+
out.result([`\u5DF2\u767B\u5F55 ${baseUrl}`, ...identityLines(me, displayPrefix), savedLine], document, [displayPrefix]);
|
|
4936
6091
|
if (source === "env") {
|
|
4937
6092
|
out.notice("\u8FD9\u628A\u5BC6\u94A5\u6765\u81EA\u73AF\u5883\u53D8\u91CF BUKE_API_KEY\uFF1B\u5B83\u5DF2\u4FDD\u5B58\u5230\u672C\u673A\uFF0C\u4E4B\u540E\u4E0D\u8BBE\u8FD9\u4E2A\u53D8\u91CF\u4E5F\u80FD\u7528");
|
|
4938
6093
|
}
|
|
4939
6094
|
}
|
|
4940
6095
|
|
|
4941
6096
|
// src/commands/logout.ts
|
|
4942
|
-
async function logout({ io, out }) {
|
|
4943
|
-
const
|
|
6097
|
+
async function logout({ io: io2, out }) {
|
|
6098
|
+
const fromKeychain = await deleteKeychainCredentials(io2);
|
|
6099
|
+
const removedFile = await deleteCredentials(io2, (line) => out.notice(line));
|
|
6100
|
+
const removed = removedFile || fromKeychain.ok && fromKeychain.value.existed;
|
|
6101
|
+
if (!fromKeychain.ok && keychainAvailable(io2)) {
|
|
6102
|
+
out.notice(`\u94A5\u5319\u4E32\u91CC\u7684\u5BC6\u94A5\u6CA1\u80FD\u5220\u9664\uFF08${fromKeychain.reason}\uFF09\uFF0C\u53EF\u5728\u300C\u94A5\u5319\u4E32\u8BBF\u95EE\u300D\u91CC\u624B\u52A8\u5220\u9664 bukesiyi-cli/api-key`);
|
|
6103
|
+
}
|
|
4944
6104
|
out.result(
|
|
4945
6105
|
[removed ? "\u5DF2\u9000\u51FA\u767B\u5F55\uFF0C\u672C\u673A\u4FDD\u5B58\u7684\u5BC6\u94A5\u5DF2\u5220\u9664\u3002\u8FD9\u628A\u5BC6\u94A5\u672C\u8EAB\u4ECD\u7136\u5728\u7528\uFF0C\u4E0D\u518D\u4F7F\u7528\u8BF7\u540A\u9500\u5B83" : "\u672C\u673A\u6CA1\u6709\u4FDD\u5B58\u7684\u5BC6\u94A5"],
|
|
4946
|
-
{ removed, credentialsPath: credentialsPath(
|
|
6106
|
+
{ removed, credentialsPath: credentialsPath(io2) }
|
|
4947
6107
|
);
|
|
4948
|
-
if (keyFromEnv(
|
|
6108
|
+
if (keyFromEnv(io2.env) !== null) {
|
|
4949
6109
|
out.notice("\u73AF\u5883\u53D8\u91CF BUKE_API_KEY \u8FD8\u8BBE\u7740\uFF0C\u4E4B\u540E\u7684\u547D\u4EE4\u4ECD\u4F1A\u7528\u5B83");
|
|
4950
6110
|
}
|
|
4951
6111
|
}
|
|
@@ -4971,8 +6131,8 @@ function productIdOf(raw, what) {
|
|
|
4971
6131
|
return raw.trim();
|
|
4972
6132
|
}
|
|
4973
6133
|
async function create2(context, values) {
|
|
4974
|
-
const { io, out } = context;
|
|
4975
|
-
const data = textOption(values, "data") ? await readPropsArgument(
|
|
6134
|
+
const { io: io2, out } = context;
|
|
6135
|
+
const data = textOption(values, "data") ? await readPropsArgument(io2, textOption(values, "data"), "\u4EA7\u54C1\u8D44\u6599") : {};
|
|
4976
6136
|
if (Object.keys(data).some((key) => !["name", "category", "sku", "productLock", "intelligence", "classificationHint"].includes(key))) throw usageError("\u4EA7\u54C1\u8D44\u6599\u5305\u542B\u4E0D\u652F\u6301\u7684\u5B57\u6BB5");
|
|
4977
6137
|
const name2 = textOption(values, "name") ?? (typeof data.name === "string" ? data.name : void 0);
|
|
4978
6138
|
if (name2 === void 0) {
|
|
@@ -4981,7 +6141,7 @@ async function create2(context, values) {
|
|
|
4981
6141
|
const category = textOption(values, "category") ?? (typeof data.category === "string" ? data.category : void 0);
|
|
4982
6142
|
const idempotencyKey = idempotencyKeyOf(values);
|
|
4983
6143
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
4984
|
-
const { view, raw, replayed } = await createProduct(baseUrl, apiKey, name2, category, idempotencyKey,
|
|
6144
|
+
const { view, raw, replayed } = await createProduct(baseUrl, apiKey, name2, category, idempotencyKey, io2, { ...data, ...textOption(values, "sku") ? { sku: textOption(values, "sku") } : {}, ...textOption(values, "classification-hint") ? { classificationHint: textOption(values, "classification-hint") } : {} });
|
|
4985
6145
|
out.result(
|
|
4986
6146
|
[
|
|
4987
6147
|
replayed ? `\u4EA7\u54C1\u5DF2\u5B58\u5728\uFF1A${singleLine(view.id)}\uFF08\u540C\u952E\u91CD\u653E\uFF09` : `\u5DF2\u521B\u5EFA\u4EA7\u54C1\uFF1A${singleLine(view.id)}`,
|
|
@@ -4993,7 +6153,7 @@ async function create2(context, values) {
|
|
|
4993
6153
|
);
|
|
4994
6154
|
}
|
|
4995
6155
|
async function setImages(context, values, rawId) {
|
|
4996
|
-
const { io, out } = context;
|
|
6156
|
+
const { io: io2, out } = context;
|
|
4997
6157
|
const productId = productIdOf(rawId, "\u4EA7\u54C1 id\uFF08buke products create \u56DE\u7684\u90A3\u4E2A\uFF09");
|
|
4998
6158
|
const planned = [];
|
|
4999
6159
|
for (const angle of PRODUCT_ANGLES) {
|
|
@@ -5009,7 +6169,7 @@ async function setImages(context, values, rawId) {
|
|
|
5009
6169
|
let latest;
|
|
5010
6170
|
const uploaded = [];
|
|
5011
6171
|
for (const image of images) {
|
|
5012
|
-
const
|
|
6172
|
+
const result4 = await putProductImage(
|
|
5013
6173
|
baseUrl,
|
|
5014
6174
|
apiKey,
|
|
5015
6175
|
productId,
|
|
@@ -5017,10 +6177,10 @@ async function setImages(context, values, rawId) {
|
|
|
5017
6177
|
image.bytes,
|
|
5018
6178
|
image.contentType,
|
|
5019
6179
|
idempotencyKey,
|
|
5020
|
-
|
|
6180
|
+
io2
|
|
5021
6181
|
);
|
|
5022
|
-
latest =
|
|
5023
|
-
uploaded.push({ angle: image.angle, replayed:
|
|
6182
|
+
latest = result4;
|
|
6183
|
+
uploaded.push({ angle: image.angle, replayed: result4.replayed });
|
|
5024
6184
|
}
|
|
5025
6185
|
out.result(
|
|
5026
6186
|
[
|
|
@@ -5034,7 +6194,7 @@ async function setImages(context, values, rawId) {
|
|
|
5034
6194
|
);
|
|
5035
6195
|
}
|
|
5036
6196
|
async function confirmLock(context, values, rawId) {
|
|
5037
|
-
const { io, out } = context;
|
|
6197
|
+
const { io: io2, out } = context;
|
|
5038
6198
|
const productId = productIdOf(rawId, "\u4EA7\u54C1 id\uFF08buke products create \u56DE\u7684\u90A3\u4E2A\uFF09");
|
|
5039
6199
|
const colorName = textOption(values, "color");
|
|
5040
6200
|
const silhouette = textOption(values, "silhouette");
|
|
@@ -5056,7 +6216,7 @@ async function confirmLock(context, values, rawId) {
|
|
|
5056
6216
|
productId,
|
|
5057
6217
|
{ colorName, silhouette, material },
|
|
5058
6218
|
idempotencyKey,
|
|
5059
|
-
|
|
6219
|
+
io2
|
|
5060
6220
|
);
|
|
5061
6221
|
out.result(
|
|
5062
6222
|
[
|
|
@@ -5078,12 +6238,12 @@ async function manageProducts(context) {
|
|
|
5078
6238
|
const path = listing ? `/api/open/v1/products${catalogQuery(context.values, ["q", "archived", "limit", "offset"])}` : `/api/open/v1/products/${encodeURIComponent(id)}`;
|
|
5079
6239
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
5080
6240
|
const key = listing || action2 === "show" ? void 0 : idempotencyKeyOf(context.values);
|
|
5081
|
-
const
|
|
5082
|
-
const items = Array.isArray(
|
|
6241
|
+
const result4 = key ? await catalogWrite(baseUrl, apiKey, `${path}${action2 === "update" ? "" : `/${action2}`}`, action2 === "update" ? "PATCH" : "POST", action2 === "update" ? { name: name2 } : {}, key, context.io) : await catalogGet(baseUrl, apiKey, path, context.io);
|
|
6242
|
+
const items = Array.isArray(result4.products) ? result4.products : [result4.product];
|
|
5083
6243
|
context.out.result(items.filter(Boolean).map((item) => {
|
|
5084
6244
|
const r = item;
|
|
5085
6245
|
return `${singleLine(String(r.id))} ${singleLine(String(r.name))} ${singleLine(String(r.category))}`;
|
|
5086
|
-
}), { ...
|
|
6246
|
+
}), { ...result4, ...key ? { idempotencyKey: key } : {} });
|
|
5087
6247
|
}
|
|
5088
6248
|
|
|
5089
6249
|
// src/commands/video-music.ts
|
|
@@ -5099,12 +6259,12 @@ function safe(value) {
|
|
|
5099
6259
|
return Object.fromEntries(Object.entries(value).filter(([key]) => fields2.has(key)).map(([key, item]) => [key, safe(item)]));
|
|
5100
6260
|
}
|
|
5101
6261
|
function task(value) {
|
|
5102
|
-
const
|
|
5103
|
-
if (typeof
|
|
5104
|
-
return
|
|
6262
|
+
const result4 = object2(safe(value));
|
|
6263
|
+
if (typeof result4.id !== "string" || !["pending", "running", "succeeded", "failed"].includes(String(result4.status))) throw new CliError({ code: "CLI_BAD_RESPONSE", exitCode: EXIT.SERVER, message: "\u670D\u52A1\u7AEF\u672A\u8FD4\u56DE\u6709\u6548\u7684\u914D\u4E50\u4EFB\u52A1\u7F16\u53F7\u6216\u72B6\u6001" });
|
|
6264
|
+
return result4;
|
|
5105
6265
|
}
|
|
5106
6266
|
async function videoMusic(context) {
|
|
5107
|
-
const { args, values, out, io } = context;
|
|
6267
|
+
const { args, values, out, io: io2 } = context;
|
|
5108
6268
|
const timeoutSeconds = timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3);
|
|
5109
6269
|
const command = args[0];
|
|
5110
6270
|
const id = args[1]?.trim();
|
|
@@ -5115,7 +6275,7 @@ async function videoMusic(context) {
|
|
|
5115
6275
|
const expectedQuoteHash = textOption(values, "quote-hash")?.toLowerCase();
|
|
5116
6276
|
if (["music-quote", "music-compose"].includes(command) && values["quote-hash"] !== void 0 && (expectedQuoteHash === void 0 || !/^[a-f0-9]{64}$/u.test(expectedQuoteHash))) throw usageError("--quote-hash \u5FC5\u987B\u662F\u5DF2\u67E5\u770B\u7684 64 \u4F4D\u5341\u516D\u8FDB\u5236\u62A5\u4EF7\u54C8\u5E0C");
|
|
5117
6277
|
if (command === "music-compose" && values.yes === true && expectedQuoteHash === void 0) throw usageError("\u786E\u8BA4\u914D\u4E50\u751F\u6210\u5FC5\u987B\u63D0\u4F9B\u5DF2\u67E5\u770B\u7684 --quote-hash\uFF1B\u5148\u4E0D\u5E26 --yes \u67E5\u770B\u62A5\u4EF7");
|
|
5118
|
-
const request = ["music-quote", "music-compose", "music-apply"].includes(command) ? await readPropsArgument(
|
|
6278
|
+
const request = ["music-quote", "music-compose", "music-apply"].includes(command) ? await readPropsArgument(io2, textOption(values, "props"), "\u914D\u4E50\u8BF7\u6C42") : {};
|
|
5119
6279
|
const key = idempotencyKeyOf(values);
|
|
5120
6280
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
5121
6281
|
const path = `/api/open/v1/videos/${encodeURIComponent(id)}/music`;
|
|
@@ -5124,7 +6284,7 @@ async function videoMusic(context) {
|
|
|
5124
6284
|
let latestTask;
|
|
5125
6285
|
try {
|
|
5126
6286
|
if (command === "music-list") {
|
|
5127
|
-
const data = object2(safe((await getJson(baseUrl, apiKey, path,
|
|
6287
|
+
const data = object2(safe((await getJson(baseUrl, apiKey, path, io2)).body));
|
|
5128
6288
|
const tasks = Array.isArray(data.tasks) ? data.tasks.map(task) : [];
|
|
5129
6289
|
out.result(tasks.map((item) => `${singleLine(item.id)} ${singleLine(item.status)} ${singleLine(String(item.title ?? ""))}`), { ...data, tasks });
|
|
5130
6290
|
return;
|
|
@@ -5133,11 +6293,11 @@ async function videoMusic(context) {
|
|
|
5133
6293
|
const taskId = textOption(values, "music-task-id");
|
|
5134
6294
|
if (!taskId) throw usageError("\u8BF7\u63D0\u4F9B --music-task-id <\u914D\u4E50\u4EFB\u52A1ID>");
|
|
5135
6295
|
const timeoutMs = values.timeout === void 0 ? 3e5 : timeoutSeconds * 1e3;
|
|
5136
|
-
const data = object2(safe((await postJson(baseUrl, apiKey, `${path}/${encodeURIComponent(taskId)}/apply`, request, key,
|
|
6296
|
+
const data = object2(safe((await postJson(baseUrl, apiKey, `${path}/${encodeURIComponent(taskId)}/apply`, request, key, io2, { timeoutMs })).body));
|
|
5137
6297
|
out.result(["\u914D\u4E50\u5DF2\u5408\u6210\uFF1B\u539F\u6210\u7247\u4FDD\u7559\uFF0C\u672C\u6B21\u5408\u6210\u4E0D\u6536\u53D6\u751F\u6210\u8D39\u7528\u3002", `\u914D\u4E50\u4EFB\u52A1\uFF1A${singleLine(taskId)}`, `\u5E42\u7B49\u952E\uFF1A${key}`], { ...data, idempotencyKey: key });
|
|
5138
6298
|
return;
|
|
5139
6299
|
}
|
|
5140
|
-
const quote3 = object2(object2(safe((await postJson(baseUrl, apiKey, `${path}/quote`, request, key,
|
|
6300
|
+
const quote3 = object2(object2(safe((await postJson(baseUrl, apiKey, `${path}/quote`, request, key, io2)).body)).quote);
|
|
5141
6301
|
if (typeof quote3.quoteHash !== "string" || !/^[a-f0-9]{64}$/u.test(quote3.quoteHash) || typeof quote3.credits !== "number" || !Number.isFinite(quote3.credits) || quote3.credits <= 0) throw new CliError({ code: "CLI_BAD_RESPONSE", exitCode: EXIT.SERVER, message: "\u914D\u4E50\u62A5\u4EF7\u54CD\u5E94\u65E0\u6548\uFF0C\u672C\u6B21\u672A\u63D0\u4EA4\u751F\u6210" });
|
|
5142
6302
|
if (expectedQuoteHash !== void 0 && expectedQuoteHash !== quote3.quoteHash) throw new CliError({ code: "OPEN_API_QUOTE_CHANGED", exitCode: EXIT.QUOTE_CHANGED, message: "\u914D\u4E50\u62A5\u4EF7\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u67E5\u770B\u5E76\u786E\u8BA4" });
|
|
5143
6303
|
if (command === "music-quote" || values.yes !== true) {
|
|
@@ -5149,16 +6309,16 @@ async function videoMusic(context) {
|
|
|
5149
6309
|
return;
|
|
5150
6310
|
}
|
|
5151
6311
|
submitted = true;
|
|
5152
|
-
latestTask = task(object2((await postJson(baseUrl, apiKey, path, { ...request, confirmed: true, quoteHash: quote3.quoteHash }, key,
|
|
6312
|
+
latestTask = task(object2((await postJson(baseUrl, apiKey, path, { ...request, confirmed: true, quoteHash: quote3.quoteHash }, key, io2)).body).task);
|
|
5153
6313
|
accepted = true;
|
|
5154
6314
|
if (values.wait === true) {
|
|
5155
|
-
const now =
|
|
6315
|
+
const now = io2.now ?? (() => /* @__PURE__ */ new Date());
|
|
5156
6316
|
const until = now().getTime() + timeoutSeconds * 1e3;
|
|
5157
6317
|
while (["pending", "running"].includes(latestTask.status)) {
|
|
5158
6318
|
if (now().getTime() >= until) throw new CliError({ code: "CLI_WAIT_TIMEOUT", exitCode: EXIT.WAIT_TIMEOUT, message: "\u914D\u4E50\u7B49\u5F85\u5DF2\u8FBE\u5230\u65F6\u9650\uFF0C\u8BF7\u67E5\u8BE2\u539F\u914D\u4E50\u4EFB\u52A1\uFF0C\u4E0D\u8981\u91CD\u65B0\u63D0\u4EA4\u751F\u6210" });
|
|
5159
|
-
await sleepFor(
|
|
6319
|
+
await sleepFor(io2, Math.min(1500, Math.max(until - now().getTime(), 1)));
|
|
5160
6320
|
if (now().getTime() >= until) continue;
|
|
5161
|
-
const data = object2((await getJson(baseUrl, apiKey, path,
|
|
6321
|
+
const data = object2((await getJson(baseUrl, apiKey, path, io2)).body);
|
|
5162
6322
|
const found = Array.isArray(data.tasks) ? data.tasks.find((item) => item && typeof item === "object" && item.id === latestTask.id) : null;
|
|
5163
6323
|
latestTask = task(found);
|
|
5164
6324
|
}
|
|
@@ -5187,7 +6347,7 @@ async function videoMusic(context) {
|
|
|
5187
6347
|
}
|
|
5188
6348
|
|
|
5189
6349
|
// src/commands/videos.ts
|
|
5190
|
-
var SUBCOMMANDS3 = "create\u3001status\u3001message\u3001confirm\u3001versions\u3001cancel\u3001download\u3001music-quote\u3001music-compose\u3001music-list\u3001music-apply";
|
|
6350
|
+
var SUBCOMMANDS3 = "create\u3001result\u3001status\u3001message\u3001confirm\u3001versions\u3001cancel\u3001download\u3001music-quote\u3001music-compose\u3001music-list\u3001music-apply";
|
|
5191
6351
|
async function videos(context) {
|
|
5192
6352
|
timeoutSecondsOf(context.values, DEFAULT_WAIT_TIMEOUT_MS / 1e3);
|
|
5193
6353
|
const { args } = context;
|
|
@@ -5200,6 +6360,7 @@ async function videos(context) {
|
|
|
5200
6360
|
if (["attachments", "upload", "attachment-download"].includes(subcommand)) return creativeAttachments(context, "videos");
|
|
5201
6361
|
if (subcommand === "create") return create3(context);
|
|
5202
6362
|
if (subcommand === "status") return status3(context, args[1]);
|
|
6363
|
+
if (subcommand === "result") return result3(context, args[1]);
|
|
5203
6364
|
if (subcommand === "message") return message(context, args[1]);
|
|
5204
6365
|
if (subcommand === "confirm") return confirm2(context, args[1]);
|
|
5205
6366
|
if (subcommand === "download") return download3(context, args[1]);
|
|
@@ -5211,11 +6372,11 @@ function runIdOf(raw) {
|
|
|
5211
6372
|
}
|
|
5212
6373
|
return raw.trim();
|
|
5213
6374
|
}
|
|
5214
|
-
function waitControls3(
|
|
6375
|
+
function waitControls3(io2, values) {
|
|
5215
6376
|
return {
|
|
5216
6377
|
timeoutMs: timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3) * 1e3,
|
|
5217
|
-
now:
|
|
5218
|
-
sleep: (ms) => sleepFor(
|
|
6378
|
+
now: io2.now ?? (() => /* @__PURE__ */ new Date()),
|
|
6379
|
+
sleep: (ms) => sleepFor(io2, ms)
|
|
5219
6380
|
};
|
|
5220
6381
|
}
|
|
5221
6382
|
function settleRun(outcome, baseUrl) {
|
|
@@ -5255,7 +6416,7 @@ function waitingLines(run2) {
|
|
|
5255
6416
|
return [];
|
|
5256
6417
|
}
|
|
5257
6418
|
async function create3(context) {
|
|
5258
|
-
const { io, out, values } = context;
|
|
6419
|
+
const { io: io2, out, values } = context;
|
|
5259
6420
|
const data = await creativeData(context);
|
|
5260
6421
|
const productId = textOption(values, "product") ?? (typeof data.productId === "string" ? data.productId : void 0);
|
|
5261
6422
|
if (productId === void 0) {
|
|
@@ -5294,42 +6455,82 @@ async function create3(context) {
|
|
|
5294
6455
|
...Object.keys(preferences).length > 0 ? { preferences: { ...data.preferences && typeof data.preferences === "object" ? data.preferences : {}, ...preferences } } : {}
|
|
5295
6456
|
},
|
|
5296
6457
|
idempotencyKey,
|
|
5297
|
-
|
|
6458
|
+
io2
|
|
5298
6459
|
);
|
|
6460
|
+
const webLink = `${baseUrl}/products/${encodeURIComponent(view.product.id)}`;
|
|
5299
6461
|
out.result(
|
|
5300
6462
|
[
|
|
5301
6463
|
...runLines(view),
|
|
5302
6464
|
`\u5E42\u7B49\u952E\uFF1A${idempotencyKey}`,
|
|
5303
|
-
`\u67E5\u8FDB\u5EA6\uFF1Abuke videos status ${view.rootRunId}
|
|
6465
|
+
`\u67E5\u8FDB\u5EA6\uFF1Abuke videos status ${view.rootRunId}`,
|
|
6466
|
+
`\u7F51\u9875\u67E5\u770B\uFF1A${webLink}`
|
|
5304
6467
|
],
|
|
5305
6468
|
// --json 按文档回服务端那份完整的 run 视图。
|
|
5306
|
-
{ run: raw.run, idempotencyKey }
|
|
6469
|
+
{ run: raw.run, idempotencyKey, webLink }
|
|
5307
6470
|
);
|
|
5308
6471
|
}
|
|
5309
6472
|
function latestDirectorLine(messages) {
|
|
5310
6473
|
return [...messages].reverse().find((message2) => message2.role === "assistant" && !message2.earlierAttemptOf && message2.text.trim() !== "");
|
|
5311
6474
|
}
|
|
5312
6475
|
async function status3(context, rawId) {
|
|
5313
|
-
const { io, out, values } = context;
|
|
6476
|
+
const { io: io2, out, values } = context;
|
|
5314
6477
|
const runId = runIdOf(rawId);
|
|
5315
6478
|
const shouldWait = values.wait === true;
|
|
5316
|
-
const controls = shouldWait ? waitControls3(
|
|
6479
|
+
const controls = shouldWait ? waitControls3(io2, values) : void 0;
|
|
5317
6480
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
5318
|
-
const current = await getVideoRun(baseUrl, apiKey, runId,
|
|
5319
|
-
const final = shouldWait ? settleRun(await awaitVideoRun(baseUrl, apiKey, current,
|
|
6481
|
+
const current = await getVideoRun(baseUrl, apiKey, runId, io2);
|
|
6482
|
+
const final = shouldWait ? settleRun(await awaitVideoRun(baseUrl, apiKey, current, io2, controls), baseUrl) : current;
|
|
5320
6483
|
const lastDirectorLine = latestDirectorLine(final.view.messages);
|
|
6484
|
+
const webLink = `${baseUrl}/products/${encodeURIComponent(final.view.product.id)}`;
|
|
5321
6485
|
out.result(
|
|
5322
6486
|
[
|
|
5323
6487
|
...runLines(final.view),
|
|
5324
6488
|
...lastDirectorLine === void 0 ? [] : [`\u5BFC\u6F14\u8BF4\uFF1A${singleLine(lastDirectorLine.text)}`],
|
|
5325
6489
|
...waitingLines(final.view),
|
|
5326
|
-
...final.view.status === "succeeded" ? [`\u4E0B\u8F7D\uFF1Abuke videos download ${final.view.rootRunId}`] : []
|
|
6490
|
+
...final.view.status === "succeeded" ? [`\u4E0B\u8F7D\uFF1Abuke videos download ${final.view.rootRunId}`] : [],
|
|
6491
|
+
`\u7F51\u9875\u67E5\u770B\uFF1A${webLink}`
|
|
6492
|
+
],
|
|
6493
|
+
{ run: final.raw.run, ...shouldWait ? { waited: true } : {}, webLink }
|
|
6494
|
+
);
|
|
6495
|
+
}
|
|
6496
|
+
async function result3(context, rawId) {
|
|
6497
|
+
const { io: io2, out, values } = context;
|
|
6498
|
+
const runId = runIdOf(rawId);
|
|
6499
|
+
const shouldWait = values.wait === true;
|
|
6500
|
+
const controls = shouldWait ? waitControls3(io2, values) : void 0;
|
|
6501
|
+
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
6502
|
+
const current = await getVideoRun(baseUrl, apiKey, runId, io2);
|
|
6503
|
+
const final = settleRun(shouldWait ? await awaitVideoRun(baseUrl, apiKey, current, io2, controls) : { value: current, timedOut: false }, baseUrl);
|
|
6504
|
+
const webLink = `${baseUrl}/products/${encodeURIComponent(final.view.product.id)}`;
|
|
6505
|
+
if (final.view.status !== "succeeded") {
|
|
6506
|
+
const lastDirectorLine = latestDirectorLine(final.view.messages);
|
|
6507
|
+
out.result(
|
|
6508
|
+
[
|
|
6509
|
+
...runLines(final.view),
|
|
6510
|
+
...lastDirectorLine === void 0 ? [] : [`\u5BFC\u6F14\u8BF4\uFF1A${singleLine(lastDirectorLine.text)}`],
|
|
6511
|
+
...waitingLines(final.view),
|
|
6512
|
+
`\u7F51\u9875\u67E5\u770B\uFF1A${webLink}`
|
|
6513
|
+
],
|
|
6514
|
+
{ run: final.raw.run, ...shouldWait ? { waited: true } : {}, webLink }
|
|
6515
|
+
);
|
|
6516
|
+
return;
|
|
6517
|
+
}
|
|
6518
|
+
const media = await downloadVideo(baseUrl, apiKey, runId, io2);
|
|
6519
|
+
const defaultName = media.filename ?? `video-${runId}.mp4`;
|
|
6520
|
+
const saved = await saveDownload(textOption(values, "out") ?? defaultName, media.bytes);
|
|
6521
|
+
out.result(
|
|
6522
|
+
[
|
|
6523
|
+
...runLines(final.view),
|
|
6524
|
+
`\u5DF2\u4E0B\u8F7D\uFF1A${saved.path}`,
|
|
6525
|
+
`\u5927\u5C0F\uFF1A${saved.bytes} \u5B57\u8282`,
|
|
6526
|
+
`\u6821\u9A8C\uFF1Asha256 ${saved.sha256}`,
|
|
6527
|
+
`\u7F51\u9875\u67E5\u770B\uFF1A${webLink}`
|
|
5327
6528
|
],
|
|
5328
|
-
{ run: final.raw.run, ...shouldWait ? { waited: true } : {} }
|
|
6529
|
+
{ run: final.raw.run, download: { ...saved, filename: defaultName }, ...shouldWait ? { waited: true } : {}, webLink }
|
|
5329
6530
|
);
|
|
5330
6531
|
}
|
|
5331
6532
|
async function message(context, rawId) {
|
|
5332
|
-
const { io, out, values } = context;
|
|
6533
|
+
const { io: io2, out, values } = context;
|
|
5333
6534
|
const runId = runIdOf(rawId);
|
|
5334
6535
|
const data = await creativeData(context);
|
|
5335
6536
|
const text = textOption(values, "text") ?? (typeof data.text === "string" ? data.text : void 0);
|
|
@@ -5338,7 +6539,7 @@ async function message(context, rawId) {
|
|
|
5338
6539
|
}
|
|
5339
6540
|
const idempotencyKey = idempotencyKeyOf(values);
|
|
5340
6541
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
5341
|
-
const { view, raw } = await retainMutationOnError("videos", runId, idempotencyKey, baseUrl, async () => runReplyOf(await postJson(baseUrl, apiKey, `/api/open/v1/videos/${encodeURIComponent(runId)}/messages`, { ...data, text }, idempotencyKey,
|
|
6542
|
+
const { view, raw } = await retainMutationOnError("videos", runId, idempotencyKey, baseUrl, async () => runReplyOf(await postJson(baseUrl, apiKey, `/api/open/v1/videos/${encodeURIComponent(runId)}/messages`, { ...data, text }, idempotencyKey, io2)));
|
|
5342
6543
|
const lastDirectorLine = latestDirectorLine(view.messages);
|
|
5343
6544
|
out.result(
|
|
5344
6545
|
[
|
|
@@ -5351,7 +6552,7 @@ async function message(context, rawId) {
|
|
|
5351
6552
|
);
|
|
5352
6553
|
}
|
|
5353
6554
|
async function confirm2(context, rawId) {
|
|
5354
|
-
const { io, out, values } = context;
|
|
6555
|
+
const { io: io2, out, values } = context;
|
|
5355
6556
|
const runId = runIdOf(rawId);
|
|
5356
6557
|
const data = await creativeData(context);
|
|
5357
6558
|
const originalKey = textOption(values, "idempotency-key");
|
|
@@ -5362,10 +6563,11 @@ async function confirm2(context, rawId) {
|
|
|
5362
6563
|
}
|
|
5363
6564
|
if (values.yes !== true) throw usageError("\u6062\u590D\u539F\u786E\u8BA4\u8BF7\u6838\u5BF9\u539F\u8BF7\u6C42\uFF0C\u5E76\u6DFB\u52A0 --yes");
|
|
5364
6565
|
const { apiKey: apiKey2, baseUrl: baseUrl2 } = await resolveApiKey(context);
|
|
5365
|
-
const outcome2 = await confirmVideoProduction(baseUrl2, apiKey2, runId, Number(data.expectedVersion), data.confirmation, originalKey,
|
|
6566
|
+
const outcome2 = await confirmVideoProduction(baseUrl2, apiKey2, runId, Number(data.expectedVersion), data.confirmation, originalKey, io2);
|
|
6567
|
+
const replayLink = `${baseUrl2}/products/${encodeURIComponent(outcome2.view.product.id)}`;
|
|
5366
6568
|
out.result(
|
|
5367
|
-
[...runLines(outcome2.view), "\u5DF2\u91CD\u653E\u539F\u786E\u8BA4\u8BF7\u6C42", ...waitingLines(outcome2.view), `\u5E42\u7B49\u952E\uFF1A${originalKey}`],
|
|
5368
|
-
{ run: outcome2.raw.run, replayedConfirmation: true, idempotencyKey: originalKey }
|
|
6569
|
+
[...runLines(outcome2.view), "\u5DF2\u91CD\u653E\u539F\u786E\u8BA4\u8BF7\u6C42", ...waitingLines(outcome2.view), `\u5E42\u7B49\u952E\uFF1A${originalKey}`, `\u7F51\u9875\u67E5\u770B\uFF1A${replayLink}`],
|
|
6570
|
+
{ run: outcome2.raw.run, replayedConfirmation: true, idempotencyKey: originalKey, webLink: replayLink }
|
|
5369
6571
|
);
|
|
5370
6572
|
return;
|
|
5371
6573
|
}
|
|
@@ -5383,7 +6585,7 @@ async function confirm2(context, rawId) {
|
|
|
5383
6585
|
throw usageError("\u786E\u8BA4\u652F\u51FA\u5FC5\u987B\u63D0\u4F9B\u4E4B\u524D\u67E5\u770B\u7684 --expected-version \u548C --expected-credits\uFF1B\u5148\u4E0D\u5E26 --yes \u67E5\u770B\u5F53\u524D\u786E\u8BA4\u5361");
|
|
5384
6586
|
}
|
|
5385
6587
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
5386
|
-
const fetched = await getVideoRun(baseUrl, apiKey, runId,
|
|
6588
|
+
const fetched = await getVideoRun(baseUrl, apiKey, runId, io2);
|
|
5387
6589
|
const run2 = fetched.view;
|
|
5388
6590
|
const card = run2.nextActions.find((action2) => action2.type === "confirm_production");
|
|
5389
6591
|
if (card === void 0) {
|
|
@@ -5430,18 +6632,19 @@ async function confirm2(context, rawId) {
|
|
|
5430
6632
|
const idempotencyKey = idempotencyKeyOf(values);
|
|
5431
6633
|
let outcome;
|
|
5432
6634
|
try {
|
|
5433
|
-
outcome = await confirmVideoProduction(baseUrl, apiKey, runId, run2.version, card.confirmation, idempotencyKey,
|
|
6635
|
+
outcome = await confirmVideoProduction(baseUrl, apiKey, runId, run2.version, card.confirmation, idempotencyKey, io2);
|
|
5434
6636
|
} catch (error) {
|
|
5435
6637
|
const failure = toCliError(error);
|
|
5436
6638
|
throw failure.withRecovery({ ...taskRecovery("videos", runId, run2.status, baseUrl), ...failure.recovery, acceptance: "confirmed" });
|
|
5437
6639
|
}
|
|
6640
|
+
const webLink = `${baseUrl}/products/${encodeURIComponent(outcome.view.product.id)}`;
|
|
5438
6641
|
out.result(
|
|
5439
|
-
[...runLines(outcome.view), `\u5DF2\u786E\u8BA4\uFF1A\u8FD9\u7B14\u6700\u591A ${credits} \u5E03`, ...waitingLines(outcome.view), `\u5E42\u7B49\u952E\uFF1A${idempotencyKey}`],
|
|
5440
|
-
{ run: outcome.raw.run, confirmed: { credits, confirmKind: card.confirmKind ?? null }, idempotencyKey }
|
|
6642
|
+
[...runLines(outcome.view), `\u5DF2\u786E\u8BA4\uFF1A\u8FD9\u7B14\u6700\u591A ${credits} \u5E03`, ...waitingLines(outcome.view), `\u5E42\u7B49\u952E\uFF1A${idempotencyKey}`, `\u7F51\u9875\u67E5\u770B\uFF1A${webLink}`],
|
|
6643
|
+
{ run: outcome.raw.run, confirmed: { credits, confirmKind: card.confirmKind ?? null }, idempotencyKey, webLink }
|
|
5441
6644
|
);
|
|
5442
6645
|
}
|
|
5443
6646
|
async function download3(context, rawId) {
|
|
5444
|
-
const { io, out, values } = context;
|
|
6647
|
+
const { io: io2, out, values } = context;
|
|
5445
6648
|
const runId = runIdOf(rawId);
|
|
5446
6649
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
5447
6650
|
const musicTask = textOption(values, "music-task-id");
|
|
@@ -5454,7 +6657,7 @@ async function download3(context, rawId) {
|
|
|
5454
6657
|
const index = Number(textOption(values, "track-index"));
|
|
5455
6658
|
if (musicTask && (!Number.isInteger(index) || index < 0 || index > 99)) throw usageError("\u914D\u4E50\u4E0B\u8F7D\u987B\u63D0\u4F9B\u6709\u6548 --track-index");
|
|
5456
6659
|
const suffix = musicTask ? `music/${encodeURIComponent(musicTask)}/tracks/${index}/download` : `edits/${encodeURIComponent(narrationEdit)}/narration/download`;
|
|
5457
|
-
const media = await downloadAssetFile(baseUrl, apiKey, `/api/open/v1/videos/${encodeURIComponent(runId)}/${suffix}`,
|
|
6660
|
+
const media = await downloadAssetFile(baseUrl, apiKey, `/api/open/v1/videos/${encodeURIComponent(runId)}/${suffix}`, io2, { allowedMimeTypes: ["audio/wav", "audio/mpeg"], requireSha256: true });
|
|
5458
6661
|
const saved2 = await saveDownload(textOption(values, "out") ?? media.filename ?? `audio-${runId}.wav`, media.bytes);
|
|
5459
6662
|
out.result([`\u5DF2\u4E0B\u8F7D\uFF1A${saved2.path}`, `\u6821\u9A8C\uFF1Asha256 ${saved2.sha256}`], { download: saved2 });
|
|
5460
6663
|
return;
|
|
@@ -5463,10 +6666,10 @@ async function download3(context, rawId) {
|
|
|
5463
6666
|
const editId = textOption(values, "edit-id");
|
|
5464
6667
|
if (productionId && editId) throw usageError("--production-id \u4E0E --edit-id \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528");
|
|
5465
6668
|
if (productionId || editId) return creativeDownload(context, "videos", runId, editId ? `edits/${encodeURIComponent(editId)}/download` : `download?productionId=${encodeURIComponent(productionId)}`);
|
|
5466
|
-
const
|
|
5467
|
-
const defaultName =
|
|
6669
|
+
const result4 = await downloadVideo(baseUrl, apiKey, runId, io2);
|
|
6670
|
+
const defaultName = result4.filename ?? `video-${runId}.mp4`;
|
|
5468
6671
|
const target = textOption(values, "out") ?? defaultName;
|
|
5469
|
-
const saved = await saveDownload(target,
|
|
6672
|
+
const saved = await saveDownload(target, result4.bytes);
|
|
5470
6673
|
out.result(
|
|
5471
6674
|
[`\u5DF2\u4E0B\u8F7D\uFF1A${saved.path}`, `\u5927\u5C0F\uFF1A${saved.bytes} \u5B57\u8282`, `\u6821\u9A8C\uFF1Asha256 ${saved.sha256}`],
|
|
5472
6675
|
{ download: { ...saved, filename: defaultName } }
|
|
@@ -5476,23 +6679,23 @@ async function manage(context) {
|
|
|
5476
6679
|
const id = runIdOf(context.args[1]);
|
|
5477
6680
|
const { baseUrl, apiKey } = await resolveApiKey(context);
|
|
5478
6681
|
if (context.args[0] === "versions") {
|
|
5479
|
-
const
|
|
5480
|
-
context.out.result([JSON.stringify(
|
|
6682
|
+
const result5 = await getCreative(baseUrl, apiKey, "videos", id, "versions", context.io);
|
|
6683
|
+
context.out.result([JSON.stringify(result5, null, 2)], result5);
|
|
5481
6684
|
return;
|
|
5482
6685
|
}
|
|
5483
6686
|
const key = idempotencyKeyOf(context.values);
|
|
5484
|
-
const
|
|
5485
|
-
context.out.result(["\u53D6\u6D88\u8BF7\u6C42\u5DF2\u5904\u7406", `\u5E42\u7B49\u952E\uFF1A${key}`], { ...
|
|
6687
|
+
const result4 = await postCreative(baseUrl, apiKey, "videos", id, "cancel", {}, key, context.io);
|
|
6688
|
+
context.out.result(["\u53D6\u6D88\u8BF7\u6C42\u5DF2\u5904\u7406", `\u5E42\u7B49\u952E\uFF1A${key}`], { ...result4, idempotencyKey: key });
|
|
5486
6689
|
}
|
|
5487
6690
|
|
|
5488
6691
|
// src/commands/whoami.ts
|
|
5489
6692
|
async function whoami(context) {
|
|
5490
|
-
const { io, out } = context;
|
|
6693
|
+
const { io: io2, out } = context;
|
|
5491
6694
|
const resolved = await resolveApiKey(context);
|
|
5492
6695
|
const { apiKey, baseUrl } = resolved;
|
|
5493
6696
|
let me;
|
|
5494
6697
|
try {
|
|
5495
|
-
me = await getMe(baseUrl, apiKey,
|
|
6698
|
+
me = await getMe(baseUrl, apiKey, io2);
|
|
5496
6699
|
} catch (error) {
|
|
5497
6700
|
if (error instanceof CliError && error.httpStatus === 401) {
|
|
5498
6701
|
throw error.withHint(
|
|
@@ -5510,6 +6713,62 @@ async function whoami(context) {
|
|
|
5510
6713
|
);
|
|
5511
6714
|
}
|
|
5512
6715
|
|
|
6716
|
+
// src/skill-install.ts
|
|
6717
|
+
import { chmod as chmod3, mkdir as mkdir4, readFile as readFile4, writeFile as writeFile2 } from "node:fs/promises";
|
|
6718
|
+
import { join as join5 } from "node:path";
|
|
6719
|
+
var SOURCE_URL = new URL("../skills/buke/SKILL.md", import.meta.url);
|
|
6720
|
+
var TARGET_DIR = join5(".agents", "skills", "buke");
|
|
6721
|
+
var DIR_MODE = 493;
|
|
6722
|
+
var FILE_MODE = 420;
|
|
6723
|
+
async function defaultReadSkillSource() {
|
|
6724
|
+
try {
|
|
6725
|
+
const content = await readFile4(SOURCE_URL, "utf8");
|
|
6726
|
+
return content.trim() === "" ? null : content;
|
|
6727
|
+
} catch {
|
|
6728
|
+
return null;
|
|
6729
|
+
}
|
|
6730
|
+
}
|
|
6731
|
+
async function installBukeSkill(io2) {
|
|
6732
|
+
const targetPath = join5(io2.homedir(), TARGET_DIR, "SKILL.md");
|
|
6733
|
+
try {
|
|
6734
|
+
const content = await (io2.readSkillSource ?? defaultReadSkillSource)();
|
|
6735
|
+
if (content === null) return { status: "skipped", reason: "\u5305\u5185\u6CA1\u6709 skills/buke/SKILL.md" };
|
|
6736
|
+
const targetDir = join5(io2.homedir(), TARGET_DIR);
|
|
6737
|
+
await mkdir4(targetDir, { recursive: true, mode: DIR_MODE });
|
|
6738
|
+
await writeFile2(targetPath, content, { mode: FILE_MODE });
|
|
6739
|
+
await chmod3(targetDir, DIR_MODE);
|
|
6740
|
+
await chmod3(targetPath, FILE_MODE);
|
|
6741
|
+
return { status: "installed", path: targetPath };
|
|
6742
|
+
} catch (error) {
|
|
6743
|
+
return { status: "failed", reason: error instanceof Error ? error.message : String(error) };
|
|
6744
|
+
}
|
|
6745
|
+
}
|
|
6746
|
+
|
|
6747
|
+
// src/update.ts
|
|
6748
|
+
var MANUAL_COMMAND = "npm install -g bukesiyi-cli@latest";
|
|
6749
|
+
async function runUpdate({ io: io2, out }) {
|
|
6750
|
+
if (io2.spawn === void 0) {
|
|
6751
|
+
throw new CliError({
|
|
6752
|
+
code: "CLI_UPDATE_FAILED",
|
|
6753
|
+
exitCode: EXIT.SERVER,
|
|
6754
|
+
message: `\u5F53\u524D\u8FD0\u884C\u73AF\u5883\u4E0D\u652F\u6301\u81EA\u52A8\u66F4\u65B0\uFF0C\u8BF7\u624B\u52A8\u8FD0\u884C ${MANUAL_COMMAND}`
|
|
6755
|
+
});
|
|
6756
|
+
}
|
|
6757
|
+
out.notice(`\u5F53\u524D\u7248\u672C ${VERSION}\uFF1B\u6B63\u5728\u901A\u8FC7 npm \u5168\u5C40\u66F4\u65B0 bukesiyi-cli\u2026`);
|
|
6758
|
+
const { code: code2 } = await io2.spawn("npm", ["install", "-g", "bukesiyi-cli@latest"]);
|
|
6759
|
+
if (code2 !== 0) {
|
|
6760
|
+
throw new CliError({
|
|
6761
|
+
code: "CLI_UPDATE_FAILED",
|
|
6762
|
+
exitCode: EXIT.SERVER,
|
|
6763
|
+
message: `npm \u66F4\u65B0\u6CA1\u6709\u6210\u529F\uFF08\u9000\u51FA\u7801 ${code2}\uFF09\u3002\u8BF7\u624B\u52A8\u8FD0\u884C ${MANUAL_COMMAND}`
|
|
6764
|
+
});
|
|
6765
|
+
}
|
|
6766
|
+
out.result(["\u66F4\u65B0\u5B8C\u6210\uFF1B\u91CD\u65B0\u8FD0\u884C buke --version \u786E\u8BA4"], { updated: true, from: VERSION });
|
|
6767
|
+
const skill = await installBukeSkill(io2);
|
|
6768
|
+
if (skill.status === "installed") out.notice(`\u5DF2\u5B89\u88C5 buke \u4F7F\u7528\u6280\u80FD\u5230 ${skill.path}`);
|
|
6769
|
+
if (skill.status === "failed") out.notice(`buke \u4F7F\u7528\u6280\u80FD\u6CA1\u88C5\u4E0A\uFF08\u4E0D\u5F71\u54CD\u66F4\u65B0\u672C\u8EAB\uFF09\uFF1A${skill.reason}`);
|
|
6770
|
+
}
|
|
6771
|
+
|
|
5513
6772
|
// src/cli.ts
|
|
5514
6773
|
var KEY_HOWTO = [
|
|
5515
6774
|
"\u5BC6\u94A5\u600E\u4E48\u7ED9\uFF08\u4E0D\u8981\u5199\u5728\u547D\u4EE4\u884C\u91CC\uFF09\uFF0C\u6309\u987A\u5E8F\u53D6\u7B2C\u4E00\u79CD\uFF1A",
|
|
@@ -5660,6 +6919,7 @@ var COMMANDS = {
|
|
|
5660
6919
|
" buke shorts upload <\u56FE\u7247\u6587\u4EF6>",
|
|
5661
6920
|
" buke shorts quote --template <\u6A21\u677Fid> --props <props.json|->",
|
|
5662
6921
|
" buke shorts order --template <\u6A21\u677Fid> --props <props.json|-> [--quote-hash <hash>] [--wait] [--timeout <\u79D2>]",
|
|
6922
|
+
" buke shorts result <\u8BA2\u5355id> [--wait] [--timeout <\u79D2>] [--out <\u8DEF\u5F84>]",
|
|
5663
6923
|
" buke shorts status <\u8BA2\u5355id> [--wait] [--timeout <\u79D2>]",
|
|
5664
6924
|
" buke shorts download <\u8BA2\u5355id> [--out <\u8DEF\u5F84>]",
|
|
5665
6925
|
" buke shorts cancel <\u8BA2\u5355id>",
|
|
@@ -5669,6 +6929,7 @@ var COMMANDS = {
|
|
|
5669
6929
|
" upload \u6258\u7BA1\u4E00\u5F20\u7D20\u6750\u56FE\uFF0C\u6362\u56DE\u53EF\u4EE5\u76F4\u63A5\u586B\u8FDB\u6A21\u677F\u56FE\u7247\u69FD\u7684\u5730\u5740",
|
|
5670
6930
|
" quote \u53EA\u8BFB\u62A5\u4EF7\uFF1B\u6536\u8D39\u7684\u6A21\u677F\u4E0B\u5355\u524D\u5FC5\u987B\u5148\u62FF quoteHash",
|
|
5671
6931
|
" order \u4E0B\u5355\uFF1B\u540C\u952E\u540C\u5185\u5BB9\u91CD\u8BD5\u56DE\u540C\u4E00\u5F20\u5355",
|
|
6932
|
+
" result \u4E00\u952E\u53D6\u4EF6\uFF1A\u67E5\u8FDB\u5EA6\uFF08--wait \u7B49\u7EC8\u6001\uFF09\uFF0C\u6210\u529F\u5C31\u76F4\u63A5\u843D\u76D8",
|
|
5672
6933
|
" status \u67E5\u8FDB\u5EA6\uFF1B--wait \u4E00\u76F4\u7B49\u5230\u51FA\u7ED3\u679C",
|
|
5673
6934
|
" download \u4E0B\u8F7D\u6E32\u67D3\u597D\u7684\u6210\u7247\uFF08mp4\uFF09",
|
|
5674
6935
|
" cancel \u53D6\u6D88\u8FD8\u6CA1\u5F00\u59CB\u7684\u8BA2\u5355",
|
|
@@ -5740,6 +7001,7 @@ var COMMANDS = {
|
|
|
5740
7001
|
" buke videos attachments <\u4EFB\u52A1id> [--attachment-ids <\u7F16\u53F7,\u7F16\u53F7>] [--offset <\u504F\u79FB>]",
|
|
5741
7002
|
" buke videos attachment-download <\u4EFB\u52A1id> --attachment-id <\u9644\u4EF6\u7F16\u53F7> [--out <\u8DEF\u5F84>]",
|
|
5742
7003
|
" buke videos status <\u89C6\u9891id> [--wait] [--timeout <\u79D2>]",
|
|
7004
|
+
" buke videos result <\u89C6\u9891id> [--wait] [--timeout <\u79D2>] [--out <\u8DEF\u5F84>]",
|
|
5743
7005
|
" buke videos message <\u89C6\u9891id> --text <\u5185\u5BB9> [--data <JSON\u6587\u4EF6|->]",
|
|
5744
7006
|
" buke videos versions <\u89C6\u9891id>",
|
|
5745
7007
|
" buke videos music-list <\u89C6\u9891id>",
|
|
@@ -5758,6 +7020,7 @@ var COMMANDS = {
|
|
|
5758
7020
|
"\u5546\u54C1\u89C6\u9891\u521B\u4F5C\u4E0E\u4EA4\u4ED8\uFF1A",
|
|
5759
7021
|
" create \u521B\u5EFA\u4EFB\u52A1\uFF1B\u987B\u5148\u5EFA\u7ACB\u4EA7\u54C1\u3002\u53D7\u7406\u540E\u901A\u8FC7 status \u67E5\u8BE2\u8FDB\u5EA6",
|
|
5760
7022
|
" status \u67E5\u8BE2\u8FDB\u5EA6\uFF1B--wait \u7B49\u5F85\u7EC8\u6001\u6216\u9700\u8981\u7528\u6237\u5904\u7406\u7684\u72B6\u6001",
|
|
7023
|
+
" result \u4E00\u952E\u53D6\u4EF6\uFF1A\u67E5\u8FDB\u5EA6\uFF08--wait \u7B49\u7EC8\u6001\uFF09\uFF0C\u6210\u529F\u5C31\u76F4\u63A5\u843D\u76D8",
|
|
5761
7024
|
" message \u63D0\u4EA4\u5236\u4F5C\u8981\u6C42\u3001\u95EE\u9898\u56DE\u590D\u3001\u9644\u4EF6\u6216\u7ED3\u6784\u5316\u9009\u9879",
|
|
5762
7025
|
" confirm \u5BF9\u7167\u5DF2\u67E5\u770B\u7684\u7248\u672C\u548C\u91D1\u989D\uFF0C\u63D0\u4EA4\u540C\u4E00\u786E\u8BA4\u5361\uFF1B\u53D8\u5316\u65F6\u4E0D\u63D0\u4EA4",
|
|
5763
7026
|
" download \u4E0B\u8F7D\u6210\u7247\uFF08mp4\uFF09",
|
|
@@ -5801,6 +7064,7 @@ var COMMANDS = {
|
|
|
5801
7064
|
" buke drama attachments <\u4EFB\u52A1id> [--attachment-ids <\u7F16\u53F7,\u7F16\u53F7>] [--offset <\u504F\u79FB>]",
|
|
5802
7065
|
" buke drama attachment-download <\u4EFB\u52A1id> --attachment-id <\u9644\u4EF6\u7F16\u53F7> [--out <\u8DEF\u5F84>]",
|
|
5803
7066
|
" buke drama status <\u8BA2\u5355id> [--wait] [--timeout <\u79D2>]",
|
|
7067
|
+
" buke drama result <\u8BA2\u5355id> [--wait] [--timeout <\u79D2>] [--out <\u8DEF\u5F84>]",
|
|
5804
7068
|
" buke drama quote <\u8BA2\u5355id>",
|
|
5805
7069
|
" buke drama confirm <\u8BA2\u5355id> --quote-hash <\u62A5\u4EF7\u54C8\u5E0C> [--yes]",
|
|
5806
7070
|
" buke drama cancel <\u8BA2\u5355id>",
|
|
@@ -5809,6 +7073,7 @@ var COMMANDS = {
|
|
|
5809
7073
|
"\u77ED\u5267\u521B\u4F5C\u4E0E\u4EA4\u4ED8\uFF1A\u51C6\u5907\u5267\u672C\u3001\u4EBA\u7269\u573A\u666F\u548C\u5206\u955C\u540E\u63D0\u4F9B\u62A5\u4EF7\uFF1B\u5236\u4F5C\u3001\u91CD\u62CD\u53CA\u540E\u671F\u8D39\u7528\u987B\u660E\u786E\u786E\u8BA4\u3002",
|
|
5810
7074
|
" create \u521B\u5EFA\u4EFB\u52A1\uFF1B\u987B\u5148\u5EFA\u7ACB\u4EA7\u54C1\u3002\u53D7\u7406\u540E\u901A\u8FC7 status \u67E5\u8BE2\u8FDB\u5EA6",
|
|
5811
7075
|
" status \u67E5\u8BE2\u8FDB\u5EA6\u5E76\u63A8\u8FDB\u6587\u672C\u51C6\u5907\uFF1B--wait \u5728\u7EC8\u6001\u6216\u9700\u8981\u5904\u7406\u65F6\u8FD4\u56DE",
|
|
7076
|
+
" result \u4E00\u952E\u53D6\u4EF6\uFF1A\u67E5\u8FDB\u5EA6\uFF08--wait \u7B49\u7EC8\u6001\uFF09\uFF0C\u53EF\u4EA4\u4ED8\u5C31\u76F4\u63A5\u843D\u76D8",
|
|
5812
7077
|
" quote \u53EA\u8BFB\u62A5\u4EF7\uFF1A\u62A5\u4EF7\u8981\u7D20\u4E0E\u62A5\u4EF7\u54C8\u5E0C\uFF0C\u786E\u8BA4\u5F00\u62CD\u65F6\u539F\u6837\u5E26\u56DE",
|
|
5813
7078
|
" confirm \u786E\u8BA4\u5F53\u524D\u62A5\u4EF7\uFF1B\u6307\u5B9A --yes \u540E\u624D\u63D0\u4EA4\u5236\u4F5C\u6388\u6743",
|
|
5814
7079
|
" cancel \u53D6\u6D88\u672A\u5F00\u59CB\u7684\u5236\u4F5C\uFF1B\u91CA\u653E\u672A\u4F7F\u7528\u9884\u7559\uFF0C\u4FDD\u7559\u5DF2\u5B8C\u6210\u7247\u6BB5\u53CA\u5B9E\u9645\u8D39\u7528",
|
|
@@ -5830,6 +7095,20 @@ var COMMANDS = {
|
|
|
5830
7095
|
" --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF1B\u7701\u7565\u65F6\u4F7F\u7528\u767B\u5F55\u65F6\u7684\u5730\u5740",
|
|
5831
7096
|
" --json \u6807\u51C6\u8F93\u51FA\u4EC5\u8FD4\u56DE\u4E00\u4E2A JSON \u6587\u6863\uFF0C\u4F9B\u811A\u672C\u89E3\u6790"
|
|
5832
7097
|
].join("\n")
|
|
7098
|
+
},
|
|
7099
|
+
update: {
|
|
7100
|
+
run: runUpdate,
|
|
7101
|
+
acceptsBaseUrl: false,
|
|
7102
|
+
options: [],
|
|
7103
|
+
positionals: [],
|
|
7104
|
+
help: [
|
|
7105
|
+
"\u7528\u6CD5\uFF1Abuke update [--json]",
|
|
7106
|
+
"",
|
|
7107
|
+
"\u66F4\u65B0 buke \u81EA\u8EAB\uFF08npm \u5168\u5C40\u5B89\u88C5\uFF09\uFF1A\u8FD0\u884C npm install -g bukesiyi-cli@latest\uFF1B\u5B8C\u6210\u540E\u91CD\u65B0\u8FD0\u884C buke --version \u786E\u8BA4\u3002",
|
|
7108
|
+
"",
|
|
7109
|
+
"\u9009\u9879\uFF1A",
|
|
7110
|
+
" --json \u6807\u51C6\u8F93\u51FA\u4EC5\u8FD4\u56DE\u4E00\u4E2A JSON \u6587\u6863\uFF0C\u4F9B\u811A\u672C\u89E3\u6790"
|
|
7111
|
+
].join("\n")
|
|
5833
7112
|
}
|
|
5834
7113
|
};
|
|
5835
7114
|
for (const resource of ["videos", "drama", "graphic", "series"]) {
|
|
@@ -5867,6 +7146,7 @@ var GENERAL_HELP = [
|
|
|
5867
7146
|
"\u9009\u9879\uFF1A",
|
|
5868
7147
|
` --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF0C\u9ED8\u8BA4 ${DEFAULT_BASE_URL}\uFF1B\u53EA\u5199\u5230\u57DF\u540D\u4E3A\u6B62`,
|
|
5869
7148
|
" --json \u6807\u51C6\u8F93\u51FA\u4EC5\u8FD4\u56DE\u4E00\u4E2A JSON \u6587\u6863\uFF0C\u4F9B\u811A\u672C\u89E3\u6790",
|
|
7149
|
+
" --text \u6807\u51C6\u8F93\u51FA\u6309\u4EBA\u8BFB\u7684\u6587\u672C\u8FD4\u56DE\uFF1B\u4E0D\u7ED9\u65D7\u6807\u65F6\uFF0C\u63A5\u7BA1\u9053\u8F93\u51FA\u4F1A\u81EA\u52A8\u6309 JSON \u7ED9",
|
|
5870
7150
|
" -h, --help \u663E\u793A\u8BF4\u660E",
|
|
5871
7151
|
" -v, --version \u663E\u793A\u7248\u672C\u53F7",
|
|
5872
7152
|
"",
|
|
@@ -5897,7 +7177,7 @@ var MAX_ECHO_LENGTH = 40;
|
|
|
5897
7177
|
function echo(item) {
|
|
5898
7178
|
return item.length > MAX_ECHO_LENGTH ? `${item.slice(0, MAX_ECHO_LENGTH)}\u2026` : item;
|
|
5899
7179
|
}
|
|
5900
|
-
var GLOBAL_OPTIONS = /* @__PURE__ */ new Set(["help", "version", "json", "base-url"]);
|
|
7180
|
+
var GLOBAL_OPTIONS = /* @__PURE__ */ new Set(["help", "version", "json", "output-text", "base-url"]);
|
|
5901
7181
|
var STRING_OPTIONS = /* @__PURE__ */ new Set([
|
|
5902
7182
|
"base-url",
|
|
5903
7183
|
"idempotency-key",
|
|
@@ -5927,7 +7207,7 @@ var STRING_OPTIONS = /* @__PURE__ */ new Set([
|
|
|
5927
7207
|
"genre",
|
|
5928
7208
|
"brief"
|
|
5929
7209
|
]);
|
|
5930
|
-
var BOOLEAN_OPTIONS = /* @__PURE__ */ new Set(["help", "version", "json", "wait", "yes", "all"]);
|
|
7210
|
+
var BOOLEAN_OPTIONS = /* @__PURE__ */ new Set(["help", "version", "json", "output-text", "wait", "yes", "all"]);
|
|
5931
7211
|
for (const command of Object.values(COMMANDS)) for (const option of command.options) {
|
|
5932
7212
|
if (!BOOLEAN_OPTIONS.has(option)) STRING_OPTIONS.add(option);
|
|
5933
7213
|
}
|
|
@@ -5966,7 +7246,7 @@ function usageFromParseError(error) {
|
|
|
5966
7246
|
}
|
|
5967
7247
|
return usageError("\u53C2\u6570\u7684\u5199\u6CD5\u4E0D\u5BF9");
|
|
5968
7248
|
}
|
|
5969
|
-
async function dispatch(argv,
|
|
7249
|
+
async function dispatch(argv, io2, out) {
|
|
5970
7250
|
if (argvContainsKey(argv)) {
|
|
5971
7251
|
throw new CliError({
|
|
5972
7252
|
code: "CLI_KEY_IN_ARGV",
|
|
@@ -6002,13 +7282,38 @@ async function dispatch(argv, io, out) {
|
|
|
6002
7282
|
out.result([`${PACKAGE_NAME}/${VERSION}`], { name: PACKAGE_NAME, version: VERSION });
|
|
6003
7283
|
return;
|
|
6004
7284
|
}
|
|
6005
|
-
if (command) await command.run({ io, out, baseUrl: parsed.baseUrl, args, values: parsed.values });
|
|
7285
|
+
if (command) await command.run({ io: io2, out, baseUrl: parsed.baseUrl, args, values: parsed.values });
|
|
7286
|
+
}
|
|
7287
|
+
function expandTextFlag(argv) {
|
|
7288
|
+
const expanded = [];
|
|
7289
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
7290
|
+
const token = argv[index];
|
|
7291
|
+
if (token === "--text") {
|
|
7292
|
+
const next = argv[index + 1];
|
|
7293
|
+
if (next === void 0 || next.startsWith("-")) {
|
|
7294
|
+
expanded.push("--output-text");
|
|
7295
|
+
continue;
|
|
7296
|
+
}
|
|
7297
|
+
expanded.push(`--text=${next}`);
|
|
7298
|
+
index += 1;
|
|
7299
|
+
continue;
|
|
7300
|
+
}
|
|
7301
|
+
expanded.push(token);
|
|
7302
|
+
}
|
|
7303
|
+
return expanded;
|
|
6006
7304
|
}
|
|
6007
|
-
async function run(argv,
|
|
7305
|
+
async function run(argv, io2) {
|
|
6008
7306
|
let out;
|
|
6009
7307
|
try {
|
|
6010
|
-
|
|
6011
|
-
|
|
7308
|
+
const expanded = expandTextFlag(argv);
|
|
7309
|
+
const wantsJson = expanded.includes("--json");
|
|
7310
|
+
const wantsText = expanded.includes("--output-text");
|
|
7311
|
+
if (wantsJson && wantsText) {
|
|
7312
|
+
out = createOutput(io2, true);
|
|
7313
|
+
throw usageError("--json \u4E0E --text \u53EA\u80FD\u7ED9\u4E00\u4E2A");
|
|
7314
|
+
}
|
|
7315
|
+
out = createOutput(io2, wantsJson || io2.stdoutIsTTY === false && !wantsText);
|
|
7316
|
+
await dispatch(expanded, io2, out);
|
|
6012
7317
|
return EXIT.OK;
|
|
6013
7318
|
} catch (error) {
|
|
6014
7319
|
const failure = toCliError(error);
|
|
@@ -6020,6 +7325,99 @@ async function run(argv, io) {
|
|
|
6020
7325
|
}
|
|
6021
7326
|
}
|
|
6022
7327
|
|
|
7328
|
+
// src/update-check.ts
|
|
7329
|
+
import { chmod as chmod4, mkdir as mkdir5, readFile as readFile5, writeFile as writeFile3 } from "node:fs/promises";
|
|
7330
|
+
import { dirname as dirname4, join as join6 } from "node:path";
|
|
7331
|
+
var CHECK_URL = "https://registry.npmjs.org/bukesiyi-cli/latest";
|
|
7332
|
+
var CACHE_FILE = "update-check.json";
|
|
7333
|
+
var FRESH_MS = 24 * 60 * 60 * 1e3;
|
|
7334
|
+
var FAILED_FRESH_MS = 60 * 60 * 1e3;
|
|
7335
|
+
var FETCH_TIMEOUT_MS = 2e3;
|
|
7336
|
+
var OWNER_ONLY_DIR2 = 448;
|
|
7337
|
+
var OWNER_ONLY_FILE2 = 384;
|
|
7338
|
+
async function readCache(path) {
|
|
7339
|
+
try {
|
|
7340
|
+
const value = JSON.parse(await readFile5(path, "utf8"));
|
|
7341
|
+
if (typeof value !== "object" || value === null) return null;
|
|
7342
|
+
const checkedAt = value.checkedAt;
|
|
7343
|
+
const latest = value.latest;
|
|
7344
|
+
if (typeof checkedAt !== "string") return null;
|
|
7345
|
+
if (latest !== null && typeof latest !== "string") return null;
|
|
7346
|
+
return { checkedAt, latest: typeof latest === "string" ? latest : null };
|
|
7347
|
+
} catch {
|
|
7348
|
+
return null;
|
|
7349
|
+
}
|
|
7350
|
+
}
|
|
7351
|
+
async function writeCache(path, cache) {
|
|
7352
|
+
await mkdir5(dirname4(path), { recursive: true, mode: OWNER_ONLY_DIR2 });
|
|
7353
|
+
await writeFile3(path, `${JSON.stringify(cache, null, 2)}
|
|
7354
|
+
`, { mode: OWNER_ONLY_FILE2 });
|
|
7355
|
+
await chmod4(path, OWNER_ONLY_FILE2);
|
|
7356
|
+
}
|
|
7357
|
+
function parseSegments(version2) {
|
|
7358
|
+
if (version2.trim() === "") return null;
|
|
7359
|
+
const segments = [];
|
|
7360
|
+
for (const part of version2.split(".")) {
|
|
7361
|
+
if (!/^\d+$/.test(part)) return null;
|
|
7362
|
+
segments.push(Number.parseInt(part, 10));
|
|
7363
|
+
}
|
|
7364
|
+
return segments;
|
|
7365
|
+
}
|
|
7366
|
+
function newer(latest, current) {
|
|
7367
|
+
const left = parseSegments(latest);
|
|
7368
|
+
const right = parseSegments(current);
|
|
7369
|
+
if (left === null || right === null) return false;
|
|
7370
|
+
const length = Math.max(left.length, right.length);
|
|
7371
|
+
for (let index = 0; index < length; index += 1) {
|
|
7372
|
+
const a = left[index] ?? 0;
|
|
7373
|
+
const b = right[index] ?? 0;
|
|
7374
|
+
if (a !== b) return a > b;
|
|
7375
|
+
}
|
|
7376
|
+
return false;
|
|
7377
|
+
}
|
|
7378
|
+
async function fetchLatest(io2, currentVersion) {
|
|
7379
|
+
const controller = new AbortController();
|
|
7380
|
+
const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
7381
|
+
try {
|
|
7382
|
+
const response = await io2.fetch(CHECK_URL, {
|
|
7383
|
+
headers: { Accept: "application/json", "User-Agent": `bukesiyi-cli/${currentVersion}` },
|
|
7384
|
+
redirect: "manual",
|
|
7385
|
+
signal: controller.signal
|
|
7386
|
+
});
|
|
7387
|
+
if (!response.ok) return null;
|
|
7388
|
+
const document = await response.json();
|
|
7389
|
+
const version2 = typeof document === "object" && document !== null && "version" in document ? document.version : void 0;
|
|
7390
|
+
return typeof version2 === "string" && version2.trim() !== "" ? version2 : null;
|
|
7391
|
+
} catch {
|
|
7392
|
+
return null;
|
|
7393
|
+
} finally {
|
|
7394
|
+
clearTimeout(timer);
|
|
7395
|
+
}
|
|
7396
|
+
}
|
|
7397
|
+
async function runUpdateCheck(io2, currentVersion) {
|
|
7398
|
+
try {
|
|
7399
|
+
if (io2.env.BUKE_DISABLE_UPDATE_CHECK !== void 0 && io2.env.BUKE_DISABLE_UPDATE_CHECK !== "") return;
|
|
7400
|
+
const now = io2.now?.() ?? /* @__PURE__ */ new Date();
|
|
7401
|
+
const path = join6(credentialsDir(io2), CACHE_FILE);
|
|
7402
|
+
const cache = await readCache(path);
|
|
7403
|
+
const checkedAt = cache === null ? NaN : Date.parse(cache.checkedAt);
|
|
7404
|
+
if (cache !== null && Number.isFinite(checkedAt)) {
|
|
7405
|
+
const age = now.getTime() - checkedAt;
|
|
7406
|
+
if (cache.latest !== null && age < FRESH_MS) return;
|
|
7407
|
+
if (cache.latest === null && age < FAILED_FRESH_MS) return;
|
|
7408
|
+
}
|
|
7409
|
+
const latest = await fetchLatest(io2, currentVersion);
|
|
7410
|
+
await writeCache(path, { checkedAt: now.toISOString(), latest });
|
|
7411
|
+
if (latest !== null && newer(latest, currentVersion)) {
|
|
7412
|
+
io2.stderr.write(
|
|
7413
|
+
`\u63D0\u793A\uFF1Abuke \u6709\u65B0\u7248\u672C ${latest}\uFF08\u5F53\u524D ${currentVersion}\uFF09\uFF1B\u8FD0\u884C buke update \u5347\u7EA7\uFF1B\u4E0D\u60F3\u770B\u5230\u63D0\u793A\u53EF\u8BBE BUKE_DISABLE_UPDATE_CHECK=1
|
|
7414
|
+
`
|
|
7415
|
+
);
|
|
7416
|
+
}
|
|
7417
|
+
} catch {
|
|
7418
|
+
}
|
|
7419
|
+
}
|
|
7420
|
+
|
|
6023
7421
|
// src/main.ts
|
|
6024
7422
|
var SIGNAL_NUMBERS = { SIGHUP: 1, SIGINT: 2, SIGTERM: 15 };
|
|
6025
7423
|
var outputLost = false;
|
|
@@ -6041,7 +7439,61 @@ for (const name2 of Object.keys(SIGNAL_NUMBERS)) {
|
|
|
6041
7439
|
});
|
|
6042
7440
|
}
|
|
6043
7441
|
var env = process.execArgv.includes("--use-env-proxy") ? { ...process.env, NODE_USE_ENV_PROXY: "1" } : process.env;
|
|
6044
|
-
|
|
7442
|
+
function runCommand(command, args) {
|
|
7443
|
+
return new Promise((resolve3) => {
|
|
7444
|
+
let child;
|
|
7445
|
+
try {
|
|
7446
|
+
child = spawn(command, args, { stdio: "inherit", ...process.platform === "win32" ? { shell: true } : {} });
|
|
7447
|
+
} catch {
|
|
7448
|
+
resolve3({ code: -1 });
|
|
7449
|
+
return;
|
|
7450
|
+
}
|
|
7451
|
+
child.on("error", () => resolve3({ code: -1 }));
|
|
7452
|
+
child.on("close", (code2) => resolve3({ code: code2 ?? -1 }));
|
|
7453
|
+
});
|
|
7454
|
+
}
|
|
7455
|
+
function runCommandCapture(command, args, options) {
|
|
7456
|
+
return new Promise((resolve3) => {
|
|
7457
|
+
let settled = false;
|
|
7458
|
+
let child;
|
|
7459
|
+
const timerRef = { current: void 0 };
|
|
7460
|
+
const finish = (outcome) => {
|
|
7461
|
+
if (settled) return;
|
|
7462
|
+
settled = true;
|
|
7463
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
7464
|
+
resolve3({ code: outcome.code, stdout, stderr, timedOut: outcome.timedOut });
|
|
7465
|
+
};
|
|
7466
|
+
let stdout = "";
|
|
7467
|
+
let stderr = "";
|
|
7468
|
+
try {
|
|
7469
|
+
child = spawn(command, args, {
|
|
7470
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
7471
|
+
...process.platform === "win32" ? { shell: true } : {}
|
|
7472
|
+
});
|
|
7473
|
+
} catch {
|
|
7474
|
+
finish({ code: -1, timedOut: false });
|
|
7475
|
+
return;
|
|
7476
|
+
}
|
|
7477
|
+
const gather = (stream, into) => {
|
|
7478
|
+
if (!stream) return;
|
|
7479
|
+
stream.setEncoding("utf8");
|
|
7480
|
+
stream.on("data", (chunk) => into(chunk));
|
|
7481
|
+
};
|
|
7482
|
+
gather(child.stdout, (chunk) => {
|
|
7483
|
+
stdout += chunk;
|
|
7484
|
+
});
|
|
7485
|
+
gather(child.stderr, (chunk) => {
|
|
7486
|
+
stderr += chunk;
|
|
7487
|
+
});
|
|
7488
|
+
timerRef.current = setTimeout(() => {
|
|
7489
|
+
child.kill("SIGKILL");
|
|
7490
|
+
finish({ code: -1, timedOut: true });
|
|
7491
|
+
}, options.timeoutMs);
|
|
7492
|
+
child.on("error", () => finish({ code: -1, timedOut: false }));
|
|
7493
|
+
child.on("close", (code2) => finish({ code: code2 ?? -1, timedOut: false }));
|
|
7494
|
+
});
|
|
7495
|
+
}
|
|
7496
|
+
var io = {
|
|
6045
7497
|
env,
|
|
6046
7498
|
stdin: process.stdin,
|
|
6047
7499
|
stdout: process.stdout,
|
|
@@ -6049,8 +7501,16 @@ var code = await run(process.argv.slice(2), {
|
|
|
6049
7501
|
fetch: globalThis.fetch,
|
|
6050
7502
|
homedir,
|
|
6051
7503
|
platform: process.platform,
|
|
6052
|
-
|
|
6053
|
-
|
|
7504
|
+
// 输出接的是不是终端:接管道时命令层会自动改按 JSON 出(显式 --text/--json 永远赢)。
|
|
7505
|
+
// 真进程里 isTTY 只有「是终端 true」和「不是 undefined」两种(Node 对管道不给 false),这里折成
|
|
7506
|
+
// 干净的布尔:命令层只在确切看到 false(=真管道)时自动 JSON,注入的 io 不带这个字段就保持文本。
|
|
7507
|
+
stdoutIsTTY: process.stdout.isTTY === true,
|
|
7508
|
+
signal: interrupt.signal,
|
|
7509
|
+
spawn: runCommand,
|
|
7510
|
+
spawnCapture: runCommandCapture
|
|
7511
|
+
};
|
|
7512
|
+
await runUpdateCheck(io, VERSION);
|
|
7513
|
+
var code = await run(process.argv.slice(2), io);
|
|
6054
7514
|
function finalCode() {
|
|
6055
7515
|
if (received !== void 0 && code === EXIT.INTERRUPTED) return 128 + SIGNAL_NUMBERS[received];
|
|
6056
7516
|
return code === EXIT.OK && outputLost ? EXIT.SERVER : code;
|