bukesiyi-cli 0.3.3 → 0.5.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 +85 -11
- package/dist/main.js +3091 -287
- package/package.json +3 -3
package/dist/main.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
// src/main.ts
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
|
|
4
|
-
// src/
|
|
5
|
-
import {
|
|
4
|
+
// src/commands/graphic.ts
|
|
5
|
+
import { readFile as readFile2, mkdir as mkdir2 } from "node:fs/promises";
|
|
6
|
+
import { basename, join as join2, resolve } from "node:path";
|
|
7
|
+
|
|
8
|
+
// src/client.ts
|
|
9
|
+
import { createHash } from "node:crypto";
|
|
6
10
|
|
|
7
11
|
// src/env-proxy.ts
|
|
8
12
|
var DEFAULT_PORTS = { "http:": 80, "https:": 443 };
|
|
@@ -22,10 +26,10 @@ function excluded(url, env2) {
|
|
|
22
26
|
if (value === "*") return true;
|
|
23
27
|
const hostname = url.host.replace(/:\d*$/, "").toLowerCase();
|
|
24
28
|
const port = Number.parseInt(url.port, 10) || DEFAULT_PORTS[url.protocol] || 0;
|
|
25
|
-
return value.split(/[,\s]/).some((
|
|
26
|
-
const withPort = /^(.+):(\d+)$/.exec(
|
|
29
|
+
return value.split(/[,\s]/).some((entry2) => {
|
|
30
|
+
const withPort = /^(.+):(\d+)$/.exec(entry2);
|
|
27
31
|
const entryPort = withPort?.[2] === void 0 ? 0 : Number.parseInt(withPort[2], 10);
|
|
28
|
-
return (withPort?.[1] ??
|
|
32
|
+
return (withPort?.[1] ?? entry2).toLowerCase() === hostname && (entryPort === 0 || entryPort === port);
|
|
29
33
|
});
|
|
30
34
|
}
|
|
31
35
|
function envProxyFor(origin, env2) {
|
|
@@ -91,6 +95,7 @@ var CliError = class _CliError extends Error {
|
|
|
91
95
|
hints;
|
|
92
96
|
recovery;
|
|
93
97
|
failures;
|
|
98
|
+
webRecovery;
|
|
94
99
|
constructor(init) {
|
|
95
100
|
super(redactKeys(init.message));
|
|
96
101
|
this.name = "CliError";
|
|
@@ -103,6 +108,7 @@ var CliError = class _CliError extends Error {
|
|
|
103
108
|
this.hints = init.hints ?? [];
|
|
104
109
|
if (init.recovery !== void 0) this.recovery = init.recovery;
|
|
105
110
|
if (init.failures !== void 0) this.failures = init.failures;
|
|
111
|
+
if (init.webRecovery !== void 0) this.webRecovery = init.webRecovery;
|
|
106
112
|
}
|
|
107
113
|
withHint(hint) {
|
|
108
114
|
return new _CliError({
|
|
@@ -115,7 +121,8 @@ var CliError = class _CliError extends Error {
|
|
|
115
121
|
httpStatus: this.httpStatus,
|
|
116
122
|
hints: [...this.hints, hint],
|
|
117
123
|
recovery: this.recovery,
|
|
118
|
-
failures: this.failures
|
|
124
|
+
failures: this.failures,
|
|
125
|
+
webRecovery: this.webRecovery
|
|
119
126
|
});
|
|
120
127
|
}
|
|
121
128
|
withRecovery(recovery) {
|
|
@@ -129,9 +136,13 @@ var CliError = class _CliError extends Error {
|
|
|
129
136
|
httpStatus: this.httpStatus,
|
|
130
137
|
hints: this.hints,
|
|
131
138
|
recovery,
|
|
132
|
-
failures: this.failures
|
|
139
|
+
failures: this.failures,
|
|
140
|
+
webRecovery: this.webRecovery
|
|
133
141
|
});
|
|
134
142
|
}
|
|
143
|
+
withWebRecovery(webRecovery) {
|
|
144
|
+
return new _CliError({ ...this, message: this.message, webRecovery });
|
|
145
|
+
}
|
|
135
146
|
};
|
|
136
147
|
function usageError(message2) {
|
|
137
148
|
return new CliError({ code: "CLI_USAGE", exitCode: EXIT.USAGE, message: `${message2}\u3002\u8FD0\u884C buke --help \u770B\u7528\u6CD5` });
|
|
@@ -261,10 +272,10 @@ function toBuffer(chunk) {
|
|
|
261
272
|
return Buffer.from(chunk);
|
|
262
273
|
}
|
|
263
274
|
function readToEnd(stdin, timeoutMs, signal) {
|
|
264
|
-
return new Promise((
|
|
275
|
+
return new Promise((resolve3, reject) => {
|
|
265
276
|
const state = stdin;
|
|
266
277
|
if (state.readableEnded === true || state.destroyed === true) {
|
|
267
|
-
|
|
278
|
+
resolve3("");
|
|
268
279
|
return;
|
|
269
280
|
}
|
|
270
281
|
const chunks = [];
|
|
@@ -292,7 +303,7 @@ function readToEnd(stdin, timeoutMs, signal) {
|
|
|
292
303
|
}
|
|
293
304
|
chunks.push(piece);
|
|
294
305
|
};
|
|
295
|
-
const onEnd = () => settle(() =>
|
|
306
|
+
const onEnd = () => settle(() => resolve3(Buffer.concat(chunks).toString("utf8").trim()));
|
|
296
307
|
const onError = (error) => settle(() => reject(missingKey(`\u6CA1\u6709\u8BFB\u5230\u5BC6\u94A5\uFF1A\u6807\u51C6\u8F93\u5165\u51FA\u9519\uFF08${briefReason(error)}\uFF09`)));
|
|
297
308
|
const timer = setTimeout(() => {
|
|
298
309
|
settle(
|
|
@@ -312,7 +323,7 @@ function readToEnd(stdin, timeoutMs, signal) {
|
|
|
312
323
|
});
|
|
313
324
|
}
|
|
314
325
|
function readHiddenLine(stdin, signal) {
|
|
315
|
-
return new Promise((
|
|
326
|
+
return new Promise((resolve3, reject) => {
|
|
316
327
|
let typed = "";
|
|
317
328
|
let escape = "none";
|
|
318
329
|
let settled = false;
|
|
@@ -343,7 +354,7 @@ function readHiddenLine(stdin, signal) {
|
|
|
343
354
|
continue;
|
|
344
355
|
}
|
|
345
356
|
if (char === "\r" || char === "\n") {
|
|
346
|
-
settle(() =>
|
|
357
|
+
settle(() => resolve3(typed));
|
|
347
358
|
return;
|
|
348
359
|
}
|
|
349
360
|
if (char === CTRL_C) {
|
|
@@ -351,7 +362,7 @@ function readHiddenLine(stdin, signal) {
|
|
|
351
362
|
return;
|
|
352
363
|
}
|
|
353
364
|
if (char === CTRL_D) {
|
|
354
|
-
settle(() => typed === "" ? reject(missingKey(NO_KEY_READ)) :
|
|
365
|
+
settle(() => typed === "" ? reject(missingKey(NO_KEY_READ)) : resolve3(typed));
|
|
355
366
|
return;
|
|
356
367
|
}
|
|
357
368
|
if (char === DELETE || char === BACKSPACE) {
|
|
@@ -371,7 +382,7 @@ function readHiddenLine(stdin, signal) {
|
|
|
371
382
|
}
|
|
372
383
|
if (escape === "started") escape = "carried";
|
|
373
384
|
};
|
|
374
|
-
const onEnd = () => settle(() =>
|
|
385
|
+
const onEnd = () => settle(() => resolve3(typed));
|
|
375
386
|
const onError = (error) => settle(() => reject(missingKey(`\u6CA1\u6709\u8BFB\u5230\u5BC6\u94A5\uFF1A\u6807\u51C6\u8F93\u5165\u51FA\u9519\uFF08${briefReason(error)}\uFF09`)));
|
|
376
387
|
const onAbort = () => settle(() => reject(interruptedError(CANCELLED)));
|
|
377
388
|
stdin.on("data", onData);
|
|
@@ -416,7 +427,7 @@ async function readNewKey(io) {
|
|
|
416
427
|
|
|
417
428
|
// package.json
|
|
418
429
|
var name = "bukesiyi-cli";
|
|
419
|
-
var version = "0.
|
|
430
|
+
var version = "0.5.0";
|
|
420
431
|
|
|
421
432
|
// src/version.ts
|
|
422
433
|
var PACKAGE_NAME = name;
|
|
@@ -436,9 +447,25 @@ function taskRecovery(taskType, taskId, status4, baseUrl, failureCode) {
|
|
|
436
447
|
...customOrigin ? { baseUrl } : {},
|
|
437
448
|
...failureCode === void 0 || failureCode === "" ? {} : { failureCode },
|
|
438
449
|
nextAction: "query",
|
|
439
|
-
statusCommand: `buke ${taskType} status ${shellArgument(taskId)}` + (customOrigin ? ` --base-url ${shellArgument(baseUrl)}` : "")
|
|
450
|
+
statusCommand: `buke ${taskType} ${taskType === "products" ? "show" : "status"} ${shellArgument(taskId)}` + (customOrigin ? ` --base-url ${shellArgument(baseUrl)}` : "")
|
|
440
451
|
};
|
|
441
452
|
}
|
|
453
|
+
async function retainMutationOnError(taskType, taskId, idempotencyKey, baseUrl, operation, extra = {}) {
|
|
454
|
+
try {
|
|
455
|
+
return await operation();
|
|
456
|
+
} catch (error) {
|
|
457
|
+
const failure = toCliError(error);
|
|
458
|
+
const rejected = failure.httpStatus !== void 0 && failure.httpStatus >= 400 && failure.httpStatus < 500 && failure.httpStatus !== 408;
|
|
459
|
+
throw failure.withRecovery({
|
|
460
|
+
...taskRecovery(taskType, taskId, void 0, baseUrl),
|
|
461
|
+
acceptance: "unknown",
|
|
462
|
+
idempotencyKey,
|
|
463
|
+
operationOutcome: rejected ? "rejected" : "unknown",
|
|
464
|
+
...extra,
|
|
465
|
+
...failure.recovery
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
}
|
|
442
469
|
function dramaConfirmationRecovery(orderId, status4, baseUrl, idempotencyKey, operationOutcome) {
|
|
443
470
|
return {
|
|
444
471
|
...taskRecovery("drama", orderId, status4, baseUrl),
|
|
@@ -530,6 +557,7 @@ var ME_PATH = "/api/open/v1/me";
|
|
|
530
557
|
var MAX_BODY_BYTES = 1024 * 1024;
|
|
531
558
|
var NOT_FOUND_HINT = "\u8FD9\u4E2A\u5730\u5740\u4E0D\u63D0\u4F9B API \u8C03\u7528\uFF1A\u53EF\u80FD\u8FD8\u6CA1\u6709\u5BF9\u5916\u5F00\u901A\uFF0C\u6216\u8005 --base-url \u5199\u9519\u4E86";
|
|
532
559
|
var EXIT_BY_SERVER_CODE = {
|
|
560
|
+
OPEN_API_IDEMPOTENCY_CONFLICT: EXIT.QUOTE_CHANGED,
|
|
533
561
|
OPEN_API_INSUFFICIENT_BALANCE: EXIT.FUNDS,
|
|
534
562
|
OPEN_API_QUOTE_CHANGED: EXIT.QUOTE_CHANGED,
|
|
535
563
|
OPEN_API_QUOTE_REQUIRED: EXIT.QUOTE_CHANGED,
|
|
@@ -757,14 +785,17 @@ async function requestJson(baseUrl, apiKey, plan, deps) {
|
|
|
757
785
|
async function getJson(baseUrl, apiKey, path, deps) {
|
|
758
786
|
return requestJson(baseUrl, apiKey, { method: "GET", path }, deps);
|
|
759
787
|
}
|
|
760
|
-
async function postJson(baseUrl, apiKey, path, body, idempotencyKey, deps) {
|
|
788
|
+
async function postJson(baseUrl, apiKey, path, body, idempotencyKey, deps, options = {}) {
|
|
761
789
|
return requestJson(
|
|
762
790
|
baseUrl,
|
|
763
791
|
apiKey,
|
|
764
|
-
{ method: "POST", path, body: JSON.stringify(body), contentType: "application/json", idempotencyKey },
|
|
792
|
+
{ method: "POST", path, body: JSON.stringify(body), contentType: "application/json", idempotencyKey, ...options },
|
|
765
793
|
deps
|
|
766
794
|
);
|
|
767
795
|
}
|
|
796
|
+
async function patchJson(baseUrl, apiKey, path, body, idempotencyKey, deps) {
|
|
797
|
+
return requestJson(baseUrl, apiKey, { method: "PATCH", path, body: JSON.stringify(body), contentType: "application/json", idempotencyKey }, deps);
|
|
798
|
+
}
|
|
768
799
|
async function putRaw(baseUrl, apiKey, path, bytes, contentType, idempotencyKey, deps) {
|
|
769
800
|
return requestJson(baseUrl, apiKey, { method: "PUT", path, body: bytes, contentType, idempotencyKey }, deps);
|
|
770
801
|
}
|
|
@@ -798,6 +829,77 @@ async function downloadFile(baseUrl, apiKey, path, deps) {
|
|
|
798
829
|
}
|
|
799
830
|
return { bytes: result.bytes, filename: filenameFromDisposition(result.headers.get("content-disposition")) };
|
|
800
831
|
}
|
|
832
|
+
async function downloadAssetFile(baseUrl, apiKey, path, deps, options) {
|
|
833
|
+
if (!/^\/api\/open\/v1\//u.test(path) || path.includes("#")) throw unreadableResponse(0);
|
|
834
|
+
const origin = normalizeBaseUrl(baseUrl);
|
|
835
|
+
assertKeyFormat(apiKey);
|
|
836
|
+
assertReachedDirectly(origin, deps.env);
|
|
837
|
+
const result = await exchange(`${origin}${path}`, apiKey, downloadPlan(path, deps), deps, origin);
|
|
838
|
+
if ("redirectedTo" in result) throw redirectError(result.redirectedTo);
|
|
839
|
+
if (result.status === 202) throw new CliError({
|
|
840
|
+
code: "CLI_DOWNLOAD_NOT_READY",
|
|
841
|
+
exitCode: EXIT.RETRY_LATER,
|
|
842
|
+
retryable: true,
|
|
843
|
+
httpStatus: 202,
|
|
844
|
+
message: "\u4E0B\u8F7D\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002\u672C\u6B21\u672A\u4FDD\u5B58\u6587\u4EF6\u3002"
|
|
845
|
+
});
|
|
846
|
+
if (result.status < 200 || result.status >= 300) {
|
|
847
|
+
const parsed = parseJson(result.bytes.toString("utf8"));
|
|
848
|
+
throw (parsed && serverError(result.status, parsed.value, apiKey)) ?? unreadableResponse(result.status);
|
|
849
|
+
}
|
|
850
|
+
const mime = result.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase();
|
|
851
|
+
if (result.status !== 200 || result.bytes.length === 0 || !mime || !options.allowedMimeTypes.includes(mime)) throw unreadableResponse(result.status);
|
|
852
|
+
const declaredLength = result.headers.get("content-length");
|
|
853
|
+
if (declaredLength !== null && (!/^\d+$/u.test(declaredLength) || Number(declaredLength) !== result.bytes.byteLength)) throw unreadableResponse(result.status);
|
|
854
|
+
const sha256 = result.headers.get("x-content-sha256");
|
|
855
|
+
if (options.requireSha256 && !sha256 || sha256 !== null && (!/^[a-f0-9]{64}$/iu.test(sha256) || createHash("sha256").update(result.bytes).digest("hex") !== sha256.toLowerCase())) throw unreadableResponse(result.status);
|
|
856
|
+
if (!assetMimeMatchesBytes(mime, result.bytes)) throw unreadableResponse(result.status);
|
|
857
|
+
return { bytes: result.bytes, filename: filenameFromDisposition(result.headers.get("content-disposition")) };
|
|
858
|
+
}
|
|
859
|
+
function assetMimeMatchesBytes(mime, bytes) {
|
|
860
|
+
if (mime === "image/png") return bytes.length >= 8 && bytes.subarray(0, 8).toString("hex") === "89504e470d0a1a0a";
|
|
861
|
+
if (mime === "image/jpeg") return bytes.length >= 3 && bytes.subarray(0, 3).toString("hex") === "ffd8ff";
|
|
862
|
+
if (mime === "image/webp") return bytes.length >= 12 && bytes.toString("ascii", 0, 4) === "RIFF" && bytes.toString("ascii", 8, 12) === "WEBP";
|
|
863
|
+
if (mime === "video/quicktime" && bytes.length >= 8 && ["wide", "free", "mdat", "moov"].includes(bytes.toString("latin1", 4, 8))) {
|
|
864
|
+
const boxSize = bytes.readUInt32BE(0);
|
|
865
|
+
return boxSize === 0 || boxSize === 1 || boxSize >= 8 && boxSize <= bytes.length;
|
|
866
|
+
}
|
|
867
|
+
if (["video/mp4", "video/quicktime", "audio/mp4"].includes(mime)) return bytes.length >= 12 && bytes.toString("ascii", 4, 8) === "ftyp";
|
|
868
|
+
if (mime === "audio/wav" || mime === "audio/x-wav") return bytes.length > 44 && bytes.toString("ascii", 0, 4) === "RIFF" && bytes.toString("ascii", 8, 12) === "WAVE";
|
|
869
|
+
if (mime === "video/webm" || mime === "audio/webm") return bytes.length >= 8 && bytes.subarray(0, 4).toString("hex") === "1a45dfa3" && bytes.subarray(4, 4096).includes(Buffer.from("webm"));
|
|
870
|
+
if (mime === "audio/mpeg") return bytes.length >= 3 && (bytes.toString("ascii", 0, 3) === "ID3" || bytes[0] === 255 && (bytes[1] & 224) === 224);
|
|
871
|
+
if (mime === "audio/aac") {
|
|
872
|
+
if (bytes.length < 7 || bytes[0] !== 255 || (bytes[1] & 246) !== 240 || (bytes[2] >> 2 & 15) > 12) return false;
|
|
873
|
+
const headerBytes = bytes[1] & 1 ? 7 : 9;
|
|
874
|
+
const frameBytes = (bytes[3] & 3) << 11 | bytes[4] << 3 | bytes[5] >> 5;
|
|
875
|
+
return frameBytes > headerBytes && frameBytes <= bytes.length;
|
|
876
|
+
}
|
|
877
|
+
if (mime === "audio/ogg") {
|
|
878
|
+
if (bytes.length < 28 || bytes.toString("ascii", 0, 4) !== "OggS" || bytes[4] !== 0) return false;
|
|
879
|
+
const segments = bytes[26], headerBytes = 27 + segments;
|
|
880
|
+
if (segments === 0 || headerBytes > bytes.length) return false;
|
|
881
|
+
const payloadBytes = bytes.subarray(27, headerBytes).reduce((sum, length) => sum + length, 0);
|
|
882
|
+
return payloadBytes > 0 && headerBytes + payloadBytes <= bytes.length;
|
|
883
|
+
}
|
|
884
|
+
if (mime === "text/vtt") return !bytes.includes(0) && /^\uFEFF?WEBVTT(?:[ \t][^\r\n]*)?(?:\r?\n|$)/u.test(bytes.toString("utf8", 0, Math.min(bytes.length, 4096)));
|
|
885
|
+
if (mime === "application/x-subrip") {
|
|
886
|
+
if (bytes.includes(0)) return false;
|
|
887
|
+
const cue = /^\uFEFF?\s*\d+\r?\n(\d{2,}):([0-5]\d):([0-5]\d),(\d{3})[ \t]+-->[ \t]+(\d{2,}):([0-5]\d):([0-5]\d),(\d{3})(?:[ \t][^\r\n]*)?\r?\n/u.exec(bytes.toString("utf8", 0, Math.min(bytes.length, 4096)));
|
|
888
|
+
if (!cue) return false;
|
|
889
|
+
const start = ((Number(cue[1]) * 60 + Number(cue[2])) * 60 + Number(cue[3])) * 1e3 + Number(cue[4]);
|
|
890
|
+
const end = ((Number(cue[5]) * 60 + Number(cue[6])) * 60 + Number(cue[7])) * 1e3 + Number(cue[8]);
|
|
891
|
+
return Number.isSafeInteger(start) && Number.isSafeInteger(end) && end > start;
|
|
892
|
+
}
|
|
893
|
+
if (mime === "application/pdf") {
|
|
894
|
+
let offset = bytes.length >= 3 && bytes.subarray(0, 3).toString("hex") === "efbbbf" ? 3 : 0;
|
|
895
|
+
const limit = Math.min(bytes.length, 1024);
|
|
896
|
+
while (offset < limit && [0, 9, 10, 12, 13, 32].includes(bytes[offset])) offset += 1;
|
|
897
|
+
return offset + 5 <= limit && bytes.toString("latin1", offset, offset + 5) === "%PDF-";
|
|
898
|
+
}
|
|
899
|
+
if (mime === "application/zip" || mime === "application/vnd.openxmlformats-officedocument.wordprocessingml.document") return bytes.length >= 4 && bytes.subarray(0, 4).toString("hex") === "504b0304";
|
|
900
|
+
if (mime === "text/plain" || mime === "text/markdown" || mime === "text/csv") return !bytes.includes(0);
|
|
901
|
+
return false;
|
|
902
|
+
}
|
|
801
903
|
function downloadPlan(path, deps) {
|
|
802
904
|
return {
|
|
803
905
|
method: "GET",
|
|
@@ -943,7 +1045,7 @@ function parseQuoteValue(value) {
|
|
|
943
1045
|
const numbers = ["durationMilliseconds", "memberMilliseconds", "excessMilliseconds", "credits"].map(
|
|
944
1046
|
(field) => numberOrUndefined(value[field])
|
|
945
1047
|
);
|
|
946
|
-
if (problems.length > 0 || numbers.some((
|
|
1048
|
+
if (problems.length > 0 || numbers.some((entry2) => entry2 === void 0)) return null;
|
|
947
1049
|
const [durationMilliseconds, memberMilliseconds, excessMilliseconds, credits] = numbers;
|
|
948
1050
|
return {
|
|
949
1051
|
quoteHash: text(value.quoteHash),
|
|
@@ -986,7 +1088,7 @@ function parseDramaMoney(value) {
|
|
|
986
1088
|
const problems = [];
|
|
987
1089
|
const text = required(problems);
|
|
988
1090
|
const numbers = ["held", "settled", "released", "refunded"].map((field) => numberOrUndefined(value[field]));
|
|
989
|
-
if (numbers.some((
|
|
1091
|
+
if (numbers.some((entry2) => entry2 === void 0)) return null;
|
|
990
1092
|
const [held, settled, released, refunded] = numbers;
|
|
991
1093
|
const currency = text(value.currency);
|
|
992
1094
|
return problems.length > 0 ? null : { currency, held, settled, released, refunded };
|
|
@@ -1009,7 +1111,7 @@ function parseDramaOrder(body) {
|
|
|
1009
1111
|
const money = parseDramaMoney(order2.money);
|
|
1010
1112
|
if (money === null) problems.push("money");
|
|
1011
1113
|
const actionsValue = Array.isArray(order2.nextActions) ? order2.nextActions : null;
|
|
1012
|
-
const actions = actionsValue === null ? [] : actionsValue.filter((
|
|
1114
|
+
const actions = actionsValue === null ? [] : actionsValue.filter((action2) => typeof action2 === "string");
|
|
1013
1115
|
if (actionsValue === null || actions.length !== actionsValue.length) problems.push("nextActions");
|
|
1014
1116
|
const gapsValue = order2.gaps === void 0 ? void 0 : Array.isArray(order2.gaps) ? order2.gaps : null;
|
|
1015
1117
|
if (order2.gaps !== void 0 && gapsValue === null) problems.push("gaps");
|
|
@@ -1103,7 +1205,11 @@ function parseRun(body) {
|
|
|
1103
1205
|
problems.push("message");
|
|
1104
1206
|
return { role: "", text: "" };
|
|
1105
1207
|
}
|
|
1106
|
-
return {
|
|
1208
|
+
return {
|
|
1209
|
+
role: typeof message2.role === "string" ? message2.role : "",
|
|
1210
|
+
text: message2.text,
|
|
1211
|
+
...typeof message2.earlierAttemptOf === "string" && message2.earlierAttemptOf ? { earlierAttemptOf: message2.earlierAttemptOf } : {}
|
|
1212
|
+
};
|
|
1107
1213
|
});
|
|
1108
1214
|
const failureValue = isRecord2(run2.failure) ? run2.failure : null;
|
|
1109
1215
|
const failure = failureValue ? {
|
|
@@ -1124,8 +1230,8 @@ function parseRun(body) {
|
|
|
1124
1230
|
productionConfirmed: run2.productionConfirmed === true,
|
|
1125
1231
|
...currentProductionCredits !== void 0 ? { currentProductionCredits } : {},
|
|
1126
1232
|
product: product ? { id: text(product.id), name: text(product.name) } : { id: "", name: "" },
|
|
1127
|
-
nextActions: actions === null ? [] : actions.map((
|
|
1128
|
-
const parsed2 = parseRunAction(
|
|
1233
|
+
nextActions: actions === null ? [] : actions.map((action2) => {
|
|
1234
|
+
const parsed2 = parseRunAction(action2);
|
|
1129
1235
|
if (parsed2 === null) problems.push("action");
|
|
1130
1236
|
return parsed2 ?? { type: "" };
|
|
1131
1237
|
}),
|
|
@@ -1163,46 +1269,52 @@ async function getBalance(baseUrl, apiKey, deps) {
|
|
|
1163
1269
|
if (!balance2 || !isRecord2(reply.body)) throw unreadableResponse(reply.status);
|
|
1164
1270
|
return { view: balance2, raw: reply.body };
|
|
1165
1271
|
}
|
|
1166
|
-
async function createProduct(baseUrl, apiKey, name2, category, idempotencyKey, deps) {
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1272
|
+
async function createProduct(baseUrl, apiKey, name2, category, idempotencyKey, deps, fields3 = {}) {
|
|
1273
|
+
return retainSubmissionOnError("products", idempotencyKey, baseUrl, async () => {
|
|
1274
|
+
const reply = await postJson(
|
|
1275
|
+
baseUrl,
|
|
1276
|
+
apiKey,
|
|
1277
|
+
"/api/open/v1/products",
|
|
1278
|
+
{ ...fields3, name: name2, ...category === void 0 ? {} : { category } },
|
|
1279
|
+
idempotencyKey,
|
|
1280
|
+
deps
|
|
1281
|
+
);
|
|
1282
|
+
const product = parseProduct(reply.body);
|
|
1283
|
+
if (!product || !isRecord2(reply.body)) throw unreadableResponse(reply.status);
|
|
1284
|
+
return { view: product, raw: reply.body, replayed: reply.status === 200 };
|
|
1285
|
+
});
|
|
1178
1286
|
}
|
|
1179
1287
|
async function putProductImage(baseUrl, apiKey, productId, angle, bytes, contentType, idempotencyKey, deps) {
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1288
|
+
return retainMutationOnError("products", productId, idempotencyKey, baseUrl, async () => {
|
|
1289
|
+
const reply = await putRaw(
|
|
1290
|
+
baseUrl,
|
|
1291
|
+
apiKey,
|
|
1292
|
+
`/api/open/v1/products/${encodeURIComponent(productId)}/images?angle=${angle}`,
|
|
1293
|
+
bytes,
|
|
1294
|
+
contentType,
|
|
1295
|
+
idempotencyKey,
|
|
1296
|
+
deps
|
|
1297
|
+
);
|
|
1298
|
+
const product = parseProduct(reply.body);
|
|
1299
|
+
if (!product || !isRecord2(reply.body)) throw unreadableResponse(reply.status);
|
|
1300
|
+
return { view: product, raw: reply.body, replayed: reply.status === 200 };
|
|
1301
|
+
});
|
|
1192
1302
|
}
|
|
1193
1303
|
async function confirmProductLock(baseUrl, apiKey, productId, lock, idempotencyKey, deps) {
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1304
|
+
return retainMutationOnError("products", productId, idempotencyKey, baseUrl, async () => {
|
|
1305
|
+
const reply = await postJson(
|
|
1306
|
+
baseUrl,
|
|
1307
|
+
apiKey,
|
|
1308
|
+
`/api/open/v1/products/${encodeURIComponent(productId)}/lock/confirm`,
|
|
1309
|
+
{ productLock: lock },
|
|
1310
|
+
idempotencyKey,
|
|
1311
|
+
deps
|
|
1312
|
+
);
|
|
1313
|
+
const productLock = parseProductLock(reply.body);
|
|
1314
|
+
const product = parseProduct(reply.body);
|
|
1315
|
+
if (!productLock || !product || !isRecord2(reply.body)) throw unreadableResponse(reply.status);
|
|
1316
|
+
return { view: { productLock, product }, raw: reply.body };
|
|
1317
|
+
});
|
|
1206
1318
|
}
|
|
1207
1319
|
async function getTemplateShortCatalog(baseUrl, apiKey, deps) {
|
|
1208
1320
|
const reply = await getJson(baseUrl, apiKey, "/api/open/v1/template-shorts", deps);
|
|
@@ -1212,9 +1324,9 @@ async function getTemplateShortCatalog(baseUrl, apiKey, deps) {
|
|
|
1212
1324
|
}
|
|
1213
1325
|
async function uploadTemplateShortAsset(baseUrl, apiKey, bytes, contentType, idempotencyKey, deps) {
|
|
1214
1326
|
const reply = await postRaw(baseUrl, apiKey, "/api/open/v1/template-shorts/uploads", bytes, contentType, idempotencyKey, deps);
|
|
1215
|
-
const
|
|
1216
|
-
if (!
|
|
1217
|
-
return { view:
|
|
1327
|
+
const upload3 = parseUpload(reply.body);
|
|
1328
|
+
if (!upload3 || !isRecord2(reply.body)) throw unreadableResponse(reply.status);
|
|
1329
|
+
return { view: upload3, raw: reply.body };
|
|
1218
1330
|
}
|
|
1219
1331
|
async function quoteTemplateShort(baseUrl, apiKey, templateId, props, idempotencyKey, deps) {
|
|
1220
1332
|
const reply = await postJson(
|
|
@@ -1272,25 +1384,13 @@ async function runReplyOf(reply) {
|
|
|
1272
1384
|
return { view: run2, raw: reply.body };
|
|
1273
1385
|
}
|
|
1274
1386
|
async function createVideoRun(baseUrl, apiKey, body, idempotencyKey, deps) {
|
|
1275
|
-
return runReplyOf(await postJson(baseUrl, apiKey, "/api/open/v1/videos", body, idempotencyKey, deps));
|
|
1387
|
+
return retainSubmissionOnError("videos", idempotencyKey, baseUrl, async () => runReplyOf(await postJson(baseUrl, apiKey, "/api/open/v1/videos", body, idempotencyKey, deps)));
|
|
1276
1388
|
}
|
|
1277
1389
|
async function getVideoRun(baseUrl, apiKey, runId, deps) {
|
|
1278
1390
|
return runReplyOf(await getJson(baseUrl, apiKey, `/api/open/v1/videos/${encodeURIComponent(runId)}`, deps));
|
|
1279
1391
|
}
|
|
1280
|
-
async function postVideoMessage(baseUrl, apiKey, runId, text, idempotencyKey, deps) {
|
|
1281
|
-
return runReplyOf(
|
|
1282
|
-
await postJson(
|
|
1283
|
-
baseUrl,
|
|
1284
|
-
apiKey,
|
|
1285
|
-
`/api/open/v1/videos/${encodeURIComponent(runId)}/messages`,
|
|
1286
|
-
{ text },
|
|
1287
|
-
idempotencyKey,
|
|
1288
|
-
deps
|
|
1289
|
-
)
|
|
1290
|
-
);
|
|
1291
|
-
}
|
|
1292
1392
|
async function confirmVideoProduction(baseUrl, apiKey, runId, expectedVersion, confirmation, idempotencyKey, deps) {
|
|
1293
|
-
return runReplyOf(
|
|
1393
|
+
return retainMutationOnError("videos", runId, idempotencyKey, baseUrl, async () => runReplyOf(
|
|
1294
1394
|
await postJson(
|
|
1295
1395
|
baseUrl,
|
|
1296
1396
|
apiKey,
|
|
@@ -1299,16 +1399,18 @@ async function confirmVideoProduction(baseUrl, apiKey, runId, expectedVersion, c
|
|
|
1299
1399
|
idempotencyKey,
|
|
1300
1400
|
deps
|
|
1301
1401
|
)
|
|
1302
|
-
);
|
|
1402
|
+
), { operation: "confirm", videoConfirmation: { expectedVersion, confirmation } });
|
|
1303
1403
|
}
|
|
1304
1404
|
async function downloadVideo(baseUrl, apiKey, runId, deps) {
|
|
1305
1405
|
return downloadFile(baseUrl, apiKey, `/api/open/v1/videos/${encodeURIComponent(runId)}/download`, deps);
|
|
1306
1406
|
}
|
|
1307
1407
|
async function createDramaOrder(baseUrl, apiKey, body, idempotencyKey, deps) {
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1408
|
+
return retainSubmissionOnError("drama", idempotencyKey, baseUrl, async () => {
|
|
1409
|
+
const reply = await postJson(baseUrl, apiKey, "/api/open/v1/drama/orders", body, idempotencyKey, deps);
|
|
1410
|
+
const view = parseDramaOrder(reply.body);
|
|
1411
|
+
if (!view || !isRecord2(reply.body)) throw unreadableResponse(reply.status);
|
|
1412
|
+
return { view, raw: reply.body, replayed: reply.status === 200 };
|
|
1413
|
+
});
|
|
1312
1414
|
}
|
|
1313
1415
|
async function getDramaOrder(baseUrl, apiKey, orderId, deps) {
|
|
1314
1416
|
const reply = await getJson(baseUrl, apiKey, `/api/open/v1/drama/orders/${encodeURIComponent(orderId)}`, deps);
|
|
@@ -1362,45 +1464,45 @@ var ORDER_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["succeeded", "failed", "c
|
|
|
1362
1464
|
var RUN_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["succeeded", "failed", "canceled"]);
|
|
1363
1465
|
var RUN_WAITING_FOR_USER_STATUSES = /* @__PURE__ */ new Set(["needs_input", "awaiting_reply", "awaiting_confirmation"]);
|
|
1364
1466
|
var DRAMA_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["delivered", "failed", "canceled", "partial"]);
|
|
1365
|
-
var DRAMA_WAITING_FOR_USER_STATUSES = /* @__PURE__ */ new Set(["needs_attention"]);
|
|
1366
|
-
async function awaitTemplateShortOrder(baseUrl, apiKey, start, deps,
|
|
1467
|
+
var DRAMA_WAITING_FOR_USER_STATUSES = /* @__PURE__ */ new Set(["needs_attention", "quotable"]);
|
|
1468
|
+
async function awaitTemplateShortOrder(baseUrl, apiKey, start, deps, wait2) {
|
|
1367
1469
|
let current = start;
|
|
1368
1470
|
if (ORDER_TERMINAL_STATUSES.has(current.view.status)) return { value: current, timedOut: false };
|
|
1369
|
-
const deadline =
|
|
1471
|
+
const deadline = wait2.now().getTime() + wait2.timeoutMs;
|
|
1370
1472
|
let interval = FIRST_POLL_INTERVAL_MS;
|
|
1371
1473
|
let said = current.view.status;
|
|
1372
1474
|
for (; ; ) {
|
|
1373
|
-
const remaining = deadline -
|
|
1475
|
+
const remaining = deadline - wait2.now().getTime();
|
|
1374
1476
|
if (remaining <= 0) return { value: current, timedOut: true };
|
|
1375
1477
|
current = await retainTaskOnError(() => taskRecovery("shorts", current.view.id, current.view.status, baseUrl), async () => {
|
|
1376
|
-
await
|
|
1478
|
+
await wait2.sleep(Math.max(Math.min(interval, remaining), 1));
|
|
1377
1479
|
interval = Math.min(Math.ceil(interval * 1.5), MAX_POLL_INTERVAL_MS);
|
|
1378
1480
|
return getTemplateShortOrder(baseUrl, apiKey, current.view.id, deps);
|
|
1379
1481
|
});
|
|
1380
1482
|
if (current.view.status !== said) {
|
|
1381
|
-
|
|
1483
|
+
wait2.note?.(`\u72B6\u6001\u53D8\u6210 ${current.view.status}`);
|
|
1382
1484
|
said = current.view.status;
|
|
1383
1485
|
}
|
|
1384
1486
|
if (ORDER_TERMINAL_STATUSES.has(current.view.status)) return { value: current, timedOut: false };
|
|
1385
1487
|
}
|
|
1386
1488
|
}
|
|
1387
|
-
async function awaitVideoRun(baseUrl, apiKey, start, deps,
|
|
1489
|
+
async function awaitVideoRun(baseUrl, apiKey, start, deps, wait2) {
|
|
1388
1490
|
let current = start;
|
|
1389
1491
|
if (runStopped(current.view.status)) return { value: current, timedOut: false };
|
|
1390
|
-
const deadline =
|
|
1492
|
+
const deadline = wait2.now().getTime() + wait2.timeoutMs;
|
|
1391
1493
|
let interval = FIRST_POLL_INTERVAL_MS;
|
|
1392
1494
|
let said = current.view.status;
|
|
1393
1495
|
for (; ; ) {
|
|
1394
|
-
const remaining = deadline -
|
|
1496
|
+
const remaining = deadline - wait2.now().getTime();
|
|
1395
1497
|
if (remaining <= 0) return { value: current, timedOut: true };
|
|
1396
1498
|
const preferred = current.view.pollAfterMs !== null && current.view.pollAfterMs > 0 ? current.view.pollAfterMs : interval;
|
|
1397
1499
|
current = await retainTaskOnError(() => taskRecovery("videos", current.view.rootRunId, current.view.status, baseUrl, current.view.failure?.code), async () => {
|
|
1398
|
-
await
|
|
1500
|
+
await wait2.sleep(Math.max(Math.min(preferred, remaining), 1));
|
|
1399
1501
|
interval = Math.min(Math.ceil(interval * 1.5), MAX_POLL_INTERVAL_MS);
|
|
1400
1502
|
return getVideoRun(baseUrl, apiKey, current.view.rootRunId, deps);
|
|
1401
1503
|
});
|
|
1402
1504
|
if (current.view.status !== said) {
|
|
1403
|
-
|
|
1505
|
+
wait2.note?.(`\u72B6\u6001\u53D8\u6210 ${current.view.status}`);
|
|
1404
1506
|
said = current.view.status;
|
|
1405
1507
|
}
|
|
1406
1508
|
if (runStopped(current.view.status)) return { value: current, timedOut: false };
|
|
@@ -1409,22 +1511,22 @@ async function awaitVideoRun(baseUrl, apiKey, start, deps, wait) {
|
|
|
1409
1511
|
function runStopped(status4) {
|
|
1410
1512
|
return RUN_TERMINAL_STATUSES.has(status4) || RUN_WAITING_FOR_USER_STATUSES.has(status4);
|
|
1411
1513
|
}
|
|
1412
|
-
async function awaitDramaOrder(baseUrl, apiKey, start, deps,
|
|
1514
|
+
async function awaitDramaOrder(baseUrl, apiKey, start, deps, wait2) {
|
|
1413
1515
|
let current = start;
|
|
1414
1516
|
if (dramaStopped(current.view.status)) return { value: current, timedOut: false };
|
|
1415
|
-
const deadline =
|
|
1517
|
+
const deadline = wait2.now().getTime() + wait2.timeoutMs;
|
|
1416
1518
|
let interval = FIRST_POLL_INTERVAL_MS;
|
|
1417
1519
|
let said = current.view.status;
|
|
1418
1520
|
for (; ; ) {
|
|
1419
|
-
const remaining = deadline -
|
|
1521
|
+
const remaining = deadline - wait2.now().getTime();
|
|
1420
1522
|
if (remaining <= 0) return { value: current, timedOut: true };
|
|
1421
1523
|
current = await retainTaskOnError(() => taskRecovery("drama", current.view.id, current.view.status, baseUrl), async () => {
|
|
1422
|
-
await
|
|
1524
|
+
await wait2.sleep(Math.max(Math.min(interval, remaining), 1));
|
|
1423
1525
|
interval = Math.min(Math.ceil(interval * 1.5), MAX_POLL_INTERVAL_MS);
|
|
1424
1526
|
return getDramaOrder(baseUrl, apiKey, current.view.id, deps);
|
|
1425
1527
|
});
|
|
1426
1528
|
if (current.view.status !== said) {
|
|
1427
|
-
|
|
1529
|
+
wait2.note?.(`\u72B6\u6001\u53D8\u6210 ${current.view.status}`);
|
|
1428
1530
|
said = current.view.status;
|
|
1429
1531
|
}
|
|
1430
1532
|
if (dramaStopped(current.view.status)) return { value: current, timedOut: false };
|
|
@@ -1434,6 +1536,41 @@ function dramaStopped(status4) {
|
|
|
1434
1536
|
return DRAMA_TERMINAL_STATUSES.has(status4) || DRAMA_WAITING_FOR_USER_STATUSES.has(status4);
|
|
1435
1537
|
}
|
|
1436
1538
|
|
|
1539
|
+
// src/client-graphic.ts
|
|
1540
|
+
var keys = /* @__PURE__ */ new Set(["unavailableAttachmentIds", "total", "nextOffset", "run", "runs", "nextCursor", "id", "productId", "title", "status", "imageModel", "aspectRatio", "planVersion", "copy", "points", "detail", "notes", "language", "imagePlan", "position", "textOnImage", "quality", "background", "editBaseImageId", "sourceImageId", "editMaskId", "referenceAttachmentIds", "useProductPhoto", "shotFlags", "images", "ordinal", "planPosition", "currentVersion", "width", "height", "mime", "bytes", "model", "credits", "origin", "transparent", "createdAt", "updatedAt", "downloadPath", "spentCredits", "turn", "messageId", "failure", "generationOrder", "waitingBalance", "totalImages", "imageCount", "failedCount", "shortfallCredits", "messages", "role", "text", "quote", "pricingScale", "pricingAlgorithmVersion", "rateCardVersion", "rateCardHash", "creditsPerImage", "totalCredits", "freeImageCount", "items", "referenceCount", "free", "currency", "quoteHash", "imageIndexes", "sufficient", "templates", "slug", "name", "family", "what", "aspect", "needsReference", "writesText", "attachment", "attachments", "attachmentId", "kind", "at", "missing", "unavailable", "mask", "image", "canceled", "replayed"]);
|
|
1541
|
+
function graphicDocument(value) {
|
|
1542
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw invalid2();
|
|
1543
|
+
const clean = (item) => {
|
|
1544
|
+
if (item === null || ["string", "number", "boolean"].includes(typeof item)) return item;
|
|
1545
|
+
if (Array.isArray(item)) return item.map(clean);
|
|
1546
|
+
if (typeof item !== "object") return void 0;
|
|
1547
|
+
return Object.fromEntries(Object.entries(item).filter(([key]) => keys.has(key)).map(([key, child]) => [key, clean(child)]));
|
|
1548
|
+
};
|
|
1549
|
+
return clean(value);
|
|
1550
|
+
}
|
|
1551
|
+
function graphicRun(value) {
|
|
1552
|
+
const body = graphicDocument(value);
|
|
1553
|
+
const run2 = body.run;
|
|
1554
|
+
if (!run2 || typeof run2.id !== "string" || !run2.id || typeof run2.status !== "string" || !Array.isArray(run2.images) || !Array.isArray(run2.imagePlan) || !Array.isArray(run2.messages)) throw invalid2();
|
|
1555
|
+
return run2;
|
|
1556
|
+
}
|
|
1557
|
+
function graphicQuote(value) {
|
|
1558
|
+
const body = graphicDocument(value);
|
|
1559
|
+
const quote3 = body.quote;
|
|
1560
|
+
if (!quote3 || typeof quote3.quoteHash !== "string" || !/^[a-f0-9]{64}$/u.test(quote3.quoteHash) || typeof quote3.totalCredits !== "number" || !Number.isFinite(quote3.totalCredits) || quote3.totalCredits < 0 || typeof quote3.imageCount !== "number") throw invalid2();
|
|
1561
|
+
return quote3;
|
|
1562
|
+
}
|
|
1563
|
+
function invalid2() {
|
|
1564
|
+
return new CliError({ code: "CLI_BAD_RESPONSE", exitCode: EXIT.SERVER, message: "\u670D\u52A1\u7AEF\u672A\u8FD4\u56DE\u6709\u6548\u7684\u56FE\u6587\u7ED3\u679C\uFF0C\u8BF7\u67E5\u8BE2\u539F\u9879\u76EE\u540E\u91CD\u8BD5" });
|
|
1565
|
+
}
|
|
1566
|
+
var graphicPath = (id) => `/api/open/v1/graphic/runs/${encodeURIComponent(id)}`;
|
|
1567
|
+
async function getGraphicRun(baseUrl, apiKey, id, deps) {
|
|
1568
|
+
return graphicRun((await getJson(baseUrl, apiKey, graphicPath(id), deps)).body);
|
|
1569
|
+
}
|
|
1570
|
+
async function getGraphicQuote(baseUrl, apiKey, id, request, key, deps) {
|
|
1571
|
+
return graphicQuote((await postJson(baseUrl, apiKey, `${graphicPath(id)}/quote`, request, key, deps)).body);
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1437
1574
|
// src/credentials.ts
|
|
1438
1575
|
import { randomBytes } from "node:crypto";
|
|
1439
1576
|
import { constants } from "node:fs";
|
|
@@ -1485,6 +1622,9 @@ function locate(io) {
|
|
|
1485
1622
|
}
|
|
1486
1623
|
return { dir: join(home, ".config", "buke"), ours: true };
|
|
1487
1624
|
}
|
|
1625
|
+
function credentialsDir(io) {
|
|
1626
|
+
return locate(io).dir;
|
|
1627
|
+
}
|
|
1488
1628
|
function credentialsPath(io) {
|
|
1489
1629
|
return join(locate(io).dir, FILE_NAME);
|
|
1490
1630
|
}
|
|
@@ -1716,26 +1856,6 @@ function keySourceLine(resolved) {
|
|
|
1716
1856
|
return resolved.source === "env" ? "\u5BC6\u94A5\u6765\u81EA\uFF1A\u73AF\u5883\u53D8\u91CF BUKE_API_KEY" : `\u5BC6\u94A5\u6765\u81EA\uFF1A${resolved.credentialsPath}`;
|
|
1717
1857
|
}
|
|
1718
1858
|
|
|
1719
|
-
// src/commands/balance.ts
|
|
1720
|
-
async function balance(context) {
|
|
1721
|
-
const { io, out } = context;
|
|
1722
|
-
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
1723
|
-
const { view, raw } = await getBalance(baseUrl, apiKey, io);
|
|
1724
|
-
out.result(
|
|
1725
|
-
[
|
|
1726
|
-
`\u53EF\u7528\u4F59\u989D\uFF1A${view.available} ${singleLine(view.currency)}`,
|
|
1727
|
-
`\u51BB\u7ED3\u4E2D\uFF1A${view.held} ${singleLine(view.currency)}`,
|
|
1728
|
-
`\u5DF2\u652F\u51FA\uFF1A${view.spent} ${singleLine(view.currency)}`,
|
|
1729
|
-
`\u66F4\u65B0\u65F6\u95F4\uFF1A${singleLine(view.updatedAt)}`
|
|
1730
|
-
],
|
|
1731
|
-
{ balance: raw.balance }
|
|
1732
|
-
);
|
|
1733
|
-
}
|
|
1734
|
-
|
|
1735
|
-
// src/commands/shorts.ts
|
|
1736
|
-
import { createHash } from "node:crypto";
|
|
1737
|
-
import { writeFile } from "node:fs/promises";
|
|
1738
|
-
|
|
1739
1859
|
// src/commands/shared.ts
|
|
1740
1860
|
import { randomUUID } from "node:crypto";
|
|
1741
1861
|
import { readFile } from "node:fs/promises";
|
|
@@ -1795,11 +1915,20 @@ async function readPropsArgument(io, ref, what) {
|
|
|
1795
1915
|
return parsed;
|
|
1796
1916
|
}
|
|
1797
1917
|
async function readStdinAll(io, maxBytes, what) {
|
|
1918
|
+
if (io.signal?.aborted) throw interruptedError();
|
|
1798
1919
|
const stdin = io.stdin;
|
|
1799
1920
|
if (stdin.readableEnded === true) return "";
|
|
1800
1921
|
const chunks = [];
|
|
1801
1922
|
let size = 0;
|
|
1802
|
-
await new Promise((
|
|
1923
|
+
await new Promise((resolve3, reject) => {
|
|
1924
|
+
const onAbort = () => {
|
|
1925
|
+
cleanup();
|
|
1926
|
+
reject(interruptedError());
|
|
1927
|
+
};
|
|
1928
|
+
const timer = setTimeout(() => {
|
|
1929
|
+
cleanup();
|
|
1930
|
+
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
|
+
}, io.stdinTimeoutMs ?? DEFAULT_STDIN_TIMEOUT_MS);
|
|
1803
1932
|
const toBuffer2 = (chunk) => typeof chunk === "string" ? Buffer.from(chunk, "utf8") : Buffer.from(chunk);
|
|
1804
1933
|
const onData = (chunk) => {
|
|
1805
1934
|
const piece = toBuffer2(chunk);
|
|
@@ -1813,25 +1942,49 @@ async function readStdinAll(io, maxBytes, what) {
|
|
|
1813
1942
|
};
|
|
1814
1943
|
const onEnd = () => {
|
|
1815
1944
|
cleanup();
|
|
1816
|
-
|
|
1945
|
+
resolve3();
|
|
1817
1946
|
};
|
|
1818
1947
|
const onError = (error) => {
|
|
1819
1948
|
cleanup();
|
|
1820
1949
|
reject(new CliError({ code: "CLI_USAGE", exitCode: EXIT.USAGE, message: `\u6807\u51C6\u8F93\u5165\u8BFB\u4E0D\u4E86\uFF1A${briefReason(error)}` }));
|
|
1821
1950
|
};
|
|
1951
|
+
const onClose = () => onError(new Error("\u6807\u51C6\u8F93\u5165\u63D0\u524D\u5173\u95ED"));
|
|
1822
1952
|
const cleanup = () => {
|
|
1953
|
+
clearTimeout(timer);
|
|
1954
|
+
io.signal?.removeEventListener("abort", onAbort);
|
|
1823
1955
|
stdin.removeListener("data", onData);
|
|
1824
1956
|
stdin.removeListener("end", onEnd);
|
|
1825
1957
|
stdin.removeListener("error", onError);
|
|
1958
|
+
stdin.removeListener("close", onClose);
|
|
1826
1959
|
stdin.pause();
|
|
1827
1960
|
};
|
|
1828
1961
|
stdin.on("data", onData);
|
|
1829
1962
|
stdin.on("end", onEnd);
|
|
1830
1963
|
stdin.on("error", onError);
|
|
1964
|
+
stdin.on("close", onClose);
|
|
1965
|
+
io.signal?.addEventListener("abort", onAbort, { once: true });
|
|
1831
1966
|
stdin.resume();
|
|
1832
1967
|
});
|
|
1833
1968
|
return Buffer.concat(chunks).toString("utf8");
|
|
1834
1969
|
}
|
|
1970
|
+
async function sleepFor(io, ms) {
|
|
1971
|
+
if (io.signal?.aborted) throw interruptedError();
|
|
1972
|
+
let timer;
|
|
1973
|
+
let stop = () => void 0;
|
|
1974
|
+
const interrupted = new Promise((_resolve, reject) => {
|
|
1975
|
+
stop = () => reject(interruptedError());
|
|
1976
|
+
io.signal?.addEventListener("abort", stop, { once: true });
|
|
1977
|
+
});
|
|
1978
|
+
const sleeping = io.sleep ? io.sleep(ms) : new Promise((resolve3) => {
|
|
1979
|
+
timer = setTimeout(resolve3, ms);
|
|
1980
|
+
});
|
|
1981
|
+
try {
|
|
1982
|
+
await Promise.race([sleeping, interrupted]);
|
|
1983
|
+
} finally {
|
|
1984
|
+
clearTimeout(timer);
|
|
1985
|
+
io.signal?.removeEventListener("abort", stop);
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1835
1988
|
async function readImageFile(path) {
|
|
1836
1989
|
let bytes;
|
|
1837
1990
|
try {
|
|
@@ -1856,10 +2009,28 @@ function sniffImageContentType(bytes) {
|
|
|
1856
2009
|
}
|
|
1857
2010
|
return void 0;
|
|
1858
2011
|
}
|
|
2012
|
+
async function readUploadFile(path) {
|
|
2013
|
+
const { stat: stat3 } = await import("node:fs/promises");
|
|
2014
|
+
try {
|
|
2015
|
+
const info = await stat3(path);
|
|
2016
|
+
if (!info.isFile() || info.size === 0 || info.size > MAX_IMAGE_BYTES) throw usageError("\u4E0A\u4F20\u6587\u4EF6\u5FC5\u987B\u4E3A 1 \u5B57\u8282\u81F3 64 MiB \u7684\u666E\u901A\u6587\u4EF6");
|
|
2017
|
+
const bytes = await readFile(path);
|
|
2018
|
+
if (bytes.byteLength === 0 || bytes.byteLength > MAX_IMAGE_BYTES) throw usageError("\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8D85\u51FA\u5141\u8BB8\u8303\u56F4");
|
|
2019
|
+
const image = sniffImageContentType(bytes);
|
|
2020
|
+
const contentType = image ?? (bytes.length >= 12 && bytes.toString("ascii", 4, 8) === "ftyp" ? "video/mp4" : bytes.length > 44 && bytes.toString("ascii", 0, 4) === "RIFF" && bytes.toString("ascii", 8, 12) === "WAVE" ? "audio/wav" : void 0);
|
|
2021
|
+
return { bytes, contentType };
|
|
2022
|
+
} catch (error) {
|
|
2023
|
+
if (error instanceof CliError) throw error;
|
|
2024
|
+
throw usageError(`\u65E0\u6CD5\u8BFB\u53D6\u4E0A\u4F20\u6587\u4EF6\uFF1A${briefReason(error)}`);
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
1859
2027
|
|
|
1860
2028
|
// src/commands/shorts.ts
|
|
2029
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
2030
|
+
import { writeFile } from "node:fs/promises";
|
|
1861
2031
|
var SUBCOMMANDS = "catalog\u3001upload\u3001quote\u3001order\u3001status\u3001download \u548C cancel";
|
|
1862
2032
|
async function shorts(context) {
|
|
2033
|
+
timeoutSecondsOf(context.values, DEFAULT_WAIT_TIMEOUT_MS / 1e3);
|
|
1863
2034
|
const { args } = context;
|
|
1864
2035
|
const [subcommand] = args;
|
|
1865
2036
|
if (subcommand === void 0) {
|
|
@@ -1891,7 +2062,7 @@ function waitControls(io, values, note) {
|
|
|
1891
2062
|
return {
|
|
1892
2063
|
timeoutMs: timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3) * 1e3,
|
|
1893
2064
|
now: io.now ?? (() => /* @__PURE__ */ new Date()),
|
|
1894
|
-
sleep:
|
|
2065
|
+
sleep: (ms) => sleepFor(io, ms),
|
|
1895
2066
|
note
|
|
1896
2067
|
};
|
|
1897
2068
|
}
|
|
@@ -2045,103 +2216,2392 @@ async function saveDownload(target, bytes) {
|
|
|
2045
2216
|
message: `\u6210\u7247\u5199\u4E0D\u8FDB ${target}\uFF08${briefReason(error)}\uFF09`
|
|
2046
2217
|
});
|
|
2047
2218
|
}
|
|
2048
|
-
return { path: target, bytes: bytes.byteLength, sha256:
|
|
2219
|
+
return { path: target, bytes: bytes.byteLength, sha256: createHash2("sha256").update(bytes).digest("hex") };
|
|
2049
2220
|
}
|
|
2050
2221
|
|
|
2051
|
-
// src/commands/
|
|
2052
|
-
var
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2222
|
+
// src/commands/graphic.ts
|
|
2223
|
+
var graphicCommand = {
|
|
2224
|
+
run: graphic,
|
|
2225
|
+
acceptsBaseUrl: true,
|
|
2226
|
+
options: ["product", "title", "model", "aspect-ratio", "text", "template", "attachment-ids", "edit-image", "source-image", "choice", "quote-hash", "yes", "wait", "timeout", "out", "file", "mime", "quality", "generation-order", "idempotency-key", "image-indexes", "all", "attachment", "mask", "limit", "cursor", "offset"],
|
|
2227
|
+
positionals: ["subcommand", "run-id", "image-or-message-id"],
|
|
2228
|
+
help: [
|
|
2229
|
+
"\u7528\u6CD5\uFF1Abuke graphic <\u5B50\u547D\u4EE4> [\u9879\u76EEID] [\u56FE\u7247\u6216\u6D88\u606FID] [\u9009\u9879]",
|
|
2230
|
+
"",
|
|
2231
|
+
"create --text <\u5236\u4F5C\u8981\u6C42> [--product <\u4EA7\u54C1ID>] [--model <\u6A21\u578B>] [--aspect-ratio <\u753B\u5E45>] [--wait]",
|
|
2232
|
+
"list | templates | status <\u9879\u76EEID> [--wait] | plan <\u9879\u76EEID> | versions <\u9879\u76EEID>",
|
|
2233
|
+
"message <\u9879\u76EEID> --text <\u8981\u6C42> [--attachment-ids <ID,ID>] [--edit-image <\u56FE\u7247ID>] [--source-image <\u56FE\u7247ID>] [--choice <\u9009\u9879ID>] [--wait]",
|
|
2234
|
+
"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
|
+
"quote <\u9879\u76EEID> [--image-indexes <1,2>]\uFF1A\u8BFB\u53D6\u6240\u9009\u65B9\u6848\u62A5\u4EF7\u3002",
|
|
2236
|
+
"generate <\u9879\u76EEID> [--image-indexes <1,2>] --quote-hash <\u5DF2\u67E5\u770B\u7684\u62A5\u4EF7\u54C8\u5E0C> --yes [--wait]\uFF1A\u62A5\u4EF7\u672A\u53D8\u65F6\u751F\u6210\uFF1B\u4E0D\u5E26 --yes \u4EC5\u9884\u89C8\u3002",
|
|
2237
|
+
"\u5C40\u90E8\u4FEE\u6539\uFF1Aquote/generate <\u9879\u76EEID> --edit-image <\u56FE\u7247ID> --text <\u4FEE\u6539\u8981\u6C42> [--mask <\u9009\u533AID>]\u3002generate \u4ECD\u987B --quote-hash \u548C --yes\u3002",
|
|
2238
|
+
"model <\u9879\u76EEID> --model <\u6A21\u578B> | quality <\u9879\u76EEID> --quality <\u6863\u4F4D> | bind-product <\u9879\u76EEID> --product <\u4EA7\u54C1ID>",
|
|
2239
|
+
"upload <\u9879\u76EEID> --file <\u56FE\u7247\u6216\u6587\u6863> | attachments <\u9879\u76EEID> [--attachment-ids <ID,ID>] [--limit <\u6570\u91CF>] [--offset <\u504F\u79FB>]",
|
|
2240
|
+
"mask <\u9879\u76EEID> <\u56FE\u7247ID> --file <PNG\u9009\u533A> | save-edit <\u9879\u76EEID> <\u56FE\u7247ID> --file <\u7F16\u8F91\u540E\u56FE\u7247>",
|
|
2241
|
+
"download <\u9879\u76EEID> <\u56FE\u7247ID> [--out <\u6587\u4EF6>] | download <\u9879\u76EEID> --all --out <\u76EE\u5F55>",
|
|
2242
|
+
"download <\u9879\u76EEID> --attachment <\u9644\u4EF6ID> --out <\u6587\u4EF6>",
|
|
2243
|
+
"cancel <\u9879\u76EEID> --generation-order <\u8BA2\u5355ID>\uFF1A\u53D6\u6D88\u5C1A\u672A\u51BB\u7ED3\u8D39\u7528\u7684\u7B49\u5F85\u4F59\u989D\u8BA2\u5355\u3002",
|
|
2244
|
+
"\u521B\u5EFA\u3001\u6D88\u606F\u3001\u65B9\u6848\u66F4\u65B0\u3001\u751F\u6210\u548C\u56FE\u7247\u4FDD\u5B58\u4F7F\u7528 --idempotency-key\uFF1B\u9644\u4EF6\u548C\u9009\u533A\u652F\u6301\u8BF7\u6C42\u952E\u53CA\u5185\u5BB9\u53BB\u91CD\u3002retry/cancel \u6309\u539F\u8D44\u6E90\u72B6\u6001\u6267\u884C\u3002--timeout \u5355\u4F4D\u4E3A\u79D2\u3002",
|
|
2245
|
+
"\u9879\u76EE\u5E93\u662F\u5426\u5141\u8BB8\u5F52\u6863\u7531\u5BF9\u5E94\u80FD\u529B\u51B3\u5B9A\uFF1B\u5F53\u524D\u56FE\u6587\u9879\u76EE\u4E0D\u652F\u6301\u5F52\u6863\u3002"
|
|
2246
|
+
].join("\n")
|
|
2247
|
+
};
|
|
2248
|
+
var imageMimes = ["image/png", "image/jpeg", "image/webp"];
|
|
2249
|
+
var documentMimes = [...imageMimes, "application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "text/plain", "text/markdown"];
|
|
2250
|
+
function required2(value, label) {
|
|
2251
|
+
if (!value?.trim()) throw usageError(`\u8BF7\u63D0\u4F9B${label}`);
|
|
2252
|
+
return value.trim();
|
|
2253
|
+
}
|
|
2254
|
+
function indexes(value) {
|
|
2255
|
+
if (value === void 0) return void 0;
|
|
2256
|
+
const result = value.split(",").map((item) => Number(item.trim()));
|
|
2257
|
+
if (!result.length || result.some((item) => !Number.isInteger(item) || item < 1) || new Set(result).size !== result.length) throw usageError("--image-indexes \u5FC5\u987B\u662F\u4E0D\u91CD\u590D\u7684\u6B63\u6574\u6570\uFF0C\u4EE5\u9017\u53F7\u5206\u9694");
|
|
2258
|
+
return result;
|
|
2259
|
+
}
|
|
2260
|
+
function selection(context) {
|
|
2261
|
+
const editImage = textOption(context.values, "edit-image");
|
|
2262
|
+
const imageIndexes = indexes(textOption(context.values, "image-indexes"));
|
|
2263
|
+
if (editImage) {
|
|
2264
|
+
if (imageIndexes) throw usageError("\u5C40\u90E8\u4FEE\u6539\u4E0D\u80FD\u540C\u65F6\u6307\u5B9A --image-indexes");
|
|
2265
|
+
return { edit: {
|
|
2266
|
+
imageId: editImage,
|
|
2267
|
+
text: required2(textOption(context.values, "text"), " --text <\u4FEE\u6539\u8981\u6C42>"),
|
|
2268
|
+
...textOption(context.values, "mask") ? { maskId: textOption(context.values, "mask") } : {}
|
|
2269
|
+
} };
|
|
2059
2270
|
}
|
|
2060
|
-
|
|
2061
|
-
if (subcommand === "status") return status2(context, args[1]);
|
|
2062
|
-
if (subcommand === "quote") return quote2(context, args[1]);
|
|
2063
|
-
if (subcommand === "confirm") return confirm(context, args[1]);
|
|
2064
|
-
if (subcommand === "cancel") return cancel2(context, args[1]);
|
|
2065
|
-
if (subcommand === "download") return download2(context, args[1]);
|
|
2066
|
-
throw usageError(`\u4E0D\u8BA4\u8BC6\u7684\u5B50\u547D\u4EE4 ${subcommand}\uFF1Adrama \u7684\u5B50\u547D\u4EE4\u662F ${SUBCOMMANDS2}`);
|
|
2271
|
+
return imageIndexes ? { imageIndexes } : {};
|
|
2067
2272
|
}
|
|
2068
|
-
function
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2273
|
+
function lines(run2) {
|
|
2274
|
+
return [
|
|
2275
|
+
`\u56FE\u6587\u9879\u76EE\uFF1A${singleLine(run2.id)}`,
|
|
2276
|
+
`\u72B6\u6001\uFF1A${singleLine(run2.status)}`,
|
|
2277
|
+
`\u56FE\u7247\uFF1A${run2.images.length} \u5F20`,
|
|
2278
|
+
...run2.status === "quotable" ? [`\u67E5\u8BE2\u62A5\u4EF7\uFF1Abuke graphic quote ${run2.id}`] : [],
|
|
2279
|
+
...run2.messages.slice(-1).map((message2) => `${message2.role === "assistant" ? "\u56DE\u590D" : "\u6D88\u606F"}\uFF1A${singleLine(String(message2.text ?? ""))}`)
|
|
2280
|
+
];
|
|
2073
2281
|
}
|
|
2074
|
-
function
|
|
2075
|
-
return
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2282
|
+
async function wait(context, baseUrl, apiKey, initial) {
|
|
2283
|
+
if (context.values.wait !== true) return initial;
|
|
2284
|
+
const now = context.io.now ?? (() => /* @__PURE__ */ new Date());
|
|
2285
|
+
const until = now().getTime() + timeoutSecondsOf(context.values, DEFAULT_WAIT_TIMEOUT_MS / 1e3) * 1e3;
|
|
2286
|
+
let run2 = initial;
|
|
2287
|
+
return retainTaskOnError(() => taskRecovery("graphic", run2.id, run2.status, baseUrl), async () => {
|
|
2288
|
+
while (["preparing", "generating"].includes(run2.status)) {
|
|
2289
|
+
if (now().getTime() >= until) throw new CliError({ code: "CLI_WAIT_TIMEOUT", exitCode: EXIT.WAIT_TIMEOUT, message: `\u7B49\u5F85\u5DF2\u8FBE\u5230\u65F6\u9650\uFF0C\u9879\u76EE\u5F53\u524D\u72B6\u6001\u4E3A ${singleLine(run2.status)}\uFF1B\u53EF\u67E5\u8BE2\u539F\u9879\u76EE\u7EE7\u7EED\u7B49\u5F85\u3002` });
|
|
2290
|
+
await sleepFor(context.io, Math.min(1500, Math.max(until - now().getTime(), 1)));
|
|
2291
|
+
if (now().getTime() >= until) continue;
|
|
2292
|
+
run2 = await getGraphicRun(baseUrl, apiKey, run2.id, context.io);
|
|
2293
|
+
}
|
|
2294
|
+
if (["failed", "canceled"].includes(run2.status)) throw new CliError({ code: "CLI_TASK_FAILED", exitCode: EXIT.TASK_FAILED, message: `\u56FE\u6587\u4EFB\u52A1\u72B6\u6001\u4E3A ${run2.status}\uFF1B\u5DF2\u5B8C\u6210\u7684\u56FE\u7247\u4FDD\u7559\u5728\u539F\u9879\u76EE\u4E2D\u3002` });
|
|
2295
|
+
return run2;
|
|
2296
|
+
});
|
|
2081
2297
|
}
|
|
2082
|
-
function
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
exitCode: EXIT.WAIT_TIMEOUT,
|
|
2089
|
-
message: order2.status === "quotable" ? `\u7B49\u5F85\u5DF2\u8FBE\u5230\u65F6\u9650\u3002\u8BA2\u5355\u72B6\u6001\u4E3A quotable\uFF0C\u9700\u5B8C\u6210\u8D39\u7528\u786E\u8BA4\u540E\u624D\u80FD\u5F00\u59CB\u5236\u4F5C\u3002\u672C\u6B21\u67E5\u8BE2\u4E0D\u4F1A\u81EA\u52A8\u786E\u8BA4\uFF1B\u8BF7\u67E5\u8BE2\u62A5\u4EF7\u540E\u663E\u5F0F\u786E\u8BA4\u5F00\u62CD\u3002\u67E5\u8BE2\u539F\u8BA2\u5355\uFF1A${recovery.statusCommand}` : `\u7B49\u5F85\u5DF2\u8FBE\u5230\u65F6\u9650\uFF0C\u8BA2\u5355\u5F53\u524D\u72B6\u6001\u4E3A ${singleLine(order2.status)}\u3002\u67E5\u8BE2\u539F\u8BA2\u5355\uFF1A${recovery.statusCommand}\uFF1B\u6DFB\u52A0 --wait --timeout <\u79D2\u6570> \u53EF\u7EE7\u7EED\u7B49\u5F85\u3002`,
|
|
2090
|
-
recovery
|
|
2091
|
-
});
|
|
2298
|
+
async function uploadFile(path) {
|
|
2299
|
+
let bytes;
|
|
2300
|
+
try {
|
|
2301
|
+
bytes = await readFile2(path);
|
|
2302
|
+
} catch {
|
|
2303
|
+
throw usageError(`\u65E0\u6CD5\u8BFB\u53D6\u6587\u4EF6\uFF1A${path}`);
|
|
2092
2304
|
}
|
|
2093
|
-
if (
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2305
|
+
if (!bytes.length || bytes.length > 64 * 1024 * 1024) throw usageError("\u6587\u4EF6\u4E0D\u80FD\u4E3A\u7A7A\u4E14\u4E0D\u80FD\u8D85\u8FC7 64 MiB");
|
|
2306
|
+
return bytes;
|
|
2307
|
+
}
|
|
2308
|
+
async function graphic(context) {
|
|
2309
|
+
const { args, values, io, out } = context;
|
|
2310
|
+
timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3);
|
|
2311
|
+
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"];
|
|
2313
|
+
if (!known.includes(command)) throw usageError(`\u672A\u77E5\u56FE\u6587\u5B50\u547D\u4EE4\uFF1A${command}`);
|
|
2314
|
+
const id = ["create", "list", "templates"].includes(command) ? void 0 : required2(args[1], "\u56FE\u6587\u9879\u76EE ID");
|
|
2315
|
+
if (["quote", "generate"].includes(command)) {
|
|
2316
|
+
for (const option of ["expected-version", "expected-credits"]) {
|
|
2317
|
+
if (values[option] !== void 0) throw usageError(`graphic ${command} \u4E0D\u652F\u6301 --${option}\uFF1B\u8BF7\u4F7F\u7528\u5DF2\u67E5\u770B\u7684 --quote-hash \u7ED1\u5B9A\u62A5\u4EF7`);
|
|
2318
|
+
}
|
|
2102
2319
|
}
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2320
|
+
const selected = ["quote", "generate"].includes(command) ? selection(context) : {};
|
|
2321
|
+
const expectedQuoteHash = textOption(values, "quote-hash")?.toLowerCase();
|
|
2322
|
+
if (["quote", "generate"].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");
|
|
2323
|
+
if (command === "generate" && values.yes === true && expectedQuoteHash === void 0) throw usageError("\u786E\u8BA4\u751F\u6210\u5FC5\u987B\u63D0\u4F9B\u5DF2\u67E5\u770B\u7684 --quote-hash\uFF1B\u5148\u4E0D\u5E26 --yes \u67E5\u770B\u62A5\u4EF7");
|
|
2324
|
+
const key = idempotencyKeyOf(values);
|
|
2325
|
+
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2326
|
+
const path = id ? graphicPath(id) : "/api/open/v1/graphic/runs";
|
|
2327
|
+
if (["list", "templates"].includes(command)) {
|
|
2328
|
+
const result = 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", io)).body);
|
|
2329
|
+
const rows = result[command === "list" ? "runs" : "templates"] ?? [];
|
|
2330
|
+
out.result([...rows.map((row) => `${singleLine(String(row.id ?? row.slug))} ${singleLine(String(row.title ?? row.name ?? ""))} ${singleLine(String(row.status ?? ""))}`), ...typeof result.nextCursor === "string" ? [`\u4E0B\u4E00\u9875\uFF1Abuke graphic list --cursor ${singleLine(result.nextCursor)}`] : []], result);
|
|
2331
|
+
return;
|
|
2110
2332
|
}
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
`\
|
|
2123
|
-
|
|
2124
|
-
|
|
2333
|
+
if (command === "create") {
|
|
2334
|
+
const request = {
|
|
2335
|
+
productId: textOption(values, "product"),
|
|
2336
|
+
title: textOption(values, "title"),
|
|
2337
|
+
text: textOption(values, "text"),
|
|
2338
|
+
imageModel: textOption(values, "model"),
|
|
2339
|
+
aspectRatio: textOption(values, "aspect-ratio"),
|
|
2340
|
+
templateId: textOption(values, "template")
|
|
2341
|
+
};
|
|
2342
|
+
const initial = await retainSubmissionOnError("graphic", key, baseUrl, async () => graphicRun((await postJson(baseUrl, apiKey, path, request, key, io)).body));
|
|
2343
|
+
const run2 = await retainTaskOnError(() => ({ ...taskRecovery("graphic", initial.id, initial.status, baseUrl), idempotencyKey: key }), () => wait(context, baseUrl, apiKey, initial));
|
|
2344
|
+
out.result([...lines(run2), `\u5E42\u7B49\u952E\uFF1A${key}`], { run: run2, idempotencyKey: key });
|
|
2345
|
+
return;
|
|
2346
|
+
}
|
|
2347
|
+
if (command === "download") {
|
|
2348
|
+
const attachment = textOption(values, "attachment");
|
|
2349
|
+
if (values.all === true && (attachment || args[2])) throw usageError("--all \u4E0D\u80FD\u540C\u65F6\u6307\u5B9A\u56FE\u7247\u6216\u9644\u4EF6 ID");
|
|
2350
|
+
const results = [];
|
|
2351
|
+
if (values.all === true) {
|
|
2352
|
+
const directory = resolve(required2(textOption(values, "out"), " --out <\u76EE\u5F55>"));
|
|
2353
|
+
const run2 = await getGraphicRun(baseUrl, apiKey, id, io);
|
|
2354
|
+
if (!run2.images.length) throw usageError("\u8BE5\u9879\u76EE\u6682\u65E0\u53EF\u4E0B\u8F7D\u7684\u56FE\u7247");
|
|
2355
|
+
await mkdir2(directory, { recursive: true });
|
|
2356
|
+
for (const image of run2.images) {
|
|
2357
|
+
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`, io, { allowedMimeTypes: imageMimes, requireSha256: true });
|
|
2359
|
+
results.push(await saveDownload(join2(directory, basename(file.filename ?? `${imageId}.png`)), file.bytes));
|
|
2360
|
+
}
|
|
2361
|
+
} else {
|
|
2362
|
+
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`, io, { allowedMimeTypes: attachment ? documentMimes : imageMimes, requireSha256: !attachment });
|
|
2364
|
+
results.push(await saveDownload(resolve(textOption(values, "out") ?? basename(file.filename ?? `${imageId}.png`)), file.bytes));
|
|
2365
|
+
}
|
|
2366
|
+
out.result(results.map((result) => `\u5DF2\u4E0B\u8F7D\uFF1A${result.path}\uFF08${result.bytes} \u5B57\u8282\uFF09`), { downloads: results });
|
|
2367
|
+
return;
|
|
2368
|
+
}
|
|
2369
|
+
if (["quote", "generate"].includes(command)) {
|
|
2370
|
+
let current;
|
|
2371
|
+
let submitted = false;
|
|
2372
|
+
let accepted = false;
|
|
2373
|
+
try {
|
|
2374
|
+
current = await getGraphicRun(baseUrl, apiKey, id, io);
|
|
2375
|
+
const quote3 = await getGraphicQuote(baseUrl, apiKey, id, selected, key, io);
|
|
2376
|
+
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
|
+
if (command === "quote" || values.yes !== true) {
|
|
2378
|
+
out.result([
|
|
2379
|
+
`\u56FE\u6587\u9879\u76EE\uFF1A${id}`,
|
|
2380
|
+
`\u672C\u6B21\u751F\u6210\uFF1A${quote3.imageCount} \u5F20\uFF0C\u9884\u4F30 ${quote3.totalCredits} \u5E03`,
|
|
2381
|
+
`\u62A5\u4EF7\u54C8\u5E0C\uFF1A${quote3.quoteHash}`,
|
|
2382
|
+
`\u672C\u6B21\u672A\u63D0\u4EA4\u751F\u6210\uFF1B\u4FDD\u7559\u539F\u56FE\u7247\u9009\u62E9\u6216\u4FEE\u6539\u8981\u6C42\uFF0C\u786E\u8BA4\u8D39\u7528\u540E\u4F7F\u7528 --quote-hash ${quote3.quoteHash} --yes\u3002`
|
|
2383
|
+
], { quote: quote3, submitted: false });
|
|
2384
|
+
return;
|
|
2385
|
+
}
|
|
2386
|
+
submitted = true;
|
|
2387
|
+
const initial = graphicRun((await postJson(baseUrl, apiKey, `${path}/generate`, { ...selected, quoteHash: quote3.quoteHash, confirmed: true }, key, io)).body);
|
|
2388
|
+
current = initial;
|
|
2389
|
+
accepted = true;
|
|
2390
|
+
const run2 = await wait(context, baseUrl, apiKey, initial);
|
|
2391
|
+
out.result([...lines(run2), `\u5E42\u7B49\u952E\uFF1A${key}`], { run: run2, idempotencyKey: key });
|
|
2392
|
+
return;
|
|
2393
|
+
} catch (error) {
|
|
2394
|
+
const failure = toCliError(error);
|
|
2395
|
+
const rejected = failure.httpStatus !== void 0 && failure.httpStatus >= 400 && failure.httpStatus < 500 && failure.httpStatus !== 408;
|
|
2396
|
+
throw failure.withRecovery({
|
|
2397
|
+
...taskRecovery("graphic", id, current?.status, baseUrl),
|
|
2398
|
+
acceptance: current ? "confirmed" : "unknown",
|
|
2399
|
+
idempotencyKey: key,
|
|
2400
|
+
operation: "confirm",
|
|
2401
|
+
...failure.recovery,
|
|
2402
|
+
operationOutcome: accepted ? "accepted" : !submitted ? "not_submitted" : rejected ? "rejected" : "unknown"
|
|
2403
|
+
});
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
await retainTaskOnError(() => ({ ...taskRecovery("graphic", id, void 0, baseUrl), acceptance: "unknown", idempotencyKey: key }), async () => {
|
|
2407
|
+
let body;
|
|
2408
|
+
if (["status", "plan", "versions"].includes(command)) {
|
|
2409
|
+
const run2 = await wait(context, baseUrl, apiKey, await getGraphicRun(baseUrl, apiKey, id, io));
|
|
2410
|
+
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
|
+
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 out.result(lines(run2), { run: run2 });
|
|
2413
|
+
return;
|
|
2414
|
+
}
|
|
2415
|
+
if (command === "message") {
|
|
2416
|
+
const attachmentIds = textOption(values, "attachment-ids")?.split(",").map((item) => item.trim()).filter(Boolean);
|
|
2417
|
+
const message2 = textOption(values, "text");
|
|
2418
|
+
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, io)).body;
|
|
2420
|
+
} else if (command === "retry") body = (await postJson(baseUrl, apiKey, `${path}/messages/${encodeURIComponent(required2(args[2], "\u6D88\u606F ID"))}/retry`, {}, key, io)).body;
|
|
2421
|
+
else if (["model", "quality", "bind-product"].includes(command)) {
|
|
2422
|
+
const option = command === "bind-product" ? "product" : command;
|
|
2423
|
+
const field = command === "bind-product" ? "productId" : command === "model" ? "imageModel" : "quality";
|
|
2424
|
+
body = (await patchJson(baseUrl, apiKey, path, { [field]: required2(textOption(values, option), ` --${option}`) }, key, io)).body;
|
|
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, io)).body;
|
|
2426
|
+
else if (command === "attachments") {
|
|
2427
|
+
const params = new URLSearchParams();
|
|
2428
|
+
for (const id2 of textOption(values, "attachment-ids")?.split(",") ?? []) params.append("attachmentId", id2.trim());
|
|
2429
|
+
for (const name2 of ["limit", "offset"]) {
|
|
2430
|
+
const value = textOption(values, name2);
|
|
2431
|
+
if (value !== void 0) params.set(name2, value);
|
|
2432
|
+
}
|
|
2433
|
+
body = (await getJson(baseUrl, apiKey, `${path}/attachments${params.size ? `?${params}` : ""}`, io)).body;
|
|
2434
|
+
} else {
|
|
2435
|
+
const filename = required2(textOption(values, "file"), " --file <\u6587\u4EF6\u8DEF\u5F84>");
|
|
2436
|
+
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, io)).body;
|
|
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, io)).body;
|
|
2439
|
+
}
|
|
2440
|
+
const document = graphicDocument(body);
|
|
2441
|
+
if (document.run) {
|
|
2442
|
+
const run2 = await wait(context, baseUrl, apiKey, graphicRun(document));
|
|
2443
|
+
out.result([...lines(run2), `\u5E42\u7B49\u952E\uFF1A${key}`], { ...document, run: run2, idempotencyKey: key });
|
|
2444
|
+
} else out.result([`\u56FE\u6587\u9879\u76EE\uFF1A${id}`, `\u64CD\u4F5C\u5DF2\u5B8C\u6210\uFF1A${command}`, `\u5E42\u7B49\u952E\uFF1A${key}`, JSON.stringify(document)], { ...document, idempotencyKey: key });
|
|
2445
|
+
});
|
|
2125
2446
|
}
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2447
|
+
|
|
2448
|
+
// src/commands/web.ts
|
|
2449
|
+
import { createHash as createHash5, randomUUID as randomUUID2 } from "node:crypto";
|
|
2450
|
+
import { lstat as lstat4, readFile as readFile3 } from "node:fs/promises";
|
|
2451
|
+
import { basename as basename3 } from "node:path";
|
|
2452
|
+
|
|
2453
|
+
// src/web-operations.ts
|
|
2454
|
+
var WEB_OPERATIONS = [
|
|
2455
|
+
{ "id": "account.clearAgentMemory", "method": "DELETE", "path": "/api/me/agent-memory", "source": "web-src/src/lib/api.ts:2373", "group": "account", "description": "\u8D26\u53F7\uFF1A\u5220\u9664\u5F53\u524D\u8D26\u53F7 / \u5BFC\u6F14\u8BB0\u5FC6", "body": "json" },
|
|
2456
|
+
{ "id": "account.deleteAgentMemory", "method": "DELETE", "path": "/api/me/agent-memory/:id", "source": "web-src/src/lib/api.ts:2372", "group": "account", "description": "\u8D26\u53F7\uFF1A\u5220\u9664\u5F53\u524D\u8D26\u53F7 / \u5BFC\u6F14\u8BB0\u5FC6", "body": "json" },
|
|
2457
|
+
{ "id": "account.emailSettings", "method": "GET", "path": "/api/me/email", "source": "web-src/src/lib/api.ts:1551", "group": "account", "description": "\u8D26\u53F7\uFF1A\u67E5\u8BE2\u5F53\u524D\u8D26\u53F7 / \u90AE\u7BB1" },
|
|
2458
|
+
{ "id": "account.getAgentSettings", "method": "GET", "path": "/api/me/agent-settings", "source": "web-src/src/lib/api.ts:2367", "group": "account", "description": "\u8D26\u53F7\uFF1A\u67E5\u8BE2\u5F53\u524D\u8D26\u53F7 / \u5BFC\u6F14\u8BBE\u7F6E" },
|
|
2459
|
+
{ "id": "account.listAgentMemory", "method": "GET", "path": "/api/me/agent-memory", "source": "web-src/src/lib/api.ts:2370", "group": "account", "description": "\u8D26\u53F7\uFF1A\u67E5\u8BE2\u5F53\u524D\u8D26\u53F7 / \u5BFC\u6F14\u8BB0\u5FC6" },
|
|
2460
|
+
{ "id": "account.me", "method": "GET", "path": "/api/me", "source": "web-src/src/lib/api.ts:1699", "group": "account", "description": "\u8D26\u53F7\uFF1A\u67E5\u8BE2\u5F53\u524D\u8D26\u53F7" },
|
|
2461
|
+
{ "id": "account.requestEmailVerification", "method": "POST", "path": "/api/me/email/verification", "source": "web-src/src/lib/api.ts:1554", "group": "account", "description": "\u8D26\u53F7\uFF1A\u63D0\u4EA4\u90AE\u7BB1 / \u9A8C\u8BC1", "body": "json" },
|
|
2462
|
+
{ "id": "account.updateAgentSettings", "method": "PATCH", "path": "/api/me/agent-settings", "source": "web-src/src/lib/api.ts:2369", "group": "account", "description": "\u8D26\u53F7\uFF1A\u66F4\u65B0\u5F53\u524D\u8D26\u53F7 / \u5BFC\u6F14\u8BBE\u7F6E", "body": "json" },
|
|
2463
|
+
{ "id": "account.updateEmailPreferences", "method": "PATCH", "path": "/api/me/email/preferences", "source": "web-src/src/lib/api.ts:1557", "group": "account", "description": "\u8D26\u53F7\uFF1A\u66F4\u65B0\u90AE\u7BB1 / \u504F\u597D", "body": "json" },
|
|
2464
|
+
{ "id": "actors.actors", "method": "GET", "path": "/api/actors", "source": "web-src/src/lib/api.ts:2037", "group": "actors", "description": "\u4EBA\u7269\uFF1A\u67E5\u8BE2\u4EBA\u7269" },
|
|
2465
|
+
{ "id": "agent.agentAgreement", "method": "GET", "path": "/api/agent/agreement", "source": "web-src/src/lib/api.ts:1709", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u67E5\u8BE2\u63A8\u8350\u8BA1\u5212 / \u5408\u4F5C\u534F\u8BAE" },
|
|
2466
|
+
{ "id": "agent.agentApply", "method": "POST", "path": "/api/agent/apply", "source": "web-src/src/lib/api.ts:1714", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u63D0\u4EA4\u63A8\u8350\u8BA1\u5212 / \u5E94\u7528", "body": "json" },
|
|
2467
|
+
{ "id": "agent.agentEntries", "method": "GET", "path": "/api/agent/entries", "source": "web-src/src/lib/api.ts:1716", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u67E5\u8BE2\u63A8\u8350\u8BA1\u5212 / \u8BB0\u5F55" },
|
|
2468
|
+
{ "id": "agent.agentInvitees", "method": "GET", "path": "/api/agent/invitees", "source": "web-src/src/lib/api.ts:1715", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u67E5\u8BE2\u63A8\u8350\u8BA1\u5212 / \u9080\u8BF7\u8BB0\u5F55" },
|
|
2469
|
+
{ "id": "agent.agentMe", "method": "GET", "path": "/api/agent/me", "source": "web-src/src/lib/api.ts:1708", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u67E5\u8BE2\u63A8\u8350\u8BA1\u5212 / \u5F53\u524D\u8D26\u53F7" },
|
|
2470
|
+
{ "id": "agent.agentProgramBrief", "method": "GET", "path": "/api/agent/program-brief", "source": "web-src/src/lib/api.ts:1712", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u67E5\u8BE2\u63A8\u8350\u8BA1\u5212 / \u5408\u4F5C\u8BA1\u5212" },
|
|
2471
|
+
{ "id": "agent.agentWithdrawals", "method": "GET", "path": "/api/agent/withdrawals", "source": "web-src/src/lib/api.ts:1717", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u67E5\u8BE2\u63A8\u8350\u8BA1\u5212 / \u63D0\u73B0\u8BB0\u5F55" },
|
|
2472
|
+
{ "id": "agent.requestWithdrawal", "method": "POST", "path": "/api/agent/withdrawals", "source": "web-src/src/lib/api.ts:1719", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u63D0\u4EA4\u63A8\u8350\u8BA1\u5212 / \u63D0\u73B0\u8BB0\u5F55", "body": "json" },
|
|
2473
|
+
{ "id": "agent.saveAgentPayoutProfile", "method": "PUT", "path": "/api/agent/payout-profile", "source": "web-src/src/lib/api.ts:1721", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u8BBE\u7F6E\u63A8\u8350\u8BA1\u5212 / \u6536\u6B3E\u4FE1\u606F", "body": "json" },
|
|
2474
|
+
{ "id": "announcements.announcementArchive", "method": "GET", "path": "/api/announcements/archive", "source": "web-src/src/lib/api.ts:1536", "group": "announcements", "description": "\u516C\u544A\uFF1A\u67E5\u8BE2\u516C\u544A / \u5F52\u6863" },
|
|
2475
|
+
{ "id": "announcements.announcementReceipt", "method": "POST", "path": "/api/announcements/:id/receipt", "source": "web-src/src/lib/api.ts:1534", "group": "announcements", "description": "\u516C\u544A\uFF1A\u63D0\u4EA4\u516C\u544A / \u9605\u8BFB\u56DE\u6267", "body": "json" },
|
|
2476
|
+
{ "id": "announcements.liveAnnouncements", "method": "GET", "path": "/api/announcements/live", "source": "web-src/src/lib/api.ts:1531", "group": "announcements", "description": "\u516C\u544A\uFF1A\u67E5\u8BE2\u516C\u544A / \u5B9E\u65F6\u8FDB\u5EA6" },
|
|
2477
|
+
{ "id": "apiKeys.create", "method": "POST", "path": "/api/api-keys", "sensitiveOutput": true, "source": "web-src/src/lib/api-keys.ts:58", "group": "apiKeys", "description": "API\u5BC6\u94A5\uFF1A\u63D0\u4EA4API\u5BC6\u94A5", "body": "json", "exampleBody": { "name": "\u81EA\u52A8\u5316\u811A\u672C", "expiresInDays": 90 } },
|
|
2478
|
+
{ "id": "apiKeys.list", "method": "GET", "path": "/api/api-keys", "source": "web-src/src/lib/api-keys.ts:51", "group": "apiKeys", "description": "API\u5BC6\u94A5\uFF1A\u67E5\u8BE2API\u5BC6\u94A5" },
|
|
2479
|
+
{ "id": "apiKeys.revoke", "method": "POST", "path": "/api/api-keys/:id/revoke", "source": "web-src/src/lib/api-keys.ts:64", "group": "apiKeys", "description": "API\u5BC6\u94A5\uFF1A\u63D0\u4EA4API\u5BC6\u94A5 / \u64A4\u9500", "body": "json" },
|
|
2480
|
+
{ "id": "assets.registry", "method": "GET", "path": "/api/assets/registry", "source": "web-src/src/lib/api.ts:2043", "group": "assets", "description": "\u7D20\u6750\uFF1A\u67E5\u8BE2\u7D20\u6750 / \u7D20\u6750\u5E93" },
|
|
2481
|
+
{ "id": "auth.alipayStatus", "method": "GET", "path": "/api/auth/alipay/status", "source": "web-src/src/lib/api.ts:1690", "group": "auth", "description": "\u767B\u5F55\uFF1A\u67E5\u8BE2\u652F\u4ED8\u5B9D\u767B\u5F55 / \u72B6\u6001", "public": true },
|
|
2482
|
+
{ "id": "auth.changePassword", "method": "POST", "path": "/api/auth/password", "source": "web-src/src/lib/api.ts:1702", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u8BA4\u8BC1 / \u5BC6\u7801", "body": "json" },
|
|
2483
|
+
{ "id": "auth.completeAlipayLogin", "method": "POST", "path": "/api/auth/alipay/complete", "source": "web-src/src/lib/api.ts:1692", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u652F\u4ED8\u5B9D\u767B\u5F55 / \u5B8C\u6210\u767B\u5F55", "body": "json", "public": true, "sessionResponse": true },
|
|
2484
|
+
{ "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
|
+
{ "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
|
+
{ "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
|
+
{ "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
|
+
{ "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
|
+
{ "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 },
|
|
2491
|
+
{ "id": "auth.sendRegistrationSms", "method": "POST", "path": "/api/auth/sms/register-code", "source": "web-src/src/lib/api.ts:1679", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u77ED\u4FE1 / \u6CE8\u518C\u9A8C\u8BC1\u7801", "body": "json", "public": true },
|
|
2492
|
+
{ "id": "budget.budget", "method": "GET", "path": "/api/budget", "source": "web-src/src/lib/api.ts:3270", "group": "budget", "description": "\u8D26\u672C\uFF1A\u67E5\u8BE2\u8D26\u6237\u989D\u5EA6" },
|
|
2493
|
+
{ "id": "budget.budgetEntries", "method": "GET", "path": "/api/budget/entries", "source": "web-src/src/lib/api.ts:3272", "group": "budget", "description": "\u8D26\u672C\uFF1A\u67E5\u8BE2\u8D26\u6237\u989D\u5EA6 / \u8BB0\u5F55" },
|
|
2494
|
+
{ "id": "budget.budgetTransactions", "method": "GET", "path": "/api/budget/transactions", "source": "web-src/src/lib/api.ts:3277", "group": "budget", "description": "\u8D26\u672C\uFF1A\u67E5\u8BE2\u8D26\u6237\u989D\u5EA6 / \u8D26\u5355" },
|
|
2495
|
+
{ "id": "budget.projectCosts", "method": "GET", "path": "/api/budget/by-project", "source": "web-src/src/lib/api.ts:3550", "group": "budget", "description": "\u8D26\u672C\uFF1A\u67E5\u8BE2\u8D26\u6237\u989D\u5EA6 / \u6309\u9879\u76EE\u6C47\u603B" },
|
|
2496
|
+
{ "id": "commercialAds.recommendCommercialAds", "method": "POST", "path": "/api/commercial-ads/recommend", "source": "web-src/src/lib/api.ts:2824", "group": "commercialAds", "description": "\u5E7F\u544A\u63A8\u8350\uFF1A\u63D0\u4EA4\u5E7F\u544A / \u63A8\u8350", "body": "json" },
|
|
2497
|
+
{ "id": "delivery.accept", "method": "POST", "path": "/api/delivery/shared/:token/accepted", "source": "web-src/src/lib/delivery-api.ts:348", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u63D0\u4EA4\u5206\u4EAB\u4EA4\u4ED8 / \u4EA4\u4ED8\u9A8C\u6536", "body": "json", "public": true },
|
|
2498
|
+
{ "id": "delivery.accept.accepted", "method": "POST", "path": "/api/delivery/packages/:id/accepted", "source": "web-src/src/lib/delivery-api.ts:348", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u63D0\u4EA4\u4EA4\u4ED8\u5305 / \u4EA4\u4ED8\u9A8C\u6536", "body": "json" },
|
|
2499
|
+
{ "id": "delivery.comment", "method": "POST", "path": "/api/delivery/shared/:token/comments", "source": "web-src/src/lib/delivery-api.ts:346", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u63D0\u4EA4\u5206\u4EAB\u4EA4\u4ED8 / \u8BC4\u8BBA", "body": "json", "public": true },
|
|
2500
|
+
{ "id": "delivery.comments", "method": "GET", "path": "/api/delivery/packages/:id/comments", "source": "web-src/src/lib/delivery-api.ts:338", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8\u5305 / \u8BC4\u8BBA" },
|
|
2501
|
+
{ "id": "delivery.create", "method": "POST", "path": "/api/delivery/packages", "source": "web-src/src/lib/delivery-api.ts:335", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u63D0\u4EA4\u4EA4\u4ED8 / \u4EA4\u4ED8\u5305", "body": "json", "idempotencyBodyKey": "requestKey", "replaySafe": true, "exampleBody": { "sources": [{ "kind": "episode", "sourceId": "\u9879\u76EE\u7F16\u53F7", "selectedFileIds": ["\u4ECEdelivery.source\u54CD\u5E94\u7684files\u4E2D\u9009\u53D6\u6587\u4EF6id"], "expectedFingerprint": "\u4ECEdelivery.source\u8BFB\u53D6" }], "scope": "full", "title": "\u4EA4\u4ED8\u8D44\u6599" } },
|
|
2502
|
+
{ "id": "delivery.createShare", "method": "POST", "path": "/api/delivery/packages/:id/shares", "sensitiveOutput": true, "source": "web-src/src/lib/delivery-api.ts:340", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u63D0\u4EA4\u4EA4\u4ED8\u5305 / \u5206\u4EAB\u8BB0\u5F55", "body": "json", "exampleBody": { "allowPreview": true, "allowDownload": true, "allowComment": true, "expiresInDays": 7 } },
|
|
2503
|
+
{ "id": "delivery.download", "method": "GET", "path": "/api/delivery/packages/:id/download", "source": "apps/api/src/http/routes/delivery.ts:194", "group": "delivery", "description": "\u4E0B\u8F7D\u5B8C\u6574\u4EA4\u4ED8\u5305" },
|
|
2504
|
+
{ "id": "delivery.downloadFile", "method": "POST", "path": "/api/delivery/packages/:id/download-ticket", "sensitiveOutput": true, "source": "web-src/src/lib/delivery-api.ts:358", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u63D0\u4EA4\u4EA4\u4ED8\u5305 / \u4E0B\u8F7D\u51ED\u8BC1", "body": "json" },
|
|
2505
|
+
{ "id": "delivery.downloadShared", "method": "GET", "path": "/api/delivery/shared/:token/download", "source": "apps/api/src/http/routes/delivery.ts:267", "group": "delivery", "description": "\u4E0B\u8F7D\u5206\u4EAB\u4EA4\u4ED8\u5305", "public": true },
|
|
2506
|
+
{ "id": "delivery.file", "method": "GET", "path": "/api/delivery/shared/:token/files/:fileId", "source": "web-src/src/lib/delivery-api.ts:352", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u5206\u4EAB\u4EA4\u4ED8 / \u6587\u4EF6", "public": true },
|
|
2507
|
+
{ "id": "delivery.file.files", "method": "GET", "path": "/api/delivery/packages/:id/files/:fileId", "source": "web-src/src/lib/delivery-api.ts:352", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8\u5305 / \u6587\u4EF6" },
|
|
2508
|
+
{ "id": "delivery.list", "method": "GET", "path": "/api/delivery/packages", "source": "web-src/src/lib/delivery-api.ts:318", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8 / \u4EA4\u4ED8\u5305" },
|
|
2509
|
+
{ "id": "delivery.options", "method": "GET", "path": "/api/delivery/source-options", "source": "web-src/src/lib/delivery-api.ts:309", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8 / \u6765\u6E90\u9009\u9879" },
|
|
2510
|
+
{ "id": "delivery.package", "method": "GET", "path": "/api/delivery/packages/:id", "source": "web-src/src/lib/delivery-api.ts:336", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8 / \u4EA4\u4ED8\u5305" },
|
|
2511
|
+
{ "id": "delivery.revokeShare", "method": "DELETE", "path": "/api/delivery/shares/:id", "source": "web-src/src/lib/delivery-api.ts:342", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u5220\u9664\u4EA4\u4ED8 / \u5206\u4EAB\u8BB0\u5F55", "body": "json" },
|
|
2512
|
+
{ "id": "delivery.shared", "method": "GET", "path": "/api/delivery/shared/:token", "source": "web-src/src/lib/delivery-api.ts:344", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8 / \u5206\u4EAB\u4EA4\u4ED8", "public": true },
|
|
2513
|
+
{ "id": "delivery.shares", "method": "GET", "path": "/api/delivery/packages/:id/shares", "source": "web-src/src/lib/delivery-api.ts:337", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8\u5305 / \u5206\u4EAB\u8BB0\u5F55" },
|
|
2514
|
+
{ "id": "delivery.source", "method": "GET", "path": "/api/delivery/sources/:kind/:sourceId", "source": "web-src/src/lib/delivery-api.ts:313", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8 / \u6765\u6E90" },
|
|
2515
|
+
{ "id": "drama.acceptAdvice", "method": "POST", "path": "/api/projects/:id/customer-quality/actions", "source": "apps/api/src/http/routes/projects.ts:4149", "group": "drama", "description": "\u7EE7\u7EED\u4F7F\u7528\u5F53\u524D\u6587\u7A3F", "body": "json" },
|
|
2516
|
+
{ "id": "drama.adoptStorySpeech", "method": "POST", "path": "/api/projects/:projectId/director/speech/tracks/:trackId/adopt", "source": "web-src/src/lib/api.ts:2582", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u97F3\u8F68 / \u91C7\u7528", "body": "json" },
|
|
2517
|
+
{ "id": "drama.approveStorySpeech", "method": "POST", "path": "/api/projects/:projectId/director/speech/tracks/:trackId/approve", "source": "web-src/src/lib/api.ts:2578", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u97F3\u8F68 / \u786E\u8BA4", "body": "json" },
|
|
2518
|
+
{ "id": "drama.approveTopicScript", "method": "POST", "path": "/api/projects/:id/topic/script/approve", "source": "web-src/src/lib/api.ts:2571", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u7A3F\u4EF6 / \u786E\u8BA4", "body": "json" },
|
|
2519
|
+
{ "id": "drama.assetGate", "method": "GET", "path": "/api/projects/:id/asset-gate", "source": "web-src/src/lib/api.ts:3436", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u7D20\u6750\u68C0\u67E5" },
|
|
2520
|
+
{ "id": "drama.bindStoryAssets", "method": "POST", "path": "/api/projects/:id/story-bindings", "source": "web-src/src/lib/api.ts:3213", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u4EBA\u7269\u573A\u666F\u7ED1\u5B9A", "body": "json" },
|
|
2521
|
+
{ "id": "drama.cancelProjectGeneration", "method": "POST", "path": "/api/projects/:id/cancel-generation", "source": "web-src/src/lib/api.ts:3503", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u505C\u6B62\u5236\u4F5C", "body": "json" },
|
|
2522
|
+
{ "id": "drama.cancelStoryDirectorAutoStart", "method": "POST", "path": "/api/projects/:projectId/director/auto-start/cancel", "source": "web-src/src/lib/api.ts:2682", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u81EA\u52A8\u5F00\u62CD / \u53D6\u6D88", "body": "json" },
|
|
2523
|
+
{ "id": "drama.capability", "method": "GET", "path": "/api/projects/:projectId/outputs/:outputId/subtitles/capability", "source": "web-src/src/lib/subtitle-version-api.ts:35", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5B57\u5E55 / \u80FD\u529B" },
|
|
2524
|
+
{ "id": "drama.casting", "method": "POST", "path": "/api/projects/:id/casting", "source": "web-src/src/lib/api.ts:3198", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u9009\u89D2", "body": "json" },
|
|
2525
|
+
{ "id": "drama.clearShotVersionSelection", "method": "DELETE", "path": "/api/projects/:id/shots/:shotId/version-selection", "source": "web-src/src/lib/api.ts:3545", "group": "drama", "description": "\u77ED\u5267\uFF1A\u5220\u9664\u955C\u5934 / \u955C\u5934\u9009\u7248", "body": "json" },
|
|
2526
|
+
{ "id": "drama.compareScreenplayVersions", "method": "GET", "path": "/api/projects/:id/screenplay/versions/compare", "source": "web-src/src/lib/api.ts:3235", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u7248\u672C / \u5BF9\u6BD4" },
|
|
2527
|
+
{ "id": "drama.confirmProductionRedo", "method": "POST", "path": "/api/projects/:id/production/redo", "source": "web-src/src/lib/api.ts:3493", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5236\u4F5C\u8FDB\u5EA6 / \u91CD\u65B0\u5236\u4F5C", "body": "json" },
|
|
2528
|
+
{ "id": "drama.confirmStitch", "method": "POST", "path": "/api/projects/:id/production/postprocess/stitch-confirm", "source": "web-src/src/lib/api.ts:3474", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u540E\u671F\u5236\u4F5C / \u786E\u8BA4\u62FC\u63A5", "body": "json" },
|
|
2529
|
+
{ "id": "drama.confirmStoryDirector", "method": "POST", "path": "/api/projects/:projectId/director/confirm", "source": "web-src/src/lib/api.ts:2676", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5BFC\u6F14 / \u786E\u8BA4", "body": "json" },
|
|
2530
|
+
{ "id": "drama.confirmStorySpeech", "method": "POST", "path": "/api/projects/:projectId/director/speech/quotes/:quoteId/confirm", "source": "web-src/src/lib/api.ts:2576", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u62A5\u4EF7 / \u786E\u8BA4", "body": "json" },
|
|
2531
|
+
{ "id": "drama.confirmStorySpeechLegacySource", "method": "POST", "path": "/api/projects/:projectId/director/speech/legacy-source/confirm", "source": "web-src/src/lib/api.ts:2586", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5386\u53F2\u6765\u6E90 / \u786E\u8BA4", "body": "json" },
|
|
2532
|
+
{ "id": "drama.create", "method": "POST", "path": "/api/projects", "source": "web-src/src/lib/api.ts:3132", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE", "body": "json", "exampleBody": { "productId": "\u5546\u54C1\u7F16\u53F7", "genreId": "family", "productionProfile": { "durationKey": "30s" }, "brief": { "description": "\u56F4\u7ED5\u8FD9\u4EF6\u5546\u54C1\u521B\u4F5C\u751F\u6D3B\u77ED\u5267" } } },
|
|
2533
|
+
{ "id": "drama.createProductionSignoff", "method": "POST", "path": "/api/projects/:id/production-signoff", "source": "web-src/src/lib/api.ts:3345", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u5F00\u62CD\u786E\u8BA4", "body": "json" },
|
|
2534
|
+
{ "id": "drama.createTopicProject", "method": "POST", "path": "/api/projects/topic", "source": "web-src/src/lib/api.ts:2568", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u9009\u9898", "body": "json" },
|
|
2535
|
+
{ "id": "drama.customerQuality", "method": "GET", "path": "/api/projects/:id/customer-quality", "source": "web-src/src/lib/api.ts:3306", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u521B\u4F5C\u5EFA\u8BAE" },
|
|
2536
|
+
{ "id": "drama.deleteProject", "method": "DELETE", "path": "/api/projects/:id", "source": "web-src/src/lib/api.ts:3123", "group": "drama", "description": "\u77ED\u5267\uFF1A\u5220\u9664\u9879\u76EE", "body": "json" },
|
|
2537
|
+
{ "id": "drama.downloadEdit", "method": "GET", "path": "/api/projects/:projectId/director/edits/:editId/download", "source": "apps/api/src/http/routes/story-director.ts:52", "group": "drama", "description": "\u4E0B\u8F7D\u77ED\u5267\u526A\u8F91\u7248" },
|
|
2538
|
+
{ "id": "drama.downloadEditSubtitles", "method": "GET", "path": "/api/projects/:projectId/director/edits/:editId/subtitles", "source": "apps/api/src/http/routes/story-director.ts:62", "group": "drama", "description": "\u4E0B\u8F7D\u77ED\u5267\u526A\u8F91\u5B57\u5E55" },
|
|
2539
|
+
{ "id": "drama.downloadFinal", "method": "GET", "path": "/api/exports/:projectId/download", "source": "apps/api/src/http/routes/exports.ts:26", "group": "drama", "description": "\u4E0B\u8F7D\u77ED\u5267\u5B8C\u6574\u6210\u7247" },
|
|
2540
|
+
{ "id": "drama.downloadHistory", "method": "GET", "path": "/api/projects/:projectId/director/history-sources/:sourceEpisodeOutputId/download", "source": "apps/api/src/http/routes/story-director.ts:98", "group": "drama", "description": "\u4E0B\u8F7D\u5386\u53F2\u6210\u7247" },
|
|
2541
|
+
{ "id": "drama.downloadSubtitleFile", "method": "GET", "path": "/api/exports/:projectId/subtitles.srt", "source": "web-src/src/lib/subtitle-download.ts:9", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u4EA4\u4ED8\u4FE1\u606F / \u5B57\u5E55\u6587\u4EF6" },
|
|
2542
|
+
{ "id": "drama.downloadSubtitleVersion", "method": "GET", "path": "/api/projects/:projectId/outputs/:outputId/subtitles/render/:taskId/video", "source": "apps/api/src/http/routes/film-subtitles.ts:40", "group": "drama", "description": "\u4E0B\u8F7D\u5B57\u5E55\u6210\u7247" },
|
|
2543
|
+
{ "id": "drama.draft", "method": "POST", "path": "/api/projects/:projectId/outputs/:outputId/subtitles/draft", "source": "web-src/src/lib/subtitle-version-api.ts:39", "group": "drama", "description": '\u77ED\u5267\uFF1A\u51C6\u5907\u5B57\u5E55\u8349\u7A3F\uFF1B\u8FD4\u56DE canRetry \u65F6\u53EF\u7528 --query JSON \u6587\u4EF6\u4F20 {"retry":1} \u91CD\u8BD5\u51C6\u5907', "body": "json" },
|
|
2544
|
+
{ "id": "drama.exports", "method": "GET", "path": "/api/exports/:projectId", "source": "web-src/src/lib/api.ts:3553", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u4EA4\u4ED8\u4FE1\u606F" },
|
|
2545
|
+
{ "id": "drama.generate", "method": "POST", "path": "/api/projects/:id/generate", "source": "web-src/src/lib/api.ts:3445", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u5236\u4F5C", "body": "json", "businessHeaders": { "prefer": { "default": "respond-async", "values": ["respond-async"] } } },
|
|
2546
|
+
{ "id": "drama.generateStoryboard", "method": "POST", "path": "/api/projects/:id/storyboard", "source": "web-src/src/lib/api.ts:3225", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u6545\u4E8B\u677F", "body": "json" },
|
|
2547
|
+
{ "id": "drama.getProject", "method": "GET", "path": "/api/projects/:id", "source": "web-src/src/lib/api.ts:3122", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE" },
|
|
2548
|
+
{ "id": "drama.getStoryDirector", "method": "GET", "path": "/api/projects/:projectId/director", "source": "web-src/src/lib/api.ts:2608", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u5BFC\u6F14" },
|
|
2549
|
+
{ "id": "drama.getStoryDirectorDoc", "method": "GET", "path": "/api/projects/:projectId/director/doc", "source": "web-src/src/lib/api.ts:2663", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5BFC\u6F14 / \u6587\u7A3F" },
|
|
2550
|
+
{ "id": "drama.getStoryDirectorSpecQuotes", "method": "GET", "path": "/api/projects/:projectId/director/spec-quotes", "source": "web-src/src/lib/api.ts:2704", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5BFC\u6F14 / \u89C4\u683C\u62A5\u4EF7" },
|
|
2551
|
+
{ "id": "drama.getStoryHistoricalSources", "method": "GET", "path": "/api/projects/:projectId/director/history-sources", "source": "web-src/src/lib/api.ts:2584", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5BFC\u6F14 / \u5386\u53F2\u6210\u7247" },
|
|
2552
|
+
{ "id": "drama.getStorySpeech", "method": "GET", "path": "/api/projects/:projectId/director/speech", "source": "web-src/src/lib/api.ts:2572", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5BFC\u6F14 / \u914D\u97F3" },
|
|
2553
|
+
{ "id": "drama.getStorySpeechAdoptions", "method": "GET", "path": "/api/projects/:projectId/director/speech/adoptions", "source": "web-src/src/lib/api.ts:2589", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u914D\u97F3 / \u91C7\u7528\u8BB0\u5F55" },
|
|
2554
|
+
{ "id": "drama.getStorySpeechAudio", "method": "GET", "path": "/api/projects/:projectId/director/speech/tracks/:trackId/audio", "source": "web-src/src/lib/api.ts:2591", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u97F3\u8F68 / \u97F3\u9891" },
|
|
2555
|
+
{ "id": "drama.getStorySpeechTaskAudio", "method": "GET", "path": "/api/projects/:projectId/director/speech/tasks/:taskId/audio", "source": "web-src/src/lib/api.ts:2593", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u4EFB\u52A1 / \u97F3\u9891" },
|
|
2556
|
+
{ "id": "drama.getStoryVideoEditSources", "method": "GET", "path": "/api/projects/:projectId/director/edit-sources", "source": "web-src/src/lib/api.ts:2583", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5BFC\u6F14 / \u526A\u8F91\u7D20\u6750" },
|
|
2557
|
+
{ "id": "drama.getTopicProject", "method": "GET", "path": "/api/projects/:id/topic", "source": "web-src/src/lib/api.ts:2569", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u9009\u9898" },
|
|
2558
|
+
{ "id": "drama.importStorySpeechRecordings", "method": "POST", "path": "/api/projects/:projectId/director/speech/import", "source": "web-src/src/lib/api.ts:2598", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u914D\u97F3 / \u5BFC\u5165", "body": "json" },
|
|
2559
|
+
{ "id": "drama.inspectStoryDirectorAttachments", "method": "GET", "path": "/api/projects/:projectId/director/attachments", "source": "web-src/src/lib/api.ts:2649", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5BFC\u6F14 / \u9644\u4EF6" },
|
|
2560
|
+
{ "id": "drama.jobs", "method": "GET", "path": "/api/projects/:id/jobs", "source": "web-src/src/lib/api.ts:3455", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u4EFB\u52A1" },
|
|
2561
|
+
{ "id": "drama.ledger", "method": "GET", "path": "/api/projects/:id/ledger", "source": "web-src/src/lib/api.ts:3551", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u8D26\u672C" },
|
|
2562
|
+
{ "id": "drama.list", "method": "GET", "path": "/api/projects", "source": "web-src/src/lib/api.ts:2882", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE" },
|
|
2563
|
+
{ "id": "drama.playEdit", "method": "GET", "path": "/api/projects/:projectId/director/edits/:editId/video", "source": "apps/api/src/http/routes/story-director.ts:52", "group": "drama", "description": "\u8BFB\u53D6\u77ED\u5267\u526A\u8F91\u7248" },
|
|
2564
|
+
{ "id": "drama.playHistory", "method": "GET", "path": "/api/projects/:projectId/director/history-sources/:sourceEpisodeOutputId/video", "source": "apps/api/src/http/routes/story-director.ts:98", "group": "drama", "description": "\u8BFB\u53D6\u5386\u53F2\u6210\u7247" },
|
|
2565
|
+
{ "id": "drama.postStoryDirectorMessage", "method": "POST", "path": "/api/projects/:projectId/director/messages", "source": "web-src/src/lib/api.ts:2610", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5BFC\u6F14 / \u5BF9\u8BDD", "body": "json", "exampleBody": { "text": "\u4FDD\u7559\u73B0\u6709\u60C5\u8282\uFF0C\u53EA\u8C03\u6574\u5F00\u573A\u5BF9\u767D" } },
|
|
2566
|
+
{ "id": "drama.production", "method": "GET", "path": "/api/projects/:id/production", "source": "web-src/src/lib/api.ts:3457", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u5236\u4F5C\u8FDB\u5EA6" },
|
|
2567
|
+
{ "id": "drama.productionRedoQuote", "method": "POST", "path": "/api/projects/:id/production/redo/quote", "source": "web-src/src/lib/api.ts:3490", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u91CD\u65B0\u5236\u4F5C / \u62A5\u4EF7", "body": "json" },
|
|
2568
|
+
{ "id": "drama.productionSignoff", "method": "GET", "path": "/api/projects/:id/production-signoff", "source": "web-src/src/lib/api.ts:3298", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u5F00\u62CD\u786E\u8BA4" },
|
|
2569
|
+
{ "id": "drama.quote", "method": "POST", "path": "/api/projects/:id/quote", "source": "web-src/src/lib/api.ts:3295", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u62A5\u4EF7", "body": "json" },
|
|
2570
|
+
{ "id": "drama.quoteShotRetry", "method": "GET", "path": "/api/projects/:id/shots/:shotId/retry-quote", "source": "web-src/src/lib/api.ts:3521", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u955C\u5934 / \u91CD\u62CD\u62A5\u4EF7" },
|
|
2571
|
+
{ "id": "drama.quoteStorySpeech", "method": "POST", "path": "/api/projects/:projectId/director/speech/quotes", "source": "web-src/src/lib/api.ts:2574", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u914D\u97F3 / \u62A5\u4EF7", "body": "json" },
|
|
2572
|
+
{ "id": "drama.refineScreenplayScene", "method": "POST", "path": "/api/projects/:id/screenplay/scenes/:sceneNo/refine", "source": "web-src/src/lib/api.ts:3255", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u573A\u666F / \u5C40\u90E8\u4FEE\u6539", "body": "json" },
|
|
2573
|
+
{ "id": "drama.render", "method": "POST", "path": "/api/projects/:projectId/outputs/:outputId/subtitles/render", "source": "web-src/src/lib/subtitle-version-api.ts:41", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5B57\u5E55 / \u5236\u4F5C\u5305\u88C5", "body": "json" },
|
|
2574
|
+
{ "id": "drama.restoreScreenplayVersion", "method": "POST", "path": "/api/projects/:id/screenplay/versions/:docId/restore", "source": "web-src/src/lib/api.ts:3243", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u7248\u672C / \u6062\u590D", "body": "json", "exampleBody": { "expectedCurrentDocumentId": "\u5F53\u524D\u6587\u7A3F\u7F16\u53F7", "productionEpoch": 0 } },
|
|
2575
|
+
{ "id": "drama.resumeProductionPostprocess", "method": "POST", "path": "/api/projects/:id/production/postprocess/resume", "source": "web-src/src/lib/api.ts:3460", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u540E\u671F\u5236\u4F5C / \u7EE7\u7EED", "body": "json" },
|
|
2576
|
+
{ "id": "drama.retryShotGeneration", "method": "POST", "path": "/api/projects/:id/shots/:shotId/retry-generation", "source": "web-src/src/lib/api.ts:3513", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u955C\u5934 / \u91CD\u65B0\u751F\u6210", "body": "json" },
|
|
2577
|
+
{ "id": "drama.revokeStorySpeech", "method": "POST", "path": "/api/projects/:projectId/director/speech/tracks/:trackId/revoke", "source": "web-src/src/lib/api.ts:2580", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u97F3\u8F68 / \u64A4\u9500", "body": "json" },
|
|
2578
|
+
{ "id": "drama.save", "method": "PUT", "path": "/api/projects/:projectId/outputs/:outputId/subtitles/draft/:draftId", "source": "web-src/src/lib/subtitle-version-api.ts:39", "group": "drama", "description": "\u77ED\u5267\uFF1A\u8BBE\u7F6E\u5B57\u5E55 / \u8349\u7A3F", "body": "json" },
|
|
2579
|
+
{ "id": "drama.saveStoryDirectorAttachmentFile", "method": "GET", "path": "/api/projects/:projectId/director/attachments/:attachmentId/file", "source": "web-src/src/lib/api.ts:2655", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9644\u4EF6 / \u6587\u4EF6" },
|
|
2580
|
+
{ "id": "drama.screenplay", "method": "POST", "path": "/api/projects/:id/screenplay", "source": "web-src/src/lib/api.ts:3227", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u5267\u672C", "body": "json" },
|
|
2581
|
+
{ "id": "drama.screenplayVersion", "method": "GET", "path": "/api/projects/:id/screenplay/versions/:docId", "source": "web-src/src/lib/api.ts:3232", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5267\u672C / \u7248\u672C" },
|
|
2582
|
+
{ "id": "drama.screenplayVersions", "method": "GET", "path": "/api/projects/:id/screenplay/versions", "source": "web-src/src/lib/api.ts:3230", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5267\u672C / \u7248\u672C" },
|
|
2583
|
+
{ "id": "drama.selectScriptAsset", "method": "POST", "path": "/api/projects/:id/script-asset", "source": "web-src/src/lib/api.ts:3262", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u6545\u4E8B\u8DEF\u7EBF", "body": "json" },
|
|
2584
|
+
{ "id": "drama.selectShotVersion", "method": "PUT", "path": "/api/projects/:id/shots/:shotId/version-selection", "source": "web-src/src/lib/api.ts:3534", "group": "drama", "description": "\u77ED\u5267\uFF1A\u8BBE\u7F6E\u955C\u5934 / \u955C\u5934\u9009\u7248", "body": "json" },
|
|
2585
|
+
{ "id": "drama.setStoryDirectorProductionChoice", "method": "POST", "path": "/api/projects/:projectId/director/production-choice", "source": "web-src/src/lib/api.ts:2698", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5BFC\u6F14 / \u5236\u4F5C\u89C4\u683C", "body": "json" },
|
|
2586
|
+
{ "id": "drama.shotPlan", "method": "POST", "path": "/api/projects/:id/shot-plan", "source": "web-src/src/lib/api.ts:3219", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u5206\u955C\u65B9\u6848", "body": "json" },
|
|
2587
|
+
{ "id": "drama.stitchDecision", "method": "POST", "path": "/api/projects/:id/production/postprocess/stitch-decision", "source": "web-src/src/lib/api.ts:3467", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u540E\u671F\u5236\u4F5C / \u62FC\u63A5\u65B9\u6848", "body": "json" },
|
|
2588
|
+
{ "id": "drama.stopStoryDirector", "method": "POST", "path": "/api/projects/:projectId/director/stop", "source": "web-src/src/lib/api.ts:2601", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5BFC\u6F14 / \u505C\u6B62\u56DE\u590D", "body": "json" },
|
|
2589
|
+
{ "id": "drama.storyboard", "method": "GET", "path": "/api/projects/:id/storyboard", "source": "web-src/src/lib/api.ts:3223", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u6545\u4E8B\u677F" },
|
|
2590
|
+
{ "id": "drama.streamStoryDirectorMessage", "method": "POST", "path": "/api/projects/:projectId/director/messages/stream", "source": "web-src/src/lib/api.ts:2623", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5BF9\u8BDD / \u5B9E\u65F6\u5BF9\u8BDD", "body": "json" },
|
|
2591
|
+
{ "id": "drama.switchProjectToLiveAction", "method": "PATCH", "path": "/api/projects/:id/production-profile", "source": "web-src/src/lib/api.ts:3139", "group": "drama", "description": "\u77ED\u5267\uFF1A\u66F4\u65B0\u9879\u76EE / \u5236\u4F5C\u89C4\u683C", "body": "json" },
|
|
2592
|
+
{ "id": "drama.task", "method": "GET", "path": "/api/projects/:projectId/outputs/:outputId/subtitles/render/:taskId", "source": "web-src/src/lib/subtitle-version-api.ts:43", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5B57\u5E55 / \u5236\u4F5C\u5305\u88C5" },
|
|
2593
|
+
{ "id": "drama.updatePlacementIntensity", "method": "PATCH", "path": "/api/projects/:id/placement-intensity", "source": "web-src/src/lib/api.ts:3152", "group": "drama", "description": "\u77ED\u5267\uFF1A\u66F4\u65B0\u9879\u76EE / \u690D\u5165\u7A0B\u5EA6", "body": "json" },
|
|
2594
|
+
{ "id": "drama.updateTopicScript", "method": "POST", "path": "/api/projects/:id/topic/script", "source": "web-src/src/lib/api.ts:2570", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9009\u9898 / \u7A3F\u4EF6", "body": "json" },
|
|
2595
|
+
{ "id": "drama.uploadStoryDirectorAttachment", "method": "PUT", "path": "/api/projects/:projectId/director/attachments", "source": "web-src/src/lib/api.ts:2640", "group": "drama", "description": "\u77ED\u5267\uFF1A\u8BBE\u7F6E\u5BFC\u6F14 / \u9644\u4EF6", "body": "binary", "uploadPolicy": "chatAttachment", "businessHeaders": { "x-attachment-delivery": { "default": "explicit", "values": ["explicit", "legacy"] }, "x-attachment-name": { "fromFilename": true } } },
|
|
2596
|
+
{ "id": "drama.uploadStorySpeechRecording", "method": "PUT", "path": "/api/projects/:projectId/director/speech/recordings/:lineId", "source": "web-src/src/lib/api.ts:2595", "group": "drama", "description": "\u77ED\u5267\uFF1A\u8BBE\u7F6E\u914D\u97F3 / \u5F55\u97F3", "body": "binary", "uploadPolicy": "storySpeech", "businessHeaders": { "x-script-fingerprint": { "required": true } } },
|
|
2597
|
+
{ "id": "email.unsubscribeEmail", "method": "POST", "path": "/api/email/unsubscribe", "source": "web-src/src/lib/api.ts:1561", "group": "email", "description": "\u90AE\u7BB1\uFF1A\u63D0\u4EA4\u90AE\u7BB1 / \u53D6\u6D88\u8BA2\u9605", "body": "json", "public": true },
|
|
2598
|
+
{ "id": "email.verifyEmail", "method": "POST", "path": "/api/email/verify", "source": "web-src/src/lib/api.ts:1559", "group": "email", "description": "\u90AE\u7BB1\uFF1A\u63D0\u4EA4\u90AE\u7BB1 / \u9A8C\u8BC1", "body": "json", "public": true },
|
|
2599
|
+
{ "id": "episodes.approveEpisodeOutline", "method": "POST", "path": "/api/episodes/:id/outline/:docId/approve", "source": "web-src/src/lib/api.ts:3193", "group": "episodes", "description": "\u5206\u96C6\uFF1A\u63D0\u4EA4\u5927\u7EB2 / \u786E\u8BA4", "body": "json" },
|
|
2600
|
+
{ "id": "episodes.generateOutline", "method": "POST", "path": "/api/episodes/:id/outline", "source": "apps/api/src/http/routes/script-engine.ts:143", "group": "episodes", "description": "\u51C6\u5907\u5206\u96C6\u5927\u7EB2", "body": "json" },
|
|
2601
|
+
{ "id": "episodes.getEpisodeOutline", "method": "GET", "path": "/api/episodes/:id/outline", "source": "web-src/src/lib/api.ts:3188", "group": "episodes", "description": "\u5206\u96C6\uFF1A\u67E5\u8BE2\u5206\u96C6 / \u5927\u7EB2" },
|
|
2602
|
+
{ "id": "feedback.commentOnFeedback", "method": "POST", "path": "/api/feedback/tickets/:ticketNo/comments", "source": "web-src/src/lib/api.ts:1621", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u63D0\u4EA4\u53CD\u9988\u5355 / \u8BC4\u8BBA", "body": "json" },
|
|
2603
|
+
{ "id": "feedback.feedbackHonors", "method": "GET", "path": "/api/feedback/honors", "source": "web-src/src/lib/api.ts:1624", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u67E5\u8BE2\u53CD\u9988 / \u8363\u8A89" },
|
|
2604
|
+
{ "id": "feedback.feedbackMe", "method": "GET", "path": "/api/feedback/me", "source": "web-src/src/lib/api.ts:1604", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u67E5\u8BE2\u53CD\u9988 / \u5F53\u524D\u8D26\u53F7" },
|
|
2605
|
+
{ "id": "feedback.feedbackPeriods", "method": "GET", "path": "/api/feedback/periods", "source": "web-src/src/lib/api.ts:1626", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u67E5\u8BE2\u53CD\u9988 / \u5468\u671F" },
|
|
2606
|
+
{ "id": "feedback.feedbackRules", "method": "GET", "path": "/api/feedback/rules", "source": "web-src/src/lib/api.ts:1600", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u67E5\u8BE2\u53CD\u9988 / \u89C4\u5219" },
|
|
2607
|
+
{ "id": "feedback.feedbackTicket", "method": "GET", "path": "/api/feedback/tickets/:ticketNo", "source": "web-src/src/lib/api.ts:1618", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u67E5\u8BE2\u53CD\u9988 / \u53CD\u9988\u5355" },
|
|
2608
|
+
{ "id": "feedback.myFeedback", "method": "GET", "path": "/api/feedback/tickets", "source": "web-src/src/lib/api.ts:1602", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u67E5\u8BE2\u53CD\u9988 / \u53CD\u9988\u5355" },
|
|
2609
|
+
{ "id": "feedback.submitFeedback", "method": "POST", "path": "/api/feedback/tickets", "source": "web-src/src/lib/api.ts:1615", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u63D0\u4EA4\u53CD\u9988 / \u53CD\u9988\u5355", "body": "json" },
|
|
2610
|
+
{ "id": "feedback.uploadFeedbackAttachment", "method": "POST", "path": "/api/feedback/attachments", "source": "web-src/src/lib/api.ts:1608", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u63D0\u4EA4\u53CD\u9988 / \u9644\u4EF6", "body": "binary", "uploadPolicy": "image" },
|
|
2611
|
+
{ "id": "genres.genres", "method": "GET", "path": "/api/genres", "source": "web-src/src/lib/api.ts:2036", "group": "genres", "description": "\u9898\u6750\uFF1A\u67E5\u8BE2\u9898\u6750" },
|
|
2612
|
+
{ "id": "graphic.attachGraphicRunFile", "method": "PUT", "path": "/api/graphic/runs/:runId/attachments", "source": "web-src/src/lib/api.ts:1441", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u8BBE\u7F6E\u4F5C\u54C1 / \u9644\u4EF6", "body": "binary", "uploadPolicy": "graphicAttachment", "businessHeaders": { "x-attachment-delivery": { "default": "explicit", "values": ["explicit", "legacy"] }, "x-attachment-name": { "fromFilename": true } } },
|
|
2613
|
+
{ "id": "graphic.bindGraphicRunProduct", "method": "PATCH", "path": "/api/graphic/runs/:runId/product", "source": "web-src/src/lib/api.ts:1346", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u66F4\u65B0\u4F5C\u54C1 / \u5546\u54C1", "body": "json" },
|
|
2614
|
+
{ "id": "graphic.cancelGraphicGenerationOrder", "method": "POST", "path": "/api/graphic/runs/:runId/generation-orders/:orderId/cancel", "source": "web-src/src/lib/api.ts:1502", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u5236\u4F5C\u5355 / \u53D6\u6D88", "body": "json" },
|
|
2615
|
+
{ "id": "graphic.changeGraphicRunModel", "method": "PATCH", "path": "/api/graphic/runs/:runId/model", "source": "web-src/src/lib/api.ts:1352", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u66F4\u65B0\u4F5C\u54C1 / \u6A21\u578B", "body": "json" },
|
|
2616
|
+
{ "id": "graphic.changeGraphicRunQuality", "method": "PATCH", "path": "/api/graphic/runs/:runId/quality", "source": "web-src/src/lib/api.ts:1357", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u66F4\u65B0\u4F5C\u54C1 / \u753B\u8D28", "body": "json" },
|
|
2617
|
+
{ "id": "graphic.create", "method": "POST", "path": "/api/graphic/runs", "source": "web-src/src/lib/api.ts:1329", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u56FE\u6587 / \u4F5C\u54C1", "body": "json", "exampleBody": { "title": "\u5546\u54C1\u5BA3\u4F20\u56FE" } },
|
|
2618
|
+
{ "id": "graphic.generateGraphicImages", "method": "POST", "path": "/api/graphic/runs/:runId/images", "source": "web-src/src/lib/api.ts:1486", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u56FE\u7247", "body": "json", "businessHeaders": { "prefer": { "default": "respond-async", "values": ["respond-async"] } } },
|
|
2619
|
+
{ "id": "graphic.graphicEditMaskBlob", "method": "GET", "path": "/api/graphic/runs/:runId/images/:imageId/masks/:maskId", "source": "web-src/src/lib/api.ts:1413", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u56FE\u7247 / \u8499\u7248" },
|
|
2620
|
+
{ "id": "graphic.graphicImageBlob", "method": "GET", "path": "/api/graphic/runs/:runId/images/:imageId/download", "source": "web-src/src/lib/api.ts:1380", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u56FE\u7247 / \u4E0B\u8F7D" },
|
|
2621
|
+
{ "id": "graphic.graphicImagePreview", "method": "GET", "path": "/api/graphic/runs/:runId/preview", "source": "web-src/src/lib/api.ts:1370", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u9884\u89C8" },
|
|
2622
|
+
{ "id": "graphic.graphicRun", "method": "GET", "path": "/api/graphic/runs/:runId", "source": "web-src/src/lib/api.ts:1368", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u56FE\u6587 / \u4F5C\u54C1" },
|
|
2623
|
+
{ "id": "graphic.graphicTemplates", "method": "GET", "path": "/api/graphic/templates", "source": "web-src/src/lib/api.ts:1366", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u56FE\u6587 / \u6A21\u677F" },
|
|
2624
|
+
{ "id": "graphic.inspectGraphicRunAttachments", "method": "GET", "path": "/api/graphic/runs/:runId/attachments", "source": "web-src/src/lib/api.ts:1453", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u9644\u4EF6" },
|
|
2625
|
+
{ "id": "graphic.list", "method": "GET", "path": "/api/graphic/runs", "source": "web-src/src/lib/api.ts:1362", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u56FE\u6587 / \u4F5C\u54C1" },
|
|
2626
|
+
{ "id": "graphic.quoteGraphicImages", "method": "POST", "path": "/api/graphic/runs/:runId/quote", "source": "web-src/src/lib/api.ts:1477", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u62A5\u4EF7", "body": "json" },
|
|
2627
|
+
{ "id": "graphic.releaseGraphicOpening", "method": "POST", "path": "/api/graphic/runs/:runId/opening/attachments", "source": "web-src/src/lib/api.ts:1339", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u5F00\u573A / \u9644\u4EF6", "body": "json" },
|
|
2628
|
+
{ "id": "graphic.retryGraphicTurn", "method": "POST", "path": "/api/graphic/runs/:runId/messages/:messageId/retry", "source": "web-src/src/lib/api.ts:1470", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u5BF9\u8BDD / \u91CD\u8BD5", "body": "json" },
|
|
2629
|
+
{ "id": "graphic.saveGraphicEditMask", "method": "POST", "path": "/api/graphic/runs/:runId/images/:imageId/masks", "source": "web-src/src/lib/api.ts:1409", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u56FE\u7247 / \u8499\u7248", "body": "multipart", "uploadPolicy": "mask", "uploadField": "mask" },
|
|
2630
|
+
{ "id": "graphic.saveGraphicImageEdit", "method": "POST", "path": "/api/graphic/runs/:runId/images/:imageId/edits", "source": "web-src/src/lib/api.ts:1402", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u56FE\u7247 / \u7F16\u8F91\u7248\u672C", "body": "multipart", "uploadPolicy": "image", "uploadField": "image" },
|
|
2631
|
+
{ "id": "graphic.saveGraphicRunAttachmentFile", "method": "GET", "path": "/api/graphic/runs/:runId/attachments/:attachmentId/file", "source": "web-src/src/lib/api.ts:1460", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u9644\u4EF6 / \u6587\u4EF6" },
|
|
2632
|
+
{ "id": "graphic.sendGraphicMessage", "method": "POST", "path": "/api/graphic/runs/:runId/messages", "source": "web-src/src/lib/api.ts:1430", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u5BF9\u8BDD", "body": "json", "exampleBody": { "text": "\u4FDD\u7559\u5546\u54C1\u5916\u89C2\uFF0C\u628A\u80CC\u666F\u6539\u6210\u7C73\u767D\u8272" }, "businessHeaders": { "prefer": { "default": "respond-async", "values": ["respond-async"] } } },
|
|
2633
|
+
{ "id": "graphic.stopGraphicRun", "method": "POST", "path": "/api/graphic/runs/:runId/stop", "source": "web-src/src/lib/api.ts:2605", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u505C\u6B62\u56DE\u590D", "body": "json" },
|
|
2634
|
+
{ "id": "graphic.streamGraphicLive", "method": "GET", "path": "/api/graphic/runs/:runId/live", "source": "web-src/src/lib/api.ts:2532", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u5B9E\u65F6\u8FDB\u5EA6" },
|
|
2635
|
+
{ "id": "health.health", "method": "GET", "path": "/api/health", "source": "web-src/src/lib/api.ts:1294", "group": "health", "description": "\u670D\u52A1\u72B6\u6001\uFF1A\u67E5\u8BE2\u670D\u52A1\u72B6\u6001", "public": true },
|
|
2636
|
+
{ "id": "imageModels.imageModelCapabilities", "method": "GET", "path": "/api/image-models/capabilities", "source": "web-src/src/lib/api.ts:2767", "group": "imageModels", "description": "\u56FE\u7247\u6A21\u578B\uFF1A\u67E5\u8BE2\u56FE\u7247\u6A21\u578B / \u80FD\u529B" },
|
|
2637
|
+
{ "id": "imageModels.imageModelReadiness", "method": "GET", "path": "/api/image-models/readiness", "source": "web-src/src/lib/api.ts:2766", "group": "imageModels", "description": "\u56FE\u7247\u6A21\u578B\uFF1A\u67E5\u8BE2\u56FE\u7247\u6A21\u578B / \u5C31\u7EEA\u72B6\u6001" },
|
|
2638
|
+
{ "id": "library.archiveLibraryProject", "method": "POST", "path": "/api/project-library/:kind/:sourceId/archive", "source": "web-src/src/lib/api.ts:2914", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u63D0\u4EA4\u4F5C\u54C1\u5E93 / \u5F52\u6863", "body": "json" },
|
|
2639
|
+
{ "id": "library.downloadTicket", "method": "POST", "path": "/api/project-library/batch-actions/:batchId/download-ticket", "sensitiveOutput": true, "source": "apps/api/src/http/routes/project-library.ts:284", "group": "library", "description": "\u51C6\u5907\u4F5C\u54C1\u5E93\u5408\u96C6\u4E0B\u8F7D", "body": "json" },
|
|
2640
|
+
{ "id": "library.downloadZip", "method": "GET", "path": "/api/project-library/batch-actions/:batchId/download.zip", "source": "apps/api/src/http/routes/project-library.ts:272", "group": "library", "description": "\u4E0B\u8F7D\u4F5C\u54C1\u5E93\u5408\u96C6" },
|
|
2641
|
+
{ "id": "library.executeProjectLibraryBatch", "method": "POST", "path": "/api/project-library/batch-actions/:preflightId/execute", "source": "web-src/src/lib/api.ts:2937", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u63D0\u4EA4\u4F5C\u54C1\u6279\u91CF\u7BA1\u7406 / \u6267\u884C", "body": "json" },
|
|
2642
|
+
{ "id": "library.preflightProjectLibraryBatch", "method": "POST", "path": "/api/project-library/batch-actions/preflight", "source": "web-src/src/lib/api.ts:2924", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u63D0\u4EA4\u4F5C\u54C1\u6279\u91CF\u7BA1\u7406 / \u9884\u68C0", "body": "json" },
|
|
2643
|
+
{ "id": "library.projectLibrary", "method": "GET", "path": "/api/project-library", "source": "web-src/src/lib/api.ts:2891", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u67E5\u8BE2\u4F5C\u54C1\u5E93" },
|
|
2644
|
+
{ "id": "library.projectLibraryBatch", "method": "GET", "path": "/api/project-library/batch-actions/:batchId", "source": "web-src/src/lib/api.ts:2949", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u67E5\u8BE2\u4F5C\u54C1\u5E93 / \u4F5C\u54C1\u6279\u91CF\u7BA1\u7406" },
|
|
2645
|
+
{ "id": "library.projectLibraryByProduct", "method": "GET", "path": "/api/project-library/by-product", "source": "web-src/src/lib/api.ts:2902", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u67E5\u8BE2\u4F5C\u54C1\u5E93 / \u6309\u5546\u54C1\u6C47\u603B" },
|
|
2646
|
+
{ "id": "library.projectLibrarySummary", "method": "GET", "path": "/api/project-library/summary", "source": "web-src/src/lib/api.ts:2896", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u67E5\u8BE2\u4F5C\u54C1\u5E93 / \u6982\u51B5" },
|
|
2647
|
+
{ "id": "library.renameLibraryProject", "method": "PATCH", "path": "/api/project-library/:kind/:sourceId/name", "source": "web-src/src/lib/api.ts:2905", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u66F4\u65B0\u4F5C\u54C1\u5E93 / \u540D\u79F0", "body": "json" },
|
|
2648
|
+
{ "id": "library.unarchiveLibraryProject", "method": "POST", "path": "/api/project-library/:kind/:sourceId/unarchive", "source": "web-src/src/lib/api.ts:2919", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u63D0\u4EA4\u4F5C\u54C1\u5E93 / \u6062\u590D\u5F52\u6863", "body": "json" },
|
|
2649
|
+
{ "id": "membership.brands", "method": "GET", "path": "/api/membership/brands", "source": "web-src/src/lib/membership.ts:345", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458 / \u54C1\u724C" },
|
|
2650
|
+
{ "id": "membership.catalog", "method": "GET", "path": "/api/membership/catalog", "source": "web-src/src/lib/membership.ts:334", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458 / \u76EE\u5F55" },
|
|
2651
|
+
{ "id": "membership.claimDailyAutomatically", "method": "POST", "path": "/api/membership/daily-claim", "source": "web-src/src/lib/membership.ts:339", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u4F1A\u5458 / \u9886\u53D6\u6BCF\u65E5\u6743\u76CA", "body": "json" },
|
|
2652
|
+
{ "id": "membership.daily", "method": "GET", "path": "/api/membership/daily", "source": "web-src/src/lib/membership.ts:338", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458 / \u6BCF\u65E5\u6743\u76CA" },
|
|
2653
|
+
{ "id": "membership.deleteBrand", "method": "DELETE", "path": "/api/membership/brands/:brandId", "source": "web-src/src/lib/membership.ts:348", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u5220\u9664\u4F1A\u5458 / \u54C1\u724C", "body": "json" },
|
|
2654
|
+
{ "id": "membership.downloadPack", "method": "GET", "path": "/api/membership/renders/:taskId/output", "source": "apps/api/src/http/routes/membership.ts:165", "group": "membership", "description": "\u4E0B\u8F7D\u5305\u88C5\u6210\u7247" },
|
|
2655
|
+
{ "id": "membership.orders.create", "method": "POST", "path": "/api/membership/orders", "source": "web-src/src/lib/membership.ts:337", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u4F1A\u5458 / \u8BA2\u5355", "body": "json", "idempotencyBodyKey": "idempotencyKey", "replaySafe": true, "exampleBody": { "planVersion": "\u4ECEmembership.catalog\u8BFB\u53D6\u5F53\u524D\u7248\u672C", "intent": "purchase" } },
|
|
2656
|
+
{ "id": "membership.payments.checkout", "method": "POST", "path": "/api/payments/orders/:id/checkout", "source": "web-src/src/lib/api.ts:3286", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u8BA2\u5355 / \u4F1A\u5458\u4ED8\u6B3E", "body": "json", "membershipPaymentOnly": true },
|
|
2657
|
+
{ "id": "membership.payments.show", "method": "GET", "path": "/api/payments/orders/:id", "source": "apps/api/src/http/routes/payments.ts:87", "group": "membership", "description": "\u8BFB\u53D6\u5E76\u9A8C\u8BC1\u672C\u4EBA\u7684\u4F1A\u5458\u4ED8\u6B3E\u5355", "membershipPaymentOnly": true },
|
|
2658
|
+
{ "id": "membership.payments.status", "method": "GET", "path": "/api/payments/orders/:id/status", "source": "web-src/src/lib/api.ts:3292", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u8BA2\u5355 / \u72B6\u6001", "membershipPaymentOnly": true },
|
|
2659
|
+
{ "id": "membership.refund", "method": "POST", "path": "/api/membership/orders/:orderId/refund", "source": "web-src/src/lib/membership.ts:342", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u8BA2\u5355 / \u9000\u6B3E", "body": "json", "idempotencyBodyKey": "idempotencyKey", "replaySafe": true, "exampleBody": {} },
|
|
2660
|
+
{ "id": "membership.refundDetails", "method": "GET", "path": "/api/membership/refunds/:groupId", "source": "web-src/src/lib/membership.ts:343", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458 / \u9000\u6B3E\u8BB0\u5F55" },
|
|
2661
|
+
{ "id": "membership.refundQuote", "method": "POST", "path": "/api/membership/orders/:orderId/refund-quote", "source": "web-src/src/lib/membership.ts:341", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u8BA2\u5355 / \u9000\u6B3E\u8BD5\u7B97", "body": "json" },
|
|
2662
|
+
{ "id": "membership.refundStatus", "method": "POST", "path": "/api/membership/refunds/:groupId/status", "source": "web-src/src/lib/membership.ts:344", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u9000\u6B3E\u8BB0\u5F55 / \u72B6\u6001", "body": "json" },
|
|
2663
|
+
{ "id": "membership.render", "method": "POST", "path": "/api/membership/render", "source": "web-src/src/lib/membership.ts:353", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u4F1A\u5458 / \u5236\u4F5C\u5305\u88C5", "body": "json" },
|
|
2664
|
+
{ "id": "membership.renderAssets", "method": "GET", "path": "/api/membership/render-assets", "source": "web-src/src/lib/membership.ts:351", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458 / \u5305\u88C5\u7D20\u6750" },
|
|
2665
|
+
{ "id": "membership.renderPreview", "method": "POST", "path": "/api/membership/render-preview", "source": "web-src/src/lib/membership.ts:350", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u4F1A\u5458 / \u5305\u88C5\u9884\u89C8", "body": "json" },
|
|
2666
|
+
{ "id": "membership.renderQuote", "method": "POST", "path": "/api/membership/render-quote", "source": "web-src/src/lib/membership.ts:352", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u4F1A\u5458 / \u5305\u88C5\u62A5\u4EF7", "body": "json" },
|
|
2667
|
+
{ "id": "membership.renders.list", "method": "GET", "path": "/api/membership/renders", "source": "web-src/src/components/domain/story-film-packs.tsx:30", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458 / \u5305\u88C5\u6210\u7247" },
|
|
2668
|
+
{ "id": "membership.renderSources", "method": "GET", "path": "/api/membership/render-sources", "source": "web-src/src/lib/membership.ts:349", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458 / \u5305\u88C5\u7247\u6E90" },
|
|
2669
|
+
{ "id": "membership.saveBrand", "method": "POST", "path": "/api/membership/brands", "source": "web-src/src/lib/membership.ts:347", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u4F1A\u5458 / \u54C1\u724C", "body": "json" },
|
|
2670
|
+
{ "id": "membership.summary", "method": "GET", "path": "/api/membership", "source": "web-src/src/lib/membership.ts:335", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458" },
|
|
2671
|
+
{ "id": "notifications.markAllNotificationsRead", "method": "POST", "path": "/api/notifications/read-all", "source": "web-src/src/lib/api.ts:1526", "group": "notifications", "description": "\u901A\u77E5\uFF1A\u63D0\u4EA4\u901A\u77E5 / \u5168\u90E8\u6807\u4E3A\u5DF2\u8BFB", "body": "json" },
|
|
2672
|
+
{ "id": "notifications.markNotificationsRead", "method": "POST", "path": "/api/notifications/read", "source": "web-src/src/lib/api.ts:1524", "group": "notifications", "description": "\u901A\u77E5\uFF1A\u63D0\u4EA4\u901A\u77E5 / \u6807\u8BB0\u5DF2\u8BFB", "body": "json" },
|
|
2673
|
+
{ "id": "notifications.notifications", "method": "GET", "path": "/api/notifications", "source": "web-src/src/lib/api.ts:1520", "group": "notifications", "description": "\u901A\u77E5\uFF1A\u67E5\u8BE2\u901A\u77E5" },
|
|
2674
|
+
{ "id": "notifications.notificationSummary", "method": "GET", "path": "/api/notifications/summary", "source": "web-src/src/lib/api.ts:1512", "group": "notifications", "description": "\u901A\u77E5\uFF1A\u67E5\u8BE2\u901A\u77E5 / \u6982\u51B5" },
|
|
2675
|
+
{ "id": "notifications.pushKey", "method": "GET", "path": "/api/notifications/push/key", "source": "web-src/src/lib/api.ts:1583", "group": "notifications", "description": "\u901A\u77E5\uFF1A\u67E5\u8BE2\u63A8\u9001 / \u63A8\u9001\u516C\u94A5" },
|
|
2676
|
+
{ "id": "notifications.subscribePush", "method": "POST", "path": "/api/notifications/push/subscribe", "source": "web-src/src/lib/api.ts:1586", "group": "notifications", "description": "\u901A\u77E5\uFF1A\u63D0\u4EA4\u63A8\u9001 / \u8BA2\u9605\u63A8\u9001", "body": "json" },
|
|
2677
|
+
{ "id": "notifications.unsubscribePush", "method": "POST", "path": "/api/notifications/push/unsubscribe", "source": "web-src/src/lib/api.ts:1589", "group": "notifications", "description": "\u901A\u77E5\uFF1A\u63D0\u4EA4\u63A8\u9001 / \u53D6\u6D88\u8BA2\u9605", "body": "json" },
|
|
2678
|
+
{ "id": "products.archiveProduct", "method": "POST", "path": "/api/products/:id/archive", "source": "web-src/src/lib/api.ts:2063", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1 / \u5F52\u6863", "body": "json" },
|
|
2679
|
+
{ "id": "products.confirmProductLock", "method": "POST", "path": "/api/products/:id/lock/confirm", "source": "web-src/src/lib/api.ts:2879", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1\u5916\u89C2 / \u786E\u8BA4", "body": "json" },
|
|
2680
|
+
{ "id": "products.create", "method": "POST", "path": "/api/products", "source": "web-src/src/lib/api.ts:2079", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1", "body": "json" },
|
|
2681
|
+
{ "id": "products.createSeries", "method": "POST", "path": "/api/products/:id/series", "source": "web-src/src/lib/api.ts:3173", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1 / \u7CFB\u5217", "body": "json" },
|
|
2682
|
+
{ "id": "products.deleteProductImage", "method": "DELETE", "path": "/api/products/:id/images", "source": "web-src/src/lib/api.ts:2105", "group": "products", "description": "\u5546\u54C1\uFF1A\u5220\u9664\u5546\u54C1 / \u56FE\u7247", "body": "json" },
|
|
2683
|
+
{ "id": "products.get", "method": "GET", "path": "/api/products/:id", "source": "web-src/src/lib/api.ts:2048", "group": "products", "description": "\u5546\u54C1\uFF1A\u67E5\u8BE2\u5546\u54C1" },
|
|
2684
|
+
{ "id": "products.list", "method": "GET", "path": "/api/products", "source": "web-src/src/lib/api.ts:2047", "group": "products", "description": "\u5546\u54C1\uFF1A\u67E5\u8BE2\u5546\u54C1" },
|
|
2685
|
+
{ "id": "products.mergeProducts", "method": "POST", "path": "/api/products/:id/merge", "source": "web-src/src/lib/api.ts:2059", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1 / \u5408\u5E76", "body": "json" },
|
|
2686
|
+
{ "id": "products.productUsage", "method": "GET", "path": "/api/products/usage", "source": "web-src/src/lib/api.ts:2050", "group": "products", "description": "\u5546\u54C1\uFF1A\u67E5\u8BE2\u5546\u54C1 / \u4F7F\u7528\u60C5\u51B5" },
|
|
2687
|
+
{ "id": "products.recognizeProductLock", "method": "POST", "path": "/api/products/:id/recognize-lock", "source": "web-src/src/lib/api.ts:2109", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1 / \u8BC6\u522B\u5546\u54C1\u5916\u89C2", "body": "json" },
|
|
2688
|
+
{ "id": "products.renameProduct", "method": "PATCH", "path": "/api/products/:id", "source": "web-src/src/lib/api.ts:2052", "group": "products", "description": "\u5546\u54C1\uFF1A\u66F4\u65B0\u5546\u54C1", "body": "json" },
|
|
2689
|
+
{ "id": "products.unarchiveProduct", "method": "POST", "path": "/api/products/:id/unarchive", "source": "web-src/src/lib/api.ts:2065", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1 / \u6062\u590D\u5F52\u6863", "body": "json" },
|
|
2690
|
+
{ "id": "products.unmergeProduct", "method": "POST", "path": "/api/products/:id/unmerge", "source": "web-src/src/lib/api.ts:2061", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1 / \u64A4\u9500\u5408\u5E76", "body": "json" },
|
|
2691
|
+
{ "id": "products.uploadProductImage", "method": "PUT", "path": "/api/products/:id/images", "source": "web-src/src/lib/api.ts:2094", "group": "products", "description": "\u5546\u54C1\uFF1A\u8BBE\u7F6E\u5546\u54C1 / \u56FE\u7247", "body": "binary", "uploadPolicy": "image" },
|
|
2692
|
+
{ "id": "public.checkReferralCode", "method": "POST", "path": "/api/public/referral-codes/check", "source": "web-src/src/lib/api.ts:1707", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u63D0\u4EA4\u63A8\u8350\u7801 / \u6838\u9A8C", "body": "json", "public": true },
|
|
2693
|
+
{ "id": "public.publicAnnouncements", "method": "GET", "path": "/api/public/announcements", "source": "web-src/src/lib/api.ts:1529", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u67E5\u8BE2\u516C\u5F00\u4FE1\u606F / \u516C\u544A", "public": true },
|
|
2694
|
+
{ "id": "public.publicAssetProof", "method": "GET", "path": "/api/public/assets/summary", "source": "web-src/src/lib/api.ts:1506", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u67E5\u8BE2\u7D20\u6750 / \u6982\u51B5", "public": true },
|
|
2695
|
+
{ "id": "public.publicPricing", "method": "GET", "path": "/api/public/pricing", "source": "web-src/src/lib/api.ts:1291", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u67E5\u8BE2\u516C\u5F00\u4FE1\u606F / \u4EF7\u683C", "public": true },
|
|
2696
|
+
{ "id": "public.publicRankings", "method": "GET", "path": "/api/public/rankings", "source": "web-src/src/lib/api.ts:1292", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u67E5\u8BE2\u516C\u5F00\u4FE1\u606F / \u699C\u5355", "public": true },
|
|
2697
|
+
{ "id": "public.publicShowcase", "method": "GET", "path": "/api/public/showcase", "source": "web-src/src/lib/api.ts:1306", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u67E5\u8BE2\u516C\u5F00\u4FE1\u606F / \u5C55\u793A\u4F5C\u54C1", "public": true },
|
|
2698
|
+
{ "id": "public.recordReferralVisit", "method": "POST", "path": "/api/public/referral-codes/visit", "source": "web-src/src/lib/api.ts:1727", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u63D0\u4EA4\u63A8\u8350\u7801 / \u8BBF\u95EE\u8BB0\u5F55", "body": "json", "public": true },
|
|
2699
|
+
{ "id": "public.submitTrialRequest", "method": "POST", "path": "/api/public/trial-requests", "source": "web-src/src/lib/api.ts:1509", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u63D0\u4EA4\u516C\u5F00\u4FE1\u606F / \u8BD5\u7528\u7533\u8BF7", "body": "json", "public": true },
|
|
2700
|
+
{ "id": "series.approveSeriesOutline", "method": "POST", "path": "/api/series/:id/outline/:docId/approve", "source": "web-src/src/lib/api.ts:3184", "group": "series", "description": "\u7CFB\u5217\uFF1A\u63D0\u4EA4\u5927\u7EB2 / \u786E\u8BA4", "body": "json" },
|
|
2701
|
+
{ "id": "series.createEpisode", "method": "POST", "path": "/api/series/:id/episodes", "source": "web-src/src/lib/api.ts:3175", "group": "series", "description": "\u7CFB\u5217\uFF1A\u63D0\u4EA4\u7CFB\u5217 / \u5206\u96C6", "body": "json" },
|
|
2702
|
+
{ "id": "series.generateOutline", "method": "POST", "path": "/api/series/:id/outline", "source": "apps/api/src/http/routes/script-engine.ts:99", "group": "series", "description": "\u51C6\u5907\u7CFB\u5217\u5927\u7EB2", "body": "json" },
|
|
2703
|
+
{ "id": "series.getSeries", "method": "GET", "path": "/api/series/:id", "source": "web-src/src/lib/api.ts:3171", "group": "series", "description": "\u7CFB\u5217\uFF1A\u67E5\u8BE2\u7CFB\u5217" },
|
|
2704
|
+
{ "id": "series.getSeriesOutline", "method": "GET", "path": "/api/series/:id/outline", "source": "web-src/src/lib/api.ts:3179", "group": "series", "description": "\u7CFB\u5217\uFF1A\u67E5\u8BE2\u7CFB\u5217 / \u5927\u7EB2" },
|
|
2705
|
+
{ "id": "series.listSeries", "method": "GET", "path": "/api/series", "source": "web-src/src/lib/api.ts:3170", "group": "series", "description": "\u7CFB\u5217\uFF1A\u67E5\u8BE2\u7CFB\u5217" },
|
|
2706
|
+
{ "id": "templates.createTemplateShortOrder", "method": "POST", "path": "/api/template-shorts/orders", "source": "web-src/src/lib/api.ts:3565", "group": "templates", "description": "\u6A21\u677F\u77ED\u7247\uFF1A\u63D0\u4EA4\u6A21\u677F\u77ED\u7247 / \u8BA2\u5355", "body": "json" },
|
|
2707
|
+
{ "id": "templates.quoteTemplateShortOrder", "method": "POST", "path": "/api/template-shorts/quote", "source": "web-src/src/lib/api.ts:3561", "group": "templates", "description": "\u6A21\u677F\u77ED\u7247\uFF1A\u63D0\u4EA4\u6A21\u677F\u77ED\u7247 / \u62A5\u4EF7", "body": "json" },
|
|
2708
|
+
{ "id": "templates.templateShortOrder", "method": "GET", "path": "/api/template-shorts/orders/:id", "source": "web-src/src/lib/api.ts:3569", "group": "templates", "description": "\u6A21\u677F\u77ED\u7247\uFF1A\u67E5\u8BE2\u6A21\u677F\u77ED\u7247 / \u8BA2\u5355" },
|
|
2709
|
+
{ "id": "templates.templateShortOrderDownload", "method": "GET", "path": "/api/template-shorts/orders/:id/download", "source": "web-src/src/lib/api.ts:3576", "group": "templates", "description": "\u6A21\u677F\u77ED\u7247\uFF1A\u67E5\u8BE2\u8BA2\u5355 / \u4E0B\u8F7D" },
|
|
2710
|
+
{ "id": "templates.templateShortsCatalog", "method": "GET", "path": "/api/template-shorts/catalog", "source": "web-src/src/lib/api.ts:3557", "group": "templates", "description": "\u6A21\u677F\u77ED\u7247\uFF1A\u67E5\u8BE2\u6A21\u677F\u77ED\u7247 / \u76EE\u5F55" },
|
|
2711
|
+
{ "id": "templates.uploadTemplateShortAsset", "method": "POST", "path": "/api/template-shorts/uploads", "source": "web-src/src/lib/api.ts:3585", "group": "templates", "description": "\u6A21\u677F\u77ED\u7247\uFF1A\u63D0\u4EA4\u6A21\u677F\u77ED\u7247 / \u4E0A\u4F20", "body": "binary", "uploadPolicy": "image" },
|
|
2712
|
+
{ "id": "upscale.createUpscaleOrder", "method": "POST", "path": "/api/upscale/orders", "source": "web-src/src/lib/api.ts:2962", "group": "upscale", "description": "\u8D85\u6E05\u753B\u8D28\uFF1A\u63D0\u4EA4\u8D85\u6E05\u753B\u8D28 / \u8BA2\u5355", "body": "json" },
|
|
2713
|
+
{ "id": "upscale.download", "method": "GET", "path": "/api/upscale/orders/:id/video", "source": "apps/api/src/http/routes/upscale.ts:28", "group": "upscale", "description": "\u4E0B\u8F7D\u8D85\u6E05\u6210\u7247" },
|
|
2714
|
+
{ "id": "upscale.listUpscaleOrders", "method": "GET", "path": "/api/upscale/orders", "source": "web-src/src/lib/api.ts:2965", "group": "upscale", "description": "\u8D85\u6E05\u753B\u8D28\uFF1A\u67E5\u8BE2\u8D85\u6E05\u753B\u8D28 / \u8BA2\u5355" },
|
|
2715
|
+
{ "id": "upscale.quoteUpscale", "method": "POST", "path": "/api/upscale/quote", "source": "web-src/src/lib/api.ts:2960", "group": "upscale", "description": "\u8D85\u6E05\u753B\u8D28\uFF1A\u63D0\u4EA4\u8D85\u6E05\u753B\u8D28 / \u62A5\u4EF7", "body": "json" },
|
|
2716
|
+
{ "id": "upscale.upscaleCapability", "method": "GET", "path": "/api/upscale/capability", "source": "web-src/src/lib/api.ts:2958", "group": "upscale", "description": "\u8D85\u6E05\u753B\u8D28\uFF1A\u67E5\u8BE2\u8D85\u6E05\u753B\u8D28 / \u80FD\u529B" },
|
|
2717
|
+
{ "id": "videoModels.videoModelReadiness", "method": "GET", "path": "/api/video-models/readiness", "source": "web-src/src/lib/api.ts:2765", "group": "videoModels", "description": "\u89C6\u9891\u6A21\u578B\uFF1A\u67E5\u8BE2\u89C6\u9891\u6A21\u578B / \u5C31\u7EEA\u72B6\u6001" },
|
|
2718
|
+
{ "id": "videos.acceptShowcaseLearning", "method": "POST", "path": "/api/showcase-videos/:id/accept-learning", "source": "web-src/src/lib/api.ts:2872", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891 / \u91C7\u7528\u5B66\u4E60\u7ED3\u679C", "body": "json" },
|
|
2719
|
+
{ "id": "videos.adoptCommercialAdAssetGapUploaded", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/gaps/:gapId/adopt-uploaded", "source": "web-src/src/lib/api.ts:2325", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u7D20\u6750\u7F3A\u53E3 / \u91C7\u7528\u4E0A\u4F20\u7D20\u6750", "body": "json" },
|
|
2720
|
+
{ "id": "videos.applyCommercialAdMusic", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/music/:taskId/apply", "source": "web-src/src/lib/api.ts:2191", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u914D\u4E50 / \u5E94\u7528", "body": "json" },
|
|
2721
|
+
{ "id": "videos.attachCommercialAdRootImage", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/attachments", "source": "web-src/src/lib/api.ts:2422", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u8BBE\u7F6E\u4F5C\u54C1 / \u9644\u4EF6", "body": "binary", "uploadPolicy": "chatAttachment", "businessHeaders": { "x-attachment-delivery": { "default": "explicit", "values": ["explicit", "legacy"] }, "x-attachment-name": { "fromFilename": true } } },
|
|
2722
|
+
{ "id": "videos.cancelCommercialAdRunWaitingBudget", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/cancel-waiting-budget", "source": "web-src/src/lib/api.ts:2340", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u505C\u6B62\u7B49\u5F85\u4F59\u989D", "body": "json" },
|
|
2723
|
+
{ "id": "videos.commercialAdAreaMaskBlob", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/image-edits/area/:quoteId/mask", "source": "web-src/src/lib/api.ts:2211", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5C40\u90E8\u4FEE\u6539 / \u8499\u7248" },
|
|
2724
|
+
{ "id": "videos.commercialAdAreaPreviewBlob", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/image-edits/area/:jobId/preview", "source": "web-src/src/lib/api.ts:2213", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5C40\u90E8\u4FEE\u6539 / \u9884\u89C8" },
|
|
2725
|
+
{ "id": "videos.commercialAdImageBlob", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/images/:assetId/download", "source": "web-src/src/lib/api.ts:2216", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u56FE\u7247 / \u4E0B\u8F7D" },
|
|
2726
|
+
{ "id": "videos.commercialAdImageBlob.download", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/storyboards/:imageKey/download", "source": "web-src/src/lib/api.ts:2216", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u6545\u4E8B\u677F / \u4E0B\u8F7D" },
|
|
2727
|
+
{ "id": "videos.commercialAdImageBlob.download_2", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/image-edits/:editId/download", "source": "web-src/src/lib/api.ts:2216", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u56FE\u7247\u7F16\u8F91 / \u4E0B\u8F7D" },
|
|
2728
|
+
{ "id": "videos.commercialAdInspirations", "method": "GET", "path": "/api/showcase-videos/inspirations", "source": "web-src/src/lib/api.ts:2763", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u7075\u611F" },
|
|
2729
|
+
{ "id": "videos.commercialAdMethods", "method": "GET", "path": "/api/showcase-videos/methods", "source": "web-src/src/lib/api.ts:2760", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u5236\u4F5C\u65B9\u5F0F" },
|
|
2730
|
+
{ "id": "videos.commercialAdPlayCards", "method": "GET", "path": "/api/showcase-videos/play-cards", "source": "web-src/src/lib/api.ts:2762", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u73A9\u6CD5" },
|
|
2731
|
+
{ "id": "videos.compareCommercialAdRunFileVersions", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/files/:path/versions/compare", "source": "web-src/src/lib/api.ts:2247", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u7248\u672C / \u5BF9\u6BD4" },
|
|
2732
|
+
{ "id": "videos.confirmCommercialAdAreaEdit", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/image-edits/area/confirm", "source": "web-src/src/lib/api.ts:2209", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5C40\u90E8\u4FEE\u6539 / \u786E\u8BA4", "body": "json" },
|
|
2733
|
+
{ "id": "videos.confirmCommercialAdDirectorImage", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/confirm-image", "source": "web-src/src/lib/api.ts:2388", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u786E\u8BA4\u51FA\u56FE", "body": "json" },
|
|
2734
|
+
{ "id": "videos.confirmCommercialAdRootProduction", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/confirm-production", "source": "web-src/src/lib/api.ts:2379", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u786E\u8BA4\u5236\u4F5C", "body": "json" },
|
|
2735
|
+
{ "id": "videos.confirmCommercialAdRootProductLock", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/product-lock-confirm", "source": "web-src/src/lib/api.ts:2354", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u786E\u8BA4\u5546\u54C1\u5916\u89C2", "body": "json" },
|
|
2736
|
+
{ "id": "videos.confirmShowcaseVideo", "method": "POST", "path": "/api/showcase-videos/:id/confirm", "source": "web-src/src/lib/api.ts:2866", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891 / \u786E\u8BA4", "body": "json" },
|
|
2737
|
+
{ "id": "videos.continueCommercialAdVoiceSelection", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/voice-selection/continue", "source": "web-src/src/lib/api.ts:2171", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u97F3\u8272\u9009\u62E9 / \u7EE7\u7EED", "body": "json" },
|
|
2738
|
+
{ "id": "videos.createCommercialAdMediaPass", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/media-pass", "source": "web-src/src/lib/api.ts:2194", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u64AD\u653E\u51ED\u8BC1", "body": "json" },
|
|
2739
|
+
{ "id": "videos.createCommercialAdPresetVoiceSample", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/voice-candidates/preset", "source": "web-src/src/lib/api.ts:2167", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u97F3\u8272\u5019\u9009 / \u9884\u8BBE", "body": "json" },
|
|
2740
|
+
{ "id": "videos.createMotionReference", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/motion-references", "source": "apps/api/src/http/routes/showcase.ts:749", "group": "videos", "description": "\u622A\u53D6\u52A8\u4F5C\u53C2\u8003", "body": "json" },
|
|
2741
|
+
{ "id": "videos.createShowcaseVideo", "method": "POST", "path": "/api/showcase-videos", "source": "web-src/src/lib/api.ts:2135", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891", "body": "json" },
|
|
2742
|
+
{ "id": "videos.decideCommercialAdPublicReferenceCandidate", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/public-reference-candidates/:assetId/decision", "source": "web-src/src/lib/api.ts:2158", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u8BBE\u7F6E\u516C\u5F00\u53C2\u8003 / \u9009\u7528\u610F\u89C1", "body": "json" },
|
|
2743
|
+
{ "id": "videos.deleteCommercialAdAsset", "method": "DELETE", "path": "/api/showcase-videos/assets/:id", "source": "web-src/src/lib/api.ts:2564", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u5220\u9664\u5546\u54C1\u89C6\u9891 / \u7D20\u6750", "body": "json" },
|
|
2744
|
+
{ "id": "videos.downloadAppend", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/append-tasks/:taskId/clip", "source": "apps/api/src/http/routes/showcase.ts:548", "group": "videos", "description": "\u4E0B\u8F7D\u65B0\u589E\u7247\u6BB5" },
|
|
2745
|
+
{ "id": "videos.downloadEdit", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/edits/:editId/download", "source": "apps/api/src/http/routes/showcase.ts:524", "group": "videos", "description": "\u4E0B\u8F7D\u5546\u54C1\u89C6\u9891\u526A\u8F91\u7248" },
|
|
2746
|
+
{ "id": "videos.downloadEditSubtitles", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/edits/:editId/subtitles", "source": "apps/api/src/http/routes/showcase.ts:527", "group": "videos", "description": "\u4E0B\u8F7D\u5546\u54C1\u89C6\u9891\u526A\u8F91\u5B57\u5E55" },
|
|
2747
|
+
{ "id": "videos.downloadFinal", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/video/download", "source": "apps/api/src/http/routes/showcase.ts:829", "group": "videos", "description": "\u4E0B\u8F7D\u5546\u54C1\u89C6\u9891\u6210\u7247" },
|
|
2748
|
+
{ "id": "videos.downloadMusic", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/music/:taskId/tracks/:index/download", "source": "apps/api/src/http/routes/showcase.ts:817", "group": "videos", "description": "\u4E0B\u8F7D\u914D\u4E50\u97F3\u8F68" },
|
|
2749
|
+
{ "id": "videos.downloadNarration", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/edits/:editId/narration/download", "source": "apps/api/src/http/routes/showcase.ts:538", "group": "videos", "description": "\u4E0B\u8F7D\u65C1\u767D\u97F3\u8F68" },
|
|
2750
|
+
{ "id": "videos.downloadProduction", "method": "GET", "path": "/api/showcase-videos/:id/video/download", "source": "apps/api/src/http/routes/showcase.ts:1460", "group": "videos", "description": "\u4E0B\u8F7D\u6307\u5B9A\u5236\u4F5C\u6210\u7247" },
|
|
2751
|
+
{ "id": "videos.generateCommercialAdAsset", "method": "POST", "path": "/api/showcase-videos/assets/generate", "source": "web-src/src/lib/api.ts:2542", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u7D20\u6750 / \u5236\u4F5C", "body": "json" },
|
|
2752
|
+
{ "id": "videos.getCommercialAdAreaQuote", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/image-edits/area/:quoteId", "source": "web-src/src/lib/api.ts:2207", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u56FE\u7247\u7F16\u8F91 / \u5C40\u90E8\u4FEE\u6539" },
|
|
2753
|
+
{ "id": "videos.getCommercialAdMusicTrackAudio", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/music/:taskId/tracks/:index/audio", "source": "web-src/src/lib/api.ts:2196", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u97F3\u8F68 / \u97F3\u9891" },
|
|
2754
|
+
{ "id": "videos.getCommercialAdPlatformVoiceAudio", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/platform-voices/:voiceId/audio", "source": "web-src/src/lib/api.ts:2179", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5E73\u53F0\u97F3\u8272 / \u97F3\u9891" },
|
|
2755
|
+
{ "id": "videos.getCommercialAdPlatformVoices", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/platform-voices", "source": "web-src/src/lib/api.ts:2177", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u5E73\u53F0\u97F3\u8272" },
|
|
2756
|
+
{ "id": "videos.getCommercialAdPresetVoiceSampleAudio", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/voice-presets/:voiceId/sample", "source": "web-src/src/lib/api.ts:2182", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u97F3\u8272\u9884\u8BBE / \u8BD5\u542C" },
|
|
2757
|
+
{ "id": "videos.getCommercialAdProductionPreview", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/production-preview", "source": "web-src/src/lib/api.ts:2146", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u5236\u4F5C\u9884\u89C8" },
|
|
2758
|
+
{ "id": "videos.getCommercialAdPublicReferenceCandidates", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/public-reference-candidates", "source": "web-src/src/lib/api.ts:2156", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u516C\u5F00\u53C2\u8003" },
|
|
2759
|
+
{ "id": "videos.getCommercialAdRun", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId", "source": "web-src/src/lib/api.ts:2143", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u4F5C\u54C1" },
|
|
2760
|
+
{ "id": "videos.getCommercialAdRunFile", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/files/:path", "source": "web-src/src/lib/api.ts:2224", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u6587\u4EF6" },
|
|
2761
|
+
{ "id": "videos.getCommercialAdRunFileVersion", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/files/:path/versions/:versionId", "source": "web-src/src/lib/api.ts:2235", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u6587\u4EF6 / \u7248\u672C" },
|
|
2762
|
+
{ "id": "videos.getCommercialAdSubtitles", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/subtitles", "source": "web-src/src/lib/api.ts:2149", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u5B57\u5E55" },
|
|
2763
|
+
{ "id": "videos.getCommercialAdVoiceAudio", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/voice-candidates/:candidateId/audio", "source": "web-src/src/lib/api.ts:2173", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u97F3\u8272\u5019\u9009 / \u97F3\u9891" },
|
|
2764
|
+
{ "id": "videos.getCommercialAdVoiceCandidates", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/voice-candidates", "source": "web-src/src/lib/api.ts:2154", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u97F3\u8272\u5019\u9009" },
|
|
2765
|
+
{ "id": "videos.getCommercialAdVoiceLibraryAudio", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/voice-library/:candidateId/audio", "source": "web-src/src/lib/api.ts:2175", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u58F0\u97F3\u5E93 / \u97F3\u9891" },
|
|
2766
|
+
{ "id": "videos.getCommercialAdVoiceoverPreviewAudio", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/voiceover/previews/:previewId/audio", "source": "web-src/src/lib/api.ts:2185", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u9884\u89C8 / \u97F3\u9891" },
|
|
2767
|
+
{ "id": "videos.getShowcaseVideo", "method": "GET", "path": "/api/showcase-videos/:id", "source": "web-src/src/lib/api.ts:2709", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891" },
|
|
2768
|
+
{ "id": "videos.inspectCommercialAdRootAttachments", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/attachments", "source": "web-src/src/lib/api.ts:2434", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u9644\u4EF6" },
|
|
2769
|
+
{ "id": "videos.listCommercialAdAssetGapOptions", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/asset-gaps/:gapId/options", "source": "web-src/src/lib/api.ts:2299", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u7D20\u6750\u7F3A\u53E3 / \u9009\u9879" },
|
|
2770
|
+
{ "id": "videos.listCommercialAdAssets", "method": "GET", "path": "/api/showcase-videos/assets", "source": "web-src/src/lib/api.ts:2549", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u7D20\u6750" },
|
|
2771
|
+
{ "id": "videos.listCommercialAdImageEdits", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/image-edits", "source": "web-src/src/lib/api.ts:2201", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u56FE\u7247\u7F16\u8F91" },
|
|
2772
|
+
{ "id": "videos.listCommercialAdMusic", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/music", "source": "web-src/src/lib/api.ts:2188", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u914D\u4E50" },
|
|
2773
|
+
{ "id": "videos.listCommercialAdRunFileVersions", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/files/:path/versions", "source": "web-src/src/lib/api.ts:2230", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u6587\u4EF6 / \u7248\u672C" },
|
|
2774
|
+
{ "id": "videos.listCommercialAdRuns", "method": "GET", "path": "/api/showcase-videos/runs/actionable", "source": "web-src/src/lib/api.ts:2758", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u5F85\u5904\u7406\u4F5C\u54C1" },
|
|
2775
|
+
{ "id": "videos.listCommercialAdRuns.runs", "method": "GET", "path": "/api/showcase-videos/runs", "source": "web-src/src/lib/api.ts:2758", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u4F5C\u54C1" },
|
|
2776
|
+
{ "id": "videos.listShowcaseVideos", "method": "GET", "path": "/api/showcase-videos", "source": "web-src/src/lib/api.ts:2745", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891" },
|
|
2777
|
+
{ "id": "videos.motionReferences", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/motion-references", "source": "web-src/src/components/domain/commercial-ad-motion-references.tsx:78", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u52A8\u4F5C\u53C2\u8003" },
|
|
2778
|
+
{ "id": "videos.planShowcaseDuration", "method": "POST", "path": "/api/showcase-videos/plan-duration", "source": "web-src/src/lib/api.ts:2801", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891 / \u89C4\u5212\u65F6\u957F", "body": "json" },
|
|
2779
|
+
{ "id": "videos.playEdit", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/edits/:editId/video", "source": "apps/api/src/http/routes/showcase.ts:523", "group": "videos", "description": "\u8BFB\u53D6\u5546\u54C1\u89C6\u9891\u526A\u8F91\u7248" },
|
|
2780
|
+
{ "id": "videos.playMotionReference", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/motion-references/:candidateId/video", "source": "apps/api/src/http/routes/showcase.ts:759", "group": "videos", "description": "\u8BFB\u53D6\u52A8\u4F5C\u53C2\u8003\u7247\u6BB5" },
|
|
2781
|
+
{ "id": "videos.playSegment", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/production-segments/:index/video", "source": "apps/api/src/http/routes/showcase.ts:559", "group": "videos", "description": "\u8BFB\u53D6\u9010\u6BB5\u89C6\u9891" },
|
|
2782
|
+
{ "id": "videos.pollShowcaseAiPrompt", "method": "POST", "path": "/api/showcase-videos/ai-prompt", "source": "web-src/src/lib/api.ts:1190", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891 / \u521B\u4F5C\u65B9\u6848", "body": "json" },
|
|
2783
|
+
{ "id": "videos.pollShowcaseAiPrompt.ai_prompt", "method": "GET", "path": "/api/showcase-videos/ai-prompt/:receiptId", "source": "web-src/src/lib/api.ts:1202", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u521B\u4F5C\u65B9\u6848" },
|
|
2784
|
+
{ "id": "videos.postCommercialAdRootMessage", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/messages", "source": "web-src/src/lib/api.ts:2463", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u5BF9\u8BDD", "body": "json", "exampleBody": { "text": "\u5148\u6574\u7406\u6545\u4E8B\u811A\u672C\u548C\u5206\u955C\uFF0C\u62A5\u4EF7\u540E\u7B49\u6211\u786E\u8BA4" } },
|
|
2785
|
+
{ "id": "videos.quoteCommercialAdAreaEdit", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/image-edits/area/quote", "source": "web-src/src/lib/api.ts:2204", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5C40\u90E8\u4FEE\u6539 / \u62A5\u4EF7", "body": "multipart", "uploadPolicy": "mask", "uploadField": "mask" },
|
|
2786
|
+
{ "id": "videos.quoteShowcaseVideo", "method": "GET", "path": "/api/showcase-videos/quote", "source": "web-src/src/lib/api.ts:2769", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u62A5\u4EF7" },
|
|
2787
|
+
{ "id": "videos.redoShowcaseStoryboard", "method": "POST", "path": "/api/showcase-videos/:id/storyboard", "source": "web-src/src/lib/api.ts:2857", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891 / \u6545\u4E8B\u677F", "body": "json" },
|
|
2788
|
+
{ "id": "videos.renameCommercialAdAsset", "method": "PATCH", "path": "/api/showcase-videos/assets/:id", "source": "web-src/src/lib/api.ts:2554", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u66F4\u65B0\u5546\u54C1\u89C6\u9891 / \u7D20\u6750", "body": "json" },
|
|
2789
|
+
{ "id": "videos.resolveCommercialAdAssetGap", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/asset-gaps/:gapId/resolve", "source": "web-src/src/lib/api.ts:2272", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u7D20\u6750\u7F3A\u53E3 / \u5904\u7406\u7F3A\u53E3", "body": "json" },
|
|
2790
|
+
{ "id": "videos.resolveCommercialAdAssetGaps", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/asset-gaps/resolve-batch", "source": "web-src/src/lib/api.ts:2281", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u7D20\u6750\u7F3A\u53E3 / \u5904\u7406\u591A\u4E2A\u7D20\u6750\u7F3A\u53E3", "body": "json" },
|
|
2791
|
+
{ "id": "videos.restoreCommercialAdRunFileVersion", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/files/:path/versions/:versionId/restore", "source": "web-src/src/lib/api.ts:2258", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u7248\u672C / \u6062\u590D", "body": "json" },
|
|
2792
|
+
{ "id": "videos.resumeCommercialAdRootAfterProductImage", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/product-image-resume", "source": "web-src/src/lib/api.ts:2345", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u5546\u54C1\u56FE\u7247\u5C31\u7EEA\u540E\u7EE7\u7EED", "body": "json" },
|
|
2793
|
+
{ "id": "videos.retryCommercialAdFilmJoin", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/append-tasks/:taskId/retry-join", "source": "web-src/src/lib/api.ts:2198", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u8FFD\u52A0\u7247\u6BB5 / \u91CD\u65B0\u5408\u6210", "body": "json" },
|
|
2794
|
+
{ "id": "videos.retryCommercialAdRootFailedStep", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/retry-failed-step", "source": "web-src/src/lib/api.ts:2334", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u91CD\u8BD5\u5931\u8D25\u6B65\u9AA4", "body": "json" },
|
|
2795
|
+
{ "id": "videos.retryShowcaseVideo", "method": "POST", "path": "/api/showcase-videos/:id/retry", "source": "web-src/src/lib/api.ts:2851", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891 / \u91CD\u8BD5", "body": "json" },
|
|
2796
|
+
{ "id": "videos.saveCommercialAdImageEdit", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/image-edits/:sourceKind/:sourceId", "source": "web-src/src/lib/api.ts:2219", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u8BBE\u7F6E\u4F5C\u54C1 / \u56FE\u7247\u7F16\u8F91", "body": "binary", "uploadPolicy": "image" },
|
|
2797
|
+
{ "id": "videos.saveCommercialAdRootAttachmentFile", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/attachments/:attachmentId/file", "source": "web-src/src/lib/api.ts:2451", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u9644\u4EF6 / \u6587\u4EF6" },
|
|
2798
|
+
{ "id": "videos.selectCommercialAdVoiceCandidate", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/voice-selection", "source": "web-src/src/lib/api.ts:2169", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u8BBE\u7F6E\u4F5C\u54C1 / \u97F3\u8272\u9009\u62E9", "body": "json" },
|
|
2799
|
+
{ "id": "videos.selectMotionReference", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/motion-references/:candidateId/select", "source": "apps/api/src/http/routes/showcase.ts:754", "group": "videos", "description": "\u9009\u62E9\u52A8\u4F5C\u53C2\u8003", "body": "json" },
|
|
2800
|
+
{ "id": "videos.setCommercialAdSubtitles", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/subtitles", "source": "web-src/src/lib/api.ts:2151", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u8BBE\u7F6E\u4F5C\u54C1 / \u5B57\u5E55", "body": "json" },
|
|
2801
|
+
{ "id": "videos.startCommercialAdRun", "method": "POST", "path": "/api/showcase-videos/runs", "source": "web-src/src/lib/api.ts:2141", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891 / \u4F5C\u54C1", "body": "json" },
|
|
2802
|
+
{ "id": "videos.streamCommercialAdRootLive", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/live", "source": "web-src/src/lib/api.ts:2518", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u5B9E\u65F6\u8FDB\u5EA6" },
|
|
2803
|
+
{ "id": "videos.streamCommercialAdRootMessage", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/messages/stream", "source": "web-src/src/lib/api.ts:2497", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5BF9\u8BDD / \u5B9E\u65F6\u5BF9\u8BDD", "body": "json" },
|
|
2804
|
+
{ "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
|
+
{ "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
|
+
{ "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" }
|
|
2808
|
+
];
|
|
2809
|
+
|
|
2810
|
+
// src/web-operation-contract.ts
|
|
2811
|
+
import { extname } from "node:path";
|
|
2812
|
+
var BUSINESS_HEADERS = /* @__PURE__ */ new Set(["prefer", "x-script-fingerprint", "x-attachment-delivery", "x-attachment-name"]);
|
|
2813
|
+
function buildBusinessHeaders(operation, supplied = {}, filename) {
|
|
2814
|
+
const rules = operation.businessHeaders ?? {};
|
|
2815
|
+
const result = {};
|
|
2816
|
+
for (const [name2, rule] of Object.entries(rules)) {
|
|
2817
|
+
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) result[name2] = rule.default;
|
|
2819
|
+
if (rule.fromFilename && filename) {
|
|
2820
|
+
try {
|
|
2821
|
+
result[name2] = encodeURIComponent(filename);
|
|
2822
|
+
} catch {
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2131
2825
|
}
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
const
|
|
2135
|
-
|
|
2826
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2827
|
+
for (const [raw, value] of Object.entries(supplied)) {
|
|
2828
|
+
const name2 = raw.toLowerCase();
|
|
2829
|
+
if (!BUSINESS_HEADERS.has(name2) || !Object.hasOwn(rules, name2)) throw usageError(`\u64CD\u4F5C ${operation.id} \u4E0D\u63A5\u53D7\u8BF7\u6C42\u5934 ${raw}`);
|
|
2830
|
+
if (seen.has(name2)) throw usageError(`\u8BF7\u6C42\u5934 ${raw} \u91CD\u590D`);
|
|
2831
|
+
seen.add(name2);
|
|
2832
|
+
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
|
+
result[name2] = value;
|
|
2136
2834
|
}
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2835
|
+
for (const [name2, rule] of Object.entries(rules)) {
|
|
2836
|
+
const value = result[name2];
|
|
2837
|
+
if (rule.required && !value) throw usageError(`\u64CD\u4F5C ${operation.id} \u9700\u8981\u901A\u8FC7 --headers \u63D0\u4F9B ${name2}`);
|
|
2838
|
+
if (value && rule.values && !rule.values.includes(value)) throw usageError(`\u8BF7\u6C42\u5934 ${name2} \u53EA\u652F\u6301 ${rule.values.join("\u3001")}`);
|
|
2839
|
+
}
|
|
2840
|
+
return result;
|
|
2841
|
+
}
|
|
2842
|
+
var MIB = 1024 * 1024;
|
|
2843
|
+
var IMAGE = ["image/png", "image/jpeg", "image/webp"];
|
|
2844
|
+
var DOCUMENT = ["application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "text/plain", "text/markdown"];
|
|
2845
|
+
var VIDEO = ["video/mp4", "video/quicktime", "video/webm"];
|
|
2846
|
+
var CHAT_AUDIO = ["audio/mpeg", "audio/wav"];
|
|
2847
|
+
var SPEECH = ["audio/wav", "audio/mpeg", "audio/mp4", "audio/webm", "audio/ogg"];
|
|
2848
|
+
var MIME_BY_EXTENSION = {
|
|
2849
|
+
".png": "image/png",
|
|
2850
|
+
".jpg": "image/jpeg",
|
|
2851
|
+
".jpeg": "image/jpeg",
|
|
2852
|
+
".webp": "image/webp",
|
|
2853
|
+
".mp4": "video/mp4",
|
|
2854
|
+
".m4v": "video/mp4",
|
|
2855
|
+
".mov": "video/quicktime",
|
|
2856
|
+
".webm": "video/webm",
|
|
2857
|
+
".mp3": "audio/mpeg",
|
|
2858
|
+
".wav": "audio/wav",
|
|
2859
|
+
".m4a": "audio/mp4",
|
|
2860
|
+
".ogg": "audio/ogg",
|
|
2861
|
+
".oga": "audio/ogg",
|
|
2862
|
+
".aac": "audio/aac",
|
|
2863
|
+
".flac": "audio/flac",
|
|
2864
|
+
".opus": "audio/ogg",
|
|
2865
|
+
".pdf": "application/pdf",
|
|
2866
|
+
".docx": DOCUMENT[1],
|
|
2867
|
+
".txt": "text/plain",
|
|
2868
|
+
".md": "text/markdown",
|
|
2869
|
+
".markdown": "text/markdown"
|
|
2870
|
+
};
|
|
2871
|
+
function webUploadPolicy(operation, filename) {
|
|
2872
|
+
const extension = extname(filename).toLowerCase();
|
|
2873
|
+
const policy = operation.uploadPolicy;
|
|
2874
|
+
const mime = policy === "storySpeech" && extension === ".webm" ? "audio/webm" : MIME_BY_EXTENSION[extension];
|
|
2875
|
+
const unsupported = () => usageError(`\u64CD\u4F5C ${operation.id} \u4E0D\u652F\u6301\u6B64\u6587\u4EF6\u7C7B\u578B\uFF1A${extension || "\u65E0\u6269\u5C55\u540D"}`);
|
|
2876
|
+
if (!mime || !policy) throw unsupported();
|
|
2877
|
+
if (policy === "storySpeech") {
|
|
2878
|
+
if (!SPEECH.includes(mime)) throw unsupported();
|
|
2879
|
+
return { mime, maxBytes: 20 * MIB };
|
|
2880
|
+
}
|
|
2881
|
+
if (policy === "voiceSource") {
|
|
2882
|
+
if (!mime.startsWith("audio/") && !VIDEO.includes(mime)) throw unsupported();
|
|
2883
|
+
return { mime, maxBytes: 64 * MIB };
|
|
2884
|
+
}
|
|
2885
|
+
if (policy === "mask") {
|
|
2886
|
+
if (mime !== "image/png") throw unsupported();
|
|
2887
|
+
return { mime, maxBytes: 4 * MIB };
|
|
2888
|
+
}
|
|
2889
|
+
if (IMAGE.includes(mime)) return { mime, maxBytes: 15 * MIB };
|
|
2890
|
+
if (policy === "image") throw unsupported();
|
|
2891
|
+
if (DOCUMENT.includes(mime)) return { mime, maxBytes: 30 * MIB };
|
|
2892
|
+
if (policy === "chatAttachment" && (VIDEO.includes(mime) || CHAT_AUDIO.includes(mime))) return { mime, maxBytes: 90 * MIB };
|
|
2893
|
+
throw unsupported();
|
|
2141
2894
|
}
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2895
|
+
|
|
2896
|
+
// src/web-client.ts
|
|
2897
|
+
import { createHash as createHash3, randomBytes as randomBytes2 } from "node:crypto";
|
|
2898
|
+
import { constants as constants2 } from "node:fs";
|
|
2899
|
+
import { link, lstat as lstat2, open as open2, stat as stat2, unlink as unlink2 } from "node:fs/promises";
|
|
2900
|
+
import { basename as basename2, dirname as dirname2, extname as extname2, join as join3, resolve as resolve2 } from "node:path";
|
|
2901
|
+
var MAX_JSON_BYTES = 16 * 1024 * 1024;
|
|
2902
|
+
var MAX_DOWNLOAD_BYTES2 = 1024 * 1024 * 1024;
|
|
2903
|
+
var secretFields = /* @__PURE__ */ new Set(["token", "sessiontoken", "accesstoken", "refreshtoken", "password", "currentpassword", "newpassword", "secret", "clientsecret", "authorization", "cookie", "privatekey", "rawkey"]);
|
|
2904
|
+
function redactWebValue(value, secrets = []) {
|
|
2905
|
+
if (typeof value === "string") return secrets.reduce((text, secret) => secret ? text.split(secret).join("[redacted]") : text, redactKeys(value));
|
|
2906
|
+
if (Array.isArray(value)) return value.map((item) => redactWebValue(item, secrets));
|
|
2907
|
+
if (!value || typeof value !== "object") return value;
|
|
2908
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [
|
|
2909
|
+
key,
|
|
2910
|
+
secretFields.has(key.toLowerCase().replace(/[_-]/gu, "")) || key === "apiKey" && typeof item === "string" ? "[redacted]" : redactWebValue(item, secrets)
|
|
2911
|
+
]));
|
|
2912
|
+
}
|
|
2913
|
+
function webSecrets(value) {
|
|
2914
|
+
if (!value || typeof value !== "object") return [];
|
|
2915
|
+
return Object.entries(value).flatMap(([key, item]) => secretFields.has(key.toLowerCase().replace(/[_-]/gu, "")) || key === "apiKey" ? typeof item === "string" ? [item] : webSecrets(item) : webSecrets(item));
|
|
2916
|
+
}
|
|
2917
|
+
function badResponse(status4) {
|
|
2918
|
+
return new CliError({ code: "CLI_BAD_RESPONSE", exitCode: EXIT.SERVER, message: "\u7F51\u9875\u63A5\u53E3\u54CD\u5E94\u683C\u5F0F\u65E0\u6548\uFF0C\u672A\u4FDD\u5B58\u4E3A\u4EA4\u4ED8\u6587\u4EF6", httpStatus: status4 });
|
|
2919
|
+
}
|
|
2920
|
+
async function checkWebOutput(path) {
|
|
2921
|
+
const target = resolve2(path);
|
|
2922
|
+
try {
|
|
2923
|
+
const info = await lstat2(target);
|
|
2924
|
+
if (info) throw usageError("\u8F93\u51FA\u8DEF\u5F84\u5DF2\u7ECF\u5B58\u5728\uFF1B\u8BF7\u9009\u62E9\u65B0\u6587\u4EF6\uFF0C\u672C\u6B21\u4E0D\u4F1A\u8986\u76D6\u539F\u6587\u4EF6");
|
|
2925
|
+
} catch (error) {
|
|
2926
|
+
if (error?.code !== "ENOENT") throw error;
|
|
2927
|
+
}
|
|
2928
|
+
try {
|
|
2929
|
+
if (!(await stat2(dirname2(target))).isDirectory()) throw new Error();
|
|
2930
|
+
} catch {
|
|
2931
|
+
throw usageError("\u8F93\u51FA\u76EE\u5F55\u4E0D\u5B58\u5728\u6216\u4E0D\u53EF\u8BBF\u95EE\uFF0C\u8BF7\u5148\u521B\u5EFA\u76EE\u5F55");
|
|
2932
|
+
}
|
|
2933
|
+
return target;
|
|
2934
|
+
}
|
|
2935
|
+
async function atomicWebOutput(path, signal, feed) {
|
|
2936
|
+
const target = await checkWebOutput(path);
|
|
2937
|
+
const temp = join3(dirname2(target), `.${basename2(target)}.${process.pid}.${randomBytes2(8).toString("hex")}.tmp`);
|
|
2938
|
+
const handle = await open2(temp, constants2.O_CREAT | constants2.O_EXCL | constants2.O_WRONLY | (constants2.O_NOFOLLOW ?? 0), 384);
|
|
2939
|
+
let bytes = 0;
|
|
2940
|
+
const hash = createHash3("sha256");
|
|
2941
|
+
try {
|
|
2942
|
+
await feed(async (chunk) => {
|
|
2943
|
+
if (signal.aborted) throw signal.reason;
|
|
2944
|
+
bytes += chunk.byteLength;
|
|
2945
|
+
if (bytes > MAX_DOWNLOAD_BYTES2) throw usageError("\u4E0B\u8F7D\u6587\u4EF6\u8D85\u8FC7 1 GiB \u4E0A\u9650");
|
|
2946
|
+
hash.update(chunk);
|
|
2947
|
+
await handle.writeFile(chunk);
|
|
2948
|
+
});
|
|
2949
|
+
await handle.sync();
|
|
2950
|
+
await handle.close();
|
|
2951
|
+
if (signal.aborted) throw signal.reason;
|
|
2952
|
+
await link(temp, target);
|
|
2953
|
+
return { path: target, bytes, sha256: hash.digest("hex") };
|
|
2954
|
+
} catch (error) {
|
|
2955
|
+
if (error instanceof CliError) throw error;
|
|
2956
|
+
throw new CliError({ code: "CLI_WEB_OUTPUT_FAILED", exitCode: EXIT.SERVER, message: "\u8F93\u51FA\u6587\u4EF6\u4FDD\u5B58\u5931\u8D25\uFF1B\u539F\u6587\u4EF6\u672A\u8986\u76D6\uFF0C\u8BF7\u68C0\u67E5\u76EE\u5F55\u6743\u9650\u4E0E\u78C1\u76D8\u7A7A\u95F4" });
|
|
2957
|
+
} finally {
|
|
2958
|
+
await handle.close().catch(() => void 0);
|
|
2959
|
+
await unlink2(temp).catch(() => void 0);
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
async function saveWebDocument(path, data, signal) {
|
|
2963
|
+
return atomicWebOutput(path, signal ?? new AbortController().signal, (write) => write(Buffer.from(`${JSON.stringify(data, null, 2)}
|
|
2964
|
+
`)));
|
|
2965
|
+
}
|
|
2966
|
+
async function consume(response, signal, max, onChunk) {
|
|
2967
|
+
if (!response.body) return 0;
|
|
2968
|
+
const reader = response.body.getReader();
|
|
2969
|
+
let total = 0;
|
|
2970
|
+
const cancel3 = () => {
|
|
2971
|
+
void reader.cancel().catch(() => void 0);
|
|
2972
|
+
};
|
|
2973
|
+
signal.addEventListener("abort", cancel3, { once: true });
|
|
2974
|
+
try {
|
|
2975
|
+
for (; ; ) {
|
|
2976
|
+
if (signal.aborted) throw signal.reason;
|
|
2977
|
+
const { value, done } = await reader.read();
|
|
2978
|
+
if (signal.aborted) throw signal.reason;
|
|
2979
|
+
if (done) break;
|
|
2980
|
+
total += value.byteLength;
|
|
2981
|
+
if (total > max) throw badResponse(response.status);
|
|
2982
|
+
if (await onChunk(value) === false) break;
|
|
2983
|
+
}
|
|
2984
|
+
return total;
|
|
2985
|
+
} finally {
|
|
2986
|
+
signal.removeEventListener("abort", cancel3);
|
|
2987
|
+
void reader.cancel().catch(() => void 0);
|
|
2988
|
+
}
|
|
2989
|
+
}
|
|
2990
|
+
async function jsonBody(response, signal) {
|
|
2991
|
+
const chunks = [];
|
|
2992
|
+
await consume(response, signal, MAX_JSON_BYTES, (chunk) => {
|
|
2993
|
+
chunks.push(chunk);
|
|
2994
|
+
});
|
|
2995
|
+
if (chunks.length === 0 && response.status === 204) return null;
|
|
2996
|
+
try {
|
|
2997
|
+
return JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
2998
|
+
} catch {
|
|
2999
|
+
throw badResponse(response.status);
|
|
3000
|
+
}
|
|
3001
|
+
}
|
|
3002
|
+
function serverFailure(status4, body, secrets) {
|
|
3003
|
+
secrets = [...secrets, ...webSecrets(body)];
|
|
3004
|
+
const data = body && typeof body === "object" ? body : {};
|
|
3005
|
+
const nested = data.error && typeof data.error === "object" ? data.error : data;
|
|
3006
|
+
const message2 = typeof nested.message === "string" ? nested.message : typeof data.error === "string" ? data.error : `\u7F51\u9875\u8BF7\u6C42\u5931\u8D25\uFF08HTTP ${status4}\uFF09`;
|
|
3007
|
+
return new CliError({
|
|
3008
|
+
code: typeof nested.code === "string" ? String(redactWebValue(nested.code, secrets)) : "CLI_WEB_REQUEST_FAILED",
|
|
3009
|
+
exitCode: exitCodeForHttpStatus(status4),
|
|
3010
|
+
httpStatus: status4,
|
|
3011
|
+
message: String(redactWebValue(message2, secrets)),
|
|
3012
|
+
retryable: status4 === 408 || status4 === 429 || status4 >= 500,
|
|
3013
|
+
...typeof nested.traceId === "string" ? { traceId: String(redactWebValue(nested.traceId, secrets)) } : {},
|
|
3014
|
+
...typeof nested.retryAfterSeconds === "number" ? { retryAfterSeconds: nested.retryAfterSeconds } : {}
|
|
3015
|
+
});
|
|
3016
|
+
}
|
|
3017
|
+
function taskIdOf(value) {
|
|
3018
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
3019
|
+
const data = value;
|
|
3020
|
+
for (const key of ["taskId", "rootRunId", "runId", "projectId"]) if (typeof data[key] === "string" && data[key]) return data[key];
|
|
3021
|
+
for (const key of ["run", "task", "project", "data"]) {
|
|
3022
|
+
const nested = data[key];
|
|
3023
|
+
const found = taskIdOf(nested);
|
|
3024
|
+
if (found) return found;
|
|
3025
|
+
if (key !== "data" && nested && typeof nested === "object" && !Array.isArray(nested) && typeof nested.id === "string") return nested.id;
|
|
3026
|
+
}
|
|
3027
|
+
return void 0;
|
|
3028
|
+
}
|
|
3029
|
+
function mediaPrefixValid(mime, prefix) {
|
|
3030
|
+
const start = prefix.toString("utf8").replace(/^\uFEFF/u, "").trimStart();
|
|
3031
|
+
if (mime === "text/html" || /^<(?:!doctype\s+html|html|head|body)(?:\s|>)/iu.test(start)) return false;
|
|
3032
|
+
if (mime === "video/mp4" || mime === "audio/mp4") return prefix.length >= 12 && prefix.toString("ascii", 4, 8) === "ftyp";
|
|
3033
|
+
if (mime === "video/quicktime") return prefix.length >= 12 && ["ftyp", "wide", "free", "mdat", "moov"].includes(prefix.toString("ascii", 4, 8));
|
|
3034
|
+
if (mime === "image/png") return prefix.subarray(0, 8).toString("hex") === "89504e470d0a1a0a";
|
|
3035
|
+
if (mime === "image/jpeg") return prefix.subarray(0, 3).toString("hex") === "ffd8ff";
|
|
3036
|
+
if (mime === "image/webp") return prefix.toString("ascii", 0, 4) === "RIFF" && prefix.toString("ascii", 8, 12) === "WEBP";
|
|
3037
|
+
if (mime === "image/gif") return /^GIF8[79]a/u.test(prefix.toString("ascii", 0, 6));
|
|
3038
|
+
if (mime === "application/pdf") return start.startsWith("%PDF-");
|
|
3039
|
+
if (["application/zip", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"].includes(mime)) return ["504b0304", "504b0506", "504b0708"].includes(prefix.subarray(0, 4).toString("hex"));
|
|
3040
|
+
if (["audio/wav", "audio/x-wav"].includes(mime)) return prefix.length >= 44 && prefix.toString("ascii", 0, 4) === "RIFF" && prefix.toString("ascii", 8, 12) === "WAVE";
|
|
3041
|
+
if (mime === "audio/mpeg") return prefix.length >= 3 && (prefix.toString("ascii", 0, 3) === "ID3" || prefix[0] === 255 && (prefix[1] & 224) === 224);
|
|
3042
|
+
if (mime === "audio/ogg") return prefix.toString("ascii", 0, 4) === "OggS";
|
|
3043
|
+
if (mime === "audio/flac") return prefix.toString("ascii", 0, 4) === "fLaC";
|
|
3044
|
+
if (mime === "video/webm" || mime === "audio/webm") return prefix.subarray(0, 4).toString("hex") === "1a45dfa3" && prefix.includes(Buffer.from("webm"));
|
|
3045
|
+
if (mime === "text/vtt") return !prefix.includes(0) && /^\uFEFF?WEBVTT(?:[ \t][^\r\n]*)?(?:\r?\n|$)/u.test(prefix.toString("utf8"));
|
|
3046
|
+
if (mime === "application/x-subrip") {
|
|
3047
|
+
if (prefix.includes(0)) return false;
|
|
3048
|
+
const cue = /^\uFEFF?\s*\d+\r?\n(\d{2,}):([0-5]\d):([0-5]\d),(\d{3})[ \t]+-->[ \t]+(\d{2,}):([0-5]\d):([0-5]\d),(\d{3})(?:[ \t][^\r\n]*)?\r?\n/u.exec(prefix.toString("utf8"));
|
|
3049
|
+
if (!cue) return false;
|
|
3050
|
+
const start2 = ((Number(cue[1]) * 60 + Number(cue[2])) * 60 + Number(cue[3])) * 1e3 + Number(cue[4]);
|
|
3051
|
+
const end = ((Number(cue[5]) * 60 + Number(cue[6])) * 60 + Number(cue[7])) * 1e3 + Number(cue[8]);
|
|
3052
|
+
return Number.isSafeInteger(start2) && Number.isSafeInteger(end) && end > start2;
|
|
3053
|
+
}
|
|
3054
|
+
if (["text/plain", "text/markdown", "text/csv"].includes(mime)) return !prefix.includes(0);
|
|
3055
|
+
return true;
|
|
3056
|
+
}
|
|
3057
|
+
async function requestWeb(io, request) {
|
|
3058
|
+
const baseUrl = normalizeBaseUrl(request.baseUrl);
|
|
3059
|
+
assertReachedDirectly(baseUrl, io.env);
|
|
3060
|
+
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
|
+
if (request.token?.startsWith("bk_")) throw usageError("API \u5BC6\u94A5\u4E0D\u80FD\u7528\u4E8E\u7F51\u9875\u63A5\u53E3");
|
|
3062
|
+
if (io.signal?.aborted) throw interruptedError();
|
|
3063
|
+
const controller = new AbortController();
|
|
3064
|
+
const secrets = [...request.secrets ?? [], ...request.token ? [request.token] : []];
|
|
3065
|
+
const headers = new Headers({ Accept: "application/json, text/event-stream, */*", "User-Agent": "bukesiyi-cli/web" });
|
|
3066
|
+
if (request.token) headers.set("Authorization", `Bearer ${request.token}`);
|
|
3067
|
+
if (request.workspaceId) headers.set("x-bukesiyi-workspace-id", request.workspaceId);
|
|
3068
|
+
if (request.contentType) headers.set("Content-Type", request.contentType);
|
|
3069
|
+
if (request.idempotencyKey) headers.set("Idempotency-Key", request.idempotencyKey);
|
|
3070
|
+
for (const [name2, value] of Object.entries(request.businessHeaders ?? {})) {
|
|
3071
|
+
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
|
+
headers.set(name2, value);
|
|
3073
|
+
}
|
|
3074
|
+
const timeoutMs = request.timeoutMs ?? io.requestTimeoutMs ?? 12e4;
|
|
3075
|
+
let timer;
|
|
3076
|
+
let responseReceived = false;
|
|
3077
|
+
let interrupt2 = () => void 0;
|
|
3078
|
+
const stopped = new Promise((_resolve, reject) => {
|
|
3079
|
+
interrupt2 = () => {
|
|
3080
|
+
const error = interruptedError();
|
|
3081
|
+
controller.abort(error);
|
|
3082
|
+
reject(error);
|
|
3083
|
+
};
|
|
3084
|
+
io.signal?.addEventListener("abort", interrupt2, { once: true });
|
|
3085
|
+
timer = setTimeout(() => {
|
|
3086
|
+
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
|
+
controller.abort(error);
|
|
3088
|
+
reject(error);
|
|
3089
|
+
}, timeoutMs);
|
|
3090
|
+
});
|
|
3091
|
+
const work = (async () => {
|
|
3092
|
+
const response = await io.fetch(`${baseUrl}${request.path}`, {
|
|
3093
|
+
method: request.method,
|
|
3094
|
+
headers,
|
|
3095
|
+
...request.body === void 0 ? {} : { body: request.body },
|
|
3096
|
+
redirect: "manual",
|
|
3097
|
+
signal: controller.signal
|
|
3098
|
+
});
|
|
3099
|
+
responseReceived = true;
|
|
3100
|
+
if (response.status >= 300 && response.status < 400) {
|
|
3101
|
+
await response.body?.cancel().catch(() => void 0);
|
|
3102
|
+
throw new CliError({ code: "CLI_REDIRECT_BLOCKED", exitCode: EXIT.SERVER, httpStatus: response.status, message: "\u7F51\u9875\u63A5\u53E3\u8FD4\u56DE\u91CD\u5B9A\u5411\uFF0C\u672A\u5411\u8DF3\u8F6C\u5730\u5740\u53D1\u9001\u4F1A\u8BDD\u51ED\u636E" });
|
|
3103
|
+
}
|
|
3104
|
+
if (response.status >= 400) {
|
|
3105
|
+
let body;
|
|
3106
|
+
try {
|
|
3107
|
+
body = await jsonBody(response, controller.signal);
|
|
3108
|
+
} catch (error) {
|
|
3109
|
+
if (controller.signal.aborted) throw error;
|
|
3110
|
+
}
|
|
3111
|
+
throw serverFailure(response.status, body, secrets);
|
|
3112
|
+
}
|
|
3113
|
+
const mime = response.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase() ?? "";
|
|
3114
|
+
if (mime === "text/event-stream") {
|
|
3115
|
+
const decoder = new TextDecoder();
|
|
3116
|
+
let buffer = "", eventCount = 0, completed = false;
|
|
3117
|
+
const events = [];
|
|
3118
|
+
const emit = (block) => {
|
|
3119
|
+
const lines2 = block.split("\n");
|
|
3120
|
+
const data = lines2.filter((line) => line.startsWith("data:")).map((line) => line.slice(5).replace(/^ /u, "")).join("\n");
|
|
3121
|
+
if (data === "[DONE]") {
|
|
3122
|
+
completed = true;
|
|
3123
|
+
return;
|
|
3124
|
+
}
|
|
3125
|
+
if (!data) return;
|
|
3126
|
+
let value;
|
|
3127
|
+
try {
|
|
3128
|
+
value = JSON.parse(data);
|
|
3129
|
+
} catch {
|
|
3130
|
+
value = { text: data };
|
|
3131
|
+
}
|
|
3132
|
+
secrets.push(...webSecrets(value));
|
|
3133
|
+
const taskId = taskIdOf(value);
|
|
3134
|
+
if (taskId) request.onTaskId?.(String(redactWebValue(taskId, secrets)));
|
|
3135
|
+
const safe2 = redactWebValue(value, secrets);
|
|
3136
|
+
const eventName = lines2.find((line) => line.startsWith("event:"))?.slice(6).trim();
|
|
3137
|
+
const payload = value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
3138
|
+
if (eventName === "error" || payload.type === "error") {
|
|
3139
|
+
const status4 = [payload.httpStatus, payload.status].find((item) => typeof item === "number" && Number.isInteger(item) && item >= 400 && item <= 599);
|
|
3140
|
+
throw serverFailure(typeof status4 === "number" ? status4 : 500, value, secrets);
|
|
3141
|
+
}
|
|
3142
|
+
events.push(eventName ? { event: eventName, data: safe2 } : safe2);
|
|
3143
|
+
if (events.length > 100) events.shift();
|
|
3144
|
+
eventCount++;
|
|
3145
|
+
request.onEvent?.(events.at(-1));
|
|
3146
|
+
if (eventName === "done" || payload.type === "done") completed = true;
|
|
3147
|
+
};
|
|
3148
|
+
await consume(response, controller.signal, MAX_JSON_BYTES, (chunk) => {
|
|
3149
|
+
buffer = (buffer + decoder.decode(chunk, { stream: true })).replace(/\r\n/gu, "\n");
|
|
3150
|
+
if (buffer.length > 1024 * 1024) throw badResponse(response.status);
|
|
3151
|
+
let boundary;
|
|
3152
|
+
while (!completed && (boundary = buffer.indexOf("\n\n")) >= 0) {
|
|
3153
|
+
emit(buffer.slice(0, boundary));
|
|
3154
|
+
buffer = buffer.slice(boundary + 2);
|
|
3155
|
+
}
|
|
3156
|
+
if (completed) return false;
|
|
3157
|
+
});
|
|
3158
|
+
buffer += decoder.decode();
|
|
3159
|
+
if (!completed && buffer.trim()) emit(buffer);
|
|
3160
|
+
if (!completed) throw new CliError({
|
|
3161
|
+
code: "CLI_STREAM_INCOMPLETE",
|
|
3162
|
+
exitCode: EXIT.SERVER,
|
|
3163
|
+
retryable: true,
|
|
3164
|
+
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
|
+
});
|
|
3166
|
+
const result = { status: response.status, events, eventCount };
|
|
3167
|
+
if (request.outPath) return { ...result, download: await atomicWebOutput(request.outPath, controller.signal, (write) => write(Buffer.from(`${JSON.stringify(result, null, 2)}
|
|
3168
|
+
`))) };
|
|
3169
|
+
return result;
|
|
3170
|
+
}
|
|
3171
|
+
if (mime.includes("json") || response.status === 204) {
|
|
3172
|
+
const data = await jsonBody(response, controller.signal);
|
|
3173
|
+
secrets.push(...webSecrets(data));
|
|
3174
|
+
if (request.method === "POST" && (request.path === "/api/auth/login" || request.sessionResponse === true) && data && typeof data === "object" && !Array.isArray(data)) {
|
|
3175
|
+
const token = data.token;
|
|
3176
|
+
if (typeof token === "string") secrets.push(token);
|
|
3177
|
+
request.onLogin?.(data);
|
|
3178
|
+
}
|
|
3179
|
+
const taskId = taskIdOf(data);
|
|
3180
|
+
if (taskId) request.onTaskId?.(String(redactWebValue(taskId, secrets)));
|
|
3181
|
+
const safe2 = request.secretOutput ? { saved: true } : redactWebValue(data, secrets);
|
|
3182
|
+
if (data && typeof data === "object" && data.error && data.ok === false) throw serverFailure(400, data, secrets);
|
|
3183
|
+
if (request.outPath) {
|
|
3184
|
+
if (response.status !== 200 && response.status !== 201) throw new CliError({ code: "CLI_DOWNLOAD_NOT_READY", exitCode: EXIT.RETRY_LATER, httpStatus: response.status, message: "\u64CD\u4F5C\u5C1A\u672A\u5B8C\u6210\uFF0C\u672A\u628A\u51C6\u5907\u54CD\u5E94\u4FDD\u5B58\u4E3A\u6587\u4EF6" });
|
|
3185
|
+
if (request.expectedFile) throw badResponse(response.status);
|
|
3186
|
+
const download5 = await atomicWebOutput(request.outPath, controller.signal, (write) => write(Buffer.from(`${JSON.stringify(request.secretOutput ? data : safe2, null, 2)}
|
|
3187
|
+
`)));
|
|
3188
|
+
return { status: response.status, data: safe2, download: download5 };
|
|
3189
|
+
}
|
|
3190
|
+
return { status: response.status, data: safe2 };
|
|
3191
|
+
}
|
|
3192
|
+
if (!request.outPath) {
|
|
3193
|
+
await response.body?.cancel().catch(() => void 0);
|
|
3194
|
+
throw usageError("\u8BE5\u64CD\u4F5C\u8FD4\u56DE\u6587\u4EF6\uFF0C\u8BF7\u4F7F\u7528 --out <\u65B0\u6587\u4EF6\u8DEF\u5F84>");
|
|
3195
|
+
}
|
|
3196
|
+
if (response.status !== 200) {
|
|
3197
|
+
await response.body?.cancel().catch(() => void 0);
|
|
3198
|
+
throw new CliError({ code: "CLI_DOWNLOAD_NOT_READY", exitCode: EXIT.RETRY_LATER, httpStatus: response.status, message: "\u4E0B\u8F7D\u5C1A\u672A\u5B8C\u6210\uFF0C\u672A\u4FDD\u5B58\u6587\u4EF6" });
|
|
3199
|
+
}
|
|
3200
|
+
const expectedSize = response.headers.get("content-length"), expectedHash = response.headers.get("x-content-sha256");
|
|
3201
|
+
const byExtension = { ".mp4": "video/mp4", ".mov": "video/quicktime", ".webm": "video/webm", ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp", ".zip": "application/zip", ".pdf": "application/pdf", ".wav": "audio/wav", ".mp3": "audio/mpeg", ".vtt": "text/vtt", ".srt": "application/x-subrip" };
|
|
3202
|
+
const expectedMime = byExtension[extname2(request.outPath).toLowerCase()];
|
|
3203
|
+
if (expectedMime && mime && mime !== "application/octet-stream" && mime !== expectedMime && !(expectedMime === "audio/wav" && mime === "audio/x-wav")) {
|
|
3204
|
+
await response.body?.cancel().catch(() => void 0);
|
|
3205
|
+
throw badResponse(response.status);
|
|
3206
|
+
}
|
|
3207
|
+
const validationMime = !mime || mime === "application/octet-stream" ? expectedMime ?? mime : mime;
|
|
3208
|
+
const download4 = await atomicWebOutput(request.outPath, controller.signal, async (write) => {
|
|
3209
|
+
let prefix = Buffer.alloc(0);
|
|
3210
|
+
const hash = createHash3("sha256");
|
|
3211
|
+
const size = await consume(response, controller.signal, MAX_DOWNLOAD_BYTES2, async (chunk) => {
|
|
3212
|
+
if (prefix.length < 1024) prefix = Buffer.concat([prefix, Buffer.from(chunk).subarray(0, 1024 - prefix.length)]);
|
|
3213
|
+
hash.update(chunk);
|
|
3214
|
+
await write(chunk);
|
|
3215
|
+
});
|
|
3216
|
+
if (size === 0 || !mediaPrefixValid(validationMime, prefix) || expectedSize !== null && (!/^\d+$/u.test(expectedSize) || Number(expectedSize) !== size) || expectedHash !== null && (!/^[a-f0-9]{64}$/iu.test(expectedHash) || hash.digest("hex") !== expectedHash.toLowerCase())) throw badResponse(response.status);
|
|
3217
|
+
});
|
|
3218
|
+
return { status: response.status, download: download4 };
|
|
3219
|
+
})();
|
|
3220
|
+
work.catch(() => void 0);
|
|
3221
|
+
try {
|
|
3222
|
+
return await Promise.race([work, stopped]);
|
|
3223
|
+
} catch (error) {
|
|
3224
|
+
if (controller.signal.aborted && responseReceived) {
|
|
3225
|
+
let cleanupTimer;
|
|
3226
|
+
await Promise.race([work.catch(() => void 0), new Promise((resolve3) => {
|
|
3227
|
+
cleanupTimer = setTimeout(resolve3, 1e3);
|
|
3228
|
+
})]);
|
|
3229
|
+
clearTimeout(cleanupTimer);
|
|
3230
|
+
}
|
|
3231
|
+
if (error instanceof CliError) throw error;
|
|
3232
|
+
if (io.signal?.aborted) throw interruptedError();
|
|
3233
|
+
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
|
+
} finally {
|
|
3235
|
+
clearTimeout(timer);
|
|
3236
|
+
io.signal?.removeEventListener("abort", interrupt2);
|
|
3237
|
+
}
|
|
3238
|
+
}
|
|
3239
|
+
|
|
3240
|
+
// src/web-session.ts
|
|
3241
|
+
import { createHash as createHash4, createHmac, randomBytes as randomBytes3 } from "node:crypto";
|
|
3242
|
+
import { constants as constants3 } from "node:fs";
|
|
3243
|
+
import { chmod as chmod2, lstat as lstat3, mkdir as mkdir3, open as open3, readdir as readdir2, rename as rename2, unlink as unlink3 } from "node:fs/promises";
|
|
3244
|
+
import { dirname as dirname3, join as join4, parse } from "node:path";
|
|
3245
|
+
import { StringDecoder } from "node:string_decoder";
|
|
3246
|
+
var noFollow = constants3.O_NOFOLLOW ?? 0;
|
|
3247
|
+
var nonBlock = constants3.O_NONBLOCK ?? 0;
|
|
3248
|
+
var stateNames = /* @__PURE__ */ new Set(["session.json", "last-web-request.json"]);
|
|
3249
|
+
var missing = (error) => error?.code === "ENOENT";
|
|
3250
|
+
function stateError(message2) {
|
|
3251
|
+
return new CliError({ code: "CLI_WEB_SESSION", exitCode: EXIT.SERVER, message: message2 });
|
|
3252
|
+
}
|
|
3253
|
+
function validateSessionToken(value) {
|
|
3254
|
+
if (typeof value !== "string" || value.startsWith("bk_") || !/^[A-Za-z0-9._~-]{20,512}$/u.test(value)) {
|
|
3255
|
+
throw usageError("\u7F51\u9875\u4F1A\u8BDD\u65E0\u6548\uFF1B\u8BF7\u8FD0\u884C buke web login\uFF0CAPI \u5BC6\u94A5\u4E0D\u80FD\u4F5C\u4E3A\u7F51\u9875\u767B\u5F55\u51ED\u636E");
|
|
3256
|
+
}
|
|
3257
|
+
return value;
|
|
3258
|
+
}
|
|
3259
|
+
function webStatePath(io, name2 = "session.json") {
|
|
3260
|
+
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(io), name2);
|
|
3262
|
+
}
|
|
3263
|
+
async function guardAncestors(path) {
|
|
3264
|
+
let current = path;
|
|
3265
|
+
for (; ; ) {
|
|
3266
|
+
try {
|
|
3267
|
+
const info = await lstat3(current);
|
|
3268
|
+
if (info.isSymbolicLink() || !info.isDirectory()) throw stateError("\u7F51\u9875\u51ED\u636E\u76EE\u5F55\u4E0D\u80FD\u7ECF\u8FC7\u7B26\u53F7\u94FE\u63A5\u6216\u975E\u76EE\u5F55\u6587\u4EF6");
|
|
3269
|
+
} catch (error) {
|
|
3270
|
+
if (!missing(error)) throw error;
|
|
3271
|
+
}
|
|
3272
|
+
if (current === parse(current).root) break;
|
|
3273
|
+
current = dirname3(current);
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
async function guardStateFile(path, io, transientTicket = false) {
|
|
3277
|
+
try {
|
|
3278
|
+
const info = await lstat3(path);
|
|
3279
|
+
if (transientTicket && info.isFile() && info.nlink === 0) return await guardStateFile(path, io, true);
|
|
3280
|
+
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 (io.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
|
+
} catch (error) {
|
|
3283
|
+
if (!missing(error)) throw error;
|
|
3284
|
+
}
|
|
3285
|
+
}
|
|
3286
|
+
async function readWebState(io, name2) {
|
|
3287
|
+
const path = webStatePath(io, name2);
|
|
3288
|
+
try {
|
|
3289
|
+
await guardAncestors(dirname3(path));
|
|
3290
|
+
await guardStateFile(path, io, name2.startsWith("web-lock-"));
|
|
3291
|
+
const handle = await open3(path, constants3.O_RDONLY | noFollow | nonBlock);
|
|
3292
|
+
try {
|
|
3293
|
+
const info = await handle.stat();
|
|
3294
|
+
if (info.nlink === 0 && name2.startsWith("web-lock-")) return await readWebState(io, name2);
|
|
3295
|
+
if (!info.isFile() || info.nlink !== 1 || info.size > 64 * 1024 || io.platform !== "win32" && (info.mode & 63) !== 0) throw stateError("\u7F51\u9875\u72B6\u6001\u6587\u4EF6\u65E0\u6548");
|
|
3296
|
+
const value = JSON.parse(await handle.readFile("utf8"));
|
|
3297
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw stateError("\u7F51\u9875\u72B6\u6001\u6587\u4EF6\u683C\u5F0F\u65E0\u6548");
|
|
3298
|
+
return value;
|
|
3299
|
+
} finally {
|
|
3300
|
+
await handle.close();
|
|
3301
|
+
}
|
|
3302
|
+
} catch (error) {
|
|
3303
|
+
if (missing(error)) return null;
|
|
3304
|
+
if (error instanceof CliError) throw error;
|
|
3305
|
+
throw stateError("\u65E0\u6CD5\u8BFB\u53D6\u7F51\u9875\u72B6\u6001\u6587\u4EF6\uFF0C\u8BF7\u68C0\u67E5\u76EE\u5F55\u4E0E\u6587\u4EF6\u6743\u9650");
|
|
3306
|
+
}
|
|
3307
|
+
}
|
|
3308
|
+
async function writeWebState(io, name2, value) {
|
|
3309
|
+
const path = webStatePath(io, name2), dir = dirname3(path);
|
|
3310
|
+
const temp = join4(dir, `.${name2}.${process.pid}.${randomBytes3(8).toString("hex")}.tmp`);
|
|
3311
|
+
let created = false;
|
|
3312
|
+
try {
|
|
3313
|
+
await guardAncestors(dir);
|
|
3314
|
+
await mkdir3(dir, { recursive: true, mode: 448 });
|
|
3315
|
+
await guardAncestors(dir);
|
|
3316
|
+
if (io.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");
|
|
3317
|
+
await guardStateFile(path, io);
|
|
3318
|
+
const handle = await open3(temp, constants3.O_CREAT | constants3.O_EXCL | constants3.O_WRONLY | noFollow, 384);
|
|
3319
|
+
created = true;
|
|
3320
|
+
try {
|
|
3321
|
+
await handle.writeFile(`${JSON.stringify(value, null, 2)}
|
|
3322
|
+
`);
|
|
3323
|
+
await handle.sync();
|
|
3324
|
+
} finally {
|
|
3325
|
+
await handle.close();
|
|
3326
|
+
}
|
|
3327
|
+
await guardStateFile(path, io);
|
|
3328
|
+
await rename2(temp, path);
|
|
3329
|
+
created = false;
|
|
3330
|
+
await chmod2(path, 384);
|
|
3331
|
+
return path;
|
|
3332
|
+
} catch (error) {
|
|
3333
|
+
if (created) await unlink3(temp).catch(() => void 0);
|
|
3334
|
+
if (error instanceof CliError) throw error;
|
|
3335
|
+
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
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
async function deleteWebSession(io, expected) {
|
|
3339
|
+
const current = await readWebState(io, "session.json");
|
|
3340
|
+
if (current?.token !== expected.token || current?.baseUrl !== expected.baseUrl) return;
|
|
3341
|
+
await unlink3(webStatePath(io)).catch((error) => {
|
|
3342
|
+
if (!missing(error)) throw stateError("\u670D\u52A1\u7AEF\u5DF2\u9000\u51FA\uFF0C\u4F46\u672C\u5730\u4F1A\u8BDD\u6587\u4EF6\u5220\u9664\u5931\u8D25");
|
|
3343
|
+
});
|
|
3344
|
+
}
|
|
3345
|
+
async function lockWebRequest(io, hash) {
|
|
3346
|
+
if (!/^[a-f0-9]{64}$/u.test(hash)) throw stateError("\u7F51\u9875\u8BF7\u6C42\u9501\u6807\u8BC6\u65E0\u6548");
|
|
3347
|
+
const nonce = randomBytes3(16).toString("hex"), prefix = `web-lock-${hash}-`;
|
|
3348
|
+
const name2 = `${prefix}${process.pid}-${nonce}.json`;
|
|
3349
|
+
const mine = { version: 1, pid: process.pid, nonce, choosing: true, ticket: 0 };
|
|
3350
|
+
const release2 = async () => {
|
|
3351
|
+
const current = await readWebState(io, name2);
|
|
3352
|
+
if (current?.nonce === nonce && current.pid === process.pid) await unlink3(webStatePath(io, name2)).catch((error) => {
|
|
3353
|
+
if (!missing(error)) throw error;
|
|
3354
|
+
});
|
|
3355
|
+
};
|
|
3356
|
+
const participants = async () => {
|
|
3357
|
+
await guardAncestors(credentialsDir(io));
|
|
3358
|
+
const names = (await readdir2(credentialsDir(io))).filter((candidate) => candidate.startsWith(prefix) && /^web-lock-[a-f0-9]{64}-\d+-[a-f0-9]{32}\.json$/u.test(candidate));
|
|
3359
|
+
const records = [];
|
|
3360
|
+
for (const candidate of names) {
|
|
3361
|
+
const value = await readWebState(io, candidate);
|
|
3362
|
+
if (!value) continue;
|
|
3363
|
+
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
|
+
let alive = true;
|
|
3365
|
+
try {
|
|
3366
|
+
process.kill(Number(value.pid), 0);
|
|
3367
|
+
} catch (error) {
|
|
3368
|
+
if (error.code === "ESRCH") alive = false;
|
|
3369
|
+
}
|
|
3370
|
+
if (!alive) {
|
|
3371
|
+
await unlink3(webStatePath(io, candidate)).catch((error) => {
|
|
3372
|
+
if (!missing(error)) throw error;
|
|
3373
|
+
});
|
|
3374
|
+
} else records.push({ name: candidate, ticket: Number(value.ticket), choosing: value.choosing });
|
|
3375
|
+
}
|
|
3376
|
+
return records;
|
|
3377
|
+
};
|
|
3378
|
+
await writeWebState(io, name2, mine);
|
|
3379
|
+
try {
|
|
3380
|
+
const others = await participants();
|
|
3381
|
+
mine.ticket = Math.max(0, ...others.map((value) => value.ticket)) + 1;
|
|
3382
|
+
if (!Number.isSafeInteger(mine.ticket)) throw stateError("\u7F51\u9875\u8BF7\u6C42\u9501\u7968\u53F7\u8D85\u51FA\u8303\u56F4");
|
|
3383
|
+
mine.choosing = false;
|
|
3384
|
+
await writeWebState(io, name2, mine);
|
|
3385
|
+
const deadline = Date.now() + 12e4;
|
|
3386
|
+
for (; ; ) {
|
|
3387
|
+
if (io.signal?.aborted) throw interruptedError();
|
|
3388
|
+
const blocked = (await participants()).some((other) => other.name !== name2 && (other.choosing || other.ticket < mine.ticket || other.ticket === mine.ticket && other.name < name2));
|
|
3389
|
+
if (!blocked) return release2;
|
|
3390
|
+
if (Date.now() >= deadline) throw new CliError({
|
|
3391
|
+
code: "CLI_WEB_REQUEST_BUSY",
|
|
3392
|
+
exitCode: EXIT.RETRY_LATER,
|
|
3393
|
+
message: "\u76F8\u540C\u7F51\u9875\u8BF7\u6C42\u6B63\u5728\u7531\u53E6\u4E00\u4E2A CLI \u8FDB\u7A0B\u5904\u7406\uFF0C\u672C\u6B21\u672A\u63D0\u4EA4\uFF1B\u8BF7\u67E5\u8BE2\u539F\u64CD\u4F5C\u7ED3\u679C"
|
|
3394
|
+
});
|
|
3395
|
+
await new Promise((resolve3) => setTimeout(resolve3, 25));
|
|
3396
|
+
}
|
|
3397
|
+
} catch (error) {
|
|
3398
|
+
await release2().catch(() => void 0);
|
|
3399
|
+
throw error;
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
async function fingerprintWebRequest(io, scope, value) {
|
|
3403
|
+
const scopeHash = createHash4("sha256").update(JSON.stringify(scope)).digest("hex");
|
|
3404
|
+
const name2 = `web-fingerprint-${scopeHash}.json`;
|
|
3405
|
+
const release2 = await lockWebRequest(io, createHash4("sha256").update(`fingerprint:${scopeHash}`).digest("hex"));
|
|
3406
|
+
try {
|
|
3407
|
+
let stored = await readWebState(io, name2);
|
|
3408
|
+
if (!stored) {
|
|
3409
|
+
stored = { version: 1, key: randomBytes3(32).toString("hex") };
|
|
3410
|
+
await writeWebState(io, name2, stored);
|
|
3411
|
+
}
|
|
3412
|
+
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
|
+
return createHmac("sha256", Buffer.from(stored.key, "hex")).update(JSON.stringify(value)).digest("hex");
|
|
3414
|
+
} finally {
|
|
3415
|
+
await release2();
|
|
3416
|
+
}
|
|
3417
|
+
}
|
|
3418
|
+
async function resolveWebSession(context) {
|
|
3419
|
+
const explicit = explicitBaseUrl(context.baseUrl, context.io.env);
|
|
3420
|
+
const supplied = context.io.env.BUKE_SESSION_TOKEN?.trim();
|
|
3421
|
+
if (supplied) {
|
|
3422
|
+
const token2 = validateSessionToken(supplied);
|
|
3423
|
+
context.out.protect(token2);
|
|
3424
|
+
return { version: 1, token: token2, baseUrl: explicit ?? DEFAULT_BASE_URL, savedAt: "", source: "env" };
|
|
3425
|
+
}
|
|
3426
|
+
const stored = await readWebState(context.io, "session.json");
|
|
3427
|
+
if (!stored) throw new CliError({
|
|
3428
|
+
code: "CLI_WEB_NOT_LOGGED_IN",
|
|
3429
|
+
exitCode: EXIT.AUTH,
|
|
3430
|
+
message: "\u5C1A\u672A\u767B\u5F55\u7F51\u9875\u4F1A\u8BDD\uFF0C\u8BF7\u8FD0\u884C buke web login\uFF1Bbuke login \u4FDD\u5B58\u7684 API \u5BC6\u94A5\u4E0D\u80FD\u7528\u4E8E\u7F51\u9875\u63A5\u53E3"
|
|
3431
|
+
});
|
|
3432
|
+
if (stored.version !== 1 || typeof stored.baseUrl !== "string" || typeof stored.savedAt !== "string") throw stateError("\u7F51\u9875\u4F1A\u8BDD\u6587\u4EF6\u683C\u5F0F\u65E0\u6548\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55");
|
|
3433
|
+
const token = validateSessionToken(stored.token), baseUrl = normalizeBaseUrl(stored.baseUrl);
|
|
3434
|
+
context.out.protect(token);
|
|
3435
|
+
if (explicit && explicit !== baseUrl) throw usageError("\u7F51\u9875\u4F1A\u8BDD\u4E0E\u670D\u52A1\u5730\u5740\u4E0D\u5339\u914D\uFF1B\u5207\u6362\u670D\u52A1\u8BF7\u91CD\u65B0\u8FD0\u884C buke web login");
|
|
3436
|
+
return {
|
|
3437
|
+
version: 1,
|
|
3438
|
+
token,
|
|
3439
|
+
baseUrl,
|
|
3440
|
+
savedAt: stored.savedAt,
|
|
3441
|
+
source: "file",
|
|
3442
|
+
...typeof stored.expiresAt === "string" ? { expiresAt: stored.expiresAt } : {}
|
|
3443
|
+
};
|
|
3444
|
+
}
|
|
3445
|
+
async function readWebPassword(io) {
|
|
3446
|
+
if (io.signal?.aborted) throw interruptedError();
|
|
3447
|
+
const fromEnv = io.env.BUKE_PASSWORD;
|
|
3448
|
+
if (fromEnv !== void 0) {
|
|
3449
|
+
if (!fromEnv || fromEnv.length > 8192 || /[\r\n\0]/u.test(fromEnv)) throw usageError("BUKE_PASSWORD \u4E0D\u80FD\u4E3A\u7A7A\u6216\u542B\u6362\u884C");
|
|
3450
|
+
return fromEnv;
|
|
3451
|
+
}
|
|
3452
|
+
const stream = io.stdin;
|
|
3453
|
+
const tty = stream.isTTY === true;
|
|
3454
|
+
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) io.stderr.write("\u7F51\u9875\u767B\u5F55\u5BC6\u7801\uFF08\u8F93\u5165\u4E0D\u663E\u793A\uFF09\uFF1A");
|
|
3456
|
+
const password = await new Promise((resolve3, reject) => {
|
|
3457
|
+
let value = "", done = false;
|
|
3458
|
+
const decoder = new StringDecoder("utf8");
|
|
3459
|
+
const finish = (error) => {
|
|
3460
|
+
if (done) return;
|
|
3461
|
+
done = true;
|
|
3462
|
+
clearTimeout(timer);
|
|
3463
|
+
for (const [name2, handler] of [["data", onData], ["end", onEnd], ["close", onEnd], ["error", onError]]) stream.removeListener(name2, handler);
|
|
3464
|
+
io.signal?.removeEventListener("abort", onAbort);
|
|
3465
|
+
if (tty) {
|
|
3466
|
+
stream.setRawMode(false);
|
|
3467
|
+
io.stderr.write("\n");
|
|
3468
|
+
}
|
|
3469
|
+
stream.pause();
|
|
3470
|
+
if (error) reject(error);
|
|
3471
|
+
else resolve3(value.replace(/\r?\n$/u, ""));
|
|
3472
|
+
};
|
|
3473
|
+
const onAbort = () => finish(interruptedError());
|
|
3474
|
+
const onEnd = () => {
|
|
3475
|
+
value += decoder.end();
|
|
3476
|
+
finish();
|
|
3477
|
+
};
|
|
3478
|
+
const onError = () => finish(usageError("\u65E0\u6CD5\u8BFB\u53D6\u5BC6\u7801\u8F93\u5165"));
|
|
3479
|
+
const onData = (chunk) => {
|
|
3480
|
+
const text = typeof chunk === "string" ? chunk : decoder.write(Buffer.from(chunk));
|
|
3481
|
+
if (tty) {
|
|
3482
|
+
for (const character of text) {
|
|
3483
|
+
if (character === "") {
|
|
3484
|
+
onAbort();
|
|
3485
|
+
return;
|
|
3486
|
+
}
|
|
3487
|
+
if (character === "\r" || character === "\n" || character === "") {
|
|
3488
|
+
finish();
|
|
3489
|
+
return;
|
|
3490
|
+
}
|
|
3491
|
+
if (character === "\b" || character === "\x7F") value = [...value].slice(0, -1).join("");
|
|
3492
|
+
else if (!/[\p{Cc}]/u.test(character)) value += character;
|
|
3493
|
+
}
|
|
3494
|
+
} else value += text;
|
|
3495
|
+
if (Buffer.byteLength(value) > 8192) finish(usageError("\u5BC6\u7801\u8F93\u5165\u8FC7\u957F"));
|
|
3496
|
+
};
|
|
3497
|
+
const timer = setTimeout(() => finish(usageError("\u7B49\u5F85\u5BC6\u7801\u8F93\u5165\u8D85\u65F6")), io.stdinTimeoutMs ?? 3e4);
|
|
3498
|
+
stream.on("data", onData);
|
|
3499
|
+
stream.on("end", onEnd);
|
|
3500
|
+
stream.on("close", onEnd);
|
|
3501
|
+
stream.on("error", onError);
|
|
3502
|
+
io.signal?.addEventListener("abort", onAbort, { once: true });
|
|
3503
|
+
if (tty) stream.setRawMode(true);
|
|
3504
|
+
stream.resume();
|
|
3505
|
+
});
|
|
3506
|
+
if (!password || /[\r\n\0]/u.test(password)) throw usageError("\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A\u6216\u5305\u542B\u6362\u884C");
|
|
3507
|
+
return password;
|
|
3508
|
+
}
|
|
3509
|
+
|
|
3510
|
+
// src/commands/web.ts
|
|
3511
|
+
var webCommand = {
|
|
3512
|
+
run: web,
|
|
3513
|
+
acceptsBaseUrl: true,
|
|
3514
|
+
options: ["username", "group", "params", "query", "data", "headers", "file", "files", "yes", "out", "timeout", "workspace", "idempotency-key"],
|
|
3515
|
+
positionals: ["\u5B50\u547D\u4EE4", "\u64CD\u4F5C\u7F16\u53F7"],
|
|
3516
|
+
help: [
|
|
3517
|
+
"\u7528\u6CD5\uFF1A",
|
|
3518
|
+
" 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
|
+
" buke web whoami [--workspace <\u5DE5\u4F5C\u533AID>] | logout",
|
|
3520
|
+
" buke web operations [--group <\u5206\u7EC4>]\uFF1A\u67E5\u770B\u56FA\u5B9A\u64CD\u4F5C\u76EE\u5F55\u3002",
|
|
3521
|
+
" buke web call <\u64CD\u4F5C\u7F16\u53F7> [--params <JSON\u6587\u4EF6|->] [--query <JSON\u6587\u4EF6>] [--data <JSON\u6587\u4EF6>]",
|
|
3522
|
+
" [--file <\u6587\u4EF6> | --files <\u5B57\u6BB5\u540D\u5230\u6587\u4EF6\u8DEF\u5F84\u7684JSON\u6587\u4EF6>] [--yes] [--out <\u65B0\u6587\u4EF6>]",
|
|
3523
|
+
" [--headers <\u4E1A\u52A1\u8BF7\u6C42\u5934JSON\u6587\u4EF6>] [--workspace <\u5DE5\u4F5C\u533AID>] [--idempotency-key <\u539F\u952E>] [--timeout <\u79D2>] [--json]",
|
|
3524
|
+
"\u6240\u6709\u5199\u64CD\u4F5C\u5FC5\u987B\u6DFB\u52A0 --yes\uFF1B\u8FD9\u53EA\u4EE3\u8868\u63D0\u4EA4\u672C\u6B21\u64CD\u4F5C\uFF0C\u8D39\u7528\u8303\u56F4\u4ECD\u7531\u7F51\u9875\u539F\u63A5\u53E3\u7684\u62A5\u4EF7\u4E0E\u786E\u8BA4\u7EA6\u675F\u3002",
|
|
3525
|
+
"\u53EA\u5141\u8BB8\u76EE\u5F55\u5185\u7684\u8DEF\u5F84\uFF0C\u5145\u503C\u53CA\u540E\u53F0\u7BA1\u7406\u4E0D\u5728\u76EE\u5F55\u4E2D\u3002\u4F1A\u8BDD\u4E0E API \u5BC6\u94A5\u5206\u522B\u4FDD\u5B58\uFF0C\u4E0D\u80FD\u6DF7\u7528\u3002",
|
|
3526
|
+
"\u9ED8\u8BA4\u8BF7\u6C42\u65F6\u9650 120 \u79D2\uFF1B\u6D41\u5F0F\u4E8B\u4EF6\u53EF\u4E2D\u65AD\u3002\u6587\u4EF6\u4EE5 0600 \u539F\u5B50\u4FDD\u5B58\uFF0C\u5DF2\u6709\u6587\u4EF6\u4E0D\u8986\u76D6\u3002",
|
|
3527
|
+
"API \u5BC6\u94A5\u7B7E\u53D1\u5FC5\u987B\u63D0\u4F9B --out\uFF0C\u660E\u6587\u53EA\u5199\u6587\u4EF6\uFF0C\u4E0D\u663E\u793A\u5728\u7EC8\u7AEF\u3002\u672A\u77E5\u7ED3\u679C\u4FDD\u7559\u539F\u952E\uFF0C\u4E0D\u81EA\u52A8\u91CD\u53D1\u3002"
|
|
3528
|
+
].join("\n")
|
|
3529
|
+
};
|
|
3530
|
+
function object(value) {
|
|
3531
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw usageError("\u8BF7\u6C42\u53C2\u6570\u5FC5\u987B\u662F JSON \u5BF9\u8C61");
|
|
3532
|
+
return value;
|
|
3533
|
+
}
|
|
3534
|
+
function issuedSession(context, baseUrl, data) {
|
|
3535
|
+
const user = data.user && typeof data.user === "object" && !Array.isArray(data.user) ? data.user : {};
|
|
3536
|
+
if (data.ok !== true || typeof data.expiresAt !== "string" || !Number.isFinite(Date.parse(data.expiresAt)) || 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
|
+
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
|
+
}
|
|
3539
|
+
const token = validateSessionToken(data.token);
|
|
3540
|
+
context.out.protect(token);
|
|
3541
|
+
return { version: 1, baseUrl, token, savedAt: (context.io.now?.() ?? /* @__PURE__ */ new Date()).toISOString(), expiresAt: data.expiresAt };
|
|
3542
|
+
}
|
|
3543
|
+
async function optionData(context, name2) {
|
|
3544
|
+
const file = textOption(context.values, name2);
|
|
3545
|
+
return file ? readPropsArgument(context.io, file, `--${name2}`) : {};
|
|
3546
|
+
}
|
|
3547
|
+
function workspaceOf(context) {
|
|
3548
|
+
const workspace = textOption(context.values, "workspace") ?? context.io.env.BUKE_WORKSPACE_ID?.trim();
|
|
3549
|
+
if (workspace && !/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/u.test(workspace)) throw usageError("\u5DE5\u4F5C\u533A\u7F16\u53F7\u683C\u5F0F\u65E0\u6548");
|
|
3550
|
+
return workspace || void 0;
|
|
3551
|
+
}
|
|
3552
|
+
function operationPath(operation, params, query) {
|
|
3553
|
+
const used = /* @__PURE__ */ new Set(), resolved = {};
|
|
3554
|
+
const path = operation.path.replace(/:([A-Za-z][A-Za-z0-9_]*)/gu, (_match, name2) => {
|
|
3555
|
+
const value = params[name2];
|
|
3556
|
+
const text = String(value);
|
|
3557
|
+
const invalidPath = name2 === "path" ? text.split("/").some((segment2) => !segment2 || segment2 === "." || segment2 === "..") : text.includes("/") || [".", ".."].includes(text);
|
|
3558
|
+
if (typeof value !== "string" && typeof value !== "number" || !text || /[\\%\p{Cc}]/u.test(text) || invalidPath) throw usageError(`\u8BF7\u5728 --params \u4E2D\u63D0\u4F9B\u6709\u6548\u8DEF\u5F84\u53C2\u6570 ${name2}`);
|
|
3559
|
+
used.add(name2);
|
|
3560
|
+
resolved[name2] = String(value);
|
|
3561
|
+
return encodeURIComponent(String(value));
|
|
3562
|
+
});
|
|
3563
|
+
if (Object.keys(params).some((name2) => !used.has(name2))) throw usageError("--params \u5305\u542B\u8BE5\u64CD\u4F5C\u4E0D\u4F7F\u7528\u7684\u53C2\u6570");
|
|
3564
|
+
const search = new URLSearchParams();
|
|
3565
|
+
for (const [name2, raw] of Object.entries(query)) {
|
|
3566
|
+
if (!name2 || /[\p{Cc}]/u.test(name2)) throw usageError("\u67E5\u8BE2\u53C2\u6570\u540D\u79F0\u65E0\u6548");
|
|
3567
|
+
for (const value of Array.isArray(raw) ? raw : [raw]) {
|
|
3568
|
+
if (value === null || value === void 0) continue;
|
|
3569
|
+
if (!["string", "number", "boolean"].includes(typeof value)) throw usageError("\u67E5\u8BE2\u53C2\u6570\u53EA\u652F\u6301\u5B57\u7B26\u4E32\u3001\u6570\u5B57\u3001\u5E03\u5C14\u503C\u53CA\u5176\u6570\u7EC4");
|
|
3570
|
+
search.append(name2, String(value));
|
|
3571
|
+
}
|
|
3572
|
+
}
|
|
3573
|
+
return { path: `${path}${search.size ? `?${search}` : ""}`, params: resolved };
|
|
3574
|
+
}
|
|
3575
|
+
function fileOperation(operation) {
|
|
3576
|
+
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);
|
|
3578
|
+
}
|
|
3579
|
+
async function upload2(path, operation) {
|
|
3580
|
+
try {
|
|
3581
|
+
const policy = webUploadPolicy(operation, basename3(path));
|
|
3582
|
+
const info = await lstat4(path);
|
|
3583
|
+
if (!info.isFile() || info.size <= 0 || info.size > policy.maxBytes) throw usageError(`\u4E0A\u4F20\u5FC5\u987B\u662F 1 \u5B57\u8282\u81F3 ${policy.maxBytes / 1024 / 1024} MiB \u7684\u666E\u901A\u6587\u4EF6`);
|
|
3584
|
+
const bytes = await readFile3(path);
|
|
3585
|
+
if (!bytes.length || bytes.length > policy.maxBytes) throw usageError("\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8D85\u51FA\u8BE5\u64CD\u4F5C\u5141\u8BB8\u8303\u56F4");
|
|
3586
|
+
return { bytes, mime: policy.mime, name: basename3(path), sha256: createHash5("sha256").update(bytes).digest("hex") };
|
|
3587
|
+
} catch (error) {
|
|
3588
|
+
if (error instanceof CliError) throw error;
|
|
3589
|
+
throw usageError("\u4E0A\u4F20\u6587\u4EF6\u4E0D\u5B58\u5728\u6216\u65E0\u6CD5\u8BFB\u53D6");
|
|
3590
|
+
}
|
|
3591
|
+
}
|
|
3592
|
+
async function requestBody(context, operation, data) {
|
|
3593
|
+
const file = textOption(context.values, "file"), filesFile = textOption(context.values, "files");
|
|
3594
|
+
if (file && filesFile) throw usageError("--file \u4E0E --files \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528");
|
|
3595
|
+
if (operation.method === "GET") {
|
|
3596
|
+
if (file || filesFile || textOption(context.values, "data")) throw usageError("\u67E5\u8BE2\u64CD\u4F5C\u4E0D\u63A5\u53D7\u6B63\u6587\u6216\u4E0A\u4F20\u6587\u4EF6");
|
|
3597
|
+
return { identity: null };
|
|
3598
|
+
}
|
|
3599
|
+
if (operation.body === "binary") {
|
|
3600
|
+
if (!file || filesFile || textOption(context.values, "data")) throw usageError("\u8BE5\u64CD\u4F5C\u9700\u8981 --file \u539F\u6587\u4EF6\uFF0C\u4E0D\u80FD\u540C\u65F6\u63D0\u4EA4 JSON \u6B63\u6587");
|
|
3601
|
+
const source = await upload2(file, operation);
|
|
3602
|
+
return { body: new Uint8Array(source.bytes), contentType: source.mime, filename: source.name, identity: { sha256: source.sha256, bytes: source.bytes.length } };
|
|
3603
|
+
}
|
|
3604
|
+
if (operation.body === "multipart") {
|
|
3605
|
+
const field = operation.uploadField;
|
|
3606
|
+
if (!field) throw usageError("\u8BE5\u64CD\u4F5C\u7F3A\u5C11\u4E0A\u4F20\u5B57\u6BB5\u5408\u540C");
|
|
3607
|
+
const mapping = file ? { [field]: file } : await optionData(context, "files");
|
|
3608
|
+
if (Object.keys(mapping).length !== 1 || !(field in mapping) || Array.isArray(mapping[field]) && mapping[field].length !== 1) throw usageError(`\u8BE5\u64CD\u4F5C\u9700\u8981\u4E14\u53EA\u63A5\u53D7\u4E00\u4E2A ${field} \u6587\u4EF6\uFF0C\u8BF7\u4F7F\u7528 --file \u6216\u5BF9\u5E94 --files \u5B57\u6BB5`);
|
|
3609
|
+
const form = new FormData(), identities = [];
|
|
3610
|
+
for (const [name2, value] of Object.entries(data)) form.append(name2, typeof value === "string" ? value : JSON.stringify(value));
|
|
3611
|
+
let total = 0;
|
|
3612
|
+
for (const [field2, paths] of Object.entries(mapping)) {
|
|
3613
|
+
if (!field2 || /[\p{Cc}]/u.test(field2)) throw usageError("\u4E0A\u4F20\u5B57\u6BB5\u540D\u79F0\u65E0\u6548");
|
|
3614
|
+
for (const path of Array.isArray(paths) ? paths : [paths]) {
|
|
3615
|
+
if (typeof path !== "string") throw usageError("--files \u7684\u503C\u5FC5\u987B\u662F\u6587\u4EF6\u8DEF\u5F84\u6216\u6587\u4EF6\u8DEF\u5F84\u6570\u7EC4");
|
|
3616
|
+
const source = await upload2(path, operation);
|
|
3617
|
+
total += source.bytes.length;
|
|
3618
|
+
if (total > 256 * 1024 * 1024) throw usageError("\u672C\u6B21\u9644\u4EF6\u603B\u91CF\u4E0D\u80FD\u8D85\u8FC7 256 MiB");
|
|
3619
|
+
form.append(field2, new Blob([new Uint8Array(source.bytes)], { type: source.mime }), source.name);
|
|
3620
|
+
identities.push({ field: field2, name: source.name, sha256: source.sha256, bytes: source.bytes.length });
|
|
3621
|
+
}
|
|
3622
|
+
}
|
|
3623
|
+
return { body: form, identity: { data, files: identities } };
|
|
3624
|
+
}
|
|
3625
|
+
if (file || filesFile) throw usageError("\u8BE5\u64CD\u4F5C\u63A5\u53D7 JSON \u6B63\u6587\uFF0C\u4E0D\u63A5\u53D7\u6587\u4EF6\u4E0A\u4F20");
|
|
3626
|
+
return { body: JSON.stringify(data), contentType: "application/json", identity: data };
|
|
3627
|
+
}
|
|
3628
|
+
async function webIdentity(context, session, workspace, timeoutMs) {
|
|
3629
|
+
const result = await requestWeb(context.io, { baseUrl: session.baseUrl, token: session.token, method: "GET", path: "/api/me", workspaceId: workspace, timeoutMs });
|
|
3630
|
+
const user = object(object(result.data).user);
|
|
3631
|
+
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
|
+
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
|
+
}
|
|
3634
|
+
return { result, userId: user.id, workspaceId: user.workspaceId };
|
|
3635
|
+
}
|
|
3636
|
+
async function web(context) {
|
|
3637
|
+
const invocationStartedAt = performance.timeOrigin + performance.now();
|
|
3638
|
+
const { io, out, args, values } = context;
|
|
3639
|
+
const timeoutSeconds = timeoutSecondsOf(values, 120);
|
|
3640
|
+
if (timeoutSeconds > 2147483) throw usageError("--timeout \u8D85\u51FA\u652F\u6301\u8303\u56F4");
|
|
3641
|
+
const timeoutMs = timeoutSeconds * 1e3;
|
|
3642
|
+
const action2 = args[0];
|
|
3643
|
+
if (!["login", "whoami", "logout", "operations", "call"].includes(action2 ?? "")) throw usageError("web \u652F\u6301 login\u3001whoami\u3001logout\u3001operations\u3001call");
|
|
3644
|
+
if (action2 !== "call" && args[1] !== void 0) throw usageError("\u8BE5\u7F51\u9875\u5B50\u547D\u4EE4\u4E0D\u63A5\u53D7\u64CD\u4F5C\u7F16\u53F7");
|
|
3645
|
+
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
|
+
if (action2 === "operations") {
|
|
3647
|
+
const group = textOption(values, "group");
|
|
3648
|
+
const operations = WEB_OPERATIONS.filter((operation2) => !group || operation2.group === group);
|
|
3649
|
+
out.result(operations.map((operation2) => `${operation2.id} ${operation2.method} ${operation2.path} ${operation2.description}`), { operations });
|
|
3650
|
+
return;
|
|
3651
|
+
}
|
|
3652
|
+
if (action2 === "login") {
|
|
3653
|
+
const username = textOption(values, "username");
|
|
3654
|
+
if (!username) throw usageError("\u8BF7\u63D0\u4F9B --username <\u8D26\u53F7>");
|
|
3655
|
+
const baseUrl = explicitBaseUrl(context.baseUrl, io.env) ?? DEFAULT_BASE_URL;
|
|
3656
|
+
const password = await readWebPassword(io);
|
|
3657
|
+
out.protect(password);
|
|
3658
|
+
let session;
|
|
3659
|
+
const result = await requestWeb(io, {
|
|
3660
|
+
baseUrl,
|
|
3661
|
+
path: "/api/auth/login",
|
|
3662
|
+
method: "POST",
|
|
3663
|
+
timeoutMs,
|
|
3664
|
+
body: JSON.stringify({ username, password }),
|
|
3665
|
+
contentType: "application/json",
|
|
3666
|
+
secrets: [password],
|
|
3667
|
+
onLogin: (data2) => {
|
|
3668
|
+
if (data2.ok !== true) return;
|
|
3669
|
+
session = issuedSession(context, baseUrl, data2);
|
|
3670
|
+
}
|
|
3671
|
+
});
|
|
3672
|
+
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(io, "session.json", session);
|
|
3674
|
+
out.result(["\u7F51\u9875\u767B\u5F55\u6210\u529F", `\u670D\u52A1\u5730\u5740\uFF1A${baseUrl}`, `\u4F1A\u8BDD\u6587\u4EF6\uFF1A${path}`], { ...object(result.data), baseUrl, sessionPath: path });
|
|
3675
|
+
return;
|
|
3676
|
+
}
|
|
3677
|
+
if (action2 === "whoami" || action2 === "logout") {
|
|
3678
|
+
const session = await resolveWebSession(context), workspace2 = workspaceOf(context);
|
|
3679
|
+
if (action2 === "whoami") {
|
|
3680
|
+
const { result } = await webIdentity(context, session, workspace2, timeoutMs);
|
|
3681
|
+
out.result([JSON.stringify(result.data, null, 2)], { ...object(result.data), baseUrl: session.baseUrl, source: session.source });
|
|
3682
|
+
} else {
|
|
3683
|
+
try {
|
|
3684
|
+
await requestWeb(io, { baseUrl: session.baseUrl, token: session.token, path: "/api/auth/logout", method: "POST", timeoutMs });
|
|
3685
|
+
} catch (error) {
|
|
3686
|
+
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
|
+
}
|
|
3688
|
+
await deleteWebSession(io, session);
|
|
3689
|
+
out.result(["\u7F51\u9875\u4F1A\u8BDD\u5DF2\u9000\u51FA"], { loggedOut: true, source: session.source });
|
|
3690
|
+
}
|
|
3691
|
+
return;
|
|
3692
|
+
}
|
|
3693
|
+
const operation = WEB_OPERATIONS.find((item) => item.id === args[1]);
|
|
3694
|
+
if (!operation) throw usageError("\u64CD\u4F5C\u4E0D\u5728\u7F51\u9875\u547D\u4EE4\u76EE\u5F55\u4E2D\uFF0C\u8BF7\u5148\u8FD0\u884C buke web operations");
|
|
3695
|
+
const mutating = operation.method !== "GET";
|
|
3696
|
+
if (mutating && values.yes !== true) throw usageError("\u7F51\u9875\u5199\u64CD\u4F5C\u5FC5\u987B\u6DFB\u52A0 --yes\uFF1B\u8BF7\u5148\u6838\u5BF9\u672C\u6B21\u64CD\u4F5C\u8303\u56F4\u4E0E\u8D39\u7528");
|
|
3697
|
+
const suppliedKey = textOption(values, "idempotency-key");
|
|
3698
|
+
const issueApiKey = operation.method === "POST" && operation.path === "/api/api-keys";
|
|
3699
|
+
const secretOutput = issueApiKey || operation.sensitiveOutput === true;
|
|
3700
|
+
const output = textOption(values, "out");
|
|
3701
|
+
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");
|
|
3702
|
+
if (output) await checkWebOutput(output);
|
|
3703
|
+
const params = await optionData(context, "params"), query = await optionData(context, "query"), data = await optionData(context, "data");
|
|
3704
|
+
const bodyKey = operation.idempotencyBodyKey ? data[operation.idempotencyBodyKey] : void 0;
|
|
3705
|
+
if (bodyKey !== void 0 && typeof bodyKey !== "string") throw usageError("\u6B63\u6587\u4E2D\u7684\u5E42\u7B49\u952E\u5FC5\u987B\u662F\u5B57\u7B26\u4E32");
|
|
3706
|
+
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");
|
|
3707
|
+
const key = mutating ? suppliedKey ?? (typeof bodyKey === "string" ? bodyKey : void 0) ?? randomUUID2() : void 0;
|
|
3708
|
+
if (key && (!/^[A-Za-z0-9_.:-]{1,200}$/u.test(key) || key.startsWith("bk_"))) throw usageError("\u5E42\u7B49\u952E\u683C\u5F0F\u65E0\u6548");
|
|
3709
|
+
if (operation.idempotencyBodyKey && key) data[operation.idempotencyBodyKey] = key;
|
|
3710
|
+
const target = operationPath(operation, params, query);
|
|
3711
|
+
const body = await requestBody(context, operation, data);
|
|
3712
|
+
const businessHeaders = buildBusinessHeaders(operation, await optionData(context, "headers"), body.filename);
|
|
3713
|
+
const requestedWorkspace = workspaceOf(context);
|
|
3714
|
+
let caller;
|
|
3715
|
+
if (operation.public) {
|
|
3716
|
+
if (requestedWorkspace) throw usageError("\u516C\u5F00\u64CD\u4F5C\u4E0D\u63A5\u53D7\u5DE5\u4F5C\u533A\u53C2\u6570");
|
|
3717
|
+
caller = { baseUrl: explicitBaseUrl(context.baseUrl, io.env) ?? DEFAULT_BASE_URL, userId: "public" };
|
|
3718
|
+
} else {
|
|
3719
|
+
const session = await resolveWebSession(context);
|
|
3720
|
+
const identity = await webIdentity(context, session, requestedWorkspace, timeoutMs);
|
|
3721
|
+
caller = { baseUrl: session.baseUrl, token: session.token, userId: identity.userId, workspaceId: identity.workspaceId };
|
|
3722
|
+
}
|
|
3723
|
+
const workspace = caller.workspaceId;
|
|
3724
|
+
const secrets = [...webSecrets(data), ...webSecrets(query), ...webSecrets(params)];
|
|
3725
|
+
for (const secret of secrets) out.protect(secret);
|
|
3726
|
+
if (operation.membershipPaymentOnly) {
|
|
3727
|
+
const id = target.params.id;
|
|
3728
|
+
if (!id) throw usageError("\u4F1A\u5458\u652F\u4ED8\u64CD\u4F5C\u7F3A\u5C11\u8BA2\u5355\u7F16\u53F7");
|
|
3729
|
+
const checked = await requestWeb(io, {
|
|
3730
|
+
baseUrl: caller.baseUrl,
|
|
3731
|
+
token: caller.token,
|
|
3732
|
+
workspaceId: workspace,
|
|
3733
|
+
method: "GET",
|
|
3734
|
+
path: `/api/payments/orders/${encodeURIComponent(id)}`,
|
|
3735
|
+
timeoutMs
|
|
3736
|
+
});
|
|
3737
|
+
const order2 = object(object(checked.data).order);
|
|
3738
|
+
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
|
+
if (operation.method === "GET" && operation.path === "/api/payments/orders/:id") {
|
|
3740
|
+
const download4 = output ? await saveWebDocument(output, checked.data, io.signal) : void 0;
|
|
3741
|
+
out.result([JSON.stringify(checked.data, null, 2)], { ...checked, ...download4 ? { download: download4 } : {}, operationId: operation.id });
|
|
3742
|
+
return;
|
|
3743
|
+
}
|
|
3744
|
+
}
|
|
3745
|
+
const identityBody = operation.idempotencyBodyKey && body.identity && typeof body.identity === "object" && !Array.isArray(body.identity) ? { ...body.identity, [operation.idempotencyBodyKey]: void 0 } : body.identity;
|
|
3746
|
+
const requestHash = mutating ? await fingerprintWebRequest(
|
|
3747
|
+
io,
|
|
3748
|
+
{ baseUrl: caller.baseUrl, userId: caller.userId },
|
|
3749
|
+
[caller.baseUrl, caller.userId, workspace ?? null, operation.id, target.path, identityBody, businessHeaders]
|
|
3750
|
+
) : void 0;
|
|
3751
|
+
const recordName = `web-request-${requestHash}.json`;
|
|
3752
|
+
let recovery = {
|
|
3753
|
+
operationId: operation.id,
|
|
3754
|
+
baseUrl: caller.baseUrl,
|
|
3755
|
+
userId: caller.userId,
|
|
3756
|
+
...workspace ? { workspaceId: workspace } : {},
|
|
3757
|
+
...key ? { idempotencyKey: key } : {},
|
|
3758
|
+
requestHash,
|
|
3759
|
+
params: redactWebValue(target.params, secrets),
|
|
3760
|
+
operationOutcome: "not_submitted",
|
|
3761
|
+
...mutating ? { requestRecord: webStatePath(io, recordName) } : {}
|
|
3762
|
+
};
|
|
3763
|
+
let finishedAtMs;
|
|
3764
|
+
const persist = async () => {
|
|
3765
|
+
await writeWebState(io, recordName, { version: 1, ...recovery, finishedAtMs });
|
|
3766
|
+
await writeWebState(io, "last-web-request.json", { version: 1, ...recovery, finishedAtMs });
|
|
3767
|
+
};
|
|
3768
|
+
const release2 = mutating ? await lockWebRequest(io, requestHash) : void 0;
|
|
3769
|
+
try {
|
|
3770
|
+
if (mutating) {
|
|
3771
|
+
const previous = await readWebState(io, recordName);
|
|
3772
|
+
const explicitlyChosen = suppliedKey ?? bodyKey;
|
|
3773
|
+
const concurrentCompletion = previous && typeof previous.finishedAtMs === "number" && previous.finishedAtMs >= invocationStartedAt;
|
|
3774
|
+
const sameAttempt = explicitlyChosen === void 0 || explicitlyChosen === previous?.idempotencyKey;
|
|
3775
|
+
if (previous && (concurrentCompletion && sameAttempt || ["unknown", "accepted"].includes(String(previous.operationOutcome)) && (explicitlyChosen === void 0 || explicitlyChosen === previous.idempotencyKey && operation.replaySafe !== true))) {
|
|
3776
|
+
throw usageError(operation.replaySafe === true ? "\u76F8\u540C\u8BF7\u6C42\u5DF2\u6709\u63D0\u4EA4\u8BB0\u5F55\uFF0C\u8BF7\u5148\u67E5\u8BE2\u539F\u64CD\u4F5C\uFF1B\u6062\u590D\u65F6\u4F7F\u7528\u539F\u5E42\u7B49\u952E\u548C\u539F\u53C2\u6570\u6587\u4EF6" : "\u76F8\u540C\u8BF7\u6C42\u5DF2\u6709\u63D0\u4EA4\u8BB0\u5F55\u4E14\u8BE5\u64CD\u4F5C\u4E0D\u652F\u6301\u5B89\u5168\u91CD\u653E\uFF1B\u8BF7\u5148\u67E5\u8BE2\u539F\u8D44\u6E90\u3002\u786E\u9700\u65B0\u5C1D\u8BD5\u65F6\u63D0\u4F9B\u65B0\u5E42\u7B49\u952E\u5E76\u6DFB\u52A0 --yes").withWebRecovery({
|
|
3777
|
+
...recovery,
|
|
3778
|
+
idempotencyKey: String(previous.idempotencyKey),
|
|
3779
|
+
operationOutcome: previous.operationOutcome,
|
|
3780
|
+
...typeof previous.taskId === "string" ? { taskId: previous.taskId } : {}
|
|
3781
|
+
});
|
|
3782
|
+
}
|
|
3783
|
+
recovery.operationOutcome = "unknown";
|
|
3784
|
+
await persist();
|
|
3785
|
+
}
|
|
3786
|
+
try {
|
|
3787
|
+
let authenticated;
|
|
3788
|
+
const result = await requestWeb(io, {
|
|
3789
|
+
baseUrl: caller.baseUrl,
|
|
3790
|
+
token: caller.token,
|
|
3791
|
+
workspaceId: workspace,
|
|
3792
|
+
path: target.path,
|
|
3793
|
+
method: operation.method,
|
|
3794
|
+
body: body.body,
|
|
3795
|
+
contentType: body.contentType,
|
|
3796
|
+
businessHeaders,
|
|
3797
|
+
idempotencyKey: key,
|
|
3798
|
+
timeoutMs,
|
|
3799
|
+
outPath: output,
|
|
3800
|
+
secretOutput,
|
|
3801
|
+
secrets,
|
|
3802
|
+
expectedFile: !secretOutput && (fileOperation(operation) || /\.(?:mp4|mov|webm|png|jpe?g|webp|mp3|wav|pdf|zip|vtt|srt)$/iu.test(output ?? "")),
|
|
3803
|
+
sessionResponse: operation.sessionResponse,
|
|
3804
|
+
onLogin: (response) => {
|
|
3805
|
+
authenticated = issuedSession(context, caller.baseUrl, response);
|
|
3806
|
+
},
|
|
3807
|
+
onTaskId: (taskId) => {
|
|
3808
|
+
recovery = { ...recovery, taskId, operationOutcome: "accepted" };
|
|
3809
|
+
},
|
|
3810
|
+
onEvent: (event) => {
|
|
3811
|
+
if (!out.json) out.notice(singleLine(JSON.stringify(event)));
|
|
3812
|
+
}
|
|
3813
|
+
});
|
|
3814
|
+
if (authenticated) await writeWebState(io, "session.json", authenticated);
|
|
3815
|
+
recovery.operationOutcome = result.status === 202 || recovery.operationOutcome === "accepted" ? "accepted" : "completed";
|
|
3816
|
+
finishedAtMs = performance.timeOrigin + performance.now();
|
|
3817
|
+
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
|
+
const document = {
|
|
3819
|
+
...result,
|
|
3820
|
+
...key ? { idempotencyKey: key } : {},
|
|
3821
|
+
operationId: operation.id,
|
|
3822
|
+
...recovery.taskId ? { taskId: recovery.taskId } : {}
|
|
3823
|
+
};
|
|
3824
|
+
out.result([JSON.stringify(redactWebValue(document, caller.token ? [caller.token] : []), null, 2)], document);
|
|
3825
|
+
} catch (error) {
|
|
3826
|
+
const failure = toCliError(error);
|
|
3827
|
+
if (recovery.operationOutcome !== "accepted") recovery.operationOutcome = failure.httpStatus !== void 0 && failure.httpStatus >= 400 && failure.httpStatus < 500 && failure.httpStatus !== 408 ? "rejected" : "unknown";
|
|
3828
|
+
finishedAtMs = performance.timeOrigin + performance.now();
|
|
3829
|
+
if (mutating) await persist().catch(() => void 0);
|
|
3830
|
+
throw failure.withWebRecovery(recovery);
|
|
3831
|
+
}
|
|
3832
|
+
} finally {
|
|
3833
|
+
await release2?.();
|
|
3834
|
+
}
|
|
3835
|
+
}
|
|
3836
|
+
|
|
3837
|
+
// src/commands/studio-actions.ts
|
|
3838
|
+
import { basename as basename4 } from "node:path";
|
|
3839
|
+
|
|
3840
|
+
// src/client-creative.ts
|
|
3841
|
+
function creativePath(resource, id, suffix = "") {
|
|
3842
|
+
const prefix = resource === "drama" ? "drama/orders" : resource;
|
|
3843
|
+
return `/api/open/v1/${prefix}${id ? `/${encodeURIComponent(id)}` : ""}${suffix ? `${suffix.startsWith("?") ? "" : "/"}${suffix}` : ""}`;
|
|
3844
|
+
}
|
|
3845
|
+
function creativeObject(value) {
|
|
3846
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new CliError({ code: "CLI_BAD_RESPONSE", message: "\u670D\u52A1\u7AEF\u54CD\u5E94\u683C\u5F0F\u4E0D\u7B26\u5408\u63A5\u53E3\u7EA6\u5B9A", exitCode: EXIT.SERVER });
|
|
3847
|
+
return value;
|
|
3848
|
+
}
|
|
3849
|
+
async function getCreative(baseUrl, apiKey, resource, id, suffix, deps) {
|
|
3850
|
+
return creativeObject((await getJson(baseUrl, apiKey, creativePath(resource, id, suffix), deps)).body);
|
|
3851
|
+
}
|
|
3852
|
+
async function postCreative(baseUrl, apiKey, resource, id, suffix, body, key, deps) {
|
|
3853
|
+
try {
|
|
3854
|
+
return creativeObject((await postJson(baseUrl, apiKey, creativePath(resource, id, suffix), body, key, deps)).body);
|
|
3855
|
+
} catch (error) {
|
|
3856
|
+
const failure = toCliError(error);
|
|
3857
|
+
const rejected = failure.httpStatus !== void 0 && failure.httpStatus >= 400 && failure.httpStatus < 500 && failure.httpStatus !== 408;
|
|
3858
|
+
const recovery = taskRecovery(resource, id ?? "", void 0, baseUrl);
|
|
3859
|
+
if (resource === "series") recovery.statusCommand = id ? recovery.statusCommand.replace(" series status ", " series show ") : recovery.statusCommand.replace(" series status ''", " series list");
|
|
3860
|
+
throw failure.withRecovery({
|
|
3861
|
+
...recovery,
|
|
3862
|
+
taskId: id,
|
|
3863
|
+
acceptance: "unknown",
|
|
3864
|
+
idempotencyKey: key,
|
|
3865
|
+
...suffix === "director/confirm" || suffix === "redo" ? { operation: "confirm" } : {},
|
|
3866
|
+
operationOutcome: rejected ? "rejected" : "unknown"
|
|
3867
|
+
});
|
|
3868
|
+
}
|
|
3869
|
+
}
|
|
3870
|
+
function downloadCreative(baseUrl, apiKey, resource, id, suffix, deps) {
|
|
3871
|
+
return downloadFile(baseUrl, apiKey, creativePath(resource, id, suffix), deps);
|
|
3872
|
+
}
|
|
3873
|
+
|
|
3874
|
+
// src/commands/creative.ts
|
|
3875
|
+
async function creativeData(context) {
|
|
3876
|
+
const path = textOption(context.values, "data");
|
|
3877
|
+
return path ? readPropsArgument(context.io, path, "\u8BF7\u6C42\u53C2\u6570\uFF08--data\uFF09") : {};
|
|
3878
|
+
}
|
|
3879
|
+
function idOf(context) {
|
|
3880
|
+
const id = context.args[1];
|
|
3881
|
+
if (!id?.trim()) throw usageError("\u8BF7\u63D0\u4F9B\u9879\u76EE\u7F16\u53F7");
|
|
3882
|
+
return id.trim();
|
|
3883
|
+
}
|
|
3884
|
+
async function dramaCreative(context) {
|
|
3885
|
+
const [action2] = context.args;
|
|
3886
|
+
const id = idOf(context);
|
|
3887
|
+
const { baseUrl, apiKey } = await resolveApiKey(context);
|
|
3888
|
+
const { io, out, values } = context;
|
|
3889
|
+
if (["context", "director", "document", "versions"].includes(action2)) {
|
|
3890
|
+
let suffix2 = action2;
|
|
3891
|
+
if (action2 === "document") {
|
|
3892
|
+
const query = new URLSearchParams({ kind: textOption(values, "kind") ?? "screenplay_snapshot" });
|
|
3893
|
+
const episode = textOption(values, "episode-number");
|
|
3894
|
+
if (episode) query.set("episodeNumber", episode);
|
|
3895
|
+
suffix2 += `?${query}`;
|
|
3896
|
+
}
|
|
3897
|
+
const result2 = await getCreative(baseUrl, apiKey, "drama", id, suffix2, io);
|
|
3898
|
+
out.result([typeof result2.content === "string" ? result2.content : JSON.stringify(result2, null, 2)], result2);
|
|
3899
|
+
return;
|
|
3900
|
+
}
|
|
3901
|
+
const body = await creativeData(context);
|
|
3902
|
+
if (action2 === "director-confirm") {
|
|
3903
|
+
const confirmationId = textOption(values, "confirmation-id") ?? body.confirmationId;
|
|
3904
|
+
const suppliedKind = textOption(values, "kind") ?? body.kind;
|
|
3905
|
+
if (typeof confirmationId !== "string" || !confirmationId) throw usageError("\u8BF7\u4F7F\u7528 drama director \u4E2D\u5F53\u524D\u786E\u8BA4\u5361\u7684 --confirmation-id");
|
|
3906
|
+
if (values.yes !== true) throw usageError("\u8BF7\u6838\u5BF9\u786E\u8BA4\u5361\u7684\u8303\u56F4\u4E0E\u8D39\u7528\uFF0C\u5E76\u6DFB\u52A0 --yes");
|
|
3907
|
+
const key2 = idempotencyKeyOf(values);
|
|
3908
|
+
let kind = suppliedKind;
|
|
3909
|
+
if (typeof kind !== "string") {
|
|
3910
|
+
try {
|
|
3911
|
+
const current = await getCreative(baseUrl, apiKey, "drama", id, "director", io);
|
|
3912
|
+
const director = creativeObject(current.director);
|
|
3913
|
+
const pending = creativeObject(director.pendingInterrupt);
|
|
3914
|
+
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");
|
|
3915
|
+
kind = pending.kind;
|
|
3916
|
+
} catch (error) {
|
|
3917
|
+
throw toCliError(error).withRecovery(dramaConfirmationRecovery(id, void 0, baseUrl, key2, "not_submitted"));
|
|
3918
|
+
}
|
|
3919
|
+
} else if (!textOption(values, "idempotency-key")) {
|
|
3920
|
+
throw usageError("\u4F7F\u7528\u4FDD\u5B58\u7684\u786E\u8BA4\u51ED\u636E\u65F6\u5FC5\u987B\u63D0\u4F9B\u539F --idempotency-key");
|
|
3921
|
+
}
|
|
3922
|
+
if (typeof kind !== "string" || !kind) throw usageError("\u786E\u8BA4\u5361\u7F3A\u5C11\u6709\u6548 kind");
|
|
3923
|
+
try {
|
|
3924
|
+
const result2 = await postCreative(baseUrl, apiKey, "drama", id, "director/confirm", { kind, confirmationId, confirmed: true }, key2, io);
|
|
3925
|
+
out.result(["\u786E\u8BA4\u8BF7\u6C42\u5DF2\u5904\u7406", `\u5E42\u7B49\u952E\uFF1A${key2}`], { ...result2, idempotencyKey: key2 });
|
|
3926
|
+
return;
|
|
3927
|
+
} catch (error) {
|
|
3928
|
+
const failure = toCliError(error);
|
|
3929
|
+
throw failure.withRecovery({ ...dramaConfirmationRecovery(id, void 0, baseUrl, key2, "unknown"), ...failure.recovery, confirmation: { kind, confirmationId } });
|
|
3930
|
+
}
|
|
3931
|
+
}
|
|
3932
|
+
if (action2 === "redo") {
|
|
3933
|
+
if (values.yes !== true) throw usageError("\u8865\u505A\u4F1A\u6309\u65B0\u62A5\u4EF7\u6536\u53D6\u8D39\u7528\uFF0C\u8BF7\u5148\u6267\u884C redo-quote\uFF0C\u6838\u5BF9\u62A5\u4EF7\u540E\u6DFB\u52A0 --yes");
|
|
3934
|
+
const quote3 = body.quote && typeof body.quote === "object" ? creativeObject(body.quote) : body;
|
|
3935
|
+
const required3 = ["redoQuoteId", "redoPlanHash", "redoQuoteHash"];
|
|
3936
|
+
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
|
+
const key2 = idempotencyKeyOf(values);
|
|
3938
|
+
const result2 = await postCreative(baseUrl, apiKey, "drama", id, "redo", { redoQuoteId: quote3.redoQuoteId, redoPlanHash: quote3.redoPlanHash, redoQuoteHash: quote3.redoQuoteHash, confirmed: true }, key2, io);
|
|
3939
|
+
out.result(["\u8865\u505A\u8BF7\u6C42\u5DF2\u53D7\u7406", `\u5E42\u7B49\u952E\uFF1A${key2}`], { ...result2, idempotencyKey: key2 });
|
|
3940
|
+
return;
|
|
3941
|
+
}
|
|
3942
|
+
const epoch = textOption(values, "expected-epoch");
|
|
3943
|
+
if (epoch !== void 0) body.expectedProductionEpoch = Number(epoch);
|
|
3944
|
+
if (!Number.isInteger(body.expectedProductionEpoch) || Number(body.expectedProductionEpoch) < 0) throw usageError("\u8BF7\u5148\u8FD0\u884C drama context\uFF0C\u63D0\u4F9B --expected-epoch \u6216\u5728 --data \u4E2D\u586B\u5199 expectedProductionEpoch");
|
|
3945
|
+
let suffix = action2;
|
|
3946
|
+
if (action2 === "message") {
|
|
3947
|
+
const text = textOption(values, "text");
|
|
3948
|
+
if (text !== void 0) body.text = text;
|
|
3949
|
+
if (typeof body.text !== "string" || !body.text.trim()) throw usageError("\u8BF7\u63D0\u4F9B --text \u6216 --data.text");
|
|
3950
|
+
suffix = "messages";
|
|
3951
|
+
} else if (action2 === "spec") {
|
|
3952
|
+
const model = textOption(values, "model"), resolution = textOption(values, "resolution");
|
|
3953
|
+
if (model !== void 0) body.videoModel = model;
|
|
3954
|
+
if (resolution !== void 0) body.resolution = resolution;
|
|
3955
|
+
} else if (action2 === "select-version") {
|
|
3956
|
+
body.shotId = textOption(values, "shot") ?? body.shotId;
|
|
3957
|
+
const selected = textOption(values, "output-id");
|
|
3958
|
+
if (selected !== void 0) body.renderOutputId = selected === "default" ? null : selected;
|
|
3959
|
+
suffix = "selection";
|
|
3960
|
+
} else if (action2 === "redo-quote") {
|
|
3961
|
+
const shot = textOption(values, "shot");
|
|
3962
|
+
if (shot !== void 0) body.shotIds = shot.split(",").map((value) => value.trim());
|
|
3963
|
+
suffix = "redo/quote";
|
|
3964
|
+
}
|
|
3965
|
+
const key = idempotencyKeyOf(values);
|
|
3966
|
+
const result = await postCreative(baseUrl, apiKey, "drama", id, suffix, body, key, io);
|
|
3967
|
+
out.result([JSON.stringify(result, null, 2), `\u5E42\u7B49\u952E\uFF1A${key}`], { ...result, idempotencyKey: key });
|
|
3968
|
+
}
|
|
3969
|
+
async function creativeDownload(context, resource, id, suffix) {
|
|
3970
|
+
const { baseUrl, apiKey } = await resolveApiKey(context);
|
|
3971
|
+
const result = await downloadCreative(baseUrl, apiKey, resource, id, suffix, context.io);
|
|
3972
|
+
const filename = result.filename ?? `${resource}-${id}.mp4`;
|
|
3973
|
+
const saved = await saveDownload(textOption(context.values, "out") ?? filename, result.bytes);
|
|
3974
|
+
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
|
+
}
|
|
3976
|
+
|
|
3977
|
+
// src/commands/studio-actions.ts
|
|
3978
|
+
var video = "/api/open/v1/videos/:id";
|
|
3979
|
+
var drama = "/api/open/v1/drama/orders/:id";
|
|
3980
|
+
var pagination = { limit: "limit", offset: "offset", cursor: "cursor" };
|
|
3981
|
+
var action = (resource, command, path, method, description, extra = {}) => ({ resource, command, path, method, description, needsYes: method !== "GET", ...extra });
|
|
3982
|
+
var v = (command, suffix, method, description, extra = {}) => action("videos", command, `${video}/${suffix}`, method, description, extra);
|
|
3983
|
+
var STUDIO_ACTIONS = [
|
|
3984
|
+
action("videos", "list", "/api/open/v1/videos", "GET", "\u5217\u51FA\u5546\u54C1\u89C6\u9891", { query: { limit: "limit", cursor: "cursor", actionable: "actionable" } }),
|
|
3985
|
+
...["methods", "play-cards", "inspirations"].map((kind) => action("videos", kind, `/api/open/v1/video-catalog/${kind}`, "GET", "\u67E5\u8BE2\u521B\u4F5C\u76EE\u5F55")),
|
|
3986
|
+
v("settings", "settings", "POST", "\u4FEE\u6539\u5F53\u524D\u89C4\u683C", { body: ["expectedVersion", "patch"] }),
|
|
3987
|
+
v("retry", "retry-failed-step", "POST", "\u6062\u590D\u672A\u5B8C\u6210\u6B65\u9AA4\u6216\u786E\u8BA4\u5173\u952E\u5E27\u91CD\u505A", { body: ["expectedVersion"] }),
|
|
3988
|
+
v("product-image-resume", "product-image-resume", "POST", "\u8865\u5145\u4EA7\u54C1\u56FE\u540E\u6062\u590D", { body: ["expectedVersion"] }),
|
|
3989
|
+
v("product-lock-confirm", "product-lock-confirm", "POST", "\u786E\u8BA4\u672C\u5355\u5546\u54C1\u5916\u89C2", { body: ["expectedVersion"] }),
|
|
3990
|
+
v("asset-options", "asset-gaps/:gapId/options", "GET", "\u67E5\u8BE2\u7D20\u6750\u804C\u8D23\u7684\u5019\u9009", { query: { ...pagination, q: "q", source: "source", "asset-id": "assetId" } }),
|
|
3991
|
+
v("asset-resolve", "asset-gaps/:gapId/resolve", "POST", "\u6309\u5F53\u524D\u804C\u8D23\u9009\u7D20\u6750\u6216\u786E\u8BA4\u751F\u6210", { body: ["action", "expectedVersion"] }),
|
|
3992
|
+
v("asset-resolve-batch", "asset-gaps/resolve-batch", "POST", "\u6279\u91CF\u91C7\u7528\u73B0\u6709\u804C\u8D23\u7D20\u6750", { body: ["expectedVersion", "items"] }),
|
|
3993
|
+
v("asset-upload", "asset-gaps/:gapId/upload", "PUT", "\u4E0A\u4F20\u672C\u5355\u804C\u8D23\u7D20\u6750", { fileType: "image", query: { "expected-version": "expectedVersion" } }),
|
|
3994
|
+
v("asset-adopt", "asset-gaps/:gapId/adopt-uploaded", "POST", "\u91C7\u7528\u672C\u5355\u5DF2\u4E0A\u4F20\u7D20\u6750", { body: ["expectedVersion", "kind", "id"] }),
|
|
3995
|
+
v("file", "files/:path", "GET", "\u8BFB\u53D6\u5F53\u524D\u6587\u7A3F"),
|
|
3996
|
+
v("file-versions", "files/:path/versions", "GET", "\u5217\u51FA\u6587\u7A3F\u5386\u53F2", { query: { limit: "limit", cursor: "cursor" } }),
|
|
3997
|
+
v("file-version", "files/:path/versions/:versionId", "GET", "\u8BFB\u53D6\u4E00\u7248\u6587\u7A3F"),
|
|
3998
|
+
v("file-compare", "files/:path/versions/compare", "GET", "\u6BD4\u8F83\u4E24\u7248\u6587\u7A3F", { query: { "base-version": "baseVersionId", "target-version": "targetVersionId", cursor: "cursor" } }),
|
|
3999
|
+
v("file-restore", "files/:path/versions/:versionId/restore", "POST", "\u6062\u590D\u6307\u5B9A\u6587\u7A3F\u7248\u672C", { body: ["expectedCurrentVersionId"] }),
|
|
4000
|
+
v("confirm-image", "confirm-image", "POST", "\u6309\u5F53\u524D\u56FE\u5361\u660E\u786E\u786E\u8BA4\u751F\u6210", { body: ["expectedVersion", "confirmation"], confirmation: true }),
|
|
4001
|
+
v("subtitles", "subtitles", "GET", "\u67E5\u8BE2\u6574\u7247\u5B57\u5E55\u5F00\u5173"),
|
|
4002
|
+
v("subtitles-set", "subtitles", "PUT", "\u8BBE\u7F6E\u6574\u7247\u5B57\u5E55\u5F00\u5173", { body: ["enabled"] }),
|
|
4003
|
+
v("production-preview", "production-preview", "GET", "\u67E5\u770B\u5F53\u524D\u5F00\u62CD\u5361\u7684\u9010\u6BB5\u9884\u89C8"),
|
|
4004
|
+
v("public-references", "public-reference-candidates", "GET", "\u67E5\u770B\u516C\u5F00\u53C2\u8003\u5019\u9009"),
|
|
4005
|
+
v("public-reference-decide", "public-reference-candidates/:assetId/decision", "PUT", "\u786E\u8BA4\u6216\u62D2\u7EDD\u516C\u5F00\u53C2\u8003", { body: ["decision", "expectedVersion"] }),
|
|
4006
|
+
v("voices", "voice-candidates", "GET", "\u67E5\u770B\u89D2\u8272\u58F0\u97F3\u5019\u9009"),
|
|
4007
|
+
v("platform-voices", "platform-voices", "GET", "\u67E5\u770B\u5E73\u53F0\u58F0\u97F3"),
|
|
4008
|
+
v("voice-import", "voice-candidates", "POST", "\u5BFC\u5165\u5DF2\u6709\u58F0\u97F3\u6765\u6E90", { fileType: "voice" }),
|
|
4009
|
+
v("voice-preset", "voice-candidates/preset", "POST", "\u91C7\u7528\u5E73\u53F0\u6837\u97F3\u6216\u7533\u8BF7\u8BD5\u542C", { body: ["voiceId"] }),
|
|
4010
|
+
v("voice-select", "voice-selection", "PUT", "\u9009\u62E9\u6216\u53D6\u6D88\u89D2\u8272\u58F0\u97F3", { body: ["roleKey", "candidateId", "expectedVersion"] }),
|
|
4011
|
+
v("voice-continue", "voice-selection/continue", "POST", "\u6309\u5DF2\u9009\u58F0\u97F3\u7EE7\u7EED", { body: ["expectedVersion"] }),
|
|
4012
|
+
v("motion-references", "motion-references", "GET", "\u67E5\u770B\u52A8\u4F5C\u53C2\u8003"),
|
|
4013
|
+
v("motion-prepare", "motion-references", "POST", "\u88C1\u526A\u5DF2\u4E0A\u4F20\u7684\u52A8\u4F5C\u53C2\u8003", { body: ["attachmentId", "startSeconds", "endSeconds"] }),
|
|
4014
|
+
v("motion-select", "motion-references/:candidateId/select", "POST", "\u5C06\u52A8\u4F5C\u53C2\u8003\u7ED1\u5B9A\u5F53\u524D\u955C\u5934", { body: ["shotIds"] }),
|
|
4015
|
+
v("image-edits", "image-edits", "GET", "\u5217\u51FA\u56FE\u7247\u7F16\u8F91\u548C\u5C40\u90E8\u4FEE\u6539\u4EFB\u52A1"),
|
|
4016
|
+
v("image-edit-save", "image-edits/:sourceKind/:sourceId", "PUT", "\u4FDD\u5B58\u672C\u5730\u7F16\u8F91\u540E\u7684\u56FE\u7247", { fileType: "image" }),
|
|
4017
|
+
v("area-quote", "image-edits/area/quote", "POST", "\u4E3A\u8499\u7248\u9009\u533A\u4FEE\u6539\u62A5\u4EF7", { fileType: "mask", body: ["sourceKind", "sourceId", "prompt"] }),
|
|
4018
|
+
v("area-status", "image-edits/area/:quoteId", "GET", "\u67E5\u8BE2\u9009\u533A\u62A5\u4EF7\u53CA\u5236\u4F5C\u72B6\u6001"),
|
|
4019
|
+
v("area-confirm", "image-edits/area/confirm", "POST", "\u786E\u8BA4\u5F53\u524D\u9009\u533A\u62A5\u4EF7", { body: ["quoteId"], confirmation: true }),
|
|
4020
|
+
v("append-retry-join", "append-tasks/:taskId/retry-join", "POST", "\u6062\u590D\u5DF2\u6709\u63D2\u7247\u7684\u514D\u8D39\u62FC\u63A5"),
|
|
4021
|
+
v("stop", "stop", "POST", "\u8BF7\u6C42\u505C\u6B62\u5C1A\u672A\u6267\u884C\u7684\u540E\u7EED\u6B65\u9AA4"),
|
|
4022
|
+
v("events", "live", "GET", "\u8BA2\u9605\u6709\u754C\u5B9E\u65F6\u8FDB\u5EA6", { events: true }),
|
|
4023
|
+
v("message-stream", "messages/stream", "POST", "\u53D1\u9001\u6D88\u606F\u5E76\u8BA2\u9605\u56DE\u5408\u4E8B\u4EF6", { events: true, body: ["text"] }),
|
|
4024
|
+
...[
|
|
4025
|
+
["storyboard-download", "storyboards/:imageKey/download", "image", "\u4E0B\u8F7D\u5173\u952E\u5E27"],
|
|
4026
|
+
["image-download", "images/:assetId/download", "image", "\u4E0B\u8F7D\u4EBA\u7269\u6216\u573A\u666F\u56FE\u7247"],
|
|
4027
|
+
["image-edit-download", "image-edits/:editId/download", "image", "\u4E0B\u8F7D\u56FE\u7247\u7F16\u8F91\u7248"],
|
|
4028
|
+
["area-mask", "image-edits/area/:quoteId/mask", "image", "\u4E0B\u8F7D\u9009\u533A\u8499\u7248"],
|
|
4029
|
+
["area-preview", "image-edits/area/:jobId/preview", "image", "\u4E0B\u8F7D\u5C40\u90E8\u4FEE\u6539\u9884\u89C8"],
|
|
4030
|
+
["edit-subtitles", "edits/:editId/subtitles", "vtt", "\u4E0B\u8F7D\u526A\u8F91\u7248\u5B57\u5E55"],
|
|
4031
|
+
["platform-voice-download", "platform-voices/:voiceId/audio", "audio", "\u4E0B\u8F7D\u5E73\u53F0\u58F0\u97F3\u8BD5\u542C"],
|
|
4032
|
+
["voice-sample-download", "voice-presets/:voiceId/sample", "audio", "\u4E0B\u8F7D\u5E73\u53F0\u6837\u97F3"],
|
|
4033
|
+
["voice-library-download", "voice-library/:candidateId/audio", "audio", "\u4E0B\u8F7D\u58F0\u97F3\u5E93\u7D20\u6750"],
|
|
4034
|
+
["voice-download", "voice-candidates/:candidateId/audio", "audio", "\u4E0B\u8F7D\u5019\u9009\u58F0\u97F3"],
|
|
4035
|
+
["voice-preview-download", "voiceover/previews/:previewId/audio", "audio", "\u4E0B\u8F7D\u914D\u97F3\u8BD5\u542C"],
|
|
4036
|
+
["motion-download", "motion-references/:candidateId/video", "video", "\u4E0B\u8F7D\u52A8\u4F5C\u53C2\u8003\u7247\u6BB5"],
|
|
4037
|
+
["segment-download", "production-segments/:index/download", "video", "\u4E0B\u8F7D\u5DF2\u5B8C\u6210\u5236\u4F5C\u7247\u6BB5"]
|
|
4038
|
+
].map(([command, path, download4, description]) => v(command, path, "GET", description, { download: download4 })),
|
|
4039
|
+
action("graphic", "stop", "/api/open/v1/graphic/runs/:id/stop", "POST", "\u505C\u6B62\u5F53\u524D\u56FE\u6587\u5BFC\u6F14\u56DE\u5408"),
|
|
4040
|
+
action("drama", "stop", `${drama}/director/stop`, "POST", "\u505C\u6B62\u5F53\u524D\u77ED\u5267\u5BFC\u6F14\u56DE\u5408"),
|
|
4041
|
+
action("drama", "script-versions", `${drama}/screenplay/versions`, "GET", "\u5217\u51FA\u5267\u672C\u6587\u7A3F\u7248\u672C", { query: { limit: "limit" } }),
|
|
4042
|
+
action("drama", "script-version", `${drama}/screenplay/versions/:documentId`, "GET", "\u67E5\u770B\u4E00\u7248\u5267\u672C\u6587\u7A3F"),
|
|
4043
|
+
action("drama", "script-compare", `${drama}/screenplay/versions/compare`, "GET", "\u6BD4\u8F83\u4E24\u7248\u5267\u672C\u6587\u7A3F", { query: { "base-version": "baseDocumentId", "target-version": "targetDocumentId", "max-changes": "maxChanges" } }),
|
|
4044
|
+
action("drama", "script-restore", `${drama}/screenplay/versions/:documentId/restore`, "POST", "\u6062\u590D\u6307\u5B9A\u5267\u672C\u6587\u7A3F", { body: ["expectedCurrentDocumentId", "expectedProductionEpoch"] }),
|
|
4045
|
+
action("drama", "edit-sources", `${drama}/edit-sources`, "GET", "\u67E5\u8BE2\u53EF\u526A\u8F91\u7684\u539F\u7247", { query: { "source-output-id": "sourceEpisodeOutputId" } }),
|
|
4046
|
+
action("drama", "speech-adoptions", `${drama}/speech/adoptions`, "GET", "\u67E5\u8BE2\u5DF2\u91C7\u7528\u7684\u914D\u97F3"),
|
|
4047
|
+
action("drama", "edit-subtitles", `${drama}/edits/:editId/subtitles`, "GET", "\u4E0B\u8F7D\u77ED\u5267\u526A\u8F91\u7248\u5B57\u5E55", { download: "vtt" }),
|
|
4048
|
+
action("series", "outline", "/api/open/v1/series/:id/outline", "GET", "\u67E5\u770B\u5267\u96C6\u5927\u7EB2"),
|
|
4049
|
+
action("series", "outline-approve", "/api/open/v1/series/:id/outline/:documentId/approve", "POST", "\u786E\u8BA4\u5927\u7EB2\u5E76\u7EE7\u7EED\u51C6\u5907", { body: ["expectedProductionEpoch"] })
|
|
4050
|
+
];
|
|
4051
|
+
var pathOptions = {
|
|
4052
|
+
gapId: "gap-id",
|
|
4053
|
+
path: "path",
|
|
4054
|
+
versionId: "version-id",
|
|
4055
|
+
candidateId: "candidate-id",
|
|
4056
|
+
taskId: "task-id",
|
|
4057
|
+
documentId: "document-id",
|
|
4058
|
+
assetId: "asset-id",
|
|
4059
|
+
sourceKind: "source-kind",
|
|
4060
|
+
sourceId: "source-id",
|
|
4061
|
+
quoteId: "quote-id",
|
|
4062
|
+
editId: "edit-id",
|
|
4063
|
+
imageKey: "image-key",
|
|
4064
|
+
jobId: "job-id",
|
|
4065
|
+
voiceId: "voice-id",
|
|
4066
|
+
previewId: "preview-id",
|
|
4067
|
+
index: "index"
|
|
4068
|
+
};
|
|
4069
|
+
var STUDIO_ACTION_OPTIONS = [.../* @__PURE__ */ new Set([
|
|
4070
|
+
"yes",
|
|
4071
|
+
"data",
|
|
4072
|
+
"file",
|
|
4073
|
+
"mime",
|
|
4074
|
+
"out",
|
|
4075
|
+
"idempotency-key",
|
|
4076
|
+
"timeout",
|
|
4077
|
+
"text",
|
|
4078
|
+
"expected-version",
|
|
4079
|
+
"expected-epoch",
|
|
4080
|
+
"expected-current-version",
|
|
4081
|
+
"expected-current-document",
|
|
4082
|
+
"expected-credits",
|
|
4083
|
+
"enabled",
|
|
4084
|
+
...Object.values(pathOptions),
|
|
4085
|
+
...STUDIO_ACTIONS.flatMap((item) => Object.keys(item.query ?? {}))
|
|
4086
|
+
])];
|
|
4087
|
+
function STUDIO_ACTION_HELP(resource) {
|
|
4088
|
+
return [
|
|
4089
|
+
"",
|
|
4090
|
+
"\u5DE5\u4F5C\u53F0\u6269\u5C55\u547D\u4EE4\uFF1A",
|
|
4091
|
+
...STUDIO_ACTIONS.filter((item) => item.resource === resource).map((item) => ` buke ${resource} ${item.command}${item.path.includes(":id") ? " <id>" : ""} ${[...item.path.matchAll(/:([A-Za-z]+)/gu)].filter((match) => match[1] !== "id").map((match) => `--${pathOptions[match[1]] ?? match[1]} <\u503C>`).join(" ")}${item.needsYes ? " --yes" : ""} ${item.description}`),
|
|
4092
|
+
" --data <JSON\u6587\u4EF6> \u8BF7\u6C42\u6B63\u6587\uFF1B--file <\u6587\u4EF6> \u4E0A\u4F20\uFF1B--out <\u8DEF\u5F84> \u4E0B\u8F7D\uFF1B--timeout <\u79D2> \u6709\u754C\u7B49\u5F85",
|
|
4093
|
+
" \u5199\u5165\u9700 --yes\uFF1B\u6536\u8D39\u786E\u8BA4\u5FC5\u987B\u63D0\u4F9B\u5DF2\u67E5\u770B\u7684\u62A5\u4EF7\u8EAB\u4EFD\uFF0CCLI \u4E0D\u81EA\u52A8\u63A5\u53D7\u65B0\u62A5\u4EF7\u3002"
|
|
4094
|
+
].join("\n");
|
|
4095
|
+
}
|
|
4096
|
+
function segment(value, label) {
|
|
4097
|
+
if (!value?.trim() || value === "." || value === ".." || new RegExp("\\p{Cc}", "u").test(value) || value.length > 512) throw usageError(`\u8BF7\u63D0\u4F9B\u6709\u6548\u7684 ${label}`);
|
|
4098
|
+
return encodeURIComponent(value);
|
|
4099
|
+
}
|
|
4100
|
+
function numberOption(context, name2) {
|
|
4101
|
+
const value = textOption(context.values, name2);
|
|
4102
|
+
if (value === void 0) return void 0;
|
|
4103
|
+
const number = Number(value);
|
|
4104
|
+
if (!Number.isSafeInteger(number) || number < 0) throw usageError(`--${name2} \u5FC5\u987B\u4E3A\u975E\u8D1F\u6574\u6570`);
|
|
4105
|
+
return number;
|
|
4106
|
+
}
|
|
4107
|
+
function requestPath(spec, context) {
|
|
4108
|
+
const path = spec.path.replace(/:([A-Za-z]+)/gu, (_match, name2) => segment(name2 === "id" ? context.args[1] : textOption(context.values, pathOptions[name2] ?? name2), name2 === "id" ? "\u9879\u76EE\u7F16\u53F7" : `--${pathOptions[name2] ?? name2}`));
|
|
4109
|
+
const query = new URLSearchParams();
|
|
4110
|
+
for (const [option, field] of Object.entries(spec.query ?? {})) {
|
|
4111
|
+
const value = textOption(context.values, option);
|
|
4112
|
+
if (value !== void 0) query.set(field, value);
|
|
4113
|
+
}
|
|
4114
|
+
if ((spec.command === "file-compare" || spec.command === "script-compare") && (!textOption(context.values, "base-version") || !textOption(context.values, "target-version"))) throw usageError("\u6BD4\u8F83\u7248\u672C\u9700\u8981 --base-version \u548C --target-version");
|
|
4115
|
+
if (spec.command === "asset-upload" && textOption(context.values, "expected-version") === void 0) throw usageError("\u4E0A\u4F20\u804C\u8D23\u7D20\u6750\u9700\u8981 --expected-version");
|
|
4116
|
+
return path + (query.size ? `?${query}` : "");
|
|
4117
|
+
}
|
|
4118
|
+
async function requestBody2(spec, context) {
|
|
4119
|
+
const body = await creativeData(context);
|
|
4120
|
+
for (const field of ["ownerId", "workspaceId", "allowPaidConfirmation"]) if (field in body) throw usageError(`--data \u4E0D\u80FD\u63D0\u4F9B ${field}\uFF1B\u5F52\u5C5E\u53CA\u6388\u6743\u7531\u5BC6\u94A5\u51B3\u5B9A`);
|
|
4121
|
+
for (const [option, field] of [["expected-version", "expectedVersion"], ["expected-epoch", "expectedProductionEpoch"], ["expected-credits", "expectedCredits"]]) {
|
|
4122
|
+
const value = numberOption(context, option);
|
|
4123
|
+
if (value !== void 0) body[field] = value;
|
|
4124
|
+
}
|
|
4125
|
+
for (const [option, field] of [["text", "text"], ["quote-id", "quoteId"], ["expected-current-version", "expectedCurrentVersionId"], ["expected-current-document", "expectedCurrentDocumentId"]]) {
|
|
4126
|
+
const value = textOption(context.values, option);
|
|
4127
|
+
if (value !== void 0) body[field] = value;
|
|
4128
|
+
}
|
|
4129
|
+
if (spec.command === "subtitles-set") {
|
|
4130
|
+
const enabled2 = textOption(context.values, "enabled");
|
|
4131
|
+
if (enabled2 !== void 0) {
|
|
4132
|
+
if (enabled2 !== "true" && enabled2 !== "false") throw usageError("--enabled \u53EA\u80FD\u662F true \u6216 false");
|
|
4133
|
+
body.enabled = enabled2 === "true";
|
|
4134
|
+
}
|
|
4135
|
+
}
|
|
4136
|
+
for (const field of spec.body ?? []) if (!(field in body)) throw usageError(`\u8BF7\u5728 --data \u4E2D\u63D0\u4F9B ${field}`);
|
|
4137
|
+
if (spec.confirmation || spec.command === "retry" && body.storyboardTaskId || spec.command === "asset-resolve" && body.action === "generate_personal") body.confirmed = true;
|
|
4138
|
+
if (spec.command === "retry" && body.storyboardTaskId || spec.command === "asset-resolve" && body.action === "generate_personal") {
|
|
4139
|
+
if (!Number.isSafeInteger(body.expectedCredits) || Number(body.expectedCredits) <= 0) throw usageError("\u6536\u8D39\u64CD\u4F5C\u5FC5\u987B\u63D0\u4F9B\u5F53\u524D\u5361\u4E0A\u7684 expectedCredits");
|
|
4140
|
+
}
|
|
4141
|
+
return body;
|
|
4142
|
+
}
|
|
4143
|
+
var mimeTypes = {
|
|
4144
|
+
image: ["image/png", "image/jpeg", "image/webp"],
|
|
4145
|
+
video: ["video/mp4", "video/quicktime"],
|
|
4146
|
+
audio: ["audio/wav", "audio/x-wav", "audio/mpeg", "audio/mp4", "audio/aac", "audio/ogg"],
|
|
4147
|
+
vtt: ["text/vtt", "application/x-subrip"]
|
|
4148
|
+
};
|
|
4149
|
+
async function tryStudioAction(resource, context) {
|
|
4150
|
+
const spec = STUDIO_ACTIONS.find((item) => item.resource === resource && item.command === context.args[0]);
|
|
4151
|
+
if (!spec) return false;
|
|
4152
|
+
if (spec.needsYes && context.values.yes !== true) throw usageError("\u8BF7\u5148\u6838\u5BF9\u64CD\u4F5C\u8303\u56F4\u548C\u8D39\u7528\uFF0C\u6DFB\u52A0 --yes \u540E\u63D0\u4EA4");
|
|
4153
|
+
const path = requestPath(spec, context);
|
|
4154
|
+
const body = spec.method !== "GET" ? await requestBody2(spec, context) : {};
|
|
4155
|
+
const filePath = textOption(context.values, "file");
|
|
4156
|
+
if (spec.fileType && spec.fileType !== "voice" && !filePath) throw usageError("\u8BF7\u63D0\u4F9B --file <\u672C\u5730\u6587\u4EF6>");
|
|
4157
|
+
const upload3 = spec.fileType && filePath ? await readUploadFile(filePath) : void 0;
|
|
4158
|
+
const { baseUrl, apiKey } = await resolveApiKey(context);
|
|
4159
|
+
const id = context.args[1] ?? "", key = spec.method === "GET" ? void 0 : idempotencyKeyOf(context.values);
|
|
4160
|
+
const perform = async () => {
|
|
4161
|
+
if (spec.events) return studioEvents(baseUrl, apiKey, path, spec.method, body, key, context);
|
|
4162
|
+
if (spec.download) {
|
|
4163
|
+
const file = await downloadAssetFile(baseUrl, apiKey, path, context.io, { allowedMimeTypes: mimeTypes[spec.download] });
|
|
4164
|
+
const filename = file.filename ?? `${resource}-${spec.command}-${id || "output"}.${spec.download === "vtt" ? "vtt" : spec.download === "audio" ? "wav" : spec.download === "video" ? "mp4" : "png"}`;
|
|
4165
|
+
const download4 = await saveDownload(textOption(context.values, "out") ?? filename, file.bytes);
|
|
4166
|
+
return { download: { ...download4, filename } };
|
|
4167
|
+
}
|
|
4168
|
+
let response;
|
|
4169
|
+
if (spec.method === "GET") response = await getJson(baseUrl, apiKey, path, context.io);
|
|
4170
|
+
else if (upload3) {
|
|
4171
|
+
let bytes = upload3.bytes, contentType = textOption(context.values, "mime") ?? upload3.contentType;
|
|
4172
|
+
if (spec.fileType === "mask" || spec.fileType === "voice") {
|
|
4173
|
+
const form = new FormData();
|
|
4174
|
+
form.set(spec.fileType === "mask" ? "mask" : "file", new Blob([new Uint8Array(upload3.bytes)], { type: contentType ?? "application/octet-stream" }), basename4(filePath));
|
|
4175
|
+
for (const [name2, value] of Object.entries(body)) if (value !== void 0 && value !== null) form.set(name2, typeof value === "object" ? JSON.stringify(value) : String(value));
|
|
4176
|
+
const prepared = new Request("https://multipart.invalid", { method: "POST", body: form });
|
|
4177
|
+
bytes = new Uint8Array(await prepared.arrayBuffer());
|
|
4178
|
+
contentType = prepared.headers.get("content-type");
|
|
4179
|
+
}
|
|
4180
|
+
response = await (spec.method === "PUT" ? putRaw : postRaw)(baseUrl, apiKey, path, bytes, contentType, key, context.io);
|
|
4181
|
+
} else if (spec.method === "PUT") response = await putRaw(baseUrl, apiKey, path, Buffer.from(JSON.stringify(body)), "application/json", key, context.io);
|
|
4182
|
+
else response = await postJson(baseUrl, apiKey, path, body, key, context.io, { timeoutMs: timeoutSecondsOf(context.values, 120) * 1e3 });
|
|
4183
|
+
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
|
+
return response.body;
|
|
4185
|
+
};
|
|
4186
|
+
const result = key ? await retainMutationOnError(resource, id, key, baseUrl, perform) : await perform();
|
|
4187
|
+
const output = { ...result, ...key ? { idempotencyKey: key } : {} };
|
|
4188
|
+
context.out.result([JSON.stringify(result, null, 2), ...key ? [`\u5E42\u7B49\u952E\uFF1A${key}`] : []], output);
|
|
4189
|
+
return true;
|
|
4190
|
+
}
|
|
4191
|
+
async function studioEvents(baseUrl, apiKey, path, method, body, key, context) {
|
|
4192
|
+
const origin = normalizeBaseUrl(baseUrl);
|
|
4193
|
+
assertKeyFormat(apiKey);
|
|
4194
|
+
assertReachedDirectly(origin, context.io.env);
|
|
4195
|
+
const timeout = timeoutSecondsOf(context.values, 30);
|
|
4196
|
+
if (timeout > 600) throw usageError("\u5B9E\u65F6\u4E8B\u4EF6\u5355\u6B21\u6700\u591A\u7B49\u5F85 600 \u79D2");
|
|
4197
|
+
const controller = new AbortController(), events = [];
|
|
4198
|
+
let timedOut = false, completed = false, accepted = false, reader;
|
|
4199
|
+
const recovery = () => ({
|
|
4200
|
+
...taskRecovery("videos", context.args[1] ?? "", void 0, baseUrl),
|
|
4201
|
+
...key ? { idempotencyKey: key, operationOutcome: accepted ? "accepted" : "unknown" } : {}
|
|
4202
|
+
});
|
|
4203
|
+
const stop = () => controller.abort();
|
|
4204
|
+
if (context.io.signal?.aborted) throw interruptedError();
|
|
4205
|
+
context.io.signal?.addEventListener("abort", stop, { once: true });
|
|
4206
|
+
const timer = setTimeout(() => {
|
|
4207
|
+
timedOut = true;
|
|
4208
|
+
controller.abort();
|
|
4209
|
+
}, timeout * 1e3);
|
|
4210
|
+
try {
|
|
4211
|
+
const response = await context.io.fetch(`${origin}${path}`, {
|
|
4212
|
+
method,
|
|
4213
|
+
redirect: "manual",
|
|
4214
|
+
signal: controller.signal,
|
|
4215
|
+
headers: { Authorization: `Bearer ${apiKey}`, Accept: "text/event-stream", ...key ? { "Idempotency-Key": key, "Content-Type": "application/json" } : {} },
|
|
4216
|
+
...method === "GET" ? {} : { body: JSON.stringify(body) }
|
|
4217
|
+
});
|
|
4218
|
+
if (response.status >= 300 && response.status < 400) throw new CliError({ code: "CLI_REDIRECT", message: "\u670D\u52A1\u7AEF\u8DF3\u8F6C\u5DF2\u62D2\u7EDD\uFF0C\u5BC6\u94A5\u6CA1\u6709\u8F6C\u53D1", exitCode: EXIT.SERVER });
|
|
4219
|
+
if (!response.ok) throw new CliError({
|
|
4220
|
+
code: "CLI_EVENT_HTTP_ERROR",
|
|
4221
|
+
message: `\u5B9E\u65F6\u4E8B\u4EF6\u8BF7\u6C42\u8FD4\u56DE HTTP ${response.status}\uFF0C\u8BF7\u67E5\u8BE2\u539F\u4EFB\u52A1`,
|
|
4222
|
+
httpStatus: response.status,
|
|
4223
|
+
exitCode: exitCodeForHttpStatus(response.status),
|
|
4224
|
+
retryable: response.status === 429 || response.status >= 500
|
|
4225
|
+
});
|
|
4226
|
+
if (response.headers.get("content-type")?.split(";")[0] !== "text/event-stream" || !response.body) throw new CliError({ code: "CLI_BAD_RESPONSE", message: "\u670D\u52A1\u7AEF\u672A\u8FD4\u56DE\u4E8B\u4EF6\u6D41", exitCode: EXIT.SERVER });
|
|
4227
|
+
accepted = true;
|
|
4228
|
+
reader = response.body.getReader();
|
|
4229
|
+
const decoder = new TextDecoder();
|
|
4230
|
+
let pending = "", size = 0;
|
|
4231
|
+
stream: for (; ; ) {
|
|
4232
|
+
const next = await reader.read();
|
|
4233
|
+
if (next.done) break;
|
|
4234
|
+
size += next.value.byteLength;
|
|
4235
|
+
if (size > 4 * 1024 * 1024 || events.length >= 1e3) throw new CliError({ code: "CLI_EVENT_LIMIT", message: "\u672C\u6B21\u4E8B\u4EF6\u5DF2\u8FBE\u5230\u8BFB\u53D6\u4E0A\u9650\uFF0C\u8BF7\u67E5\u8BE2\u5F53\u524D\u4EFB\u52A1\u6216\u91CD\u65B0\u8FDE\u63A5", exitCode: EXIT.RETRY_LATER });
|
|
4236
|
+
pending = (pending + decoder.decode(next.value, { stream: true })).replace(/\r\n/gu, "\n");
|
|
4237
|
+
for (let at = pending.indexOf("\n\n"); at >= 0; at = pending.indexOf("\n\n")) {
|
|
4238
|
+
const block = pending.slice(0, at);
|
|
4239
|
+
pending = pending.slice(at + 2);
|
|
4240
|
+
const data = block.split("\n").filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trimStart()).join("\n");
|
|
4241
|
+
const eventName = block.split("\n").find((line) => line.startsWith("event:"))?.slice(6).trim();
|
|
4242
|
+
if (data === "[DONE]") {
|
|
4243
|
+
completed = true;
|
|
4244
|
+
break stream;
|
|
4245
|
+
}
|
|
4246
|
+
if (!data) continue;
|
|
4247
|
+
let event;
|
|
4248
|
+
try {
|
|
4249
|
+
event = JSON.parse(data);
|
|
4250
|
+
} catch {
|
|
4251
|
+
event = { text: singleLine(data) };
|
|
4252
|
+
}
|
|
4253
|
+
if (events.length >= 1e3) throw new CliError({ code: "CLI_EVENT_LIMIT", message: "\u672C\u6B21\u4E8B\u4EF6\u5DF2\u8FBE\u5230\u8BFB\u53D6\u4E0A\u9650\uFF0C\u8BF7\u67E5\u8BE2\u5F53\u524D\u4EFB\u52A1", exitCode: EXIT.RETRY_LATER });
|
|
4254
|
+
events.push(event);
|
|
4255
|
+
const payload = event && typeof event === "object" && !Array.isArray(event) ? event : {};
|
|
4256
|
+
if (payload.type === "error" || eventName === "error") throw new CliError({
|
|
4257
|
+
code: "CLI_EVENT_ERROR",
|
|
4258
|
+
message: singleLine(typeof payload.message === "string" ? payload.message : "\u5BFC\u6F14\u56DE\u5408\u8FD4\u56DE\u9519\u8BEF\uFF0C\u8BF7\u67E5\u8BE2\u539F\u4EFB\u52A1"),
|
|
4259
|
+
exitCode: EXIT.SERVER
|
|
4260
|
+
});
|
|
4261
|
+
if (payload.type === "done" || eventName === "done") {
|
|
4262
|
+
completed = true;
|
|
4263
|
+
break stream;
|
|
4264
|
+
}
|
|
4265
|
+
}
|
|
4266
|
+
}
|
|
4267
|
+
if (!completed) throw new CliError({ code: "CLI_EVENT_INCOMPLETE", message: "\u5B9E\u65F6\u8FDE\u63A5\u5DF2\u7ED3\u675F\uFF0C\u4F46\u672A\u6536\u5230\u5B8C\u6210\u56DE\u6267\uFF0C\u8BF7\u67E5\u8BE2\u539F\u4EFB\u52A1", exitCode: EXIT.RETRY_LATER });
|
|
4268
|
+
} catch (error) {
|
|
4269
|
+
const failure = context.io.signal?.aborted ? interruptedError() : timedOut ? new CliError({ code: "CLI_TIMEOUT", message: "\u5B9E\u65F6\u7B49\u5F85\u5DF2\u8D85\u65F6\uFF0C\u8BF7\u67E5\u8BE2\u539F\u4EFB\u52A1\uFF1B\u6CA1\u6709\u91CD\u65B0\u63D0\u4EA4\u6D88\u606F", exitCode: EXIT.SERVER }) : toCliError(error);
|
|
4270
|
+
if (!timedOut || key || context.io.signal?.aborted) throw accepted ? failure.withRecovery(recovery()) : failure;
|
|
4271
|
+
} finally {
|
|
4272
|
+
clearTimeout(timer);
|
|
4273
|
+
context.io.signal?.removeEventListener("abort", stop);
|
|
4274
|
+
await reader?.cancel().catch(() => void 0);
|
|
4275
|
+
}
|
|
4276
|
+
return { events, timedOut, completed, taskId: context.args[1], recovery: recovery() };
|
|
4277
|
+
}
|
|
4278
|
+
|
|
4279
|
+
// src/commands/series.ts
|
|
4280
|
+
async function series(context) {
|
|
4281
|
+
const [action2, id] = context.args;
|
|
4282
|
+
const { baseUrl, apiKey } = await resolveApiKey(context);
|
|
4283
|
+
if (action2 === "list" || action2 === "show") {
|
|
4284
|
+
if (action2 === "show" && !id) throw usageError("\u8BF7\u63D0\u4F9B\u5267\u96C6\u7F16\u53F7");
|
|
4285
|
+
const query = new URLSearchParams();
|
|
4286
|
+
for (const name2 of ["limit", "offset"]) {
|
|
4287
|
+
const value = textOption(context.values, name2);
|
|
4288
|
+
if (value) query.set(name2, value);
|
|
4289
|
+
}
|
|
4290
|
+
const result2 = await getCreative(baseUrl, apiKey, "series", action2 === "show" ? id : void 0, action2 === "list" && query.size ? `?${query}` : "", context.io);
|
|
4291
|
+
context.out.result([JSON.stringify(result2, null, 2)], result2);
|
|
4292
|
+
return;
|
|
4293
|
+
}
|
|
4294
|
+
if (action2 !== "create" && action2 !== "episode-create") throw usageError("series \u652F\u6301 list\u3001show\u3001create\u3001episode-create");
|
|
4295
|
+
if (action2 === "episode-create" && !id) throw usageError("\u8BF7\u63D0\u4F9B\u5267\u96C6\u7F16\u53F7");
|
|
4296
|
+
const body = await creativeData(context);
|
|
4297
|
+
for (const [option, field] of [["product", "productId"], ["project", "projectId"], ["title", "title"], ["main-line", "mainLine"], ["logline", "logline"], ["previous-episode", "previousEpisodeId"]]) {
|
|
4298
|
+
const value = textOption(context.values, option);
|
|
4299
|
+
if (value !== void 0) body[field] = value;
|
|
4300
|
+
}
|
|
4301
|
+
const epoch = textOption(context.values, "expected-epoch");
|
|
4302
|
+
if (epoch !== void 0) body.expectedProductionEpoch = Number(epoch);
|
|
4303
|
+
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
|
+
const key = idempotencyKeyOf(context.values);
|
|
4305
|
+
const result = await postCreative(baseUrl, apiKey, "series", action2 === "episode-create" ? id : void 0, action2 === "episode-create" ? "episodes" : "", body, key, context.io);
|
|
4306
|
+
context.out.result([JSON.stringify(result, null, 2), `\u5E42\u7B49\u952E\uFF1A${key}`], { ...result, idempotencyKey: key });
|
|
4307
|
+
}
|
|
4308
|
+
|
|
4309
|
+
// src/commands/assets.ts
|
|
4310
|
+
import { basename as basename5 } from "node:path";
|
|
4311
|
+
|
|
4312
|
+
// src/client-catalog.ts
|
|
4313
|
+
var fields = ["id", "name", "category", "sku", "archivedAt", "mergedIntoProductId", "createdAt", "updatedAt", "kind", "source", "status", "statusLabel", "projectId", "seriesId", "durationSeconds", "aspectRatio", "model", "renamable", "archivable", "mime", "bytes", "sha256", "license", "manageable", "archived", "url"];
|
|
4314
|
+
function record(value) {
|
|
4315
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
4316
|
+
}
|
|
4317
|
+
function bad(status4) {
|
|
4318
|
+
throw new CliError({ code: "CLI_BAD_RESPONSE", message: "\u670D\u52A1\u5668\u54CD\u5E94\u683C\u5F0F\u4E0D\u7B26\u5408\u63A5\u53E3\u7EA6\u5B9A", exitCode: EXIT.SERVER, httpStatus: status4 });
|
|
4319
|
+
}
|
|
4320
|
+
function entry(value, status4) {
|
|
4321
|
+
if (!record(value) || typeof value.id !== "string") return bad(status4);
|
|
4322
|
+
const selected = {};
|
|
4323
|
+
for (const field of fields) if (["string", "number", "boolean"].includes(typeof value[field]) || value[field] === null) selected[field] = value[field];
|
|
4324
|
+
if (Array.isArray(value.tags)) selected.tags = value.tags.filter((tag) => typeof tag === "string");
|
|
4325
|
+
if (Array.isArray(value.images)) selected.images = value.images.flatMap((image) => {
|
|
4326
|
+
if (!record(image)) return [];
|
|
4327
|
+
return [Object.fromEntries(["id", "angle", "slot", "url", "mime", "bytes", "sha256"].filter((key) => typeof image[key] === "string" || typeof image[key] === "number" || image[key] === null).map((key) => [key, image[key]]))];
|
|
4328
|
+
});
|
|
4329
|
+
if (record(value.product) && typeof value.product.id === "string") selected.product = entry(value.product, status4);
|
|
4330
|
+
if (record(value.episode)) {
|
|
4331
|
+
const episode = value.episode;
|
|
4332
|
+
selected.episode = Object.fromEntries(["id", "number"].filter((key) => typeof episode[key] === "string" || typeof episode[key] === "number").map((key) => [key, episode[key]]));
|
|
4333
|
+
}
|
|
4334
|
+
return selected;
|
|
4335
|
+
}
|
|
4336
|
+
function catalogResponse(reply) {
|
|
4337
|
+
if (!record(reply.body)) return bad(reply.status);
|
|
4338
|
+
const result = {};
|
|
4339
|
+
let hasData = false;
|
|
4340
|
+
for (const key of ["product", "item", "asset"]) if (reply.body[key] !== void 0) {
|
|
4341
|
+
result[key] = entry(reply.body[key], reply.status);
|
|
4342
|
+
hasData = true;
|
|
4343
|
+
}
|
|
4344
|
+
for (const key of ["products", "items", "assets"]) if (Array.isArray(reply.body[key])) {
|
|
4345
|
+
result[key] = reply.body[key].map((item) => entry(item, reply.status));
|
|
4346
|
+
hasData = true;
|
|
4347
|
+
}
|
|
4348
|
+
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) result[key] = reply.body[key];
|
|
4350
|
+
return result;
|
|
4351
|
+
}
|
|
4352
|
+
function catalogQuery(values, fields3) {
|
|
4353
|
+
const query = new URLSearchParams();
|
|
4354
|
+
for (const field of fields3) {
|
|
4355
|
+
const value = values[field];
|
|
4356
|
+
if (typeof value === "string" && value.trim()) query.set(field === "product" ? "productId" : field, value);
|
|
4357
|
+
}
|
|
4358
|
+
const text = query.toString();
|
|
4359
|
+
return text ? `?${text}` : "";
|
|
4360
|
+
}
|
|
4361
|
+
async function catalogGet(baseUrl, key, path, deps) {
|
|
4362
|
+
return catalogResponse(await getJson(baseUrl, key, path, deps));
|
|
4363
|
+
}
|
|
4364
|
+
async function retainKey(key, operation) {
|
|
4365
|
+
try {
|
|
4366
|
+
return await operation();
|
|
4367
|
+
} catch (error) {
|
|
4368
|
+
const e = toCliError(error);
|
|
4369
|
+
throw new CliError({
|
|
4370
|
+
code: e.code,
|
|
4371
|
+
message: `${e.message}
|
|
4372
|
+
\u672C\u6B21\u5E42\u7B49\u952E\uFF1A${key}\u3002\u518D\u6B21\u63D0\u4EA4\u540C\u4E00\u64CD\u4F5C\u65F6\u8BF7\u590D\u7528\u6B64\u952E\u3002`,
|
|
4373
|
+
exitCode: e.exitCode,
|
|
4374
|
+
retryable: e.retryable,
|
|
4375
|
+
traceId: e.traceId,
|
|
4376
|
+
retryAfterSeconds: e.retryAfterSeconds,
|
|
4377
|
+
httpStatus: e.httpStatus,
|
|
4378
|
+
hints: e.hints,
|
|
4379
|
+
recovery: e.recovery
|
|
4380
|
+
});
|
|
4381
|
+
}
|
|
4382
|
+
}
|
|
4383
|
+
async function catalogWrite(baseUrl, key, path, method, body, idempotencyKey, deps) {
|
|
4384
|
+
return retainKey(idempotencyKey, async () => catalogResponse(await (method === "PATCH" ? patchJson : postJson)(baseUrl, key, path, body, idempotencyKey, deps)));
|
|
4385
|
+
}
|
|
4386
|
+
async function catalogUpload(baseUrl, key, path, bytes, mime, idempotencyKey, deps) {
|
|
4387
|
+
return retainKey(idempotencyKey, async () => catalogResponse(await postRaw(baseUrl, key, path, bytes, mime, idempotencyKey, deps)));
|
|
4388
|
+
}
|
|
4389
|
+
|
|
4390
|
+
// src/commands/assets.ts
|
|
4391
|
+
async function assets(context) {
|
|
4392
|
+
const [action2, rawId] = context.args;
|
|
4393
|
+
if (!["list", "search", "show", "upload", "rename", "archive", "restore"].includes(action2 ?? "")) throw usageError("assets \u652F\u6301 list\u3001search\u3001show\u3001upload\u3001rename\u3001archive\u3001restore");
|
|
4394
|
+
const listing = action2 === "list" || action2 === "search";
|
|
4395
|
+
if (!listing && !rawId) throw usageError(action2 === "upload" ? "\u8BF7\u63D0\u4F9B\u4E0A\u4F20\u6587\u4EF6\u8DEF\u5F84" : "\u8BF7\u63D0\u4F9B\u7D20\u6750\u7F16\u53F7");
|
|
4396
|
+
const name2 = textOption(context.values, "name");
|
|
4397
|
+
if (action2 === "rename" && !name2) throw usageError("\u8BF7\u63D0\u4F9B --name <\u540D\u79F0>");
|
|
4398
|
+
const source = textOption(context.values, "source") ?? "personal";
|
|
4399
|
+
if (["rename", "archive", "restore"].includes(action2) && source !== "personal") throw usageError("\u53EA\u6709\u4E2A\u4EBA\u751F\u6210\u7D20\u6750\u652F\u6301\u6539\u540D\u3001\u5F52\u6863\u53CA\u6062\u590D\uFF1B\u5E73\u53F0\u7D20\u6750\u53EA\u8BFB\uFF0C\u4E0A\u4F20\u7D20\u6750\u4FDD\u7559\u6388\u6743\u8BB0\u5F55");
|
|
4400
|
+
let upload3;
|
|
4401
|
+
let query = "";
|
|
4402
|
+
if (action2 === "upload") {
|
|
4403
|
+
const authorization = textOption(context.values, "authorization"), license = textOption(context.values, "license");
|
|
4404
|
+
if (!authorization || !["own", "licensed", "public_domain"].includes(authorization) || !license) throw usageError("\u4E0A\u4F20\u9700\u63D0\u4F9B --authorization <own|licensed|public_domain> \u4E0E --license <\u6388\u6743\u8BF4\u660E>");
|
|
4405
|
+
upload3 = await readUploadFile(rawId);
|
|
4406
|
+
query = `?${new URLSearchParams({ name: name2 ?? basename5(rawId), authorization, license })}`;
|
|
4407
|
+
}
|
|
4408
|
+
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
4409
|
+
const key = listing || action2 === "show" ? void 0 : idempotencyKeyOf(context.values);
|
|
4410
|
+
const path = listing ? `/api/open/v1/assets${catalogQuery(context.values, ["q", "kind", "source", "limit", "offset"])}` : `/api/open/v1/assets/${encodeURIComponent(rawId)}`;
|
|
4411
|
+
const result = 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);
|
|
4412
|
+
const items = Array.isArray(result.assets) ? result.assets : [result.asset];
|
|
4413
|
+
context.out.result(items.filter(Boolean).map((item) => {
|
|
4414
|
+
const r = item;
|
|
4415
|
+
return `${singleLine(String(r.id))} ${singleLine(String(r.name))} ${singleLine(String(r.source))}`;
|
|
4416
|
+
}), { ...result, ...key ? { idempotencyKey: key } : {} });
|
|
4417
|
+
}
|
|
4418
|
+
|
|
4419
|
+
// src/commands/library.ts
|
|
4420
|
+
async function library(context) {
|
|
4421
|
+
const [action2, rawId] = context.args;
|
|
4422
|
+
if (!["list", "search", "show", "rename", "archive", "restore"].includes(action2 ?? "")) throw usageError("library \u652F\u6301 list\u3001search\u3001show\u3001rename\u3001archive\u3001restore");
|
|
4423
|
+
const listing = action2 === "list" || action2 === "search";
|
|
4424
|
+
const kind = textOption(context.values, "kind");
|
|
4425
|
+
if (!listing && (!rawId || !kind)) throw usageError("\u8BF7\u63D0\u4F9B\u4F5C\u54C1\u7F16\u53F7\u53CA --kind <commercial_ad|episode|graphic>");
|
|
4426
|
+
const path = listing ? `/api/open/v1/library${catalogQuery(context.values, ["q", "kind", "state", "product", "archived", "limit", "cursor"])}` : `/api/open/v1/library/${encodeURIComponent(kind)}/${encodeURIComponent(rawId)}`;
|
|
4427
|
+
const name2 = textOption(context.values, "name");
|
|
4428
|
+
if (action2 === "rename" && !name2) throw usageError("\u8BF7\u63D0\u4F9B --name <\u540D\u79F0>");
|
|
4429
|
+
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
4430
|
+
const key = listing || action2 === "show" ? void 0 : idempotencyKeyOf(context.values);
|
|
4431
|
+
const result = 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);
|
|
4432
|
+
const items = Array.isArray(result.items) ? result.items : [result.item];
|
|
4433
|
+
context.out.result(items.filter(Boolean).map((item) => {
|
|
4434
|
+
const r = item;
|
|
4435
|
+
return `${singleLine(String(r.id))} ${singleLine(String(r.name))} ${singleLine(String(r.status))}`;
|
|
4436
|
+
}), { ...result, ...key ? { idempotencyKey: key } : {} });
|
|
4437
|
+
}
|
|
4438
|
+
|
|
4439
|
+
// src/cli.ts
|
|
4440
|
+
import { parseArgs } from "node:util";
|
|
4441
|
+
|
|
4442
|
+
// src/commands/balance.ts
|
|
4443
|
+
async function balance(context) {
|
|
4444
|
+
const { io, out } = context;
|
|
4445
|
+
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
4446
|
+
const { view, raw } = await getBalance(baseUrl, apiKey, io);
|
|
4447
|
+
out.result(
|
|
4448
|
+
[
|
|
4449
|
+
`\u53EF\u7528\u4F59\u989D\uFF1A${view.available} ${singleLine(view.currency)}`,
|
|
4450
|
+
`\u51BB\u7ED3\u4E2D\uFF1A${view.held} ${singleLine(view.currency)}`,
|
|
4451
|
+
`\u5DF2\u652F\u51FA\uFF1A${view.spent} ${singleLine(view.currency)}`,
|
|
4452
|
+
`\u66F4\u65B0\u65F6\u95F4\uFF1A${singleLine(view.updatedAt)}`
|
|
4453
|
+
],
|
|
4454
|
+
{ balance: raw.balance }
|
|
4455
|
+
);
|
|
4456
|
+
}
|
|
4457
|
+
|
|
4458
|
+
// src/commands/creative-attachments.ts
|
|
4459
|
+
import { basename as basename6 } from "node:path";
|
|
4460
|
+
async function creativeAttachments(context, resource) {
|
|
4461
|
+
const [action2, id] = context.args;
|
|
4462
|
+
if (!id) throw usageError("\u8BF7\u63D0\u4F9B\u9879\u76EE\u7F16\u53F7");
|
|
4463
|
+
const { baseUrl, apiKey } = await resolveApiKey(context);
|
|
4464
|
+
if (action2 === "attachments") {
|
|
4465
|
+
const ids = textOption(context.values, "attachment-ids")?.split(",").map((value) => value.trim());
|
|
4466
|
+
const params = new URLSearchParams();
|
|
4467
|
+
const offset = textOption(context.values, "offset");
|
|
4468
|
+
if (offset) params.set("offset", offset);
|
|
4469
|
+
for (const item of ids ?? []) params.append("attachmentId", item);
|
|
4470
|
+
const result = await getCreative(baseUrl, apiKey, resource, id, `attachments${params.size ? `?${params}` : ""}`, context.io);
|
|
4471
|
+
context.out.result([JSON.stringify(result, null, 2)], result);
|
|
4472
|
+
return;
|
|
4473
|
+
}
|
|
4474
|
+
if (action2 === "upload") {
|
|
4475
|
+
const path = textOption(context.values, "file");
|
|
4476
|
+
if (!path) throw usageError("\u8BF7\u63D0\u4F9B --file <\u9644\u4EF6\u8DEF\u5F84>");
|
|
4477
|
+
const upload3 = await readUploadFile(path);
|
|
4478
|
+
const key = idempotencyKeyOf(context.values);
|
|
4479
|
+
const suffix = `attachments?${new URLSearchParams({ name: basename6(path) })}`;
|
|
4480
|
+
try {
|
|
4481
|
+
const result = creativeObject((await putRaw(baseUrl, apiKey, creativePath(resource, id, suffix), upload3.bytes, upload3.contentType, key, context.io)).body);
|
|
4482
|
+
context.out.result([JSON.stringify(result, null, 2), `\u5E42\u7B49\u952E\uFF1A${key}`], { ...result, idempotencyKey: key });
|
|
4483
|
+
return;
|
|
4484
|
+
} catch (error) {
|
|
4485
|
+
const failure = toCliError(error);
|
|
4486
|
+
const recovery = taskRecovery(resource, id, void 0, baseUrl);
|
|
4487
|
+
throw failure.withRecovery({
|
|
4488
|
+
...recovery,
|
|
4489
|
+
acceptance: "unknown",
|
|
4490
|
+
idempotencyKey: key,
|
|
4491
|
+
statusCommand: recovery.statusCommand?.replace(` ${resource} status `, ` ${resource} attachments `)
|
|
4492
|
+
});
|
|
4493
|
+
}
|
|
4494
|
+
}
|
|
4495
|
+
const attachmentId = textOption(context.values, "attachment-id");
|
|
4496
|
+
if (!attachmentId) throw usageError("\u8BF7\u63D0\u4F9B --attachment-id <\u9644\u4EF6\u7F16\u53F7>");
|
|
4497
|
+
const file = await downloadAssetFile(
|
|
4498
|
+
baseUrl,
|
|
4499
|
+
apiKey,
|
|
4500
|
+
creativePath(resource, id, `attachments/${encodeURIComponent(attachmentId)}/download`),
|
|
4501
|
+
context.io,
|
|
4502
|
+
{ allowedMimeTypes: ["image/png", "image/jpeg", "image/webp", "application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "text/plain", "text/markdown", "video/mp4", "video/quicktime", "video/webm"] }
|
|
4503
|
+
);
|
|
4504
|
+
const saved = await saveDownload(textOption(context.values, "out") ?? file.filename ?? `attachment-${attachmentId}`, file.bytes);
|
|
4505
|
+
context.out.result([`\u5DF2\u4E0B\u8F7D\uFF1A${saved.path}`, `\u6821\u9A8C\uFF1Asha256 ${saved.sha256}`], { download: saved });
|
|
4506
|
+
}
|
|
4507
|
+
|
|
4508
|
+
// 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";
|
|
4510
|
+
var DURATION_KEYS = ["30s", "60s", "90s"];
|
|
4511
|
+
async function drama2(context) {
|
|
4512
|
+
timeoutSecondsOf(context.values, DEFAULT_WAIT_TIMEOUT_MS / 1e3);
|
|
4513
|
+
const { args } = context;
|
|
4514
|
+
const [subcommand] = args;
|
|
4515
|
+
if (subcommand === void 0) {
|
|
4516
|
+
throw usageError(`drama \u8981\u8DDF\u4E00\u4E2A\u5B50\u547D\u4EE4\uFF1A${SUBCOMMANDS2}`);
|
|
4517
|
+
}
|
|
4518
|
+
if (["context", "director", "document", "versions", "message", "director-confirm", "bindings", "spec", "shot-plan", "select-version", "redo-quote", "redo"].includes(subcommand)) return dramaCreative(context);
|
|
4519
|
+
if (["attachments", "upload", "attachment-download"].includes(subcommand)) return creativeAttachments(context, "drama");
|
|
4520
|
+
if (subcommand === "create") return create(context);
|
|
4521
|
+
if (subcommand === "status") return status2(context, args[1]);
|
|
4522
|
+
if (subcommand === "quote") return quote2(context, args[1]);
|
|
4523
|
+
if (subcommand === "confirm") return confirm(context, args[1]);
|
|
4524
|
+
if (subcommand === "cancel") return cancel2(context, args[1]);
|
|
4525
|
+
if (subcommand === "download") return download2(context, args[1]);
|
|
4526
|
+
throw usageError(`\u4E0D\u8BA4\u8BC6\u7684\u5B50\u547D\u4EE4 ${subcommand}\uFF1Adrama \u7684\u5B50\u547D\u4EE4\u662F ${SUBCOMMANDS2}`);
|
|
4527
|
+
}
|
|
4528
|
+
function orderIdOf2(raw) {
|
|
4529
|
+
if (raw === void 0 || raw.trim() === "") {
|
|
4530
|
+
throw usageError("\u8981\u7ED9\u8BA2\u5355 id\uFF08drama create \u56DE\u7684\u90A3\u4E2A\uFF09");
|
|
4531
|
+
}
|
|
4532
|
+
return raw.trim();
|
|
4533
|
+
}
|
|
4534
|
+
function waitControls2(io, values, note) {
|
|
4535
|
+
return {
|
|
4536
|
+
timeoutMs: timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3) * 1e3,
|
|
4537
|
+
now: io.now ?? (() => /* @__PURE__ */ new Date()),
|
|
4538
|
+
sleep: (ms) => sleepFor(io, ms),
|
|
4539
|
+
note
|
|
4540
|
+
};
|
|
4541
|
+
}
|
|
4542
|
+
function settleOrder2(outcome, baseUrl) {
|
|
4543
|
+
const order2 = outcome.value.view;
|
|
4544
|
+
const recovery = taskRecovery("drama", order2.id, order2.status, baseUrl);
|
|
4545
|
+
if (outcome.timedOut) {
|
|
4546
|
+
throw new CliError({
|
|
4547
|
+
code: "CLI_WAIT_TIMEOUT",
|
|
4548
|
+
exitCode: EXIT.WAIT_TIMEOUT,
|
|
4549
|
+
message: order2.status === "quotable" ? `\u7B49\u5F85\u5DF2\u8FBE\u5230\u65F6\u9650\u3002\u8BA2\u5355\u72B6\u6001\u4E3A quotable\uFF0C\u9700\u5B8C\u6210\u8D39\u7528\u786E\u8BA4\u540E\u624D\u80FD\u5F00\u59CB\u5236\u4F5C\u3002\u672C\u6B21\u67E5\u8BE2\u4E0D\u4F1A\u81EA\u52A8\u786E\u8BA4\uFF1B\u8BF7\u67E5\u8BE2\u62A5\u4EF7\u540E\u663E\u5F0F\u786E\u8BA4\u5F00\u62CD\u3002\u67E5\u8BE2\u539F\u8BA2\u5355\uFF1A${recovery.statusCommand}` : `\u7B49\u5F85\u5DF2\u8FBE\u5230\u65F6\u9650\uFF0C\u8BA2\u5355\u5F53\u524D\u72B6\u6001\u4E3A ${singleLine(order2.status)}\u3002\u67E5\u8BE2\u539F\u8BA2\u5355\uFF1A${recovery.statusCommand}\uFF1B\u6DFB\u52A0 --wait --timeout <\u79D2\u6570> \u53EF\u7EE7\u7EED\u7B49\u5F85\u3002`,
|
|
4550
|
+
recovery
|
|
4551
|
+
});
|
|
4552
|
+
}
|
|
4553
|
+
if (order2.status === "failed") {
|
|
4554
|
+
throw new CliError({
|
|
4555
|
+
code: "CLI_TASK_FAILED",
|
|
4556
|
+
exitCode: EXIT.TASK_FAILED,
|
|
4557
|
+
message: order2.reason === void 0 || order2.reason.trim() === "" ? "\u8FD9\u5355\u77ED\u5267\u6CA1\u6709\u62CD\u6210" : singleLine(order2.reason),
|
|
4558
|
+
recovery,
|
|
4559
|
+
hints: failureLines(order2),
|
|
4560
|
+
...order2.failures?.length ? { failures: order2.failures } : {}
|
|
4561
|
+
});
|
|
4562
|
+
}
|
|
4563
|
+
if (order2.status === "canceled") {
|
|
4564
|
+
throw new CliError({
|
|
4565
|
+
code: "CLI_TASK_FAILED",
|
|
4566
|
+
exitCode: EXIT.TASK_FAILED,
|
|
4567
|
+
message: "\u8FD9\u5355\u77ED\u5267\u5DF2\u53D6\u6D88\uFF1A\u6CA1\u62CD\u7684\u955C\u5934\u9000\u56DE\u51BB\u7ED3\u989D\u5EA6\uFF0C\u5DF2\u7ECF\u62CD\u6210\u7684\u4FDD\u7559\u7167\u6263",
|
|
4568
|
+
recovery
|
|
4569
|
+
});
|
|
4570
|
+
}
|
|
4571
|
+
return outcome.value;
|
|
4572
|
+
}
|
|
4573
|
+
function orderLines2(order2) {
|
|
4574
|
+
const money = order2.money;
|
|
4575
|
+
const extra = [];
|
|
4576
|
+
if (money.released > 0) extra.push(`\u5DF2\u91CA\u653E ${money.released} ${money.currency}`);
|
|
4577
|
+
if (money.refunded > 0) extra.push(`\u5DF2\u9000\u6B3E ${money.refunded} ${money.currency}`);
|
|
4578
|
+
return [
|
|
4579
|
+
`\u8BA2\u5355\uFF1A${singleLine(order2.id)}`,
|
|
4580
|
+
`\u72B6\u6001\uFF1A${singleLine(order2.status)}`,
|
|
4581
|
+
`\u4EA7\u54C1\uFF1A${singleLine(order2.productId)}\uFF08\u9898\u6750 ${singleLine(order2.genreId)}\uFF0C\u4F53\u91CF ${singleLine(order2.durationKey)}\uFF09`,
|
|
4582
|
+
`\u66F4\u65B0\u65F6\u95F4\uFF1A${singleLine(order2.updatedAt)}`,
|
|
4583
|
+
`\u8D26\uFF1A\u51BB\u7ED3 ${money.held} ${money.currency}\uFF0C\u5DF2\u7ED3\u7B97 ${money.settled} ${money.currency}` + (extra.length > 0 ? `\uFF08${extra.join("\uFF0C")}\uFF09` : "")
|
|
4584
|
+
];
|
|
4585
|
+
}
|
|
4586
|
+
function guidanceLines(order2) {
|
|
4587
|
+
const lines2 = [];
|
|
4588
|
+
if (order2.reason !== void 0 && order2.reason.trim() !== "") {
|
|
4589
|
+
const label = order2.status === "failed" ? "\u5931\u8D25\u539F\u56E0" : order2.status === "partial" ? "\u6CA1\u62CD\u5B8C\u7684\u90E8\u5206" : "\u505C\u9760\u539F\u56E0";
|
|
4590
|
+
lines2.push(`${label}\uFF1A${singleLine(order2.reason)}`);
|
|
4591
|
+
}
|
|
4592
|
+
for (const gap of order2.gaps ?? []) {
|
|
4593
|
+
const kind = gap.kind === "character" ? "\u89D2\u8272" : gap.kind === "scene" ? "\u573A\u666F" : "\u7D20\u6750";
|
|
4594
|
+
const scenes = gap.sceneNos.length > 0 ? `\uFF0C\u51FA\u73B0\u5728\u7B2C ${gap.sceneNos.join("\u3001")} \u955C` : "";
|
|
4595
|
+
lines2.push(`\u7F3A\u53E3\uFF1A${kind}\u300C${singleLine(gap.label !== "" ? gap.label : gap.key)}\u300D\u8FD8\u6CA1\u7ED1\u5B9A${scenes}`);
|
|
4596
|
+
}
|
|
4597
|
+
lines2.push(...failureLines(order2));
|
|
4598
|
+
if (order2.productionCompatibility?.notice) lines2.push(`\u5236\u4F5C\u89C4\u683C\uFF1A${singleLine(order2.productionCompatibility.notice)}`);
|
|
4599
|
+
const next = nextStepOf(order2);
|
|
4600
|
+
return next === null ? lines2 : [...lines2, next];
|
|
4601
|
+
}
|
|
4602
|
+
function failureLines(order2) {
|
|
4603
|
+
return (order2.failures ?? []).flatMap((failure) => [
|
|
4604
|
+
`\u955C\u5934\u95EE\u9898\uFF1A${singleLine(failure.message)}`,
|
|
2145
4605
|
...failure.reference?.assetIds.length ? [`\u7D20\u6750\u7F16\u53F7\uFF1A${failure.reference.assetIds.map(singleLine).join("\u3001")}`] : [],
|
|
2146
4606
|
`\u5904\u7406\u5EFA\u8BAE\uFF1A${singleLine(failure.suggestion)}`
|
|
2147
4607
|
]);
|
|
@@ -2151,14 +4611,14 @@ function nextStepOf(order2) {
|
|
|
2151
4611
|
case "preparing":
|
|
2152
4612
|
return `\u4E0B\u4E00\u6B65\uFF1A\u7B49\u5199\u7A3F\u4E0E\u6392\u7248\u8DD1\u5B8C\uFF0C\u91CD\u65B0\u67E5\u8BE2\uFF1Abuke drama status ${order2.id}`;
|
|
2153
4613
|
case "needs_attention":
|
|
2154
|
-
return `\u4E0B\u4E00\u6B65\uFF1A\
|
|
4614
|
+
return `\u4E0B\u4E00\u6B65\uFF1A\u5148\u67E5\u8BE2\u5F53\u524D\u7248\u672C\u4E0E\u5BFC\u6F14\u72B6\u6001\uFF1Abuke drama context ${order2.id}\uFF1Bbuke drama director ${order2.id}\u3002\u6309\u95EE\u9898\u4F7F\u7528 bindings\u3001spec \u6216 message \u5904\u7406\uFF0C\u518D\u8FD0\u884C buke drama status ${order2.id}`;
|
|
2155
4615
|
case "quotable":
|
|
2156
4616
|
return `\u4E0B\u4E00\u6B65\uFF1A\u770B\u62A5\u4EF7\uFF1Abuke drama quote ${order2.id}\uFF0C\u518D\u786E\u8BA4\u5F00\u62CD\uFF1Abuke drama confirm ${order2.id} --quote-hash <\u62A5\u4EF7\u54C8\u5E0C>`;
|
|
2157
4617
|
case "producing":
|
|
2158
4618
|
case "stitching":
|
|
2159
4619
|
return `\u4E0B\u4E00\u6B65\uFF1A\u7B49\u5B83\u62CD\u5B8C\uFF1Abuke drama status ${order2.id} --wait`;
|
|
2160
4620
|
case "partial":
|
|
2161
|
-
if (order2.failures?.length) return "\u4E0B\u4E00\u6B65\uFF1A\
|
|
4621
|
+
if (order2.failures?.length) return "\u4E0B\u4E00\u6B65\uFF1A\u6309\u955C\u5934\u63D0\u793A\u4F7F\u7528 buke drama bindings \u4FEE\u6B63\u7D20\u6750\uFF0C\u6216\u901A\u8FC7 buke drama spec \u4FEE\u6539\u5236\u4F5C\u89C4\u683C\uFF1B\u91CD\u65B0\u67E5\u8BE2\u62A5\u4EF7\u540E\u660E\u786E\u786E\u8BA4\u8865\u62CD\u3002";
|
|
2162
4622
|
return `\u4E0B\u4E00\u6B65\uFF1A\u53EA\u8865\u7F3A\u7684\u955C\u5934\uFF1Abuke drama confirm ${order2.id} --quote-hash <\u62A5\u4EF7\u54C8\u5E0C>\uFF1B\u4E0D\u8981\u4E86\uFF1Abuke drama cancel ${order2.id}`;
|
|
2163
4623
|
case "delivered":
|
|
2164
4624
|
return `\u4E0B\u8F7D\uFF1Abuke drama download ${order2.id}`;
|
|
@@ -2174,7 +4634,7 @@ function sufficientLine(sufficient) {
|
|
|
2174
4634
|
function quoteLines(orderId, quote3) {
|
|
2175
4635
|
const price = [`\u603B\u4EF7 ${quote3.totalCredits} \u5E03`, `${quote3.shotCount} \u4E2A\u955C\u5934`];
|
|
2176
4636
|
if (quote3.shotCreditCost !== void 0) price.push(`\u6BCF\u955C ${quote3.shotCreditCost} \u5E03`);
|
|
2177
|
-
const spec = [quote3.videoModel, quote3.resolution].filter((
|
|
4637
|
+
const spec = [quote3.videoModel, quote3.resolution].filter((entry2) => entry2 !== void 0);
|
|
2178
4638
|
const compatibility = quote3.productionCompatibility;
|
|
2179
4639
|
return [
|
|
2180
4640
|
`\u62A5\u4EF7\uFF1A${price.join("\uFF0C")}`,
|
|
@@ -2188,12 +4648,15 @@ function quoteLines(orderId, quote3) {
|
|
|
2188
4648
|
}
|
|
2189
4649
|
async function create(context) {
|
|
2190
4650
|
const { io, out, values } = context;
|
|
2191
|
-
const
|
|
2192
|
-
|
|
4651
|
+
const dataRef = textOption(values, "data");
|
|
4652
|
+
const data = dataRef ? await readPropsArgument(io, dataRef, "\u77ED\u5267\u53C2\u6570\uFF08--data\uFF09") : {};
|
|
4653
|
+
for (const field of ["ownerId", "workspaceId", "allowPaidConfirmation"]) if (field in data) throw usageError(`--data \u4E0D\u80FD\u63D0\u4F9B ${field}`);
|
|
4654
|
+
const productId = textOption(values, "product") ?? (typeof data.productId === "string" ? data.productId : void 0);
|
|
4655
|
+
if (!productId?.trim()) {
|
|
2193
4656
|
throw usageError("\u8981\u7ED9 --product <\u4EA7\u54C1id>\uFF08buke products create \u56DE\u7684\u90A3\u4E2A\uFF09");
|
|
2194
4657
|
}
|
|
2195
4658
|
const genreId = textOption(values, "genre");
|
|
2196
|
-
const durationKey = textOption(values, "duration");
|
|
4659
|
+
const durationKey = textOption(values, "duration") ?? (typeof data.durationKey === "string" ? data.durationKey : void 0);
|
|
2197
4660
|
if (durationKey !== void 0 && !DURATION_KEYS.includes(durationKey)) {
|
|
2198
4661
|
throw usageError(`--duration \u53EA\u80FD\u662F ${DURATION_KEYS.join("\u3001")}\uFF0C\u5199\u7684\u662F ${durationKey}`);
|
|
2199
4662
|
}
|
|
@@ -2207,6 +4670,7 @@ async function create(context) {
|
|
|
2207
4670
|
baseUrl,
|
|
2208
4671
|
apiKey,
|
|
2209
4672
|
{
|
|
4673
|
+
...data,
|
|
2210
4674
|
productId,
|
|
2211
4675
|
...genreId === void 0 ? {} : { genreId },
|
|
2212
4676
|
...durationKey === void 0 ? {} : { durationKey },
|
|
@@ -2312,6 +4776,12 @@ async function download2(context, rawId) {
|
|
|
2312
4776
|
const { io, out, values } = context;
|
|
2313
4777
|
const orderId = orderIdOf2(rawId);
|
|
2314
4778
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
4779
|
+
const outputId = textOption(values, "output-id");
|
|
4780
|
+
const editId = textOption(values, "edit-id");
|
|
4781
|
+
const sourceId = textOption(values, "source-output-id");
|
|
4782
|
+
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
|
+
if (outputId) return creativeDownload(context, "drama", orderId, `renders/${encodeURIComponent(outputId)}/download`);
|
|
4784
|
+
if (editId || sourceId) return creativeDownload(context, "drama", orderId, `${editId ? "edit" : "history"}/${encodeURIComponent(editId ?? sourceId)}/download`);
|
|
2315
4785
|
const result = await downloadDramaFilm(baseUrl, apiKey, orderId, io);
|
|
2316
4786
|
const defaultName = result.filename ?? `drama-${orderId}.mp4`;
|
|
2317
4787
|
const target = textOption(values, "out") ?? defaultName;
|
|
@@ -2331,6 +4801,7 @@ function errorDocument(error) {
|
|
|
2331
4801
|
if (error.httpStatus !== void 0) document.error.httpStatus = error.httpStatus;
|
|
2332
4802
|
if (error.recovery !== void 0) document.recovery = error.recovery;
|
|
2333
4803
|
if (error.failures !== void 0) document.failures = error.failures;
|
|
4804
|
+
if (error.webRecovery !== void 0) document.webRecovery = error.webRecovery;
|
|
2334
4805
|
return document;
|
|
2335
4806
|
}
|
|
2336
4807
|
function errorLines(error) {
|
|
@@ -2342,15 +4813,23 @@ function errorLines(error) {
|
|
|
2342
4813
|
`\u9519\u8BEF\uFF1A${singleLine(error.message)}`,
|
|
2343
4814
|
`\uFF08${details.join("\uFF1B")}\uFF09`,
|
|
2344
4815
|
...error.hints,
|
|
4816
|
+
...error.webRecovery ? [
|
|
4817
|
+
`\u7F51\u9875\u64CD\u4F5C\uFF1A${singleLine(error.webRecovery.operationId)}\uFF1B\u7ED3\u679C\uFF1A${error.webRecovery.operationOutcome}`,
|
|
4818
|
+
...error.webRecovery.taskId ? [`\u539F\u4EFB\u52A1\uFF1A${singleLine(error.webRecovery.taskId)}`] : [],
|
|
4819
|
+
...error.webRecovery.idempotencyKey ? [`\u539F\u5E42\u7B49\u952E\uFF1A${singleLine(error.webRecovery.idempotencyKey)}\uFF1B\u8BF7\u5148\u67E5\u8BE2\u539F\u64CD\u4F5C\uFF0C\u4E0D\u8981\u6362\u952E\u91CD\u590D\u63D0\u4EA4\u3002`] : [],
|
|
4820
|
+
...error.webRecovery.requestRecord ? [`\u6062\u590D\u8BB0\u5F55\uFF1A${singleLine(error.webRecovery.requestRecord)}`] : []
|
|
4821
|
+
] : [],
|
|
2345
4822
|
...recovery === void 0 ? [] : [
|
|
2346
4823
|
recovery.operation === "confirm" ? `${recovery.acceptance === "confirmed" ? "\u539F\u8BA2\u5355" : "\u76EE\u6807\u8BA2\u5355"}\uFF1A${singleLine(recovery.taskId ?? "")}` : recovery.acceptance === "confirmed" ? `\u5DF2\u53D7\u7406\u4EFB\u52A1\uFF1A${singleLine(recovery.taskId ?? "")}` : "\u63D0\u4EA4\u7ED3\u679C\u5C1A\u672A\u786E\u8BA4\uFF0C\u8BF7\u5148\u5728 Studio \u6838\u5BF9\u539F\u8BF7\u6C42\uFF1B\u4E0D\u8981\u91CD\u65B0\u4E0B\u5355",
|
|
2347
4824
|
...recovery.operation !== "confirm" ? [] : [
|
|
2348
|
-
recovery.operationOutcome === "not_submitted" ? "\u672C\u6B21\u786E\u8BA4\u5C1A\u672A\u63D0\u4EA4\uFF1B\u8BF7\u5148\u67E5\u8BE2\u8BA2\u5355\u72B6\u6001\u5E76\u5904\u7406\u9519\u8BEF\u3002" : recovery.operationOutcome === "rejected" ? "\u672C\u6B21\u786E\u8BA4\u5DF2\u88AB\u62D2\u7EDD\uFF0C\u672A\u53D7\u7406\uFF1B\u8BF7\u5904\u7406\u9519\u8BEF\u540E\u67E5\u8BE2\u539F\u8BA2\u5355\u3002" : "\u672C\u6B21\u786E\u8BA4\u7ED3\u679C\u672A\u77E5\uFF1B\u8BF7\u5148\u67E5\u8BE2\u539F\u8BA2\u5355\uFF0C\u4E0D\u8981\u91CD\u590D\u63D0\u4EA4\u786E\u8BA4\u3002"
|
|
4825
|
+
recovery.operationOutcome === "not_submitted" ? "\u672C\u6B21\u786E\u8BA4\u5C1A\u672A\u63D0\u4EA4\uFF1B\u8BF7\u5148\u67E5\u8BE2\u8BA2\u5355\u72B6\u6001\u5E76\u5904\u7406\u9519\u8BEF\u3002" : recovery.operationOutcome === "rejected" ? "\u672C\u6B21\u786E\u8BA4\u5DF2\u88AB\u62D2\u7EDD\uFF0C\u672A\u53D7\u7406\uFF1B\u8BF7\u5904\u7406\u9519\u8BEF\u540E\u67E5\u8BE2\u539F\u8BA2\u5355\u3002" : recovery.operationOutcome === "accepted" ? "\u672C\u6B21\u786E\u8BA4\u5DF2\u53D7\u7406\uFF1B\u540E\u7EED\u7B49\u5F85\u6216\u67E5\u8BE2\u672A\u5B8C\u6210\uFF0C\u8BF7\u7EE7\u7EED\u67E5\u8BE2\u539F\u4EFB\u52A1\uFF0C\u4E0D\u8981\u91CD\u65B0\u63D0\u4EA4\u751F\u6210\u3002" : "\u672C\u6B21\u786E\u8BA4\u7ED3\u679C\u672A\u77E5\uFF1B\u8BF7\u5148\u67E5\u8BE2\u539F\u8BA2\u5355\uFF0C\u4E0D\u8981\u91CD\u590D\u63D0\u4EA4\u786E\u8BA4\u3002"
|
|
2349
4826
|
],
|
|
2350
4827
|
...recovery.baseUrl === void 0 ? [] : [`\u670D\u52A1\u5730\u5740\uFF1A${singleLine(recovery.baseUrl)}`],
|
|
2351
4828
|
...recovery.status === void 0 ? [] : [`\u6700\u540E\u72B6\u6001\uFF1A${singleLine(recovery.status)}`],
|
|
2352
4829
|
...recovery.failureCode === void 0 ? [] : [`\u4EFB\u52A1\u5931\u8D25\u7801\uFF1A${singleLine(recovery.failureCode)}`],
|
|
2353
4830
|
...recovery.idempotencyKey === void 0 ? [] : [`\u5E42\u7B49\u952E\uFF1A${singleLine(recovery.idempotencyKey)}`],
|
|
4831
|
+
...recovery.confirmation === void 0 ? [] : [`\u539F\u786E\u8BA4\u7C7B\u578B\uFF1A${singleLine(recovery.confirmation.kind)}`, `\u539F\u786E\u8BA4\u7F16\u53F7\uFF1A${singleLine(recovery.confirmation.confirmationId)}`],
|
|
4832
|
+
...recovery.videoConfirmation === void 0 ? [] : [`\u539F\u786E\u8BA4\u8BF7\u6C42\uFF08\u4FDD\u5B58\u4E3A JSON\uFF0C\u7528 --data \u4E0E\u539F --idempotency-key \u6062\u590D\uFF09\uFF1A${JSON.stringify(recovery.videoConfirmation)}`],
|
|
2354
4833
|
...recovery.statusCommand === void 0 ? [] : [`${recovery.operation === "confirm" ? "\u67E5\u8BE2\u8BA2\u5355\u72B6\u6001" : "\u53EA\u67E5\u8BE2\u539F\u4EFB\u52A1"}\uFF1A${singleLine(recovery.statusCommand)}`]
|
|
2355
4834
|
]
|
|
2356
4835
|
];
|
|
@@ -2370,9 +4849,9 @@ function createOutput(streams, json) {
|
|
|
2370
4849
|
protect(secret) {
|
|
2371
4850
|
secrets.push(secret);
|
|
2372
4851
|
},
|
|
2373
|
-
result(
|
|
4852
|
+
result(lines2, data, keep = []) {
|
|
2374
4853
|
if (!json) {
|
|
2375
|
-
toStdout(`${
|
|
4854
|
+
toStdout(`${lines2.join("\n")}
|
|
2376
4855
|
`, keep);
|
|
2377
4856
|
return;
|
|
2378
4857
|
}
|
|
@@ -2479,6 +4958,7 @@ async function products(context) {
|
|
|
2479
4958
|
if (subcommand === void 0) {
|
|
2480
4959
|
throw usageError("products \u8981\u8DDF\u4E00\u4E2A\u5B50\u547D\u4EE4\uFF1Acreate\u3001set-images \u6216 confirm-lock");
|
|
2481
4960
|
}
|
|
4961
|
+
if (["list", "search", "show", "update", "archive", "restore"].includes(subcommand)) return manageProducts(context);
|
|
2482
4962
|
if (subcommand === "create") return create2(context, values);
|
|
2483
4963
|
if (subcommand === "set-images") return setImages(context, values, args[1]);
|
|
2484
4964
|
if (subcommand === "confirm-lock") return confirmLock(context, values, args[1]);
|
|
@@ -2492,14 +4972,16 @@ function productIdOf(raw, what) {
|
|
|
2492
4972
|
}
|
|
2493
4973
|
async function create2(context, values) {
|
|
2494
4974
|
const { io, out } = context;
|
|
2495
|
-
const
|
|
4975
|
+
const data = textOption(values, "data") ? await readPropsArgument(io, textOption(values, "data"), "\u4EA7\u54C1\u8D44\u6599") : {};
|
|
4976
|
+
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
|
+
const name2 = textOption(values, "name") ?? (typeof data.name === "string" ? data.name : void 0);
|
|
2496
4978
|
if (name2 === void 0) {
|
|
2497
4979
|
throw usageError("\u8981\u7ED9 --name <\u540D\u79F0>");
|
|
2498
4980
|
}
|
|
2499
|
-
const category = textOption(values, "category");
|
|
4981
|
+
const category = textOption(values, "category") ?? (typeof data.category === "string" ? data.category : void 0);
|
|
2500
4982
|
const idempotencyKey = idempotencyKeyOf(values);
|
|
2501
4983
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2502
|
-
const { view, raw, replayed } = await createProduct(baseUrl, apiKey, name2, category, idempotencyKey, io);
|
|
4984
|
+
const { view, raw, replayed } = await createProduct(baseUrl, apiKey, name2, category, idempotencyKey, io, { ...data, ...textOption(values, "sku") ? { sku: textOption(values, "sku") } : {}, ...textOption(values, "classification-hint") ? { classificationHint: textOption(values, "classification-hint") } : {} });
|
|
2503
4985
|
out.result(
|
|
2504
4986
|
[
|
|
2505
4987
|
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)}`,
|
|
@@ -2587,15 +5069,135 @@ async function confirmLock(context, values, rawId) {
|
|
|
2587
5069
|
{ productLock: raw.productLock, product: raw.product, idempotencyKey }
|
|
2588
5070
|
);
|
|
2589
5071
|
}
|
|
5072
|
+
async function manageProducts(context) {
|
|
5073
|
+
const [action2, id] = context.args;
|
|
5074
|
+
const listing = action2 === "list" || action2 === "search";
|
|
5075
|
+
if (!listing && !id) throw usageError("\u8BF7\u63D0\u4F9B\u4EA7\u54C1\u7F16\u53F7");
|
|
5076
|
+
const name2 = textOption(context.values, "name");
|
|
5077
|
+
if (action2 === "update" && !name2) throw usageError("\u8BF7\u63D0\u4F9B --name <\u540D\u79F0>\uFF1B\u56FE\u7247\u548C\u5916\u89C2\u9501\u4F7F\u7528 set-images\u3001confirm-lock");
|
|
5078
|
+
const path = listing ? `/api/open/v1/products${catalogQuery(context.values, ["q", "archived", "limit", "offset"])}` : `/api/open/v1/products/${encodeURIComponent(id)}`;
|
|
5079
|
+
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
5080
|
+
const key = listing || action2 === "show" ? void 0 : idempotencyKeyOf(context.values);
|
|
5081
|
+
const result = 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);
|
|
5082
|
+
const items = Array.isArray(result.products) ? result.products : [result.product];
|
|
5083
|
+
context.out.result(items.filter(Boolean).map((item) => {
|
|
5084
|
+
const r = item;
|
|
5085
|
+
return `${singleLine(String(r.id))} ${singleLine(String(r.name))} ${singleLine(String(r.category))}`;
|
|
5086
|
+
}), { ...result, ...key ? { idempotencyKey: key } : {} });
|
|
5087
|
+
}
|
|
5088
|
+
|
|
5089
|
+
// src/commands/video-music.ts
|
|
5090
|
+
function object2(value) {
|
|
5091
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new CliError({ code: "CLI_BAD_RESPONSE", exitCode: EXIT.SERVER, message: "\u670D\u52A1\u7AEF\u672A\u8FD4\u56DE\u6709\u6548\u7684\u914D\u4E50\u7ED3\u679C" });
|
|
5092
|
+
return value;
|
|
5093
|
+
}
|
|
5094
|
+
var fields2 = /* @__PURE__ */ new Set(["quote", "quoteHash", "credits", "currency", "brief", "purpose", "title", "style", "instrumental", "lyrics", "vocalGender", "durationSeconds", "followVideo", "placement", "startSeconds", "maxMusicSeconds", "musicOffsetSeconds", "originalAudioVolume", "duckedAudioVolume", "narration", "base", "kind", "taskId", "productionId", "filmDurationSeconds", "sufficient", "availability", "available", "reason", "videoCredits", "songLength", "tasks", "task", "id", "status", "source", "queued", "chargedCredits", "createdAt", "tracks", "index", "applied", "trackIndex", "editId", "withNarration", "inDelivery", "position", "appliedForEarlierFilm", "composeRetryable", "failure", "edit", "label", "reused"]);
|
|
5095
|
+
function safe(value) {
|
|
5096
|
+
if (value === null || ["string", "number", "boolean"].includes(typeof value)) return value;
|
|
5097
|
+
if (Array.isArray(value)) return value.map(safe);
|
|
5098
|
+
if (!value || typeof value !== "object") return void 0;
|
|
5099
|
+
return Object.fromEntries(Object.entries(value).filter(([key]) => fields2.has(key)).map(([key, item]) => [key, safe(item)]));
|
|
5100
|
+
}
|
|
5101
|
+
function task(value) {
|
|
5102
|
+
const result = object2(safe(value));
|
|
5103
|
+
if (typeof result.id !== "string" || !["pending", "running", "succeeded", "failed"].includes(String(result.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" });
|
|
5104
|
+
return result;
|
|
5105
|
+
}
|
|
5106
|
+
async function videoMusic(context) {
|
|
5107
|
+
const { args, values, out, io } = context;
|
|
5108
|
+
const timeoutSeconds = timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3);
|
|
5109
|
+
const command = args[0];
|
|
5110
|
+
const id = args[1]?.trim();
|
|
5111
|
+
if (!id) throw usageError("\u8BF7\u63D0\u4F9B\u5546\u54C1\u89C6\u9891\u4EFB\u52A1 ID");
|
|
5112
|
+
for (const option of ["expected-version", "expected-credits"]) {
|
|
5113
|
+
if (values[option] !== void 0) throw usageError(`videos ${command} \u4E0D\u652F\u6301 --${option}\uFF1B\u914D\u4E50\u751F\u6210\u8BF7\u4F7F\u7528\u5DF2\u67E5\u770B\u7684 --quote-hash \u7ED1\u5B9A\u62A5\u4EF7`);
|
|
5114
|
+
}
|
|
5115
|
+
const expectedQuoteHash = textOption(values, "quote-hash")?.toLowerCase();
|
|
5116
|
+
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
|
+
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(io, textOption(values, "props"), "\u914D\u4E50\u8BF7\u6C42") : {};
|
|
5119
|
+
const key = idempotencyKeyOf(values);
|
|
5120
|
+
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
5121
|
+
const path = `/api/open/v1/videos/${encodeURIComponent(id)}/music`;
|
|
5122
|
+
let submitted = false;
|
|
5123
|
+
let accepted = false;
|
|
5124
|
+
let latestTask;
|
|
5125
|
+
try {
|
|
5126
|
+
if (command === "music-list") {
|
|
5127
|
+
const data = object2(safe((await getJson(baseUrl, apiKey, path, io)).body));
|
|
5128
|
+
const tasks = Array.isArray(data.tasks) ? data.tasks.map(task) : [];
|
|
5129
|
+
out.result(tasks.map((item) => `${singleLine(item.id)} ${singleLine(item.status)} ${singleLine(String(item.title ?? ""))}`), { ...data, tasks });
|
|
5130
|
+
return;
|
|
5131
|
+
}
|
|
5132
|
+
if (command === "music-apply") {
|
|
5133
|
+
const taskId = textOption(values, "music-task-id");
|
|
5134
|
+
if (!taskId) throw usageError("\u8BF7\u63D0\u4F9B --music-task-id <\u914D\u4E50\u4EFB\u52A1ID>");
|
|
5135
|
+
const timeoutMs = values.timeout === void 0 ? 3e5 : timeoutSeconds * 1e3;
|
|
5136
|
+
const data = object2(safe((await postJson(baseUrl, apiKey, `${path}/${encodeURIComponent(taskId)}/apply`, request, key, io, { timeoutMs })).body));
|
|
5137
|
+
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
|
+
return;
|
|
5139
|
+
}
|
|
5140
|
+
const quote3 = object2(object2(safe((await postJson(baseUrl, apiKey, `${path}/quote`, request, key, io)).body)).quote);
|
|
5141
|
+
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
|
+
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
|
+
if (command === "music-quote" || values.yes !== true) {
|
|
5144
|
+
out.result([
|
|
5145
|
+
`\u914D\u4E50\u62A5\u4EF7\uFF1A${quote3.credits} \u5E03`,
|
|
5146
|
+
`\u62A5\u4EF7\u54C8\u5E0C\uFF1A${quote3.quoteHash}`,
|
|
5147
|
+
`\u786E\u8BA4\u540E\u4F7F\u7528 buke videos music-compose ${id} --props <\u539F\u914D\u4E50\u8BF7\u6C42\u6587\u4EF6> --quote-hash ${quote3.quoteHash} --yes \u63D0\u4EA4\u751F\u6210\u3002`
|
|
5148
|
+
], { quote: quote3, submitted: false });
|
|
5149
|
+
return;
|
|
5150
|
+
}
|
|
5151
|
+
submitted = true;
|
|
5152
|
+
latestTask = task(object2((await postJson(baseUrl, apiKey, path, { ...request, confirmed: true, quoteHash: quote3.quoteHash }, key, io)).body).task);
|
|
5153
|
+
accepted = true;
|
|
5154
|
+
if (values.wait === true) {
|
|
5155
|
+
const now = io.now ?? (() => /* @__PURE__ */ new Date());
|
|
5156
|
+
const until = now().getTime() + timeoutSeconds * 1e3;
|
|
5157
|
+
while (["pending", "running"].includes(latestTask.status)) {
|
|
5158
|
+
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(io, Math.min(1500, Math.max(until - now().getTime(), 1)));
|
|
5160
|
+
if (now().getTime() >= until) continue;
|
|
5161
|
+
const data = object2((await getJson(baseUrl, apiKey, path, io)).body);
|
|
5162
|
+
const found = Array.isArray(data.tasks) ? data.tasks.find((item) => item && typeof item === "object" && item.id === latestTask.id) : null;
|
|
5163
|
+
latestTask = task(found);
|
|
5164
|
+
}
|
|
5165
|
+
if (latestTask.status === "failed") throw new CliError({ code: "CLI_TASK_FAILED", exitCode: EXIT.TASK_FAILED, message: "\u672C\u6B21\u914D\u4E50\u672A\u5B8C\u6210\uFF0C\u8BF7\u67E5\u8BE2\u539F\u4EFB\u52A1\u53CA\u8D39\u7528\u72B6\u6001" });
|
|
5166
|
+
}
|
|
5167
|
+
out.result([`\u914D\u4E50\u4EFB\u52A1\uFF1A${singleLine(latestTask.id)}`, `\u72B6\u6001\uFF1A${singleLine(latestTask.status)}`, `\u5E42\u7B49\u952E\uFF1A${key}`, `\u67E5\u8BE2\uFF1Abuke videos music-list ${id}`], { task: latestTask, idempotencyKey: key });
|
|
5168
|
+
} catch (error) {
|
|
5169
|
+
const failure = toCliError(error);
|
|
5170
|
+
if (command === "music-apply") throw failure.withRecovery({
|
|
5171
|
+
...taskRecovery("videos", id, void 0, baseUrl),
|
|
5172
|
+
acceptance: "unknown",
|
|
5173
|
+
idempotencyKey: key,
|
|
5174
|
+
statusCommand: taskRecovery("videos", id, void 0, baseUrl).statusCommand.replace(" videos status ", " videos music-list ")
|
|
5175
|
+
});
|
|
5176
|
+
if (command !== "music-compose") throw failure;
|
|
5177
|
+
const rejected = failure.httpStatus !== void 0 && failure.httpStatus >= 400 && failure.httpStatus < 500 && failure.httpStatus !== 408;
|
|
5178
|
+
throw failure.withRecovery({
|
|
5179
|
+
...taskRecovery("videos", id, latestTask?.status, baseUrl),
|
|
5180
|
+
acceptance: latestTask ? "confirmed" : "unknown",
|
|
5181
|
+
idempotencyKey: key,
|
|
5182
|
+
operation: "confirm",
|
|
5183
|
+
operationOutcome: accepted ? "accepted" : !submitted ? "not_submitted" : rejected ? "rejected" : "unknown",
|
|
5184
|
+
statusCommand: taskRecovery("videos", id, latestTask?.status, baseUrl).statusCommand.replace(" videos status ", " videos music-list ")
|
|
5185
|
+
});
|
|
5186
|
+
}
|
|
5187
|
+
}
|
|
2590
5188
|
|
|
2591
5189
|
// src/commands/videos.ts
|
|
2592
|
-
var SUBCOMMANDS3 = "create\u3001status\u3001message\u3001confirm
|
|
5190
|
+
var SUBCOMMANDS3 = "create\u3001status\u3001message\u3001confirm\u3001versions\u3001cancel\u3001download\u3001music-quote\u3001music-compose\u3001music-list\u3001music-apply";
|
|
2593
5191
|
async function videos(context) {
|
|
5192
|
+
timeoutSecondsOf(context.values, DEFAULT_WAIT_TIMEOUT_MS / 1e3);
|
|
2594
5193
|
const { args } = context;
|
|
2595
5194
|
const [subcommand] = args;
|
|
2596
5195
|
if (subcommand === void 0) {
|
|
2597
5196
|
throw usageError(`videos \u8981\u8DDF\u4E00\u4E2A\u5B50\u547D\u4EE4\uFF1A${SUBCOMMANDS3}`);
|
|
2598
5197
|
}
|
|
5198
|
+
if (["music-quote", "music-compose", "music-list", "music-apply"].includes(subcommand)) return videoMusic(context);
|
|
5199
|
+
if (subcommand === "versions" || subcommand === "cancel") return manage(context);
|
|
5200
|
+
if (["attachments", "upload", "attachment-download"].includes(subcommand)) return creativeAttachments(context, "videos");
|
|
2599
5201
|
if (subcommand === "create") return create3(context);
|
|
2600
5202
|
if (subcommand === "status") return status3(context, args[1]);
|
|
2601
5203
|
if (subcommand === "message") return message(context, args[1]);
|
|
@@ -2613,7 +5215,7 @@ function waitControls3(io, values) {
|
|
|
2613
5215
|
return {
|
|
2614
5216
|
timeoutMs: timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3) * 1e3,
|
|
2615
5217
|
now: io.now ?? (() => /* @__PURE__ */ new Date()),
|
|
2616
|
-
sleep:
|
|
5218
|
+
sleep: (ms) => sleepFor(io, ms)
|
|
2617
5219
|
};
|
|
2618
5220
|
}
|
|
2619
5221
|
function settleRun(outcome, baseUrl) {
|
|
@@ -2654,7 +5256,8 @@ function waitingLines(run2) {
|
|
|
2654
5256
|
}
|
|
2655
5257
|
async function create3(context) {
|
|
2656
5258
|
const { io, out, values } = context;
|
|
2657
|
-
const
|
|
5259
|
+
const data = await creativeData(context);
|
|
5260
|
+
const productId = textOption(values, "product") ?? (typeof data.productId === "string" ? data.productId : void 0);
|
|
2658
5261
|
if (productId === void 0) {
|
|
2659
5262
|
throw usageError("\u8981\u7ED9 --product <\u4EA7\u54C1id>\uFF08buke products create \u56DE\u7684\u90A3\u4E2A\uFF09");
|
|
2660
5263
|
}
|
|
@@ -2685,9 +5288,10 @@ async function create3(context) {
|
|
|
2685
5288
|
baseUrl,
|
|
2686
5289
|
apiKey,
|
|
2687
5290
|
{
|
|
5291
|
+
...data,
|
|
2688
5292
|
productId,
|
|
2689
5293
|
...intent === void 0 ? {} : { intent },
|
|
2690
|
-
...Object.keys(preferences).length > 0 ? { preferences } : {}
|
|
5294
|
+
...Object.keys(preferences).length > 0 ? { preferences: { ...data.preferences && typeof data.preferences === "object" ? data.preferences : {}, ...preferences } } : {}
|
|
2691
5295
|
},
|
|
2692
5296
|
idempotencyKey,
|
|
2693
5297
|
io
|
|
@@ -2702,6 +5306,9 @@ async function create3(context) {
|
|
|
2702
5306
|
{ run: raw.run, idempotencyKey }
|
|
2703
5307
|
);
|
|
2704
5308
|
}
|
|
5309
|
+
function latestDirectorLine(messages) {
|
|
5310
|
+
return [...messages].reverse().find((message2) => message2.role === "assistant" && !message2.earlierAttemptOf && message2.text.trim() !== "");
|
|
5311
|
+
}
|
|
2705
5312
|
async function status3(context, rawId) {
|
|
2706
5313
|
const { io, out, values } = context;
|
|
2707
5314
|
const runId = runIdOf(rawId);
|
|
@@ -2710,7 +5317,7 @@ async function status3(context, rawId) {
|
|
|
2710
5317
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2711
5318
|
const current = await getVideoRun(baseUrl, apiKey, runId, io);
|
|
2712
5319
|
const final = shouldWait ? settleRun(await awaitVideoRun(baseUrl, apiKey, current, io, controls), baseUrl) : current;
|
|
2713
|
-
const lastDirectorLine =
|
|
5320
|
+
const lastDirectorLine = latestDirectorLine(final.view.messages);
|
|
2714
5321
|
out.result(
|
|
2715
5322
|
[
|
|
2716
5323
|
...runLines(final.view),
|
|
@@ -2724,14 +5331,15 @@ async function status3(context, rawId) {
|
|
|
2724
5331
|
async function message(context, rawId) {
|
|
2725
5332
|
const { io, out, values } = context;
|
|
2726
5333
|
const runId = runIdOf(rawId);
|
|
2727
|
-
const
|
|
5334
|
+
const data = await creativeData(context);
|
|
5335
|
+
const text = textOption(values, "text") ?? (typeof data.text === "string" ? data.text : void 0);
|
|
2728
5336
|
if (text === void 0) {
|
|
2729
5337
|
throw usageError("\u8981\u7ED9 --text <\u5185\u5BB9>\uFF1A\u60F3\u5BF9\u5BFC\u6F14\u8BF4\u7684\u90A3\u53E5\u8BDD");
|
|
2730
5338
|
}
|
|
2731
5339
|
const idempotencyKey = idempotencyKeyOf(values);
|
|
2732
5340
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2733
|
-
const { view, raw } = await
|
|
2734
|
-
const lastDirectorLine =
|
|
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, io)));
|
|
5342
|
+
const lastDirectorLine = latestDirectorLine(view.messages);
|
|
2735
5343
|
out.result(
|
|
2736
5344
|
[
|
|
2737
5345
|
...runLines(view),
|
|
@@ -2745,10 +5353,39 @@ async function message(context, rawId) {
|
|
|
2745
5353
|
async function confirm2(context, rawId) {
|
|
2746
5354
|
const { io, out, values } = context;
|
|
2747
5355
|
const runId = runIdOf(rawId);
|
|
5356
|
+
const data = await creativeData(context);
|
|
5357
|
+
const originalKey = textOption(values, "idempotency-key");
|
|
5358
|
+
if (textOption(values, "data")) {
|
|
5359
|
+
if (!originalKey) throw usageError("\u6062\u590D\u539F\u786E\u8BA4\u5FC5\u987B\u63D0\u4F9B\u539F --idempotency-key");
|
|
5360
|
+
if (!Number.isInteger(data.expectedVersion) || Number(data.expectedVersion) < 0 || !data.confirmation || typeof data.confirmation !== "object" || Array.isArray(data.confirmation)) {
|
|
5361
|
+
throw usageError("--data \u5FC5\u987B\u5305\u542B\u539F\u786E\u8BA4\u7684 expectedVersion \u4E0E confirmation");
|
|
5362
|
+
}
|
|
5363
|
+
if (values.yes !== true) throw usageError("\u6062\u590D\u539F\u786E\u8BA4\u8BF7\u6838\u5BF9\u539F\u8BF7\u6C42\uFF0C\u5E76\u6DFB\u52A0 --yes");
|
|
5364
|
+
const { apiKey: apiKey2, baseUrl: baseUrl2 } = await resolveApiKey(context);
|
|
5365
|
+
const outcome2 = await confirmVideoProduction(baseUrl2, apiKey2, runId, Number(data.expectedVersion), data.confirmation, originalKey, io);
|
|
5366
|
+
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 }
|
|
5369
|
+
);
|
|
5370
|
+
return;
|
|
5371
|
+
}
|
|
5372
|
+
const expectedVersionRaw = textOption(values, "expected-version");
|
|
5373
|
+
const expectedCreditsRaw = textOption(values, "expected-credits");
|
|
5374
|
+
const expectedVersion = expectedVersionRaw === void 0 ? void 0 : Number(expectedVersionRaw);
|
|
5375
|
+
const expectedCredits = expectedCreditsRaw === void 0 ? void 0 : Number(expectedCreditsRaw);
|
|
5376
|
+
if (values["expected-version"] !== void 0 && (expectedVersion === void 0 || !Number.isSafeInteger(expectedVersion) || expectedVersion < 0)) {
|
|
5377
|
+
throw usageError("--expected-version \u5FC5\u987B\u662F\u4E4B\u524D\u67E5\u770B\u7684\u975E\u8D1F\u6574\u6570\u7248\u672C\u53F7");
|
|
5378
|
+
}
|
|
5379
|
+
if (values["expected-credits"] !== void 0 && (expectedCredits === void 0 || !Number.isFinite(expectedCredits) || expectedCredits < 0)) {
|
|
5380
|
+
throw usageError("--expected-credits \u5FC5\u987B\u662F\u4E4B\u524D\u67E5\u770B\u7684\u975E\u8D1F\u6709\u9650\u91D1\u989D");
|
|
5381
|
+
}
|
|
5382
|
+
if (values.yes === true && (expectedVersion === void 0 || expectedCredits === void 0)) {
|
|
5383
|
+
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
|
+
}
|
|
2748
5385
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2749
5386
|
const fetched = await getVideoRun(baseUrl, apiKey, runId, io);
|
|
2750
5387
|
const run2 = fetched.view;
|
|
2751
|
-
const card = run2.nextActions.find((
|
|
5388
|
+
const card = run2.nextActions.find((action2) => action2.type === "confirm_production");
|
|
2752
5389
|
if (card === void 0) {
|
|
2753
5390
|
throw new CliError({
|
|
2754
5391
|
code: "CLI_USAGE",
|
|
@@ -2756,25 +5393,48 @@ async function confirm2(context, rawId) {
|
|
|
2756
5393
|
message: `\u73B0\u5728\u6CA1\u6709\u7B49\u7740\u786E\u8BA4\u7684\u5361\uFF08\u5F53\u524D\u72B6\u6001\uFF1A${run2.status}\uFF09\u3002\u5BFC\u6F14\u505C\u4E0B\u6765\u8981\u786E\u8BA4\u65F6\u518D\u8FD0\u884C\u8FD9\u6761\u547D\u4EE4`
|
|
2757
5394
|
});
|
|
2758
5395
|
}
|
|
2759
|
-
if (card.confirmation
|
|
5396
|
+
if (!card.confirmation || typeof card.confirmation !== "object" || Array.isArray(card.confirmation)) {
|
|
2760
5397
|
throw new CliError({
|
|
2761
5398
|
code: "CLI_USAGE",
|
|
2762
5399
|
exitCode: EXIT.USAGE,
|
|
2763
5400
|
message: "\u670D\u52A1\u7AEF\u6302\u51FA\u7684\u8FD9\u5F20\u5361\u4E0D\u5E26\u786E\u8BA4\u8EAB\u4EFD\uFF0C\u786E\u8BA4\u4E0D\u4E86\uFF1B\u7A0D\u540E\u91CD\u65B0\u8FD0\u884C buke videos status \u770B\u6700\u65B0\u72B6\u6001"
|
|
2764
5401
|
});
|
|
2765
5402
|
}
|
|
2766
|
-
const credits = card.credits
|
|
5403
|
+
const credits = card.credits;
|
|
5404
|
+
if (!Number.isSafeInteger(run2.version) || run2.version < 0 || typeof credits !== "number" || !Number.isFinite(credits) || credits < 0 || "credits" in card.confirmation && card.confirmation.credits !== credits) {
|
|
5405
|
+
throw new CliError({
|
|
5406
|
+
code: "CLI_BAD_RESPONSE",
|
|
5407
|
+
exitCode: EXIT.SERVER,
|
|
5408
|
+
message: "\u786E\u8BA4\u5361\u7248\u672C\u6216\u91D1\u989D\u65E0\u6548\uFF0C\u6216\u786E\u8BA4\u8EAB\u4EFD\u5185\u7684\u91D1\u989D\u4E0D\u4E00\u81F4\uFF1B\u672C\u6B21\u672A\u63D0\u4EA4\uFF0C\u8BF7\u91CD\u65B0\u67E5\u8BE2\u5F53\u524D\u786E\u8BA4\u5361"
|
|
5409
|
+
});
|
|
5410
|
+
}
|
|
5411
|
+
if (expectedVersion !== void 0 && expectedVersion !== run2.version || expectedCredits !== void 0 && expectedCredits !== credits) {
|
|
5412
|
+
throw new CliError({
|
|
5413
|
+
code: "OPEN_API_QUOTE_CHANGED",
|
|
5414
|
+
exitCode: EXIT.QUOTE_CHANGED,
|
|
5415
|
+
message: "\u786E\u8BA4\u5361\u7248\u672C\u6216\u91D1\u989D\u5DF2\u53D8\u5316\uFF0C\u672C\u6B21\u672A\u63D0\u4EA4\uFF1B\u8BF7\u91CD\u65B0\u67E5\u770B\u540E\u660E\u786E\u786E\u8BA4"
|
|
5416
|
+
});
|
|
5417
|
+
}
|
|
2767
5418
|
const kind = card.confirmKind === void 0 ? "\u786E\u8BA4" : `\u786E\u8BA4\uFF08${card.confirmKind}\uFF09`;
|
|
2768
5419
|
if (values.yes !== true) {
|
|
2769
5420
|
throw new CliError({
|
|
2770
5421
|
code: "CLI_USAGE",
|
|
2771
5422
|
exitCode: EXIT.USAGE,
|
|
2772
5423
|
message: `\u8FD9\u5F20\u5361\u8981\u82B1 ${credits} \u5E03\u3002\u52A0 --yes \u786E\u8BA4\u8FD9\u7B14\u5E03\u652F\u51FA`,
|
|
2773
|
-
hints: [
|
|
5424
|
+
hints: [
|
|
5425
|
+
`${kind}\uFF1A${singleLine(run2.label)}`,
|
|
5426
|
+
`\u770B\u8FC7\u518D\u786E\u8BA4\uFF1Abuke videos confirm ${run2.rootRunId} --expected-version ${run2.version} --expected-credits ${credits} --yes`
|
|
5427
|
+
]
|
|
2774
5428
|
});
|
|
2775
5429
|
}
|
|
2776
5430
|
const idempotencyKey = idempotencyKeyOf(values);
|
|
2777
|
-
|
|
5431
|
+
let outcome;
|
|
5432
|
+
try {
|
|
5433
|
+
outcome = await confirmVideoProduction(baseUrl, apiKey, runId, run2.version, card.confirmation, idempotencyKey, io);
|
|
5434
|
+
} catch (error) {
|
|
5435
|
+
const failure = toCliError(error);
|
|
5436
|
+
throw failure.withRecovery({ ...taskRecovery("videos", runId, run2.status, baseUrl), ...failure.recovery, acceptance: "confirmed" });
|
|
5437
|
+
}
|
|
2778
5438
|
out.result(
|
|
2779
5439
|
[...runLines(outcome.view), `\u5DF2\u786E\u8BA4\uFF1A\u8FD9\u7B14\u6700\u591A ${credits} \u5E03`, ...waitingLines(outcome.view), `\u5E42\u7B49\u952E\uFF1A${idempotencyKey}`],
|
|
2780
5440
|
{ run: outcome.raw.run, confirmed: { credits, confirmKind: card.confirmKind ?? null }, idempotencyKey }
|
|
@@ -2784,6 +5444,25 @@ async function download3(context, rawId) {
|
|
|
2784
5444
|
const { io, out, values } = context;
|
|
2785
5445
|
const runId = runIdOf(rawId);
|
|
2786
5446
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
5447
|
+
const musicTask = textOption(values, "music-task-id");
|
|
5448
|
+
const narrationEdit = textOption(values, "narration-edit-id");
|
|
5449
|
+
const appendTask = textOption(values, "append-task-id");
|
|
5450
|
+
const selectedCount = [musicTask, narrationEdit, appendTask, textOption(values, "production-id"), textOption(values, "edit-id")].filter(Boolean).length;
|
|
5451
|
+
if (selectedCount > 1) throw usageError("\u6BCF\u6B21\u4E0B\u8F7D\u53EA\u80FD\u9009\u62E9\u4E00\u79CD\u5236\u4F5C\u7248\u672C\u6216\u97F3\u8F68");
|
|
5452
|
+
if (appendTask) return creativeDownload(context, "videos", runId, `append-tasks/${encodeURIComponent(appendTask)}/download`);
|
|
5453
|
+
if (musicTask || narrationEdit) {
|
|
5454
|
+
const index = Number(textOption(values, "track-index"));
|
|
5455
|
+
if (musicTask && (!Number.isInteger(index) || index < 0 || index > 99)) throw usageError("\u914D\u4E50\u4E0B\u8F7D\u987B\u63D0\u4F9B\u6709\u6548 --track-index");
|
|
5456
|
+
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}`, io, { allowedMimeTypes: ["audio/wav", "audio/mpeg"], requireSha256: true });
|
|
5458
|
+
const saved2 = await saveDownload(textOption(values, "out") ?? media.filename ?? `audio-${runId}.wav`, media.bytes);
|
|
5459
|
+
out.result([`\u5DF2\u4E0B\u8F7D\uFF1A${saved2.path}`, `\u6821\u9A8C\uFF1Asha256 ${saved2.sha256}`], { download: saved2 });
|
|
5460
|
+
return;
|
|
5461
|
+
}
|
|
5462
|
+
const productionId = textOption(values, "production-id");
|
|
5463
|
+
const editId = textOption(values, "edit-id");
|
|
5464
|
+
if (productionId && editId) throw usageError("--production-id \u4E0E --edit-id \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528");
|
|
5465
|
+
if (productionId || editId) return creativeDownload(context, "videos", runId, editId ? `edits/${encodeURIComponent(editId)}/download` : `download?productionId=${encodeURIComponent(productionId)}`);
|
|
2787
5466
|
const result = await downloadVideo(baseUrl, apiKey, runId, io);
|
|
2788
5467
|
const defaultName = result.filename ?? `video-${runId}.mp4`;
|
|
2789
5468
|
const target = textOption(values, "out") ?? defaultName;
|
|
@@ -2793,6 +5472,18 @@ async function download3(context, rawId) {
|
|
|
2793
5472
|
{ download: { ...saved, filename: defaultName } }
|
|
2794
5473
|
);
|
|
2795
5474
|
}
|
|
5475
|
+
async function manage(context) {
|
|
5476
|
+
const id = runIdOf(context.args[1]);
|
|
5477
|
+
const { baseUrl, apiKey } = await resolveApiKey(context);
|
|
5478
|
+
if (context.args[0] === "versions") {
|
|
5479
|
+
const result2 = await getCreative(baseUrl, apiKey, "videos", id, "versions", context.io);
|
|
5480
|
+
context.out.result([JSON.stringify(result2, null, 2)], result2);
|
|
5481
|
+
return;
|
|
5482
|
+
}
|
|
5483
|
+
const key = idempotencyKeyOf(context.values);
|
|
5484
|
+
const result = await postCreative(baseUrl, apiKey, "videos", id, "cancel", {}, key, context.io);
|
|
5485
|
+
context.out.result(["\u53D6\u6D88\u8BF7\u6C42\u5DF2\u5904\u7406", `\u5E42\u7B49\u952E\uFF1A${key}`], { ...result, idempotencyKey: key });
|
|
5486
|
+
}
|
|
2796
5487
|
|
|
2797
5488
|
// src/commands/whoami.ts
|
|
2798
5489
|
async function whoami(context) {
|
|
@@ -2827,6 +5518,8 @@ var KEY_HOWTO = [
|
|
|
2827
5518
|
" 3. \u5728\u7EC8\u7AEF\u91CC\u76F4\u63A5\u8FD0\u884C buke login\uFF0C\u6309\u63D0\u793A\u7C98\u8D34\uFF08\u8F93\u5165\u4E0D\u4F1A\u663E\u793A\uFF09"
|
|
2828
5519
|
];
|
|
2829
5520
|
var COMMANDS = {
|
|
5521
|
+
web: webCommand,
|
|
5522
|
+
graphic: graphicCommand,
|
|
2830
5523
|
login: {
|
|
2831
5524
|
run: login,
|
|
2832
5525
|
acceptsBaseUrl: true,
|
|
@@ -2842,7 +5535,7 @@ var COMMANDS = {
|
|
|
2842
5535
|
"",
|
|
2843
5536
|
"\u9009\u9879\uFF1A",
|
|
2844
5537
|
` --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF0C\u9ED8\u8BA4 ${DEFAULT_BASE_URL}\uFF1B\u53EA\u5199\u5230\u57DF\u540D\u4E3A\u6B62`,
|
|
2845
|
-
" --json \
|
|
5538
|
+
" --json \u6807\u51C6\u8F93\u51FA\u4EC5\u8FD4\u56DE\u4E00\u4E2A JSON \u6587\u6863\uFF0C\u4F9B\u811A\u672C\u89E3\u6790"
|
|
2846
5539
|
].join("\n")
|
|
2847
5540
|
},
|
|
2848
5541
|
whoami: {
|
|
@@ -2858,8 +5551,8 @@ var COMMANDS = {
|
|
|
2858
5551
|
"\u672C\u673A\u4FDD\u5B58\u7684\u5BC6\u94A5\u53EA\u4F1A\u53D1\u5F80\u767B\u5F55\u65F6\u7684\u90A3\u4E2A\u5730\u5740\u3002",
|
|
2859
5552
|
"",
|
|
2860
5553
|
"\u9009\u9879\uFF1A",
|
|
2861
|
-
" --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF1B\
|
|
2862
|
-
" --json \
|
|
5554
|
+
" --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF1B\u7701\u7565\u65F6\u4F7F\u7528\u767B\u5F55\u65F6\u7684\u5730\u5740",
|
|
5555
|
+
" --json \u6807\u51C6\u8F93\u51FA\u4EC5\u8FD4\u56DE\u4E00\u4E2A JSON \u6587\u6863\uFF0C\u4F9B\u811A\u672C\u89E3\u6790"
|
|
2863
5556
|
].join("\n")
|
|
2864
5557
|
},
|
|
2865
5558
|
logout: {
|
|
@@ -2873,7 +5566,7 @@ var COMMANDS = {
|
|
|
2873
5566
|
"\u5220\u9664\u672C\u673A\u4FDD\u5B58\u7684\u5BC6\u94A5\u3002\u8FD9\u628A\u5BC6\u94A5\u672C\u8EAB\u4ECD\u7136\u5728\u7528\uFF0C\u4E0D\u518D\u4F7F\u7528\u8BF7\u540A\u9500\u5B83\u3002",
|
|
2874
5567
|
"",
|
|
2875
5568
|
"\u9009\u9879\uFF1A",
|
|
2876
|
-
" --json \
|
|
5569
|
+
" --json \u6807\u51C6\u8F93\u51FA\u4EC5\u8FD4\u56DE\u4E00\u4E2A JSON \u6587\u6863\uFF0C\u4F9B\u811A\u672C\u89E3\u6790"
|
|
2877
5570
|
].join("\n")
|
|
2878
5571
|
},
|
|
2879
5572
|
balance: {
|
|
@@ -2887,18 +5580,22 @@ var COMMANDS = {
|
|
|
2887
5580
|
"\u67E5\u8BE2\u8FD9\u4E2A\u8D26\u53F7\u7684\u4F59\u989D\uFF1A\u53EF\u7528\u591A\u5C11\u3001\u51BB\u7740\u591A\u5C11\u3001\u5DF2\u7ECF\u82B1\u4E86\u591A\u5C11\u3002",
|
|
2888
5581
|
"",
|
|
2889
5582
|
"\u9009\u9879\uFF1A",
|
|
2890
|
-
" --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF1B\
|
|
2891
|
-
" --json \
|
|
5583
|
+
" --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF1B\u7701\u7565\u65F6\u4F7F\u7528\u767B\u5F55\u65F6\u7684\u5730\u5740",
|
|
5584
|
+
" --json \u6807\u51C6\u8F93\u51FA\u4EC5\u8FD4\u56DE\u4E00\u4E2A JSON \u6587\u6863\uFF0C\u4F9B\u811A\u672C\u89E3\u6790"
|
|
2892
5585
|
].join("\n")
|
|
2893
5586
|
},
|
|
2894
5587
|
products: {
|
|
2895
5588
|
run: products,
|
|
2896
5589
|
acceptsBaseUrl: true,
|
|
2897
|
-
options: ["name", "category", "front", "side", "back", "detail", "color", "silhouette", "material", "idempotency-key"],
|
|
5590
|
+
options: ["name", "category", "front", "side", "back", "detail", "color", "silhouette", "material", "idempotency-key", "data", "sku", "classification-hint", "q", "archived", "limit", "offset"],
|
|
2898
5591
|
positionals: ["\u5B50\u547D\u4EE4", "\u4EA7\u54C1id"],
|
|
2899
5592
|
help: [
|
|
2900
5593
|
"\u7528\u6CD5\uFF1A",
|
|
2901
|
-
" buke products
|
|
5594
|
+
" buke products list|search [--q <\u5173\u952E\u8BCD>] [--archived exclude|only|include] [--limit <\u6570\u91CF>] [--offset <\u504F\u79FB>]",
|
|
5595
|
+
" buke products show <\u4EA7\u54C1id>",
|
|
5596
|
+
" buke products create --name <\u540D\u79F0> [--category <\u7C7B\u76EE>] [--sku <\u7F16\u53F7>] [--classification-hint <\u54C1\u7C7B\u8BF4\u660E>] [--data <JSON\u6587\u4EF6|->]",
|
|
5597
|
+
" buke products update <\u4EA7\u54C1id> --name <\u540D\u79F0>",
|
|
5598
|
+
" buke products archive|restore <\u4EA7\u54C1id>",
|
|
2902
5599
|
" buke products set-images <\u4EA7\u54C1id> --front <\u56FE> [--side <\u56FE>] [--back <\u56FE>] [--detail <\u56FE>]",
|
|
2903
5600
|
" buke products confirm-lock <\u4EA7\u54C1id> --color <\u8272> --silhouette <\u5ED3\u5F62> --material <\u6750\u8D28>",
|
|
2904
5601
|
"",
|
|
@@ -2914,9 +5611,42 @@ var COMMANDS = {
|
|
|
2914
5611
|
" --color <\u8272> \u5916\u89C2\u9501\uFF1A\u989C\u8272",
|
|
2915
5612
|
" --silhouette <\u5ED3\u5F62> \u5916\u89C2\u9501\uFF1A\u5ED3\u5F62",
|
|
2916
5613
|
" --material <\u6750\u8D28> \u5916\u89C2\u9501\uFF1A\u6750\u8D28",
|
|
2917
|
-
" --idempotency-key <\u952E> \u5E42\u7B49\u952E\uFF1B\
|
|
2918
|
-
" --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF1B\
|
|
2919
|
-
" --json \
|
|
5614
|
+
" --idempotency-key <\u952E> \u5E42\u7B49\u952E\uFF1B\u7701\u7565\u65F6\u81EA\u52A8\u751F\u6210\u5E76\u8FD4\u56DE\uFF1B\u6062\u590D\u540C\u4E00\u6B21\u8BF7\u6C42\u65F6\u4F7F\u7528\u539F\u952E\u548C\u539F\u5185\u5BB9",
|
|
5615
|
+
" --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF1B\u7701\u7565\u65F6\u4F7F\u7528\u767B\u5F55\u65F6\u7684\u5730\u5740",
|
|
5616
|
+
" --json \u6807\u51C6\u8F93\u51FA\u4EC5\u8FD4\u56DE\u4E00\u4E2A JSON \u6587\u6863\uFF0C\u4F9B\u811A\u672C\u89E3\u6790"
|
|
5617
|
+
].join("\n")
|
|
5618
|
+
},
|
|
5619
|
+
library: {
|
|
5620
|
+
run: library,
|
|
5621
|
+
acceptsBaseUrl: true,
|
|
5622
|
+
options: ["q", "kind", "state", "product", "archived", "limit", "cursor", "name", "idempotency-key"],
|
|
5623
|
+
positionals: ["\u5B50\u547D\u4EE4", "\u4F5C\u54C1id"],
|
|
5624
|
+
help: [
|
|
5625
|
+
"\u7528\u6CD5\uFF1A",
|
|
5626
|
+
" buke library list|search [--q <\u5173\u952E\u8BCD>] [--kind commercial_ad|episode|graphic] [--state ready|active|attention|draft]",
|
|
5627
|
+
" buke library show <\u4F5C\u54C1id> --kind <\u7C7B\u578B>",
|
|
5628
|
+
" buke library rename <\u4F5C\u54C1id> --kind <\u7C7B\u578B> --name <\u540D\u79F0>",
|
|
5629
|
+
" buke library archive|restore <\u4F5C\u54C1id> --kind <\u7C7B\u578B>",
|
|
5630
|
+
"",
|
|
5631
|
+
"\u5217\u8868\u652F\u6301 --product\u3001--archived exclude|only|include\u3001--limit\u3001--cursor\u3002\u5199\u5165\u652F\u6301 --idempotency-key\u3002",
|
|
5632
|
+
"\u4F5C\u54C1\u80FD\u529B\u4EE5\u67E5\u8BE2\u54CD\u5E94\u4E3A\u51C6\uFF1B\u56FE\u6587\u76EE\u524D\u4E0D\u652F\u6301\u5F52\u6863\uFF0C\u6B63\u5728\u5236\u4F5C\u7684\u4F5C\u54C1\u4E0D\u80FD\u5F52\u6863\u3002"
|
|
5633
|
+
].join("\n")
|
|
5634
|
+
},
|
|
5635
|
+
assets: {
|
|
5636
|
+
run: assets,
|
|
5637
|
+
acceptsBaseUrl: true,
|
|
5638
|
+
options: ["q", "source", "kind", "name", "authorization", "license", "limit", "offset", "idempotency-key"],
|
|
5639
|
+
positionals: ["\u5B50\u547D\u4EE4", "\u7D20\u6750id\u6216\u6587\u4EF6\u8DEF\u5F84"],
|
|
5640
|
+
help: [
|
|
5641
|
+
"\u7528\u6CD5\uFF1A",
|
|
5642
|
+
" buke assets list|search [--source personal|platform|upload] [--kind character|scene|image|video|audio] [--q <\u5173\u952E\u8BCD>]",
|
|
5643
|
+
" buke assets show <\u7D20\u6750id> [--source personal|platform|upload]",
|
|
5644
|
+
" buke assets upload <\u6587\u4EF6> --authorization own|licensed|public_domain --license <\u6388\u6743\u8BF4\u660E> [--name <\u540D\u79F0>]",
|
|
5645
|
+
" buke assets rename <\u7D20\u6750id> --name <\u540D\u79F0>",
|
|
5646
|
+
" buke assets archive|restore <\u7D20\u6750id>",
|
|
5647
|
+
"",
|
|
5648
|
+
"\u5217\u8868\u652F\u6301 --limit\u3001--offset\u3002\u5199\u5165\u652F\u6301 --idempotency-key\u3002",
|
|
5649
|
+
"\u5E73\u53F0\u7D20\u6750\u4E3A\u53EA\u8BFB\uFF1B\u4E2A\u4EBA\u7D20\u6750\u5F52\u6863\u4FDD\u7559\u539F\u6587\u4EF6\u53CA\u5DF2\u6709\u8BA2\u5355\u5F15\u7528\u3002\u4E0A\u4F20\u9700\u56FE\u7247\u3001\u89C6\u9891\u6216\u97F3\u9891\u539F\u6587\u4EF6\u3002"
|
|
2920
5650
|
].join("\n")
|
|
2921
5651
|
},
|
|
2922
5652
|
shorts: {
|
|
@@ -2934,7 +5664,7 @@ var COMMANDS = {
|
|
|
2934
5664
|
" buke shorts download <\u8BA2\u5355id> [--out <\u8DEF\u5F84>]",
|
|
2935
5665
|
" buke shorts cancel <\u8BA2\u5355id>",
|
|
2936
5666
|
"",
|
|
2937
|
-
"\
|
|
5667
|
+
"\u6A21\u677F\u77ED\u7247\uFF08\u6A21\u677F\u76F4\u51FA\u7684\u7AD6\u5C4F\u5546\u54C1\u77ED\u7247\uFF09\uFF1A",
|
|
2938
5668
|
" catalog \u5217\u51FA\u5168\u90E8\u6A21\u677F\uFF08id\u3001\u65F6\u957F\u3001\u8981\u54EA\u4E9B\u7D20\u6750\uFF09",
|
|
2939
5669
|
" 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",
|
|
2940
5670
|
" quote \u53EA\u8BFB\u62A5\u4EF7\uFF1B\u6536\u8D39\u7684\u6A21\u677F\u4E0B\u5355\u524D\u5FC5\u987B\u5148\u62FF quoteHash",
|
|
@@ -2947,18 +5677,46 @@ var COMMANDS = {
|
|
|
2947
5677
|
" --template <\u6A21\u677Fid> \u6A21\u677F id\uFF08catalog \u91CC\u5217\u51FA\u7684\uFF09",
|
|
2948
5678
|
" --props <props.json|-> \u6A21\u677F\u53C2\u6570\uFF1A\u4E00\u4E2A JSON \u6587\u4EF6\uFF0C\u6216 - \u8868\u793A\u4ECE\u6807\u51C6\u8F93\u5165\u8BFB",
|
|
2949
5679
|
" --quote-hash <hash> \u62A5\u4EF7\u54C8\u5E0C\uFF08quote \u547D\u4EE4\u56DE\u7684\uFF09",
|
|
2950
|
-
" --wait \
|
|
5680
|
+
" --wait \u7B49\u5F85\u7EC8\u6001\uFF1A\u6210\u529F\u9000\u51FA 0\uFF0C\u4EFB\u52A1\u5931\u8D25\u9000\u51FA 9\uFF0C\u8D85\u65F6\u9000\u51FA 8",
|
|
2951
5681
|
" --timeout <\u79D2> --wait \u7684\u65F6\u9650\uFF0C\u9ED8\u8BA4 600",
|
|
2952
|
-
" --out <\u8DEF\u5F84> \u4E0B\u8F7D\u4FDD\u5B58\u7684\u4F4D\u7F6E\uFF1B\
|
|
2953
|
-
" --idempotency-key <\u952E> \u5E42\u7B49\u952E\uFF1B\
|
|
2954
|
-
" --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF1B\
|
|
2955
|
-
" --json \
|
|
5682
|
+
" --out <\u8DEF\u5F84> \u4E0B\u8F7D\u4FDD\u5B58\u7684\u4F4D\u7F6E\uFF1B\u7701\u7565\u65F6\u4FDD\u5B58\u5230\u5F53\u524D\u76EE\u5F55",
|
|
5683
|
+
" --idempotency-key <\u952E> \u5E42\u7B49\u952E\uFF1B\u7701\u7565\u65F6\u81EA\u52A8\u751F\u6210\u5E76\u8FD4\u56DE\uFF1B\u6062\u590D\u540C\u4E00\u6B21\u8BF7\u6C42\u65F6\u4F7F\u7528\u539F\u952E\u548C\u539F\u5185\u5BB9",
|
|
5684
|
+
" --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF1B\u7701\u7565\u65F6\u4F7F\u7528\u767B\u5F55\u65F6\u7684\u5730\u5740",
|
|
5685
|
+
" --json \u6807\u51C6\u8F93\u51FA\u4EC5\u8FD4\u56DE\u4E00\u4E2A JSON \u6587\u6863\uFF0C\u4F9B\u811A\u672C\u89E3\u6790"
|
|
5686
|
+
].join("\n")
|
|
5687
|
+
},
|
|
5688
|
+
series: {
|
|
5689
|
+
run: series,
|
|
5690
|
+
acceptsBaseUrl: true,
|
|
5691
|
+
options: ["limit", "offset", "data", "product", "project", "title", "main-line", "logline", "previous-episode", "expected-epoch", "idempotency-key"],
|
|
5692
|
+
positionals: ["\u5B50\u547D\u4EE4", "\u5267\u96C6id"],
|
|
5693
|
+
help: [
|
|
5694
|
+
"\u7528\u6CD5\uFF1A",
|
|
5695
|
+
" buke series list [--limit <\u6570\u91CF>] [--offset <\u504F\u79FB>]",
|
|
5696
|
+
" buke series show <\u5267\u96C6id>",
|
|
5697
|
+
" buke series create --product <\u4EA7\u54C1id> --project <\u77ED\u5267id> --expected-epoch <\u7248\u672C> [--title <\u6807\u9898>] [--data <JSON\u6587\u4EF6|->]",
|
|
5698
|
+
" buke series episode-create <\u5267\u96C6id> --expected-epoch <\u7248\u672C> --previous-episode <\u5206\u96C6id> [--data <JSON\u6587\u4EF6|->]",
|
|
5699
|
+
"",
|
|
5700
|
+
"\u521B\u5EFA\u4E0E\u7EED\u96C6\u53C2\u6570\u652F\u6301 --product\u3001--main-line\u3001--logline\u3001--idempotency-key\u3002"
|
|
2956
5701
|
].join("\n")
|
|
2957
5702
|
},
|
|
2958
5703
|
videos: {
|
|
2959
5704
|
run: videos,
|
|
2960
5705
|
acceptsBaseUrl: true,
|
|
2961
5706
|
options: [
|
|
5707
|
+
"file",
|
|
5708
|
+
"offset",
|
|
5709
|
+
"attachment-id",
|
|
5710
|
+
"props",
|
|
5711
|
+
"quote-hash",
|
|
5712
|
+
"music-task-id",
|
|
5713
|
+
"track-index",
|
|
5714
|
+
"narration-edit-id",
|
|
5715
|
+
"append-task-id",
|
|
5716
|
+
"data",
|
|
5717
|
+
"production-id",
|
|
5718
|
+
"edit-id",
|
|
5719
|
+
"attachment-ids",
|
|
2962
5720
|
"product",
|
|
2963
5721
|
"intent",
|
|
2964
5722
|
"duration",
|
|
@@ -2978,56 +5736,82 @@ var COMMANDS = {
|
|
|
2978
5736
|
"\u7528\u6CD5\uFF1A",
|
|
2979
5737
|
" buke videos create --product <\u4EA7\u54C1id> [--intent <\u4E00\u53E5\u8BDD>] [--duration <\u79D2>] [--resolution <r>]",
|
|
2980
5738
|
" [--speed <\u6863>] [--aspect-ratio <a>] [--style-preset <p>] [--json]",
|
|
5739
|
+
" buke videos upload <\u4EFB\u52A1id> --file <\u9644\u4EF6\u8DEF\u5F84>",
|
|
5740
|
+
" buke videos attachments <\u4EFB\u52A1id> [--attachment-ids <\u7F16\u53F7,\u7F16\u53F7>] [--offset <\u504F\u79FB>]",
|
|
5741
|
+
" buke videos attachment-download <\u4EFB\u52A1id> --attachment-id <\u9644\u4EF6\u7F16\u53F7> [--out <\u8DEF\u5F84>]",
|
|
2981
5742
|
" buke videos status <\u89C6\u9891id> [--wait] [--timeout <\u79D2>]",
|
|
2982
|
-
" buke videos message <\u89C6\u9891id> --text <\u5185\u5BB9>",
|
|
2983
|
-
" buke videos
|
|
2984
|
-
" buke videos
|
|
5743
|
+
" buke videos message <\u89C6\u9891id> --text <\u5185\u5BB9> [--data <JSON\u6587\u4EF6|->]",
|
|
5744
|
+
" buke videos versions <\u89C6\u9891id>",
|
|
5745
|
+
" buke videos music-list <\u89C6\u9891id>",
|
|
5746
|
+
" buke videos music-quote <\u89C6\u9891id> --props <JSON\u6587\u4EF6|->",
|
|
5747
|
+
" buke videos music-compose <\u89C6\u9891id> --props <JSON\u6587\u4EF6|-> --quote-hash <\u5DF2\u67E5\u770B\u62A5\u4EF7\u6807\u8BC6> --yes",
|
|
5748
|
+
" buke videos music-apply <\u89C6\u9891id> --music-task-id <\u4EFB\u52A1id> --props <JSON\u6587\u4EF6|->",
|
|
5749
|
+
" buke videos cancel <\u89C6\u9891id>",
|
|
5750
|
+
" buke videos confirm <\u89C6\u9891id> \u67E5\u770B\u5F53\u524D\u786E\u8BA4\u5361",
|
|
5751
|
+
" buke videos confirm <\u89C6\u9891id> --expected-version <\u5DF2\u67E5\u770B\u7248\u672C> --expected-credits <\u5DF2\u67E5\u770B\u91D1\u989D> --yes",
|
|
5752
|
+
" buke videos confirm <\u89C6\u9891id> --data <\u539F\u786E\u8BA4JSON> --idempotency-key <\u539F\u952E> --yes \u91CD\u653E\u539F\u786E\u8BA4",
|
|
5753
|
+
" buke videos download <\u89C6\u9891id> [--production-id <\u5236\u4F5C\u7248\u672C>] [--edit-id <\u526A\u8F91\u7248\u672C>] [--out <\u8DEF\u5F84>]",
|
|
5754
|
+
" buke videos download <\u89C6\u9891id> --music-task-id <\u4EFB\u52A1id> --track-index <0|1> [--out <\u8DEF\u5F84>]",
|
|
5755
|
+
" buke videos download <\u89C6\u9891id> [--append-task-id <\u63D2\u6BB5\u4EFB\u52A1>] [--narration-edit-id <\u914D\u97F3\u7248\u672C>] [--out <\u8DEF\u5F84>]",
|
|
5756
|
+
" \u5404\u4E0B\u8F7D\u7248\u672C\u9009\u62E9\u9879\u4E92\u65A5\u3002",
|
|
2985
5757
|
"",
|
|
2986
|
-
"\u5546\u54C1\u89C6\u9891\
|
|
2987
|
-
" create \
|
|
2988
|
-
" status \u67E5\u8FDB\u5EA6\uFF1B--wait \
|
|
2989
|
-
" message \
|
|
2990
|
-
" confirm \
|
|
5758
|
+
"\u5546\u54C1\u89C6\u9891\u521B\u4F5C\u4E0E\u4EA4\u4ED8\uFF1A",
|
|
5759
|
+
" create \u521B\u5EFA\u4EFB\u52A1\uFF1B\u987B\u5148\u5EFA\u7ACB\u4EA7\u54C1\u3002\u53D7\u7406\u540E\u901A\u8FC7 status \u67E5\u8BE2\u8FDB\u5EA6",
|
|
5760
|
+
" status \u67E5\u8BE2\u8FDB\u5EA6\uFF1B--wait \u7B49\u5F85\u7EC8\u6001\u6216\u9700\u8981\u7528\u6237\u5904\u7406\u7684\u72B6\u6001",
|
|
5761
|
+
" message \u63D0\u4EA4\u5236\u4F5C\u8981\u6C42\u3001\u95EE\u9898\u56DE\u590D\u3001\u9644\u4EF6\u6216\u7ED3\u6784\u5316\u9009\u9879",
|
|
5762
|
+
" 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",
|
|
2991
5763
|
" download \u4E0B\u8F7D\u6210\u7247\uFF08mp4\uFF09",
|
|
2992
5764
|
"",
|
|
2993
5765
|
"\u9009\u9879\uFF1A",
|
|
2994
5766
|
" --product <\u4EA7\u54C1id> \u4EA7\u54C1 id\uFF08buke products create \u56DE\u7684\uFF09",
|
|
2995
|
-
" --intent <\u4E00\u53E5\u8BDD> \
|
|
5767
|
+
" --intent <\u4E00\u53E5\u8BDD> \u5236\u4F5C\u8981\u6C42\uFF1B\u7701\u7565\u65F6\u7531\u5BFC\u6F14\u6839\u636E\u4EA7\u54C1\u8D44\u6599\u51C6\u5907\u65B9\u6848",
|
|
2996
5768
|
" --duration <\u79D2> \u671F\u671B\u65F6\u957F",
|
|
2997
5769
|
" --resolution <r> \u5206\u8FA8\u7387\u6863\u4F4D",
|
|
2998
5770
|
" --speed <\u6863> \u751F\u6210\u901F\u5EA6\u6863\u4F4D",
|
|
2999
5771
|
" --aspect-ratio <a> \u753B\u5E45\uFF08\u5982 9:16\uFF09",
|
|
3000
5772
|
" --style-preset <p> \u753B\u9762\u98CE\u683C",
|
|
3001
|
-
" --text <\u5185\u5BB9> \
|
|
3002
|
-
" --yes
|
|
3003
|
-
" --wait \
|
|
5773
|
+
" --text <\u5185\u5BB9> \u53D1\u9001\u7ED9\u5BFC\u6F14\u7684\u6D88\u606F\u6B63\u6587",
|
|
5774
|
+
" --yes \u660E\u786E\u63D0\u4EA4\u5F53\u524D\u786E\u8BA4\uFF1B\u7701\u7565\u65F6\u4EC5\u663E\u793A\u786E\u8BA4\u5361",
|
|
5775
|
+
" --wait \u7B49\u5F85\u7EC8\u6001\uFF1A\u6210\u529F\u9000\u51FA 0\uFF0C\u4EFB\u52A1\u5931\u8D25\u9000\u51FA 9\uFF0C\u8D85\u65F6\u9000\u51FA 8",
|
|
3004
5776
|
" --timeout <\u79D2> --wait \u7684\u65F6\u9650\uFF0C\u9ED8\u8BA4 600",
|
|
3005
|
-
" --out <\u8DEF\u5F84> \u4E0B\u8F7D\u4FDD\u5B58\u7684\u4F4D\u7F6E\uFF1B\
|
|
3006
|
-
" --idempotency-key <\u952E> \u5E42\u7B49\u952E\uFF1B\
|
|
3007
|
-
" --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF1B\
|
|
3008
|
-
" --json \
|
|
5777
|
+
" --out <\u8DEF\u5F84> \u4E0B\u8F7D\u4FDD\u5B58\u7684\u4F4D\u7F6E\uFF1B\u7701\u7565\u65F6\u4FDD\u5B58\u5230\u5F53\u524D\u76EE\u5F55",
|
|
5778
|
+
" --idempotency-key <\u952E> \u5E42\u7B49\u952E\uFF1B\u7701\u7565\u65F6\u81EA\u52A8\u751F\u6210\u5E76\u8FD4\u56DE\uFF1B\u6062\u590D\u540C\u4E00\u6B21\u8BF7\u6C42\u65F6\u4F7F\u7528\u539F\u952E\u548C\u539F\u5185\u5BB9",
|
|
5779
|
+
" --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF1B\u7701\u7565\u65F6\u4F7F\u7528\u767B\u5F55\u65F6\u7684\u5730\u5740",
|
|
5780
|
+
" --json \u6807\u51C6\u8F93\u51FA\u4EC5\u8FD4\u56DE\u4E00\u4E2A JSON \u6587\u6863\uFF0C\u4F9B\u811A\u672C\u89E3\u6790"
|
|
3009
5781
|
].join("\n")
|
|
3010
5782
|
},
|
|
3011
5783
|
drama: {
|
|
3012
|
-
run:
|
|
5784
|
+
run: drama2,
|
|
3013
5785
|
acceptsBaseUrl: true,
|
|
3014
|
-
options: ["product", "genre", "duration", "brief", "model", "resolution", "quote-hash", "yes", "wait", "timeout", "out", "idempotency-key"],
|
|
5786
|
+
options: ["file", "offset", "attachment-id", "text", "data", "expected-epoch", "kind", "episode-number", "confirmation-id", "shot", "output-id", "edit-id", "source-output-id", "attachment-ids", "product", "genre", "duration", "brief", "model", "resolution", "quote-hash", "yes", "wait", "timeout", "out", "idempotency-key"],
|
|
3015
5787
|
positionals: ["\u5B50\u547D\u4EE4", "\u8BA2\u5355id"],
|
|
3016
5788
|
help: [
|
|
3017
5789
|
"\u7528\u6CD5\uFF1A",
|
|
5790
|
+
" buke drama context|director|versions <\u8BA2\u5355id>",
|
|
5791
|
+
" buke drama document <\u8BA2\u5355id> --kind <\u6587\u6863\u7C7B\u578B> [--episode-number <\u96C6\u6570>]",
|
|
5792
|
+
" buke drama message|bindings|spec <\u8BA2\u5355id> --data <JSON\u6587\u4EF6|-> [--expected-epoch <\u7248\u672C>]",
|
|
5793
|
+
" buke drama director-confirm <\u8BA2\u5355id> --confirmation-id <\u786E\u8BA4\u7F16\u53F7> --yes",
|
|
5794
|
+
" \u786E\u8BA4\u7ED3\u679C\u672A\u77E5\u65F6\uFF0C\u4FDD\u7559\u539F\u5E42\u7B49\u952E\uFF0C\u53EF\u7528 --kind \u4E0E --confirmation-id \u6216 --data \u539F\u786E\u8BA4\u8EAB\u4EFD\u6062\u590D\u3002",
|
|
5795
|
+
" buke drama shot-plan <\u8BA2\u5355id> --data <\u5206\u955CJSON\u6587\u4EF6|-> --expected-epoch <\u7248\u672C>",
|
|
5796
|
+
" buke drama select-version <\u8BA2\u5355id> --shot <\u955C\u5934id> --output-id <\u7248\u672Cid> --expected-epoch <\u7248\u672C>",
|
|
5797
|
+
" buke drama redo-quote <\u8BA2\u5355id> --expected-epoch <\u7248\u672C> [--shot <\u955C\u5934id,\u955C\u5934id>] [--data <JSON\u6587\u4EF6|->]",
|
|
5798
|
+
" buke drama redo <\u8BA2\u5355id> --data <JSON\u6587\u4EF6|-> --yes",
|
|
3018
5799
|
" buke drama create --product <\u4EA7\u54C1id> [--genre <\u9898\u6750id>] [--duration 30s|60s|90s] [--brief <JSON \u6587\u4EF6|->] [--model <\u6A21\u578B>] [--resolution <\u5206\u8FA8\u7387>] [--json]",
|
|
5800
|
+
" buke drama upload <\u4EFB\u52A1id> --file <\u9644\u4EF6\u8DEF\u5F84>",
|
|
5801
|
+
" buke drama attachments <\u4EFB\u52A1id> [--attachment-ids <\u7F16\u53F7,\u7F16\u53F7>] [--offset <\u504F\u79FB>]",
|
|
5802
|
+
" buke drama attachment-download <\u4EFB\u52A1id> --attachment-id <\u9644\u4EF6\u7F16\u53F7> [--out <\u8DEF\u5F84>]",
|
|
3019
5803
|
" buke drama status <\u8BA2\u5355id> [--wait] [--timeout <\u79D2>]",
|
|
3020
5804
|
" buke drama quote <\u8BA2\u5355id>",
|
|
3021
5805
|
" buke drama confirm <\u8BA2\u5355id> --quote-hash <\u62A5\u4EF7\u54C8\u5E0C> [--yes]",
|
|
3022
5806
|
" buke drama cancel <\u8BA2\u5355id>",
|
|
3023
|
-
" buke drama download <\u8BA2\u5355id> [--out <\u8DEF\u5F84>]",
|
|
5807
|
+
" buke drama download <\u8BA2\u5355id> [--output-id <\u955C\u5934\u7248\u672C>] [--source-output-id <\u5386\u53F2\u6210\u7247>] [--edit-id <\u540E\u671F\u7248\u672C>] [--out <\u8DEF\u5F84>]",
|
|
3024
5808
|
"",
|
|
3025
|
-
"\u77ED\u5267\
|
|
3026
|
-
" create \
|
|
3027
|
-
" status \u67E5\u8FDB\u5EA6\
|
|
5809
|
+
"\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
|
+
" create \u521B\u5EFA\u4EFB\u52A1\uFF1B\u987B\u5148\u5EFA\u7ACB\u4EA7\u54C1\u3002\u53D7\u7406\u540E\u901A\u8FC7 status \u67E5\u8BE2\u8FDB\u5EA6",
|
|
5811
|
+
" 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",
|
|
3028
5812
|
" 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",
|
|
3029
|
-
" confirm \u786E\u8BA4\
|
|
3030
|
-
" cancel \u53D6\u6D88\
|
|
5813
|
+
" confirm \u786E\u8BA4\u5F53\u524D\u62A5\u4EF7\uFF1B\u6307\u5B9A --yes \u540E\u624D\u63D0\u4EA4\u5236\u4F5C\u6388\u6743",
|
|
5814
|
+
" 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",
|
|
3031
5815
|
" download \u4E0B\u8F7D\u76F4\u62FC\u597D\u7684\u6210\u7247\uFF08mp4\uFF09",
|
|
3032
5816
|
"",
|
|
3033
5817
|
"\u9009\u9879\uFF1A",
|
|
@@ -3035,19 +5819,31 @@ var COMMANDS = {
|
|
|
3035
5819
|
" --genre <\u9898\u6750id> \u9898\u6750 id\uFF08\u5982 counterattack\u3001urban-ceo\u3001family\uFF09",
|
|
3036
5820
|
" --duration <\u4F53\u91CF> \u6210\u7247\u4F53\u91CF\uFF1A30s\u300160s \u6216 90s\uFF1B\u4E0D\u7ED9\u65F6 30s",
|
|
3037
5821
|
" --brief <JSON \u6587\u4EF6|-> \u6545\u4E8B\u8BBE\u5B9A\uFF1Adescription\u3001forbidden\u3001storyTone \u4E09\u9879\uFF0C\u4E00\u4E2A JSON \u6587\u4EF6\u6216 - \u8868\u793A\u4ECE\u6807\u51C6\u8F93\u5165\u8BFB",
|
|
3038
|
-
" --model <\u6A21\u578B> \u660E\u786E\u9009\u62E9\u5236\u4F5C\u6A21\u578B\uFF0C\u670D\u52A1\u7AEF\u6309\u5F53\u524D\u80FD\u529B\u6821\u9A8C\uFF1B\u5DF2\u6709\u8BA2\u5355\
|
|
5822
|
+
" --model <\u6A21\u578B> \u660E\u786E\u9009\u62E9\u5236\u4F5C\u6A21\u578B\uFF0C\u670D\u52A1\u7AEF\u6309\u5F53\u524D\u80FD\u529B\u6821\u9A8C\uFF1B\u5DF2\u6709\u8BA2\u5355\u901A\u8FC7 drama spec \u4FEE\u6539\u5236\u4F5C\u89C4\u683C",
|
|
3039
5823
|
" --resolution <\u5206\u8FA8\u7387> \u660E\u786E\u9009\u62E9\u5236\u4F5C\u5206\u8FA8\u7387\uFF0C\u4E0E\u6A21\u578B\u4E00\u5E76\u7531\u670D\u52A1\u7AEF\u6821\u9A8C",
|
|
3040
5824
|
" --quote-hash <\u54C8\u5E0C> \u62A5\u4EF7\u54C8\u5E0C\uFF08buke drama quote \u56DE\u7684\uFF09\uFF0C\u786E\u8BA4\u5F00\u62CD\u65F6\u539F\u6837\u5E26\u56DE",
|
|
3041
|
-
" --yes
|
|
3042
|
-
" --wait \
|
|
5825
|
+
" --yes \u660E\u786E\u63D0\u4EA4\u5236\u4F5C\u786E\u8BA4\uFF1B\u7701\u7565\u65F6\u4EC5\u663E\u793A\u5F53\u524D\u62A5\u4EF7",
|
|
5826
|
+
" --wait \u7B49\u5F85\u7EC8\u6001\u6216\u9700\u8981\u5904\u7406\uFF1A\u6210\u529F\u9000\u51FA 0\uFF0C\u5931\u8D25\u6216\u53D6\u6D88\u9000\u51FA 9\uFF0C\u8D85\u65F6\u9000\u51FA 8",
|
|
3043
5827
|
" --timeout <\u79D2> --wait \u7684\u65F6\u9650\uFF0C\u9ED8\u8BA4 600",
|
|
3044
|
-
" --out <\u8DEF\u5F84> \u4E0B\u8F7D\u4FDD\u5B58\u7684\u4F4D\u7F6E\uFF1B\
|
|
3045
|
-
" --idempotency-key <\u952E> \u5E42\u7B49\u952E\uFF1B\
|
|
3046
|
-
" --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF1B\
|
|
3047
|
-
" --json \
|
|
5828
|
+
" --out <\u8DEF\u5F84> \u4E0B\u8F7D\u4FDD\u5B58\u7684\u4F4D\u7F6E\uFF1B\u7701\u7565\u65F6\u4FDD\u5B58\u5230\u5F53\u524D\u76EE\u5F55",
|
|
5829
|
+
" --idempotency-key <\u952E> \u5E42\u7B49\u952E\uFF1B\u7701\u7565\u65F6\u81EA\u52A8\u751F\u6210\u5E76\u8FD4\u56DE\uFF1B\u6062\u590D\u540C\u4E00\u6B21\u8BF7\u6C42\u65F6\u4F7F\u7528\u539F\u952E\u548C\u539F\u5185\u5BB9",
|
|
5830
|
+
" --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF1B\u7701\u7565\u65F6\u4F7F\u7528\u767B\u5F55\u65F6\u7684\u5730\u5740",
|
|
5831
|
+
" --json \u6807\u51C6\u8F93\u51FA\u4EC5\u8FD4\u56DE\u4E00\u4E2A JSON \u6587\u6863\uFF0C\u4F9B\u811A\u672C\u89E3\u6790"
|
|
3048
5832
|
].join("\n")
|
|
3049
5833
|
}
|
|
3050
5834
|
};
|
|
5835
|
+
for (const resource of ["videos", "drama", "graphic", "series"]) {
|
|
5836
|
+
const command = COMMANDS[resource];
|
|
5837
|
+
const runOriginal = command.run;
|
|
5838
|
+
COMMANDS[resource] = {
|
|
5839
|
+
...command,
|
|
5840
|
+
options: [.../* @__PURE__ */ new Set([...command.options, ...STUDIO_ACTION_OPTIONS])],
|
|
5841
|
+
help: command.help + STUDIO_ACTION_HELP(resource),
|
|
5842
|
+
run: async (context) => {
|
|
5843
|
+
if (!await tryStudioAction(resource, context)) await runOriginal(context);
|
|
5844
|
+
}
|
|
5845
|
+
};
|
|
5846
|
+
}
|
|
3051
5847
|
var GENERAL_HELP = [
|
|
3052
5848
|
"buke\uFF1A\u300A\u4E0D\u53EF\u601D\u8BAE\u300B\u7684\u547D\u4EE4\u884C\u5DE5\u5177",
|
|
3053
5849
|
"",
|
|
@@ -3056,16 +5852,21 @@ var GENERAL_HELP = [
|
|
|
3056
5852
|
" buke whoami [--base-url <\u5730\u5740>] [--json] \u67E5\u770B\u5F53\u524D\u7528\u7684\u662F\u54EA\u628A\u5BC6\u94A5\u3001\u5C5E\u4E8E\u54EA\u4E2A\u56E2\u961F",
|
|
3057
5853
|
" buke logout [--json] \u9000\u51FA\u767B\u5F55\uFF0C\u5220\u9664\u672C\u673A\u4FDD\u5B58\u7684\u5BC6\u94A5",
|
|
3058
5854
|
" buke balance [--json] \u67E5\u8BE2\u8D26\u6237\u4F59\u989D",
|
|
3059
|
-
" buke products <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u4EA7\u54C1\u5EFA\u6863\
|
|
3060
|
-
" buke shorts <\u5B50\u547D\u4EE4> [\u53C2\u6570] \
|
|
3061
|
-
" buke videos <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u5546\u54C1\u89C6\u9891\
|
|
3062
|
-
" buke drama <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u77ED\u5267\
|
|
5855
|
+
" buke products <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u4EA7\u54C1\u5EFA\u6863\u4E0E\u7BA1\u7406\uFF1Alist\u3001show\u3001create\u3001update\u3001archive\u3001restore",
|
|
5856
|
+
" buke shorts <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u6A21\u677F\u77ED\u7247\uFF1Acatalog\u3001upload\u3001quote\u3001order\u3001status\u3001download\u3001cancel",
|
|
5857
|
+
" buke videos <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u5546\u54C1\u89C6\u9891\uFF1A\u521B\u4F5C\u3001\u786E\u8BA4\u3001\u7248\u672C\u3001\u914D\u4E50\u548C\u4E0B\u8F7D",
|
|
5858
|
+
" buke drama <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u77ED\u5267\uFF1A\u5267\u672C\u3001\u5206\u955C\u3001\u4EBA\u666F\u7ED1\u5B9A\u3001\u62A5\u4EF7\u3001\u91CD\u62CD\u548C\u4EA4\u4ED8",
|
|
5859
|
+
" buke library <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u4F5C\u54C1\u67E5\u8BE2\u3001\u641C\u7D22\u3001\u91CD\u547D\u540D\u3001\u5F52\u6863\u53CA\u6062\u590D",
|
|
5860
|
+
" buke assets <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u5E73\u53F0\u4E0E\u4E2A\u4EBA\u7D20\u6750\u67E5\u8BE2\u3001\u4E0A\u4F20\u53CA\u7BA1\u7406",
|
|
5861
|
+
" buke graphic <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u56FE\u6587\u65B9\u6848\u3001\u62A5\u4EF7\u3001\u751F\u6210\u3001\u7F16\u8F91\u53CA\u4E0B\u8F7D",
|
|
5862
|
+
" buke series <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u591A\u96C6\u77ED\u5267\u67E5\u8BE2\u3001\u521B\u5EFA\u53CA\u7EED\u96C6",
|
|
5863
|
+
" buke web <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u7F51\u9875\u4F1A\u8BDD\uFF1A\u767B\u5F55\u3001\u64CD\u4F5C\u76EE\u5F55\u4E0E\u7F51\u9875\u529F\u80FD\u8C03\u7528\uFF08\u5145\u503C\u9664\u5916\uFF09",
|
|
3063
5864
|
" buke --help | -h \u663E\u793A\u8FD9\u4EFD\u8BF4\u660E\uFF1Bbuke <\u547D\u4EE4> --help \u770B\u5355\u6761\u547D\u4EE4",
|
|
3064
5865
|
" buke --version | -v \u663E\u793A\u7248\u672C\u53F7",
|
|
3065
5866
|
"",
|
|
3066
5867
|
"\u9009\u9879\uFF1A",
|
|
3067
5868
|
` --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF0C\u9ED8\u8BA4 ${DEFAULT_BASE_URL}\uFF1B\u53EA\u5199\u5230\u57DF\u540D\u4E3A\u6B62`,
|
|
3068
|
-
" --json \
|
|
5869
|
+
" --json \u6807\u51C6\u8F93\u51FA\u4EC5\u8FD4\u56DE\u4E00\u4E2A JSON \u6587\u6863\uFF0C\u4F9B\u811A\u672C\u89E3\u6790",
|
|
3069
5870
|
" -h, --help \u663E\u793A\u8BF4\u660E",
|
|
3070
5871
|
" -v, --version \u663E\u793A\u7248\u672C\u53F7",
|
|
3071
5872
|
"",
|
|
@@ -3090,7 +5891,7 @@ var GENERAL_HELP = [
|
|
|
3090
5891
|
" 10 \u8981\u627E\u7684\u4E1C\u897F\u4E0D\u5B58\u5728",
|
|
3091
5892
|
" 130 \u88AB Ctrl-C \u6253\u65AD",
|
|
3092
5893
|
"",
|
|
3093
|
-
"\
|
|
5894
|
+
"\u652F\u6301\u6A21\u677F\u77ED\u7247\u3001\u5546\u54C1\u89C6\u9891\u3001\u77ED\u5267\u53CA\u56FE\u6587\u5236\u4F5C\uFF0C\u53E6\u63D0\u4F9B\u4EA7\u54C1\u3001\u4F5C\u54C1\u548C\u7D20\u6750\u7BA1\u7406\u3002"
|
|
3094
5895
|
].join("\n");
|
|
3095
5896
|
var MAX_ECHO_LENGTH = 40;
|
|
3096
5897
|
function echo(item) {
|
|
@@ -3126,8 +5927,11 @@ var STRING_OPTIONS = /* @__PURE__ */ new Set([
|
|
|
3126
5927
|
"genre",
|
|
3127
5928
|
"brief"
|
|
3128
5929
|
]);
|
|
3129
|
-
var BOOLEAN_OPTIONS = /* @__PURE__ */ new Set(["help", "version", "json", "wait", "yes"]);
|
|
3130
|
-
|
|
5930
|
+
var BOOLEAN_OPTIONS = /* @__PURE__ */ new Set(["help", "version", "json", "wait", "yes", "all"]);
|
|
5931
|
+
for (const command of Object.values(COMMANDS)) for (const option of command.options) {
|
|
5932
|
+
if (!BOOLEAN_OPTIONS.has(option)) STRING_OPTIONS.add(option);
|
|
5933
|
+
}
|
|
5934
|
+
function parse2(argv) {
|
|
3131
5935
|
try {
|
|
3132
5936
|
const options = {};
|
|
3133
5937
|
for (const name2 of STRING_OPTIONS) options[name2] = { type: "string" };
|
|
@@ -3170,7 +5974,7 @@ async function dispatch(argv, io, out) {
|
|
|
3170
5974
|
message: "\u5BC6\u94A5\u4E0D\u8981\u5199\u5728\u547D\u4EE4\u884C\u91CC\uFF08\u4F1A\u7559\u5728 shell \u5386\u53F2\u548C\u8FDB\u7A0B\u5217\u8868\u91CC\uFF09\u3002\u8BF7\u7528\u73AF\u5883\u53D8\u91CF BUKE_API_KEY\uFF0C\u6216\u8005\u901A\u8FC7\u7BA1\u9053\u4F20\u7ED9 buke login\u3002\u521A\u624D\u8FD9\u628A\u5982\u679C\u662F\u771F\u7684\uFF0C\u5EFA\u8BAE\u540A\u9500\u540E\u91CD\u65B0\u521B\u5EFA\u3002"
|
|
3171
5975
|
});
|
|
3172
5976
|
}
|
|
3173
|
-
const parsed =
|
|
5977
|
+
const parsed = parse2(argv);
|
|
3174
5978
|
const command = parsed.command !== void 0 && Object.hasOwn(COMMANDS, parsed.command) ? COMMANDS[parsed.command] : void 0;
|
|
3175
5979
|
if (parsed.command !== void 0 && !command) throw usageError(`\u4E0D\u8BA4\u8BC6\u7684\u547D\u4EE4 ${echo(parsed.command)}`);
|
|
3176
5980
|
const args = parsed.positionals.slice(1);
|