bukesiyi-cli 0.3.3 → 0.4.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 +37 -6
- package/dist/main.js +1048 -142
- package/package.json +2 -2
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) {
|
|
@@ -261,10 +265,10 @@ function toBuffer(chunk) {
|
|
|
261
265
|
return Buffer.from(chunk);
|
|
262
266
|
}
|
|
263
267
|
function readToEnd(stdin, timeoutMs, signal) {
|
|
264
|
-
return new Promise((
|
|
268
|
+
return new Promise((resolve2, reject) => {
|
|
265
269
|
const state = stdin;
|
|
266
270
|
if (state.readableEnded === true || state.destroyed === true) {
|
|
267
|
-
|
|
271
|
+
resolve2("");
|
|
268
272
|
return;
|
|
269
273
|
}
|
|
270
274
|
const chunks = [];
|
|
@@ -292,7 +296,7 @@ function readToEnd(stdin, timeoutMs, signal) {
|
|
|
292
296
|
}
|
|
293
297
|
chunks.push(piece);
|
|
294
298
|
};
|
|
295
|
-
const onEnd = () => settle(() =>
|
|
299
|
+
const onEnd = () => settle(() => resolve2(Buffer.concat(chunks).toString("utf8").trim()));
|
|
296
300
|
const onError = (error) => settle(() => reject(missingKey(`\u6CA1\u6709\u8BFB\u5230\u5BC6\u94A5\uFF1A\u6807\u51C6\u8F93\u5165\u51FA\u9519\uFF08${briefReason(error)}\uFF09`)));
|
|
297
301
|
const timer = setTimeout(() => {
|
|
298
302
|
settle(
|
|
@@ -312,7 +316,7 @@ function readToEnd(stdin, timeoutMs, signal) {
|
|
|
312
316
|
});
|
|
313
317
|
}
|
|
314
318
|
function readHiddenLine(stdin, signal) {
|
|
315
|
-
return new Promise((
|
|
319
|
+
return new Promise((resolve2, reject) => {
|
|
316
320
|
let typed = "";
|
|
317
321
|
let escape = "none";
|
|
318
322
|
let settled = false;
|
|
@@ -343,7 +347,7 @@ function readHiddenLine(stdin, signal) {
|
|
|
343
347
|
continue;
|
|
344
348
|
}
|
|
345
349
|
if (char === "\r" || char === "\n") {
|
|
346
|
-
settle(() =>
|
|
350
|
+
settle(() => resolve2(typed));
|
|
347
351
|
return;
|
|
348
352
|
}
|
|
349
353
|
if (char === CTRL_C) {
|
|
@@ -351,7 +355,7 @@ function readHiddenLine(stdin, signal) {
|
|
|
351
355
|
return;
|
|
352
356
|
}
|
|
353
357
|
if (char === CTRL_D) {
|
|
354
|
-
settle(() => typed === "" ? reject(missingKey(NO_KEY_READ)) :
|
|
358
|
+
settle(() => typed === "" ? reject(missingKey(NO_KEY_READ)) : resolve2(typed));
|
|
355
359
|
return;
|
|
356
360
|
}
|
|
357
361
|
if (char === DELETE || char === BACKSPACE) {
|
|
@@ -371,7 +375,7 @@ function readHiddenLine(stdin, signal) {
|
|
|
371
375
|
}
|
|
372
376
|
if (escape === "started") escape = "carried";
|
|
373
377
|
};
|
|
374
|
-
const onEnd = () => settle(() =>
|
|
378
|
+
const onEnd = () => settle(() => resolve2(typed));
|
|
375
379
|
const onError = (error) => settle(() => reject(missingKey(`\u6CA1\u6709\u8BFB\u5230\u5BC6\u94A5\uFF1A\u6807\u51C6\u8F93\u5165\u51FA\u9519\uFF08${briefReason(error)}\uFF09`)));
|
|
376
380
|
const onAbort = () => settle(() => reject(interruptedError(CANCELLED)));
|
|
377
381
|
stdin.on("data", onData);
|
|
@@ -416,7 +420,7 @@ async function readNewKey(io) {
|
|
|
416
420
|
|
|
417
421
|
// package.json
|
|
418
422
|
var name = "bukesiyi-cli";
|
|
419
|
-
var version = "0.
|
|
423
|
+
var version = "0.4.0";
|
|
420
424
|
|
|
421
425
|
// src/version.ts
|
|
422
426
|
var PACKAGE_NAME = name;
|
|
@@ -530,6 +534,7 @@ var ME_PATH = "/api/open/v1/me";
|
|
|
530
534
|
var MAX_BODY_BYTES = 1024 * 1024;
|
|
531
535
|
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
536
|
var EXIT_BY_SERVER_CODE = {
|
|
537
|
+
OPEN_API_IDEMPOTENCY_CONFLICT: EXIT.QUOTE_CHANGED,
|
|
533
538
|
OPEN_API_INSUFFICIENT_BALANCE: EXIT.FUNDS,
|
|
534
539
|
OPEN_API_QUOTE_CHANGED: EXIT.QUOTE_CHANGED,
|
|
535
540
|
OPEN_API_QUOTE_REQUIRED: EXIT.QUOTE_CHANGED,
|
|
@@ -765,6 +770,9 @@ async function postJson(baseUrl, apiKey, path, body, idempotencyKey, deps) {
|
|
|
765
770
|
deps
|
|
766
771
|
);
|
|
767
772
|
}
|
|
773
|
+
async function patchJson(baseUrl, apiKey, path, body, idempotencyKey, deps) {
|
|
774
|
+
return requestJson(baseUrl, apiKey, { method: "PATCH", path, body: JSON.stringify(body), contentType: "application/json", idempotencyKey }, deps);
|
|
775
|
+
}
|
|
768
776
|
async function putRaw(baseUrl, apiKey, path, bytes, contentType, idempotencyKey, deps) {
|
|
769
777
|
return requestJson(baseUrl, apiKey, { method: "PUT", path, body: bytes, contentType, idempotencyKey }, deps);
|
|
770
778
|
}
|
|
@@ -798,6 +806,55 @@ async function downloadFile(baseUrl, apiKey, path, deps) {
|
|
|
798
806
|
}
|
|
799
807
|
return { bytes: result.bytes, filename: filenameFromDisposition(result.headers.get("content-disposition")) };
|
|
800
808
|
}
|
|
809
|
+
async function downloadAssetFile(baseUrl, apiKey, path, deps, options) {
|
|
810
|
+
if (!/^\/api\/open\/v1\//u.test(path) || path.includes("#")) throw unreadableResponse(0);
|
|
811
|
+
const origin = normalizeBaseUrl(baseUrl);
|
|
812
|
+
assertKeyFormat(apiKey);
|
|
813
|
+
assertReachedDirectly(origin, deps.env);
|
|
814
|
+
const result = await exchange(`${origin}${path}`, apiKey, downloadPlan(path, deps), deps, origin);
|
|
815
|
+
if ("redirectedTo" in result) throw redirectError(result.redirectedTo);
|
|
816
|
+
if (result.status === 202) throw new CliError({
|
|
817
|
+
code: "CLI_DOWNLOAD_NOT_READY",
|
|
818
|
+
exitCode: EXIT.RETRY_LATER,
|
|
819
|
+
retryable: true,
|
|
820
|
+
httpStatus: 202,
|
|
821
|
+
message: "\u4E0B\u8F7D\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002\u672C\u6B21\u672A\u4FDD\u5B58\u6587\u4EF6\u3002"
|
|
822
|
+
});
|
|
823
|
+
if (result.status < 200 || result.status >= 300) {
|
|
824
|
+
const parsed = parseJson(result.bytes.toString("utf8"));
|
|
825
|
+
throw (parsed && serverError(result.status, parsed.value, apiKey)) ?? unreadableResponse(result.status);
|
|
826
|
+
}
|
|
827
|
+
const mime = result.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase();
|
|
828
|
+
if (result.status !== 200 || result.bytes.length === 0 || !mime || !options.allowedMimeTypes.includes(mime)) throw unreadableResponse(result.status);
|
|
829
|
+
const declaredLength = result.headers.get("content-length");
|
|
830
|
+
if (declaredLength !== null && (!/^\d+$/u.test(declaredLength) || Number(declaredLength) !== result.bytes.byteLength)) throw unreadableResponse(result.status);
|
|
831
|
+
const sha256 = result.headers.get("x-content-sha256");
|
|
832
|
+
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);
|
|
833
|
+
if (!assetMimeMatchesBytes(mime, result.bytes)) throw unreadableResponse(result.status);
|
|
834
|
+
return { bytes: result.bytes, filename: filenameFromDisposition(result.headers.get("content-disposition")) };
|
|
835
|
+
}
|
|
836
|
+
function assetMimeMatchesBytes(mime, bytes) {
|
|
837
|
+
if (mime === "image/png") return bytes.length >= 8 && bytes.subarray(0, 8).toString("hex") === "89504e470d0a1a0a";
|
|
838
|
+
if (mime === "image/jpeg") return bytes.length >= 3 && bytes.subarray(0, 3).toString("hex") === "ffd8ff";
|
|
839
|
+
if (mime === "image/webp") return bytes.length >= 12 && bytes.toString("ascii", 0, 4) === "RIFF" && bytes.toString("ascii", 8, 12) === "WEBP";
|
|
840
|
+
if (mime === "video/quicktime" && bytes.length >= 8 && ["wide", "free", "mdat", "moov"].includes(bytes.toString("latin1", 4, 8))) {
|
|
841
|
+
const boxSize = bytes.readUInt32BE(0);
|
|
842
|
+
return boxSize === 0 || boxSize === 1 || boxSize >= 8 && boxSize <= bytes.length;
|
|
843
|
+
}
|
|
844
|
+
if (["video/mp4", "video/quicktime", "audio/mp4"].includes(mime)) return bytes.length >= 12 && bytes.toString("ascii", 4, 8) === "ftyp";
|
|
845
|
+
if (mime === "audio/wav" || mime === "audio/x-wav") return bytes.length > 44 && bytes.toString("ascii", 0, 4) === "RIFF" && bytes.toString("ascii", 8, 12) === "WAVE";
|
|
846
|
+
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"));
|
|
847
|
+
if (mime === "audio/mpeg") return bytes.length >= 3 && (bytes.toString("ascii", 0, 3) === "ID3" || bytes[0] === 255 && (bytes[1] & 224) === 224);
|
|
848
|
+
if (mime === "application/pdf") {
|
|
849
|
+
let offset = bytes.length >= 3 && bytes.subarray(0, 3).toString("hex") === "efbbbf" ? 3 : 0;
|
|
850
|
+
const limit = Math.min(bytes.length, 1024);
|
|
851
|
+
while (offset < limit && [0, 9, 10, 12, 13, 32].includes(bytes[offset])) offset += 1;
|
|
852
|
+
return offset + 5 <= limit && bytes.toString("latin1", offset, offset + 5) === "%PDF-";
|
|
853
|
+
}
|
|
854
|
+
if (mime === "application/zip" || mime === "application/vnd.openxmlformats-officedocument.wordprocessingml.document") return bytes.length >= 4 && bytes.subarray(0, 4).toString("hex") === "504b0304";
|
|
855
|
+
if (mime === "text/plain" || mime === "text/markdown" || mime === "text/csv") return !bytes.includes(0);
|
|
856
|
+
return false;
|
|
857
|
+
}
|
|
801
858
|
function downloadPlan(path, deps) {
|
|
802
859
|
return {
|
|
803
860
|
method: "GET",
|
|
@@ -943,7 +1000,7 @@ function parseQuoteValue(value) {
|
|
|
943
1000
|
const numbers = ["durationMilliseconds", "memberMilliseconds", "excessMilliseconds", "credits"].map(
|
|
944
1001
|
(field) => numberOrUndefined(value[field])
|
|
945
1002
|
);
|
|
946
|
-
if (problems.length > 0 || numbers.some((
|
|
1003
|
+
if (problems.length > 0 || numbers.some((entry2) => entry2 === void 0)) return null;
|
|
947
1004
|
const [durationMilliseconds, memberMilliseconds, excessMilliseconds, credits] = numbers;
|
|
948
1005
|
return {
|
|
949
1006
|
quoteHash: text(value.quoteHash),
|
|
@@ -986,7 +1043,7 @@ function parseDramaMoney(value) {
|
|
|
986
1043
|
const problems = [];
|
|
987
1044
|
const text = required(problems);
|
|
988
1045
|
const numbers = ["held", "settled", "released", "refunded"].map((field) => numberOrUndefined(value[field]));
|
|
989
|
-
if (numbers.some((
|
|
1046
|
+
if (numbers.some((entry2) => entry2 === void 0)) return null;
|
|
990
1047
|
const [held, settled, released, refunded] = numbers;
|
|
991
1048
|
const currency = text(value.currency);
|
|
992
1049
|
return problems.length > 0 ? null : { currency, held, settled, released, refunded };
|
|
@@ -1163,12 +1220,12 @@ async function getBalance(baseUrl, apiKey, deps) {
|
|
|
1163
1220
|
if (!balance2 || !isRecord2(reply.body)) throw unreadableResponse(reply.status);
|
|
1164
1221
|
return { view: balance2, raw: reply.body };
|
|
1165
1222
|
}
|
|
1166
|
-
async function createProduct(baseUrl, apiKey, name2, category, idempotencyKey, deps) {
|
|
1223
|
+
async function createProduct(baseUrl, apiKey, name2, category, idempotencyKey, deps, fields3 = {}) {
|
|
1167
1224
|
const reply = await postJson(
|
|
1168
1225
|
baseUrl,
|
|
1169
1226
|
apiKey,
|
|
1170
1227
|
"/api/open/v1/products",
|
|
1171
|
-
{ name: name2, ...category === void 0 ? {} : { category } },
|
|
1228
|
+
{ ...fields3, name: name2, ...category === void 0 ? {} : { category } },
|
|
1172
1229
|
idempotencyKey,
|
|
1173
1230
|
deps
|
|
1174
1231
|
);
|
|
@@ -1277,18 +1334,6 @@ async function createVideoRun(baseUrl, apiKey, body, idempotencyKey, deps) {
|
|
|
1277
1334
|
async function getVideoRun(baseUrl, apiKey, runId, deps) {
|
|
1278
1335
|
return runReplyOf(await getJson(baseUrl, apiKey, `/api/open/v1/videos/${encodeURIComponent(runId)}`, deps));
|
|
1279
1336
|
}
|
|
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
1337
|
async function confirmVideoProduction(baseUrl, apiKey, runId, expectedVersion, confirmation, idempotencyKey, deps) {
|
|
1293
1338
|
return runReplyOf(
|
|
1294
1339
|
await postJson(
|
|
@@ -1363,44 +1408,44 @@ var RUN_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["succeeded", "failed", "can
|
|
|
1363
1408
|
var RUN_WAITING_FOR_USER_STATUSES = /* @__PURE__ */ new Set(["needs_input", "awaiting_reply", "awaiting_confirmation"]);
|
|
1364
1409
|
var DRAMA_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["delivered", "failed", "canceled", "partial"]);
|
|
1365
1410
|
var DRAMA_WAITING_FOR_USER_STATUSES = /* @__PURE__ */ new Set(["needs_attention"]);
|
|
1366
|
-
async function awaitTemplateShortOrder(baseUrl, apiKey, start, deps,
|
|
1411
|
+
async function awaitTemplateShortOrder(baseUrl, apiKey, start, deps, wait2) {
|
|
1367
1412
|
let current = start;
|
|
1368
1413
|
if (ORDER_TERMINAL_STATUSES.has(current.view.status)) return { value: current, timedOut: false };
|
|
1369
|
-
const deadline =
|
|
1414
|
+
const deadline = wait2.now().getTime() + wait2.timeoutMs;
|
|
1370
1415
|
let interval = FIRST_POLL_INTERVAL_MS;
|
|
1371
1416
|
let said = current.view.status;
|
|
1372
1417
|
for (; ; ) {
|
|
1373
|
-
const remaining = deadline -
|
|
1418
|
+
const remaining = deadline - wait2.now().getTime();
|
|
1374
1419
|
if (remaining <= 0) return { value: current, timedOut: true };
|
|
1375
1420
|
current = await retainTaskOnError(() => taskRecovery("shorts", current.view.id, current.view.status, baseUrl), async () => {
|
|
1376
|
-
await
|
|
1421
|
+
await wait2.sleep(Math.max(Math.min(interval, remaining), 1));
|
|
1377
1422
|
interval = Math.min(Math.ceil(interval * 1.5), MAX_POLL_INTERVAL_MS);
|
|
1378
1423
|
return getTemplateShortOrder(baseUrl, apiKey, current.view.id, deps);
|
|
1379
1424
|
});
|
|
1380
1425
|
if (current.view.status !== said) {
|
|
1381
|
-
|
|
1426
|
+
wait2.note?.(`\u72B6\u6001\u53D8\u6210 ${current.view.status}`);
|
|
1382
1427
|
said = current.view.status;
|
|
1383
1428
|
}
|
|
1384
1429
|
if (ORDER_TERMINAL_STATUSES.has(current.view.status)) return { value: current, timedOut: false };
|
|
1385
1430
|
}
|
|
1386
1431
|
}
|
|
1387
|
-
async function awaitVideoRun(baseUrl, apiKey, start, deps,
|
|
1432
|
+
async function awaitVideoRun(baseUrl, apiKey, start, deps, wait2) {
|
|
1388
1433
|
let current = start;
|
|
1389
1434
|
if (runStopped(current.view.status)) return { value: current, timedOut: false };
|
|
1390
|
-
const deadline =
|
|
1435
|
+
const deadline = wait2.now().getTime() + wait2.timeoutMs;
|
|
1391
1436
|
let interval = FIRST_POLL_INTERVAL_MS;
|
|
1392
1437
|
let said = current.view.status;
|
|
1393
1438
|
for (; ; ) {
|
|
1394
|
-
const remaining = deadline -
|
|
1439
|
+
const remaining = deadline - wait2.now().getTime();
|
|
1395
1440
|
if (remaining <= 0) return { value: current, timedOut: true };
|
|
1396
1441
|
const preferred = current.view.pollAfterMs !== null && current.view.pollAfterMs > 0 ? current.view.pollAfterMs : interval;
|
|
1397
1442
|
current = await retainTaskOnError(() => taskRecovery("videos", current.view.rootRunId, current.view.status, baseUrl, current.view.failure?.code), async () => {
|
|
1398
|
-
await
|
|
1443
|
+
await wait2.sleep(Math.max(Math.min(preferred, remaining), 1));
|
|
1399
1444
|
interval = Math.min(Math.ceil(interval * 1.5), MAX_POLL_INTERVAL_MS);
|
|
1400
1445
|
return getVideoRun(baseUrl, apiKey, current.view.rootRunId, deps);
|
|
1401
1446
|
});
|
|
1402
1447
|
if (current.view.status !== said) {
|
|
1403
|
-
|
|
1448
|
+
wait2.note?.(`\u72B6\u6001\u53D8\u6210 ${current.view.status}`);
|
|
1404
1449
|
said = current.view.status;
|
|
1405
1450
|
}
|
|
1406
1451
|
if (runStopped(current.view.status)) return { value: current, timedOut: false };
|
|
@@ -1409,22 +1454,22 @@ async function awaitVideoRun(baseUrl, apiKey, start, deps, wait) {
|
|
|
1409
1454
|
function runStopped(status4) {
|
|
1410
1455
|
return RUN_TERMINAL_STATUSES.has(status4) || RUN_WAITING_FOR_USER_STATUSES.has(status4);
|
|
1411
1456
|
}
|
|
1412
|
-
async function awaitDramaOrder(baseUrl, apiKey, start, deps,
|
|
1457
|
+
async function awaitDramaOrder(baseUrl, apiKey, start, deps, wait2) {
|
|
1413
1458
|
let current = start;
|
|
1414
1459
|
if (dramaStopped(current.view.status)) return { value: current, timedOut: false };
|
|
1415
|
-
const deadline =
|
|
1460
|
+
const deadline = wait2.now().getTime() + wait2.timeoutMs;
|
|
1416
1461
|
let interval = FIRST_POLL_INTERVAL_MS;
|
|
1417
1462
|
let said = current.view.status;
|
|
1418
1463
|
for (; ; ) {
|
|
1419
|
-
const remaining = deadline -
|
|
1464
|
+
const remaining = deadline - wait2.now().getTime();
|
|
1420
1465
|
if (remaining <= 0) return { value: current, timedOut: true };
|
|
1421
1466
|
current = await retainTaskOnError(() => taskRecovery("drama", current.view.id, current.view.status, baseUrl), async () => {
|
|
1422
|
-
await
|
|
1467
|
+
await wait2.sleep(Math.max(Math.min(interval, remaining), 1));
|
|
1423
1468
|
interval = Math.min(Math.ceil(interval * 1.5), MAX_POLL_INTERVAL_MS);
|
|
1424
1469
|
return getDramaOrder(baseUrl, apiKey, current.view.id, deps);
|
|
1425
1470
|
});
|
|
1426
1471
|
if (current.view.status !== said) {
|
|
1427
|
-
|
|
1472
|
+
wait2.note?.(`\u72B6\u6001\u53D8\u6210 ${current.view.status}`);
|
|
1428
1473
|
said = current.view.status;
|
|
1429
1474
|
}
|
|
1430
1475
|
if (dramaStopped(current.view.status)) return { value: current, timedOut: false };
|
|
@@ -1434,6 +1479,41 @@ function dramaStopped(status4) {
|
|
|
1434
1479
|
return DRAMA_TERMINAL_STATUSES.has(status4) || DRAMA_WAITING_FOR_USER_STATUSES.has(status4);
|
|
1435
1480
|
}
|
|
1436
1481
|
|
|
1482
|
+
// src/client-graphic.ts
|
|
1483
|
+
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"]);
|
|
1484
|
+
function graphicDocument(value) {
|
|
1485
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw invalid2();
|
|
1486
|
+
const clean = (item) => {
|
|
1487
|
+
if (item === null || ["string", "number", "boolean"].includes(typeof item)) return item;
|
|
1488
|
+
if (Array.isArray(item)) return item.map(clean);
|
|
1489
|
+
if (typeof item !== "object") return void 0;
|
|
1490
|
+
return Object.fromEntries(Object.entries(item).filter(([key]) => keys.has(key)).map(([key, child]) => [key, clean(child)]));
|
|
1491
|
+
};
|
|
1492
|
+
return clean(value);
|
|
1493
|
+
}
|
|
1494
|
+
function graphicRun(value) {
|
|
1495
|
+
const body = graphicDocument(value);
|
|
1496
|
+
const run2 = body.run;
|
|
1497
|
+
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();
|
|
1498
|
+
return run2;
|
|
1499
|
+
}
|
|
1500
|
+
function graphicQuote(value) {
|
|
1501
|
+
const body = graphicDocument(value);
|
|
1502
|
+
const quote3 = body.quote;
|
|
1503
|
+
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();
|
|
1504
|
+
return quote3;
|
|
1505
|
+
}
|
|
1506
|
+
function invalid2() {
|
|
1507
|
+
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" });
|
|
1508
|
+
}
|
|
1509
|
+
var graphicPath = (id) => `/api/open/v1/graphic/runs/${encodeURIComponent(id)}`;
|
|
1510
|
+
async function getGraphicRun(baseUrl, apiKey, id, deps) {
|
|
1511
|
+
return graphicRun((await getJson(baseUrl, apiKey, graphicPath(id), deps)).body);
|
|
1512
|
+
}
|
|
1513
|
+
async function getGraphicQuote(baseUrl, apiKey, id, request, key, deps) {
|
|
1514
|
+
return graphicQuote((await postJson(baseUrl, apiKey, `${graphicPath(id)}/quote`, request, key, deps)).body);
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1437
1517
|
// src/credentials.ts
|
|
1438
1518
|
import { randomBytes } from "node:crypto";
|
|
1439
1519
|
import { constants } from "node:fs";
|
|
@@ -1716,26 +1796,6 @@ function keySourceLine(resolved) {
|
|
|
1716
1796
|
return resolved.source === "env" ? "\u5BC6\u94A5\u6765\u81EA\uFF1A\u73AF\u5883\u53D8\u91CF BUKE_API_KEY" : `\u5BC6\u94A5\u6765\u81EA\uFF1A${resolved.credentialsPath}`;
|
|
1717
1797
|
}
|
|
1718
1798
|
|
|
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
1799
|
// src/commands/shared.ts
|
|
1740
1800
|
import { randomUUID } from "node:crypto";
|
|
1741
1801
|
import { readFile } from "node:fs/promises";
|
|
@@ -1799,7 +1859,7 @@ async function readStdinAll(io, maxBytes, what) {
|
|
|
1799
1859
|
if (stdin.readableEnded === true) return "";
|
|
1800
1860
|
const chunks = [];
|
|
1801
1861
|
let size = 0;
|
|
1802
|
-
await new Promise((
|
|
1862
|
+
await new Promise((resolve2, reject) => {
|
|
1803
1863
|
const toBuffer2 = (chunk) => typeof chunk === "string" ? Buffer.from(chunk, "utf8") : Buffer.from(chunk);
|
|
1804
1864
|
const onData = (chunk) => {
|
|
1805
1865
|
const piece = toBuffer2(chunk);
|
|
@@ -1813,7 +1873,7 @@ async function readStdinAll(io, maxBytes, what) {
|
|
|
1813
1873
|
};
|
|
1814
1874
|
const onEnd = () => {
|
|
1815
1875
|
cleanup();
|
|
1816
|
-
|
|
1876
|
+
resolve2();
|
|
1817
1877
|
};
|
|
1818
1878
|
const onError = (error) => {
|
|
1819
1879
|
cleanup();
|
|
@@ -1856,8 +1916,25 @@ function sniffImageContentType(bytes) {
|
|
|
1856
1916
|
}
|
|
1857
1917
|
return void 0;
|
|
1858
1918
|
}
|
|
1919
|
+
async function readUploadFile(path) {
|
|
1920
|
+
const { stat: stat2 } = await import("node:fs/promises");
|
|
1921
|
+
try {
|
|
1922
|
+
const info = await stat2(path);
|
|
1923
|
+
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");
|
|
1924
|
+
const bytes = await readFile(path);
|
|
1925
|
+
if (bytes.byteLength === 0 || bytes.byteLength > MAX_IMAGE_BYTES) throw usageError("\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8D85\u51FA\u5141\u8BB8\u8303\u56F4");
|
|
1926
|
+
const image = sniffImageContentType(bytes);
|
|
1927
|
+
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);
|
|
1928
|
+
return { bytes, contentType };
|
|
1929
|
+
} catch (error) {
|
|
1930
|
+
if (error instanceof CliError) throw error;
|
|
1931
|
+
throw usageError(`\u65E0\u6CD5\u8BFB\u53D6\u4E0A\u4F20\u6587\u4EF6\uFF1A${briefReason(error)}`);
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1859
1934
|
|
|
1860
1935
|
// src/commands/shorts.ts
|
|
1936
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
1937
|
+
import { writeFile } from "node:fs/promises";
|
|
1861
1938
|
var SUBCOMMANDS = "catalog\u3001upload\u3001quote\u3001order\u3001status\u3001download \u548C cancel";
|
|
1862
1939
|
async function shorts(context) {
|
|
1863
1940
|
const { args } = context;
|
|
@@ -1891,7 +1968,7 @@ function waitControls(io, values, note) {
|
|
|
1891
1968
|
return {
|
|
1892
1969
|
timeoutMs: timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3) * 1e3,
|
|
1893
1970
|
now: io.now ?? (() => /* @__PURE__ */ new Date()),
|
|
1894
|
-
sleep: io.sleep ?? ((ms) => new Promise((
|
|
1971
|
+
sleep: io.sleep ?? ((ms) => new Promise((resolve2) => setTimeout(resolve2, ms))),
|
|
1895
1972
|
note
|
|
1896
1973
|
};
|
|
1897
1974
|
}
|
|
@@ -2045,11 +2122,591 @@ async function saveDownload(target, bytes) {
|
|
|
2045
2122
|
message: `\u6210\u7247\u5199\u4E0D\u8FDB ${target}\uFF08${briefReason(error)}\uFF09`
|
|
2046
2123
|
});
|
|
2047
2124
|
}
|
|
2048
|
-
return { path: target, bytes: bytes.byteLength, sha256:
|
|
2125
|
+
return { path: target, bytes: bytes.byteLength, sha256: createHash2("sha256").update(bytes).digest("hex") };
|
|
2126
|
+
}
|
|
2127
|
+
|
|
2128
|
+
// src/commands/graphic.ts
|
|
2129
|
+
var graphicCommand = {
|
|
2130
|
+
run: graphic,
|
|
2131
|
+
acceptsBaseUrl: true,
|
|
2132
|
+
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"],
|
|
2133
|
+
positionals: ["subcommand", "run-id", "image-or-message-id"],
|
|
2134
|
+
help: [
|
|
2135
|
+
"\u7528\u6CD5\uFF1Abuke graphic <\u5B50\u547D\u4EE4> [\u9879\u76EEID] [\u56FE\u7247\u6216\u6D88\u606FID] [\u9009\u9879]",
|
|
2136
|
+
"",
|
|
2137
|
+
"create --text <\u5236\u4F5C\u8981\u6C42> [--product <\u4EA7\u54C1ID>] [--model <\u6A21\u578B>] [--aspect-ratio <\u753B\u5E45>] [--wait]",
|
|
2138
|
+
"list | templates | status <\u9879\u76EEID> [--wait] | plan <\u9879\u76EEID> | versions <\u9879\u76EEID>",
|
|
2139
|
+
"message <\u9879\u76EEID> --text <\u8981\u6C42> [--attachment-ids <ID,ID>] [--edit-image <\u56FE\u7247ID>] [--source-image <\u56FE\u7247ID>] [--choice <\u9009\u9879ID>] [--wait]",
|
|
2140
|
+
"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",
|
|
2141
|
+
"quote <\u9879\u76EEID> [--image-indexes <1,2>]\uFF1A\u8BFB\u53D6\u6240\u9009\u65B9\u6848\u62A5\u4EF7\u3002",
|
|
2142
|
+
"generate <\u9879\u76EEID> [--image-indexes <1,2>] [--quote-hash <\u62A5\u4EF7\u54C8\u5E0C>] --yes [--wait]\uFF1A\u786E\u8BA4\u5F53\u524D\u62A5\u4EF7\u5E76\u751F\u6210\u3002",
|
|
2143
|
+
"\u5C40\u90E8\u4FEE\u6539\uFF1Aquote/generate <\u9879\u76EEID> --edit-image <\u56FE\u7247ID> --text <\u4FEE\u6539\u8981\u6C42> [--mask <\u9009\u533AID>]\u3002generate \u4ECD\u987B --yes\u3002",
|
|
2144
|
+
"model <\u9879\u76EEID> --model <\u6A21\u578B> | quality <\u9879\u76EEID> --quality <\u6863\u4F4D> | bind-product <\u9879\u76EEID> --product <\u4EA7\u54C1ID>",
|
|
2145
|
+
"upload <\u9879\u76EEID> --file <\u56FE\u7247\u6216\u6587\u6863> | attachments <\u9879\u76EEID> [--attachment-ids <ID,ID>] [--limit <\u6570\u91CF>] [--offset <\u504F\u79FB>]",
|
|
2146
|
+
"mask <\u9879\u76EEID> <\u56FE\u7247ID> --file <PNG\u9009\u533A> | save-edit <\u9879\u76EEID> <\u56FE\u7247ID> --file <\u7F16\u8F91\u540E\u56FE\u7247>",
|
|
2147
|
+
"download <\u9879\u76EEID> <\u56FE\u7247ID> [--out <\u6587\u4EF6>] | download <\u9879\u76EEID> --all --out <\u76EE\u5F55>",
|
|
2148
|
+
"download <\u9879\u76EEID> --attachment <\u9644\u4EF6ID> --out <\u6587\u4EF6>",
|
|
2149
|
+
"cancel <\u9879\u76EEID> --generation-order <\u8BA2\u5355ID>\uFF1A\u53D6\u6D88\u5C1A\u672A\u51BB\u7ED3\u8D39\u7528\u7684\u7B49\u5F85\u4F59\u989D\u8BA2\u5355\u3002",
|
|
2150
|
+
"\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",
|
|
2151
|
+
"\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"
|
|
2152
|
+
].join("\n")
|
|
2153
|
+
};
|
|
2154
|
+
var imageMimes = ["image/png", "image/jpeg", "image/webp"];
|
|
2155
|
+
var documentMimes = [...imageMimes, "application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "text/plain", "text/markdown"];
|
|
2156
|
+
function required2(value, label) {
|
|
2157
|
+
if (!value?.trim()) throw usageError(`\u8BF7\u63D0\u4F9B${label}`);
|
|
2158
|
+
return value.trim();
|
|
2159
|
+
}
|
|
2160
|
+
function indexes(value) {
|
|
2161
|
+
if (value === void 0) return void 0;
|
|
2162
|
+
const result = value.split(",").map((item) => Number(item.trim()));
|
|
2163
|
+
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");
|
|
2164
|
+
return result;
|
|
2165
|
+
}
|
|
2166
|
+
function selection(context) {
|
|
2167
|
+
const editImage = textOption(context.values, "edit-image");
|
|
2168
|
+
const imageIndexes = indexes(textOption(context.values, "image-indexes"));
|
|
2169
|
+
if (editImage) {
|
|
2170
|
+
if (imageIndexes) throw usageError("\u5C40\u90E8\u4FEE\u6539\u4E0D\u80FD\u540C\u65F6\u6307\u5B9A --image-indexes");
|
|
2171
|
+
return { edit: {
|
|
2172
|
+
imageId: editImage,
|
|
2173
|
+
text: required2(textOption(context.values, "text"), " --text <\u4FEE\u6539\u8981\u6C42>"),
|
|
2174
|
+
...textOption(context.values, "mask") ? { maskId: textOption(context.values, "mask") } : {}
|
|
2175
|
+
} };
|
|
2176
|
+
}
|
|
2177
|
+
return imageIndexes ? { imageIndexes } : {};
|
|
2178
|
+
}
|
|
2179
|
+
function lines(run2) {
|
|
2180
|
+
return [
|
|
2181
|
+
`\u56FE\u6587\u9879\u76EE\uFF1A${singleLine(run2.id)}`,
|
|
2182
|
+
`\u72B6\u6001\uFF1A${singleLine(run2.status)}`,
|
|
2183
|
+
`\u56FE\u7247\uFF1A${run2.images.length} \u5F20`,
|
|
2184
|
+
...run2.status === "quotable" ? [`\u67E5\u8BE2\u62A5\u4EF7\uFF1Abuke graphic quote ${run2.id}`] : [],
|
|
2185
|
+
...run2.messages.slice(-1).map((message2) => `${message2.role === "assistant" ? "\u56DE\u590D" : "\u6D88\u606F"}\uFF1A${singleLine(String(message2.text ?? ""))}`)
|
|
2186
|
+
];
|
|
2187
|
+
}
|
|
2188
|
+
async function wait(context, baseUrl, apiKey, initial) {
|
|
2189
|
+
if (context.values.wait !== true) return initial;
|
|
2190
|
+
const now = context.io.now ?? (() => /* @__PURE__ */ new Date());
|
|
2191
|
+
const sleep = context.io.sleep ?? ((ms) => new Promise((resolve2) => setTimeout(resolve2, ms)));
|
|
2192
|
+
const until = now().getTime() + timeoutSecondsOf(context.values, DEFAULT_WAIT_TIMEOUT_MS / 1e3) * 1e3;
|
|
2193
|
+
let run2 = initial;
|
|
2194
|
+
return retainTaskOnError(() => taskRecovery("graphic", run2.id, run2.status, baseUrl), async () => {
|
|
2195
|
+
while (["preparing", "generating"].includes(run2.status)) {
|
|
2196
|
+
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` });
|
|
2197
|
+
await sleep(1500);
|
|
2198
|
+
run2 = await getGraphicRun(baseUrl, apiKey, run2.id, context.io);
|
|
2199
|
+
}
|
|
2200
|
+
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` });
|
|
2201
|
+
return run2;
|
|
2202
|
+
});
|
|
2203
|
+
}
|
|
2204
|
+
async function uploadFile(path) {
|
|
2205
|
+
let bytes;
|
|
2206
|
+
try {
|
|
2207
|
+
bytes = await readFile2(path);
|
|
2208
|
+
} catch {
|
|
2209
|
+
throw usageError(`\u65E0\u6CD5\u8BFB\u53D6\u6587\u4EF6\uFF1A${path}`);
|
|
2210
|
+
}
|
|
2211
|
+
if (!bytes.length || bytes.length > 64 * 1024 * 1024) throw usageError("\u6587\u4EF6\u4E0D\u80FD\u4E3A\u7A7A\u4E14\u4E0D\u80FD\u8D85\u8FC7 64 MiB");
|
|
2212
|
+
return bytes;
|
|
2213
|
+
}
|
|
2214
|
+
async function graphic(context) {
|
|
2215
|
+
const { args, values, io, out } = context;
|
|
2216
|
+
const command = required2(args[0], "\u56FE\u6587\u5B50\u547D\u4EE4\uFF1B\u8FD0\u884C buke graphic --help \u67E5\u770B\u8BF4\u660E");
|
|
2217
|
+
const known = ["create", "list", "templates", "status", "message", "retry", "plan", "quote", "generate", "model", "quality", "bind-product", "attachments", "upload", "versions", "download", "save-edit", "mask", "cancel"];
|
|
2218
|
+
if (!known.includes(command)) throw usageError(`\u672A\u77E5\u56FE\u6587\u5B50\u547D\u4EE4\uFF1A${command}`);
|
|
2219
|
+
const id = ["create", "list", "templates"].includes(command) ? void 0 : required2(args[1], "\u56FE\u6587\u9879\u76EE ID");
|
|
2220
|
+
const selected = ["quote", "generate"].includes(command) ? selection(context) : {};
|
|
2221
|
+
const key = idempotencyKeyOf(values);
|
|
2222
|
+
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2223
|
+
const path = id ? graphicPath(id) : "/api/open/v1/graphic/runs";
|
|
2224
|
+
if (["list", "templates"].includes(command)) {
|
|
2225
|
+
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);
|
|
2226
|
+
const rows = result[command === "list" ? "runs" : "templates"] ?? [];
|
|
2227
|
+
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);
|
|
2228
|
+
return;
|
|
2229
|
+
}
|
|
2230
|
+
if (command === "create") {
|
|
2231
|
+
const request = {
|
|
2232
|
+
productId: textOption(values, "product"),
|
|
2233
|
+
title: textOption(values, "title"),
|
|
2234
|
+
text: textOption(values, "text"),
|
|
2235
|
+
imageModel: textOption(values, "model"),
|
|
2236
|
+
aspectRatio: textOption(values, "aspect-ratio"),
|
|
2237
|
+
templateId: textOption(values, "template")
|
|
2238
|
+
};
|
|
2239
|
+
const initial = await retainSubmissionOnError("graphic", key, baseUrl, async () => graphicRun((await postJson(baseUrl, apiKey, path, request, key, io)).body));
|
|
2240
|
+
const run2 = await retainTaskOnError(() => ({ ...taskRecovery("graphic", initial.id, initial.status, baseUrl), idempotencyKey: key }), () => wait(context, baseUrl, apiKey, initial));
|
|
2241
|
+
out.result([...lines(run2), `\u5E42\u7B49\u952E\uFF1A${key}`], { run: run2, idempotencyKey: key });
|
|
2242
|
+
return;
|
|
2243
|
+
}
|
|
2244
|
+
if (command === "download") {
|
|
2245
|
+
const attachment = textOption(values, "attachment");
|
|
2246
|
+
if (values.all === true && (attachment || args[2])) throw usageError("--all \u4E0D\u80FD\u540C\u65F6\u6307\u5B9A\u56FE\u7247\u6216\u9644\u4EF6 ID");
|
|
2247
|
+
const results = [];
|
|
2248
|
+
if (values.all === true) {
|
|
2249
|
+
const directory = resolve(required2(textOption(values, "out"), " --out <\u76EE\u5F55>"));
|
|
2250
|
+
const run2 = await getGraphicRun(baseUrl, apiKey, id, io);
|
|
2251
|
+
if (!run2.images.length) throw usageError("\u8BE5\u9879\u76EE\u6682\u65E0\u53EF\u4E0B\u8F7D\u7684\u56FE\u7247");
|
|
2252
|
+
await mkdir2(directory, { recursive: true });
|
|
2253
|
+
for (const image of run2.images) {
|
|
2254
|
+
const imageId = required2(typeof image.id === "string" ? image.id : void 0, "\u56FE\u7247 ID");
|
|
2255
|
+
const file = await downloadAssetFile(baseUrl, apiKey, `${path}/images/${encodeURIComponent(imageId)}/download`, io, { allowedMimeTypes: imageMimes, requireSha256: true });
|
|
2256
|
+
results.push(await saveDownload(join2(directory, basename(file.filename ?? `${imageId}.png`)), file.bytes));
|
|
2257
|
+
}
|
|
2258
|
+
} else {
|
|
2259
|
+
const imageId = attachment ?? required2(args[2], "\u56FE\u7247 ID\uFF0C\u6216\u4F7F\u7528 --all");
|
|
2260
|
+
const file = await downloadAssetFile(baseUrl, apiKey, `${path}/${attachment ? "attachments" : "images"}/${encodeURIComponent(imageId)}/download`, io, { allowedMimeTypes: attachment ? documentMimes : imageMimes, requireSha256: !attachment });
|
|
2261
|
+
results.push(await saveDownload(resolve(textOption(values, "out") ?? basename(file.filename ?? `${imageId}.png`)), file.bytes));
|
|
2262
|
+
}
|
|
2263
|
+
out.result(results.map((result) => `\u5DF2\u4E0B\u8F7D\uFF1A${result.path}\uFF08${result.bytes} \u5B57\u8282\uFF09`), { downloads: results });
|
|
2264
|
+
return;
|
|
2265
|
+
}
|
|
2266
|
+
if (["quote", "generate"].includes(command)) {
|
|
2267
|
+
let current;
|
|
2268
|
+
let submitted = false;
|
|
2269
|
+
try {
|
|
2270
|
+
current = await getGraphicRun(baseUrl, apiKey, id, io);
|
|
2271
|
+
const quote3 = await getGraphicQuote(baseUrl, apiKey, id, selected, key, io);
|
|
2272
|
+
if (textOption(values, "quote-hash") && values["quote-hash"] !== 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" });
|
|
2273
|
+
if (command === "quote" || values.yes !== true) {
|
|
2274
|
+
out.result([
|
|
2275
|
+
`\u56FE\u6587\u9879\u76EE\uFF1A${id}`,
|
|
2276
|
+
`\u672C\u6B21\u751F\u6210\uFF1A${quote3.imageCount} \u5F20\uFF0C\u9884\u4F30 ${quote3.totalCredits} \u5E03`,
|
|
2277
|
+
`\u62A5\u4EF7\u54C8\u5E0C\uFF1A${quote3.quoteHash}`,
|
|
2278
|
+
...command === "generate" ? ["\u672C\u6B21\u672A\u63D0\u4EA4\u751F\u6210\uFF1B\u786E\u8BA4\u8D39\u7528\u540E\u4F7F\u7528 --yes\u3002"] : []
|
|
2279
|
+
], { quote: quote3, submitted: false });
|
|
2280
|
+
return;
|
|
2281
|
+
}
|
|
2282
|
+
submitted = true;
|
|
2283
|
+
const initial = graphicRun((await postJson(baseUrl, apiKey, `${path}/generate`, { ...selected, quoteHash: quote3.quoteHash, confirmed: true }, key, io)).body);
|
|
2284
|
+
const run2 = await wait(context, baseUrl, apiKey, initial);
|
|
2285
|
+
out.result([...lines(run2), `\u5E42\u7B49\u952E\uFF1A${key}`], { run: run2, idempotencyKey: key });
|
|
2286
|
+
return;
|
|
2287
|
+
} catch (error) {
|
|
2288
|
+
const failure = toCliError(error);
|
|
2289
|
+
const rejected = failure.httpStatus !== void 0 && failure.httpStatus >= 400 && failure.httpStatus < 500 && failure.httpStatus !== 408;
|
|
2290
|
+
throw failure.withRecovery({
|
|
2291
|
+
...taskRecovery("graphic", id, current?.status, baseUrl),
|
|
2292
|
+
acceptance: current ? "confirmed" : "unknown",
|
|
2293
|
+
idempotencyKey: key,
|
|
2294
|
+
operation: "confirm",
|
|
2295
|
+
operationOutcome: !submitted ? "not_submitted" : rejected ? "rejected" : "unknown",
|
|
2296
|
+
...failure.recovery
|
|
2297
|
+
});
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
await retainTaskOnError(() => ({ ...taskRecovery("graphic", id, void 0, baseUrl), acceptance: "unknown", idempotencyKey: key }), async () => {
|
|
2301
|
+
let body;
|
|
2302
|
+
if (["status", "plan", "versions"].includes(command)) {
|
|
2303
|
+
const run2 = await wait(context, baseUrl, apiKey, await getGraphicRun(baseUrl, apiKey, id, io));
|
|
2304
|
+
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 });
|
|
2305
|
+
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 });
|
|
2306
|
+
else out.result(lines(run2), { run: run2 });
|
|
2307
|
+
return;
|
|
2308
|
+
}
|
|
2309
|
+
if (command === "message") {
|
|
2310
|
+
const attachmentIds = textOption(values, "attachment-ids")?.split(",").map((item) => item.trim()).filter(Boolean);
|
|
2311
|
+
const message2 = textOption(values, "text");
|
|
2312
|
+
if (!message2 && !attachmentIds?.length) throw usageError("\u8BF7\u63D0\u4F9B --text \u6216 --attachment-ids");
|
|
2313
|
+
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;
|
|
2314
|
+
} else if (command === "retry") body = (await postJson(baseUrl, apiKey, `${path}/messages/${encodeURIComponent(required2(args[2], "\u6D88\u606F ID"))}/retry`, {}, key, io)).body;
|
|
2315
|
+
else if (["model", "quality", "bind-product"].includes(command)) {
|
|
2316
|
+
const option = command === "bind-product" ? "product" : command;
|
|
2317
|
+
const field = command === "bind-product" ? "productId" : command === "model" ? "imageModel" : "quality";
|
|
2318
|
+
body = (await patchJson(baseUrl, apiKey, path, { [field]: required2(textOption(values, option), ` --${option}`) }, key, io)).body;
|
|
2319
|
+
} 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;
|
|
2320
|
+
else if (command === "attachments") {
|
|
2321
|
+
const params = new URLSearchParams();
|
|
2322
|
+
for (const id2 of textOption(values, "attachment-ids")?.split(",") ?? []) params.append("attachmentId", id2.trim());
|
|
2323
|
+
for (const name2 of ["limit", "offset"]) {
|
|
2324
|
+
const value = textOption(values, name2);
|
|
2325
|
+
if (value !== void 0) params.set(name2, value);
|
|
2326
|
+
}
|
|
2327
|
+
body = (await getJson(baseUrl, apiKey, `${path}/attachments${params.size ? `?${params}` : ""}`, io)).body;
|
|
2328
|
+
} else {
|
|
2329
|
+
const filename = required2(textOption(values, "file"), " --file <\u6587\u4EF6\u8DEF\u5F84>");
|
|
2330
|
+
const bytes = await uploadFile(filename);
|
|
2331
|
+
if (command === "upload") body = (await putRaw(baseUrl, apiKey, `${path}/attachments?name=${encodeURIComponent(basename(filename))}`, bytes, textOption(values, "mime") ?? "application/octet-stream", key, io)).body;
|
|
2332
|
+
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;
|
|
2333
|
+
}
|
|
2334
|
+
const document = graphicDocument(body);
|
|
2335
|
+
if (document.run) {
|
|
2336
|
+
const run2 = await wait(context, baseUrl, apiKey, graphicRun(document));
|
|
2337
|
+
out.result([...lines(run2), `\u5E42\u7B49\u952E\uFF1A${key}`], { ...document, run: run2, idempotencyKey: key });
|
|
2338
|
+
} 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 });
|
|
2339
|
+
});
|
|
2340
|
+
}
|
|
2341
|
+
|
|
2342
|
+
// src/client-creative.ts
|
|
2343
|
+
function creativePath(resource, id, suffix = "") {
|
|
2344
|
+
const prefix = resource === "drama" ? "drama/orders" : resource;
|
|
2345
|
+
return `/api/open/v1/${prefix}${id ? `/${encodeURIComponent(id)}` : ""}${suffix ? `${suffix.startsWith("?") ? "" : "/"}${suffix}` : ""}`;
|
|
2346
|
+
}
|
|
2347
|
+
function creativeObject(value) {
|
|
2348
|
+
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 });
|
|
2349
|
+
return value;
|
|
2350
|
+
}
|
|
2351
|
+
async function getCreative(baseUrl, apiKey, resource, id, suffix, deps) {
|
|
2352
|
+
return creativeObject((await getJson(baseUrl, apiKey, creativePath(resource, id, suffix), deps)).body);
|
|
2353
|
+
}
|
|
2354
|
+
async function postCreative(baseUrl, apiKey, resource, id, suffix, body, key, deps) {
|
|
2355
|
+
try {
|
|
2356
|
+
return creativeObject((await postJson(baseUrl, apiKey, creativePath(resource, id, suffix), body, key, deps)).body);
|
|
2357
|
+
} catch (error) {
|
|
2358
|
+
const failure = toCliError(error);
|
|
2359
|
+
const rejected = failure.httpStatus !== void 0 && failure.httpStatus >= 400 && failure.httpStatus < 500 && failure.httpStatus !== 408;
|
|
2360
|
+
const recovery = taskRecovery(resource, id ?? "", void 0, baseUrl);
|
|
2361
|
+
if (resource === "series") recovery.statusCommand = id ? recovery.statusCommand.replace(" series status ", " series show ") : recovery.statusCommand.replace(" series status ''", " series list");
|
|
2362
|
+
throw failure.withRecovery({
|
|
2363
|
+
...recovery,
|
|
2364
|
+
taskId: id,
|
|
2365
|
+
acceptance: "unknown",
|
|
2366
|
+
idempotencyKey: key,
|
|
2367
|
+
...suffix === "director/confirm" || suffix === "redo" ? { operation: "confirm" } : {},
|
|
2368
|
+
operationOutcome: rejected ? "rejected" : "unknown"
|
|
2369
|
+
});
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
function downloadCreative(baseUrl, apiKey, resource, id, suffix, deps) {
|
|
2373
|
+
return downloadFile(baseUrl, apiKey, creativePath(resource, id, suffix), deps);
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
// src/commands/creative.ts
|
|
2377
|
+
async function creativeData(context) {
|
|
2378
|
+
const path = textOption(context.values, "data");
|
|
2379
|
+
return path ? readPropsArgument(context.io, path, "\u8BF7\u6C42\u53C2\u6570\uFF08--data\uFF09") : {};
|
|
2380
|
+
}
|
|
2381
|
+
function idOf(context) {
|
|
2382
|
+
const id = context.args[1];
|
|
2383
|
+
if (!id?.trim()) throw usageError("\u8BF7\u63D0\u4F9B\u9879\u76EE\u7F16\u53F7");
|
|
2384
|
+
return id.trim();
|
|
2385
|
+
}
|
|
2386
|
+
async function dramaCreative(context) {
|
|
2387
|
+
const [action] = context.args;
|
|
2388
|
+
const id = idOf(context);
|
|
2389
|
+
const { baseUrl, apiKey } = await resolveApiKey(context);
|
|
2390
|
+
const { io, out, values } = context;
|
|
2391
|
+
if (["context", "director", "document", "versions"].includes(action)) {
|
|
2392
|
+
let suffix2 = action;
|
|
2393
|
+
if (action === "document") {
|
|
2394
|
+
const query = new URLSearchParams({ kind: textOption(values, "kind") ?? "screenplay_snapshot" });
|
|
2395
|
+
const episode = textOption(values, "episode-number");
|
|
2396
|
+
if (episode) query.set("episodeNumber", episode);
|
|
2397
|
+
suffix2 += `?${query}`;
|
|
2398
|
+
}
|
|
2399
|
+
const result2 = await getCreative(baseUrl, apiKey, "drama", id, suffix2, io);
|
|
2400
|
+
out.result([typeof result2.content === "string" ? result2.content : JSON.stringify(result2, null, 2)], result2);
|
|
2401
|
+
return;
|
|
2402
|
+
}
|
|
2403
|
+
const body = await creativeData(context);
|
|
2404
|
+
if (action === "director-confirm") {
|
|
2405
|
+
const confirmationId = textOption(values, "confirmation-id") ?? body.confirmationId;
|
|
2406
|
+
const suppliedKind = textOption(values, "kind") ?? body.kind;
|
|
2407
|
+
if (typeof confirmationId !== "string" || !confirmationId) throw usageError("\u8BF7\u4F7F\u7528 drama director \u4E2D\u5F53\u524D\u786E\u8BA4\u5361\u7684 --confirmation-id");
|
|
2408
|
+
if (values.yes !== true) throw usageError("\u8BF7\u6838\u5BF9\u786E\u8BA4\u5361\u7684\u8303\u56F4\u4E0E\u8D39\u7528\uFF0C\u5E76\u6DFB\u52A0 --yes");
|
|
2409
|
+
const key2 = idempotencyKeyOf(values);
|
|
2410
|
+
let kind = suppliedKind;
|
|
2411
|
+
if (typeof kind !== "string") {
|
|
2412
|
+
try {
|
|
2413
|
+
const current = await getCreative(baseUrl, apiKey, "drama", id, "director", io);
|
|
2414
|
+
const director = creativeObject(current.director);
|
|
2415
|
+
const pending = creativeObject(director.pendingInterrupt);
|
|
2416
|
+
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");
|
|
2417
|
+
kind = pending.kind;
|
|
2418
|
+
} catch (error) {
|
|
2419
|
+
throw toCliError(error).withRecovery(dramaConfirmationRecovery(id, void 0, baseUrl, key2, "not_submitted"));
|
|
2420
|
+
}
|
|
2421
|
+
} else if (!textOption(values, "idempotency-key")) {
|
|
2422
|
+
throw usageError("\u4F7F\u7528\u4FDD\u5B58\u7684\u786E\u8BA4\u51ED\u636E\u65F6\u5FC5\u987B\u63D0\u4F9B\u539F --idempotency-key");
|
|
2423
|
+
}
|
|
2424
|
+
if (typeof kind !== "string" || !kind) throw usageError("\u786E\u8BA4\u5361\u7F3A\u5C11\u6709\u6548 kind");
|
|
2425
|
+
try {
|
|
2426
|
+
const result2 = await postCreative(baseUrl, apiKey, "drama", id, "director/confirm", { kind, confirmationId, confirmed: true }, key2, io);
|
|
2427
|
+
out.result(["\u786E\u8BA4\u8BF7\u6C42\u5DF2\u5904\u7406", `\u5E42\u7B49\u952E\uFF1A${key2}`], { ...result2, idempotencyKey: key2 });
|
|
2428
|
+
return;
|
|
2429
|
+
} catch (error) {
|
|
2430
|
+
const failure = toCliError(error);
|
|
2431
|
+
throw failure.withRecovery({ ...dramaConfirmationRecovery(id, void 0, baseUrl, key2, "unknown"), ...failure.recovery, confirmation: { kind, confirmationId } });
|
|
2432
|
+
}
|
|
2433
|
+
}
|
|
2434
|
+
if (action === "redo") {
|
|
2435
|
+
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");
|
|
2436
|
+
const quote3 = body.quote && typeof body.quote === "object" ? creativeObject(body.quote) : body;
|
|
2437
|
+
const required3 = ["redoQuoteId", "redoPlanHash", "redoQuoteHash"];
|
|
2438
|
+
for (const field of required3) if (typeof quote3[field] !== "string") throw usageError(`--data \u5FC5\u987B\u5305\u542B\u6709\u6548\u62A5\u4EF7\u5B57\u6BB5 ${field}`);
|
|
2439
|
+
const key2 = idempotencyKeyOf(values);
|
|
2440
|
+
const result2 = await postCreative(baseUrl, apiKey, "drama", id, "redo", { redoQuoteId: quote3.redoQuoteId, redoPlanHash: quote3.redoPlanHash, redoQuoteHash: quote3.redoQuoteHash, confirmed: true }, key2, io);
|
|
2441
|
+
out.result(["\u8865\u505A\u8BF7\u6C42\u5DF2\u53D7\u7406", `\u5E42\u7B49\u952E\uFF1A${key2}`], { ...result2, idempotencyKey: key2 });
|
|
2442
|
+
return;
|
|
2443
|
+
}
|
|
2444
|
+
const epoch = textOption(values, "expected-epoch");
|
|
2445
|
+
if (epoch !== void 0) body.expectedProductionEpoch = Number(epoch);
|
|
2446
|
+
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");
|
|
2447
|
+
let suffix = action;
|
|
2448
|
+
if (action === "message") {
|
|
2449
|
+
const text = textOption(values, "text");
|
|
2450
|
+
if (text !== void 0) body.text = text;
|
|
2451
|
+
if (typeof body.text !== "string" || !body.text.trim()) throw usageError("\u8BF7\u63D0\u4F9B --text \u6216 --data.text");
|
|
2452
|
+
suffix = "messages";
|
|
2453
|
+
} else if (action === "spec") {
|
|
2454
|
+
const model = textOption(values, "model"), resolution = textOption(values, "resolution");
|
|
2455
|
+
if (model !== void 0) body.videoModel = model;
|
|
2456
|
+
if (resolution !== void 0) body.resolution = resolution;
|
|
2457
|
+
} else if (action === "select-version") {
|
|
2458
|
+
body.shotId = textOption(values, "shot") ?? body.shotId;
|
|
2459
|
+
const selected = textOption(values, "output-id");
|
|
2460
|
+
if (selected !== void 0) body.renderOutputId = selected === "default" ? null : selected;
|
|
2461
|
+
suffix = "selection";
|
|
2462
|
+
} else if (action === "redo-quote") {
|
|
2463
|
+
const shot = textOption(values, "shot");
|
|
2464
|
+
if (shot !== void 0) body.shotIds = shot.split(",").map((value) => value.trim());
|
|
2465
|
+
suffix = "redo/quote";
|
|
2466
|
+
}
|
|
2467
|
+
const key = idempotencyKeyOf(values);
|
|
2468
|
+
const result = await postCreative(baseUrl, apiKey, "drama", id, suffix, body, key, io);
|
|
2469
|
+
out.result([JSON.stringify(result, null, 2), `\u5E42\u7B49\u952E\uFF1A${key}`], { ...result, idempotencyKey: key });
|
|
2470
|
+
}
|
|
2471
|
+
async function creativeDownload(context, resource, id, suffix) {
|
|
2472
|
+
const { baseUrl, apiKey } = await resolveApiKey(context);
|
|
2473
|
+
const result = await downloadCreative(baseUrl, apiKey, resource, id, suffix, context.io);
|
|
2474
|
+
const filename = result.filename ?? `${resource}-${id}.mp4`;
|
|
2475
|
+
const saved = await saveDownload(textOption(context.values, "out") ?? filename, result.bytes);
|
|
2476
|
+
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 } });
|
|
2477
|
+
}
|
|
2478
|
+
|
|
2479
|
+
// src/commands/series.ts
|
|
2480
|
+
async function series(context) {
|
|
2481
|
+
const [action, id] = context.args;
|
|
2482
|
+
const { baseUrl, apiKey } = await resolveApiKey(context);
|
|
2483
|
+
if (action === "list" || action === "show") {
|
|
2484
|
+
if (action === "show" && !id) throw usageError("\u8BF7\u63D0\u4F9B\u5267\u96C6\u7F16\u53F7");
|
|
2485
|
+
const query = new URLSearchParams();
|
|
2486
|
+
for (const name2 of ["limit", "offset"]) {
|
|
2487
|
+
const value = textOption(context.values, name2);
|
|
2488
|
+
if (value) query.set(name2, value);
|
|
2489
|
+
}
|
|
2490
|
+
const result2 = await getCreative(baseUrl, apiKey, "series", action === "show" ? id : void 0, action === "list" && query.size ? `?${query}` : "", context.io);
|
|
2491
|
+
context.out.result([JSON.stringify(result2, null, 2)], result2);
|
|
2492
|
+
return;
|
|
2493
|
+
}
|
|
2494
|
+
if (action !== "create" && action !== "episode-create") throw usageError("series \u652F\u6301 list\u3001show\u3001create\u3001episode-create");
|
|
2495
|
+
if (action === "episode-create" && !id) throw usageError("\u8BF7\u63D0\u4F9B\u5267\u96C6\u7F16\u53F7");
|
|
2496
|
+
const body = await creativeData(context);
|
|
2497
|
+
for (const [option, field] of [["product", "productId"], ["project", "projectId"], ["title", "title"], ["main-line", "mainLine"], ["logline", "logline"], ["previous-episode", "previousEpisodeId"]]) {
|
|
2498
|
+
const value = textOption(context.values, option);
|
|
2499
|
+
if (value !== void 0) body[field] = value;
|
|
2500
|
+
}
|
|
2501
|
+
const epoch = textOption(context.values, "expected-epoch");
|
|
2502
|
+
if (epoch !== void 0) body.expectedProductionEpoch = Number(epoch);
|
|
2503
|
+
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");
|
|
2504
|
+
const key = idempotencyKeyOf(context.values);
|
|
2505
|
+
const result = await postCreative(baseUrl, apiKey, "series", action === "episode-create" ? id : void 0, action === "episode-create" ? "episodes" : "", body, key, context.io);
|
|
2506
|
+
context.out.result([JSON.stringify(result, null, 2), `\u5E42\u7B49\u952E\uFF1A${key}`], { ...result, idempotencyKey: key });
|
|
2507
|
+
}
|
|
2508
|
+
|
|
2509
|
+
// src/commands/assets.ts
|
|
2510
|
+
import { basename as basename2 } from "node:path";
|
|
2511
|
+
|
|
2512
|
+
// src/client-catalog.ts
|
|
2513
|
+
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"];
|
|
2514
|
+
function record(value) {
|
|
2515
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
2516
|
+
}
|
|
2517
|
+
function bad(status4) {
|
|
2518
|
+
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 });
|
|
2519
|
+
}
|
|
2520
|
+
function entry(value, status4) {
|
|
2521
|
+
if (!record(value) || typeof value.id !== "string") return bad(status4);
|
|
2522
|
+
const selected = {};
|
|
2523
|
+
for (const field of fields) if (["string", "number", "boolean"].includes(typeof value[field]) || value[field] === null) selected[field] = value[field];
|
|
2524
|
+
if (Array.isArray(value.tags)) selected.tags = value.tags.filter((tag) => typeof tag === "string");
|
|
2525
|
+
if (Array.isArray(value.images)) selected.images = value.images.flatMap((image) => {
|
|
2526
|
+
if (!record(image)) return [];
|
|
2527
|
+
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]]))];
|
|
2528
|
+
});
|
|
2529
|
+
if (record(value.product) && typeof value.product.id === "string") selected.product = entry(value.product, status4);
|
|
2530
|
+
if (record(value.episode)) {
|
|
2531
|
+
const episode = value.episode;
|
|
2532
|
+
selected.episode = Object.fromEntries(["id", "number"].filter((key) => typeof episode[key] === "string" || typeof episode[key] === "number").map((key) => [key, episode[key]]));
|
|
2533
|
+
}
|
|
2534
|
+
return selected;
|
|
2535
|
+
}
|
|
2536
|
+
function catalogResponse(reply) {
|
|
2537
|
+
if (!record(reply.body)) return bad(reply.status);
|
|
2538
|
+
const result = {};
|
|
2539
|
+
let hasData = false;
|
|
2540
|
+
for (const key of ["product", "item", "asset"]) if (reply.body[key] !== void 0) {
|
|
2541
|
+
result[key] = entry(reply.body[key], reply.status);
|
|
2542
|
+
hasData = true;
|
|
2543
|
+
}
|
|
2544
|
+
for (const key of ["products", "items", "assets"]) if (Array.isArray(reply.body[key])) {
|
|
2545
|
+
result[key] = reply.body[key].map((item) => entry(item, reply.status));
|
|
2546
|
+
hasData = true;
|
|
2547
|
+
}
|
|
2548
|
+
if (!hasData) return bad(reply.status);
|
|
2549
|
+
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];
|
|
2550
|
+
return result;
|
|
2551
|
+
}
|
|
2552
|
+
function catalogQuery(values, fields3) {
|
|
2553
|
+
const query = new URLSearchParams();
|
|
2554
|
+
for (const field of fields3) {
|
|
2555
|
+
const value = values[field];
|
|
2556
|
+
if (typeof value === "string" && value.trim()) query.set(field === "product" ? "productId" : field, value);
|
|
2557
|
+
}
|
|
2558
|
+
const text = query.toString();
|
|
2559
|
+
return text ? `?${text}` : "";
|
|
2560
|
+
}
|
|
2561
|
+
async function catalogGet(baseUrl, key, path, deps) {
|
|
2562
|
+
return catalogResponse(await getJson(baseUrl, key, path, deps));
|
|
2563
|
+
}
|
|
2564
|
+
async function retainKey(key, operation) {
|
|
2565
|
+
try {
|
|
2566
|
+
return await operation();
|
|
2567
|
+
} catch (error) {
|
|
2568
|
+
const e = toCliError(error);
|
|
2569
|
+
throw new CliError({
|
|
2570
|
+
code: e.code,
|
|
2571
|
+
message: `${e.message}
|
|
2572
|
+
\u672C\u6B21\u5E42\u7B49\u952E\uFF1A${key}\u3002\u518D\u6B21\u63D0\u4EA4\u540C\u4E00\u64CD\u4F5C\u65F6\u8BF7\u590D\u7528\u6B64\u952E\u3002`,
|
|
2573
|
+
exitCode: e.exitCode,
|
|
2574
|
+
retryable: e.retryable,
|
|
2575
|
+
traceId: e.traceId,
|
|
2576
|
+
retryAfterSeconds: e.retryAfterSeconds,
|
|
2577
|
+
httpStatus: e.httpStatus,
|
|
2578
|
+
hints: e.hints,
|
|
2579
|
+
recovery: e.recovery
|
|
2580
|
+
});
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2583
|
+
async function catalogWrite(baseUrl, key, path, method, body, idempotencyKey, deps) {
|
|
2584
|
+
return retainKey(idempotencyKey, async () => catalogResponse(await (method === "PATCH" ? patchJson : postJson)(baseUrl, key, path, body, idempotencyKey, deps)));
|
|
2585
|
+
}
|
|
2586
|
+
async function catalogUpload(baseUrl, key, path, bytes, mime, idempotencyKey, deps) {
|
|
2587
|
+
return retainKey(idempotencyKey, async () => catalogResponse(await postRaw(baseUrl, key, path, bytes, mime, idempotencyKey, deps)));
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2590
|
+
// src/commands/assets.ts
|
|
2591
|
+
async function assets(context) {
|
|
2592
|
+
const [action, rawId] = context.args;
|
|
2593
|
+
if (!["list", "search", "show", "upload", "rename", "archive", "restore"].includes(action ?? "")) throw usageError("assets \u652F\u6301 list\u3001search\u3001show\u3001upload\u3001rename\u3001archive\u3001restore");
|
|
2594
|
+
const listing = action === "list" || action === "search";
|
|
2595
|
+
if (!listing && !rawId) throw usageError(action === "upload" ? "\u8BF7\u63D0\u4F9B\u4E0A\u4F20\u6587\u4EF6\u8DEF\u5F84" : "\u8BF7\u63D0\u4F9B\u7D20\u6750\u7F16\u53F7");
|
|
2596
|
+
const name2 = textOption(context.values, "name");
|
|
2597
|
+
if (action === "rename" && !name2) throw usageError("\u8BF7\u63D0\u4F9B --name <\u540D\u79F0>");
|
|
2598
|
+
const source = textOption(context.values, "source") ?? "personal";
|
|
2599
|
+
if (["rename", "archive", "restore"].includes(action) && 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");
|
|
2600
|
+
let upload2;
|
|
2601
|
+
let query = "";
|
|
2602
|
+
if (action === "upload") {
|
|
2603
|
+
const authorization = textOption(context.values, "authorization"), license = textOption(context.values, "license");
|
|
2604
|
+
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>");
|
|
2605
|
+
upload2 = await readUploadFile(rawId);
|
|
2606
|
+
query = `?${new URLSearchParams({ name: name2 ?? basename2(rawId), authorization, license })}`;
|
|
2607
|
+
}
|
|
2608
|
+
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2609
|
+
const key = listing || action === "show" ? void 0 : idempotencyKeyOf(context.values);
|
|
2610
|
+
const path = listing ? `/api/open/v1/assets${catalogQuery(context.values, ["q", "kind", "source", "limit", "offset"])}` : `/api/open/v1/assets/${encodeURIComponent(rawId)}`;
|
|
2611
|
+
const result = upload2 ? await catalogUpload(baseUrl, apiKey, `/api/open/v1/assets/uploads${query}`, upload2.bytes, upload2.contentType, key, context.io) : key ? await catalogWrite(baseUrl, apiKey, `${path}${action === "rename" ? "" : `/${action}`}`, action === "rename" ? "PATCH" : "POST", action === "rename" ? { name: name2 } : {}, key, context.io) : await catalogGet(baseUrl, apiKey, listing ? path : `${path}?${new URLSearchParams({ source })}`, context.io);
|
|
2612
|
+
const items = Array.isArray(result.assets) ? result.assets : [result.asset];
|
|
2613
|
+
context.out.result(items.filter(Boolean).map((item) => {
|
|
2614
|
+
const r = item;
|
|
2615
|
+
return `${singleLine(String(r.id))} ${singleLine(String(r.name))} ${singleLine(String(r.source))}`;
|
|
2616
|
+
}), { ...result, ...key ? { idempotencyKey: key } : {} });
|
|
2617
|
+
}
|
|
2618
|
+
|
|
2619
|
+
// src/commands/library.ts
|
|
2620
|
+
async function library(context) {
|
|
2621
|
+
const [action, rawId] = context.args;
|
|
2622
|
+
if (!["list", "search", "show", "rename", "archive", "restore"].includes(action ?? "")) throw usageError("library \u652F\u6301 list\u3001search\u3001show\u3001rename\u3001archive\u3001restore");
|
|
2623
|
+
const listing = action === "list" || action === "search";
|
|
2624
|
+
const kind = textOption(context.values, "kind");
|
|
2625
|
+
if (!listing && (!rawId || !kind)) throw usageError("\u8BF7\u63D0\u4F9B\u4F5C\u54C1\u7F16\u53F7\u53CA --kind <commercial_ad|episode|graphic>");
|
|
2626
|
+
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)}`;
|
|
2627
|
+
const name2 = textOption(context.values, "name");
|
|
2628
|
+
if (action === "rename" && !name2) throw usageError("\u8BF7\u63D0\u4F9B --name <\u540D\u79F0>");
|
|
2629
|
+
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2630
|
+
const key = listing || action === "show" ? void 0 : idempotencyKeyOf(context.values);
|
|
2631
|
+
const result = key ? await catalogWrite(baseUrl, apiKey, `${path}${action === "rename" ? "" : `/${action}`}`, action === "rename" ? "PATCH" : "POST", action === "rename" ? { name: name2 } : {}, key, context.io) : await catalogGet(baseUrl, apiKey, path, context.io);
|
|
2632
|
+
const items = Array.isArray(result.items) ? result.items : [result.item];
|
|
2633
|
+
context.out.result(items.filter(Boolean).map((item) => {
|
|
2634
|
+
const r = item;
|
|
2635
|
+
return `${singleLine(String(r.id))} ${singleLine(String(r.name))} ${singleLine(String(r.status))}`;
|
|
2636
|
+
}), { ...result, ...key ? { idempotencyKey: key } : {} });
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
// src/cli.ts
|
|
2640
|
+
import { parseArgs } from "node:util";
|
|
2641
|
+
|
|
2642
|
+
// src/commands/balance.ts
|
|
2643
|
+
async function balance(context) {
|
|
2644
|
+
const { io, out } = context;
|
|
2645
|
+
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2646
|
+
const { view, raw } = await getBalance(baseUrl, apiKey, io);
|
|
2647
|
+
out.result(
|
|
2648
|
+
[
|
|
2649
|
+
`\u53EF\u7528\u4F59\u989D\uFF1A${view.available} ${singleLine(view.currency)}`,
|
|
2650
|
+
`\u51BB\u7ED3\u4E2D\uFF1A${view.held} ${singleLine(view.currency)}`,
|
|
2651
|
+
`\u5DF2\u652F\u51FA\uFF1A${view.spent} ${singleLine(view.currency)}`,
|
|
2652
|
+
`\u66F4\u65B0\u65F6\u95F4\uFF1A${singleLine(view.updatedAt)}`
|
|
2653
|
+
],
|
|
2654
|
+
{ balance: raw.balance }
|
|
2655
|
+
);
|
|
2656
|
+
}
|
|
2657
|
+
|
|
2658
|
+
// src/commands/creative-attachments.ts
|
|
2659
|
+
import { basename as basename3 } from "node:path";
|
|
2660
|
+
async function creativeAttachments(context, resource) {
|
|
2661
|
+
const [action, id] = context.args;
|
|
2662
|
+
if (!id) throw usageError("\u8BF7\u63D0\u4F9B\u9879\u76EE\u7F16\u53F7");
|
|
2663
|
+
const { baseUrl, apiKey } = await resolveApiKey(context);
|
|
2664
|
+
if (action === "attachments") {
|
|
2665
|
+
const ids = textOption(context.values, "attachment-ids")?.split(",").map((value) => value.trim());
|
|
2666
|
+
const params = new URLSearchParams();
|
|
2667
|
+
const offset = textOption(context.values, "offset");
|
|
2668
|
+
if (offset) params.set("offset", offset);
|
|
2669
|
+
for (const item of ids ?? []) params.append("attachmentId", item);
|
|
2670
|
+
const result = await getCreative(baseUrl, apiKey, resource, id, `attachments${params.size ? `?${params}` : ""}`, context.io);
|
|
2671
|
+
context.out.result([JSON.stringify(result, null, 2)], result);
|
|
2672
|
+
return;
|
|
2673
|
+
}
|
|
2674
|
+
if (action === "upload") {
|
|
2675
|
+
const path = textOption(context.values, "file");
|
|
2676
|
+
if (!path) throw usageError("\u8BF7\u63D0\u4F9B --file <\u9644\u4EF6\u8DEF\u5F84>");
|
|
2677
|
+
const upload2 = await readUploadFile(path);
|
|
2678
|
+
const key = idempotencyKeyOf(context.values);
|
|
2679
|
+
const suffix = `attachments?${new URLSearchParams({ name: basename3(path) })}`;
|
|
2680
|
+
try {
|
|
2681
|
+
const result = creativeObject((await putRaw(baseUrl, apiKey, creativePath(resource, id, suffix), upload2.bytes, upload2.contentType, key, context.io)).body);
|
|
2682
|
+
context.out.result([JSON.stringify(result, null, 2), `\u5E42\u7B49\u952E\uFF1A${key}`], { ...result, idempotencyKey: key });
|
|
2683
|
+
return;
|
|
2684
|
+
} catch (error) {
|
|
2685
|
+
const failure = toCliError(error);
|
|
2686
|
+
const recovery = taskRecovery(resource, id, void 0, baseUrl);
|
|
2687
|
+
throw failure.withRecovery({
|
|
2688
|
+
...recovery,
|
|
2689
|
+
acceptance: "unknown",
|
|
2690
|
+
idempotencyKey: key,
|
|
2691
|
+
statusCommand: recovery.statusCommand?.replace(` ${resource} status `, ` ${resource} attachments `)
|
|
2692
|
+
});
|
|
2693
|
+
}
|
|
2694
|
+
}
|
|
2695
|
+
const attachmentId = textOption(context.values, "attachment-id");
|
|
2696
|
+
if (!attachmentId) throw usageError("\u8BF7\u63D0\u4F9B --attachment-id <\u9644\u4EF6\u7F16\u53F7>");
|
|
2697
|
+
const file = await downloadAssetFile(
|
|
2698
|
+
baseUrl,
|
|
2699
|
+
apiKey,
|
|
2700
|
+
creativePath(resource, id, `attachments/${encodeURIComponent(attachmentId)}/download`),
|
|
2701
|
+
context.io,
|
|
2702
|
+
{ 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"] }
|
|
2703
|
+
);
|
|
2704
|
+
const saved = await saveDownload(textOption(context.values, "out") ?? file.filename ?? `attachment-${attachmentId}`, file.bytes);
|
|
2705
|
+
context.out.result([`\u5DF2\u4E0B\u8F7D\uFF1A${saved.path}`, `\u6821\u9A8C\uFF1Asha256 ${saved.sha256}`], { download: saved });
|
|
2049
2706
|
}
|
|
2050
2707
|
|
|
2051
2708
|
// src/commands/drama.ts
|
|
2052
|
-
var SUBCOMMANDS2 = "create\u3001status\u3001quote\u3001confirm\u3001cancel
|
|
2709
|
+
var SUBCOMMANDS2 = "create\u3001status\u3001quote\u3001confirm\u3001cancel\u3001download\u3001context\u3001director\u3001document\u3001message\u3001director-confirm\u3001bindings\u3001spec\u3001shot-plan\u3001versions\u3001select-version\u3001redo-quote\u3001redo";
|
|
2053
2710
|
var DURATION_KEYS = ["30s", "60s", "90s"];
|
|
2054
2711
|
async function drama(context) {
|
|
2055
2712
|
const { args } = context;
|
|
@@ -2057,6 +2714,8 @@ async function drama(context) {
|
|
|
2057
2714
|
if (subcommand === void 0) {
|
|
2058
2715
|
throw usageError(`drama \u8981\u8DDF\u4E00\u4E2A\u5B50\u547D\u4EE4\uFF1A${SUBCOMMANDS2}`);
|
|
2059
2716
|
}
|
|
2717
|
+
if (["context", "director", "document", "versions", "message", "director-confirm", "bindings", "spec", "shot-plan", "select-version", "redo-quote", "redo"].includes(subcommand)) return dramaCreative(context);
|
|
2718
|
+
if (["attachments", "upload", "attachment-download"].includes(subcommand)) return creativeAttachments(context, "drama");
|
|
2060
2719
|
if (subcommand === "create") return create(context);
|
|
2061
2720
|
if (subcommand === "status") return status2(context, args[1]);
|
|
2062
2721
|
if (subcommand === "quote") return quote2(context, args[1]);
|
|
@@ -2075,7 +2734,7 @@ function waitControls2(io, values, note) {
|
|
|
2075
2734
|
return {
|
|
2076
2735
|
timeoutMs: timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3) * 1e3,
|
|
2077
2736
|
now: io.now ?? (() => /* @__PURE__ */ new Date()),
|
|
2078
|
-
sleep: io.sleep ?? ((ms) => new Promise((
|
|
2737
|
+
sleep: io.sleep ?? ((ms) => new Promise((resolve2) => setTimeout(resolve2, ms))),
|
|
2079
2738
|
note
|
|
2080
2739
|
};
|
|
2081
2740
|
}
|
|
@@ -2124,20 +2783,20 @@ function orderLines2(order2) {
|
|
|
2124
2783
|
];
|
|
2125
2784
|
}
|
|
2126
2785
|
function guidanceLines(order2) {
|
|
2127
|
-
const
|
|
2786
|
+
const lines2 = [];
|
|
2128
2787
|
if (order2.reason !== void 0 && order2.reason.trim() !== "") {
|
|
2129
2788
|
const label = order2.status === "failed" ? "\u5931\u8D25\u539F\u56E0" : order2.status === "partial" ? "\u6CA1\u62CD\u5B8C\u7684\u90E8\u5206" : "\u505C\u9760\u539F\u56E0";
|
|
2130
|
-
|
|
2789
|
+
lines2.push(`${label}\uFF1A${singleLine(order2.reason)}`);
|
|
2131
2790
|
}
|
|
2132
2791
|
for (const gap of order2.gaps ?? []) {
|
|
2133
2792
|
const kind = gap.kind === "character" ? "\u89D2\u8272" : gap.kind === "scene" ? "\u573A\u666F" : "\u7D20\u6750";
|
|
2134
2793
|
const scenes = gap.sceneNos.length > 0 ? `\uFF0C\u51FA\u73B0\u5728\u7B2C ${gap.sceneNos.join("\u3001")} \u955C` : "";
|
|
2135
|
-
|
|
2794
|
+
lines2.push(`\u7F3A\u53E3\uFF1A${kind}\u300C${singleLine(gap.label !== "" ? gap.label : gap.key)}\u300D\u8FD8\u6CA1\u7ED1\u5B9A${scenes}`);
|
|
2136
2795
|
}
|
|
2137
|
-
|
|
2138
|
-
if (order2.productionCompatibility?.notice)
|
|
2796
|
+
lines2.push(...failureLines(order2));
|
|
2797
|
+
if (order2.productionCompatibility?.notice) lines2.push(`\u5236\u4F5C\u89C4\u683C\uFF1A${singleLine(order2.productionCompatibility.notice)}`);
|
|
2139
2798
|
const next = nextStepOf(order2);
|
|
2140
|
-
return next === null ?
|
|
2799
|
+
return next === null ? lines2 : [...lines2, next];
|
|
2141
2800
|
}
|
|
2142
2801
|
function failureLines(order2) {
|
|
2143
2802
|
return (order2.failures ?? []).flatMap((failure) => [
|
|
@@ -2151,14 +2810,14 @@ function nextStepOf(order2) {
|
|
|
2151
2810
|
case "preparing":
|
|
2152
2811
|
return `\u4E0B\u4E00\u6B65\uFF1A\u7B49\u5199\u7A3F\u4E0E\u6392\u7248\u8DD1\u5B8C\uFF0C\u91CD\u65B0\u67E5\u8BE2\uFF1Abuke drama status ${order2.id}`;
|
|
2153
2812
|
case "needs_attention":
|
|
2154
|
-
return `\u4E0B\u4E00\u6B65\uFF1A\
|
|
2813
|
+
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
2814
|
case "quotable":
|
|
2156
2815
|
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
2816
|
case "producing":
|
|
2158
2817
|
case "stitching":
|
|
2159
2818
|
return `\u4E0B\u4E00\u6B65\uFF1A\u7B49\u5B83\u62CD\u5B8C\uFF1Abuke drama status ${order2.id} --wait`;
|
|
2160
2819
|
case "partial":
|
|
2161
|
-
if (order2.failures?.length) return "\u4E0B\u4E00\u6B65\uFF1A\
|
|
2820
|
+
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
2821
|
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
2822
|
case "delivered":
|
|
2164
2823
|
return `\u4E0B\u8F7D\uFF1Abuke drama download ${order2.id}`;
|
|
@@ -2174,7 +2833,7 @@ function sufficientLine(sufficient) {
|
|
|
2174
2833
|
function quoteLines(orderId, quote3) {
|
|
2175
2834
|
const price = [`\u603B\u4EF7 ${quote3.totalCredits} \u5E03`, `${quote3.shotCount} \u4E2A\u955C\u5934`];
|
|
2176
2835
|
if (quote3.shotCreditCost !== void 0) price.push(`\u6BCF\u955C ${quote3.shotCreditCost} \u5E03`);
|
|
2177
|
-
const spec = [quote3.videoModel, quote3.resolution].filter((
|
|
2836
|
+
const spec = [quote3.videoModel, quote3.resolution].filter((entry2) => entry2 !== void 0);
|
|
2178
2837
|
const compatibility = quote3.productionCompatibility;
|
|
2179
2838
|
return [
|
|
2180
2839
|
`\u62A5\u4EF7\uFF1A${price.join("\uFF0C")}`,
|
|
@@ -2312,6 +2971,12 @@ async function download2(context, rawId) {
|
|
|
2312
2971
|
const { io, out, values } = context;
|
|
2313
2972
|
const orderId = orderIdOf2(rawId);
|
|
2314
2973
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2974
|
+
const outputId = textOption(values, "output-id");
|
|
2975
|
+
const editId = textOption(values, "edit-id");
|
|
2976
|
+
const sourceId = textOption(values, "source-output-id");
|
|
2977
|
+
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");
|
|
2978
|
+
if (outputId) return creativeDownload(context, "drama", orderId, `renders/${encodeURIComponent(outputId)}/download`);
|
|
2979
|
+
if (editId || sourceId) return creativeDownload(context, "drama", orderId, `${editId ? "edit" : "history"}/${encodeURIComponent(editId ?? sourceId)}/download`);
|
|
2315
2980
|
const result = await downloadDramaFilm(baseUrl, apiKey, orderId, io);
|
|
2316
2981
|
const defaultName = result.filename ?? `drama-${orderId}.mp4`;
|
|
2317
2982
|
const target = textOption(values, "out") ?? defaultName;
|
|
@@ -2351,6 +3016,7 @@ function errorLines(error) {
|
|
|
2351
3016
|
...recovery.status === void 0 ? [] : [`\u6700\u540E\u72B6\u6001\uFF1A${singleLine(recovery.status)}`],
|
|
2352
3017
|
...recovery.failureCode === void 0 ? [] : [`\u4EFB\u52A1\u5931\u8D25\u7801\uFF1A${singleLine(recovery.failureCode)}`],
|
|
2353
3018
|
...recovery.idempotencyKey === void 0 ? [] : [`\u5E42\u7B49\u952E\uFF1A${singleLine(recovery.idempotencyKey)}`],
|
|
3019
|
+
...recovery.confirmation === void 0 ? [] : [`\u539F\u786E\u8BA4\u7C7B\u578B\uFF1A${singleLine(recovery.confirmation.kind)}`, `\u539F\u786E\u8BA4\u7F16\u53F7\uFF1A${singleLine(recovery.confirmation.confirmationId)}`],
|
|
2354
3020
|
...recovery.statusCommand === void 0 ? [] : [`${recovery.operation === "confirm" ? "\u67E5\u8BE2\u8BA2\u5355\u72B6\u6001" : "\u53EA\u67E5\u8BE2\u539F\u4EFB\u52A1"}\uFF1A${singleLine(recovery.statusCommand)}`]
|
|
2355
3021
|
]
|
|
2356
3022
|
];
|
|
@@ -2370,9 +3036,9 @@ function createOutput(streams, json) {
|
|
|
2370
3036
|
protect(secret) {
|
|
2371
3037
|
secrets.push(secret);
|
|
2372
3038
|
},
|
|
2373
|
-
result(
|
|
3039
|
+
result(lines2, data, keep = []) {
|
|
2374
3040
|
if (!json) {
|
|
2375
|
-
toStdout(`${
|
|
3041
|
+
toStdout(`${lines2.join("\n")}
|
|
2376
3042
|
`, keep);
|
|
2377
3043
|
return;
|
|
2378
3044
|
}
|
|
@@ -2479,6 +3145,7 @@ async function products(context) {
|
|
|
2479
3145
|
if (subcommand === void 0) {
|
|
2480
3146
|
throw usageError("products \u8981\u8DDF\u4E00\u4E2A\u5B50\u547D\u4EE4\uFF1Acreate\u3001set-images \u6216 confirm-lock");
|
|
2481
3147
|
}
|
|
3148
|
+
if (["list", "search", "show", "update", "archive", "restore"].includes(subcommand)) return manageProducts(context);
|
|
2482
3149
|
if (subcommand === "create") return create2(context, values);
|
|
2483
3150
|
if (subcommand === "set-images") return setImages(context, values, args[1]);
|
|
2484
3151
|
if (subcommand === "confirm-lock") return confirmLock(context, values, args[1]);
|
|
@@ -2492,14 +3159,16 @@ function productIdOf(raw, what) {
|
|
|
2492
3159
|
}
|
|
2493
3160
|
async function create2(context, values) {
|
|
2494
3161
|
const { io, out } = context;
|
|
2495
|
-
const
|
|
3162
|
+
const data = textOption(values, "data") ? await readPropsArgument(io, textOption(values, "data"), "\u4EA7\u54C1\u8D44\u6599") : {};
|
|
3163
|
+
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");
|
|
3164
|
+
const name2 = textOption(values, "name") ?? (typeof data.name === "string" ? data.name : void 0);
|
|
2496
3165
|
if (name2 === void 0) {
|
|
2497
3166
|
throw usageError("\u8981\u7ED9 --name <\u540D\u79F0>");
|
|
2498
3167
|
}
|
|
2499
|
-
const category = textOption(values, "category");
|
|
3168
|
+
const category = textOption(values, "category") ?? (typeof data.category === "string" ? data.category : void 0);
|
|
2500
3169
|
const idempotencyKey = idempotencyKeyOf(values);
|
|
2501
3170
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2502
|
-
const { view, raw, replayed } = await createProduct(baseUrl, apiKey, name2, category, idempotencyKey, io);
|
|
3171
|
+
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
3172
|
out.result(
|
|
2504
3173
|
[
|
|
2505
3174
|
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 +3256,121 @@ async function confirmLock(context, values, rawId) {
|
|
|
2587
3256
|
{ productLock: raw.productLock, product: raw.product, idempotencyKey }
|
|
2588
3257
|
);
|
|
2589
3258
|
}
|
|
3259
|
+
async function manageProducts(context) {
|
|
3260
|
+
const [action, id] = context.args;
|
|
3261
|
+
const listing = action === "list" || action === "search";
|
|
3262
|
+
if (!listing && !id) throw usageError("\u8BF7\u63D0\u4F9B\u4EA7\u54C1\u7F16\u53F7");
|
|
3263
|
+
const name2 = textOption(context.values, "name");
|
|
3264
|
+
if (action === "update" && !name2) throw usageError("\u8BF7\u63D0\u4F9B --name <\u540D\u79F0>\uFF1B\u56FE\u7247\u548C\u5916\u89C2\u9501\u4F7F\u7528 set-images\u3001confirm-lock");
|
|
3265
|
+
const path = listing ? `/api/open/v1/products${catalogQuery(context.values, ["q", "archived", "limit", "offset"])}` : `/api/open/v1/products/${encodeURIComponent(id)}`;
|
|
3266
|
+
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
3267
|
+
const key = listing || action === "show" ? void 0 : idempotencyKeyOf(context.values);
|
|
3268
|
+
const result = key ? await catalogWrite(baseUrl, apiKey, `${path}${action === "update" ? "" : `/${action}`}`, action === "update" ? "PATCH" : "POST", action === "update" ? { name: name2 } : {}, key, context.io) : await catalogGet(baseUrl, apiKey, path, context.io);
|
|
3269
|
+
const items = Array.isArray(result.products) ? result.products : [result.product];
|
|
3270
|
+
context.out.result(items.filter(Boolean).map((item) => {
|
|
3271
|
+
const r = item;
|
|
3272
|
+
return `${singleLine(String(r.id))} ${singleLine(String(r.name))} ${singleLine(String(r.category))}`;
|
|
3273
|
+
}), { ...result, ...key ? { idempotencyKey: key } : {} });
|
|
3274
|
+
}
|
|
3275
|
+
|
|
3276
|
+
// src/commands/video-music.ts
|
|
3277
|
+
function object(value) {
|
|
3278
|
+
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" });
|
|
3279
|
+
return value;
|
|
3280
|
+
}
|
|
3281
|
+
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"]);
|
|
3282
|
+
function safe(value) {
|
|
3283
|
+
if (value === null || ["string", "number", "boolean"].includes(typeof value)) return value;
|
|
3284
|
+
if (Array.isArray(value)) return value.map(safe);
|
|
3285
|
+
if (!value || typeof value !== "object") return void 0;
|
|
3286
|
+
return Object.fromEntries(Object.entries(value).filter(([key]) => fields2.has(key)).map(([key, item]) => [key, safe(item)]));
|
|
3287
|
+
}
|
|
3288
|
+
function task(value) {
|
|
3289
|
+
const result = object(safe(value));
|
|
3290
|
+
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" });
|
|
3291
|
+
return result;
|
|
3292
|
+
}
|
|
3293
|
+
async function videoMusic(context) {
|
|
3294
|
+
const { args, values, out, io } = context;
|
|
3295
|
+
const command = args[0];
|
|
3296
|
+
const id = args[1]?.trim();
|
|
3297
|
+
if (!id) throw usageError("\u8BF7\u63D0\u4F9B\u5546\u54C1\u89C6\u9891\u4EFB\u52A1 ID");
|
|
3298
|
+
const request = ["music-quote", "music-compose", "music-apply"].includes(command) ? await readPropsArgument(io, textOption(values, "props"), "\u914D\u4E50\u8BF7\u6C42") : {};
|
|
3299
|
+
const key = idempotencyKeyOf(values);
|
|
3300
|
+
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
3301
|
+
const path = `/api/open/v1/videos/${encodeURIComponent(id)}/music`;
|
|
3302
|
+
let submitted = false;
|
|
3303
|
+
let latestTask;
|
|
3304
|
+
try {
|
|
3305
|
+
if (command === "music-list") {
|
|
3306
|
+
const data = object(safe((await getJson(baseUrl, apiKey, path, io)).body));
|
|
3307
|
+
const tasks = Array.isArray(data.tasks) ? data.tasks.map(task) : [];
|
|
3308
|
+
out.result(tasks.map((item) => `${singleLine(item.id)} ${singleLine(item.status)} ${singleLine(String(item.title ?? ""))}`), { ...data, tasks });
|
|
3309
|
+
return;
|
|
3310
|
+
}
|
|
3311
|
+
if (command === "music-apply") {
|
|
3312
|
+
const taskId = textOption(values, "music-task-id");
|
|
3313
|
+
if (!taskId) throw usageError("\u8BF7\u63D0\u4F9B --music-task-id <\u914D\u4E50\u4EFB\u52A1ID>");
|
|
3314
|
+
const data = object(safe((await postJson(baseUrl, apiKey, `${path}/${encodeURIComponent(taskId)}/apply`, request, key, io)).body));
|
|
3315
|
+
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 });
|
|
3316
|
+
return;
|
|
3317
|
+
}
|
|
3318
|
+
const quote3 = object(object(safe((await postJson(baseUrl, apiKey, `${path}/quote`, request, key, io)).body)).quote);
|
|
3319
|
+
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" });
|
|
3320
|
+
const expected = textOption(values, "quote-hash");
|
|
3321
|
+
if (expected && expected !== 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" });
|
|
3322
|
+
if (command === "music-quote" || values.yes !== true) {
|
|
3323
|
+
out.result([`\u914D\u4E50\u62A5\u4EF7\uFF1A${quote3.credits} \u5E03`, `\u62A5\u4EF7\u54C8\u5E0C\uFF1A${quote3.quoteHash}`, "\u786E\u8BA4\u540E\u4F7F\u7528 music-compose --yes \u63D0\u4EA4\u751F\u6210\u3002"], { quote: quote3, submitted: false });
|
|
3324
|
+
return;
|
|
3325
|
+
}
|
|
3326
|
+
submitted = true;
|
|
3327
|
+
latestTask = task(object((await postJson(baseUrl, apiKey, path, { ...request, confirmed: true, quoteHash: quote3.quoteHash }, key, io)).body).task);
|
|
3328
|
+
if (values.wait === true) {
|
|
3329
|
+
const now = io.now ?? (() => /* @__PURE__ */ new Date());
|
|
3330
|
+
const sleep = io.sleep ?? ((ms) => new Promise((resolve2) => setTimeout(resolve2, ms)));
|
|
3331
|
+
const until = now().getTime() + timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3) * 1e3;
|
|
3332
|
+
while (["pending", "running"].includes(latestTask.status)) {
|
|
3333
|
+
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" });
|
|
3334
|
+
await sleep(1500);
|
|
3335
|
+
const data = object((await getJson(baseUrl, apiKey, path, io)).body);
|
|
3336
|
+
const found = Array.isArray(data.tasks) ? data.tasks.find((item) => item && typeof item === "object" && item.id === latestTask.id) : null;
|
|
3337
|
+
latestTask = task(found);
|
|
3338
|
+
}
|
|
3339
|
+
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" });
|
|
3340
|
+
}
|
|
3341
|
+
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 });
|
|
3342
|
+
} catch (error) {
|
|
3343
|
+
const failure = toCliError(error);
|
|
3344
|
+
if (command === "music-apply") throw failure.withRecovery({
|
|
3345
|
+
...taskRecovery("videos", id, void 0, baseUrl),
|
|
3346
|
+
acceptance: "unknown",
|
|
3347
|
+
idempotencyKey: key,
|
|
3348
|
+
statusCommand: taskRecovery("videos", id, void 0, baseUrl).statusCommand.replace(" videos status ", " videos music-list ")
|
|
3349
|
+
});
|
|
3350
|
+
if (command !== "music-compose") throw failure;
|
|
3351
|
+
const rejected = failure.httpStatus !== void 0 && failure.httpStatus >= 400 && failure.httpStatus < 500 && failure.httpStatus !== 408;
|
|
3352
|
+
throw failure.withRecovery({
|
|
3353
|
+
...taskRecovery("videos", id, latestTask?.status, baseUrl),
|
|
3354
|
+
acceptance: latestTask ? "confirmed" : "unknown",
|
|
3355
|
+
idempotencyKey: key,
|
|
3356
|
+
operation: "confirm",
|
|
3357
|
+
operationOutcome: !submitted ? "not_submitted" : rejected ? "rejected" : "unknown",
|
|
3358
|
+
statusCommand: taskRecovery("videos", id, latestTask?.status, baseUrl).statusCommand.replace(" videos status ", " videos music-list ")
|
|
3359
|
+
});
|
|
3360
|
+
}
|
|
3361
|
+
}
|
|
2590
3362
|
|
|
2591
3363
|
// src/commands/videos.ts
|
|
2592
|
-
var SUBCOMMANDS3 = "create\u3001status\u3001message\u3001confirm
|
|
3364
|
+
var SUBCOMMANDS3 = "create\u3001status\u3001message\u3001confirm\u3001versions\u3001cancel\u3001download\u3001music-quote\u3001music-compose\u3001music-list\u3001music-apply";
|
|
2593
3365
|
async function videos(context) {
|
|
2594
3366
|
const { args } = context;
|
|
2595
3367
|
const [subcommand] = args;
|
|
2596
3368
|
if (subcommand === void 0) {
|
|
2597
3369
|
throw usageError(`videos \u8981\u8DDF\u4E00\u4E2A\u5B50\u547D\u4EE4\uFF1A${SUBCOMMANDS3}`);
|
|
2598
3370
|
}
|
|
3371
|
+
if (["music-quote", "music-compose", "music-list", "music-apply"].includes(subcommand)) return videoMusic(context);
|
|
3372
|
+
if (subcommand === "versions" || subcommand === "cancel") return manage(context);
|
|
3373
|
+
if (["attachments", "upload", "attachment-download"].includes(subcommand)) return creativeAttachments(context, "videos");
|
|
2599
3374
|
if (subcommand === "create") return create3(context);
|
|
2600
3375
|
if (subcommand === "status") return status3(context, args[1]);
|
|
2601
3376
|
if (subcommand === "message") return message(context, args[1]);
|
|
@@ -2613,7 +3388,7 @@ function waitControls3(io, values) {
|
|
|
2613
3388
|
return {
|
|
2614
3389
|
timeoutMs: timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3) * 1e3,
|
|
2615
3390
|
now: io.now ?? (() => /* @__PURE__ */ new Date()),
|
|
2616
|
-
sleep: io.sleep ?? ((ms) => new Promise((
|
|
3391
|
+
sleep: io.sleep ?? ((ms) => new Promise((resolve2) => setTimeout(resolve2, ms)))
|
|
2617
3392
|
};
|
|
2618
3393
|
}
|
|
2619
3394
|
function settleRun(outcome, baseUrl) {
|
|
@@ -2654,7 +3429,8 @@ function waitingLines(run2) {
|
|
|
2654
3429
|
}
|
|
2655
3430
|
async function create3(context) {
|
|
2656
3431
|
const { io, out, values } = context;
|
|
2657
|
-
const
|
|
3432
|
+
const data = await creativeData(context);
|
|
3433
|
+
const productId = textOption(values, "product") ?? (typeof data.productId === "string" ? data.productId : void 0);
|
|
2658
3434
|
if (productId === void 0) {
|
|
2659
3435
|
throw usageError("\u8981\u7ED9 --product <\u4EA7\u54C1id>\uFF08buke products create \u56DE\u7684\u90A3\u4E2A\uFF09");
|
|
2660
3436
|
}
|
|
@@ -2685,9 +3461,10 @@ async function create3(context) {
|
|
|
2685
3461
|
baseUrl,
|
|
2686
3462
|
apiKey,
|
|
2687
3463
|
{
|
|
3464
|
+
...data,
|
|
2688
3465
|
productId,
|
|
2689
3466
|
...intent === void 0 ? {} : { intent },
|
|
2690
|
-
...Object.keys(preferences).length > 0 ? { preferences } : {}
|
|
3467
|
+
...Object.keys(preferences).length > 0 ? { preferences: { ...data.preferences && typeof data.preferences === "object" ? data.preferences : {}, ...preferences } } : {}
|
|
2691
3468
|
},
|
|
2692
3469
|
idempotencyKey,
|
|
2693
3470
|
io
|
|
@@ -2724,14 +3501,15 @@ async function status3(context, rawId) {
|
|
|
2724
3501
|
async function message(context, rawId) {
|
|
2725
3502
|
const { io, out, values } = context;
|
|
2726
3503
|
const runId = runIdOf(rawId);
|
|
2727
|
-
const
|
|
3504
|
+
const data = await creativeData(context);
|
|
3505
|
+
const text = textOption(values, "text") ?? (typeof data.text === "string" ? data.text : void 0);
|
|
2728
3506
|
if (text === void 0) {
|
|
2729
3507
|
throw usageError("\u8981\u7ED9 --text <\u5185\u5BB9>\uFF1A\u60F3\u5BF9\u5BFC\u6F14\u8BF4\u7684\u90A3\u53E5\u8BDD");
|
|
2730
3508
|
}
|
|
2731
3509
|
const idempotencyKey = idempotencyKeyOf(values);
|
|
2732
3510
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2733
|
-
const { view, raw } = await
|
|
2734
|
-
const lastDirectorLine = [...view.messages].reverse().find((
|
|
3511
|
+
const { view, raw } = await runReplyOf(await postJson(baseUrl, apiKey, `/api/open/v1/videos/${encodeURIComponent(runId)}/messages`, { ...data, text }, idempotencyKey, io));
|
|
3512
|
+
const lastDirectorLine = [...view.messages].reverse().find((entry2) => entry2.role === "assistant" && entry2.text.trim() !== "");
|
|
2735
3513
|
out.result(
|
|
2736
3514
|
[
|
|
2737
3515
|
...runLines(view),
|
|
@@ -2784,6 +3562,25 @@ async function download3(context, rawId) {
|
|
|
2784
3562
|
const { io, out, values } = context;
|
|
2785
3563
|
const runId = runIdOf(rawId);
|
|
2786
3564
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
3565
|
+
const musicTask = textOption(values, "music-task-id");
|
|
3566
|
+
const narrationEdit = textOption(values, "narration-edit-id");
|
|
3567
|
+
const appendTask = textOption(values, "append-task-id");
|
|
3568
|
+
const selectedCount = [musicTask, narrationEdit, appendTask, textOption(values, "production-id"), textOption(values, "edit-id")].filter(Boolean).length;
|
|
3569
|
+
if (selectedCount > 1) throw usageError("\u6BCF\u6B21\u4E0B\u8F7D\u53EA\u80FD\u9009\u62E9\u4E00\u79CD\u5236\u4F5C\u7248\u672C\u6216\u97F3\u8F68");
|
|
3570
|
+
if (appendTask) return creativeDownload(context, "videos", runId, `append-tasks/${encodeURIComponent(appendTask)}/download`);
|
|
3571
|
+
if (musicTask || narrationEdit) {
|
|
3572
|
+
const index = Number(textOption(values, "track-index"));
|
|
3573
|
+
if (musicTask && (!Number.isInteger(index) || index < 0 || index > 99)) throw usageError("\u914D\u4E50\u4E0B\u8F7D\u987B\u63D0\u4F9B\u6709\u6548 --track-index");
|
|
3574
|
+
const suffix = musicTask ? `music/${encodeURIComponent(musicTask)}/tracks/${index}/download` : `edits/${encodeURIComponent(narrationEdit)}/narration/download`;
|
|
3575
|
+
const media = await downloadAssetFile(baseUrl, apiKey, `/api/open/v1/videos/${encodeURIComponent(runId)}/${suffix}`, io, { allowedMimeTypes: ["audio/wav", "audio/mpeg"], requireSha256: true });
|
|
3576
|
+
const saved2 = await saveDownload(textOption(values, "out") ?? media.filename ?? `audio-${runId}.wav`, media.bytes);
|
|
3577
|
+
out.result([`\u5DF2\u4E0B\u8F7D\uFF1A${saved2.path}`, `\u6821\u9A8C\uFF1Asha256 ${saved2.sha256}`], { download: saved2 });
|
|
3578
|
+
return;
|
|
3579
|
+
}
|
|
3580
|
+
const productionId = textOption(values, "production-id");
|
|
3581
|
+
const editId = textOption(values, "edit-id");
|
|
3582
|
+
if (productionId && editId) throw usageError("--production-id \u4E0E --edit-id \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528");
|
|
3583
|
+
if (productionId || editId) return creativeDownload(context, "videos", runId, editId ? `edits/${encodeURIComponent(editId)}/download` : `download?productionId=${encodeURIComponent(productionId)}`);
|
|
2787
3584
|
const result = await downloadVideo(baseUrl, apiKey, runId, io);
|
|
2788
3585
|
const defaultName = result.filename ?? `video-${runId}.mp4`;
|
|
2789
3586
|
const target = textOption(values, "out") ?? defaultName;
|
|
@@ -2793,6 +3590,18 @@ async function download3(context, rawId) {
|
|
|
2793
3590
|
{ download: { ...saved, filename: defaultName } }
|
|
2794
3591
|
);
|
|
2795
3592
|
}
|
|
3593
|
+
async function manage(context) {
|
|
3594
|
+
const id = runIdOf(context.args[1]);
|
|
3595
|
+
const { baseUrl, apiKey } = await resolveApiKey(context);
|
|
3596
|
+
if (context.args[0] === "versions") {
|
|
3597
|
+
const result2 = await getCreative(baseUrl, apiKey, "videos", id, "versions", context.io);
|
|
3598
|
+
context.out.result([JSON.stringify(result2, null, 2)], result2);
|
|
3599
|
+
return;
|
|
3600
|
+
}
|
|
3601
|
+
const key = idempotencyKeyOf(context.values);
|
|
3602
|
+
const result = await postCreative(baseUrl, apiKey, "videos", id, "cancel", {}, key, context.io);
|
|
3603
|
+
context.out.result(["\u53D6\u6D88\u8BF7\u6C42\u5DF2\u5904\u7406", `\u5E42\u7B49\u952E\uFF1A${key}`], { ...result, idempotencyKey: key });
|
|
3604
|
+
}
|
|
2796
3605
|
|
|
2797
3606
|
// src/commands/whoami.ts
|
|
2798
3607
|
async function whoami(context) {
|
|
@@ -2827,6 +3636,7 @@ var KEY_HOWTO = [
|
|
|
2827
3636
|
" 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
3637
|
];
|
|
2829
3638
|
var COMMANDS = {
|
|
3639
|
+
graphic: graphicCommand,
|
|
2830
3640
|
login: {
|
|
2831
3641
|
run: login,
|
|
2832
3642
|
acceptsBaseUrl: true,
|
|
@@ -2842,7 +3652,7 @@ var COMMANDS = {
|
|
|
2842
3652
|
"",
|
|
2843
3653
|
"\u9009\u9879\uFF1A",
|
|
2844
3654
|
` --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF0C\u9ED8\u8BA4 ${DEFAULT_BASE_URL}\uFF1B\u53EA\u5199\u5230\u57DF\u540D\u4E3A\u6B62`,
|
|
2845
|
-
" --json \
|
|
3655
|
+
" --json \u6807\u51C6\u8F93\u51FA\u4EC5\u8FD4\u56DE\u4E00\u4E2A JSON \u6587\u6863\uFF0C\u4F9B\u811A\u672C\u89E3\u6790"
|
|
2846
3656
|
].join("\n")
|
|
2847
3657
|
},
|
|
2848
3658
|
whoami: {
|
|
@@ -2858,8 +3668,8 @@ var COMMANDS = {
|
|
|
2858
3668
|
"\u672C\u673A\u4FDD\u5B58\u7684\u5BC6\u94A5\u53EA\u4F1A\u53D1\u5F80\u767B\u5F55\u65F6\u7684\u90A3\u4E2A\u5730\u5740\u3002",
|
|
2859
3669
|
"",
|
|
2860
3670
|
"\u9009\u9879\uFF1A",
|
|
2861
|
-
" --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF1B\
|
|
2862
|
-
" --json \
|
|
3671
|
+
" --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF1B\u7701\u7565\u65F6\u4F7F\u7528\u767B\u5F55\u65F6\u7684\u5730\u5740",
|
|
3672
|
+
" --json \u6807\u51C6\u8F93\u51FA\u4EC5\u8FD4\u56DE\u4E00\u4E2A JSON \u6587\u6863\uFF0C\u4F9B\u811A\u672C\u89E3\u6790"
|
|
2863
3673
|
].join("\n")
|
|
2864
3674
|
},
|
|
2865
3675
|
logout: {
|
|
@@ -2873,7 +3683,7 @@ var COMMANDS = {
|
|
|
2873
3683
|
"\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
3684
|
"",
|
|
2875
3685
|
"\u9009\u9879\uFF1A",
|
|
2876
|
-
" --json \
|
|
3686
|
+
" --json \u6807\u51C6\u8F93\u51FA\u4EC5\u8FD4\u56DE\u4E00\u4E2A JSON \u6587\u6863\uFF0C\u4F9B\u811A\u672C\u89E3\u6790"
|
|
2877
3687
|
].join("\n")
|
|
2878
3688
|
},
|
|
2879
3689
|
balance: {
|
|
@@ -2887,18 +3697,22 @@ var COMMANDS = {
|
|
|
2887
3697
|
"\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
3698
|
"",
|
|
2889
3699
|
"\u9009\u9879\uFF1A",
|
|
2890
|
-
" --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF1B\
|
|
2891
|
-
" --json \
|
|
3700
|
+
" --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF1B\u7701\u7565\u65F6\u4F7F\u7528\u767B\u5F55\u65F6\u7684\u5730\u5740",
|
|
3701
|
+
" --json \u6807\u51C6\u8F93\u51FA\u4EC5\u8FD4\u56DE\u4E00\u4E2A JSON \u6587\u6863\uFF0C\u4F9B\u811A\u672C\u89E3\u6790"
|
|
2892
3702
|
].join("\n")
|
|
2893
3703
|
},
|
|
2894
3704
|
products: {
|
|
2895
3705
|
run: products,
|
|
2896
3706
|
acceptsBaseUrl: true,
|
|
2897
|
-
options: ["name", "category", "front", "side", "back", "detail", "color", "silhouette", "material", "idempotency-key"],
|
|
3707
|
+
options: ["name", "category", "front", "side", "back", "detail", "color", "silhouette", "material", "idempotency-key", "data", "sku", "classification-hint", "q", "archived", "limit", "offset"],
|
|
2898
3708
|
positionals: ["\u5B50\u547D\u4EE4", "\u4EA7\u54C1id"],
|
|
2899
3709
|
help: [
|
|
2900
3710
|
"\u7528\u6CD5\uFF1A",
|
|
2901
|
-
" buke products
|
|
3711
|
+
" buke products list|search [--q <\u5173\u952E\u8BCD>] [--archived exclude|only|include] [--limit <\u6570\u91CF>] [--offset <\u504F\u79FB>]",
|
|
3712
|
+
" buke products show <\u4EA7\u54C1id>",
|
|
3713
|
+
" buke products create --name <\u540D\u79F0> [--category <\u7C7B\u76EE>] [--sku <\u7F16\u53F7>] [--classification-hint <\u54C1\u7C7B\u8BF4\u660E>] [--data <JSON\u6587\u4EF6|->]",
|
|
3714
|
+
" buke products update <\u4EA7\u54C1id> --name <\u540D\u79F0>",
|
|
3715
|
+
" buke products archive|restore <\u4EA7\u54C1id>",
|
|
2902
3716
|
" buke products set-images <\u4EA7\u54C1id> --front <\u56FE> [--side <\u56FE>] [--back <\u56FE>] [--detail <\u56FE>]",
|
|
2903
3717
|
" buke products confirm-lock <\u4EA7\u54C1id> --color <\u8272> --silhouette <\u5ED3\u5F62> --material <\u6750\u8D28>",
|
|
2904
3718
|
"",
|
|
@@ -2914,9 +3728,42 @@ var COMMANDS = {
|
|
|
2914
3728
|
" --color <\u8272> \u5916\u89C2\u9501\uFF1A\u989C\u8272",
|
|
2915
3729
|
" --silhouette <\u5ED3\u5F62> \u5916\u89C2\u9501\uFF1A\u5ED3\u5F62",
|
|
2916
3730
|
" --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 \
|
|
3731
|
+
" --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",
|
|
3732
|
+
" --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF1B\u7701\u7565\u65F6\u4F7F\u7528\u767B\u5F55\u65F6\u7684\u5730\u5740",
|
|
3733
|
+
" --json \u6807\u51C6\u8F93\u51FA\u4EC5\u8FD4\u56DE\u4E00\u4E2A JSON \u6587\u6863\uFF0C\u4F9B\u811A\u672C\u89E3\u6790"
|
|
3734
|
+
].join("\n")
|
|
3735
|
+
},
|
|
3736
|
+
library: {
|
|
3737
|
+
run: library,
|
|
3738
|
+
acceptsBaseUrl: true,
|
|
3739
|
+
options: ["q", "kind", "state", "product", "archived", "limit", "cursor", "name", "idempotency-key"],
|
|
3740
|
+
positionals: ["\u5B50\u547D\u4EE4", "\u4F5C\u54C1id"],
|
|
3741
|
+
help: [
|
|
3742
|
+
"\u7528\u6CD5\uFF1A",
|
|
3743
|
+
" buke library list|search [--q <\u5173\u952E\u8BCD>] [--kind commercial_ad|episode|graphic] [--state ready|active|attention|draft]",
|
|
3744
|
+
" buke library show <\u4F5C\u54C1id> --kind <\u7C7B\u578B>",
|
|
3745
|
+
" buke library rename <\u4F5C\u54C1id> --kind <\u7C7B\u578B> --name <\u540D\u79F0>",
|
|
3746
|
+
" buke library archive|restore <\u4F5C\u54C1id> --kind <\u7C7B\u578B>",
|
|
3747
|
+
"",
|
|
3748
|
+
"\u5217\u8868\u652F\u6301 --product\u3001--archived exclude|only|include\u3001--limit\u3001--cursor\u3002\u5199\u5165\u652F\u6301 --idempotency-key\u3002",
|
|
3749
|
+
"\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"
|
|
3750
|
+
].join("\n")
|
|
3751
|
+
},
|
|
3752
|
+
assets: {
|
|
3753
|
+
run: assets,
|
|
3754
|
+
acceptsBaseUrl: true,
|
|
3755
|
+
options: ["q", "source", "kind", "name", "authorization", "license", "limit", "offset", "idempotency-key"],
|
|
3756
|
+
positionals: ["\u5B50\u547D\u4EE4", "\u7D20\u6750id\u6216\u6587\u4EF6\u8DEF\u5F84"],
|
|
3757
|
+
help: [
|
|
3758
|
+
"\u7528\u6CD5\uFF1A",
|
|
3759
|
+
" buke assets list|search [--source personal|platform|upload] [--kind character|scene|image|video|audio] [--q <\u5173\u952E\u8BCD>]",
|
|
3760
|
+
" buke assets show <\u7D20\u6750id> [--source personal|platform|upload]",
|
|
3761
|
+
" buke assets upload <\u6587\u4EF6> --authorization own|licensed|public_domain --license <\u6388\u6743\u8BF4\u660E> [--name <\u540D\u79F0>]",
|
|
3762
|
+
" buke assets rename <\u7D20\u6750id> --name <\u540D\u79F0>",
|
|
3763
|
+
" buke assets archive|restore <\u7D20\u6750id>",
|
|
3764
|
+
"",
|
|
3765
|
+
"\u5217\u8868\u652F\u6301 --limit\u3001--offset\u3002\u5199\u5165\u652F\u6301 --idempotency-key\u3002",
|
|
3766
|
+
"\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
3767
|
].join("\n")
|
|
2921
3768
|
},
|
|
2922
3769
|
shorts: {
|
|
@@ -2947,18 +3794,46 @@ var COMMANDS = {
|
|
|
2947
3794
|
" --template <\u6A21\u677Fid> \u6A21\u677F id\uFF08catalog \u91CC\u5217\u51FA\u7684\uFF09",
|
|
2948
3795
|
" --props <props.json|-> \u6A21\u677F\u53C2\u6570\uFF1A\u4E00\u4E2A JSON \u6587\u4EF6\uFF0C\u6216 - \u8868\u793A\u4ECE\u6807\u51C6\u8F93\u5165\u8BFB",
|
|
2949
3796
|
" --quote-hash <hash> \u62A5\u4EF7\u54C8\u5E0C\uFF08quote \u547D\u4EE4\u56DE\u7684\uFF09",
|
|
2950
|
-
" --wait \
|
|
3797
|
+
" --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
3798
|
" --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 \
|
|
3799
|
+
" --out <\u8DEF\u5F84> \u4E0B\u8F7D\u4FDD\u5B58\u7684\u4F4D\u7F6E\uFF1B\u7701\u7565\u65F6\u4FDD\u5B58\u5230\u5F53\u524D\u76EE\u5F55",
|
|
3800
|
+
" --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",
|
|
3801
|
+
" --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF1B\u7701\u7565\u65F6\u4F7F\u7528\u767B\u5F55\u65F6\u7684\u5730\u5740",
|
|
3802
|
+
" --json \u6807\u51C6\u8F93\u51FA\u4EC5\u8FD4\u56DE\u4E00\u4E2A JSON \u6587\u6863\uFF0C\u4F9B\u811A\u672C\u89E3\u6790"
|
|
3803
|
+
].join("\n")
|
|
3804
|
+
},
|
|
3805
|
+
series: {
|
|
3806
|
+
run: series,
|
|
3807
|
+
acceptsBaseUrl: true,
|
|
3808
|
+
options: ["limit", "offset", "data", "product", "project", "title", "main-line", "logline", "previous-episode", "expected-epoch", "idempotency-key"],
|
|
3809
|
+
positionals: ["\u5B50\u547D\u4EE4", "\u5267\u96C6id"],
|
|
3810
|
+
help: [
|
|
3811
|
+
"\u7528\u6CD5\uFF1A",
|
|
3812
|
+
" buke series list [--limit <\u6570\u91CF>] [--offset <\u504F\u79FB>]",
|
|
3813
|
+
" buke series show <\u5267\u96C6id>",
|
|
3814
|
+
" buke series create --product <\u4EA7\u54C1id> --project <\u77ED\u5267id> --expected-epoch <\u7248\u672C> [--title <\u6807\u9898>] [--data <JSON\u6587\u4EF6|->]",
|
|
3815
|
+
" buke series episode-create <\u5267\u96C6id> --expected-epoch <\u7248\u672C> --previous-episode <\u5206\u96C6id> [--data <JSON\u6587\u4EF6|->]",
|
|
3816
|
+
"",
|
|
3817
|
+
"\u521B\u5EFA\u4E0E\u7EED\u96C6\u53C2\u6570\u652F\u6301 --product\u3001--main-line\u3001--logline\u3001--idempotency-key\u3002"
|
|
2956
3818
|
].join("\n")
|
|
2957
3819
|
},
|
|
2958
3820
|
videos: {
|
|
2959
3821
|
run: videos,
|
|
2960
3822
|
acceptsBaseUrl: true,
|
|
2961
3823
|
options: [
|
|
3824
|
+
"file",
|
|
3825
|
+
"offset",
|
|
3826
|
+
"attachment-id",
|
|
3827
|
+
"props",
|
|
3828
|
+
"quote-hash",
|
|
3829
|
+
"music-task-id",
|
|
3830
|
+
"track-index",
|
|
3831
|
+
"narration-edit-id",
|
|
3832
|
+
"append-task-id",
|
|
3833
|
+
"data",
|
|
3834
|
+
"production-id",
|
|
3835
|
+
"edit-id",
|
|
3836
|
+
"attachment-ids",
|
|
2962
3837
|
"product",
|
|
2963
3838
|
"intent",
|
|
2964
3839
|
"duration",
|
|
@@ -2978,56 +3853,80 @@ var COMMANDS = {
|
|
|
2978
3853
|
"\u7528\u6CD5\uFF1A",
|
|
2979
3854
|
" buke videos create --product <\u4EA7\u54C1id> [--intent <\u4E00\u53E5\u8BDD>] [--duration <\u79D2>] [--resolution <r>]",
|
|
2980
3855
|
" [--speed <\u6863>] [--aspect-ratio <a>] [--style-preset <p>] [--json]",
|
|
3856
|
+
" buke videos upload <\u4EFB\u52A1id> --file <\u9644\u4EF6\u8DEF\u5F84>",
|
|
3857
|
+
" buke videos attachments <\u4EFB\u52A1id> [--attachment-ids <\u7F16\u53F7,\u7F16\u53F7>] [--offset <\u504F\u79FB>]",
|
|
3858
|
+
" buke videos attachment-download <\u4EFB\u52A1id> --attachment-id <\u9644\u4EF6\u7F16\u53F7> [--out <\u8DEF\u5F84>]",
|
|
2981
3859
|
" buke videos status <\u89C6\u9891id> [--wait] [--timeout <\u79D2>]",
|
|
2982
|
-
" buke videos message <\u89C6\u9891id> --text <\u5185\u5BB9>",
|
|
3860
|
+
" buke videos message <\u89C6\u9891id> --text <\u5185\u5BB9> [--data <JSON\u6587\u4EF6|->]",
|
|
3861
|
+
" buke videos versions <\u89C6\u9891id>",
|
|
3862
|
+
" buke videos music-list <\u89C6\u9891id>",
|
|
3863
|
+
" buke videos music-quote <\u89C6\u9891id> --props <JSON\u6587\u4EF6|->",
|
|
3864
|
+
" buke videos music-compose <\u89C6\u9891id> --props <JSON\u6587\u4EF6|-> --yes [--quote-hash <\u62A5\u4EF7\u6807\u8BC6>]",
|
|
3865
|
+
" buke videos music-apply <\u89C6\u9891id> --music-task-id <\u4EFB\u52A1id> --props <JSON\u6587\u4EF6|->",
|
|
3866
|
+
" buke videos cancel <\u89C6\u9891id>",
|
|
2983
3867
|
" buke videos confirm <\u89C6\u9891id> [--yes]",
|
|
2984
|
-
" buke videos download <\u89C6\u9891id> [--out <\u8DEF\u5F84>]",
|
|
3868
|
+
" buke videos download <\u89C6\u9891id> [--production-id <\u5236\u4F5C\u7248\u672C>] [--edit-id <\u526A\u8F91\u7248\u672C>] [--out <\u8DEF\u5F84>]",
|
|
3869
|
+
" buke videos download <\u89C6\u9891id> --music-task-id <\u4EFB\u52A1id> --track-index <0|1> [--out <\u8DEF\u5F84>]",
|
|
3870
|
+
" buke videos download <\u89C6\u9891id> [--append-task-id <\u63D2\u6BB5\u4EFB\u52A1>] [--narration-edit-id <\u914D\u97F3\u7248\u672C>] [--out <\u8DEF\u5F84>]",
|
|
3871
|
+
" \u5404\u4E0B\u8F7D\u7248\u672C\u9009\u62E9\u9879\u4E92\u65A5\u3002",
|
|
2985
3872
|
"",
|
|
2986
|
-
"\u5546\u54C1\u89C6\u9891\
|
|
2987
|
-
" create \
|
|
2988
|
-
" status \u67E5\u8FDB\u5EA6\uFF1B--wait \
|
|
2989
|
-
" message \
|
|
2990
|
-
" confirm \u786E\u8BA4\
|
|
3873
|
+
"\u5546\u54C1\u89C6\u9891\u521B\u4F5C\u4E0E\u4EA4\u4ED8\uFF1A",
|
|
3874
|
+
" create \u521B\u5EFA\u4EFB\u52A1\uFF1B\u987B\u5148\u5EFA\u7ACB\u4EA7\u54C1\u3002\u53D7\u7406\u540E\u901A\u8FC7 status \u67E5\u8BE2\u8FDB\u5EA6",
|
|
3875
|
+
" status \u67E5\u8BE2\u8FDB\u5EA6\uFF1B--wait \u7B49\u5F85\u7EC8\u6001\u6216\u9700\u8981\u7528\u6237\u5904\u7406\u7684\u72B6\u6001",
|
|
3876
|
+
" message \u63D0\u4EA4\u5236\u4F5C\u8981\u6C42\u3001\u95EE\u9898\u56DE\u590D\u3001\u9644\u4EF6\u6216\u7ED3\u6784\u5316\u9009\u9879",
|
|
3877
|
+
" confirm \u786E\u8BA4\u5F53\u524D\u64CD\u4F5C\uFF1A\u63D0\u4EA4\u670D\u52A1\u7AEF\u786E\u8BA4\u5361\u53CA\u7248\u672C\uFF0C\u6388\u6743\u5BF9\u5E94\u8D39\u7528",
|
|
2991
3878
|
" download \u4E0B\u8F7D\u6210\u7247\uFF08mp4\uFF09",
|
|
2992
3879
|
"",
|
|
2993
3880
|
"\u9009\u9879\uFF1A",
|
|
2994
3881
|
" --product <\u4EA7\u54C1id> \u4EA7\u54C1 id\uFF08buke products create \u56DE\u7684\uFF09",
|
|
2995
|
-
" --intent <\u4E00\u53E5\u8BDD> \
|
|
3882
|
+
" --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
3883
|
" --duration <\u79D2> \u671F\u671B\u65F6\u957F",
|
|
2997
3884
|
" --resolution <r> \u5206\u8FA8\u7387\u6863\u4F4D",
|
|
2998
3885
|
" --speed <\u6863> \u751F\u6210\u901F\u5EA6\u6863\u4F4D",
|
|
2999
3886
|
" --aspect-ratio <a> \u753B\u5E45\uFF08\u5982 9:16\uFF09",
|
|
3000
3887
|
" --style-preset <p> \u753B\u9762\u98CE\u683C",
|
|
3001
|
-
" --text <\u5185\u5BB9> \
|
|
3002
|
-
" --yes
|
|
3003
|
-
" --wait \
|
|
3888
|
+
" --text <\u5185\u5BB9> \u53D1\u9001\u7ED9\u5BFC\u6F14\u7684\u6D88\u606F\u6B63\u6587",
|
|
3889
|
+
" --yes \u660E\u786E\u63D0\u4EA4\u5F53\u524D\u786E\u8BA4\uFF1B\u7701\u7565\u65F6\u4EC5\u663E\u793A\u786E\u8BA4\u5361",
|
|
3890
|
+
" --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
3891
|
" --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 \
|
|
3892
|
+
" --out <\u8DEF\u5F84> \u4E0B\u8F7D\u4FDD\u5B58\u7684\u4F4D\u7F6E\uFF1B\u7701\u7565\u65F6\u4FDD\u5B58\u5230\u5F53\u524D\u76EE\u5F55",
|
|
3893
|
+
" --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",
|
|
3894
|
+
" --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF1B\u7701\u7565\u65F6\u4F7F\u7528\u767B\u5F55\u65F6\u7684\u5730\u5740",
|
|
3895
|
+
" --json \u6807\u51C6\u8F93\u51FA\u4EC5\u8FD4\u56DE\u4E00\u4E2A JSON \u6587\u6863\uFF0C\u4F9B\u811A\u672C\u89E3\u6790"
|
|
3009
3896
|
].join("\n")
|
|
3010
3897
|
},
|
|
3011
3898
|
drama: {
|
|
3012
3899
|
run: drama,
|
|
3013
3900
|
acceptsBaseUrl: true,
|
|
3014
|
-
options: ["product", "genre", "duration", "brief", "model", "resolution", "quote-hash", "yes", "wait", "timeout", "out", "idempotency-key"],
|
|
3901
|
+
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
3902
|
positionals: ["\u5B50\u547D\u4EE4", "\u8BA2\u5355id"],
|
|
3016
3903
|
help: [
|
|
3017
3904
|
"\u7528\u6CD5\uFF1A",
|
|
3905
|
+
" buke drama context|director|versions <\u8BA2\u5355id>",
|
|
3906
|
+
" buke drama document <\u8BA2\u5355id> --kind <\u6587\u6863\u7C7B\u578B> [--episode-number <\u96C6\u6570>]",
|
|
3907
|
+
" buke drama message|bindings|spec <\u8BA2\u5355id> --data <JSON\u6587\u4EF6|-> [--expected-epoch <\u7248\u672C>]",
|
|
3908
|
+
" buke drama director-confirm <\u8BA2\u5355id> --confirmation-id <\u786E\u8BA4\u7F16\u53F7> --yes",
|
|
3909
|
+
" \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",
|
|
3910
|
+
" buke drama shot-plan <\u8BA2\u5355id> --data <\u5206\u955CJSON\u6587\u4EF6|-> --expected-epoch <\u7248\u672C>",
|
|
3911
|
+
" buke drama select-version <\u8BA2\u5355id> --shot <\u955C\u5934id> --output-id <\u7248\u672Cid> --expected-epoch <\u7248\u672C>",
|
|
3912
|
+
" buke drama redo-quote <\u8BA2\u5355id> --expected-epoch <\u7248\u672C> [--shot <\u955C\u5934id,\u955C\u5934id>] [--data <JSON\u6587\u4EF6|->]",
|
|
3913
|
+
" buke drama redo <\u8BA2\u5355id> --data <JSON\u6587\u4EF6|-> --yes",
|
|
3018
3914
|
" 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]",
|
|
3915
|
+
" buke drama upload <\u4EFB\u52A1id> --file <\u9644\u4EF6\u8DEF\u5F84>",
|
|
3916
|
+
" buke drama attachments <\u4EFB\u52A1id> [--attachment-ids <\u7F16\u53F7,\u7F16\u53F7>] [--offset <\u504F\u79FB>]",
|
|
3917
|
+
" buke drama attachment-download <\u4EFB\u52A1id> --attachment-id <\u9644\u4EF6\u7F16\u53F7> [--out <\u8DEF\u5F84>]",
|
|
3019
3918
|
" buke drama status <\u8BA2\u5355id> [--wait] [--timeout <\u79D2>]",
|
|
3020
3919
|
" buke drama quote <\u8BA2\u5355id>",
|
|
3021
3920
|
" buke drama confirm <\u8BA2\u5355id> --quote-hash <\u62A5\u4EF7\u54C8\u5E0C> [--yes]",
|
|
3022
3921
|
" buke drama cancel <\u8BA2\u5355id>",
|
|
3023
|
-
" buke drama download <\u8BA2\u5355id> [--out <\u8DEF\u5F84>]",
|
|
3922
|
+
" 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
3923
|
"",
|
|
3025
|
-
"\u77ED\u5267\
|
|
3026
|
-
" create \
|
|
3027
|
-
" status \u67E5\u8FDB\u5EA6\
|
|
3924
|
+
"\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",
|
|
3925
|
+
" create \u521B\u5EFA\u4EFB\u52A1\uFF1B\u987B\u5148\u5EFA\u7ACB\u4EA7\u54C1\u3002\u53D7\u7406\u540E\u901A\u8FC7 status \u67E5\u8BE2\u8FDB\u5EA6",
|
|
3926
|
+
" 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
3927
|
" 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\
|
|
3928
|
+
" confirm \u786E\u8BA4\u5F53\u524D\u62A5\u4EF7\uFF1B\u6307\u5B9A --yes \u540E\u624D\u63D0\u4EA4\u5236\u4F5C\u6388\u6743",
|
|
3929
|
+
" 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
3930
|
" download \u4E0B\u8F7D\u76F4\u62FC\u597D\u7684\u6210\u7247\uFF08mp4\uFF09",
|
|
3032
3931
|
"",
|
|
3033
3932
|
"\u9009\u9879\uFF1A",
|
|
@@ -3035,16 +3934,16 @@ var COMMANDS = {
|
|
|
3035
3934
|
" --genre <\u9898\u6750id> \u9898\u6750 id\uFF08\u5982 counterattack\u3001urban-ceo\u3001family\uFF09",
|
|
3036
3935
|
" --duration <\u4F53\u91CF> \u6210\u7247\u4F53\u91CF\uFF1A30s\u300160s \u6216 90s\uFF1B\u4E0D\u7ED9\u65F6 30s",
|
|
3037
3936
|
" --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\
|
|
3937
|
+
" --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
3938
|
" --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
3939
|
" --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 \
|
|
3940
|
+
" --yes \u660E\u786E\u63D0\u4EA4\u5236\u4F5C\u786E\u8BA4\uFF1B\u7701\u7565\u65F6\u4EC5\u663E\u793A\u5F53\u524D\u62A5\u4EF7",
|
|
3941
|
+
" --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
3942
|
" --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 \
|
|
3943
|
+
" --out <\u8DEF\u5F84> \u4E0B\u8F7D\u4FDD\u5B58\u7684\u4F4D\u7F6E\uFF1B\u7701\u7565\u65F6\u4FDD\u5B58\u5230\u5F53\u524D\u76EE\u5F55",
|
|
3944
|
+
" --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",
|
|
3945
|
+
" --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF1B\u7701\u7565\u65F6\u4F7F\u7528\u767B\u5F55\u65F6\u7684\u5730\u5740",
|
|
3946
|
+
" --json \u6807\u51C6\u8F93\u51FA\u4EC5\u8FD4\u56DE\u4E00\u4E2A JSON \u6587\u6863\uFF0C\u4F9B\u811A\u672C\u89E3\u6790"
|
|
3048
3947
|
].join("\n")
|
|
3049
3948
|
}
|
|
3050
3949
|
};
|
|
@@ -3056,16 +3955,20 @@ var GENERAL_HELP = [
|
|
|
3056
3955
|
" 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
3956
|
" buke logout [--json] \u9000\u51FA\u767B\u5F55\uFF0C\u5220\u9664\u672C\u673A\u4FDD\u5B58\u7684\u5BC6\u94A5",
|
|
3058
3957
|
" buke balance [--json] \u67E5\u8BE2\u8D26\u6237\u4F59\u989D",
|
|
3059
|
-
" buke products <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u4EA7\u54C1\u5EFA\u6863\
|
|
3958
|
+
" buke products <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u4EA7\u54C1\u5EFA\u6863\u4E0E\u7BA1\u7406\uFF1Alist\u3001show\u3001create\u3001update\u3001archive\u3001restore",
|
|
3060
3959
|
" buke shorts <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u6E32\u67D3\u77ED\u7247\uFF1Acatalog\u3001upload\u3001quote\u3001order\u3001status\u3001download\u3001cancel",
|
|
3061
|
-
" buke videos <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u5546\u54C1\u89C6\u9891\
|
|
3062
|
-
" buke drama <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u77ED\u5267\
|
|
3960
|
+
" 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",
|
|
3961
|
+
" 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",
|
|
3962
|
+
" buke library <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u4F5C\u54C1\u67E5\u8BE2\u3001\u641C\u7D22\u3001\u91CD\u547D\u540D\u3001\u5F52\u6863\u53CA\u6062\u590D",
|
|
3963
|
+
" buke assets <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u5E73\u53F0\u4E0E\u4E2A\u4EBA\u7D20\u6750\u67E5\u8BE2\u3001\u4E0A\u4F20\u53CA\u7BA1\u7406",
|
|
3964
|
+
" buke graphic <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u56FE\u6587\u65B9\u6848\u3001\u62A5\u4EF7\u3001\u751F\u6210\u3001\u7F16\u8F91\u53CA\u4E0B\u8F7D",
|
|
3965
|
+
" buke series <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u591A\u96C6\u77ED\u5267\u67E5\u8BE2\u3001\u521B\u5EFA\u53CA\u7EED\u96C6",
|
|
3063
3966
|
" buke --help | -h \u663E\u793A\u8FD9\u4EFD\u8BF4\u660E\uFF1Bbuke <\u547D\u4EE4> --help \u770B\u5355\u6761\u547D\u4EE4",
|
|
3064
3967
|
" buke --version | -v \u663E\u793A\u7248\u672C\u53F7",
|
|
3065
3968
|
"",
|
|
3066
3969
|
"\u9009\u9879\uFF1A",
|
|
3067
3970
|
` --base-url <\u5730\u5740> \u670D\u52A1\u5730\u5740\uFF0C\u9ED8\u8BA4 ${DEFAULT_BASE_URL}\uFF1B\u53EA\u5199\u5230\u57DF\u540D\u4E3A\u6B62`,
|
|
3068
|
-
" --json \
|
|
3971
|
+
" --json \u6807\u51C6\u8F93\u51FA\u4EC5\u8FD4\u56DE\u4E00\u4E2A JSON \u6587\u6863\uFF0C\u4F9B\u811A\u672C\u89E3\u6790",
|
|
3069
3972
|
" -h, --help \u663E\u793A\u8BF4\u660E",
|
|
3070
3973
|
" -v, --version \u663E\u793A\u7248\u672C\u53F7",
|
|
3071
3974
|
"",
|
|
@@ -3090,7 +3993,7 @@ var GENERAL_HELP = [
|
|
|
3090
3993
|
" 10 \u8981\u627E\u7684\u4E1C\u897F\u4E0D\u5B58\u5728",
|
|
3091
3994
|
" 130 \u88AB Ctrl-C \u6253\u65AD",
|
|
3092
3995
|
"",
|
|
3093
|
-
"\
|
|
3996
|
+
"\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
3997
|
].join("\n");
|
|
3095
3998
|
var MAX_ECHO_LENGTH = 40;
|
|
3096
3999
|
function echo(item) {
|
|
@@ -3126,7 +4029,10 @@ var STRING_OPTIONS = /* @__PURE__ */ new Set([
|
|
|
3126
4029
|
"genre",
|
|
3127
4030
|
"brief"
|
|
3128
4031
|
]);
|
|
3129
|
-
var BOOLEAN_OPTIONS = /* @__PURE__ */ new Set(["help", "version", "json", "wait", "yes"]);
|
|
4032
|
+
var BOOLEAN_OPTIONS = /* @__PURE__ */ new Set(["help", "version", "json", "wait", "yes", "all"]);
|
|
4033
|
+
for (const command of Object.values(COMMANDS)) for (const option of command.options) {
|
|
4034
|
+
if (!BOOLEAN_OPTIONS.has(option)) STRING_OPTIONS.add(option);
|
|
4035
|
+
}
|
|
3130
4036
|
function parse(argv) {
|
|
3131
4037
|
try {
|
|
3132
4038
|
const options = {};
|