bukesiyi-cli 0.4.0 → 0.6.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 +93 -8
- package/dist/main.js +2097 -162
- package/package.json +3 -3
package/dist/main.js
CHANGED
|
@@ -95,6 +95,7 @@ var CliError = class _CliError extends Error {
|
|
|
95
95
|
hints;
|
|
96
96
|
recovery;
|
|
97
97
|
failures;
|
|
98
|
+
webRecovery;
|
|
98
99
|
constructor(init) {
|
|
99
100
|
super(redactKeys(init.message));
|
|
100
101
|
this.name = "CliError";
|
|
@@ -107,6 +108,7 @@ var CliError = class _CliError extends Error {
|
|
|
107
108
|
this.hints = init.hints ?? [];
|
|
108
109
|
if (init.recovery !== void 0) this.recovery = init.recovery;
|
|
109
110
|
if (init.failures !== void 0) this.failures = init.failures;
|
|
111
|
+
if (init.webRecovery !== void 0) this.webRecovery = init.webRecovery;
|
|
110
112
|
}
|
|
111
113
|
withHint(hint) {
|
|
112
114
|
return new _CliError({
|
|
@@ -119,7 +121,8 @@ var CliError = class _CliError extends Error {
|
|
|
119
121
|
httpStatus: this.httpStatus,
|
|
120
122
|
hints: [...this.hints, hint],
|
|
121
123
|
recovery: this.recovery,
|
|
122
|
-
failures: this.failures
|
|
124
|
+
failures: this.failures,
|
|
125
|
+
webRecovery: this.webRecovery
|
|
123
126
|
});
|
|
124
127
|
}
|
|
125
128
|
withRecovery(recovery) {
|
|
@@ -133,9 +136,13 @@ var CliError = class _CliError extends Error {
|
|
|
133
136
|
httpStatus: this.httpStatus,
|
|
134
137
|
hints: this.hints,
|
|
135
138
|
recovery,
|
|
136
|
-
failures: this.failures
|
|
139
|
+
failures: this.failures,
|
|
140
|
+
webRecovery: this.webRecovery
|
|
137
141
|
});
|
|
138
142
|
}
|
|
143
|
+
withWebRecovery(webRecovery) {
|
|
144
|
+
return new _CliError({ ...this, message: this.message, webRecovery });
|
|
145
|
+
}
|
|
139
146
|
};
|
|
140
147
|
function usageError(message2) {
|
|
141
148
|
return new CliError({ code: "CLI_USAGE", exitCode: EXIT.USAGE, message: `${message2}\u3002\u8FD0\u884C buke --help \u770B\u7528\u6CD5` });
|
|
@@ -265,10 +272,10 @@ function toBuffer(chunk) {
|
|
|
265
272
|
return Buffer.from(chunk);
|
|
266
273
|
}
|
|
267
274
|
function readToEnd(stdin, timeoutMs, signal) {
|
|
268
|
-
return new Promise((
|
|
275
|
+
return new Promise((resolve3, reject) => {
|
|
269
276
|
const state = stdin;
|
|
270
277
|
if (state.readableEnded === true || state.destroyed === true) {
|
|
271
|
-
|
|
278
|
+
resolve3("");
|
|
272
279
|
return;
|
|
273
280
|
}
|
|
274
281
|
const chunks = [];
|
|
@@ -296,7 +303,7 @@ function readToEnd(stdin, timeoutMs, signal) {
|
|
|
296
303
|
}
|
|
297
304
|
chunks.push(piece);
|
|
298
305
|
};
|
|
299
|
-
const onEnd = () => settle(() =>
|
|
306
|
+
const onEnd = () => settle(() => resolve3(Buffer.concat(chunks).toString("utf8").trim()));
|
|
300
307
|
const onError = (error) => settle(() => reject(missingKey(`\u6CA1\u6709\u8BFB\u5230\u5BC6\u94A5\uFF1A\u6807\u51C6\u8F93\u5165\u51FA\u9519\uFF08${briefReason(error)}\uFF09`)));
|
|
301
308
|
const timer = setTimeout(() => {
|
|
302
309
|
settle(
|
|
@@ -316,7 +323,7 @@ function readToEnd(stdin, timeoutMs, signal) {
|
|
|
316
323
|
});
|
|
317
324
|
}
|
|
318
325
|
function readHiddenLine(stdin, signal) {
|
|
319
|
-
return new Promise((
|
|
326
|
+
return new Promise((resolve3, reject) => {
|
|
320
327
|
let typed = "";
|
|
321
328
|
let escape = "none";
|
|
322
329
|
let settled = false;
|
|
@@ -347,7 +354,7 @@ function readHiddenLine(stdin, signal) {
|
|
|
347
354
|
continue;
|
|
348
355
|
}
|
|
349
356
|
if (char === "\r" || char === "\n") {
|
|
350
|
-
settle(() =>
|
|
357
|
+
settle(() => resolve3(typed));
|
|
351
358
|
return;
|
|
352
359
|
}
|
|
353
360
|
if (char === CTRL_C) {
|
|
@@ -355,7 +362,7 @@ function readHiddenLine(stdin, signal) {
|
|
|
355
362
|
return;
|
|
356
363
|
}
|
|
357
364
|
if (char === CTRL_D) {
|
|
358
|
-
settle(() => typed === "" ? reject(missingKey(NO_KEY_READ)) :
|
|
365
|
+
settle(() => typed === "" ? reject(missingKey(NO_KEY_READ)) : resolve3(typed));
|
|
359
366
|
return;
|
|
360
367
|
}
|
|
361
368
|
if (char === DELETE || char === BACKSPACE) {
|
|
@@ -375,7 +382,7 @@ function readHiddenLine(stdin, signal) {
|
|
|
375
382
|
}
|
|
376
383
|
if (escape === "started") escape = "carried";
|
|
377
384
|
};
|
|
378
|
-
const onEnd = () => settle(() =>
|
|
385
|
+
const onEnd = () => settle(() => resolve3(typed));
|
|
379
386
|
const onError = (error) => settle(() => reject(missingKey(`\u6CA1\u6709\u8BFB\u5230\u5BC6\u94A5\uFF1A\u6807\u51C6\u8F93\u5165\u51FA\u9519\uFF08${briefReason(error)}\uFF09`)));
|
|
380
387
|
const onAbort = () => settle(() => reject(interruptedError(CANCELLED)));
|
|
381
388
|
stdin.on("data", onData);
|
|
@@ -420,7 +427,7 @@ async function readNewKey(io) {
|
|
|
420
427
|
|
|
421
428
|
// package.json
|
|
422
429
|
var name = "bukesiyi-cli";
|
|
423
|
-
var version = "0.
|
|
430
|
+
var version = "0.6.0";
|
|
424
431
|
|
|
425
432
|
// src/version.ts
|
|
426
433
|
var PACKAGE_NAME = name;
|
|
@@ -440,9 +447,25 @@ function taskRecovery(taskType, taskId, status4, baseUrl, failureCode) {
|
|
|
440
447
|
...customOrigin ? { baseUrl } : {},
|
|
441
448
|
...failureCode === void 0 || failureCode === "" ? {} : { failureCode },
|
|
442
449
|
nextAction: "query",
|
|
443
|
-
statusCommand: `buke ${taskType} status ${shellArgument(taskId)}` + (customOrigin ? ` --base-url ${shellArgument(baseUrl)}` : "")
|
|
450
|
+
statusCommand: `buke ${taskType} ${taskType === "products" ? "show" : "status"} ${shellArgument(taskId)}` + (customOrigin ? ` --base-url ${shellArgument(baseUrl)}` : "")
|
|
444
451
|
};
|
|
445
452
|
}
|
|
453
|
+
async function retainMutationOnError(taskType, taskId, idempotencyKey, baseUrl, operation, extra = {}) {
|
|
454
|
+
try {
|
|
455
|
+
return await operation();
|
|
456
|
+
} catch (error) {
|
|
457
|
+
const failure = toCliError(error);
|
|
458
|
+
const rejected = failure.httpStatus !== void 0 && failure.httpStatus >= 400 && failure.httpStatus < 500 && failure.httpStatus !== 408;
|
|
459
|
+
throw failure.withRecovery({
|
|
460
|
+
...taskRecovery(taskType, taskId, void 0, baseUrl),
|
|
461
|
+
acceptance: "unknown",
|
|
462
|
+
idempotencyKey,
|
|
463
|
+
operationOutcome: rejected ? "rejected" : "unknown",
|
|
464
|
+
...extra,
|
|
465
|
+
...failure.recovery
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
}
|
|
446
469
|
function dramaConfirmationRecovery(orderId, status4, baseUrl, idempotencyKey, operationOutcome) {
|
|
447
470
|
return {
|
|
448
471
|
...taskRecovery("drama", orderId, status4, baseUrl),
|
|
@@ -762,11 +785,11 @@ async function requestJson(baseUrl, apiKey, plan, deps) {
|
|
|
762
785
|
async function getJson(baseUrl, apiKey, path, deps) {
|
|
763
786
|
return requestJson(baseUrl, apiKey, { method: "GET", path }, deps);
|
|
764
787
|
}
|
|
765
|
-
async function postJson(baseUrl, apiKey, path, body, idempotencyKey, deps) {
|
|
788
|
+
async function postJson(baseUrl, apiKey, path, body, idempotencyKey, deps, options = {}) {
|
|
766
789
|
return requestJson(
|
|
767
790
|
baseUrl,
|
|
768
791
|
apiKey,
|
|
769
|
-
{ method: "POST", path, body: JSON.stringify(body), contentType: "application/json", idempotencyKey },
|
|
792
|
+
{ method: "POST", path, body: JSON.stringify(body), contentType: "application/json", idempotencyKey, ...options },
|
|
770
793
|
deps
|
|
771
794
|
);
|
|
772
795
|
}
|
|
@@ -845,6 +868,28 @@ function assetMimeMatchesBytes(mime, bytes) {
|
|
|
845
868
|
if (mime === "audio/wav" || mime === "audio/x-wav") return bytes.length > 44 && bytes.toString("ascii", 0, 4) === "RIFF" && bytes.toString("ascii", 8, 12) === "WAVE";
|
|
846
869
|
if (mime === "video/webm" || mime === "audio/webm") return bytes.length >= 8 && bytes.subarray(0, 4).toString("hex") === "1a45dfa3" && bytes.subarray(4, 4096).includes(Buffer.from("webm"));
|
|
847
870
|
if (mime === "audio/mpeg") return bytes.length >= 3 && (bytes.toString("ascii", 0, 3) === "ID3" || bytes[0] === 255 && (bytes[1] & 224) === 224);
|
|
871
|
+
if (mime === "audio/aac") {
|
|
872
|
+
if (bytes.length < 7 || bytes[0] !== 255 || (bytes[1] & 246) !== 240 || (bytes[2] >> 2 & 15) > 12) return false;
|
|
873
|
+
const headerBytes = bytes[1] & 1 ? 7 : 9;
|
|
874
|
+
const frameBytes = (bytes[3] & 3) << 11 | bytes[4] << 3 | bytes[5] >> 5;
|
|
875
|
+
return frameBytes > headerBytes && frameBytes <= bytes.length;
|
|
876
|
+
}
|
|
877
|
+
if (mime === "audio/ogg") {
|
|
878
|
+
if (bytes.length < 28 || bytes.toString("ascii", 0, 4) !== "OggS" || bytes[4] !== 0) return false;
|
|
879
|
+
const segments = bytes[26], headerBytes = 27 + segments;
|
|
880
|
+
if (segments === 0 || headerBytes > bytes.length) return false;
|
|
881
|
+
const payloadBytes = bytes.subarray(27, headerBytes).reduce((sum, length) => sum + length, 0);
|
|
882
|
+
return payloadBytes > 0 && headerBytes + payloadBytes <= bytes.length;
|
|
883
|
+
}
|
|
884
|
+
if (mime === "text/vtt") return !bytes.includes(0) && /^\uFEFF?WEBVTT(?:[ \t][^\r\n]*)?(?:\r?\n|$)/u.test(bytes.toString("utf8", 0, Math.min(bytes.length, 4096)));
|
|
885
|
+
if (mime === "application/x-subrip") {
|
|
886
|
+
if (bytes.includes(0)) return false;
|
|
887
|
+
const cue = /^\uFEFF?\s*\d+\r?\n(\d{2,}):([0-5]\d):([0-5]\d),(\d{3})[ \t]+-->[ \t]+(\d{2,}):([0-5]\d):([0-5]\d),(\d{3})(?:[ \t][^\r\n]*)?\r?\n/u.exec(bytes.toString("utf8", 0, Math.min(bytes.length, 4096)));
|
|
888
|
+
if (!cue) return false;
|
|
889
|
+
const start = ((Number(cue[1]) * 60 + Number(cue[2])) * 60 + Number(cue[3])) * 1e3 + Number(cue[4]);
|
|
890
|
+
const end = ((Number(cue[5]) * 60 + Number(cue[6])) * 60 + Number(cue[7])) * 1e3 + Number(cue[8]);
|
|
891
|
+
return Number.isSafeInteger(start) && Number.isSafeInteger(end) && end > start;
|
|
892
|
+
}
|
|
848
893
|
if (mime === "application/pdf") {
|
|
849
894
|
let offset = bytes.length >= 3 && bytes.subarray(0, 3).toString("hex") === "efbbbf" ? 3 : 0;
|
|
850
895
|
const limit = Math.min(bytes.length, 1024);
|
|
@@ -1066,7 +1111,7 @@ function parseDramaOrder(body) {
|
|
|
1066
1111
|
const money = parseDramaMoney(order2.money);
|
|
1067
1112
|
if (money === null) problems.push("money");
|
|
1068
1113
|
const actionsValue = Array.isArray(order2.nextActions) ? order2.nextActions : null;
|
|
1069
|
-
const actions = actionsValue === null ? [] : actionsValue.filter((
|
|
1114
|
+
const actions = actionsValue === null ? [] : actionsValue.filter((action2) => typeof action2 === "string");
|
|
1070
1115
|
if (actionsValue === null || actions.length !== actionsValue.length) problems.push("nextActions");
|
|
1071
1116
|
const gapsValue = order2.gaps === void 0 ? void 0 : Array.isArray(order2.gaps) ? order2.gaps : null;
|
|
1072
1117
|
if (order2.gaps !== void 0 && gapsValue === null) problems.push("gaps");
|
|
@@ -1160,7 +1205,11 @@ function parseRun(body) {
|
|
|
1160
1205
|
problems.push("message");
|
|
1161
1206
|
return { role: "", text: "" };
|
|
1162
1207
|
}
|
|
1163
|
-
return {
|
|
1208
|
+
return {
|
|
1209
|
+
role: typeof message2.role === "string" ? message2.role : "",
|
|
1210
|
+
text: message2.text,
|
|
1211
|
+
...typeof message2.earlierAttemptOf === "string" && message2.earlierAttemptOf ? { earlierAttemptOf: message2.earlierAttemptOf } : {}
|
|
1212
|
+
};
|
|
1164
1213
|
});
|
|
1165
1214
|
const failureValue = isRecord2(run2.failure) ? run2.failure : null;
|
|
1166
1215
|
const failure = failureValue ? {
|
|
@@ -1181,8 +1230,8 @@ function parseRun(body) {
|
|
|
1181
1230
|
productionConfirmed: run2.productionConfirmed === true,
|
|
1182
1231
|
...currentProductionCredits !== void 0 ? { currentProductionCredits } : {},
|
|
1183
1232
|
product: product ? { id: text(product.id), name: text(product.name) } : { id: "", name: "" },
|
|
1184
|
-
nextActions: actions === null ? [] : actions.map((
|
|
1185
|
-
const parsed2 = parseRunAction(
|
|
1233
|
+
nextActions: actions === null ? [] : actions.map((action2) => {
|
|
1234
|
+
const parsed2 = parseRunAction(action2);
|
|
1186
1235
|
if (parsed2 === null) problems.push("action");
|
|
1187
1236
|
return parsed2 ?? { type: "" };
|
|
1188
1237
|
}),
|
|
@@ -1221,45 +1270,51 @@ async function getBalance(baseUrl, apiKey, deps) {
|
|
|
1221
1270
|
return { view: balance2, raw: reply.body };
|
|
1222
1271
|
}
|
|
1223
1272
|
async function createProduct(baseUrl, apiKey, name2, category, idempotencyKey, deps, fields3 = {}) {
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1273
|
+
return retainSubmissionOnError("products", idempotencyKey, baseUrl, async () => {
|
|
1274
|
+
const reply = await postJson(
|
|
1275
|
+
baseUrl,
|
|
1276
|
+
apiKey,
|
|
1277
|
+
"/api/open/v1/products",
|
|
1278
|
+
{ ...fields3, name: name2, ...category === void 0 ? {} : { category } },
|
|
1279
|
+
idempotencyKey,
|
|
1280
|
+
deps
|
|
1281
|
+
);
|
|
1282
|
+
const product = parseProduct(reply.body);
|
|
1283
|
+
if (!product || !isRecord2(reply.body)) throw unreadableResponse(reply.status);
|
|
1284
|
+
return { view: product, raw: reply.body, replayed: reply.status === 200 };
|
|
1285
|
+
});
|
|
1235
1286
|
}
|
|
1236
1287
|
async function putProductImage(baseUrl, apiKey, productId, angle, bytes, contentType, idempotencyKey, deps) {
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1288
|
+
return retainMutationOnError("products", productId, idempotencyKey, baseUrl, async () => {
|
|
1289
|
+
const reply = await putRaw(
|
|
1290
|
+
baseUrl,
|
|
1291
|
+
apiKey,
|
|
1292
|
+
`/api/open/v1/products/${encodeURIComponent(productId)}/images?angle=${angle}`,
|
|
1293
|
+
bytes,
|
|
1294
|
+
contentType,
|
|
1295
|
+
idempotencyKey,
|
|
1296
|
+
deps
|
|
1297
|
+
);
|
|
1298
|
+
const product = parseProduct(reply.body);
|
|
1299
|
+
if (!product || !isRecord2(reply.body)) throw unreadableResponse(reply.status);
|
|
1300
|
+
return { view: product, raw: reply.body, replayed: reply.status === 200 };
|
|
1301
|
+
});
|
|
1249
1302
|
}
|
|
1250
1303
|
async function confirmProductLock(baseUrl, apiKey, productId, lock, idempotencyKey, deps) {
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1304
|
+
return retainMutationOnError("products", productId, idempotencyKey, baseUrl, async () => {
|
|
1305
|
+
const reply = await postJson(
|
|
1306
|
+
baseUrl,
|
|
1307
|
+
apiKey,
|
|
1308
|
+
`/api/open/v1/products/${encodeURIComponent(productId)}/lock/confirm`,
|
|
1309
|
+
{ productLock: lock },
|
|
1310
|
+
idempotencyKey,
|
|
1311
|
+
deps
|
|
1312
|
+
);
|
|
1313
|
+
const productLock = parseProductLock(reply.body);
|
|
1314
|
+
const product = parseProduct(reply.body);
|
|
1315
|
+
if (!productLock || !product || !isRecord2(reply.body)) throw unreadableResponse(reply.status);
|
|
1316
|
+
return { view: { productLock, product }, raw: reply.body };
|
|
1317
|
+
});
|
|
1263
1318
|
}
|
|
1264
1319
|
async function getTemplateShortCatalog(baseUrl, apiKey, deps) {
|
|
1265
1320
|
const reply = await getJson(baseUrl, apiKey, "/api/open/v1/template-shorts", deps);
|
|
@@ -1269,9 +1324,9 @@ async function getTemplateShortCatalog(baseUrl, apiKey, deps) {
|
|
|
1269
1324
|
}
|
|
1270
1325
|
async function uploadTemplateShortAsset(baseUrl, apiKey, bytes, contentType, idempotencyKey, deps) {
|
|
1271
1326
|
const reply = await postRaw(baseUrl, apiKey, "/api/open/v1/template-shorts/uploads", bytes, contentType, idempotencyKey, deps);
|
|
1272
|
-
const
|
|
1273
|
-
if (!
|
|
1274
|
-
return { view:
|
|
1327
|
+
const upload3 = parseUpload(reply.body);
|
|
1328
|
+
if (!upload3 || !isRecord2(reply.body)) throw unreadableResponse(reply.status);
|
|
1329
|
+
return { view: upload3, raw: reply.body };
|
|
1275
1330
|
}
|
|
1276
1331
|
async function quoteTemplateShort(baseUrl, apiKey, templateId, props, idempotencyKey, deps) {
|
|
1277
1332
|
const reply = await postJson(
|
|
@@ -1329,13 +1384,13 @@ async function runReplyOf(reply) {
|
|
|
1329
1384
|
return { view: run2, raw: reply.body };
|
|
1330
1385
|
}
|
|
1331
1386
|
async function createVideoRun(baseUrl, apiKey, body, idempotencyKey, deps) {
|
|
1332
|
-
return runReplyOf(await postJson(baseUrl, apiKey, "/api/open/v1/videos", body, idempotencyKey, deps));
|
|
1387
|
+
return retainSubmissionOnError("videos", idempotencyKey, baseUrl, async () => runReplyOf(await postJson(baseUrl, apiKey, "/api/open/v1/videos", body, idempotencyKey, deps)));
|
|
1333
1388
|
}
|
|
1334
1389
|
async function getVideoRun(baseUrl, apiKey, runId, deps) {
|
|
1335
1390
|
return runReplyOf(await getJson(baseUrl, apiKey, `/api/open/v1/videos/${encodeURIComponent(runId)}`, deps));
|
|
1336
1391
|
}
|
|
1337
1392
|
async function confirmVideoProduction(baseUrl, apiKey, runId, expectedVersion, confirmation, idempotencyKey, deps) {
|
|
1338
|
-
return runReplyOf(
|
|
1393
|
+
return retainMutationOnError("videos", runId, idempotencyKey, baseUrl, async () => runReplyOf(
|
|
1339
1394
|
await postJson(
|
|
1340
1395
|
baseUrl,
|
|
1341
1396
|
apiKey,
|
|
@@ -1344,16 +1399,18 @@ async function confirmVideoProduction(baseUrl, apiKey, runId, expectedVersion, c
|
|
|
1344
1399
|
idempotencyKey,
|
|
1345
1400
|
deps
|
|
1346
1401
|
)
|
|
1347
|
-
);
|
|
1402
|
+
), { operation: "confirm", videoConfirmation: { expectedVersion, confirmation } });
|
|
1348
1403
|
}
|
|
1349
1404
|
async function downloadVideo(baseUrl, apiKey, runId, deps) {
|
|
1350
1405
|
return downloadFile(baseUrl, apiKey, `/api/open/v1/videos/${encodeURIComponent(runId)}/download`, deps);
|
|
1351
1406
|
}
|
|
1352
1407
|
async function createDramaOrder(baseUrl, apiKey, body, idempotencyKey, deps) {
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1408
|
+
return retainSubmissionOnError("drama", idempotencyKey, baseUrl, async () => {
|
|
1409
|
+
const reply = await postJson(baseUrl, apiKey, "/api/open/v1/drama/orders", body, idempotencyKey, deps);
|
|
1410
|
+
const view = parseDramaOrder(reply.body);
|
|
1411
|
+
if (!view || !isRecord2(reply.body)) throw unreadableResponse(reply.status);
|
|
1412
|
+
return { view, raw: reply.body, replayed: reply.status === 200 };
|
|
1413
|
+
});
|
|
1357
1414
|
}
|
|
1358
1415
|
async function getDramaOrder(baseUrl, apiKey, orderId, deps) {
|
|
1359
1416
|
const reply = await getJson(baseUrl, apiKey, `/api/open/v1/drama/orders/${encodeURIComponent(orderId)}`, deps);
|
|
@@ -1407,7 +1464,7 @@ var ORDER_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["succeeded", "failed", "c
|
|
|
1407
1464
|
var RUN_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["succeeded", "failed", "canceled"]);
|
|
1408
1465
|
var RUN_WAITING_FOR_USER_STATUSES = /* @__PURE__ */ new Set(["needs_input", "awaiting_reply", "awaiting_confirmation"]);
|
|
1409
1466
|
var DRAMA_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["delivered", "failed", "canceled", "partial"]);
|
|
1410
|
-
var DRAMA_WAITING_FOR_USER_STATUSES = /* @__PURE__ */ new Set(["needs_attention"]);
|
|
1467
|
+
var DRAMA_WAITING_FOR_USER_STATUSES = /* @__PURE__ */ new Set(["needs_attention", "quotable"]);
|
|
1411
1468
|
async function awaitTemplateShortOrder(baseUrl, apiKey, start, deps, wait2) {
|
|
1412
1469
|
let current = start;
|
|
1413
1470
|
if (ORDER_TERMINAL_STATUSES.has(current.view.status)) return { value: current, timedOut: false };
|
|
@@ -1565,6 +1622,9 @@ function locate(io) {
|
|
|
1565
1622
|
}
|
|
1566
1623
|
return { dir: join(home, ".config", "buke"), ours: true };
|
|
1567
1624
|
}
|
|
1625
|
+
function credentialsDir(io) {
|
|
1626
|
+
return locate(io).dir;
|
|
1627
|
+
}
|
|
1568
1628
|
function credentialsPath(io) {
|
|
1569
1629
|
return join(locate(io).dir, FILE_NAME);
|
|
1570
1630
|
}
|
|
@@ -1855,11 +1915,20 @@ async function readPropsArgument(io, ref, what) {
|
|
|
1855
1915
|
return parsed;
|
|
1856
1916
|
}
|
|
1857
1917
|
async function readStdinAll(io, maxBytes, what) {
|
|
1918
|
+
if (io.signal?.aborted) throw interruptedError();
|
|
1858
1919
|
const stdin = io.stdin;
|
|
1859
1920
|
if (stdin.readableEnded === true) return "";
|
|
1860
1921
|
const chunks = [];
|
|
1861
1922
|
let size = 0;
|
|
1862
|
-
await new Promise((
|
|
1923
|
+
await new Promise((resolve3, reject) => {
|
|
1924
|
+
const onAbort = () => {
|
|
1925
|
+
cleanup();
|
|
1926
|
+
reject(interruptedError());
|
|
1927
|
+
};
|
|
1928
|
+
const timer = setTimeout(() => {
|
|
1929
|
+
cleanup();
|
|
1930
|
+
reject(new CliError({ code: "CLI_STDIN_TIMEOUT", exitCode: EXIT.USAGE, message: `${what}\u6807\u51C6\u8F93\u5165\u7B49\u5F85\u8D85\u65F6\uFF0C\u8BF7\u63D0\u4F9B\u5B8C\u6574 JSON \u5E76\u5173\u95ED\u8F93\u5165\u6D41` }));
|
|
1931
|
+
}, io.stdinTimeoutMs ?? DEFAULT_STDIN_TIMEOUT_MS);
|
|
1863
1932
|
const toBuffer2 = (chunk) => typeof chunk === "string" ? Buffer.from(chunk, "utf8") : Buffer.from(chunk);
|
|
1864
1933
|
const onData = (chunk) => {
|
|
1865
1934
|
const piece = toBuffer2(chunk);
|
|
@@ -1873,25 +1942,49 @@ async function readStdinAll(io, maxBytes, what) {
|
|
|
1873
1942
|
};
|
|
1874
1943
|
const onEnd = () => {
|
|
1875
1944
|
cleanup();
|
|
1876
|
-
|
|
1945
|
+
resolve3();
|
|
1877
1946
|
};
|
|
1878
1947
|
const onError = (error) => {
|
|
1879
1948
|
cleanup();
|
|
1880
1949
|
reject(new CliError({ code: "CLI_USAGE", exitCode: EXIT.USAGE, message: `\u6807\u51C6\u8F93\u5165\u8BFB\u4E0D\u4E86\uFF1A${briefReason(error)}` }));
|
|
1881
1950
|
};
|
|
1951
|
+
const onClose = () => onError(new Error("\u6807\u51C6\u8F93\u5165\u63D0\u524D\u5173\u95ED"));
|
|
1882
1952
|
const cleanup = () => {
|
|
1953
|
+
clearTimeout(timer);
|
|
1954
|
+
io.signal?.removeEventListener("abort", onAbort);
|
|
1883
1955
|
stdin.removeListener("data", onData);
|
|
1884
1956
|
stdin.removeListener("end", onEnd);
|
|
1885
1957
|
stdin.removeListener("error", onError);
|
|
1958
|
+
stdin.removeListener("close", onClose);
|
|
1886
1959
|
stdin.pause();
|
|
1887
1960
|
};
|
|
1888
1961
|
stdin.on("data", onData);
|
|
1889
1962
|
stdin.on("end", onEnd);
|
|
1890
1963
|
stdin.on("error", onError);
|
|
1964
|
+
stdin.on("close", onClose);
|
|
1965
|
+
io.signal?.addEventListener("abort", onAbort, { once: true });
|
|
1891
1966
|
stdin.resume();
|
|
1892
1967
|
});
|
|
1893
1968
|
return Buffer.concat(chunks).toString("utf8");
|
|
1894
1969
|
}
|
|
1970
|
+
async function sleepFor(io, ms) {
|
|
1971
|
+
if (io.signal?.aborted) throw interruptedError();
|
|
1972
|
+
let timer;
|
|
1973
|
+
let stop = () => void 0;
|
|
1974
|
+
const interrupted = new Promise((_resolve, reject) => {
|
|
1975
|
+
stop = () => reject(interruptedError());
|
|
1976
|
+
io.signal?.addEventListener("abort", stop, { once: true });
|
|
1977
|
+
});
|
|
1978
|
+
const sleeping = io.sleep ? io.sleep(ms) : new Promise((resolve3) => {
|
|
1979
|
+
timer = setTimeout(resolve3, ms);
|
|
1980
|
+
});
|
|
1981
|
+
try {
|
|
1982
|
+
await Promise.race([sleeping, interrupted]);
|
|
1983
|
+
} finally {
|
|
1984
|
+
clearTimeout(timer);
|
|
1985
|
+
io.signal?.removeEventListener("abort", stop);
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1895
1988
|
async function readImageFile(path) {
|
|
1896
1989
|
let bytes;
|
|
1897
1990
|
try {
|
|
@@ -1917,9 +2010,9 @@ function sniffImageContentType(bytes) {
|
|
|
1917
2010
|
return void 0;
|
|
1918
2011
|
}
|
|
1919
2012
|
async function readUploadFile(path) {
|
|
1920
|
-
const { stat:
|
|
2013
|
+
const { stat: stat3 } = await import("node:fs/promises");
|
|
1921
2014
|
try {
|
|
1922
|
-
const info = await
|
|
2015
|
+
const info = await stat3(path);
|
|
1923
2016
|
if (!info.isFile() || info.size === 0 || info.size > MAX_IMAGE_BYTES) throw usageError("\u4E0A\u4F20\u6587\u4EF6\u5FC5\u987B\u4E3A 1 \u5B57\u8282\u81F3 64 MiB \u7684\u666E\u901A\u6587\u4EF6");
|
|
1924
2017
|
const bytes = await readFile(path);
|
|
1925
2018
|
if (bytes.byteLength === 0 || bytes.byteLength > MAX_IMAGE_BYTES) throw usageError("\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8D85\u51FA\u5141\u8BB8\u8303\u56F4");
|
|
@@ -1937,6 +2030,7 @@ import { createHash as createHash2 } from "node:crypto";
|
|
|
1937
2030
|
import { writeFile } from "node:fs/promises";
|
|
1938
2031
|
var SUBCOMMANDS = "catalog\u3001upload\u3001quote\u3001order\u3001status\u3001download \u548C cancel";
|
|
1939
2032
|
async function shorts(context) {
|
|
2033
|
+
timeoutSecondsOf(context.values, DEFAULT_WAIT_TIMEOUT_MS / 1e3);
|
|
1940
2034
|
const { args } = context;
|
|
1941
2035
|
const [subcommand] = args;
|
|
1942
2036
|
if (subcommand === void 0) {
|
|
@@ -1968,7 +2062,7 @@ function waitControls(io, values, note) {
|
|
|
1968
2062
|
return {
|
|
1969
2063
|
timeoutMs: timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3) * 1e3,
|
|
1970
2064
|
now: io.now ?? (() => /* @__PURE__ */ new Date()),
|
|
1971
|
-
sleep:
|
|
2065
|
+
sleep: (ms) => sleepFor(io, ms),
|
|
1972
2066
|
note
|
|
1973
2067
|
};
|
|
1974
2068
|
}
|
|
@@ -2139,8 +2233,8 @@ var graphicCommand = {
|
|
|
2139
2233
|
"message <\u9879\u76EEID> --text <\u8981\u6C42> [--attachment-ids <ID,ID>] [--edit-image <\u56FE\u7247ID>] [--source-image <\u56FE\u7247ID>] [--choice <\u9009\u9879ID>] [--wait]",
|
|
2140
2234
|
"retry <\u9879\u76EEID> <\u6D88\u606FID> [--wait]\uFF1A\u91CD\u8BD5\u539F\u514D\u8D39\u6587\u6848\u56DE\u5408\u3002\u6D88\u606F\u4E0D\u4F1A\u81EA\u52A8\u6388\u6743\u51FA\u56FE\u3002",
|
|
2141
2235
|
"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>]
|
|
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",
|
|
2236
|
+
"generate <\u9879\u76EEID> [--image-indexes <1,2>] --quote-hash <\u5DF2\u67E5\u770B\u7684\u62A5\u4EF7\u54C8\u5E0C> --yes [--wait]\uFF1A\u62A5\u4EF7\u672A\u53D8\u65F6\u751F\u6210\uFF1B\u4E0D\u5E26 --yes \u4EC5\u9884\u89C8\u3002",
|
|
2237
|
+
"\u5C40\u90E8\u4FEE\u6539\uFF1Aquote/generate <\u9879\u76EEID> --edit-image <\u56FE\u7247ID> --text <\u4FEE\u6539\u8981\u6C42> [--mask <\u9009\u533AID>]\u3002generate \u4ECD\u987B --quote-hash \u548C --yes\u3002",
|
|
2144
2238
|
"model <\u9879\u76EEID> --model <\u6A21\u578B> | quality <\u9879\u76EEID> --quality <\u6863\u4F4D> | bind-product <\u9879\u76EEID> --product <\u4EA7\u54C1ID>",
|
|
2145
2239
|
"upload <\u9879\u76EEID> --file <\u56FE\u7247\u6216\u6587\u6863> | attachments <\u9879\u76EEID> [--attachment-ids <ID,ID>] [--limit <\u6570\u91CF>] [--offset <\u504F\u79FB>]",
|
|
2146
2240
|
"mask <\u9879\u76EEID> <\u56FE\u7247ID> --file <PNG\u9009\u533A> | save-edit <\u9879\u76EEID> <\u56FE\u7247ID> --file <\u7F16\u8F91\u540E\u56FE\u7247>",
|
|
@@ -2188,13 +2282,13 @@ function lines(run2) {
|
|
|
2188
2282
|
async function wait(context, baseUrl, apiKey, initial) {
|
|
2189
2283
|
if (context.values.wait !== true) return initial;
|
|
2190
2284
|
const now = context.io.now ?? (() => /* @__PURE__ */ new Date());
|
|
2191
|
-
const sleep = context.io.sleep ?? ((ms) => new Promise((resolve2) => setTimeout(resolve2, ms)));
|
|
2192
2285
|
const until = now().getTime() + timeoutSecondsOf(context.values, DEFAULT_WAIT_TIMEOUT_MS / 1e3) * 1e3;
|
|
2193
2286
|
let run2 = initial;
|
|
2194
2287
|
return retainTaskOnError(() => taskRecovery("graphic", run2.id, run2.status, baseUrl), async () => {
|
|
2195
2288
|
while (["preparing", "generating"].includes(run2.status)) {
|
|
2196
2289
|
if (now().getTime() >= until) throw new CliError({ code: "CLI_WAIT_TIMEOUT", exitCode: EXIT.WAIT_TIMEOUT, message: `\u7B49\u5F85\u5DF2\u8FBE\u5230\u65F6\u9650\uFF0C\u9879\u76EE\u5F53\u524D\u72B6\u6001\u4E3A ${singleLine(run2.status)}\uFF1B\u53EF\u67E5\u8BE2\u539F\u9879\u76EE\u7EE7\u7EED\u7B49\u5F85\u3002` });
|
|
2197
|
-
await
|
|
2290
|
+
await sleepFor(context.io, Math.min(1500, Math.max(until - now().getTime(), 1)));
|
|
2291
|
+
if (now().getTime() >= until) continue;
|
|
2198
2292
|
run2 = await getGraphicRun(baseUrl, apiKey, run2.id, context.io);
|
|
2199
2293
|
}
|
|
2200
2294
|
if (["failed", "canceled"].includes(run2.status)) throw new CliError({ code: "CLI_TASK_FAILED", exitCode: EXIT.TASK_FAILED, message: `\u56FE\u6587\u4EFB\u52A1\u72B6\u6001\u4E3A ${run2.status}\uFF1B\u5DF2\u5B8C\u6210\u7684\u56FE\u7247\u4FDD\u7559\u5728\u539F\u9879\u76EE\u4E2D\u3002` });
|
|
@@ -2213,11 +2307,20 @@ async function uploadFile(path) {
|
|
|
2213
2307
|
}
|
|
2214
2308
|
async function graphic(context) {
|
|
2215
2309
|
const { args, values, io, out } = context;
|
|
2310
|
+
timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3);
|
|
2216
2311
|
const command = required2(args[0], "\u56FE\u6587\u5B50\u547D\u4EE4\uFF1B\u8FD0\u884C buke graphic --help \u67E5\u770B\u8BF4\u660E");
|
|
2217
2312
|
const known = ["create", "list", "templates", "status", "message", "retry", "plan", "quote", "generate", "model", "quality", "bind-product", "attachments", "upload", "versions", "download", "save-edit", "mask", "cancel"];
|
|
2218
2313
|
if (!known.includes(command)) throw usageError(`\u672A\u77E5\u56FE\u6587\u5B50\u547D\u4EE4\uFF1A${command}`);
|
|
2219
2314
|
const id = ["create", "list", "templates"].includes(command) ? void 0 : required2(args[1], "\u56FE\u6587\u9879\u76EE ID");
|
|
2315
|
+
if (["quote", "generate"].includes(command)) {
|
|
2316
|
+
for (const option of ["expected-version", "expected-credits"]) {
|
|
2317
|
+
if (values[option] !== void 0) throw usageError(`graphic ${command} \u4E0D\u652F\u6301 --${option}\uFF1B\u8BF7\u4F7F\u7528\u5DF2\u67E5\u770B\u7684 --quote-hash \u7ED1\u5B9A\u62A5\u4EF7`);
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2220
2320
|
const selected = ["quote", "generate"].includes(command) ? selection(context) : {};
|
|
2321
|
+
const expectedQuoteHash = textOption(values, "quote-hash")?.toLowerCase();
|
|
2322
|
+
if (["quote", "generate"].includes(command) && values["quote-hash"] !== void 0 && (expectedQuoteHash === void 0 || !/^[a-f0-9]{64}$/u.test(expectedQuoteHash))) throw usageError("--quote-hash \u5FC5\u987B\u662F\u5DF2\u67E5\u770B\u7684 64 \u4F4D\u5341\u516D\u8FDB\u5236\u62A5\u4EF7\u54C8\u5E0C");
|
|
2323
|
+
if (command === "generate" && values.yes === true && expectedQuoteHash === void 0) throw usageError("\u786E\u8BA4\u751F\u6210\u5FC5\u987B\u63D0\u4F9B\u5DF2\u67E5\u770B\u7684 --quote-hash\uFF1B\u5148\u4E0D\u5E26 --yes \u67E5\u770B\u62A5\u4EF7");
|
|
2221
2324
|
const key = idempotencyKeyOf(values);
|
|
2222
2325
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2223
2326
|
const path = id ? graphicPath(id) : "/api/open/v1/graphic/runs";
|
|
@@ -2266,21 +2369,24 @@ async function graphic(context) {
|
|
|
2266
2369
|
if (["quote", "generate"].includes(command)) {
|
|
2267
2370
|
let current;
|
|
2268
2371
|
let submitted = false;
|
|
2372
|
+
let accepted = false;
|
|
2269
2373
|
try {
|
|
2270
2374
|
current = await getGraphicRun(baseUrl, apiKey, id, io);
|
|
2271
2375
|
const quote3 = await getGraphicQuote(baseUrl, apiKey, id, selected, key, io);
|
|
2272
|
-
if (
|
|
2376
|
+
if (expectedQuoteHash !== void 0 && expectedQuoteHash !== quote3.quoteHash) throw new CliError({ code: "OPEN_API_QUOTE_CHANGED", exitCode: EXIT.QUOTE_CHANGED, message: "\u62A5\u4EF7\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u67E5\u770B\u5F53\u524D\u62A5\u4EF7\u540E\u786E\u8BA4" });
|
|
2273
2377
|
if (command === "quote" || values.yes !== true) {
|
|
2274
2378
|
out.result([
|
|
2275
2379
|
`\u56FE\u6587\u9879\u76EE\uFF1A${id}`,
|
|
2276
2380
|
`\u672C\u6B21\u751F\u6210\uFF1A${quote3.imageCount} \u5F20\uFF0C\u9884\u4F30 ${quote3.totalCredits} \u5E03`,
|
|
2277
2381
|
`\u62A5\u4EF7\u54C8\u5E0C\uFF1A${quote3.quoteHash}`,
|
|
2278
|
-
|
|
2382
|
+
`\u672C\u6B21\u672A\u63D0\u4EA4\u751F\u6210\uFF1B\u4FDD\u7559\u539F\u56FE\u7247\u9009\u62E9\u6216\u4FEE\u6539\u8981\u6C42\uFF0C\u786E\u8BA4\u8D39\u7528\u540E\u4F7F\u7528 --quote-hash ${quote3.quoteHash} --yes\u3002`
|
|
2279
2383
|
], { quote: quote3, submitted: false });
|
|
2280
2384
|
return;
|
|
2281
2385
|
}
|
|
2282
2386
|
submitted = true;
|
|
2283
2387
|
const initial = graphicRun((await postJson(baseUrl, apiKey, `${path}/generate`, { ...selected, quoteHash: quote3.quoteHash, confirmed: true }, key, io)).body);
|
|
2388
|
+
current = initial;
|
|
2389
|
+
accepted = true;
|
|
2284
2390
|
const run2 = await wait(context, baseUrl, apiKey, initial);
|
|
2285
2391
|
out.result([...lines(run2), `\u5E42\u7B49\u952E\uFF1A${key}`], { run: run2, idempotencyKey: key });
|
|
2286
2392
|
return;
|
|
@@ -2292,8 +2398,8 @@ async function graphic(context) {
|
|
|
2292
2398
|
acceptance: current ? "confirmed" : "unknown",
|
|
2293
2399
|
idempotencyKey: key,
|
|
2294
2400
|
operation: "confirm",
|
|
2295
|
-
|
|
2296
|
-
|
|
2401
|
+
...failure.recovery,
|
|
2402
|
+
operationOutcome: accepted ? "accepted" : !submitted ? "not_submitted" : rejected ? "rejected" : "unknown"
|
|
2297
2403
|
});
|
|
2298
2404
|
}
|
|
2299
2405
|
}
|
|
@@ -2339,6 +2445,1435 @@ async function graphic(context) {
|
|
|
2339
2445
|
});
|
|
2340
2446
|
}
|
|
2341
2447
|
|
|
2448
|
+
// src/commands/web.ts
|
|
2449
|
+
import { createHash as createHash5, randomUUID as randomUUID2 } from "node:crypto";
|
|
2450
|
+
import { lstat as lstat4, readFile as readFile3 } from "node:fs/promises";
|
|
2451
|
+
import { basename as basename3 } from "node:path";
|
|
2452
|
+
|
|
2453
|
+
// src/web-operations.ts
|
|
2454
|
+
var WEB_OPERATIONS = [
|
|
2455
|
+
{ "id": "account.clearAgentMemory", "method": "DELETE", "path": "/api/me/agent-memory", "source": "web-src/src/lib/api.ts:2373", "group": "account", "description": "\u8D26\u53F7\uFF1A\u5220\u9664\u5F53\u524D\u8D26\u53F7 / \u5BFC\u6F14\u8BB0\u5FC6", "body": "json" },
|
|
2456
|
+
{ "id": "account.deleteAgentMemory", "method": "DELETE", "path": "/api/me/agent-memory/:id", "source": "web-src/src/lib/api.ts:2372", "group": "account", "description": "\u8D26\u53F7\uFF1A\u5220\u9664\u5F53\u524D\u8D26\u53F7 / \u5BFC\u6F14\u8BB0\u5FC6", "body": "json" },
|
|
2457
|
+
{ "id": "account.emailSettings", "method": "GET", "path": "/api/me/email", "source": "web-src/src/lib/api.ts:1551", "group": "account", "description": "\u8D26\u53F7\uFF1A\u67E5\u8BE2\u5F53\u524D\u8D26\u53F7 / \u90AE\u7BB1" },
|
|
2458
|
+
{ "id": "account.getAgentSettings", "method": "GET", "path": "/api/me/agent-settings", "source": "web-src/src/lib/api.ts:2367", "group": "account", "description": "\u8D26\u53F7\uFF1A\u67E5\u8BE2\u5F53\u524D\u8D26\u53F7 / \u5BFC\u6F14\u8BBE\u7F6E" },
|
|
2459
|
+
{ "id": "account.listAgentMemory", "method": "GET", "path": "/api/me/agent-memory", "source": "web-src/src/lib/api.ts:2370", "group": "account", "description": "\u8D26\u53F7\uFF1A\u67E5\u8BE2\u5F53\u524D\u8D26\u53F7 / \u5BFC\u6F14\u8BB0\u5FC6" },
|
|
2460
|
+
{ "id": "account.me", "method": "GET", "path": "/api/me", "source": "web-src/src/lib/api.ts:1699", "group": "account", "description": "\u8D26\u53F7\uFF1A\u67E5\u8BE2\u5F53\u524D\u8D26\u53F7" },
|
|
2461
|
+
{ "id": "account.requestEmailVerification", "method": "POST", "path": "/api/me/email/verification", "source": "web-src/src/lib/api.ts:1554", "group": "account", "description": "\u8D26\u53F7\uFF1A\u63D0\u4EA4\u90AE\u7BB1 / \u9A8C\u8BC1", "body": "json" },
|
|
2462
|
+
{ "id": "account.updateAgentSettings", "method": "PATCH", "path": "/api/me/agent-settings", "source": "web-src/src/lib/api.ts:2369", "group": "account", "description": "\u8D26\u53F7\uFF1A\u66F4\u65B0\u5F53\u524D\u8D26\u53F7 / \u5BFC\u6F14\u8BBE\u7F6E", "body": "json" },
|
|
2463
|
+
{ "id": "account.updateEmailPreferences", "method": "PATCH", "path": "/api/me/email/preferences", "source": "web-src/src/lib/api.ts:1557", "group": "account", "description": "\u8D26\u53F7\uFF1A\u66F4\u65B0\u90AE\u7BB1 / \u504F\u597D", "body": "json" },
|
|
2464
|
+
{ "id": "actors.actors", "method": "GET", "path": "/api/actors", "source": "web-src/src/lib/api.ts:2037", "group": "actors", "description": "\u4EBA\u7269\uFF1A\u67E5\u8BE2\u4EBA\u7269" },
|
|
2465
|
+
{ "id": "agent.agentAgreement", "method": "GET", "path": "/api/agent/agreement", "source": "web-src/src/lib/api.ts:1709", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u67E5\u8BE2\u63A8\u8350\u8BA1\u5212 / \u5408\u4F5C\u534F\u8BAE" },
|
|
2466
|
+
{ "id": "agent.agentApply", "method": "POST", "path": "/api/agent/apply", "source": "web-src/src/lib/api.ts:1714", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u63D0\u4EA4\u63A8\u8350\u8BA1\u5212 / \u5E94\u7528", "body": "json" },
|
|
2467
|
+
{ "id": "agent.agentEntries", "method": "GET", "path": "/api/agent/entries", "source": "web-src/src/lib/api.ts:1716", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u67E5\u8BE2\u63A8\u8350\u8BA1\u5212 / \u8BB0\u5F55" },
|
|
2468
|
+
{ "id": "agent.agentInvitees", "method": "GET", "path": "/api/agent/invitees", "source": "web-src/src/lib/api.ts:1715", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u67E5\u8BE2\u63A8\u8350\u8BA1\u5212 / \u9080\u8BF7\u8BB0\u5F55" },
|
|
2469
|
+
{ "id": "agent.agentMe", "method": "GET", "path": "/api/agent/me", "source": "web-src/src/lib/api.ts:1708", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u67E5\u8BE2\u63A8\u8350\u8BA1\u5212 / \u5F53\u524D\u8D26\u53F7" },
|
|
2470
|
+
{ "id": "agent.agentProgramBrief", "method": "GET", "path": "/api/agent/program-brief", "source": "web-src/src/lib/api.ts:1712", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u67E5\u8BE2\u63A8\u8350\u8BA1\u5212 / \u5408\u4F5C\u8BA1\u5212" },
|
|
2471
|
+
{ "id": "agent.agentWithdrawals", "method": "GET", "path": "/api/agent/withdrawals", "source": "web-src/src/lib/api.ts:1717", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u67E5\u8BE2\u63A8\u8350\u8BA1\u5212 / \u63D0\u73B0\u8BB0\u5F55" },
|
|
2472
|
+
{ "id": "agent.requestWithdrawal", "method": "POST", "path": "/api/agent/withdrawals", "source": "web-src/src/lib/api.ts:1719", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u63D0\u4EA4\u63A8\u8350\u8BA1\u5212 / \u63D0\u73B0\u8BB0\u5F55", "body": "json" },
|
|
2473
|
+
{ "id": "agent.saveAgentPayoutProfile", "method": "PUT", "path": "/api/agent/payout-profile", "source": "web-src/src/lib/api.ts:1721", "group": "agent", "description": "\u63A8\u8350\u8BA1\u5212\uFF1A\u8BBE\u7F6E\u63A8\u8350\u8BA1\u5212 / \u6536\u6B3E\u4FE1\u606F", "body": "json" },
|
|
2474
|
+
{ "id": "announcements.announcementArchive", "method": "GET", "path": "/api/announcements/archive", "source": "web-src/src/lib/api.ts:1536", "group": "announcements", "description": "\u516C\u544A\uFF1A\u67E5\u8BE2\u516C\u544A / \u5F52\u6863" },
|
|
2475
|
+
{ "id": "announcements.announcementReceipt", "method": "POST", "path": "/api/announcements/:id/receipt", "source": "web-src/src/lib/api.ts:1534", "group": "announcements", "description": "\u516C\u544A\uFF1A\u63D0\u4EA4\u516C\u544A / \u9605\u8BFB\u56DE\u6267", "body": "json" },
|
|
2476
|
+
{ "id": "announcements.liveAnnouncements", "method": "GET", "path": "/api/announcements/live", "source": "web-src/src/lib/api.ts:1531", "group": "announcements", "description": "\u516C\u544A\uFF1A\u67E5\u8BE2\u516C\u544A / \u5B9E\u65F6\u8FDB\u5EA6" },
|
|
2477
|
+
{ "id": "apiKeys.create", "method": "POST", "path": "/api/api-keys", "sensitiveOutput": true, "source": "web-src/src/lib/api-keys.ts:58", "group": "apiKeys", "description": "API\u5BC6\u94A5\uFF1A\u63D0\u4EA4API\u5BC6\u94A5", "body": "json", "exampleBody": { "name": "\u81EA\u52A8\u5316\u811A\u672C", "expiresInDays": 90 } },
|
|
2478
|
+
{ "id": "apiKeys.list", "method": "GET", "path": "/api/api-keys", "source": "web-src/src/lib/api-keys.ts:51", "group": "apiKeys", "description": "API\u5BC6\u94A5\uFF1A\u67E5\u8BE2API\u5BC6\u94A5" },
|
|
2479
|
+
{ "id": "apiKeys.revoke", "method": "POST", "path": "/api/api-keys/:id/revoke", "source": "web-src/src/lib/api-keys.ts:64", "group": "apiKeys", "description": "API\u5BC6\u94A5\uFF1A\u63D0\u4EA4API\u5BC6\u94A5 / \u64A4\u9500", "body": "json" },
|
|
2480
|
+
{ "id": "assets.registry", "method": "GET", "path": "/api/assets/registry", "source": "web-src/src/lib/api.ts:2043", "group": "assets", "description": "\u7D20\u6750\uFF1A\u67E5\u8BE2\u7D20\u6750 / \u7D20\u6750\u5E93" },
|
|
2481
|
+
{ "id": "auth.alipayStatus", "method": "GET", "path": "/api/auth/alipay/status", "source": "web-src/src/lib/api.ts:1690", "group": "auth", "description": "\u767B\u5F55\uFF1A\u67E5\u8BE2\u652F\u4ED8\u5B9D\u767B\u5F55 / \u72B6\u6001", "public": true },
|
|
2482
|
+
{ "id": "auth.changePassword", "method": "POST", "path": "/api/auth/password", "source": "web-src/src/lib/api.ts:1702", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u8BA4\u8BC1 / \u5BC6\u7801", "body": "json" },
|
|
2483
|
+
{ "id": "auth.completeAlipayLogin", "method": "POST", "path": "/api/auth/alipay/complete", "source": "web-src/src/lib/api.ts:1692", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u652F\u4ED8\u5B9D\u767B\u5F55 / \u5B8C\u6210\u767B\u5F55", "body": "json", "public": true, "sessionResponse": true },
|
|
2484
|
+
{ "id": "auth.emailAuthStatus", "method": "GET", "path": "/api/auth/email/status", "source": "web-src/src/lib/api.ts:1684", "group": "auth", "description": "\u767B\u5F55\uFF1A\u67E5\u8BE2\u90AE\u7BB1 / \u72B6\u6001", "public": true },
|
|
2485
|
+
{ "id": "auth.login", "method": "POST", "path": "/api/auth/login", "source": "web-src/src/lib/api.ts:1674", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u8BA4\u8BC1 / \u767B\u5F55", "body": "json", "public": true, "sessionResponse": true },
|
|
2486
|
+
{ "id": "auth.logout", "method": "POST", "path": "/api/auth/logout", "source": "web-src/src/lib/api.ts:1697", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u8BA4\u8BC1 / \u9000\u51FA\u767B\u5F55", "body": "json" },
|
|
2487
|
+
{ "id": "auth.register", "method": "POST", "path": "/api/auth/register", "source": "web-src/src/lib/api.ts:1677", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u8BA4\u8BC1 / \u6CE8\u518C", "body": "json", "public": true, "sessionResponse": true },
|
|
2488
|
+
{ "id": "auth.registerWithEmail", "method": "POST", "path": "/api/auth/register/email", "source": "web-src/src/lib/api.ts:1688", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u6CE8\u518C / \u90AE\u7BB1", "body": "json", "public": true, "sessionResponse": true },
|
|
2489
|
+
{ "id": "auth.registerWithSms", "method": "POST", "path": "/api/auth/register/sms", "source": "web-src/src/lib/api.ts:1682", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u6CE8\u518C / \u77ED\u4FE1", "body": "json", "public": true, "sessionResponse": true },
|
|
2490
|
+
{ "id": "auth.sendRegistrationEmail", "method": "POST", "path": "/api/auth/email/register-code", "source": "web-src/src/lib/api.ts:1686", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u90AE\u7BB1 / \u6CE8\u518C\u9A8C\u8BC1\u7801", "body": "json", "public": true },
|
|
2491
|
+
{ "id": "auth.sendRegistrationSms", "method": "POST", "path": "/api/auth/sms/register-code", "source": "web-src/src/lib/api.ts:1679", "group": "auth", "description": "\u767B\u5F55\uFF1A\u63D0\u4EA4\u77ED\u4FE1 / \u6CE8\u518C\u9A8C\u8BC1\u7801", "body": "json", "public": true },
|
|
2492
|
+
{ "id": "budget.budget", "method": "GET", "path": "/api/budget", "source": "web-src/src/lib/api.ts:3270", "group": "budget", "description": "\u8D26\u672C\uFF1A\u67E5\u8BE2\u8D26\u6237\u989D\u5EA6" },
|
|
2493
|
+
{ "id": "budget.budgetEntries", "method": "GET", "path": "/api/budget/entries", "source": "web-src/src/lib/api.ts:3272", "group": "budget", "description": "\u8D26\u672C\uFF1A\u67E5\u8BE2\u8D26\u6237\u989D\u5EA6 / \u8BB0\u5F55" },
|
|
2494
|
+
{ "id": "budget.budgetTransactions", "method": "GET", "path": "/api/budget/transactions", "source": "web-src/src/lib/api.ts:3277", "group": "budget", "description": "\u8D26\u672C\uFF1A\u67E5\u8BE2\u8D26\u6237\u989D\u5EA6 / \u8D26\u5355" },
|
|
2495
|
+
{ "id": "budget.projectCosts", "method": "GET", "path": "/api/budget/by-project", "source": "web-src/src/lib/api.ts:3550", "group": "budget", "description": "\u8D26\u672C\uFF1A\u67E5\u8BE2\u8D26\u6237\u989D\u5EA6 / \u6309\u9879\u76EE\u6C47\u603B" },
|
|
2496
|
+
{ "id": "commercialAds.recommendCommercialAds", "method": "POST", "path": "/api/commercial-ads/recommend", "source": "web-src/src/lib/api.ts:2824", "group": "commercialAds", "description": "\u5E7F\u544A\u63A8\u8350\uFF1A\u63D0\u4EA4\u5E7F\u544A / \u63A8\u8350", "body": "json" },
|
|
2497
|
+
{ "id": "delivery.accept", "method": "POST", "path": "/api/delivery/shared/:token/accepted", "source": "web-src/src/lib/delivery-api.ts:348", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u63D0\u4EA4\u5206\u4EAB\u4EA4\u4ED8 / \u4EA4\u4ED8\u9A8C\u6536", "body": "json", "public": true },
|
|
2498
|
+
{ "id": "delivery.accept.accepted", "method": "POST", "path": "/api/delivery/packages/:id/accepted", "source": "web-src/src/lib/delivery-api.ts:348", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u63D0\u4EA4\u4EA4\u4ED8\u5305 / \u4EA4\u4ED8\u9A8C\u6536", "body": "json" },
|
|
2499
|
+
{ "id": "delivery.comment", "method": "POST", "path": "/api/delivery/shared/:token/comments", "source": "web-src/src/lib/delivery-api.ts:346", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u63D0\u4EA4\u5206\u4EAB\u4EA4\u4ED8 / \u8BC4\u8BBA", "body": "json", "public": true },
|
|
2500
|
+
{ "id": "delivery.comments", "method": "GET", "path": "/api/delivery/packages/:id/comments", "source": "web-src/src/lib/delivery-api.ts:338", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8\u5305 / \u8BC4\u8BBA" },
|
|
2501
|
+
{ "id": "delivery.create", "method": "POST", "path": "/api/delivery/packages", "source": "web-src/src/lib/delivery-api.ts:335", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u63D0\u4EA4\u4EA4\u4ED8 / \u4EA4\u4ED8\u5305", "body": "json", "idempotencyBodyKey": "requestKey", "replaySafe": true, "exampleBody": { "sources": [{ "kind": "episode", "sourceId": "\u9879\u76EE\u7F16\u53F7", "selectedFileIds": ["\u4ECEdelivery.source\u54CD\u5E94\u7684files\u4E2D\u9009\u53D6\u6587\u4EF6id"], "expectedFingerprint": "\u4ECEdelivery.source\u8BFB\u53D6" }], "scope": "full", "title": "\u4EA4\u4ED8\u8D44\u6599" } },
|
|
2502
|
+
{ "id": "delivery.createShare", "method": "POST", "path": "/api/delivery/packages/:id/shares", "sensitiveOutput": true, "source": "web-src/src/lib/delivery-api.ts:340", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u63D0\u4EA4\u4EA4\u4ED8\u5305 / \u5206\u4EAB\u8BB0\u5F55", "body": "json", "exampleBody": { "allowPreview": true, "allowDownload": true, "allowComment": true, "expiresInDays": 7 } },
|
|
2503
|
+
{ "id": "delivery.download", "method": "GET", "path": "/api/delivery/packages/:id/download", "source": "apps/api/src/http/routes/delivery.ts:194", "group": "delivery", "description": "\u4E0B\u8F7D\u5B8C\u6574\u4EA4\u4ED8\u5305" },
|
|
2504
|
+
{ "id": "delivery.downloadFile", "method": "POST", "path": "/api/delivery/packages/:id/download-ticket", "sensitiveOutput": true, "source": "web-src/src/lib/delivery-api.ts:358", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u63D0\u4EA4\u4EA4\u4ED8\u5305 / \u4E0B\u8F7D\u51ED\u8BC1", "body": "json" },
|
|
2505
|
+
{ "id": "delivery.downloadShared", "method": "GET", "path": "/api/delivery/shared/:token/download", "source": "apps/api/src/http/routes/delivery.ts:267", "group": "delivery", "description": "\u4E0B\u8F7D\u5206\u4EAB\u4EA4\u4ED8\u5305", "public": true },
|
|
2506
|
+
{ "id": "delivery.file", "method": "GET", "path": "/api/delivery/shared/:token/files/:fileId", "source": "web-src/src/lib/delivery-api.ts:352", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u5206\u4EAB\u4EA4\u4ED8 / \u6587\u4EF6", "public": true },
|
|
2507
|
+
{ "id": "delivery.file.files", "method": "GET", "path": "/api/delivery/packages/:id/files/:fileId", "source": "web-src/src/lib/delivery-api.ts:352", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8\u5305 / \u6587\u4EF6" },
|
|
2508
|
+
{ "id": "delivery.list", "method": "GET", "path": "/api/delivery/packages", "source": "web-src/src/lib/delivery-api.ts:318", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8 / \u4EA4\u4ED8\u5305" },
|
|
2509
|
+
{ "id": "delivery.options", "method": "GET", "path": "/api/delivery/source-options", "source": "web-src/src/lib/delivery-api.ts:309", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8 / \u6765\u6E90\u9009\u9879" },
|
|
2510
|
+
{ "id": "delivery.package", "method": "GET", "path": "/api/delivery/packages/:id", "source": "web-src/src/lib/delivery-api.ts:336", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8 / \u4EA4\u4ED8\u5305" },
|
|
2511
|
+
{ "id": "delivery.revokeShare", "method": "DELETE", "path": "/api/delivery/shares/:id", "source": "web-src/src/lib/delivery-api.ts:342", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u5220\u9664\u4EA4\u4ED8 / \u5206\u4EAB\u8BB0\u5F55", "body": "json" },
|
|
2512
|
+
{ "id": "delivery.shared", "method": "GET", "path": "/api/delivery/shared/:token", "source": "web-src/src/lib/delivery-api.ts:344", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8 / \u5206\u4EAB\u4EA4\u4ED8", "public": true },
|
|
2513
|
+
{ "id": "delivery.shares", "method": "GET", "path": "/api/delivery/packages/:id/shares", "source": "web-src/src/lib/delivery-api.ts:337", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8\u5305 / \u5206\u4EAB\u8BB0\u5F55" },
|
|
2514
|
+
{ "id": "delivery.source", "method": "GET", "path": "/api/delivery/sources/:kind/:sourceId", "source": "web-src/src/lib/delivery-api.ts:313", "group": "delivery", "description": "\u4EA4\u4ED8\uFF1A\u67E5\u8BE2\u4EA4\u4ED8 / \u6765\u6E90" },
|
|
2515
|
+
{ "id": "drama.acceptAdvice", "method": "POST", "path": "/api/projects/:id/customer-quality/actions", "source": "apps/api/src/http/routes/projects.ts:4149", "group": "drama", "description": "\u7EE7\u7EED\u4F7F\u7528\u5F53\u524D\u6587\u7A3F", "body": "json" },
|
|
2516
|
+
{ "id": "drama.adoptStorySpeech", "method": "POST", "path": "/api/projects/:projectId/director/speech/tracks/:trackId/adopt", "source": "web-src/src/lib/api.ts:2582", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u97F3\u8F68 / \u91C7\u7528", "body": "json" },
|
|
2517
|
+
{ "id": "drama.approveStorySpeech", "method": "POST", "path": "/api/projects/:projectId/director/speech/tracks/:trackId/approve", "source": "web-src/src/lib/api.ts:2578", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u97F3\u8F68 / \u786E\u8BA4", "body": "json" },
|
|
2518
|
+
{ "id": "drama.approveTopicScript", "method": "POST", "path": "/api/projects/:id/topic/script/approve", "source": "web-src/src/lib/api.ts:2571", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u7A3F\u4EF6 / \u786E\u8BA4", "body": "json" },
|
|
2519
|
+
{ "id": "drama.assetGate", "method": "GET", "path": "/api/projects/:id/asset-gate", "source": "web-src/src/lib/api.ts:3436", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u7D20\u6750\u68C0\u67E5" },
|
|
2520
|
+
{ "id": "drama.bindStoryAssets", "method": "POST", "path": "/api/projects/:id/story-bindings", "source": "web-src/src/lib/api.ts:3213", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u4EBA\u7269\u573A\u666F\u7ED1\u5B9A", "body": "json" },
|
|
2521
|
+
{ "id": "drama.cancelProjectGeneration", "method": "POST", "path": "/api/projects/:id/cancel-generation", "source": "web-src/src/lib/api.ts:3503", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u505C\u6B62\u5236\u4F5C", "body": "json" },
|
|
2522
|
+
{ "id": "drama.cancelStoryDirectorAutoStart", "method": "POST", "path": "/api/projects/:projectId/director/auto-start/cancel", "source": "web-src/src/lib/api.ts:2682", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u81EA\u52A8\u5F00\u62CD / \u53D6\u6D88", "body": "json" },
|
|
2523
|
+
{ "id": "drama.capability", "method": "GET", "path": "/api/projects/:projectId/outputs/:outputId/subtitles/capability", "source": "web-src/src/lib/subtitle-version-api.ts:35", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5B57\u5E55 / \u80FD\u529B" },
|
|
2524
|
+
{ "id": "drama.casting", "method": "POST", "path": "/api/projects/:id/casting", "source": "web-src/src/lib/api.ts:3198", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u9009\u89D2", "body": "json" },
|
|
2525
|
+
{ "id": "drama.clearShotVersionSelection", "method": "DELETE", "path": "/api/projects/:id/shots/:shotId/version-selection", "source": "web-src/src/lib/api.ts:3545", "group": "drama", "description": "\u77ED\u5267\uFF1A\u5220\u9664\u955C\u5934 / \u955C\u5934\u9009\u7248", "body": "json" },
|
|
2526
|
+
{ "id": "drama.compareScreenplayVersions", "method": "GET", "path": "/api/projects/:id/screenplay/versions/compare", "source": "web-src/src/lib/api.ts:3235", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u7248\u672C / \u5BF9\u6BD4" },
|
|
2527
|
+
{ "id": "drama.confirmProductionRedo", "method": "POST", "path": "/api/projects/:id/production/redo", "source": "web-src/src/lib/api.ts:3493", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5236\u4F5C\u8FDB\u5EA6 / \u91CD\u65B0\u5236\u4F5C", "body": "json" },
|
|
2528
|
+
{ "id": "drama.confirmStitch", "method": "POST", "path": "/api/projects/:id/production/postprocess/stitch-confirm", "source": "web-src/src/lib/api.ts:3474", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u540E\u671F\u5236\u4F5C / \u786E\u8BA4\u62FC\u63A5", "body": "json" },
|
|
2529
|
+
{ "id": "drama.confirmStoryDirector", "method": "POST", "path": "/api/projects/:projectId/director/confirm", "source": "web-src/src/lib/api.ts:2676", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5BFC\u6F14 / \u786E\u8BA4", "body": "json" },
|
|
2530
|
+
{ "id": "drama.confirmStorySpeech", "method": "POST", "path": "/api/projects/:projectId/director/speech/quotes/:quoteId/confirm", "source": "web-src/src/lib/api.ts:2576", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u62A5\u4EF7 / \u786E\u8BA4", "body": "json" },
|
|
2531
|
+
{ "id": "drama.confirmStorySpeechLegacySource", "method": "POST", "path": "/api/projects/:projectId/director/speech/legacy-source/confirm", "source": "web-src/src/lib/api.ts:2586", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5386\u53F2\u6765\u6E90 / \u786E\u8BA4", "body": "json" },
|
|
2532
|
+
{ "id": "drama.create", "method": "POST", "path": "/api/projects", "source": "web-src/src/lib/api.ts:3132", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE", "body": "json", "exampleBody": { "productId": "\u5546\u54C1\u7F16\u53F7", "genreId": "family", "productionProfile": { "durationKey": "30s" }, "brief": { "description": "\u56F4\u7ED5\u8FD9\u4EF6\u5546\u54C1\u521B\u4F5C\u751F\u6D3B\u77ED\u5267" } } },
|
|
2533
|
+
{ "id": "drama.createProductionSignoff", "method": "POST", "path": "/api/projects/:id/production-signoff", "source": "web-src/src/lib/api.ts:3345", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u5F00\u62CD\u786E\u8BA4", "body": "json" },
|
|
2534
|
+
{ "id": "drama.createTopicProject", "method": "POST", "path": "/api/projects/topic", "source": "web-src/src/lib/api.ts:2568", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u9009\u9898", "body": "json" },
|
|
2535
|
+
{ "id": "drama.customerQuality", "method": "GET", "path": "/api/projects/:id/customer-quality", "source": "web-src/src/lib/api.ts:3306", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u521B\u4F5C\u5EFA\u8BAE" },
|
|
2536
|
+
{ "id": "drama.deleteProject", "method": "DELETE", "path": "/api/projects/:id", "source": "web-src/src/lib/api.ts:3123", "group": "drama", "description": "\u77ED\u5267\uFF1A\u5220\u9664\u9879\u76EE", "body": "json" },
|
|
2537
|
+
{ "id": "drama.downloadEdit", "method": "GET", "path": "/api/projects/:projectId/director/edits/:editId/download", "source": "apps/api/src/http/routes/story-director.ts:52", "group": "drama", "description": "\u4E0B\u8F7D\u77ED\u5267\u526A\u8F91\u7248" },
|
|
2538
|
+
{ "id": "drama.downloadEditSubtitles", "method": "GET", "path": "/api/projects/:projectId/director/edits/:editId/subtitles", "source": "apps/api/src/http/routes/story-director.ts:62", "group": "drama", "description": "\u4E0B\u8F7D\u77ED\u5267\u526A\u8F91\u5B57\u5E55" },
|
|
2539
|
+
{ "id": "drama.downloadFinal", "method": "GET", "path": "/api/exports/:projectId/download", "source": "apps/api/src/http/routes/exports.ts:26", "group": "drama", "description": "\u4E0B\u8F7D\u77ED\u5267\u5B8C\u6574\u6210\u7247" },
|
|
2540
|
+
{ "id": "drama.downloadHistory", "method": "GET", "path": "/api/projects/:projectId/director/history-sources/:sourceEpisodeOutputId/download", "source": "apps/api/src/http/routes/story-director.ts:98", "group": "drama", "description": "\u4E0B\u8F7D\u5386\u53F2\u6210\u7247" },
|
|
2541
|
+
{ "id": "drama.downloadSubtitleFile", "method": "GET", "path": "/api/exports/:projectId/subtitles.srt", "source": "web-src/src/lib/subtitle-download.ts:9", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u4EA4\u4ED8\u4FE1\u606F / \u5B57\u5E55\u6587\u4EF6" },
|
|
2542
|
+
{ "id": "drama.downloadSubtitleVersion", "method": "GET", "path": "/api/projects/:projectId/outputs/:outputId/subtitles/render/:taskId/video", "source": "apps/api/src/http/routes/film-subtitles.ts:40", "group": "drama", "description": "\u4E0B\u8F7D\u5B57\u5E55\u6210\u7247" },
|
|
2543
|
+
{ "id": "drama.draft", "method": "POST", "path": "/api/projects/:projectId/outputs/:outputId/subtitles/draft", "source": "web-src/src/lib/subtitle-version-api.ts:39", "group": "drama", "description": '\u77ED\u5267\uFF1A\u51C6\u5907\u5B57\u5E55\u8349\u7A3F\uFF1B\u8FD4\u56DE canRetry \u65F6\u53EF\u7528 --query JSON \u6587\u4EF6\u4F20 {"retry":1} \u91CD\u8BD5\u51C6\u5907', "body": "json" },
|
|
2544
|
+
{ "id": "drama.exports", "method": "GET", "path": "/api/exports/:projectId", "source": "web-src/src/lib/api.ts:3553", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u4EA4\u4ED8\u4FE1\u606F" },
|
|
2545
|
+
{ "id": "drama.generate", "method": "POST", "path": "/api/projects/:id/generate", "source": "web-src/src/lib/api.ts:3445", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u5236\u4F5C", "body": "json", "businessHeaders": { "prefer": { "default": "respond-async", "values": ["respond-async"] } } },
|
|
2546
|
+
{ "id": "drama.generateStoryboard", "method": "POST", "path": "/api/projects/:id/storyboard", "source": "web-src/src/lib/api.ts:3225", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u6545\u4E8B\u677F", "body": "json" },
|
|
2547
|
+
{ "id": "drama.getProject", "method": "GET", "path": "/api/projects/:id", "source": "web-src/src/lib/api.ts:3122", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE" },
|
|
2548
|
+
{ "id": "drama.getStoryDirector", "method": "GET", "path": "/api/projects/:projectId/director", "source": "web-src/src/lib/api.ts:2608", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u5BFC\u6F14" },
|
|
2549
|
+
{ "id": "drama.getStoryDirectorDoc", "method": "GET", "path": "/api/projects/:projectId/director/doc", "source": "web-src/src/lib/api.ts:2663", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5BFC\u6F14 / \u6587\u7A3F" },
|
|
2550
|
+
{ "id": "drama.getStoryDirectorSpecQuotes", "method": "GET", "path": "/api/projects/:projectId/director/spec-quotes", "source": "web-src/src/lib/api.ts:2704", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5BFC\u6F14 / \u89C4\u683C\u62A5\u4EF7" },
|
|
2551
|
+
{ "id": "drama.getStoryHistoricalSources", "method": "GET", "path": "/api/projects/:projectId/director/history-sources", "source": "web-src/src/lib/api.ts:2584", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5BFC\u6F14 / \u5386\u53F2\u6210\u7247" },
|
|
2552
|
+
{ "id": "drama.getStorySpeech", "method": "GET", "path": "/api/projects/:projectId/director/speech", "source": "web-src/src/lib/api.ts:2572", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5BFC\u6F14 / \u914D\u97F3" },
|
|
2553
|
+
{ "id": "drama.getStorySpeechAdoptions", "method": "GET", "path": "/api/projects/:projectId/director/speech/adoptions", "source": "web-src/src/lib/api.ts:2589", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u914D\u97F3 / \u91C7\u7528\u8BB0\u5F55" },
|
|
2554
|
+
{ "id": "drama.getStorySpeechAudio", "method": "GET", "path": "/api/projects/:projectId/director/speech/tracks/:trackId/audio", "source": "web-src/src/lib/api.ts:2591", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u97F3\u8F68 / \u97F3\u9891" },
|
|
2555
|
+
{ "id": "drama.getStorySpeechTaskAudio", "method": "GET", "path": "/api/projects/:projectId/director/speech/tasks/:taskId/audio", "source": "web-src/src/lib/api.ts:2593", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u4EFB\u52A1 / \u97F3\u9891" },
|
|
2556
|
+
{ "id": "drama.getStoryVideoEditSources", "method": "GET", "path": "/api/projects/:projectId/director/edit-sources", "source": "web-src/src/lib/api.ts:2583", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5BFC\u6F14 / \u526A\u8F91\u7D20\u6750" },
|
|
2557
|
+
{ "id": "drama.getTopicProject", "method": "GET", "path": "/api/projects/:id/topic", "source": "web-src/src/lib/api.ts:2569", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u9009\u9898" },
|
|
2558
|
+
{ "id": "drama.importStorySpeechRecordings", "method": "POST", "path": "/api/projects/:projectId/director/speech/import", "source": "web-src/src/lib/api.ts:2598", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u914D\u97F3 / \u5BFC\u5165", "body": "json" },
|
|
2559
|
+
{ "id": "drama.inspectStoryDirectorAttachments", "method": "GET", "path": "/api/projects/:projectId/director/attachments", "source": "web-src/src/lib/api.ts:2649", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5BFC\u6F14 / \u9644\u4EF6" },
|
|
2560
|
+
{ "id": "drama.jobs", "method": "GET", "path": "/api/projects/:id/jobs", "source": "web-src/src/lib/api.ts:3455", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u4EFB\u52A1" },
|
|
2561
|
+
{ "id": "drama.ledger", "method": "GET", "path": "/api/projects/:id/ledger", "source": "web-src/src/lib/api.ts:3551", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u8D26\u672C" },
|
|
2562
|
+
{ "id": "drama.list", "method": "GET", "path": "/api/projects", "source": "web-src/src/lib/api.ts:2882", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE" },
|
|
2563
|
+
{ "id": "drama.playEdit", "method": "GET", "path": "/api/projects/:projectId/director/edits/:editId/video", "source": "apps/api/src/http/routes/story-director.ts:52", "group": "drama", "description": "\u8BFB\u53D6\u77ED\u5267\u526A\u8F91\u7248" },
|
|
2564
|
+
{ "id": "drama.playHistory", "method": "GET", "path": "/api/projects/:projectId/director/history-sources/:sourceEpisodeOutputId/video", "source": "apps/api/src/http/routes/story-director.ts:98", "group": "drama", "description": "\u8BFB\u53D6\u5386\u53F2\u6210\u7247" },
|
|
2565
|
+
{ "id": "drama.postStoryDirectorMessage", "method": "POST", "path": "/api/projects/:projectId/director/messages", "source": "web-src/src/lib/api.ts:2610", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5BFC\u6F14 / \u5BF9\u8BDD", "body": "json", "exampleBody": { "text": "\u4FDD\u7559\u73B0\u6709\u60C5\u8282\uFF0C\u53EA\u8C03\u6574\u5F00\u573A\u5BF9\u767D" } },
|
|
2566
|
+
{ "id": "drama.production", "method": "GET", "path": "/api/projects/:id/production", "source": "web-src/src/lib/api.ts:3457", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u5236\u4F5C\u8FDB\u5EA6" },
|
|
2567
|
+
{ "id": "drama.productionRedoQuote", "method": "POST", "path": "/api/projects/:id/production/redo/quote", "source": "web-src/src/lib/api.ts:3490", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u91CD\u65B0\u5236\u4F5C / \u62A5\u4EF7", "body": "json" },
|
|
2568
|
+
{ "id": "drama.productionSignoff", "method": "GET", "path": "/api/projects/:id/production-signoff", "source": "web-src/src/lib/api.ts:3298", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u5F00\u62CD\u786E\u8BA4" },
|
|
2569
|
+
{ "id": "drama.quote", "method": "POST", "path": "/api/projects/:id/quote", "source": "web-src/src/lib/api.ts:3295", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u62A5\u4EF7", "body": "json" },
|
|
2570
|
+
{ "id": "drama.quoteShotRetry", "method": "GET", "path": "/api/projects/:id/shots/:shotId/retry-quote", "source": "web-src/src/lib/api.ts:3521", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u955C\u5934 / \u91CD\u62CD\u62A5\u4EF7" },
|
|
2571
|
+
{ "id": "drama.quoteStorySpeech", "method": "POST", "path": "/api/projects/:projectId/director/speech/quotes", "source": "web-src/src/lib/api.ts:2574", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u914D\u97F3 / \u62A5\u4EF7", "body": "json" },
|
|
2572
|
+
{ "id": "drama.refineScreenplayScene", "method": "POST", "path": "/api/projects/:id/screenplay/scenes/:sceneNo/refine", "source": "web-src/src/lib/api.ts:3255", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u573A\u666F / \u5C40\u90E8\u4FEE\u6539", "body": "json" },
|
|
2573
|
+
{ "id": "drama.render", "method": "POST", "path": "/api/projects/:projectId/outputs/:outputId/subtitles/render", "source": "web-src/src/lib/subtitle-version-api.ts:41", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5B57\u5E55 / \u5236\u4F5C\u5305\u88C5", "body": "json" },
|
|
2574
|
+
{ "id": "drama.restoreScreenplayVersion", "method": "POST", "path": "/api/projects/:id/screenplay/versions/:docId/restore", "source": "web-src/src/lib/api.ts:3243", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u7248\u672C / \u6062\u590D", "body": "json", "exampleBody": { "expectedCurrentDocumentId": "\u5F53\u524D\u6587\u7A3F\u7F16\u53F7", "productionEpoch": 0 } },
|
|
2575
|
+
{ "id": "drama.resumeProductionPostprocess", "method": "POST", "path": "/api/projects/:id/production/postprocess/resume", "source": "web-src/src/lib/api.ts:3460", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u540E\u671F\u5236\u4F5C / \u7EE7\u7EED", "body": "json" },
|
|
2576
|
+
{ "id": "drama.retryShotGeneration", "method": "POST", "path": "/api/projects/:id/shots/:shotId/retry-generation", "source": "web-src/src/lib/api.ts:3513", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u955C\u5934 / \u91CD\u65B0\u751F\u6210", "body": "json" },
|
|
2577
|
+
{ "id": "drama.revokeStorySpeech", "method": "POST", "path": "/api/projects/:projectId/director/speech/tracks/:trackId/revoke", "source": "web-src/src/lib/api.ts:2580", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u97F3\u8F68 / \u64A4\u9500", "body": "json" },
|
|
2578
|
+
{ "id": "drama.save", "method": "PUT", "path": "/api/projects/:projectId/outputs/:outputId/subtitles/draft/:draftId", "source": "web-src/src/lib/subtitle-version-api.ts:39", "group": "drama", "description": "\u77ED\u5267\uFF1A\u8BBE\u7F6E\u5B57\u5E55 / \u8349\u7A3F", "body": "json" },
|
|
2579
|
+
{ "id": "drama.saveStoryDirectorAttachmentFile", "method": "GET", "path": "/api/projects/:projectId/director/attachments/:attachmentId/file", "source": "web-src/src/lib/api.ts:2655", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9644\u4EF6 / \u6587\u4EF6" },
|
|
2580
|
+
{ "id": "drama.screenplay", "method": "POST", "path": "/api/projects/:id/screenplay", "source": "web-src/src/lib/api.ts:3227", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u5267\u672C", "body": "json" },
|
|
2581
|
+
{ "id": "drama.screenplayVersion", "method": "GET", "path": "/api/projects/:id/screenplay/versions/:docId", "source": "web-src/src/lib/api.ts:3232", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5267\u672C / \u7248\u672C" },
|
|
2582
|
+
{ "id": "drama.screenplayVersions", "method": "GET", "path": "/api/projects/:id/screenplay/versions", "source": "web-src/src/lib/api.ts:3230", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5267\u672C / \u7248\u672C" },
|
|
2583
|
+
{ "id": "drama.selectScriptAsset", "method": "POST", "path": "/api/projects/:id/script-asset", "source": "web-src/src/lib/api.ts:3262", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u6545\u4E8B\u8DEF\u7EBF", "body": "json" },
|
|
2584
|
+
{ "id": "drama.selectShotVersion", "method": "PUT", "path": "/api/projects/:id/shots/:shotId/version-selection", "source": "web-src/src/lib/api.ts:3534", "group": "drama", "description": "\u77ED\u5267\uFF1A\u8BBE\u7F6E\u955C\u5934 / \u955C\u5934\u9009\u7248", "body": "json" },
|
|
2585
|
+
{ "id": "drama.setStoryDirectorProductionChoice", "method": "POST", "path": "/api/projects/:projectId/director/production-choice", "source": "web-src/src/lib/api.ts:2698", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5BFC\u6F14 / \u5236\u4F5C\u89C4\u683C", "body": "json" },
|
|
2586
|
+
{ "id": "drama.shotPlan", "method": "POST", "path": "/api/projects/:id/shot-plan", "source": "web-src/src/lib/api.ts:3219", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9879\u76EE / \u5206\u955C\u65B9\u6848", "body": "json" },
|
|
2587
|
+
{ "id": "drama.stitchDecision", "method": "POST", "path": "/api/projects/:id/production/postprocess/stitch-decision", "source": "web-src/src/lib/api.ts:3467", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u540E\u671F\u5236\u4F5C / \u62FC\u63A5\u65B9\u6848", "body": "json" },
|
|
2588
|
+
{ "id": "drama.stopStoryDirector", "method": "POST", "path": "/api/projects/:projectId/director/stop", "source": "web-src/src/lib/api.ts:2601", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5BFC\u6F14 / \u505C\u6B62\u56DE\u590D", "body": "json" },
|
|
2589
|
+
{ "id": "drama.storyboard", "method": "GET", "path": "/api/projects/:id/storyboard", "source": "web-src/src/lib/api.ts:3223", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u9879\u76EE / \u6545\u4E8B\u677F" },
|
|
2590
|
+
{ "id": "drama.streamStoryDirectorMessage", "method": "POST", "path": "/api/projects/:projectId/director/messages/stream", "source": "web-src/src/lib/api.ts:2623", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u5BF9\u8BDD / \u5B9E\u65F6\u5BF9\u8BDD", "body": "json" },
|
|
2591
|
+
{ "id": "drama.switchProjectToLiveAction", "method": "PATCH", "path": "/api/projects/:id/production-profile", "source": "web-src/src/lib/api.ts:3139", "group": "drama", "description": "\u77ED\u5267\uFF1A\u66F4\u65B0\u9879\u76EE / \u5236\u4F5C\u89C4\u683C", "body": "json" },
|
|
2592
|
+
{ "id": "drama.task", "method": "GET", "path": "/api/projects/:projectId/outputs/:outputId/subtitles/render/:taskId", "source": "web-src/src/lib/subtitle-version-api.ts:43", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u5B57\u5E55 / \u5236\u4F5C\u5305\u88C5" },
|
|
2593
|
+
{ "id": "drama.updatePlacementIntensity", "method": "PATCH", "path": "/api/projects/:id/placement-intensity", "source": "web-src/src/lib/api.ts:3152", "group": "drama", "description": "\u77ED\u5267\uFF1A\u66F4\u65B0\u9879\u76EE / \u690D\u5165\u7A0B\u5EA6", "body": "json" },
|
|
2594
|
+
{ "id": "drama.updateTopicScript", "method": "POST", "path": "/api/projects/:id/topic/script", "source": "web-src/src/lib/api.ts:2570", "group": "drama", "description": "\u77ED\u5267\uFF1A\u63D0\u4EA4\u9009\u9898 / \u7A3F\u4EF6", "body": "json" },
|
|
2595
|
+
{ "id": "drama.uploadStoryDirectorAttachment", "method": "PUT", "path": "/api/projects/:projectId/director/attachments", "source": "web-src/src/lib/api.ts:2640", "group": "drama", "description": "\u77ED\u5267\uFF1A\u8BBE\u7F6E\u5BFC\u6F14 / \u9644\u4EF6", "body": "binary", "uploadPolicy": "chatAttachment", "businessHeaders": { "x-attachment-delivery": { "default": "explicit", "values": ["explicit", "legacy"] }, "x-attachment-name": { "fromFilename": true } } },
|
|
2596
|
+
{ "id": "drama.uploadStorySpeechRecording", "method": "PUT", "path": "/api/projects/:projectId/director/speech/recordings/:lineId", "source": "web-src/src/lib/api.ts:2595", "group": "drama", "description": "\u77ED\u5267\uFF1A\u8BBE\u7F6E\u914D\u97F3 / \u5F55\u97F3", "body": "binary", "uploadPolicy": "storySpeech", "businessHeaders": { "x-script-fingerprint": { "required": true } } },
|
|
2597
|
+
{ "id": "email.unsubscribeEmail", "method": "POST", "path": "/api/email/unsubscribe", "source": "web-src/src/lib/api.ts:1561", "group": "email", "description": "\u90AE\u7BB1\uFF1A\u63D0\u4EA4\u90AE\u7BB1 / \u53D6\u6D88\u8BA2\u9605", "body": "json", "public": true },
|
|
2598
|
+
{ "id": "email.verifyEmail", "method": "POST", "path": "/api/email/verify", "source": "web-src/src/lib/api.ts:1559", "group": "email", "description": "\u90AE\u7BB1\uFF1A\u63D0\u4EA4\u90AE\u7BB1 / \u9A8C\u8BC1", "body": "json", "public": true },
|
|
2599
|
+
{ "id": "episodes.approveEpisodeOutline", "method": "POST", "path": "/api/episodes/:id/outline/:docId/approve", "source": "web-src/src/lib/api.ts:3193", "group": "episodes", "description": "\u5206\u96C6\uFF1A\u63D0\u4EA4\u5927\u7EB2 / \u786E\u8BA4", "body": "json" },
|
|
2600
|
+
{ "id": "episodes.generateOutline", "method": "POST", "path": "/api/episodes/:id/outline", "source": "apps/api/src/http/routes/script-engine.ts:143", "group": "episodes", "description": "\u51C6\u5907\u5206\u96C6\u5927\u7EB2", "body": "json" },
|
|
2601
|
+
{ "id": "episodes.getEpisodeOutline", "method": "GET", "path": "/api/episodes/:id/outline", "source": "web-src/src/lib/api.ts:3188", "group": "episodes", "description": "\u5206\u96C6\uFF1A\u67E5\u8BE2\u5206\u96C6 / \u5927\u7EB2" },
|
|
2602
|
+
{ "id": "feedback.commentOnFeedback", "method": "POST", "path": "/api/feedback/tickets/:ticketNo/comments", "source": "web-src/src/lib/api.ts:1621", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u63D0\u4EA4\u53CD\u9988\u5355 / \u8BC4\u8BBA", "body": "json" },
|
|
2603
|
+
{ "id": "feedback.feedbackHonors", "method": "GET", "path": "/api/feedback/honors", "source": "web-src/src/lib/api.ts:1624", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u67E5\u8BE2\u53CD\u9988 / \u8363\u8A89" },
|
|
2604
|
+
{ "id": "feedback.feedbackMe", "method": "GET", "path": "/api/feedback/me", "source": "web-src/src/lib/api.ts:1604", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u67E5\u8BE2\u53CD\u9988 / \u5F53\u524D\u8D26\u53F7" },
|
|
2605
|
+
{ "id": "feedback.feedbackPeriods", "method": "GET", "path": "/api/feedback/periods", "source": "web-src/src/lib/api.ts:1626", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u67E5\u8BE2\u53CD\u9988 / \u5468\u671F" },
|
|
2606
|
+
{ "id": "feedback.feedbackRules", "method": "GET", "path": "/api/feedback/rules", "source": "web-src/src/lib/api.ts:1600", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u67E5\u8BE2\u53CD\u9988 / \u89C4\u5219" },
|
|
2607
|
+
{ "id": "feedback.feedbackTicket", "method": "GET", "path": "/api/feedback/tickets/:ticketNo", "source": "web-src/src/lib/api.ts:1618", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u67E5\u8BE2\u53CD\u9988 / \u53CD\u9988\u5355" },
|
|
2608
|
+
{ "id": "feedback.myFeedback", "method": "GET", "path": "/api/feedback/tickets", "source": "web-src/src/lib/api.ts:1602", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u67E5\u8BE2\u53CD\u9988 / \u53CD\u9988\u5355" },
|
|
2609
|
+
{ "id": "feedback.submitFeedback", "method": "POST", "path": "/api/feedback/tickets", "source": "web-src/src/lib/api.ts:1615", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u63D0\u4EA4\u53CD\u9988 / \u53CD\u9988\u5355", "body": "json" },
|
|
2610
|
+
{ "id": "feedback.uploadFeedbackAttachment", "method": "POST", "path": "/api/feedback/attachments", "source": "web-src/src/lib/api.ts:1608", "group": "feedback", "description": "\u53CD\u9988\uFF1A\u63D0\u4EA4\u53CD\u9988 / \u9644\u4EF6", "body": "binary", "uploadPolicy": "image" },
|
|
2611
|
+
{ "id": "genres.genres", "method": "GET", "path": "/api/genres", "source": "web-src/src/lib/api.ts:2036", "group": "genres", "description": "\u9898\u6750\uFF1A\u67E5\u8BE2\u9898\u6750" },
|
|
2612
|
+
{ "id": "graphic.attachGraphicRunFile", "method": "PUT", "path": "/api/graphic/runs/:runId/attachments", "source": "web-src/src/lib/api.ts:1441", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u8BBE\u7F6E\u4F5C\u54C1 / \u9644\u4EF6", "body": "binary", "uploadPolicy": "graphicAttachment", "businessHeaders": { "x-attachment-delivery": { "default": "explicit", "values": ["explicit", "legacy"] }, "x-attachment-name": { "fromFilename": true } } },
|
|
2613
|
+
{ "id": "graphic.bindGraphicRunProduct", "method": "PATCH", "path": "/api/graphic/runs/:runId/product", "source": "web-src/src/lib/api.ts:1346", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u66F4\u65B0\u4F5C\u54C1 / \u5546\u54C1", "body": "json" },
|
|
2614
|
+
{ "id": "graphic.cancelGraphicGenerationOrder", "method": "POST", "path": "/api/graphic/runs/:runId/generation-orders/:orderId/cancel", "source": "web-src/src/lib/api.ts:1502", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u5236\u4F5C\u5355 / \u53D6\u6D88", "body": "json" },
|
|
2615
|
+
{ "id": "graphic.changeGraphicRunModel", "method": "PATCH", "path": "/api/graphic/runs/:runId/model", "source": "web-src/src/lib/api.ts:1352", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u66F4\u65B0\u4F5C\u54C1 / \u6A21\u578B", "body": "json" },
|
|
2616
|
+
{ "id": "graphic.changeGraphicRunQuality", "method": "PATCH", "path": "/api/graphic/runs/:runId/quality", "source": "web-src/src/lib/api.ts:1357", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u66F4\u65B0\u4F5C\u54C1 / \u753B\u8D28", "body": "json" },
|
|
2617
|
+
{ "id": "graphic.create", "method": "POST", "path": "/api/graphic/runs", "source": "web-src/src/lib/api.ts:1329", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u56FE\u6587 / \u4F5C\u54C1", "body": "json", "exampleBody": { "title": "\u5546\u54C1\u5BA3\u4F20\u56FE" } },
|
|
2618
|
+
{ "id": "graphic.generateGraphicImages", "method": "POST", "path": "/api/graphic/runs/:runId/images", "source": "web-src/src/lib/api.ts:1486", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u56FE\u7247", "body": "json", "businessHeaders": { "prefer": { "default": "respond-async", "values": ["respond-async"] } } },
|
|
2619
|
+
{ "id": "graphic.graphicEditMaskBlob", "method": "GET", "path": "/api/graphic/runs/:runId/images/:imageId/masks/:maskId", "source": "web-src/src/lib/api.ts:1413", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u56FE\u7247 / \u8499\u7248" },
|
|
2620
|
+
{ "id": "graphic.graphicImageBlob", "method": "GET", "path": "/api/graphic/runs/:runId/images/:imageId/download", "source": "web-src/src/lib/api.ts:1380", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u56FE\u7247 / \u4E0B\u8F7D" },
|
|
2621
|
+
{ "id": "graphic.graphicImagePreview", "method": "GET", "path": "/api/graphic/runs/:runId/preview", "source": "web-src/src/lib/api.ts:1370", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u9884\u89C8" },
|
|
2622
|
+
{ "id": "graphic.graphicRun", "method": "GET", "path": "/api/graphic/runs/:runId", "source": "web-src/src/lib/api.ts:1368", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u56FE\u6587 / \u4F5C\u54C1" },
|
|
2623
|
+
{ "id": "graphic.graphicTemplates", "method": "GET", "path": "/api/graphic/templates", "source": "web-src/src/lib/api.ts:1366", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u56FE\u6587 / \u6A21\u677F" },
|
|
2624
|
+
{ "id": "graphic.inspectGraphicRunAttachments", "method": "GET", "path": "/api/graphic/runs/:runId/attachments", "source": "web-src/src/lib/api.ts:1453", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u9644\u4EF6" },
|
|
2625
|
+
{ "id": "graphic.list", "method": "GET", "path": "/api/graphic/runs", "source": "web-src/src/lib/api.ts:1362", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u56FE\u6587 / \u4F5C\u54C1" },
|
|
2626
|
+
{ "id": "graphic.quoteGraphicImages", "method": "POST", "path": "/api/graphic/runs/:runId/quote", "source": "web-src/src/lib/api.ts:1477", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u62A5\u4EF7", "body": "json" },
|
|
2627
|
+
{ "id": "graphic.releaseGraphicOpening", "method": "POST", "path": "/api/graphic/runs/:runId/opening/attachments", "source": "web-src/src/lib/api.ts:1339", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u5F00\u573A / \u9644\u4EF6", "body": "json" },
|
|
2628
|
+
{ "id": "graphic.retryGraphicTurn", "method": "POST", "path": "/api/graphic/runs/:runId/messages/:messageId/retry", "source": "web-src/src/lib/api.ts:1470", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u5BF9\u8BDD / \u91CD\u8BD5", "body": "json" },
|
|
2629
|
+
{ "id": "graphic.saveGraphicEditMask", "method": "POST", "path": "/api/graphic/runs/:runId/images/:imageId/masks", "source": "web-src/src/lib/api.ts:1409", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u56FE\u7247 / \u8499\u7248", "body": "multipart", "uploadPolicy": "mask", "uploadField": "mask" },
|
|
2630
|
+
{ "id": "graphic.saveGraphicImageEdit", "method": "POST", "path": "/api/graphic/runs/:runId/images/:imageId/edits", "source": "web-src/src/lib/api.ts:1402", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u56FE\u7247 / \u7F16\u8F91\u7248\u672C", "body": "multipart", "uploadPolicy": "image", "uploadField": "image" },
|
|
2631
|
+
{ "id": "graphic.saveGraphicRunAttachmentFile", "method": "GET", "path": "/api/graphic/runs/:runId/attachments/:attachmentId/file", "source": "web-src/src/lib/api.ts:1460", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u9644\u4EF6 / \u6587\u4EF6" },
|
|
2632
|
+
{ "id": "graphic.sendGraphicMessage", "method": "POST", "path": "/api/graphic/runs/:runId/messages", "source": "web-src/src/lib/api.ts:1430", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u5BF9\u8BDD", "body": "json", "exampleBody": { "text": "\u4FDD\u7559\u5546\u54C1\u5916\u89C2\uFF0C\u628A\u80CC\u666F\u6539\u6210\u7C73\u767D\u8272" }, "businessHeaders": { "prefer": { "default": "respond-async", "values": ["respond-async"] } } },
|
|
2633
|
+
{ "id": "graphic.stopGraphicRun", "method": "POST", "path": "/api/graphic/runs/:runId/stop", "source": "web-src/src/lib/api.ts:2605", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u505C\u6B62\u56DE\u590D", "body": "json" },
|
|
2634
|
+
{ "id": "graphic.streamGraphicLive", "method": "GET", "path": "/api/graphic/runs/:runId/live", "source": "web-src/src/lib/api.ts:2532", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u5B9E\u65F6\u8FDB\u5EA6" },
|
|
2635
|
+
{ "id": "health.health", "method": "GET", "path": "/api/health", "source": "web-src/src/lib/api.ts:1294", "group": "health", "description": "\u670D\u52A1\u72B6\u6001\uFF1A\u67E5\u8BE2\u670D\u52A1\u72B6\u6001", "public": true },
|
|
2636
|
+
{ "id": "imageModels.imageModelCapabilities", "method": "GET", "path": "/api/image-models/capabilities", "source": "web-src/src/lib/api.ts:2767", "group": "imageModels", "description": "\u56FE\u7247\u6A21\u578B\uFF1A\u67E5\u8BE2\u56FE\u7247\u6A21\u578B / \u80FD\u529B" },
|
|
2637
|
+
{ "id": "imageModels.imageModelReadiness", "method": "GET", "path": "/api/image-models/readiness", "source": "web-src/src/lib/api.ts:2766", "group": "imageModels", "description": "\u56FE\u7247\u6A21\u578B\uFF1A\u67E5\u8BE2\u56FE\u7247\u6A21\u578B / \u5C31\u7EEA\u72B6\u6001" },
|
|
2638
|
+
{ "id": "library.archiveLibraryProject", "method": "POST", "path": "/api/project-library/:kind/:sourceId/archive", "source": "web-src/src/lib/api.ts:2914", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u63D0\u4EA4\u4F5C\u54C1\u5E93 / \u5F52\u6863", "body": "json" },
|
|
2639
|
+
{ "id": "library.downloadTicket", "method": "POST", "path": "/api/project-library/batch-actions/:batchId/download-ticket", "sensitiveOutput": true, "source": "apps/api/src/http/routes/project-library.ts:284", "group": "library", "description": "\u51C6\u5907\u4F5C\u54C1\u5E93\u5408\u96C6\u4E0B\u8F7D", "body": "json" },
|
|
2640
|
+
{ "id": "library.downloadZip", "method": "GET", "path": "/api/project-library/batch-actions/:batchId/download.zip", "source": "apps/api/src/http/routes/project-library.ts:272", "group": "library", "description": "\u4E0B\u8F7D\u4F5C\u54C1\u5E93\u5408\u96C6" },
|
|
2641
|
+
{ "id": "library.executeProjectLibraryBatch", "method": "POST", "path": "/api/project-library/batch-actions/:preflightId/execute", "source": "web-src/src/lib/api.ts:2937", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u63D0\u4EA4\u4F5C\u54C1\u6279\u91CF\u7BA1\u7406 / \u6267\u884C", "body": "json" },
|
|
2642
|
+
{ "id": "library.preflightProjectLibraryBatch", "method": "POST", "path": "/api/project-library/batch-actions/preflight", "source": "web-src/src/lib/api.ts:2924", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u63D0\u4EA4\u4F5C\u54C1\u6279\u91CF\u7BA1\u7406 / \u9884\u68C0", "body": "json" },
|
|
2643
|
+
{ "id": "library.projectLibrary", "method": "GET", "path": "/api/project-library", "source": "web-src/src/lib/api.ts:2891", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u67E5\u8BE2\u4F5C\u54C1\u5E93" },
|
|
2644
|
+
{ "id": "library.projectLibraryBatch", "method": "GET", "path": "/api/project-library/batch-actions/:batchId", "source": "web-src/src/lib/api.ts:2949", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u67E5\u8BE2\u4F5C\u54C1\u5E93 / \u4F5C\u54C1\u6279\u91CF\u7BA1\u7406" },
|
|
2645
|
+
{ "id": "library.projectLibraryByProduct", "method": "GET", "path": "/api/project-library/by-product", "source": "web-src/src/lib/api.ts:2902", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u67E5\u8BE2\u4F5C\u54C1\u5E93 / \u6309\u5546\u54C1\u6C47\u603B" },
|
|
2646
|
+
{ "id": "library.projectLibrarySummary", "method": "GET", "path": "/api/project-library/summary", "source": "web-src/src/lib/api.ts:2896", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u67E5\u8BE2\u4F5C\u54C1\u5E93 / \u6982\u51B5" },
|
|
2647
|
+
{ "id": "library.renameLibraryProject", "method": "PATCH", "path": "/api/project-library/:kind/:sourceId/name", "source": "web-src/src/lib/api.ts:2905", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u66F4\u65B0\u4F5C\u54C1\u5E93 / \u540D\u79F0", "body": "json" },
|
|
2648
|
+
{ "id": "library.unarchiveLibraryProject", "method": "POST", "path": "/api/project-library/:kind/:sourceId/unarchive", "source": "web-src/src/lib/api.ts:2919", "group": "library", "description": "\u4F5C\u54C1\u5E93\uFF1A\u63D0\u4EA4\u4F5C\u54C1\u5E93 / \u6062\u590D\u5F52\u6863", "body": "json" },
|
|
2649
|
+
{ "id": "membership.brands", "method": "GET", "path": "/api/membership/brands", "source": "web-src/src/lib/membership.ts:345", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458 / \u54C1\u724C" },
|
|
2650
|
+
{ "id": "membership.catalog", "method": "GET", "path": "/api/membership/catalog", "source": "web-src/src/lib/membership.ts:334", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458 / \u76EE\u5F55" },
|
|
2651
|
+
{ "id": "membership.claimDailyAutomatically", "method": "POST", "path": "/api/membership/daily-claim", "source": "web-src/src/lib/membership.ts:339", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u4F1A\u5458 / \u9886\u53D6\u6BCF\u65E5\u6743\u76CA", "body": "json" },
|
|
2652
|
+
{ "id": "membership.daily", "method": "GET", "path": "/api/membership/daily", "source": "web-src/src/lib/membership.ts:338", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458 / \u6BCF\u65E5\u6743\u76CA" },
|
|
2653
|
+
{ "id": "membership.deleteBrand", "method": "DELETE", "path": "/api/membership/brands/:brandId", "source": "web-src/src/lib/membership.ts:348", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u5220\u9664\u4F1A\u5458 / \u54C1\u724C", "body": "json" },
|
|
2654
|
+
{ "id": "membership.downloadPack", "method": "GET", "path": "/api/membership/renders/:taskId/output", "source": "apps/api/src/http/routes/membership.ts:165", "group": "membership", "description": "\u4E0B\u8F7D\u5305\u88C5\u6210\u7247" },
|
|
2655
|
+
{ "id": "membership.orders.create", "method": "POST", "path": "/api/membership/orders", "source": "web-src/src/lib/membership.ts:337", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u4F1A\u5458 / \u8BA2\u5355", "body": "json", "idempotencyBodyKey": "idempotencyKey", "replaySafe": true, "exampleBody": { "planVersion": "\u4ECEmembership.catalog\u8BFB\u53D6\u5F53\u524D\u7248\u672C", "intent": "purchase" } },
|
|
2656
|
+
{ "id": "membership.payments.checkout", "method": "POST", "path": "/api/payments/orders/:id/checkout", "source": "web-src/src/lib/api.ts:3286", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u8BA2\u5355 / \u4F1A\u5458\u4ED8\u6B3E", "body": "json", "membershipPaymentOnly": true },
|
|
2657
|
+
{ "id": "membership.payments.show", "method": "GET", "path": "/api/payments/orders/:id", "source": "apps/api/src/http/routes/payments.ts:87", "group": "membership", "description": "\u8BFB\u53D6\u5E76\u9A8C\u8BC1\u672C\u4EBA\u7684\u4F1A\u5458\u4ED8\u6B3E\u5355", "membershipPaymentOnly": true },
|
|
2658
|
+
{ "id": "membership.payments.status", "method": "GET", "path": "/api/payments/orders/:id/status", "source": "web-src/src/lib/api.ts:3292", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u8BA2\u5355 / \u72B6\u6001", "membershipPaymentOnly": true },
|
|
2659
|
+
{ "id": "membership.refund", "method": "POST", "path": "/api/membership/orders/:orderId/refund", "source": "web-src/src/lib/membership.ts:342", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u8BA2\u5355 / \u9000\u6B3E", "body": "json", "idempotencyBodyKey": "idempotencyKey", "replaySafe": true, "exampleBody": {} },
|
|
2660
|
+
{ "id": "membership.refundDetails", "method": "GET", "path": "/api/membership/refunds/:groupId", "source": "web-src/src/lib/membership.ts:343", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458 / \u9000\u6B3E\u8BB0\u5F55" },
|
|
2661
|
+
{ "id": "membership.refundQuote", "method": "POST", "path": "/api/membership/orders/:orderId/refund-quote", "source": "web-src/src/lib/membership.ts:341", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u8BA2\u5355 / \u9000\u6B3E\u8BD5\u7B97", "body": "json" },
|
|
2662
|
+
{ "id": "membership.refundStatus", "method": "POST", "path": "/api/membership/refunds/:groupId/status", "source": "web-src/src/lib/membership.ts:344", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u9000\u6B3E\u8BB0\u5F55 / \u72B6\u6001", "body": "json" },
|
|
2663
|
+
{ "id": "membership.render", "method": "POST", "path": "/api/membership/render", "source": "web-src/src/lib/membership.ts:353", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u4F1A\u5458 / \u5236\u4F5C\u5305\u88C5", "body": "json" },
|
|
2664
|
+
{ "id": "membership.renderAssets", "method": "GET", "path": "/api/membership/render-assets", "source": "web-src/src/lib/membership.ts:351", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458 / \u5305\u88C5\u7D20\u6750" },
|
|
2665
|
+
{ "id": "membership.renderPreview", "method": "POST", "path": "/api/membership/render-preview", "source": "web-src/src/lib/membership.ts:350", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u4F1A\u5458 / \u5305\u88C5\u9884\u89C8", "body": "json" },
|
|
2666
|
+
{ "id": "membership.renderQuote", "method": "POST", "path": "/api/membership/render-quote", "source": "web-src/src/lib/membership.ts:352", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u4F1A\u5458 / \u5305\u88C5\u62A5\u4EF7", "body": "json" },
|
|
2667
|
+
{ "id": "membership.renders.list", "method": "GET", "path": "/api/membership/renders", "source": "web-src/src/components/domain/story-film-packs.tsx:30", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458 / \u5305\u88C5\u6210\u7247" },
|
|
2668
|
+
{ "id": "membership.renderSources", "method": "GET", "path": "/api/membership/render-sources", "source": "web-src/src/lib/membership.ts:349", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458 / \u5305\u88C5\u7247\u6E90" },
|
|
2669
|
+
{ "id": "membership.saveBrand", "method": "POST", "path": "/api/membership/brands", "source": "web-src/src/lib/membership.ts:347", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u63D0\u4EA4\u4F1A\u5458 / \u54C1\u724C", "body": "json" },
|
|
2670
|
+
{ "id": "membership.summary", "method": "GET", "path": "/api/membership", "source": "web-src/src/lib/membership.ts:335", "group": "membership", "description": "\u4F1A\u5458\uFF1A\u67E5\u8BE2\u4F1A\u5458" },
|
|
2671
|
+
{ "id": "notifications.markAllNotificationsRead", "method": "POST", "path": "/api/notifications/read-all", "source": "web-src/src/lib/api.ts:1526", "group": "notifications", "description": "\u901A\u77E5\uFF1A\u63D0\u4EA4\u901A\u77E5 / \u5168\u90E8\u6807\u4E3A\u5DF2\u8BFB", "body": "json" },
|
|
2672
|
+
{ "id": "notifications.markNotificationsRead", "method": "POST", "path": "/api/notifications/read", "source": "web-src/src/lib/api.ts:1524", "group": "notifications", "description": "\u901A\u77E5\uFF1A\u63D0\u4EA4\u901A\u77E5 / \u6807\u8BB0\u5DF2\u8BFB", "body": "json" },
|
|
2673
|
+
{ "id": "notifications.notifications", "method": "GET", "path": "/api/notifications", "source": "web-src/src/lib/api.ts:1520", "group": "notifications", "description": "\u901A\u77E5\uFF1A\u67E5\u8BE2\u901A\u77E5" },
|
|
2674
|
+
{ "id": "notifications.notificationSummary", "method": "GET", "path": "/api/notifications/summary", "source": "web-src/src/lib/api.ts:1512", "group": "notifications", "description": "\u901A\u77E5\uFF1A\u67E5\u8BE2\u901A\u77E5 / \u6982\u51B5" },
|
|
2675
|
+
{ "id": "notifications.pushKey", "method": "GET", "path": "/api/notifications/push/key", "source": "web-src/src/lib/api.ts:1583", "group": "notifications", "description": "\u901A\u77E5\uFF1A\u67E5\u8BE2\u63A8\u9001 / \u63A8\u9001\u516C\u94A5" },
|
|
2676
|
+
{ "id": "notifications.subscribePush", "method": "POST", "path": "/api/notifications/push/subscribe", "source": "web-src/src/lib/api.ts:1586", "group": "notifications", "description": "\u901A\u77E5\uFF1A\u63D0\u4EA4\u63A8\u9001 / \u8BA2\u9605\u63A8\u9001", "body": "json" },
|
|
2677
|
+
{ "id": "notifications.unsubscribePush", "method": "POST", "path": "/api/notifications/push/unsubscribe", "source": "web-src/src/lib/api.ts:1589", "group": "notifications", "description": "\u901A\u77E5\uFF1A\u63D0\u4EA4\u63A8\u9001 / \u53D6\u6D88\u8BA2\u9605", "body": "json" },
|
|
2678
|
+
{ "id": "products.archiveProduct", "method": "POST", "path": "/api/products/:id/archive", "source": "web-src/src/lib/api.ts:2063", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1 / \u5F52\u6863", "body": "json" },
|
|
2679
|
+
{ "id": "products.confirmProductLock", "method": "POST", "path": "/api/products/:id/lock/confirm", "source": "web-src/src/lib/api.ts:2879", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1\u5916\u89C2 / \u786E\u8BA4", "body": "json" },
|
|
2680
|
+
{ "id": "products.create", "method": "POST", "path": "/api/products", "source": "web-src/src/lib/api.ts:2079", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1", "body": "json" },
|
|
2681
|
+
{ "id": "products.createSeries", "method": "POST", "path": "/api/products/:id/series", "source": "web-src/src/lib/api.ts:3173", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1 / \u7CFB\u5217", "body": "json" },
|
|
2682
|
+
{ "id": "products.deleteProductImage", "method": "DELETE", "path": "/api/products/:id/images", "source": "web-src/src/lib/api.ts:2105", "group": "products", "description": "\u5546\u54C1\uFF1A\u5220\u9664\u5546\u54C1 / \u56FE\u7247", "body": "json" },
|
|
2683
|
+
{ "id": "products.get", "method": "GET", "path": "/api/products/:id", "source": "web-src/src/lib/api.ts:2048", "group": "products", "description": "\u5546\u54C1\uFF1A\u67E5\u8BE2\u5546\u54C1" },
|
|
2684
|
+
{ "id": "products.list", "method": "GET", "path": "/api/products", "source": "web-src/src/lib/api.ts:2047", "group": "products", "description": "\u5546\u54C1\uFF1A\u67E5\u8BE2\u5546\u54C1" },
|
|
2685
|
+
{ "id": "products.mergeProducts", "method": "POST", "path": "/api/products/:id/merge", "source": "web-src/src/lib/api.ts:2059", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1 / \u5408\u5E76", "body": "json" },
|
|
2686
|
+
{ "id": "products.productUsage", "method": "GET", "path": "/api/products/usage", "source": "web-src/src/lib/api.ts:2050", "group": "products", "description": "\u5546\u54C1\uFF1A\u67E5\u8BE2\u5546\u54C1 / \u4F7F\u7528\u60C5\u51B5" },
|
|
2687
|
+
{ "id": "products.recognizeProductLock", "method": "POST", "path": "/api/products/:id/recognize-lock", "source": "web-src/src/lib/api.ts:2109", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1 / \u8BC6\u522B\u5546\u54C1\u5916\u89C2", "body": "json" },
|
|
2688
|
+
{ "id": "products.renameProduct", "method": "PATCH", "path": "/api/products/:id", "source": "web-src/src/lib/api.ts:2052", "group": "products", "description": "\u5546\u54C1\uFF1A\u66F4\u65B0\u5546\u54C1", "body": "json" },
|
|
2689
|
+
{ "id": "products.unarchiveProduct", "method": "POST", "path": "/api/products/:id/unarchive", "source": "web-src/src/lib/api.ts:2065", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1 / \u6062\u590D\u5F52\u6863", "body": "json" },
|
|
2690
|
+
{ "id": "products.unmergeProduct", "method": "POST", "path": "/api/products/:id/unmerge", "source": "web-src/src/lib/api.ts:2061", "group": "products", "description": "\u5546\u54C1\uFF1A\u63D0\u4EA4\u5546\u54C1 / \u64A4\u9500\u5408\u5E76", "body": "json" },
|
|
2691
|
+
{ "id": "products.uploadProductImage", "method": "PUT", "path": "/api/products/:id/images", "source": "web-src/src/lib/api.ts:2094", "group": "products", "description": "\u5546\u54C1\uFF1A\u8BBE\u7F6E\u5546\u54C1 / \u56FE\u7247", "body": "binary", "uploadPolicy": "image" },
|
|
2692
|
+
{ "id": "public.checkReferralCode", "method": "POST", "path": "/api/public/referral-codes/check", "source": "web-src/src/lib/api.ts:1707", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u63D0\u4EA4\u63A8\u8350\u7801 / \u6838\u9A8C", "body": "json", "public": true },
|
|
2693
|
+
{ "id": "public.publicAnnouncements", "method": "GET", "path": "/api/public/announcements", "source": "web-src/src/lib/api.ts:1529", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u67E5\u8BE2\u516C\u5F00\u4FE1\u606F / \u516C\u544A", "public": true },
|
|
2694
|
+
{ "id": "public.publicAssetProof", "method": "GET", "path": "/api/public/assets/summary", "source": "web-src/src/lib/api.ts:1506", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u67E5\u8BE2\u7D20\u6750 / \u6982\u51B5", "public": true },
|
|
2695
|
+
{ "id": "public.publicPricing", "method": "GET", "path": "/api/public/pricing", "source": "web-src/src/lib/api.ts:1291", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u67E5\u8BE2\u516C\u5F00\u4FE1\u606F / \u4EF7\u683C", "public": true },
|
|
2696
|
+
{ "id": "public.publicRankings", "method": "GET", "path": "/api/public/rankings", "source": "web-src/src/lib/api.ts:1292", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u67E5\u8BE2\u516C\u5F00\u4FE1\u606F / \u699C\u5355", "public": true },
|
|
2697
|
+
{ "id": "public.publicShowcase", "method": "GET", "path": "/api/public/showcase", "source": "web-src/src/lib/api.ts:1306", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u67E5\u8BE2\u516C\u5F00\u4FE1\u606F / \u5C55\u793A\u4F5C\u54C1", "public": true },
|
|
2698
|
+
{ "id": "public.recordReferralVisit", "method": "POST", "path": "/api/public/referral-codes/visit", "source": "web-src/src/lib/api.ts:1727", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u63D0\u4EA4\u63A8\u8350\u7801 / \u8BBF\u95EE\u8BB0\u5F55", "body": "json", "public": true },
|
|
2699
|
+
{ "id": "public.submitTrialRequest", "method": "POST", "path": "/api/public/trial-requests", "source": "web-src/src/lib/api.ts:1509", "group": "public", "description": "\u516C\u5F00\u4FE1\u606F\uFF1A\u63D0\u4EA4\u516C\u5F00\u4FE1\u606F / \u8BD5\u7528\u7533\u8BF7", "body": "json", "public": true },
|
|
2700
|
+
{ "id": "series.approveSeriesOutline", "method": "POST", "path": "/api/series/:id/outline/:docId/approve", "source": "web-src/src/lib/api.ts:3184", "group": "series", "description": "\u7CFB\u5217\uFF1A\u63D0\u4EA4\u5927\u7EB2 / \u786E\u8BA4", "body": "json" },
|
|
2701
|
+
{ "id": "series.createEpisode", "method": "POST", "path": "/api/series/:id/episodes", "source": "web-src/src/lib/api.ts:3175", "group": "series", "description": "\u7CFB\u5217\uFF1A\u63D0\u4EA4\u7CFB\u5217 / \u5206\u96C6", "body": "json" },
|
|
2702
|
+
{ "id": "series.generateOutline", "method": "POST", "path": "/api/series/:id/outline", "source": "apps/api/src/http/routes/script-engine.ts:99", "group": "series", "description": "\u51C6\u5907\u7CFB\u5217\u5927\u7EB2", "body": "json" },
|
|
2703
|
+
{ "id": "series.getSeries", "method": "GET", "path": "/api/series/:id", "source": "web-src/src/lib/api.ts:3171", "group": "series", "description": "\u7CFB\u5217\uFF1A\u67E5\u8BE2\u7CFB\u5217" },
|
|
2704
|
+
{ "id": "series.getSeriesOutline", "method": "GET", "path": "/api/series/:id/outline", "source": "web-src/src/lib/api.ts:3179", "group": "series", "description": "\u7CFB\u5217\uFF1A\u67E5\u8BE2\u7CFB\u5217 / \u5927\u7EB2" },
|
|
2705
|
+
{ "id": "series.listSeries", "method": "GET", "path": "/api/series", "source": "web-src/src/lib/api.ts:3170", "group": "series", "description": "\u7CFB\u5217\uFF1A\u67E5\u8BE2\u7CFB\u5217" },
|
|
2706
|
+
{ "id": "templates.createTemplateShortOrder", "method": "POST", "path": "/api/template-shorts/orders", "source": "web-src/src/lib/api.ts:3565", "group": "templates", "description": "\u6A21\u677F\u77ED\u7247\uFF1A\u63D0\u4EA4\u6A21\u677F\u77ED\u7247 / \u8BA2\u5355", "body": "json" },
|
|
2707
|
+
{ "id": "templates.quoteTemplateShortOrder", "method": "POST", "path": "/api/template-shorts/quote", "source": "web-src/src/lib/api.ts:3561", "group": "templates", "description": "\u6A21\u677F\u77ED\u7247\uFF1A\u63D0\u4EA4\u6A21\u677F\u77ED\u7247 / \u62A5\u4EF7", "body": "json" },
|
|
2708
|
+
{ "id": "templates.templateShortOrder", "method": "GET", "path": "/api/template-shorts/orders/:id", "source": "web-src/src/lib/api.ts:3569", "group": "templates", "description": "\u6A21\u677F\u77ED\u7247\uFF1A\u67E5\u8BE2\u6A21\u677F\u77ED\u7247 / \u8BA2\u5355" },
|
|
2709
|
+
{ "id": "templates.templateShortOrderDownload", "method": "GET", "path": "/api/template-shorts/orders/:id/download", "source": "web-src/src/lib/api.ts:3576", "group": "templates", "description": "\u6A21\u677F\u77ED\u7247\uFF1A\u67E5\u8BE2\u8BA2\u5355 / \u4E0B\u8F7D" },
|
|
2710
|
+
{ "id": "templates.templateShortsCatalog", "method": "GET", "path": "/api/template-shorts/catalog", "source": "web-src/src/lib/api.ts:3557", "group": "templates", "description": "\u6A21\u677F\u77ED\u7247\uFF1A\u67E5\u8BE2\u6A21\u677F\u77ED\u7247 / \u76EE\u5F55" },
|
|
2711
|
+
{ "id": "templates.uploadTemplateShortAsset", "method": "POST", "path": "/api/template-shorts/uploads", "source": "web-src/src/lib/api.ts:3585", "group": "templates", "description": "\u6A21\u677F\u77ED\u7247\uFF1A\u63D0\u4EA4\u6A21\u677F\u77ED\u7247 / \u4E0A\u4F20", "body": "binary", "uploadPolicy": "image" },
|
|
2712
|
+
{ "id": "upscale.createUpscaleOrder", "method": "POST", "path": "/api/upscale/orders", "source": "web-src/src/lib/api.ts:2962", "group": "upscale", "description": "\u8D85\u6E05\u753B\u8D28\uFF1A\u63D0\u4EA4\u8D85\u6E05\u753B\u8D28 / \u8BA2\u5355", "body": "json" },
|
|
2713
|
+
{ "id": "upscale.download", "method": "GET", "path": "/api/upscale/orders/:id/video", "source": "apps/api/src/http/routes/upscale.ts:28", "group": "upscale", "description": "\u4E0B\u8F7D\u8D85\u6E05\u6210\u7247" },
|
|
2714
|
+
{ "id": "upscale.listUpscaleOrders", "method": "GET", "path": "/api/upscale/orders", "source": "web-src/src/lib/api.ts:2965", "group": "upscale", "description": "\u8D85\u6E05\u753B\u8D28\uFF1A\u67E5\u8BE2\u8D85\u6E05\u753B\u8D28 / \u8BA2\u5355" },
|
|
2715
|
+
{ "id": "upscale.quoteUpscale", "method": "POST", "path": "/api/upscale/quote", "source": "web-src/src/lib/api.ts:2960", "group": "upscale", "description": "\u8D85\u6E05\u753B\u8D28\uFF1A\u63D0\u4EA4\u8D85\u6E05\u753B\u8D28 / \u62A5\u4EF7", "body": "json" },
|
|
2716
|
+
{ "id": "upscale.upscaleCapability", "method": "GET", "path": "/api/upscale/capability", "source": "web-src/src/lib/api.ts:2958", "group": "upscale", "description": "\u8D85\u6E05\u753B\u8D28\uFF1A\u67E5\u8BE2\u8D85\u6E05\u753B\u8D28 / \u80FD\u529B" },
|
|
2717
|
+
{ "id": "videoModels.videoModelReadiness", "method": "GET", "path": "/api/video-models/readiness", "source": "web-src/src/lib/api.ts:2765", "group": "videoModels", "description": "\u89C6\u9891\u6A21\u578B\uFF1A\u67E5\u8BE2\u89C6\u9891\u6A21\u578B / \u5C31\u7EEA\u72B6\u6001" },
|
|
2718
|
+
{ "id": "videos.acceptShowcaseLearning", "method": "POST", "path": "/api/showcase-videos/:id/accept-learning", "source": "web-src/src/lib/api.ts:2872", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891 / \u91C7\u7528\u5B66\u4E60\u7ED3\u679C", "body": "json" },
|
|
2719
|
+
{ "id": "videos.adoptCommercialAdAssetGapUploaded", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/gaps/:gapId/adopt-uploaded", "source": "web-src/src/lib/api.ts:2325", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u7D20\u6750\u7F3A\u53E3 / \u91C7\u7528\u4E0A\u4F20\u7D20\u6750", "body": "json" },
|
|
2720
|
+
{ "id": "videos.applyCommercialAdMusic", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/music/:taskId/apply", "source": "web-src/src/lib/api.ts:2191", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u914D\u4E50 / \u5E94\u7528", "body": "json" },
|
|
2721
|
+
{ "id": "videos.attachCommercialAdRootImage", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/attachments", "source": "web-src/src/lib/api.ts:2422", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u8BBE\u7F6E\u4F5C\u54C1 / \u9644\u4EF6", "body": "binary", "uploadPolicy": "chatAttachment", "businessHeaders": { "x-attachment-delivery": { "default": "explicit", "values": ["explicit", "legacy"] }, "x-attachment-name": { "fromFilename": true } } },
|
|
2722
|
+
{ "id": "videos.cancelCommercialAdRunWaitingBudget", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/cancel-waiting-budget", "source": "web-src/src/lib/api.ts:2340", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u505C\u6B62\u7B49\u5F85\u4F59\u989D", "body": "json" },
|
|
2723
|
+
{ "id": "videos.commercialAdAreaMaskBlob", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/image-edits/area/:quoteId/mask", "source": "web-src/src/lib/api.ts:2211", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5C40\u90E8\u4FEE\u6539 / \u8499\u7248" },
|
|
2724
|
+
{ "id": "videos.commercialAdAreaPreviewBlob", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/image-edits/area/:jobId/preview", "source": "web-src/src/lib/api.ts:2213", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5C40\u90E8\u4FEE\u6539 / \u9884\u89C8" },
|
|
2725
|
+
{ "id": "videos.commercialAdImageBlob", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/images/:assetId/download", "source": "web-src/src/lib/api.ts:2216", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u56FE\u7247 / \u4E0B\u8F7D" },
|
|
2726
|
+
{ "id": "videos.commercialAdImageBlob.download", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/storyboards/:imageKey/download", "source": "web-src/src/lib/api.ts:2216", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u6545\u4E8B\u677F / \u4E0B\u8F7D" },
|
|
2727
|
+
{ "id": "videos.commercialAdImageBlob.download_2", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/image-edits/:editId/download", "source": "web-src/src/lib/api.ts:2216", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u56FE\u7247\u7F16\u8F91 / \u4E0B\u8F7D" },
|
|
2728
|
+
{ "id": "videos.commercialAdInspirations", "method": "GET", "path": "/api/showcase-videos/inspirations", "source": "web-src/src/lib/api.ts:2763", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u7075\u611F" },
|
|
2729
|
+
{ "id": "videos.commercialAdMethods", "method": "GET", "path": "/api/showcase-videos/methods", "source": "web-src/src/lib/api.ts:2760", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u5236\u4F5C\u65B9\u5F0F" },
|
|
2730
|
+
{ "id": "videos.commercialAdPlayCards", "method": "GET", "path": "/api/showcase-videos/play-cards", "source": "web-src/src/lib/api.ts:2762", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u73A9\u6CD5" },
|
|
2731
|
+
{ "id": "videos.compareCommercialAdRunFileVersions", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/files/:path/versions/compare", "source": "web-src/src/lib/api.ts:2247", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u7248\u672C / \u5BF9\u6BD4" },
|
|
2732
|
+
{ "id": "videos.confirmCommercialAdAreaEdit", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/image-edits/area/confirm", "source": "web-src/src/lib/api.ts:2209", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5C40\u90E8\u4FEE\u6539 / \u786E\u8BA4", "body": "json" },
|
|
2733
|
+
{ "id": "videos.confirmCommercialAdDirectorImage", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/confirm-image", "source": "web-src/src/lib/api.ts:2388", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u786E\u8BA4\u51FA\u56FE", "body": "json" },
|
|
2734
|
+
{ "id": "videos.confirmCommercialAdRootProduction", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/confirm-production", "source": "web-src/src/lib/api.ts:2379", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u786E\u8BA4\u5236\u4F5C", "body": "json" },
|
|
2735
|
+
{ "id": "videos.confirmCommercialAdRootProductLock", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/product-lock-confirm", "source": "web-src/src/lib/api.ts:2354", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u786E\u8BA4\u5546\u54C1\u5916\u89C2", "body": "json" },
|
|
2736
|
+
{ "id": "videos.confirmShowcaseVideo", "method": "POST", "path": "/api/showcase-videos/:id/confirm", "source": "web-src/src/lib/api.ts:2866", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891 / \u786E\u8BA4", "body": "json" },
|
|
2737
|
+
{ "id": "videos.continueCommercialAdVoiceSelection", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/voice-selection/continue", "source": "web-src/src/lib/api.ts:2171", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u97F3\u8272\u9009\u62E9 / \u7EE7\u7EED", "body": "json" },
|
|
2738
|
+
{ "id": "videos.createCommercialAdMediaPass", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/media-pass", "source": "web-src/src/lib/api.ts:2194", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u64AD\u653E\u51ED\u8BC1", "body": "json" },
|
|
2739
|
+
{ "id": "videos.createCommercialAdPresetVoiceSample", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/voice-candidates/preset", "source": "web-src/src/lib/api.ts:2167", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u97F3\u8272\u5019\u9009 / \u9884\u8BBE", "body": "json" },
|
|
2740
|
+
{ "id": "videos.createMotionReference", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/motion-references", "source": "apps/api/src/http/routes/showcase.ts:749", "group": "videos", "description": "\u622A\u53D6\u52A8\u4F5C\u53C2\u8003", "body": "json" },
|
|
2741
|
+
{ "id": "videos.createShowcaseVideo", "method": "POST", "path": "/api/showcase-videos", "source": "web-src/src/lib/api.ts:2135", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891", "body": "json" },
|
|
2742
|
+
{ "id": "videos.decideCommercialAdPublicReferenceCandidate", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/public-reference-candidates/:assetId/decision", "source": "web-src/src/lib/api.ts:2158", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u8BBE\u7F6E\u516C\u5F00\u53C2\u8003 / \u9009\u7528\u610F\u89C1", "body": "json" },
|
|
2743
|
+
{ "id": "videos.deleteCommercialAdAsset", "method": "DELETE", "path": "/api/showcase-videos/assets/:id", "source": "web-src/src/lib/api.ts:2564", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u5220\u9664\u5546\u54C1\u89C6\u9891 / \u7D20\u6750", "body": "json" },
|
|
2744
|
+
{ "id": "videos.downloadAppend", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/append-tasks/:taskId/clip", "source": "apps/api/src/http/routes/showcase.ts:548", "group": "videos", "description": "\u4E0B\u8F7D\u65B0\u589E\u7247\u6BB5" },
|
|
2745
|
+
{ "id": "videos.downloadEdit", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/edits/:editId/download", "source": "apps/api/src/http/routes/showcase.ts:524", "group": "videos", "description": "\u4E0B\u8F7D\u5546\u54C1\u89C6\u9891\u526A\u8F91\u7248" },
|
|
2746
|
+
{ "id": "videos.downloadEditSubtitles", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/edits/:editId/subtitles", "source": "apps/api/src/http/routes/showcase.ts:527", "group": "videos", "description": "\u4E0B\u8F7D\u5546\u54C1\u89C6\u9891\u526A\u8F91\u5B57\u5E55" },
|
|
2747
|
+
{ "id": "videos.downloadFinal", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/video/download", "source": "apps/api/src/http/routes/showcase.ts:829", "group": "videos", "description": "\u4E0B\u8F7D\u5546\u54C1\u89C6\u9891\u6210\u7247" },
|
|
2748
|
+
{ "id": "videos.downloadMusic", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/music/:taskId/tracks/:index/download", "source": "apps/api/src/http/routes/showcase.ts:817", "group": "videos", "description": "\u4E0B\u8F7D\u914D\u4E50\u97F3\u8F68" },
|
|
2749
|
+
{ "id": "videos.downloadNarration", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/edits/:editId/narration/download", "source": "apps/api/src/http/routes/showcase.ts:538", "group": "videos", "description": "\u4E0B\u8F7D\u65C1\u767D\u97F3\u8F68" },
|
|
2750
|
+
{ "id": "videos.downloadProduction", "method": "GET", "path": "/api/showcase-videos/:id/video/download", "source": "apps/api/src/http/routes/showcase.ts:1460", "group": "videos", "description": "\u4E0B\u8F7D\u6307\u5B9A\u5236\u4F5C\u6210\u7247" },
|
|
2751
|
+
{ "id": "videos.generateCommercialAdAsset", "method": "POST", "path": "/api/showcase-videos/assets/generate", "source": "web-src/src/lib/api.ts:2542", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u7D20\u6750 / \u5236\u4F5C", "body": "json" },
|
|
2752
|
+
{ "id": "videos.getCommercialAdAreaQuote", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/image-edits/area/:quoteId", "source": "web-src/src/lib/api.ts:2207", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u56FE\u7247\u7F16\u8F91 / \u5C40\u90E8\u4FEE\u6539" },
|
|
2753
|
+
{ "id": "videos.getCommercialAdMusicTrackAudio", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/music/:taskId/tracks/:index/audio", "source": "web-src/src/lib/api.ts:2196", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u97F3\u8F68 / \u97F3\u9891" },
|
|
2754
|
+
{ "id": "videos.getCommercialAdPlatformVoiceAudio", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/platform-voices/:voiceId/audio", "source": "web-src/src/lib/api.ts:2179", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5E73\u53F0\u97F3\u8272 / \u97F3\u9891" },
|
|
2755
|
+
{ "id": "videos.getCommercialAdPlatformVoices", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/platform-voices", "source": "web-src/src/lib/api.ts:2177", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u5E73\u53F0\u97F3\u8272" },
|
|
2756
|
+
{ "id": "videos.getCommercialAdPresetVoiceSampleAudio", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/voice-presets/:voiceId/sample", "source": "web-src/src/lib/api.ts:2182", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u97F3\u8272\u9884\u8BBE / \u8BD5\u542C" },
|
|
2757
|
+
{ "id": "videos.getCommercialAdProductionPreview", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/production-preview", "source": "web-src/src/lib/api.ts:2146", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u5236\u4F5C\u9884\u89C8" },
|
|
2758
|
+
{ "id": "videos.getCommercialAdPublicReferenceCandidates", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/public-reference-candidates", "source": "web-src/src/lib/api.ts:2156", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u516C\u5F00\u53C2\u8003" },
|
|
2759
|
+
{ "id": "videos.getCommercialAdRun", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId", "source": "web-src/src/lib/api.ts:2143", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u4F5C\u54C1" },
|
|
2760
|
+
{ "id": "videos.getCommercialAdRunFile", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/files/:path", "source": "web-src/src/lib/api.ts:2224", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u6587\u4EF6" },
|
|
2761
|
+
{ "id": "videos.getCommercialAdRunFileVersion", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/files/:path/versions/:versionId", "source": "web-src/src/lib/api.ts:2235", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u6587\u4EF6 / \u7248\u672C" },
|
|
2762
|
+
{ "id": "videos.getCommercialAdSubtitles", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/subtitles", "source": "web-src/src/lib/api.ts:2149", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u5B57\u5E55" },
|
|
2763
|
+
{ "id": "videos.getCommercialAdVoiceAudio", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/voice-candidates/:candidateId/audio", "source": "web-src/src/lib/api.ts:2173", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u97F3\u8272\u5019\u9009 / \u97F3\u9891" },
|
|
2764
|
+
{ "id": "videos.getCommercialAdVoiceCandidates", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/voice-candidates", "source": "web-src/src/lib/api.ts:2154", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u97F3\u8272\u5019\u9009" },
|
|
2765
|
+
{ "id": "videos.getCommercialAdVoiceLibraryAudio", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/voice-library/:candidateId/audio", "source": "web-src/src/lib/api.ts:2175", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u58F0\u97F3\u5E93 / \u97F3\u9891" },
|
|
2766
|
+
{ "id": "videos.getCommercialAdVoiceoverPreviewAudio", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/voiceover/previews/:previewId/audio", "source": "web-src/src/lib/api.ts:2185", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u9884\u89C8 / \u97F3\u9891" },
|
|
2767
|
+
{ "id": "videos.getShowcaseVideo", "method": "GET", "path": "/api/showcase-videos/:id", "source": "web-src/src/lib/api.ts:2709", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891" },
|
|
2768
|
+
{ "id": "videos.inspectCommercialAdRootAttachments", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/attachments", "source": "web-src/src/lib/api.ts:2434", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u9644\u4EF6" },
|
|
2769
|
+
{ "id": "videos.listCommercialAdAssetGapOptions", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/asset-gaps/:gapId/options", "source": "web-src/src/lib/api.ts:2299", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u7D20\u6750\u7F3A\u53E3 / \u9009\u9879" },
|
|
2770
|
+
{ "id": "videos.listCommercialAdAssets", "method": "GET", "path": "/api/showcase-videos/assets", "source": "web-src/src/lib/api.ts:2549", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u7D20\u6750" },
|
|
2771
|
+
{ "id": "videos.listCommercialAdImageEdits", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/image-edits", "source": "web-src/src/lib/api.ts:2201", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u56FE\u7247\u7F16\u8F91" },
|
|
2772
|
+
{ "id": "videos.listCommercialAdMusic", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/music", "source": "web-src/src/lib/api.ts:2188", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u914D\u4E50" },
|
|
2773
|
+
{ "id": "videos.listCommercialAdRunFileVersions", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/files/:path/versions", "source": "web-src/src/lib/api.ts:2230", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u6587\u4EF6 / \u7248\u672C" },
|
|
2774
|
+
{ "id": "videos.listCommercialAdRuns", "method": "GET", "path": "/api/showcase-videos/runs/actionable", "source": "web-src/src/lib/api.ts:2758", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u5F85\u5904\u7406\u4F5C\u54C1" },
|
|
2775
|
+
{ "id": "videos.listCommercialAdRuns.runs", "method": "GET", "path": "/api/showcase-videos/runs", "source": "web-src/src/lib/api.ts:2758", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u4F5C\u54C1" },
|
|
2776
|
+
{ "id": "videos.listShowcaseVideos", "method": "GET", "path": "/api/showcase-videos", "source": "web-src/src/lib/api.ts:2745", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891" },
|
|
2777
|
+
{ "id": "videos.motionReferences", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/motion-references", "source": "web-src/src/components/domain/commercial-ad-motion-references.tsx:78", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u52A8\u4F5C\u53C2\u8003" },
|
|
2778
|
+
{ "id": "videos.planShowcaseDuration", "method": "POST", "path": "/api/showcase-videos/plan-duration", "source": "web-src/src/lib/api.ts:2801", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891 / \u89C4\u5212\u65F6\u957F", "body": "json" },
|
|
2779
|
+
{ "id": "videos.playEdit", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/edits/:editId/video", "source": "apps/api/src/http/routes/showcase.ts:523", "group": "videos", "description": "\u8BFB\u53D6\u5546\u54C1\u89C6\u9891\u526A\u8F91\u7248" },
|
|
2780
|
+
{ "id": "videos.playMotionReference", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/motion-references/:candidateId/video", "source": "apps/api/src/http/routes/showcase.ts:759", "group": "videos", "description": "\u8BFB\u53D6\u52A8\u4F5C\u53C2\u8003\u7247\u6BB5" },
|
|
2781
|
+
{ "id": "videos.playSegment", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/production-segments/:index/video", "source": "apps/api/src/http/routes/showcase.ts:559", "group": "videos", "description": "\u8BFB\u53D6\u9010\u6BB5\u89C6\u9891" },
|
|
2782
|
+
{ "id": "videos.pollShowcaseAiPrompt", "method": "POST", "path": "/api/showcase-videos/ai-prompt", "source": "web-src/src/lib/api.ts:1190", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891 / \u521B\u4F5C\u65B9\u6848", "body": "json" },
|
|
2783
|
+
{ "id": "videos.pollShowcaseAiPrompt.ai_prompt", "method": "GET", "path": "/api/showcase-videos/ai-prompt/:receiptId", "source": "web-src/src/lib/api.ts:1202", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u521B\u4F5C\u65B9\u6848" },
|
|
2784
|
+
{ "id": "videos.postCommercialAdRootMessage", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/messages", "source": "web-src/src/lib/api.ts:2463", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u5BF9\u8BDD", "body": "json", "exampleBody": { "text": "\u5148\u6574\u7406\u6545\u4E8B\u811A\u672C\u548C\u5206\u955C\uFF0C\u62A5\u4EF7\u540E\u7B49\u6211\u786E\u8BA4" } },
|
|
2785
|
+
{ "id": "videos.quoteCommercialAdAreaEdit", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/image-edits/area/quote", "source": "web-src/src/lib/api.ts:2204", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5C40\u90E8\u4FEE\u6539 / \u62A5\u4EF7", "body": "multipart", "uploadPolicy": "mask", "uploadField": "mask" },
|
|
2786
|
+
{ "id": "videos.quoteShowcaseVideo", "method": "GET", "path": "/api/showcase-videos/quote", "source": "web-src/src/lib/api.ts:2769", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891 / \u62A5\u4EF7" },
|
|
2787
|
+
{ "id": "videos.redoShowcaseStoryboard", "method": "POST", "path": "/api/showcase-videos/:id/storyboard", "source": "web-src/src/lib/api.ts:2857", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891 / \u6545\u4E8B\u677F", "body": "json" },
|
|
2788
|
+
{ "id": "videos.renameCommercialAdAsset", "method": "PATCH", "path": "/api/showcase-videos/assets/:id", "source": "web-src/src/lib/api.ts:2554", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u66F4\u65B0\u5546\u54C1\u89C6\u9891 / \u7D20\u6750", "body": "json" },
|
|
2789
|
+
{ "id": "videos.resolveCommercialAdAssetGap", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/asset-gaps/:gapId/resolve", "source": "web-src/src/lib/api.ts:2272", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u7D20\u6750\u7F3A\u53E3 / \u5904\u7406\u7F3A\u53E3", "body": "json" },
|
|
2790
|
+
{ "id": "videos.resolveCommercialAdAssetGaps", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/asset-gaps/resolve-batch", "source": "web-src/src/lib/api.ts:2281", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u7D20\u6750\u7F3A\u53E3 / \u5904\u7406\u591A\u4E2A\u7D20\u6750\u7F3A\u53E3", "body": "json" },
|
|
2791
|
+
{ "id": "videos.restoreCommercialAdRunFileVersion", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/files/:path/versions/:versionId/restore", "source": "web-src/src/lib/api.ts:2258", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u7248\u672C / \u6062\u590D", "body": "json" },
|
|
2792
|
+
{ "id": "videos.resumeCommercialAdRootAfterProductImage", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/product-image-resume", "source": "web-src/src/lib/api.ts:2345", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u5546\u54C1\u56FE\u7247\u5C31\u7EEA\u540E\u7EE7\u7EED", "body": "json" },
|
|
2793
|
+
{ "id": "videos.retryCommercialAdFilmJoin", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/append-tasks/:taskId/retry-join", "source": "web-src/src/lib/api.ts:2198", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u8FFD\u52A0\u7247\u6BB5 / \u91CD\u65B0\u5408\u6210", "body": "json" },
|
|
2794
|
+
{ "id": "videos.retryCommercialAdRootFailedStep", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/retry-failed-step", "source": "web-src/src/lib/api.ts:2334", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u91CD\u8BD5\u5931\u8D25\u6B65\u9AA4", "body": "json" },
|
|
2795
|
+
{ "id": "videos.retryShowcaseVideo", "method": "POST", "path": "/api/showcase-videos/:id/retry", "source": "web-src/src/lib/api.ts:2851", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891 / \u91CD\u8BD5", "body": "json" },
|
|
2796
|
+
{ "id": "videos.saveCommercialAdImageEdit", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/image-edits/:sourceKind/:sourceId", "source": "web-src/src/lib/api.ts:2219", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u8BBE\u7F6E\u4F5C\u54C1 / \u56FE\u7247\u7F16\u8F91", "body": "binary", "uploadPolicy": "image" },
|
|
2797
|
+
{ "id": "videos.saveCommercialAdRootAttachmentFile", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/attachments/:attachmentId/file", "source": "web-src/src/lib/api.ts:2451", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u9644\u4EF6 / \u6587\u4EF6" },
|
|
2798
|
+
{ "id": "videos.selectCommercialAdVoiceCandidate", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/voice-selection", "source": "web-src/src/lib/api.ts:2169", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u8BBE\u7F6E\u4F5C\u54C1 / \u97F3\u8272\u9009\u62E9", "body": "json" },
|
|
2799
|
+
{ "id": "videos.selectMotionReference", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/motion-references/:candidateId/select", "source": "apps/api/src/http/routes/showcase.ts:754", "group": "videos", "description": "\u9009\u62E9\u52A8\u4F5C\u53C2\u8003", "body": "json" },
|
|
2800
|
+
{ "id": "videos.setCommercialAdSubtitles", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/subtitles", "source": "web-src/src/lib/api.ts:2151", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u8BBE\u7F6E\u4F5C\u54C1 / \u5B57\u5E55", "body": "json" },
|
|
2801
|
+
{ "id": "videos.startCommercialAdRun", "method": "POST", "path": "/api/showcase-videos/runs", "source": "web-src/src/lib/api.ts:2141", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5546\u54C1\u89C6\u9891 / \u4F5C\u54C1", "body": "json" },
|
|
2802
|
+
{ "id": "videos.streamCommercialAdRootLive", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/live", "source": "web-src/src/lib/api.ts:2518", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u4F5C\u54C1 / \u5B9E\u65F6\u8FDB\u5EA6" },
|
|
2803
|
+
{ "id": "videos.streamCommercialAdRootMessage", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/messages/stream", "source": "web-src/src/lib/api.ts:2497", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u5BF9\u8BDD / \u5B9E\u65F6\u5BF9\u8BDD", "body": "json" },
|
|
2804
|
+
{ "id": "videos.updateCommercialAdRootSettings", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/settings", "source": "web-src/src/lib/api.ts:2363", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u63D0\u4EA4\u4F5C\u54C1 / \u8BBE\u7F6E", "body": "json" },
|
|
2805
|
+
{ "id": "videos.uploadCommercialAdAssetGap", "method": "PUT", "path": "/api/showcase-videos/runs/:rootRunId/gaps/:gapId/upload", "source": "web-src/src/lib/api.ts:2400", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u8BBE\u7F6E\u7D20\u6750\u7F3A\u53E3 / \u4E0A\u4F20", "body": "binary", "uploadPolicy": "image" },
|
|
2806
|
+
{ "id": "videos.voiceCandidates.importSource", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/voice-candidates", "source": "web-src/src/lib/api.ts:2161", "group": "videos", "description": "\u4ECE\u5DF2\u6709\u6765\u6E90\u5BFC\u5165\u5546\u54C1\u89C6\u9891\u97F3\u8272\u53C2\u8003", "body": "json" },
|
|
2807
|
+
{ "id": "videos.voiceCandidates.upload", "method": "POST", "path": "/api/showcase-videos/runs/:rootRunId/voice-candidates", "source": "web-src/src/lib/api.ts:2161", "group": "videos", "description": "\u4E0A\u4F20\u5546\u54C1\u89C6\u9891\u97F3\u8272\u53C2\u8003", "body": "multipart", "uploadPolicy": "voiceSource", "uploadField": "file" },
|
|
2808
|
+
{ "id": "auth.smsLoginStatus", "method": "GET", "path": "/api/auth/sms/login/status", "source": "web-src/src/lib/api.ts:1803", "group": "auth", "description": "\u767B\u5F55\uFF1A\u67E5\u8BE2\u77ED\u4FE1\u767B\u5F55\u662F\u5426\u5F00\u653E", "public": true },
|
|
2809
|
+
{ "id": "auth.sendLoginSms", "method": "POST", "path": "/api/auth/sms/login-code", "source": "web-src/src/lib/api.ts:1805", "group": "auth", "description": "\u767B\u5F55\uFF1A\u53D1\u9001\u767B\u5F55\u9A8C\u8BC1\u7801", "body": "json", "public": true, "exampleBody": { "phone": "\u624B\u673A\u53F7" } },
|
|
2810
|
+
{ "id": "auth.loginWithSms", "method": "POST", "path": "/api/auth/login/sms", "source": "web-src/src/lib/api.ts:1808", "group": "auth", "description": "\u767B\u5F55\uFF1A\u4F7F\u7528\u77ED\u4FE1\u9A8C\u8BC1\u7801\u767B\u5F55\u5E76\u4FDD\u5B58\u4F1A\u8BDD", "body": "json", "public": true, "sessionResponse": true, "exampleBody": { "phone": "\u624B\u673A\u53F7", "code": "\u9A8C\u8BC1\u7801" } },
|
|
2811
|
+
{ "id": "auth.sendPasswordSetupSms", "method": "POST", "path": "/api/auth/password/setup-code", "source": "web-src/src/lib/api.ts:1847", "group": "auth", "description": "\u767B\u5F55\uFF1A\u5411\u5F53\u524D\u8D26\u53F7\u53D1\u9001\u9996\u6B21\u8BBE\u5BC6\u9A8C\u8BC1\u7801", "body": "json" },
|
|
2812
|
+
{ "id": "auth.setupPassword", "method": "POST", "path": "/api/auth/password/setup", "source": "web-src/src/lib/api.ts:1850", "group": "auth", "description": "\u767B\u5F55\uFF1A\u4F7F\u7528\u9A8C\u8BC1\u7801\u9996\u6B21\u8BBE\u7F6E\u5BC6\u7801", "body": "json", "exampleBody": { "code": "\u9A8C\u8BC1\u7801", "newPassword": "\u65B0\u5BC6\u7801" } },
|
|
2813
|
+
{ "id": "graphic.saveGraphicImageToLibrary", "method": "POST", "path": "/api/graphic/runs/:runId/images/:imageId/save-to-library", "source": "web-src/src/lib/api.ts:1477", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u5C06\u56FE\u7247\u4FDD\u5B58\u5230\u672C\u4EBA\u7D20\u6750\u5E93", "body": "json", "exampleBody": { "kind": "scene" } },
|
|
2814
|
+
{ "id": "graphic.attachGraphicRunAsset", "method": "POST", "path": "/api/graphic/runs/:runId/attachments/from-library", "source": "web-src/src/lib/api.ts:1558", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u5F15\u7528\u672C\u4EBA\u7D20\u6750\u5E93\u4E2D\u7684\u7D20\u6750", "body": "json", "exampleBody": { "assetId": "\u7D20\u6750\u7F16\u53F7" } },
|
|
2815
|
+
{ "id": "graphic.graphicImageSource", "method": "GET", "path": "/api/graphic/runs/:runId/images/:imageId/source", "source": "web-src/src/lib/api.ts:1491", "group": "graphic", "description": "\u56FE\u6587\uFF1A\u4FDD\u5B58\u4F9B\u7F16\u8F91\u4F7F\u7528\u7684\u56FE\u7247\u539F\u4EF6\uFF1B\u9700\u8981 --out", "response": "file" },
|
|
2816
|
+
{ "id": "videos.commercialAdImageSource", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/images/:assetId/source", "source": "web-src/src/lib/api.ts:2396", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u4FDD\u5B58\u4F9B\u7F16\u8F91\u4F7F\u7528\u7684\u7D20\u6750\u539F\u56FE\uFF1B\u9700\u8981 --out", "response": "file" },
|
|
2817
|
+
{ "id": "videos.commercialAdStoryboardSource", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/storyboards/:imageKey/source", "source": "web-src/src/lib/api.ts:2396", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u4FDD\u5B58\u4F9B\u7F16\u8F91\u4F7F\u7528\u7684\u6545\u4E8B\u677F\u539F\u56FE\uFF1B\u9700\u8981 --out", "response": "file" },
|
|
2818
|
+
{ "id": "videos.commercialAdImageEditSource", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/image-edits/:editId/source", "source": "web-src/src/lib/api.ts:2396", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u4FDD\u5B58\u4F9B\u7EE7\u7EED\u7F16\u8F91\u4F7F\u7528\u7684\u4FEE\u6539\u540E\u539F\u56FE\uFF1B\u9700\u8981 --out", "response": "file" },
|
|
2819
|
+
{ "id": "videos.getCommercialAdEditTimeline", "method": "GET", "path": "/api/showcase-videos/runs/:rootRunId/edit-timeline", "source": "web-src/src/lib/api.ts:2323", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u526A\u8F91\u65F6\u95F4\u7EBF" },
|
|
2820
|
+
{ "id": "drama.getStoryEditTimeline", "method": "GET", "path": "/api/projects/:projectId/director/edit-timeline", "source": "web-src/src/lib/api.ts:2800", "group": "drama", "description": "\u77ED\u5267\uFF1A\u67E5\u8BE2\u526A\u8F91\u65F6\u95F4\u7EBF" },
|
|
2821
|
+
{ "id": "speech.health", "method": "GET", "path": "/api/speech/health", "source": "web-src/src/components/domain/voice-composer.tsx:45", "group": "speech", "description": "\u8BED\u97F3\uFF1A\u67E5\u8BE2\u8BC6\u522B\u670D\u52A1\u72B6\u6001" },
|
|
2822
|
+
{ "id": "speech.transcribe", "method": "POST", "path": "/api/speech/transcribe", "source": "web-src/src/components/domain/voice-composer.tsx:47", "group": "speech", "description": "\u8BED\u97F3\uFF1A\u5C06\u5F55\u97F3\u8F6C\u4E3A\u6587\u5B57\uFF1B--file \u97F3\u9891\uFF0C\u6700\u591A 2 MiB\u30010.5 \u81F3 60 \u79D2", "body": "binary", "uploadPolicy": "speechTranscription" },
|
|
2823
|
+
{ "id": "public.publicCommercialAdInspirations", "method": "GET", "path": "/api/public/showcase-inspirations", "source": "web-src/src/lib/api.ts:2964", "group": "public", "description": "\u516C\u5F00\uFF1A\u67E5\u8BE2\u5546\u54C1\u89C6\u9891\u521B\u610F\u53C2\u8003", "public": true },
|
|
2824
|
+
{ "id": "videos.showcaseEntryDefault", "method": "GET", "path": "/api/showcase-videos/entry-default", "source": "web-src/src/lib/api.ts:2971", "group": "videos", "description": "\u5546\u54C1\u89C6\u9891\uFF1A\u67E5\u8BE2\u5F53\u524D\u8D26\u53F7\u7684\u521B\u5EFA\u9ED8\u8BA4\u503C" }
|
|
2825
|
+
];
|
|
2826
|
+
|
|
2827
|
+
// src/web-operation-contract.ts
|
|
2828
|
+
import { extname } from "node:path";
|
|
2829
|
+
var BUSINESS_HEADERS = /* @__PURE__ */ new Set(["prefer", "x-script-fingerprint", "x-attachment-delivery", "x-attachment-name"]);
|
|
2830
|
+
function buildBusinessHeaders(operation, supplied = {}, filename) {
|
|
2831
|
+
const rules = operation.businessHeaders ?? {};
|
|
2832
|
+
const result = {};
|
|
2833
|
+
for (const [name2, rule] of Object.entries(rules)) {
|
|
2834
|
+
if (!BUSINESS_HEADERS.has(name2)) throw usageError(`\u64CD\u4F5C ${operation.id} \u7684\u4E1A\u52A1\u5934\u914D\u7F6E\u65E0\u6548`);
|
|
2835
|
+
if (rule.default !== void 0) result[name2] = rule.default;
|
|
2836
|
+
if (rule.fromFilename && filename) {
|
|
2837
|
+
try {
|
|
2838
|
+
result[name2] = encodeURIComponent(filename);
|
|
2839
|
+
} catch {
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2844
|
+
for (const [raw, value] of Object.entries(supplied)) {
|
|
2845
|
+
const name2 = raw.toLowerCase();
|
|
2846
|
+
if (!BUSINESS_HEADERS.has(name2) || !Object.hasOwn(rules, name2)) throw usageError(`\u64CD\u4F5C ${operation.id} \u4E0D\u63A5\u53D7\u8BF7\u6C42\u5934 ${raw}`);
|
|
2847
|
+
if (seen.has(name2)) throw usageError(`\u8BF7\u6C42\u5934 ${raw} \u91CD\u590D`);
|
|
2848
|
+
seen.add(name2);
|
|
2849
|
+
if (typeof value !== "string" || !value.trim() || value.length > 4096 || /[^\x20-\x7e]/u.test(value)) throw usageError(`\u8BF7\u6C42\u5934 ${raw} \u5FC5\u987B\u662F\u6709\u6548\u7684 ASCII \u5B57\u7B26\u4E32\uFF1B\u6587\u4EF6\u540D\u8BF7\u5148 URL \u7F16\u7801`);
|
|
2850
|
+
result[name2] = value;
|
|
2851
|
+
}
|
|
2852
|
+
for (const [name2, rule] of Object.entries(rules)) {
|
|
2853
|
+
const value = result[name2];
|
|
2854
|
+
if (rule.required && !value) throw usageError(`\u64CD\u4F5C ${operation.id} \u9700\u8981\u901A\u8FC7 --headers \u63D0\u4F9B ${name2}`);
|
|
2855
|
+
if (value && rule.values && !rule.values.includes(value)) throw usageError(`\u8BF7\u6C42\u5934 ${name2} \u53EA\u652F\u6301 ${rule.values.join("\u3001")}`);
|
|
2856
|
+
}
|
|
2857
|
+
return result;
|
|
2858
|
+
}
|
|
2859
|
+
var MIB = 1024 * 1024;
|
|
2860
|
+
var IMAGE = ["image/png", "image/jpeg", "image/webp"];
|
|
2861
|
+
var DOCUMENT = ["application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "text/plain", "text/markdown"];
|
|
2862
|
+
var VIDEO = ["video/mp4", "video/quicktime", "video/webm"];
|
|
2863
|
+
var CHAT_AUDIO = ["audio/mpeg", "audio/wav"];
|
|
2864
|
+
var SPEECH = ["audio/wav", "audio/mpeg", "audio/mp4", "audio/webm", "audio/ogg"];
|
|
2865
|
+
var MIME_BY_EXTENSION = {
|
|
2866
|
+
".png": "image/png",
|
|
2867
|
+
".jpg": "image/jpeg",
|
|
2868
|
+
".jpeg": "image/jpeg",
|
|
2869
|
+
".webp": "image/webp",
|
|
2870
|
+
".mp4": "video/mp4",
|
|
2871
|
+
".m4v": "video/mp4",
|
|
2872
|
+
".mov": "video/quicktime",
|
|
2873
|
+
".webm": "video/webm",
|
|
2874
|
+
".mp3": "audio/mpeg",
|
|
2875
|
+
".wav": "audio/wav",
|
|
2876
|
+
".m4a": "audio/mp4",
|
|
2877
|
+
".ogg": "audio/ogg",
|
|
2878
|
+
".oga": "audio/ogg",
|
|
2879
|
+
".aac": "audio/aac",
|
|
2880
|
+
".flac": "audio/flac",
|
|
2881
|
+
".opus": "audio/ogg",
|
|
2882
|
+
".pdf": "application/pdf",
|
|
2883
|
+
".docx": DOCUMENT[1],
|
|
2884
|
+
".txt": "text/plain",
|
|
2885
|
+
".md": "text/markdown",
|
|
2886
|
+
".markdown": "text/markdown"
|
|
2887
|
+
};
|
|
2888
|
+
function webUploadPolicy(operation, filename) {
|
|
2889
|
+
const extension = extname(filename).toLowerCase();
|
|
2890
|
+
const policy = operation.uploadPolicy;
|
|
2891
|
+
const audioRecording = policy === "storySpeech" || policy === "speechTranscription";
|
|
2892
|
+
const mime = audioRecording && extension === ".webm" ? "audio/webm" : policy === "speechTranscription" && extension === ".mp4" ? "audio/mp4" : MIME_BY_EXTENSION[extension];
|
|
2893
|
+
const unsupported = () => usageError(`\u64CD\u4F5C ${operation.id} \u4E0D\u652F\u6301\u6B64\u6587\u4EF6\u7C7B\u578B\uFF1A${extension || "\u65E0\u6269\u5C55\u540D"}`);
|
|
2894
|
+
if (!mime || !policy) throw unsupported();
|
|
2895
|
+
if (policy === "speechTranscription") {
|
|
2896
|
+
if (!SPEECH.includes(mime) && !["audio/aac", "audio/flac"].includes(mime)) throw unsupported();
|
|
2897
|
+
return { mime, maxBytes: 2 * MIB };
|
|
2898
|
+
}
|
|
2899
|
+
if (policy === "storySpeech") {
|
|
2900
|
+
if (!SPEECH.includes(mime)) throw unsupported();
|
|
2901
|
+
return { mime, maxBytes: 20 * MIB };
|
|
2902
|
+
}
|
|
2903
|
+
if (policy === "voiceSource") {
|
|
2904
|
+
if (!mime.startsWith("audio/") && !VIDEO.includes(mime)) throw unsupported();
|
|
2905
|
+
return { mime, maxBytes: 64 * MIB };
|
|
2906
|
+
}
|
|
2907
|
+
if (policy === "mask") {
|
|
2908
|
+
if (mime !== "image/png") throw unsupported();
|
|
2909
|
+
return { mime, maxBytes: 4 * MIB };
|
|
2910
|
+
}
|
|
2911
|
+
if (IMAGE.includes(mime)) return { mime, maxBytes: 15 * MIB };
|
|
2912
|
+
if (policy === "image") throw unsupported();
|
|
2913
|
+
if (DOCUMENT.includes(mime)) return { mime, maxBytes: 30 * MIB };
|
|
2914
|
+
if (policy === "chatAttachment" && (VIDEO.includes(mime) || CHAT_AUDIO.includes(mime))) return { mime, maxBytes: 90 * MIB };
|
|
2915
|
+
throw unsupported();
|
|
2916
|
+
}
|
|
2917
|
+
|
|
2918
|
+
// src/web-client.ts
|
|
2919
|
+
import { createHash as createHash3, randomBytes as randomBytes2 } from "node:crypto";
|
|
2920
|
+
import { constants as constants2 } from "node:fs";
|
|
2921
|
+
import { link, lstat as lstat2, open as open2, stat as stat2, unlink as unlink2 } from "node:fs/promises";
|
|
2922
|
+
import { basename as basename2, dirname as dirname2, extname as extname2, join as join3, resolve as resolve2 } from "node:path";
|
|
2923
|
+
var MAX_JSON_BYTES = 16 * 1024 * 1024;
|
|
2924
|
+
var MAX_DOWNLOAD_BYTES2 = 1024 * 1024 * 1024;
|
|
2925
|
+
var secretFields = /* @__PURE__ */ new Set(["token", "sessiontoken", "accesstoken", "refreshtoken", "password", "currentpassword", "newpassword", "secret", "clientsecret", "authorization", "cookie", "privatekey", "rawkey"]);
|
|
2926
|
+
function redactWebValue(value, secrets = []) {
|
|
2927
|
+
if (typeof value === "string") return secrets.reduce((text, secret) => secret ? text.split(secret).join("[redacted]") : text, redactKeys(value));
|
|
2928
|
+
if (typeof value === "number" && secrets.includes(String(value))) return "[redacted]";
|
|
2929
|
+
if (Array.isArray(value)) return value.map((item) => redactWebValue(item, secrets));
|
|
2930
|
+
if (!value || typeof value !== "object") return value;
|
|
2931
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [
|
|
2932
|
+
key,
|
|
2933
|
+
secretFields.has(key.toLowerCase().replace(/[_-]/gu, "")) || key === "apiKey" && typeof item === "string" ? "[redacted]" : redactWebValue(item, secrets)
|
|
2934
|
+
]));
|
|
2935
|
+
}
|
|
2936
|
+
function webSecrets(value) {
|
|
2937
|
+
if (!value || typeof value !== "object") return [];
|
|
2938
|
+
return Object.entries(value).flatMap(([key, item]) => secretFields.has(key.toLowerCase().replace(/[_-]/gu, "")) || key === "apiKey" ? typeof item === "string" ? [item] : webSecrets(item) : webSecrets(item));
|
|
2939
|
+
}
|
|
2940
|
+
function badResponse(status4) {
|
|
2941
|
+
return new CliError({ code: "CLI_BAD_RESPONSE", exitCode: EXIT.SERVER, message: "\u7F51\u9875\u63A5\u53E3\u54CD\u5E94\u683C\u5F0F\u65E0\u6548\uFF0C\u672A\u4FDD\u5B58\u4E3A\u4EA4\u4ED8\u6587\u4EF6", httpStatus: status4 });
|
|
2942
|
+
}
|
|
2943
|
+
async function checkWebOutput(path) {
|
|
2944
|
+
const target = resolve2(path);
|
|
2945
|
+
try {
|
|
2946
|
+
const info = await lstat2(target);
|
|
2947
|
+
if (info) throw usageError("\u8F93\u51FA\u8DEF\u5F84\u5DF2\u7ECF\u5B58\u5728\uFF1B\u8BF7\u9009\u62E9\u65B0\u6587\u4EF6\uFF0C\u672C\u6B21\u4E0D\u4F1A\u8986\u76D6\u539F\u6587\u4EF6");
|
|
2948
|
+
} catch (error) {
|
|
2949
|
+
if (error?.code !== "ENOENT") throw error;
|
|
2950
|
+
}
|
|
2951
|
+
try {
|
|
2952
|
+
if (!(await stat2(dirname2(target))).isDirectory()) throw new Error();
|
|
2953
|
+
} catch {
|
|
2954
|
+
throw usageError("\u8F93\u51FA\u76EE\u5F55\u4E0D\u5B58\u5728\u6216\u4E0D\u53EF\u8BBF\u95EE\uFF0C\u8BF7\u5148\u521B\u5EFA\u76EE\u5F55");
|
|
2955
|
+
}
|
|
2956
|
+
return target;
|
|
2957
|
+
}
|
|
2958
|
+
async function atomicWebOutput(path, signal, feed) {
|
|
2959
|
+
const target = await checkWebOutput(path);
|
|
2960
|
+
const temp = join3(dirname2(target), `.${basename2(target)}.${process.pid}.${randomBytes2(8).toString("hex")}.tmp`);
|
|
2961
|
+
const handle = await open2(temp, constants2.O_CREAT | constants2.O_EXCL | constants2.O_WRONLY | (constants2.O_NOFOLLOW ?? 0), 384);
|
|
2962
|
+
let bytes = 0;
|
|
2963
|
+
const hash = createHash3("sha256");
|
|
2964
|
+
try {
|
|
2965
|
+
await feed(async (chunk) => {
|
|
2966
|
+
if (signal.aborted) throw signal.reason;
|
|
2967
|
+
bytes += chunk.byteLength;
|
|
2968
|
+
if (bytes > MAX_DOWNLOAD_BYTES2) throw usageError("\u4E0B\u8F7D\u6587\u4EF6\u8D85\u8FC7 1 GiB \u4E0A\u9650");
|
|
2969
|
+
hash.update(chunk);
|
|
2970
|
+
await handle.writeFile(chunk);
|
|
2971
|
+
});
|
|
2972
|
+
await handle.sync();
|
|
2973
|
+
await handle.close();
|
|
2974
|
+
if (signal.aborted) throw signal.reason;
|
|
2975
|
+
await link(temp, target);
|
|
2976
|
+
return { path: target, bytes, sha256: hash.digest("hex") };
|
|
2977
|
+
} catch (error) {
|
|
2978
|
+
if (error instanceof CliError) throw error;
|
|
2979
|
+
throw new CliError({ code: "CLI_WEB_OUTPUT_FAILED", exitCode: EXIT.SERVER, message: "\u8F93\u51FA\u6587\u4EF6\u4FDD\u5B58\u5931\u8D25\uFF1B\u539F\u6587\u4EF6\u672A\u8986\u76D6\uFF0C\u8BF7\u68C0\u67E5\u76EE\u5F55\u6743\u9650\u4E0E\u78C1\u76D8\u7A7A\u95F4" });
|
|
2980
|
+
} finally {
|
|
2981
|
+
await handle.close().catch(() => void 0);
|
|
2982
|
+
await unlink2(temp).catch(() => void 0);
|
|
2983
|
+
}
|
|
2984
|
+
}
|
|
2985
|
+
async function saveWebDocument(path, data, signal) {
|
|
2986
|
+
return atomicWebOutput(path, signal ?? new AbortController().signal, (write) => write(Buffer.from(`${JSON.stringify(data, null, 2)}
|
|
2987
|
+
`)));
|
|
2988
|
+
}
|
|
2989
|
+
async function consume(response, signal, max, onChunk) {
|
|
2990
|
+
if (!response.body) return 0;
|
|
2991
|
+
const reader = response.body.getReader();
|
|
2992
|
+
let total = 0;
|
|
2993
|
+
const cancel3 = () => {
|
|
2994
|
+
void reader.cancel().catch(() => void 0);
|
|
2995
|
+
};
|
|
2996
|
+
signal.addEventListener("abort", cancel3, { once: true });
|
|
2997
|
+
try {
|
|
2998
|
+
for (; ; ) {
|
|
2999
|
+
if (signal.aborted) throw signal.reason;
|
|
3000
|
+
const { value, done } = await reader.read();
|
|
3001
|
+
if (signal.aborted) throw signal.reason;
|
|
3002
|
+
if (done) break;
|
|
3003
|
+
total += value.byteLength;
|
|
3004
|
+
if (total > max) throw badResponse(response.status);
|
|
3005
|
+
if (await onChunk(value) === false) break;
|
|
3006
|
+
}
|
|
3007
|
+
return total;
|
|
3008
|
+
} finally {
|
|
3009
|
+
signal.removeEventListener("abort", cancel3);
|
|
3010
|
+
void reader.cancel().catch(() => void 0);
|
|
3011
|
+
}
|
|
3012
|
+
}
|
|
3013
|
+
async function jsonBody(response, signal) {
|
|
3014
|
+
const chunks = [];
|
|
3015
|
+
await consume(response, signal, MAX_JSON_BYTES, (chunk) => {
|
|
3016
|
+
chunks.push(chunk);
|
|
3017
|
+
});
|
|
3018
|
+
if (chunks.length === 0 && response.status === 204) return null;
|
|
3019
|
+
try {
|
|
3020
|
+
return JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
3021
|
+
} catch {
|
|
3022
|
+
throw badResponse(response.status);
|
|
3023
|
+
}
|
|
3024
|
+
}
|
|
3025
|
+
function serverFailure(status4, body, secrets) {
|
|
3026
|
+
secrets = [...secrets, ...webSecrets(body)];
|
|
3027
|
+
const data = body && typeof body === "object" ? body : {};
|
|
3028
|
+
const nested = data.error && typeof data.error === "object" ? data.error : data;
|
|
3029
|
+
const message2 = typeof nested.message === "string" ? nested.message : typeof data.error === "string" ? data.error : `\u7F51\u9875\u8BF7\u6C42\u5931\u8D25\uFF08HTTP ${status4}\uFF09`;
|
|
3030
|
+
return new CliError({
|
|
3031
|
+
code: typeof nested.code === "string" ? String(redactWebValue(nested.code, secrets)) : "CLI_WEB_REQUEST_FAILED",
|
|
3032
|
+
exitCode: exitCodeForHttpStatus(status4),
|
|
3033
|
+
httpStatus: status4,
|
|
3034
|
+
message: String(redactWebValue(message2, secrets)),
|
|
3035
|
+
retryable: status4 === 408 || status4 === 429 || status4 >= 500,
|
|
3036
|
+
...typeof nested.traceId === "string" ? { traceId: String(redactWebValue(nested.traceId, secrets)) } : {},
|
|
3037
|
+
...typeof nested.retryAfterSeconds === "number" ? { retryAfterSeconds: nested.retryAfterSeconds } : {}
|
|
3038
|
+
});
|
|
3039
|
+
}
|
|
3040
|
+
function taskIdOf(value) {
|
|
3041
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
3042
|
+
const data = value;
|
|
3043
|
+
for (const key of ["taskId", "rootRunId", "runId", "projectId"]) if (typeof data[key] === "string" && data[key]) return data[key];
|
|
3044
|
+
for (const key of ["run", "task", "project", "data"]) {
|
|
3045
|
+
const nested = data[key];
|
|
3046
|
+
const found = taskIdOf(nested);
|
|
3047
|
+
if (found) return found;
|
|
3048
|
+
if (key !== "data" && nested && typeof nested === "object" && !Array.isArray(nested) && typeof nested.id === "string") return nested.id;
|
|
3049
|
+
}
|
|
3050
|
+
return void 0;
|
|
3051
|
+
}
|
|
3052
|
+
function mediaPrefixValid(mime, prefix) {
|
|
3053
|
+
const start = prefix.toString("utf8").replace(/^\uFEFF/u, "").trimStart();
|
|
3054
|
+
if (mime === "text/html" || /^<(?:!doctype\s+html|html|head|body)(?:\s|>)/iu.test(start)) return false;
|
|
3055
|
+
if (mime === "video/mp4" || mime === "audio/mp4") return prefix.length >= 12 && prefix.toString("ascii", 4, 8) === "ftyp";
|
|
3056
|
+
if (mime === "video/quicktime") return prefix.length >= 12 && ["ftyp", "wide", "free", "mdat", "moov"].includes(prefix.toString("ascii", 4, 8));
|
|
3057
|
+
if (mime === "image/png") return prefix.subarray(0, 8).toString("hex") === "89504e470d0a1a0a";
|
|
3058
|
+
if (mime === "image/jpeg") return prefix.subarray(0, 3).toString("hex") === "ffd8ff";
|
|
3059
|
+
if (mime === "image/webp") return prefix.toString("ascii", 0, 4) === "RIFF" && prefix.toString("ascii", 8, 12) === "WEBP";
|
|
3060
|
+
if (mime === "image/gif") return /^GIF8[79]a/u.test(prefix.toString("ascii", 0, 6));
|
|
3061
|
+
if (mime === "application/pdf") return start.startsWith("%PDF-");
|
|
3062
|
+
if (["application/zip", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"].includes(mime)) return ["504b0304", "504b0506", "504b0708"].includes(prefix.subarray(0, 4).toString("hex"));
|
|
3063
|
+
if (["audio/wav", "audio/x-wav"].includes(mime)) return prefix.length >= 44 && prefix.toString("ascii", 0, 4) === "RIFF" && prefix.toString("ascii", 8, 12) === "WAVE";
|
|
3064
|
+
if (mime === "audio/mpeg") return prefix.length >= 3 && (prefix.toString("ascii", 0, 3) === "ID3" || prefix[0] === 255 && (prefix[1] & 224) === 224);
|
|
3065
|
+
if (mime === "audio/ogg") return prefix.toString("ascii", 0, 4) === "OggS";
|
|
3066
|
+
if (mime === "audio/flac") return prefix.toString("ascii", 0, 4) === "fLaC";
|
|
3067
|
+
if (mime === "video/webm" || mime === "audio/webm") return prefix.subarray(0, 4).toString("hex") === "1a45dfa3" && prefix.includes(Buffer.from("webm"));
|
|
3068
|
+
if (mime === "text/vtt") return !prefix.includes(0) && /^\uFEFF?WEBVTT(?:[ \t][^\r\n]*)?(?:\r?\n|$)/u.test(prefix.toString("utf8"));
|
|
3069
|
+
if (mime === "application/x-subrip") {
|
|
3070
|
+
if (prefix.includes(0)) return false;
|
|
3071
|
+
const cue = /^\uFEFF?\s*\d+\r?\n(\d{2,}):([0-5]\d):([0-5]\d),(\d{3})[ \t]+-->[ \t]+(\d{2,}):([0-5]\d):([0-5]\d),(\d{3})(?:[ \t][^\r\n]*)?\r?\n/u.exec(prefix.toString("utf8"));
|
|
3072
|
+
if (!cue) return false;
|
|
3073
|
+
const start2 = ((Number(cue[1]) * 60 + Number(cue[2])) * 60 + Number(cue[3])) * 1e3 + Number(cue[4]);
|
|
3074
|
+
const end = ((Number(cue[5]) * 60 + Number(cue[6])) * 60 + Number(cue[7])) * 1e3 + Number(cue[8]);
|
|
3075
|
+
return Number.isSafeInteger(start2) && Number.isSafeInteger(end) && end > start2;
|
|
3076
|
+
}
|
|
3077
|
+
if (["text/plain", "text/markdown", "text/csv"].includes(mime)) return !prefix.includes(0);
|
|
3078
|
+
return true;
|
|
3079
|
+
}
|
|
3080
|
+
async function requestWeb(io, request) {
|
|
3081
|
+
const baseUrl = normalizeBaseUrl(request.baseUrl);
|
|
3082
|
+
assertReachedDirectly(baseUrl, io.env);
|
|
3083
|
+
if (!request.path.startsWith("/api/") || request.path.includes("#") || request.path.includes("\\") || new URL(request.path, baseUrl).origin !== baseUrl || new URL(request.path, baseUrl).pathname !== request.path.split("?")[0]) throw usageError("\u7F51\u9875\u64CD\u4F5C\u8DEF\u5F84\u65E0\u6548");
|
|
3084
|
+
if (request.token?.startsWith("bk_")) throw usageError("API \u5BC6\u94A5\u4E0D\u80FD\u7528\u4E8E\u7F51\u9875\u63A5\u53E3");
|
|
3085
|
+
if (io.signal?.aborted) throw interruptedError();
|
|
3086
|
+
const controller = new AbortController();
|
|
3087
|
+
const secrets = [...request.secrets ?? [], ...request.token ? [request.token] : []];
|
|
3088
|
+
const headers = new Headers({ Accept: "application/json, text/event-stream, */*", "User-Agent": "bukesiyi-cli/web" });
|
|
3089
|
+
if (request.token) headers.set("Authorization", `Bearer ${request.token}`);
|
|
3090
|
+
if (request.workspaceId) headers.set("x-bukesiyi-workspace-id", request.workspaceId);
|
|
3091
|
+
if (request.contentType) headers.set("Content-Type", request.contentType);
|
|
3092
|
+
if (request.idempotencyKey) headers.set("Idempotency-Key", request.idempotencyKey);
|
|
3093
|
+
for (const [name2, value] of Object.entries(request.businessHeaders ?? {})) {
|
|
3094
|
+
if (!["prefer", "x-script-fingerprint", "x-attachment-delivery", "x-attachment-name"].includes(name2.toLowerCase()) || typeof value !== "string" || !value || /[^\x20-\x7e]/u.test(value) || value.length > 4096) throw usageError("\u7F51\u9875\u4E1A\u52A1\u8BF7\u6C42\u5934\u4E0D\u5728\u5141\u8BB8\u8303\u56F4\uFF0C\u64CD\u4F5C\u672A\u63D0\u4EA4");
|
|
3095
|
+
headers.set(name2, value);
|
|
3096
|
+
}
|
|
3097
|
+
const timeoutMs = request.timeoutMs ?? io.requestTimeoutMs ?? 12e4;
|
|
3098
|
+
let timer;
|
|
3099
|
+
let responseReceived = false;
|
|
3100
|
+
let interrupt2 = () => void 0;
|
|
3101
|
+
const stopped = new Promise((_resolve, reject) => {
|
|
3102
|
+
interrupt2 = () => {
|
|
3103
|
+
const error = interruptedError();
|
|
3104
|
+
controller.abort(error);
|
|
3105
|
+
reject(error);
|
|
3106
|
+
};
|
|
3107
|
+
io.signal?.addEventListener("abort", interrupt2, { once: true });
|
|
3108
|
+
timer = setTimeout(() => {
|
|
3109
|
+
const error = new CliError({ code: "CLI_TIMEOUT", exitCode: EXIT.SERVER, retryable: true, message: `\u7F51\u9875\u8BF7\u6C42\u7B49\u5F85\u8D85\u65F6\uFF08${timeoutMs / 1e3} \u79D2\uFF09\uFF1B\u8BF7\u67E5\u8BE2\u539F\u64CD\u4F5C\u7ED3\u679C` });
|
|
3110
|
+
controller.abort(error);
|
|
3111
|
+
reject(error);
|
|
3112
|
+
}, timeoutMs);
|
|
3113
|
+
});
|
|
3114
|
+
const work = (async () => {
|
|
3115
|
+
const response = await io.fetch(`${baseUrl}${request.path}`, {
|
|
3116
|
+
method: request.method,
|
|
3117
|
+
headers,
|
|
3118
|
+
...request.body === void 0 ? {} : { body: request.body },
|
|
3119
|
+
redirect: "manual",
|
|
3120
|
+
signal: controller.signal
|
|
3121
|
+
});
|
|
3122
|
+
responseReceived = true;
|
|
3123
|
+
if (response.status >= 300 && response.status < 400) {
|
|
3124
|
+
await response.body?.cancel().catch(() => void 0);
|
|
3125
|
+
throw new CliError({ code: "CLI_REDIRECT_BLOCKED", exitCode: EXIT.SERVER, httpStatus: response.status, message: "\u7F51\u9875\u63A5\u53E3\u8FD4\u56DE\u91CD\u5B9A\u5411\uFF0C\u672A\u5411\u8DF3\u8F6C\u5730\u5740\u53D1\u9001\u4F1A\u8BDD\u51ED\u636E" });
|
|
3126
|
+
}
|
|
3127
|
+
if (response.status >= 400) {
|
|
3128
|
+
let body;
|
|
3129
|
+
try {
|
|
3130
|
+
body = await jsonBody(response, controller.signal);
|
|
3131
|
+
} catch (error) {
|
|
3132
|
+
if (controller.signal.aborted) throw error;
|
|
3133
|
+
}
|
|
3134
|
+
throw serverFailure(response.status, body, secrets);
|
|
3135
|
+
}
|
|
3136
|
+
const mime = response.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase() ?? "";
|
|
3137
|
+
const sessionResponse = request.method === "POST" && (request.path === "/api/auth/login" || request.sessionResponse === true);
|
|
3138
|
+
if (sessionResponse && (!mime.includes("json") || ![200, 201].includes(response.status))) {
|
|
3139
|
+
await response.body?.cancel().catch(() => void 0);
|
|
3140
|
+
throw badResponse(response.status);
|
|
3141
|
+
}
|
|
3142
|
+
if (mime === "text/event-stream") {
|
|
3143
|
+
if (request.expectedFile) {
|
|
3144
|
+
await response.body?.cancel().catch(() => void 0);
|
|
3145
|
+
throw badResponse(response.status);
|
|
3146
|
+
}
|
|
3147
|
+
const decoder = new TextDecoder();
|
|
3148
|
+
let buffer = "", eventCount = 0, completed = false;
|
|
3149
|
+
const events = [];
|
|
3150
|
+
const emit = (block) => {
|
|
3151
|
+
const lines2 = block.split("\n");
|
|
3152
|
+
const data = lines2.filter((line) => line.startsWith("data:")).map((line) => line.slice(5).replace(/^ /u, "")).join("\n");
|
|
3153
|
+
if (data === "[DONE]") {
|
|
3154
|
+
completed = true;
|
|
3155
|
+
return;
|
|
3156
|
+
}
|
|
3157
|
+
if (!data) return;
|
|
3158
|
+
let value;
|
|
3159
|
+
try {
|
|
3160
|
+
value = JSON.parse(data);
|
|
3161
|
+
} catch {
|
|
3162
|
+
value = { text: data };
|
|
3163
|
+
}
|
|
3164
|
+
secrets.push(...webSecrets(value));
|
|
3165
|
+
const taskId = taskIdOf(value);
|
|
3166
|
+
if (taskId) request.onTaskId?.(String(redactWebValue(taskId, secrets)));
|
|
3167
|
+
const safe2 = redactWebValue(value, secrets);
|
|
3168
|
+
const eventName = lines2.find((line) => line.startsWith("event:"))?.slice(6).trim();
|
|
3169
|
+
const payload = value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
3170
|
+
if (eventName === "error" || payload.type === "error") {
|
|
3171
|
+
const status4 = [payload.httpStatus, payload.status].find((item) => typeof item === "number" && Number.isInteger(item) && item >= 400 && item <= 599);
|
|
3172
|
+
throw serverFailure(typeof status4 === "number" ? status4 : 500, value, secrets);
|
|
3173
|
+
}
|
|
3174
|
+
events.push(eventName ? { event: eventName, data: safe2 } : safe2);
|
|
3175
|
+
if (events.length > 100) events.shift();
|
|
3176
|
+
eventCount++;
|
|
3177
|
+
request.onEvent?.(events.at(-1));
|
|
3178
|
+
if (eventName === "done" || payload.type === "done") completed = true;
|
|
3179
|
+
};
|
|
3180
|
+
await consume(response, controller.signal, MAX_JSON_BYTES, (chunk) => {
|
|
3181
|
+
buffer = (buffer + decoder.decode(chunk, { stream: true })).replace(/\r\n/gu, "\n");
|
|
3182
|
+
if (buffer.length > 1024 * 1024) throw badResponse(response.status);
|
|
3183
|
+
let boundary;
|
|
3184
|
+
while (!completed && (boundary = buffer.indexOf("\n\n")) >= 0) {
|
|
3185
|
+
emit(buffer.slice(0, boundary));
|
|
3186
|
+
buffer = buffer.slice(boundary + 2);
|
|
3187
|
+
}
|
|
3188
|
+
if (completed) return false;
|
|
3189
|
+
});
|
|
3190
|
+
buffer += decoder.decode();
|
|
3191
|
+
if (!completed && buffer.trim()) emit(buffer);
|
|
3192
|
+
if (!completed) throw new CliError({
|
|
3193
|
+
code: "CLI_STREAM_INCOMPLETE",
|
|
3194
|
+
exitCode: EXIT.SERVER,
|
|
3195
|
+
retryable: true,
|
|
3196
|
+
message: "\u7F51\u9875\u4E8B\u4EF6\u6D41\u5728\u5B8C\u6210\u6807\u8BB0\u524D\u7ED3\u675F\uFF1B\u64CD\u4F5C\u7ED3\u679C\u5C1A\u672A\u786E\u8BA4\uFF0C\u8BF7\u4F7F\u7528\u539F\u5E42\u7B49\u952E\u67E5\u8BE2\u539F\u64CD\u4F5C"
|
|
3197
|
+
});
|
|
3198
|
+
const result = { status: response.status, events, eventCount };
|
|
3199
|
+
if (request.outPath) return { ...result, download: await atomicWebOutput(request.outPath, controller.signal, (write) => write(Buffer.from(`${JSON.stringify(result, null, 2)}
|
|
3200
|
+
`))) };
|
|
3201
|
+
return result;
|
|
3202
|
+
}
|
|
3203
|
+
if (mime.includes("json") || response.status === 204) {
|
|
3204
|
+
const data = await jsonBody(response, controller.signal);
|
|
3205
|
+
secrets.push(...webSecrets(data));
|
|
3206
|
+
if (sessionResponse) {
|
|
3207
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) throw badResponse(response.status);
|
|
3208
|
+
const token = data.token;
|
|
3209
|
+
if (typeof token === "string") secrets.push(token);
|
|
3210
|
+
request.onLogin?.(data);
|
|
3211
|
+
}
|
|
3212
|
+
const taskId = taskIdOf(data);
|
|
3213
|
+
if (taskId) request.onTaskId?.(String(redactWebValue(taskId, secrets)));
|
|
3214
|
+
const safe2 = request.secretOutput ? { saved: true } : redactWebValue(data, secrets);
|
|
3215
|
+
if (data && typeof data === "object" && data.error && data.ok === false) throw serverFailure(400, data, secrets);
|
|
3216
|
+
if (request.outPath) {
|
|
3217
|
+
if (response.status !== 200 && response.status !== 201) throw new CliError({ code: "CLI_DOWNLOAD_NOT_READY", exitCode: EXIT.RETRY_LATER, httpStatus: response.status, message: "\u64CD\u4F5C\u5C1A\u672A\u5B8C\u6210\uFF0C\u672A\u628A\u51C6\u5907\u54CD\u5E94\u4FDD\u5B58\u4E3A\u6587\u4EF6" });
|
|
3218
|
+
if (request.expectedFile) throw badResponse(response.status);
|
|
3219
|
+
const download5 = await atomicWebOutput(request.outPath, controller.signal, (write) => write(Buffer.from(`${JSON.stringify(request.secretOutput ? data : safe2, null, 2)}
|
|
3220
|
+
`)));
|
|
3221
|
+
return { status: response.status, data: safe2, download: download5 };
|
|
3222
|
+
}
|
|
3223
|
+
return { status: response.status, data: safe2 };
|
|
3224
|
+
}
|
|
3225
|
+
if (!request.outPath) {
|
|
3226
|
+
await response.body?.cancel().catch(() => void 0);
|
|
3227
|
+
throw usageError("\u8BE5\u64CD\u4F5C\u8FD4\u56DE\u6587\u4EF6\uFF0C\u8BF7\u4F7F\u7528 --out <\u65B0\u6587\u4EF6\u8DEF\u5F84>");
|
|
3228
|
+
}
|
|
3229
|
+
if (response.status !== 200) {
|
|
3230
|
+
await response.body?.cancel().catch(() => void 0);
|
|
3231
|
+
throw new CliError({ code: "CLI_DOWNLOAD_NOT_READY", exitCode: EXIT.RETRY_LATER, httpStatus: response.status, message: "\u4E0B\u8F7D\u5C1A\u672A\u5B8C\u6210\uFF0C\u672A\u4FDD\u5B58\u6587\u4EF6" });
|
|
3232
|
+
}
|
|
3233
|
+
const expectedSize = response.headers.get("content-length"), expectedHash = response.headers.get("x-content-sha256");
|
|
3234
|
+
const byExtension = { ".mp4": "video/mp4", ".mov": "video/quicktime", ".webm": "video/webm", ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp", ".zip": "application/zip", ".pdf": "application/pdf", ".wav": "audio/wav", ".mp3": "audio/mpeg", ".vtt": "text/vtt", ".srt": "application/x-subrip" };
|
|
3235
|
+
const expectedMime = byExtension[extname2(request.outPath).toLowerCase()];
|
|
3236
|
+
if (expectedMime && mime && mime !== "application/octet-stream" && mime !== expectedMime && !(expectedMime === "audio/wav" && mime === "audio/x-wav")) {
|
|
3237
|
+
await response.body?.cancel().catch(() => void 0);
|
|
3238
|
+
throw badResponse(response.status);
|
|
3239
|
+
}
|
|
3240
|
+
const validationMime = !mime || mime === "application/octet-stream" ? expectedMime ?? mime : mime;
|
|
3241
|
+
const download4 = await atomicWebOutput(request.outPath, controller.signal, async (write) => {
|
|
3242
|
+
let prefix = Buffer.alloc(0);
|
|
3243
|
+
const hash = createHash3("sha256");
|
|
3244
|
+
const size = await consume(response, controller.signal, MAX_DOWNLOAD_BYTES2, async (chunk) => {
|
|
3245
|
+
if (prefix.length < 1024) prefix = Buffer.concat([prefix, Buffer.from(chunk).subarray(0, 1024 - prefix.length)]);
|
|
3246
|
+
hash.update(chunk);
|
|
3247
|
+
await write(chunk);
|
|
3248
|
+
});
|
|
3249
|
+
if (size === 0 || !mediaPrefixValid(validationMime, prefix) || expectedSize !== null && (!/^\d+$/u.test(expectedSize) || Number(expectedSize) !== size) || expectedHash !== null && (!/^[a-f0-9]{64}$/iu.test(expectedHash) || hash.digest("hex") !== expectedHash.toLowerCase())) throw badResponse(response.status);
|
|
3250
|
+
});
|
|
3251
|
+
return { status: response.status, download: download4 };
|
|
3252
|
+
})();
|
|
3253
|
+
work.catch(() => void 0);
|
|
3254
|
+
try {
|
|
3255
|
+
return await Promise.race([work, stopped]);
|
|
3256
|
+
} catch (error) {
|
|
3257
|
+
if (controller.signal.aborted && responseReceived) {
|
|
3258
|
+
let cleanupTimer;
|
|
3259
|
+
await Promise.race([work.catch(() => void 0), new Promise((resolve3) => {
|
|
3260
|
+
cleanupTimer = setTimeout(resolve3, 1e3);
|
|
3261
|
+
})]);
|
|
3262
|
+
clearTimeout(cleanupTimer);
|
|
3263
|
+
}
|
|
3264
|
+
if (error instanceof CliError) throw error;
|
|
3265
|
+
if (io.signal?.aborted) throw interruptedError();
|
|
3266
|
+
throw new CliError({ code: "CLI_NETWORK", exitCode: EXIT.SERVER, retryable: true, message: "\u7F51\u9875\u8BF7\u6C42\u8FDE\u63A5\u5931\u8D25\uFF0C\u8BF7\u67E5\u8BE2\u539F\u64CD\u4F5C\u7ED3\u679C\u540E\u518D\u51B3\u5B9A\u662F\u5426\u91CD\u8BD5" });
|
|
3267
|
+
} finally {
|
|
3268
|
+
clearTimeout(timer);
|
|
3269
|
+
io.signal?.removeEventListener("abort", interrupt2);
|
|
3270
|
+
}
|
|
3271
|
+
}
|
|
3272
|
+
|
|
3273
|
+
// src/web-session.ts
|
|
3274
|
+
import { createHash as createHash4, createHmac, randomBytes as randomBytes3 } from "node:crypto";
|
|
3275
|
+
import { constants as constants3 } from "node:fs";
|
|
3276
|
+
import { chmod as chmod2, lstat as lstat3, mkdir as mkdir3, open as open3, readdir as readdir2, rename as rename2, unlink as unlink3 } from "node:fs/promises";
|
|
3277
|
+
import { dirname as dirname3, join as join4, parse } from "node:path";
|
|
3278
|
+
import { StringDecoder } from "node:string_decoder";
|
|
3279
|
+
var noFollow = constants3.O_NOFOLLOW ?? 0;
|
|
3280
|
+
var nonBlock = constants3.O_NONBLOCK ?? 0;
|
|
3281
|
+
var stateNames = /* @__PURE__ */ new Set(["session.json", "last-web-request.json"]);
|
|
3282
|
+
var missing = (error) => error?.code === "ENOENT";
|
|
3283
|
+
function stateError(message2) {
|
|
3284
|
+
return new CliError({ code: "CLI_WEB_SESSION", exitCode: EXIT.SERVER, message: message2 });
|
|
3285
|
+
}
|
|
3286
|
+
function validateSessionToken(value) {
|
|
3287
|
+
if (typeof value !== "string" || value.startsWith("bk_") || !/^[A-Za-z0-9._~-]{20,512}$/u.test(value)) {
|
|
3288
|
+
throw usageError("\u7F51\u9875\u4F1A\u8BDD\u65E0\u6548\uFF1B\u8BF7\u8FD0\u884C buke web login\uFF0CAPI \u5BC6\u94A5\u4E0D\u80FD\u4F5C\u4E3A\u7F51\u9875\u767B\u5F55\u51ED\u636E");
|
|
3289
|
+
}
|
|
3290
|
+
return value;
|
|
3291
|
+
}
|
|
3292
|
+
function webStatePath(io, name2 = "session.json") {
|
|
3293
|
+
if (!stateNames.has(name2) && !/^web-(?:request|fingerprint)-[a-f0-9]{64}\.json$/u.test(name2) && !/^web-lock-[a-f0-9]{64}-\d+-[a-f0-9]{32}\.json$/u.test(name2)) throw stateError("\u4E0D\u652F\u6301\u7684\u7F51\u9875\u72B6\u6001\u6587\u4EF6");
|
|
3294
|
+
return join4(credentialsDir(io), name2);
|
|
3295
|
+
}
|
|
3296
|
+
async function guardAncestors(path) {
|
|
3297
|
+
let current = path;
|
|
3298
|
+
for (; ; ) {
|
|
3299
|
+
try {
|
|
3300
|
+
const info = await lstat3(current);
|
|
3301
|
+
if (info.isSymbolicLink() || !info.isDirectory()) throw stateError("\u7F51\u9875\u51ED\u636E\u76EE\u5F55\u4E0D\u80FD\u7ECF\u8FC7\u7B26\u53F7\u94FE\u63A5\u6216\u975E\u76EE\u5F55\u6587\u4EF6");
|
|
3302
|
+
} catch (error) {
|
|
3303
|
+
if (!missing(error)) throw error;
|
|
3304
|
+
}
|
|
3305
|
+
if (current === parse(current).root) break;
|
|
3306
|
+
current = dirname3(current);
|
|
3307
|
+
}
|
|
3308
|
+
}
|
|
3309
|
+
async function guardStateFile(path, io, transientTicket = false) {
|
|
3310
|
+
try {
|
|
3311
|
+
const info = await lstat3(path);
|
|
3312
|
+
if (transientTicket && info.isFile() && info.nlink === 0) return await guardStateFile(path, io, true);
|
|
3313
|
+
if (info.isSymbolicLink() || !info.isFile() || info.nlink !== 1) throw stateError("\u7F51\u9875\u72B6\u6001\u6587\u4EF6\u5FC5\u987B\u662F\u666E\u901A\u6587\u4EF6\uFF0C\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5\u6216\u786C\u94FE\u63A5");
|
|
3314
|
+
if (io.platform !== "win32" && (info.mode & 63) !== 0) throw stateError("\u7F51\u9875\u72B6\u6001\u6587\u4EF6\u6743\u9650\u8FC7\u5BBD\uFF0C\u8BF7\u5148\u8BBE\u7F6E\u4E3A 0600");
|
|
3315
|
+
} catch (error) {
|
|
3316
|
+
if (!missing(error)) throw error;
|
|
3317
|
+
}
|
|
3318
|
+
}
|
|
3319
|
+
async function readWebState(io, name2) {
|
|
3320
|
+
const path = webStatePath(io, name2);
|
|
3321
|
+
try {
|
|
3322
|
+
await guardAncestors(dirname3(path));
|
|
3323
|
+
await guardStateFile(path, io, name2.startsWith("web-lock-"));
|
|
3324
|
+
const handle = await open3(path, constants3.O_RDONLY | noFollow | nonBlock);
|
|
3325
|
+
try {
|
|
3326
|
+
const info = await handle.stat();
|
|
3327
|
+
if (info.nlink === 0 && name2.startsWith("web-lock-")) return await readWebState(io, name2);
|
|
3328
|
+
if (!info.isFile() || info.nlink !== 1 || info.size > 64 * 1024 || io.platform !== "win32" && (info.mode & 63) !== 0) throw stateError("\u7F51\u9875\u72B6\u6001\u6587\u4EF6\u65E0\u6548");
|
|
3329
|
+
const value = JSON.parse(await handle.readFile("utf8"));
|
|
3330
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw stateError("\u7F51\u9875\u72B6\u6001\u6587\u4EF6\u683C\u5F0F\u65E0\u6548");
|
|
3331
|
+
return value;
|
|
3332
|
+
} finally {
|
|
3333
|
+
await handle.close();
|
|
3334
|
+
}
|
|
3335
|
+
} catch (error) {
|
|
3336
|
+
if (missing(error)) return null;
|
|
3337
|
+
if (error instanceof CliError) throw error;
|
|
3338
|
+
throw stateError("\u65E0\u6CD5\u8BFB\u53D6\u7F51\u9875\u72B6\u6001\u6587\u4EF6\uFF0C\u8BF7\u68C0\u67E5\u76EE\u5F55\u4E0E\u6587\u4EF6\u6743\u9650");
|
|
3339
|
+
}
|
|
3340
|
+
}
|
|
3341
|
+
async function writeWebState(io, name2, value) {
|
|
3342
|
+
const path = webStatePath(io, name2), dir = dirname3(path);
|
|
3343
|
+
const temp = join4(dir, `.${name2}.${process.pid}.${randomBytes3(8).toString("hex")}.tmp`);
|
|
3344
|
+
let created = false;
|
|
3345
|
+
try {
|
|
3346
|
+
await guardAncestors(dir);
|
|
3347
|
+
await mkdir3(dir, { recursive: true, mode: 448 });
|
|
3348
|
+
await guardAncestors(dir);
|
|
3349
|
+
if (io.platform !== "win32" && ((await lstat3(dir)).mode & 63) !== 0) throw stateError("\u7F51\u9875\u51ED\u636E\u76EE\u5F55\u6743\u9650\u8FC7\u5BBD\uFF0C\u8BF7\u5148\u8BBE\u7F6E\u4E3A 0700");
|
|
3350
|
+
await guardStateFile(path, io);
|
|
3351
|
+
const handle = await open3(temp, constants3.O_CREAT | constants3.O_EXCL | constants3.O_WRONLY | noFollow, 384);
|
|
3352
|
+
created = true;
|
|
3353
|
+
try {
|
|
3354
|
+
await handle.writeFile(`${JSON.stringify(value, null, 2)}
|
|
3355
|
+
`);
|
|
3356
|
+
await handle.sync();
|
|
3357
|
+
} finally {
|
|
3358
|
+
await handle.close();
|
|
3359
|
+
}
|
|
3360
|
+
await guardStateFile(path, io);
|
|
3361
|
+
await rename2(temp, path);
|
|
3362
|
+
created = false;
|
|
3363
|
+
await chmod2(path, 384);
|
|
3364
|
+
return path;
|
|
3365
|
+
} catch (error) {
|
|
3366
|
+
if (created) await unlink3(temp).catch(() => void 0);
|
|
3367
|
+
if (error instanceof CliError) throw error;
|
|
3368
|
+
throw stateError("\u7F51\u9875\u72B6\u6001\u672A\u80FD\u4FDD\u5B58\uFF0C\u539F\u6587\u4EF6\u4FDD\u6301\u4E0D\u53D8\uFF1B\u8BF7\u68C0\u67E5\u76EE\u5F55\u6743\u9650\u4E0E\u78C1\u76D8\u7A7A\u95F4");
|
|
3369
|
+
}
|
|
3370
|
+
}
|
|
3371
|
+
async function deleteWebSession(io, expected) {
|
|
3372
|
+
const current = await readWebState(io, "session.json");
|
|
3373
|
+
if (current?.token !== expected.token || current?.baseUrl !== expected.baseUrl) return;
|
|
3374
|
+
await unlink3(webStatePath(io)).catch((error) => {
|
|
3375
|
+
if (!missing(error)) throw stateError("\u670D\u52A1\u7AEF\u5DF2\u9000\u51FA\uFF0C\u4F46\u672C\u5730\u4F1A\u8BDD\u6587\u4EF6\u5220\u9664\u5931\u8D25");
|
|
3376
|
+
});
|
|
3377
|
+
}
|
|
3378
|
+
async function lockWebRequest(io, hash) {
|
|
3379
|
+
if (!/^[a-f0-9]{64}$/u.test(hash)) throw stateError("\u7F51\u9875\u8BF7\u6C42\u9501\u6807\u8BC6\u65E0\u6548");
|
|
3380
|
+
const nonce = randomBytes3(16).toString("hex"), prefix = `web-lock-${hash}-`;
|
|
3381
|
+
const name2 = `${prefix}${process.pid}-${nonce}.json`;
|
|
3382
|
+
const mine = { version: 1, pid: process.pid, nonce, choosing: true, ticket: 0 };
|
|
3383
|
+
const release2 = async () => {
|
|
3384
|
+
const current = await readWebState(io, name2);
|
|
3385
|
+
if (current?.nonce === nonce && current.pid === process.pid) await unlink3(webStatePath(io, name2)).catch((error) => {
|
|
3386
|
+
if (!missing(error)) throw error;
|
|
3387
|
+
});
|
|
3388
|
+
};
|
|
3389
|
+
const participants = async () => {
|
|
3390
|
+
await guardAncestors(credentialsDir(io));
|
|
3391
|
+
const names = (await readdir2(credentialsDir(io))).filter((candidate) => candidate.startsWith(prefix) && /^web-lock-[a-f0-9]{64}-\d+-[a-f0-9]{32}\.json$/u.test(candidate));
|
|
3392
|
+
const records = [];
|
|
3393
|
+
for (const candidate of names) {
|
|
3394
|
+
const value = await readWebState(io, candidate);
|
|
3395
|
+
if (!value) continue;
|
|
3396
|
+
if (value.version !== 1 || !Number.isSafeInteger(value.pid) || Number(value.pid) <= 0 || typeof value.nonce !== "string" || candidate !== `${prefix}${value.pid}-${value.nonce}.json` || typeof value.choosing !== "boolean" || !Number.isSafeInteger(value.ticket) || Number(value.ticket) < 0) throw stateError("\u7F51\u9875\u8BF7\u6C42\u9501\u7968\u636E\u65E0\u6548\uFF0C\u64CD\u4F5C\u672A\u63D0\u4EA4");
|
|
3397
|
+
let alive = true;
|
|
3398
|
+
try {
|
|
3399
|
+
process.kill(Number(value.pid), 0);
|
|
3400
|
+
} catch (error) {
|
|
3401
|
+
if (error.code === "ESRCH") alive = false;
|
|
3402
|
+
}
|
|
3403
|
+
if (!alive) {
|
|
3404
|
+
await unlink3(webStatePath(io, candidate)).catch((error) => {
|
|
3405
|
+
if (!missing(error)) throw error;
|
|
3406
|
+
});
|
|
3407
|
+
} else records.push({ name: candidate, ticket: Number(value.ticket), choosing: value.choosing });
|
|
3408
|
+
}
|
|
3409
|
+
return records;
|
|
3410
|
+
};
|
|
3411
|
+
await writeWebState(io, name2, mine);
|
|
3412
|
+
try {
|
|
3413
|
+
const others = await participants();
|
|
3414
|
+
mine.ticket = Math.max(0, ...others.map((value) => value.ticket)) + 1;
|
|
3415
|
+
if (!Number.isSafeInteger(mine.ticket)) throw stateError("\u7F51\u9875\u8BF7\u6C42\u9501\u7968\u53F7\u8D85\u51FA\u8303\u56F4");
|
|
3416
|
+
mine.choosing = false;
|
|
3417
|
+
await writeWebState(io, name2, mine);
|
|
3418
|
+
const deadline = Date.now() + 12e4;
|
|
3419
|
+
for (; ; ) {
|
|
3420
|
+
if (io.signal?.aborted) throw interruptedError();
|
|
3421
|
+
const blocked = (await participants()).some((other) => other.name !== name2 && (other.choosing || other.ticket < mine.ticket || other.ticket === mine.ticket && other.name < name2));
|
|
3422
|
+
if (!blocked) return release2;
|
|
3423
|
+
if (Date.now() >= deadline) throw new CliError({
|
|
3424
|
+
code: "CLI_WEB_REQUEST_BUSY",
|
|
3425
|
+
exitCode: EXIT.RETRY_LATER,
|
|
3426
|
+
message: "\u76F8\u540C\u7F51\u9875\u8BF7\u6C42\u6B63\u5728\u7531\u53E6\u4E00\u4E2A CLI \u8FDB\u7A0B\u5904\u7406\uFF0C\u672C\u6B21\u672A\u63D0\u4EA4\uFF1B\u8BF7\u67E5\u8BE2\u539F\u64CD\u4F5C\u7ED3\u679C"
|
|
3427
|
+
});
|
|
3428
|
+
await new Promise((resolve3) => setTimeout(resolve3, 25));
|
|
3429
|
+
}
|
|
3430
|
+
} catch (error) {
|
|
3431
|
+
await release2().catch(() => void 0);
|
|
3432
|
+
throw error;
|
|
3433
|
+
}
|
|
3434
|
+
}
|
|
3435
|
+
async function fingerprintWebRequest(io, scope, value) {
|
|
3436
|
+
const scopeHash = createHash4("sha256").update(JSON.stringify(scope)).digest("hex");
|
|
3437
|
+
const name2 = `web-fingerprint-${scopeHash}.json`;
|
|
3438
|
+
const release2 = await lockWebRequest(io, createHash4("sha256").update(`fingerprint:${scopeHash}`).digest("hex"));
|
|
3439
|
+
try {
|
|
3440
|
+
let stored = await readWebState(io, name2);
|
|
3441
|
+
if (!stored) {
|
|
3442
|
+
stored = { version: 1, key: randomBytes3(32).toString("hex") };
|
|
3443
|
+
await writeWebState(io, name2, stored);
|
|
3444
|
+
}
|
|
3445
|
+
if (stored.version !== 1 || typeof stored.key !== "string" || !/^[a-f0-9]{64}$/u.test(stored.key)) throw stateError("\u7F51\u9875\u8BF7\u6C42\u6458\u8981\u5BC6\u94A5\u65E0\u6548\uFF0C\u64CD\u4F5C\u672A\u63D0\u4EA4");
|
|
3446
|
+
return createHmac("sha256", Buffer.from(stored.key, "hex")).update(JSON.stringify(value)).digest("hex");
|
|
3447
|
+
} finally {
|
|
3448
|
+
await release2();
|
|
3449
|
+
}
|
|
3450
|
+
}
|
|
3451
|
+
async function resolveWebSession(context) {
|
|
3452
|
+
const explicit = explicitBaseUrl(context.baseUrl, context.io.env);
|
|
3453
|
+
const supplied = context.io.env.BUKE_SESSION_TOKEN?.trim();
|
|
3454
|
+
if (supplied) {
|
|
3455
|
+
const token2 = validateSessionToken(supplied);
|
|
3456
|
+
context.out.protect(token2);
|
|
3457
|
+
return { version: 1, token: token2, baseUrl: explicit ?? DEFAULT_BASE_URL, savedAt: "", source: "env" };
|
|
3458
|
+
}
|
|
3459
|
+
const stored = await readWebState(context.io, "session.json");
|
|
3460
|
+
if (!stored) throw new CliError({
|
|
3461
|
+
code: "CLI_WEB_NOT_LOGGED_IN",
|
|
3462
|
+
exitCode: EXIT.AUTH,
|
|
3463
|
+
message: "\u5C1A\u672A\u767B\u5F55\u7F51\u9875\u4F1A\u8BDD\uFF0C\u8BF7\u8FD0\u884C buke web login\uFF1Bbuke login \u4FDD\u5B58\u7684 API \u5BC6\u94A5\u4E0D\u80FD\u7528\u4E8E\u7F51\u9875\u63A5\u53E3"
|
|
3464
|
+
});
|
|
3465
|
+
if (stored.version !== 1 || typeof stored.baseUrl !== "string" || typeof stored.savedAt !== "string") throw stateError("\u7F51\u9875\u4F1A\u8BDD\u6587\u4EF6\u683C\u5F0F\u65E0\u6548\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55");
|
|
3466
|
+
const token = validateSessionToken(stored.token), baseUrl = normalizeBaseUrl(stored.baseUrl);
|
|
3467
|
+
context.out.protect(token);
|
|
3468
|
+
if (explicit && explicit !== baseUrl) throw usageError("\u7F51\u9875\u4F1A\u8BDD\u4E0E\u670D\u52A1\u5730\u5740\u4E0D\u5339\u914D\uFF1B\u5207\u6362\u670D\u52A1\u8BF7\u91CD\u65B0\u8FD0\u884C buke web login");
|
|
3469
|
+
return {
|
|
3470
|
+
version: 1,
|
|
3471
|
+
token,
|
|
3472
|
+
baseUrl,
|
|
3473
|
+
savedAt: stored.savedAt,
|
|
3474
|
+
source: "file",
|
|
3475
|
+
...typeof stored.expiresAt === "string" ? { expiresAt: stored.expiresAt } : {}
|
|
3476
|
+
};
|
|
3477
|
+
}
|
|
3478
|
+
async function readWebPassword(io) {
|
|
3479
|
+
if (io.signal?.aborted) throw interruptedError();
|
|
3480
|
+
const fromEnv = io.env.BUKE_PASSWORD;
|
|
3481
|
+
if (fromEnv !== void 0) {
|
|
3482
|
+
if (!fromEnv || fromEnv.length > 8192 || /[\r\n\0]/u.test(fromEnv)) throw usageError("BUKE_PASSWORD \u4E0D\u80FD\u4E3A\u7A7A\u6216\u542B\u6362\u884C");
|
|
3483
|
+
return fromEnv;
|
|
3484
|
+
}
|
|
3485
|
+
const stream = io.stdin;
|
|
3486
|
+
const tty = stream.isTTY === true;
|
|
3487
|
+
if (tty && typeof stream.setRawMode !== "function") throw usageError("\u5F53\u524D\u7EC8\u7AEF\u4E0D\u80FD\u9690\u85CF\u5BC6\u7801\u8F93\u5165\uFF0C\u8BF7\u4F7F\u7528 BUKE_PASSWORD \u6216\u7BA1\u9053");
|
|
3488
|
+
if (tty) io.stderr.write("\u7F51\u9875\u767B\u5F55\u5BC6\u7801\uFF08\u8F93\u5165\u4E0D\u663E\u793A\uFF09\uFF1A");
|
|
3489
|
+
const password = await new Promise((resolve3, reject) => {
|
|
3490
|
+
let value = "", done = false;
|
|
3491
|
+
const decoder = new StringDecoder("utf8");
|
|
3492
|
+
const finish = (error) => {
|
|
3493
|
+
if (done) return;
|
|
3494
|
+
done = true;
|
|
3495
|
+
clearTimeout(timer);
|
|
3496
|
+
for (const [name2, handler] of [["data", onData], ["end", onEnd], ["close", onEnd], ["error", onError]]) stream.removeListener(name2, handler);
|
|
3497
|
+
io.signal?.removeEventListener("abort", onAbort);
|
|
3498
|
+
if (tty) {
|
|
3499
|
+
stream.setRawMode(false);
|
|
3500
|
+
io.stderr.write("\n");
|
|
3501
|
+
}
|
|
3502
|
+
stream.pause();
|
|
3503
|
+
if (error) reject(error);
|
|
3504
|
+
else resolve3(value.replace(/\r?\n$/u, ""));
|
|
3505
|
+
};
|
|
3506
|
+
const onAbort = () => finish(interruptedError());
|
|
3507
|
+
const onEnd = () => {
|
|
3508
|
+
value += decoder.end();
|
|
3509
|
+
finish();
|
|
3510
|
+
};
|
|
3511
|
+
const onError = () => finish(usageError("\u65E0\u6CD5\u8BFB\u53D6\u5BC6\u7801\u8F93\u5165"));
|
|
3512
|
+
const onData = (chunk) => {
|
|
3513
|
+
const text = typeof chunk === "string" ? chunk : decoder.write(Buffer.from(chunk));
|
|
3514
|
+
if (tty) {
|
|
3515
|
+
for (const character of text) {
|
|
3516
|
+
if (character === "") {
|
|
3517
|
+
onAbort();
|
|
3518
|
+
return;
|
|
3519
|
+
}
|
|
3520
|
+
if (character === "\r" || character === "\n" || character === "") {
|
|
3521
|
+
finish();
|
|
3522
|
+
return;
|
|
3523
|
+
}
|
|
3524
|
+
if (character === "\b" || character === "\x7F") value = [...value].slice(0, -1).join("");
|
|
3525
|
+
else if (!/[\p{Cc}]/u.test(character)) value += character;
|
|
3526
|
+
}
|
|
3527
|
+
} else value += text;
|
|
3528
|
+
if (Buffer.byteLength(value) > 8192) finish(usageError("\u5BC6\u7801\u8F93\u5165\u8FC7\u957F"));
|
|
3529
|
+
};
|
|
3530
|
+
const timer = setTimeout(() => finish(usageError("\u7B49\u5F85\u5BC6\u7801\u8F93\u5165\u8D85\u65F6")), io.stdinTimeoutMs ?? 3e4);
|
|
3531
|
+
stream.on("data", onData);
|
|
3532
|
+
stream.on("end", onEnd);
|
|
3533
|
+
stream.on("close", onEnd);
|
|
3534
|
+
stream.on("error", onError);
|
|
3535
|
+
io.signal?.addEventListener("abort", onAbort, { once: true });
|
|
3536
|
+
if (tty) stream.setRawMode(true);
|
|
3537
|
+
stream.resume();
|
|
3538
|
+
});
|
|
3539
|
+
if (!password || /[\r\n\0]/u.test(password)) throw usageError("\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A\u6216\u5305\u542B\u6362\u884C");
|
|
3540
|
+
return password;
|
|
3541
|
+
}
|
|
3542
|
+
|
|
3543
|
+
// src/commands/web.ts
|
|
3544
|
+
var webCommand = {
|
|
3545
|
+
run: web,
|
|
3546
|
+
acceptsBaseUrl: true,
|
|
3547
|
+
options: ["username", "group", "params", "query", "data", "headers", "file", "files", "yes", "out", "timeout", "workspace", "idempotency-key"],
|
|
3548
|
+
positionals: ["\u5B50\u547D\u4EE4", "\u64CD\u4F5C\u7F16\u53F7"],
|
|
3549
|
+
help: [
|
|
3550
|
+
"\u7528\u6CD5\uFF1A",
|
|
3551
|
+
" buke web login --username <\u8D26\u53F7>\uFF1A\u5BC6\u7801\u901A\u8FC7 BUKE_PASSWORD\u3001\u7BA1\u9053\u6216\u9690\u85CF\u7EC8\u7AEF\u8F93\u5165\u63D0\u4F9B\u3002",
|
|
3552
|
+
" buke web whoami [--workspace <\u5DE5\u4F5C\u533AID>] | logout",
|
|
3553
|
+
" buke web operations [--group <\u5206\u7EC4>]\uFF1A\u67E5\u770B\u56FA\u5B9A\u64CD\u4F5C\u76EE\u5F55\u3002",
|
|
3554
|
+
" buke web call <\u64CD\u4F5C\u7F16\u53F7> [--params <JSON\u6587\u4EF6|->] [--query <JSON\u6587\u4EF6>] [--data <JSON\u6587\u4EF6>]",
|
|
3555
|
+
" [--file <\u6587\u4EF6> | --files <\u5B57\u6BB5\u540D\u5230\u6587\u4EF6\u8DEF\u5F84\u7684JSON\u6587\u4EF6>] [--yes] [--out <\u65B0\u6587\u4EF6>]",
|
|
3556
|
+
" [--headers <\u4E1A\u52A1\u8BF7\u6C42\u5934JSON\u6587\u4EF6>] [--workspace <\u5DE5\u4F5C\u533AID>] [--idempotency-key <\u539F\u952E>] [--timeout <\u79D2>] [--json]",
|
|
3557
|
+
"\u6240\u6709\u5199\u64CD\u4F5C\u5FC5\u987B\u6DFB\u52A0 --yes\uFF1B\u8FD9\u53EA\u4EE3\u8868\u63D0\u4EA4\u672C\u6B21\u64CD\u4F5C\uFF0C\u8D39\u7528\u8303\u56F4\u4ECD\u7531\u7F51\u9875\u539F\u63A5\u53E3\u7684\u62A5\u4EF7\u4E0E\u786E\u8BA4\u7EA6\u675F\u3002",
|
|
3558
|
+
"\u53EA\u5141\u8BB8\u76EE\u5F55\u5185\u7684\u8DEF\u5F84\uFF0C\u5145\u503C\u53CA\u540E\u53F0\u7BA1\u7406\u4E0D\u5728\u76EE\u5F55\u4E2D\u3002\u4F1A\u8BDD\u4E0E API \u5BC6\u94A5\u5206\u522B\u4FDD\u5B58\uFF0C\u4E0D\u80FD\u6DF7\u7528\u3002",
|
|
3559
|
+
"\u9ED8\u8BA4\u8BF7\u6C42\u65F6\u9650 120 \u79D2\uFF1B\u6D41\u5F0F\u4E8B\u4EF6\u53EF\u4E2D\u65AD\u3002\u6587\u4EF6\u4EE5 0600 \u539F\u5B50\u4FDD\u5B58\uFF0C\u5DF2\u6709\u6587\u4EF6\u4E0D\u8986\u76D6\u3002",
|
|
3560
|
+
"API \u5BC6\u94A5\u7B7E\u53D1\u5FC5\u987B\u63D0\u4F9B --out\uFF0C\u660E\u6587\u53EA\u5199\u6587\u4EF6\uFF0C\u4E0D\u663E\u793A\u5728\u7EC8\u7AEF\u3002\u672A\u77E5\u7ED3\u679C\u4FDD\u7559\u539F\u952E\uFF0C\u4E0D\u81EA\u52A8\u91CD\u53D1\u3002"
|
|
3561
|
+
].join("\n")
|
|
3562
|
+
};
|
|
3563
|
+
function object(value) {
|
|
3564
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw usageError("\u8BF7\u6C42\u53C2\u6570\u5FC5\u987B\u662F JSON \u5BF9\u8C61");
|
|
3565
|
+
return value;
|
|
3566
|
+
}
|
|
3567
|
+
function issuedSession(context, baseUrl, data) {
|
|
3568
|
+
const user = data.user && typeof data.user === "object" && !Array.isArray(data.user) ? data.user : {};
|
|
3569
|
+
const now = context.io.now?.() ?? /* @__PURE__ */ new Date();
|
|
3570
|
+
if (data.ok !== true || typeof data.expiresAt !== "string" || !Number.isFinite(Date.parse(data.expiresAt)) || Date.parse(data.expiresAt) <= now.getTime() || typeof user.id !== "string" || !user.id || typeof user.username !== "string" || !user.username || typeof user.workspaceId !== "string" || !user.workspaceId || !Array.isArray(user.workspaces) || !user.workspaces.some((item) => item && typeof item === "object" && item.id === user.workspaceId)) {
|
|
3571
|
+
throw new CliError({ code: "CLI_BAD_RESPONSE", exitCode: EXIT.SERVER, message: "\u8BA4\u8BC1\u54CD\u5E94\u7F3A\u5C11\u5B8C\u6574\u4F1A\u8BDD\u6216\u7528\u6237\u8EAB\u4EFD\uFF0C\u539F\u4F1A\u8BDD\u4FDD\u6301\u4E0D\u53D8" });
|
|
3572
|
+
}
|
|
3573
|
+
const token = validateSessionToken(data.token);
|
|
3574
|
+
context.out.protect(token);
|
|
3575
|
+
return { version: 1, baseUrl, token, savedAt: now.toISOString(), expiresAt: data.expiresAt };
|
|
3576
|
+
}
|
|
3577
|
+
async function optionData(context, name2) {
|
|
3578
|
+
const file = textOption(context.values, name2);
|
|
3579
|
+
return file ? readPropsArgument(context.io, file, `--${name2}`) : {};
|
|
3580
|
+
}
|
|
3581
|
+
function workspaceOf(context) {
|
|
3582
|
+
const workspace = textOption(context.values, "workspace") ?? context.io.env.BUKE_WORKSPACE_ID?.trim();
|
|
3583
|
+
if (workspace && !/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/u.test(workspace)) throw usageError("\u5DE5\u4F5C\u533A\u7F16\u53F7\u683C\u5F0F\u65E0\u6548");
|
|
3584
|
+
return workspace || void 0;
|
|
3585
|
+
}
|
|
3586
|
+
function operationPath(operation, params, query) {
|
|
3587
|
+
const used = /* @__PURE__ */ new Set(), resolved = {};
|
|
3588
|
+
const path = operation.path.replace(/:([A-Za-z][A-Za-z0-9_]*)/gu, (_match, name2) => {
|
|
3589
|
+
const value = params[name2];
|
|
3590
|
+
const text = String(value);
|
|
3591
|
+
const invalidPath = name2 === "path" ? text.split("/").some((segment2) => !segment2 || segment2 === "." || segment2 === "..") : text.includes("/") || [".", ".."].includes(text);
|
|
3592
|
+
if (typeof value !== "string" && typeof value !== "number" || !text || /[\\%\p{Cc}]/u.test(text) || invalidPath) throw usageError(`\u8BF7\u5728 --params \u4E2D\u63D0\u4F9B\u6709\u6548\u8DEF\u5F84\u53C2\u6570 ${name2}`);
|
|
3593
|
+
used.add(name2);
|
|
3594
|
+
resolved[name2] = String(value);
|
|
3595
|
+
return encodeURIComponent(String(value));
|
|
3596
|
+
});
|
|
3597
|
+
if (Object.keys(params).some((name2) => !used.has(name2))) throw usageError("--params \u5305\u542B\u8BE5\u64CD\u4F5C\u4E0D\u4F7F\u7528\u7684\u53C2\u6570");
|
|
3598
|
+
const search = new URLSearchParams();
|
|
3599
|
+
for (const [name2, raw] of Object.entries(query)) {
|
|
3600
|
+
if (!name2 || /[\p{Cc}]/u.test(name2)) throw usageError("\u67E5\u8BE2\u53C2\u6570\u540D\u79F0\u65E0\u6548");
|
|
3601
|
+
for (const value of Array.isArray(raw) ? raw : [raw]) {
|
|
3602
|
+
if (value === null || value === void 0) continue;
|
|
3603
|
+
if (!["string", "number", "boolean"].includes(typeof value)) throw usageError("\u67E5\u8BE2\u53C2\u6570\u53EA\u652F\u6301\u5B57\u7B26\u4E32\u3001\u6570\u5B57\u3001\u5E03\u5C14\u503C\u53CA\u5176\u6570\u7EC4");
|
|
3604
|
+
search.append(name2, String(value));
|
|
3605
|
+
}
|
|
3606
|
+
}
|
|
3607
|
+
return { path: `${path}${search.size ? `?${search}` : ""}`, params: resolved };
|
|
3608
|
+
}
|
|
3609
|
+
function fileOperation(operation) {
|
|
3610
|
+
if (operation.method !== "GET") return false;
|
|
3611
|
+
return operation.response === "file" || /\/(?:download(?:\.zip)?|video|audio|clip|subtitles\.srt)$/u.test(operation.path) || /\/edits\/:[^/]+\/subtitles$/u.test(operation.path) || /\/attachments\/:[^/]+\/file$/u.test(operation.path) || /^\/api\/delivery\/(?:packages|shared)\/:[^/]+\/files\/:[^/]+$/u.test(operation.path) || /^\/api\/membership\/renders\/:[^/]+\/output$/u.test(operation.path) || operation.path === "/api/graphic/runs/:runId/preview" || /^\/api\/showcase-videos\/runs\/:[^/]+\/image-edits\/area\/:[^/]+\/preview$/u.test(operation.path);
|
|
3612
|
+
}
|
|
3613
|
+
async function upload2(path, operation) {
|
|
3614
|
+
try {
|
|
3615
|
+
const policy = webUploadPolicy(operation, basename3(path));
|
|
3616
|
+
const info = await lstat4(path);
|
|
3617
|
+
if (!info.isFile() || info.size <= 0 || info.size > policy.maxBytes) throw usageError(`\u4E0A\u4F20\u5FC5\u987B\u662F 1 \u5B57\u8282\u81F3 ${policy.maxBytes / 1024 / 1024} MiB \u7684\u666E\u901A\u6587\u4EF6`);
|
|
3618
|
+
const bytes = await readFile3(path);
|
|
3619
|
+
if (!bytes.length || bytes.length > policy.maxBytes) throw usageError("\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u8D85\u51FA\u8BE5\u64CD\u4F5C\u5141\u8BB8\u8303\u56F4");
|
|
3620
|
+
return { bytes, mime: policy.mime, name: basename3(path), sha256: createHash5("sha256").update(bytes).digest("hex") };
|
|
3621
|
+
} catch (error) {
|
|
3622
|
+
if (error instanceof CliError) throw error;
|
|
3623
|
+
throw usageError("\u4E0A\u4F20\u6587\u4EF6\u4E0D\u5B58\u5728\u6216\u65E0\u6CD5\u8BFB\u53D6");
|
|
3624
|
+
}
|
|
3625
|
+
}
|
|
3626
|
+
async function requestBody(context, operation, data) {
|
|
3627
|
+
const file = textOption(context.values, "file"), filesFile = textOption(context.values, "files");
|
|
3628
|
+
if (file && filesFile) throw usageError("--file \u4E0E --files \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528");
|
|
3629
|
+
if (operation.method === "GET") {
|
|
3630
|
+
if (file || filesFile || textOption(context.values, "data")) throw usageError("\u67E5\u8BE2\u64CD\u4F5C\u4E0D\u63A5\u53D7\u6B63\u6587\u6216\u4E0A\u4F20\u6587\u4EF6");
|
|
3631
|
+
return { identity: null };
|
|
3632
|
+
}
|
|
3633
|
+
if (operation.body === "binary") {
|
|
3634
|
+
if (!file || filesFile || textOption(context.values, "data")) throw usageError("\u8BE5\u64CD\u4F5C\u9700\u8981 --file \u539F\u6587\u4EF6\uFF0C\u4E0D\u80FD\u540C\u65F6\u63D0\u4EA4 JSON \u6B63\u6587");
|
|
3635
|
+
const source = await upload2(file, operation);
|
|
3636
|
+
return { body: new Uint8Array(source.bytes), contentType: source.mime, filename: source.name, identity: { sha256: source.sha256, bytes: source.bytes.length } };
|
|
3637
|
+
}
|
|
3638
|
+
if (operation.body === "multipart") {
|
|
3639
|
+
const field = operation.uploadField;
|
|
3640
|
+
if (!field) throw usageError("\u8BE5\u64CD\u4F5C\u7F3A\u5C11\u4E0A\u4F20\u5B57\u6BB5\u5408\u540C");
|
|
3641
|
+
const mapping = file ? { [field]: file } : await optionData(context, "files");
|
|
3642
|
+
if (Object.keys(mapping).length !== 1 || !(field in mapping) || Array.isArray(mapping[field]) && mapping[field].length !== 1) throw usageError(`\u8BE5\u64CD\u4F5C\u9700\u8981\u4E14\u53EA\u63A5\u53D7\u4E00\u4E2A ${field} \u6587\u4EF6\uFF0C\u8BF7\u4F7F\u7528 --file \u6216\u5BF9\u5E94 --files \u5B57\u6BB5`);
|
|
3643
|
+
const form = new FormData(), identities = [];
|
|
3644
|
+
for (const [name2, value] of Object.entries(data)) form.append(name2, typeof value === "string" ? value : JSON.stringify(value));
|
|
3645
|
+
let total = 0;
|
|
3646
|
+
for (const [field2, paths] of Object.entries(mapping)) {
|
|
3647
|
+
if (!field2 || /[\p{Cc}]/u.test(field2)) throw usageError("\u4E0A\u4F20\u5B57\u6BB5\u540D\u79F0\u65E0\u6548");
|
|
3648
|
+
for (const path of Array.isArray(paths) ? paths : [paths]) {
|
|
3649
|
+
if (typeof path !== "string") throw usageError("--files \u7684\u503C\u5FC5\u987B\u662F\u6587\u4EF6\u8DEF\u5F84\u6216\u6587\u4EF6\u8DEF\u5F84\u6570\u7EC4");
|
|
3650
|
+
const source = await upload2(path, operation);
|
|
3651
|
+
total += source.bytes.length;
|
|
3652
|
+
if (total > 256 * 1024 * 1024) throw usageError("\u672C\u6B21\u9644\u4EF6\u603B\u91CF\u4E0D\u80FD\u8D85\u8FC7 256 MiB");
|
|
3653
|
+
form.append(field2, new Blob([new Uint8Array(source.bytes)], { type: source.mime }), source.name);
|
|
3654
|
+
identities.push({ field: field2, name: source.name, sha256: source.sha256, bytes: source.bytes.length });
|
|
3655
|
+
}
|
|
3656
|
+
}
|
|
3657
|
+
return { body: form, identity: { data, files: identities } };
|
|
3658
|
+
}
|
|
3659
|
+
if (file || filesFile) throw usageError("\u8BE5\u64CD\u4F5C\u63A5\u53D7 JSON \u6B63\u6587\uFF0C\u4E0D\u63A5\u53D7\u6587\u4EF6\u4E0A\u4F20");
|
|
3660
|
+
return { body: JSON.stringify(data), contentType: "application/json", identity: data };
|
|
3661
|
+
}
|
|
3662
|
+
async function webIdentity(context, session, workspace, timeoutMs) {
|
|
3663
|
+
const result = await requestWeb(context.io, { baseUrl: session.baseUrl, token: session.token, method: "GET", path: "/api/me", workspaceId: workspace, timeoutMs });
|
|
3664
|
+
const user = object(object(result.data).user);
|
|
3665
|
+
if (typeof user.id !== "string" || !user.id || typeof user.workspaceId !== "string" || !user.workspaceId || workspace && (user.workspaceId !== workspace || !Array.isArray(user.workspaces) || !user.workspaces.some((item) => item && typeof item === "object" && item.id === workspace))) {
|
|
3666
|
+
throw new CliError({ code: "CLI_WEB_WORKSPACE_FORBIDDEN", exitCode: EXIT.AUTH, message: "\u670D\u52A1\u7AEF\u672A\u786E\u8BA4\u8BE5\u5DE5\u4F5C\u533A\u7684\u6210\u5458\u6743\u9650\uFF0C\u672C\u6B21\u64CD\u4F5C\u672A\u63D0\u4EA4" });
|
|
3667
|
+
}
|
|
3668
|
+
return { result, userId: user.id, workspaceId: user.workspaceId };
|
|
3669
|
+
}
|
|
3670
|
+
async function web(context) {
|
|
3671
|
+
const invocationStartedAt = performance.timeOrigin + performance.now();
|
|
3672
|
+
const { io, out, args, values } = context;
|
|
3673
|
+
const timeoutSeconds = timeoutSecondsOf(values, 120);
|
|
3674
|
+
if (timeoutSeconds > 2147483) throw usageError("--timeout \u8D85\u51FA\u652F\u6301\u8303\u56F4");
|
|
3675
|
+
const timeoutMs = timeoutSeconds * 1e3;
|
|
3676
|
+
const action2 = args[0];
|
|
3677
|
+
if (!["login", "whoami", "logout", "operations", "call"].includes(action2 ?? "")) throw usageError("web \u652F\u6301 login\u3001whoami\u3001logout\u3001operations\u3001call");
|
|
3678
|
+
if (action2 !== "call" && args[1] !== void 0) throw usageError("\u8BE5\u7F51\u9875\u5B50\u547D\u4EE4\u4E0D\u63A5\u53D7\u64CD\u4F5C\u7F16\u53F7");
|
|
3679
|
+
if (["params", "query", "data", "files", "headers"].filter((name2) => values[name2] === "-").length > 1) throw usageError("\u4E00\u6B21\u547D\u4EE4\u53EA\u80FD\u6709\u4E00\u4E2A JSON \u53C2\u6570\u4ECE\u6807\u51C6\u8F93\u5165\u8BFB\u53D6");
|
|
3680
|
+
if (action2 === "operations") {
|
|
3681
|
+
const group = textOption(values, "group");
|
|
3682
|
+
const operations = WEB_OPERATIONS.filter((operation2) => !group || operation2.group === group);
|
|
3683
|
+
out.result(operations.map((operation2) => `${operation2.id} ${operation2.method} ${operation2.path} ${operation2.description}`), { operations });
|
|
3684
|
+
return;
|
|
3685
|
+
}
|
|
3686
|
+
if (action2 === "login") {
|
|
3687
|
+
const username = textOption(values, "username");
|
|
3688
|
+
if (!username) throw usageError("\u8BF7\u63D0\u4F9B --username <\u8D26\u53F7>");
|
|
3689
|
+
const baseUrl = explicitBaseUrl(context.baseUrl, io.env) ?? DEFAULT_BASE_URL;
|
|
3690
|
+
const password = await readWebPassword(io);
|
|
3691
|
+
out.protect(password);
|
|
3692
|
+
let session;
|
|
3693
|
+
const result = await requestWeb(io, {
|
|
3694
|
+
baseUrl,
|
|
3695
|
+
path: "/api/auth/login",
|
|
3696
|
+
method: "POST",
|
|
3697
|
+
timeoutMs,
|
|
3698
|
+
body: JSON.stringify({ username, password }),
|
|
3699
|
+
contentType: "application/json",
|
|
3700
|
+
secrets: [password],
|
|
3701
|
+
onLogin: (data2) => {
|
|
3702
|
+
if (data2.ok !== true) return;
|
|
3703
|
+
session = issuedSession(context, baseUrl, data2);
|
|
3704
|
+
}
|
|
3705
|
+
});
|
|
3706
|
+
if (!session) throw new CliError({ code: "CLI_BAD_RESPONSE", exitCode: EXIT.SERVER, message: "\u767B\u5F55\u54CD\u5E94\u6CA1\u6709\u6709\u6548\u4F1A\u8BDD\uFF0C\u672A\u4FDD\u5B58\u51ED\u636E" });
|
|
3707
|
+
const path = await writeWebState(io, "session.json", session);
|
|
3708
|
+
out.result(["\u7F51\u9875\u767B\u5F55\u6210\u529F", `\u670D\u52A1\u5730\u5740\uFF1A${baseUrl}`, `\u4F1A\u8BDD\u6587\u4EF6\uFF1A${path}`], { ...object(result.data), baseUrl, sessionPath: path });
|
|
3709
|
+
return;
|
|
3710
|
+
}
|
|
3711
|
+
if (action2 === "whoami" || action2 === "logout") {
|
|
3712
|
+
const session = await resolveWebSession(context), workspace2 = workspaceOf(context);
|
|
3713
|
+
if (action2 === "whoami") {
|
|
3714
|
+
const { result } = await webIdentity(context, session, workspace2, timeoutMs);
|
|
3715
|
+
out.result([JSON.stringify(result.data, null, 2)], { ...object(result.data), baseUrl: session.baseUrl, source: session.source });
|
|
3716
|
+
} else {
|
|
3717
|
+
try {
|
|
3718
|
+
await requestWeb(io, { baseUrl: session.baseUrl, token: session.token, path: "/api/auth/logout", method: "POST", timeoutMs });
|
|
3719
|
+
} catch (error) {
|
|
3720
|
+
throw toCliError(error).withHint("\u9000\u51FA\u7ED3\u679C\u672A\u77E5\u6216\u88AB\u62D2\u7EDD\uFF0C\u672C\u5730\u4F1A\u8BDD\u4FDD\u7559\uFF1B\u8BF7\u786E\u8BA4\u670D\u52A1\u5730\u5740\u540E\u91CD\u8BD5\u9000\u51FA\u3002");
|
|
3721
|
+
}
|
|
3722
|
+
await deleteWebSession(io, session);
|
|
3723
|
+
out.result(["\u7F51\u9875\u4F1A\u8BDD\u5DF2\u9000\u51FA"], { loggedOut: true, source: session.source });
|
|
3724
|
+
}
|
|
3725
|
+
return;
|
|
3726
|
+
}
|
|
3727
|
+
const operation = WEB_OPERATIONS.find((item) => item.id === args[1]);
|
|
3728
|
+
if (!operation) throw usageError("\u64CD\u4F5C\u4E0D\u5728\u7F51\u9875\u547D\u4EE4\u76EE\u5F55\u4E2D\uFF0C\u8BF7\u5148\u8FD0\u884C buke web operations");
|
|
3729
|
+
const mutating = operation.method !== "GET";
|
|
3730
|
+
if (mutating && values.yes !== true) throw usageError("\u7F51\u9875\u5199\u64CD\u4F5C\u5FC5\u987B\u6DFB\u52A0 --yes\uFF1B\u8BF7\u5148\u6838\u5BF9\u672C\u6B21\u64CD\u4F5C\u8303\u56F4\u4E0E\u8D39\u7528");
|
|
3731
|
+
const suppliedKey = textOption(values, "idempotency-key");
|
|
3732
|
+
const issueApiKey = operation.method === "POST" && operation.path === "/api/api-keys";
|
|
3733
|
+
const secretOutput = issueApiKey || operation.sensitiveOutput === true;
|
|
3734
|
+
const output = textOption(values, "out");
|
|
3735
|
+
if (secretOutput && !output) throw usageError("\u8BE5\u64CD\u4F5C\u7B7E\u53D1\u5BC6\u94A5\u6216\u79C1\u6709\u94FE\u63A5\uFF0C\u5FC5\u987B\u4F7F\u7528 --out <\u65B0\u6587\u4EF6>\uFF1B\u660E\u6587\u4E0D\u4F1A\u8F93\u51FA\u5230\u7EC8\u7AEF");
|
|
3736
|
+
if (operation.response === "file" && !output) throw usageError("\u8BE5\u64CD\u4F5C\u8FD4\u56DE\u56FE\u7247\u539F\u6587\u4EF6\uFF0C\u5FC5\u987B\u4F7F\u7528 --out <\u65B0\u6587\u4EF6> \u4FDD\u5B58");
|
|
3737
|
+
if (output) await checkWebOutput(output);
|
|
3738
|
+
const params = await optionData(context, "params"), query = await optionData(context, "query"), data = await optionData(context, "data");
|
|
3739
|
+
const authCodes = operation.group === "auth" && (typeof data.code === "string" || typeof data.code === "number") ? [String(data.code)] : [];
|
|
3740
|
+
const secrets = [...webSecrets(data), ...webSecrets(query), ...webSecrets(params), ...authCodes];
|
|
3741
|
+
for (const secret of secrets) out.protect(secret);
|
|
3742
|
+
const bodyKey = operation.idempotencyBodyKey ? data[operation.idempotencyBodyKey] : void 0;
|
|
3743
|
+
if (bodyKey !== void 0 && typeof bodyKey !== "string") throw usageError("\u6B63\u6587\u4E2D\u7684\u5E42\u7B49\u952E\u5FC5\u987B\u662F\u5B57\u7B26\u4E32");
|
|
3744
|
+
if (suppliedKey && bodyKey !== void 0 && suppliedKey !== bodyKey) throw usageError("--idempotency-key \u4E0E\u6B63\u6587\u5E42\u7B49\u952E\u4E0D\u4E00\u81F4\uFF0C\u64CD\u4F5C\u672A\u63D0\u4EA4");
|
|
3745
|
+
const key = mutating ? suppliedKey ?? (typeof bodyKey === "string" ? bodyKey : void 0) ?? randomUUID2() : void 0;
|
|
3746
|
+
if (key && (!/^[A-Za-z0-9_.:-]{1,200}$/u.test(key) || key.startsWith("bk_"))) throw usageError("\u5E42\u7B49\u952E\u683C\u5F0F\u65E0\u6548");
|
|
3747
|
+
if (operation.idempotencyBodyKey && key) data[operation.idempotencyBodyKey] = key;
|
|
3748
|
+
const target = operationPath(operation, params, query);
|
|
3749
|
+
const body = await requestBody(context, operation, data);
|
|
3750
|
+
const businessHeaders = buildBusinessHeaders(operation, await optionData(context, "headers"), body.filename);
|
|
3751
|
+
const requestedWorkspace = workspaceOf(context);
|
|
3752
|
+
let caller;
|
|
3753
|
+
if (operation.public) {
|
|
3754
|
+
if (requestedWorkspace) throw usageError("\u516C\u5F00\u64CD\u4F5C\u4E0D\u63A5\u53D7\u5DE5\u4F5C\u533A\u53C2\u6570");
|
|
3755
|
+
caller = { baseUrl: explicitBaseUrl(context.baseUrl, io.env) ?? DEFAULT_BASE_URL, userId: "public" };
|
|
3756
|
+
} else {
|
|
3757
|
+
const session = await resolveWebSession(context);
|
|
3758
|
+
const identity = await webIdentity(context, session, requestedWorkspace, timeoutMs);
|
|
3759
|
+
caller = { baseUrl: session.baseUrl, token: session.token, userId: identity.userId, workspaceId: identity.workspaceId };
|
|
3760
|
+
}
|
|
3761
|
+
const workspace = caller.workspaceId;
|
|
3762
|
+
if (operation.membershipPaymentOnly) {
|
|
3763
|
+
const id = target.params.id;
|
|
3764
|
+
if (!id) throw usageError("\u4F1A\u5458\u652F\u4ED8\u64CD\u4F5C\u7F3A\u5C11\u8BA2\u5355\u7F16\u53F7");
|
|
3765
|
+
const checked = await requestWeb(io, {
|
|
3766
|
+
baseUrl: caller.baseUrl,
|
|
3767
|
+
token: caller.token,
|
|
3768
|
+
workspaceId: workspace,
|
|
3769
|
+
method: "GET",
|
|
3770
|
+
path: `/api/payments/orders/${encodeURIComponent(id)}`,
|
|
3771
|
+
timeoutMs
|
|
3772
|
+
});
|
|
3773
|
+
const order2 = object(object(checked.data).order);
|
|
3774
|
+
if (order2.id !== id || order2.orderType !== "membership") throw usageError("\u8BE5\u8BA2\u5355\u4E0D\u662F\u4F1A\u5458\u8BA2\u5355\uFF1BCLI \u4E0D\u652F\u6301\u5145\u503C\u53CA\u5176\u652F\u4ED8\u64CD\u4F5C");
|
|
3775
|
+
if (operation.method === "GET" && operation.path === "/api/payments/orders/:id") {
|
|
3776
|
+
const download4 = output ? await saveWebDocument(output, checked.data, io.signal) : void 0;
|
|
3777
|
+
out.result([JSON.stringify(checked.data, null, 2)], { ...checked, ...download4 ? { download: download4 } : {}, operationId: operation.id });
|
|
3778
|
+
return;
|
|
3779
|
+
}
|
|
3780
|
+
}
|
|
3781
|
+
const identityBody = operation.idempotencyBodyKey && body.identity && typeof body.identity === "object" && !Array.isArray(body.identity) ? { ...body.identity, [operation.idempotencyBodyKey]: void 0 } : body.identity;
|
|
3782
|
+
const requestHash = mutating ? await fingerprintWebRequest(
|
|
3783
|
+
io,
|
|
3784
|
+
{ baseUrl: caller.baseUrl, userId: caller.userId },
|
|
3785
|
+
[caller.baseUrl, caller.userId, workspace ?? null, operation.id, target.path, identityBody, businessHeaders]
|
|
3786
|
+
) : void 0;
|
|
3787
|
+
const recordName = `web-request-${requestHash}.json`;
|
|
3788
|
+
let recovery = {
|
|
3789
|
+
operationId: operation.id,
|
|
3790
|
+
baseUrl: caller.baseUrl,
|
|
3791
|
+
userId: caller.userId,
|
|
3792
|
+
...workspace ? { workspaceId: workspace } : {},
|
|
3793
|
+
...key ? { idempotencyKey: key } : {},
|
|
3794
|
+
requestHash,
|
|
3795
|
+
params: redactWebValue(target.params, secrets),
|
|
3796
|
+
operationOutcome: "not_submitted",
|
|
3797
|
+
...mutating ? { requestRecord: webStatePath(io, recordName) } : {}
|
|
3798
|
+
};
|
|
3799
|
+
let finishedAtMs;
|
|
3800
|
+
const persist = async () => {
|
|
3801
|
+
await writeWebState(io, recordName, { version: 1, ...recovery, finishedAtMs });
|
|
3802
|
+
await writeWebState(io, "last-web-request.json", { version: 1, ...recovery, finishedAtMs });
|
|
3803
|
+
};
|
|
3804
|
+
const release2 = mutating ? await lockWebRequest(io, requestHash) : void 0;
|
|
3805
|
+
try {
|
|
3806
|
+
if (mutating) {
|
|
3807
|
+
const previous = await readWebState(io, recordName);
|
|
3808
|
+
const explicitlyChosen = suppliedKey ?? bodyKey;
|
|
3809
|
+
const concurrentCompletion = previous && typeof previous.finishedAtMs === "number" && previous.finishedAtMs >= invocationStartedAt;
|
|
3810
|
+
const sameAttempt = explicitlyChosen === void 0 || explicitlyChosen === previous?.idempotencyKey;
|
|
3811
|
+
if (previous && (concurrentCompletion && sameAttempt || ["unknown", "accepted"].includes(String(previous.operationOutcome)) && (explicitlyChosen === void 0 || explicitlyChosen === previous.idempotencyKey && operation.replaySafe !== true))) {
|
|
3812
|
+
throw usageError(operation.replaySafe === true ? "\u76F8\u540C\u8BF7\u6C42\u5DF2\u6709\u63D0\u4EA4\u8BB0\u5F55\uFF0C\u8BF7\u5148\u67E5\u8BE2\u539F\u64CD\u4F5C\uFF1B\u6062\u590D\u65F6\u4F7F\u7528\u539F\u5E42\u7B49\u952E\u548C\u539F\u53C2\u6570\u6587\u4EF6" : "\u76F8\u540C\u8BF7\u6C42\u5DF2\u6709\u63D0\u4EA4\u8BB0\u5F55\u4E14\u8BE5\u64CD\u4F5C\u4E0D\u652F\u6301\u5B89\u5168\u91CD\u653E\uFF1B\u8BF7\u5148\u67E5\u8BE2\u539F\u8D44\u6E90\u3002\u786E\u9700\u65B0\u5C1D\u8BD5\u65F6\u63D0\u4F9B\u65B0\u5E42\u7B49\u952E\u5E76\u6DFB\u52A0 --yes").withWebRecovery({
|
|
3813
|
+
...recovery,
|
|
3814
|
+
idempotencyKey: String(previous.idempotencyKey),
|
|
3815
|
+
operationOutcome: previous.operationOutcome,
|
|
3816
|
+
...typeof previous.taskId === "string" ? { taskId: previous.taskId } : {}
|
|
3817
|
+
});
|
|
3818
|
+
}
|
|
3819
|
+
recovery.operationOutcome = "unknown";
|
|
3820
|
+
await persist();
|
|
3821
|
+
}
|
|
3822
|
+
try {
|
|
3823
|
+
let authenticated;
|
|
3824
|
+
const result = await requestWeb(io, {
|
|
3825
|
+
baseUrl: caller.baseUrl,
|
|
3826
|
+
token: caller.token,
|
|
3827
|
+
workspaceId: workspace,
|
|
3828
|
+
path: target.path,
|
|
3829
|
+
method: operation.method,
|
|
3830
|
+
body: body.body,
|
|
3831
|
+
contentType: body.contentType,
|
|
3832
|
+
businessHeaders,
|
|
3833
|
+
idempotencyKey: key,
|
|
3834
|
+
timeoutMs,
|
|
3835
|
+
outPath: output,
|
|
3836
|
+
secretOutput,
|
|
3837
|
+
secrets,
|
|
3838
|
+
expectedFile: !secretOutput && (fileOperation(operation) || /\.(?:mp4|mov|webm|png|jpe?g|webp|mp3|wav|pdf|zip|vtt|srt)$/iu.test(output ?? "")),
|
|
3839
|
+
sessionResponse: operation.sessionResponse,
|
|
3840
|
+
onLogin: (response) => {
|
|
3841
|
+
authenticated = issuedSession(context, caller.baseUrl, response);
|
|
3842
|
+
},
|
|
3843
|
+
onTaskId: (taskId) => {
|
|
3844
|
+
recovery = { ...recovery, taskId, operationOutcome: "accepted" };
|
|
3845
|
+
},
|
|
3846
|
+
onEvent: (event) => {
|
|
3847
|
+
if (!out.json) out.notice(singleLine(JSON.stringify(event)));
|
|
3848
|
+
}
|
|
3849
|
+
});
|
|
3850
|
+
if (operation.sessionResponse && !authenticated) throw new CliError({ code: "CLI_BAD_RESPONSE", exitCode: EXIT.SERVER, message: "\u8BA4\u8BC1\u54CD\u5E94\u6CA1\u6709\u6709\u6548\u4F1A\u8BDD\uFF0C\u539F\u4F1A\u8BDD\u4FDD\u6301\u4E0D\u53D8" });
|
|
3851
|
+
if (authenticated) await writeWebState(io, "session.json", authenticated);
|
|
3852
|
+
recovery.operationOutcome = result.status === 202 || recovery.operationOutcome === "accepted" ? "accepted" : "completed";
|
|
3853
|
+
finishedAtMs = performance.timeOrigin + performance.now();
|
|
3854
|
+
if (mutating) await persist().catch(() => out.notice("\u64CD\u4F5C\u5DF2\u5B8C\u6210\uFF0C\u4F46\u672C\u5730\u6062\u590D\u8BB0\u5F55\u66F4\u65B0\u5931\u8D25\uFF1B\u8BF7\u4FDD\u5B58\u672C\u6B21\u7ED3\u679C\u4E0E\u5E42\u7B49\u952E\u3002"));
|
|
3855
|
+
const document = {
|
|
3856
|
+
...result,
|
|
3857
|
+
...key ? { idempotencyKey: key } : {},
|
|
3858
|
+
operationId: operation.id,
|
|
3859
|
+
...recovery.taskId ? { taskId: recovery.taskId } : {}
|
|
3860
|
+
};
|
|
3861
|
+
out.result([JSON.stringify(redactWebValue(document, caller.token ? [caller.token] : []), null, 2)], document);
|
|
3862
|
+
} catch (error) {
|
|
3863
|
+
const failure = toCliError(error);
|
|
3864
|
+
if (recovery.operationOutcome !== "accepted") recovery.operationOutcome = failure.httpStatus !== void 0 && failure.httpStatus >= 400 && failure.httpStatus < 500 && failure.httpStatus !== 408 ? "rejected" : "unknown";
|
|
3865
|
+
finishedAtMs = performance.timeOrigin + performance.now();
|
|
3866
|
+
if (mutating) await persist().catch(() => void 0);
|
|
3867
|
+
throw failure.withWebRecovery(recovery);
|
|
3868
|
+
}
|
|
3869
|
+
} finally {
|
|
3870
|
+
await release2?.();
|
|
3871
|
+
}
|
|
3872
|
+
}
|
|
3873
|
+
|
|
3874
|
+
// src/commands/studio-actions.ts
|
|
3875
|
+
import { basename as basename4 } from "node:path";
|
|
3876
|
+
|
|
2342
3877
|
// src/client-creative.ts
|
|
2343
3878
|
function creativePath(resource, id, suffix = "") {
|
|
2344
3879
|
const prefix = resource === "drama" ? "drama/orders" : resource;
|
|
@@ -2384,13 +3919,13 @@ function idOf(context) {
|
|
|
2384
3919
|
return id.trim();
|
|
2385
3920
|
}
|
|
2386
3921
|
async function dramaCreative(context) {
|
|
2387
|
-
const [
|
|
3922
|
+
const [action2] = context.args;
|
|
2388
3923
|
const id = idOf(context);
|
|
2389
3924
|
const { baseUrl, apiKey } = await resolveApiKey(context);
|
|
2390
3925
|
const { io, out, values } = context;
|
|
2391
|
-
if (["context", "director", "document", "versions"].includes(
|
|
2392
|
-
let suffix2 =
|
|
2393
|
-
if (
|
|
3926
|
+
if (["context", "director", "document", "versions"].includes(action2)) {
|
|
3927
|
+
let suffix2 = action2;
|
|
3928
|
+
if (action2 === "document") {
|
|
2394
3929
|
const query = new URLSearchParams({ kind: textOption(values, "kind") ?? "screenplay_snapshot" });
|
|
2395
3930
|
const episode = textOption(values, "episode-number");
|
|
2396
3931
|
if (episode) query.set("episodeNumber", episode);
|
|
@@ -2401,7 +3936,7 @@ async function dramaCreative(context) {
|
|
|
2401
3936
|
return;
|
|
2402
3937
|
}
|
|
2403
3938
|
const body = await creativeData(context);
|
|
2404
|
-
if (
|
|
3939
|
+
if (action2 === "director-confirm") {
|
|
2405
3940
|
const confirmationId = textOption(values, "confirmation-id") ?? body.confirmationId;
|
|
2406
3941
|
const suppliedKind = textOption(values, "kind") ?? body.kind;
|
|
2407
3942
|
if (typeof confirmationId !== "string" || !confirmationId) throw usageError("\u8BF7\u4F7F\u7528 drama director \u4E2D\u5F53\u524D\u786E\u8BA4\u5361\u7684 --confirmation-id");
|
|
@@ -2431,7 +3966,7 @@ async function dramaCreative(context) {
|
|
|
2431
3966
|
throw failure.withRecovery({ ...dramaConfirmationRecovery(id, void 0, baseUrl, key2, "unknown"), ...failure.recovery, confirmation: { kind, confirmationId } });
|
|
2432
3967
|
}
|
|
2433
3968
|
}
|
|
2434
|
-
if (
|
|
3969
|
+
if (action2 === "redo") {
|
|
2435
3970
|
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
3971
|
const quote3 = body.quote && typeof body.quote === "object" ? creativeObject(body.quote) : body;
|
|
2437
3972
|
const required3 = ["redoQuoteId", "redoPlanHash", "redoQuoteHash"];
|
|
@@ -2444,22 +3979,22 @@ async function dramaCreative(context) {
|
|
|
2444
3979
|
const epoch = textOption(values, "expected-epoch");
|
|
2445
3980
|
if (epoch !== void 0) body.expectedProductionEpoch = Number(epoch);
|
|
2446
3981
|
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 =
|
|
2448
|
-
if (
|
|
3982
|
+
let suffix = action2;
|
|
3983
|
+
if (action2 === "message") {
|
|
2449
3984
|
const text = textOption(values, "text");
|
|
2450
3985
|
if (text !== void 0) body.text = text;
|
|
2451
3986
|
if (typeof body.text !== "string" || !body.text.trim()) throw usageError("\u8BF7\u63D0\u4F9B --text \u6216 --data.text");
|
|
2452
3987
|
suffix = "messages";
|
|
2453
|
-
} else if (
|
|
3988
|
+
} else if (action2 === "spec") {
|
|
2454
3989
|
const model = textOption(values, "model"), resolution = textOption(values, "resolution");
|
|
2455
3990
|
if (model !== void 0) body.videoModel = model;
|
|
2456
3991
|
if (resolution !== void 0) body.resolution = resolution;
|
|
2457
|
-
} else if (
|
|
3992
|
+
} else if (action2 === "select-version") {
|
|
2458
3993
|
body.shotId = textOption(values, "shot") ?? body.shotId;
|
|
2459
3994
|
const selected = textOption(values, "output-id");
|
|
2460
3995
|
if (selected !== void 0) body.renderOutputId = selected === "default" ? null : selected;
|
|
2461
3996
|
suffix = "selection";
|
|
2462
|
-
} else if (
|
|
3997
|
+
} else if (action2 === "redo-quote") {
|
|
2463
3998
|
const shot = textOption(values, "shot");
|
|
2464
3999
|
if (shot !== void 0) body.shotIds = shot.split(",").map((value) => value.trim());
|
|
2465
4000
|
suffix = "redo/quote";
|
|
@@ -2476,23 +4011,325 @@ async function creativeDownload(context, resource, id, suffix) {
|
|
|
2476
4011
|
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
4012
|
}
|
|
2478
4013
|
|
|
4014
|
+
// src/commands/studio-actions.ts
|
|
4015
|
+
var video = "/api/open/v1/videos/:id";
|
|
4016
|
+
var drama = "/api/open/v1/drama/orders/:id";
|
|
4017
|
+
var pagination = { limit: "limit", offset: "offset", cursor: "cursor" };
|
|
4018
|
+
var action = (resource, command, path, method, description, extra = {}) => ({ resource, command, path, method, description, needsYes: method !== "GET", ...extra });
|
|
4019
|
+
var v = (command, suffix, method, description, extra = {}) => action("videos", command, `${video}/${suffix}`, method, description, extra);
|
|
4020
|
+
var STUDIO_ACTIONS = [
|
|
4021
|
+
action("videos", "list", "/api/open/v1/videos", "GET", "\u5217\u51FA\u5546\u54C1\u89C6\u9891", { query: { limit: "limit", cursor: "cursor", actionable: "actionable" } }),
|
|
4022
|
+
...["methods", "play-cards", "inspirations"].map((kind) => action("videos", kind, `/api/open/v1/video-catalog/${kind}`, "GET", "\u67E5\u8BE2\u521B\u4F5C\u76EE\u5F55")),
|
|
4023
|
+
v("settings", "settings", "POST", "\u4FEE\u6539\u5F53\u524D\u89C4\u683C", { body: ["expectedVersion", "patch"] }),
|
|
4024
|
+
v("retry", "retry-failed-step", "POST", "\u6062\u590D\u672A\u5B8C\u6210\u6B65\u9AA4\u6216\u786E\u8BA4\u5173\u952E\u5E27\u91CD\u505A", { body: ["expectedVersion"] }),
|
|
4025
|
+
v("product-image-resume", "product-image-resume", "POST", "\u8865\u5145\u4EA7\u54C1\u56FE\u540E\u6062\u590D", { body: ["expectedVersion"] }),
|
|
4026
|
+
v("product-lock-confirm", "product-lock-confirm", "POST", "\u786E\u8BA4\u672C\u5355\u5546\u54C1\u5916\u89C2", { body: ["expectedVersion"] }),
|
|
4027
|
+
v("asset-options", "asset-gaps/:gapId/options", "GET", "\u67E5\u8BE2\u7D20\u6750\u804C\u8D23\u7684\u5019\u9009", { query: { ...pagination, q: "q", source: "source", "asset-id": "assetId" } }),
|
|
4028
|
+
v("asset-resolve", "asset-gaps/:gapId/resolve", "POST", "\u6309\u5F53\u524D\u804C\u8D23\u9009\u7D20\u6750\u6216\u786E\u8BA4\u751F\u6210", { body: ["action", "expectedVersion"] }),
|
|
4029
|
+
v("asset-resolve-batch", "asset-gaps/resolve-batch", "POST", "\u6279\u91CF\u91C7\u7528\u73B0\u6709\u804C\u8D23\u7D20\u6750", { body: ["expectedVersion", "items"] }),
|
|
4030
|
+
v("asset-upload", "asset-gaps/:gapId/upload", "PUT", "\u4E0A\u4F20\u672C\u5355\u804C\u8D23\u7D20\u6750", { fileType: "image", query: { "expected-version": "expectedVersion" } }),
|
|
4031
|
+
v("asset-adopt", "asset-gaps/:gapId/adopt-uploaded", "POST", "\u91C7\u7528\u672C\u5355\u5DF2\u4E0A\u4F20\u7D20\u6750", { body: ["expectedVersion", "kind", "id"] }),
|
|
4032
|
+
v("file", "files/:path", "GET", "\u8BFB\u53D6\u5F53\u524D\u6587\u7A3F"),
|
|
4033
|
+
v("file-versions", "files/:path/versions", "GET", "\u5217\u51FA\u6587\u7A3F\u5386\u53F2", { query: { limit: "limit", cursor: "cursor" } }),
|
|
4034
|
+
v("file-version", "files/:path/versions/:versionId", "GET", "\u8BFB\u53D6\u4E00\u7248\u6587\u7A3F"),
|
|
4035
|
+
v("file-compare", "files/:path/versions/compare", "GET", "\u6BD4\u8F83\u4E24\u7248\u6587\u7A3F", { query: { "base-version": "baseVersionId", "target-version": "targetVersionId", cursor: "cursor" } }),
|
|
4036
|
+
v("file-restore", "files/:path/versions/:versionId/restore", "POST", "\u6062\u590D\u6307\u5B9A\u6587\u7A3F\u7248\u672C", { body: ["expectedCurrentVersionId"] }),
|
|
4037
|
+
v("confirm-image", "confirm-image", "POST", "\u6309\u5F53\u524D\u56FE\u5361\u660E\u786E\u786E\u8BA4\u751F\u6210", { body: ["expectedVersion", "confirmation"], confirmation: true }),
|
|
4038
|
+
v("subtitles", "subtitles", "GET", "\u67E5\u8BE2\u6574\u7247\u5B57\u5E55\u5F00\u5173"),
|
|
4039
|
+
v("subtitles-set", "subtitles", "PUT", "\u8BBE\u7F6E\u6574\u7247\u5B57\u5E55\u5F00\u5173", { body: ["enabled"] }),
|
|
4040
|
+
v("production-preview", "production-preview", "GET", "\u67E5\u770B\u5F53\u524D\u5F00\u62CD\u5361\u7684\u9010\u6BB5\u9884\u89C8"),
|
|
4041
|
+
v("public-references", "public-reference-candidates", "GET", "\u67E5\u770B\u516C\u5F00\u53C2\u8003\u5019\u9009"),
|
|
4042
|
+
v("public-reference-decide", "public-reference-candidates/:assetId/decision", "PUT", "\u786E\u8BA4\u6216\u62D2\u7EDD\u516C\u5F00\u53C2\u8003", { body: ["decision", "expectedVersion"] }),
|
|
4043
|
+
v("voices", "voice-candidates", "GET", "\u67E5\u770B\u89D2\u8272\u58F0\u97F3\u5019\u9009"),
|
|
4044
|
+
v("platform-voices", "platform-voices", "GET", "\u67E5\u770B\u5E73\u53F0\u58F0\u97F3"),
|
|
4045
|
+
v("voice-import", "voice-candidates", "POST", "\u5BFC\u5165\u5DF2\u6709\u58F0\u97F3\u6765\u6E90", { fileType: "voice" }),
|
|
4046
|
+
v("voice-preset", "voice-candidates/preset", "POST", "\u91C7\u7528\u5E73\u53F0\u6837\u97F3\u6216\u7533\u8BF7\u8BD5\u542C", { body: ["voiceId"] }),
|
|
4047
|
+
v("voice-select", "voice-selection", "PUT", "\u9009\u62E9\u6216\u53D6\u6D88\u89D2\u8272\u58F0\u97F3", { body: ["roleKey", "candidateId", "expectedVersion"] }),
|
|
4048
|
+
v("voice-continue", "voice-selection/continue", "POST", "\u6309\u5DF2\u9009\u58F0\u97F3\u7EE7\u7EED", { body: ["expectedVersion"] }),
|
|
4049
|
+
v("motion-references", "motion-references", "GET", "\u67E5\u770B\u52A8\u4F5C\u53C2\u8003"),
|
|
4050
|
+
v("motion-prepare", "motion-references", "POST", "\u88C1\u526A\u5DF2\u4E0A\u4F20\u7684\u52A8\u4F5C\u53C2\u8003", { body: ["attachmentId", "startSeconds", "endSeconds"] }),
|
|
4051
|
+
v("motion-select", "motion-references/:candidateId/select", "POST", "\u5C06\u52A8\u4F5C\u53C2\u8003\u7ED1\u5B9A\u5F53\u524D\u955C\u5934", { body: ["shotIds"] }),
|
|
4052
|
+
v("image-edits", "image-edits", "GET", "\u5217\u51FA\u56FE\u7247\u7F16\u8F91\u548C\u5C40\u90E8\u4FEE\u6539\u4EFB\u52A1"),
|
|
4053
|
+
v("image-edit-save", "image-edits/:sourceKind/:sourceId", "PUT", "\u4FDD\u5B58\u672C\u5730\u7F16\u8F91\u540E\u7684\u56FE\u7247", { fileType: "image" }),
|
|
4054
|
+
v("area-quote", "image-edits/area/quote", "POST", "\u4E3A\u8499\u7248\u9009\u533A\u4FEE\u6539\u62A5\u4EF7", { fileType: "mask", body: ["sourceKind", "sourceId", "prompt"] }),
|
|
4055
|
+
v("area-status", "image-edits/area/:quoteId", "GET", "\u67E5\u8BE2\u9009\u533A\u62A5\u4EF7\u53CA\u5236\u4F5C\u72B6\u6001"),
|
|
4056
|
+
v("area-confirm", "image-edits/area/confirm", "POST", "\u786E\u8BA4\u5F53\u524D\u9009\u533A\u62A5\u4EF7", { body: ["quoteId"], confirmation: true }),
|
|
4057
|
+
v("append-retry-join", "append-tasks/:taskId/retry-join", "POST", "\u6062\u590D\u5DF2\u6709\u63D2\u7247\u7684\u514D\u8D39\u62FC\u63A5"),
|
|
4058
|
+
v("stop", "stop", "POST", "\u8BF7\u6C42\u505C\u6B62\u5C1A\u672A\u6267\u884C\u7684\u540E\u7EED\u6B65\u9AA4"),
|
|
4059
|
+
v("events", "live", "GET", "\u8BA2\u9605\u6709\u754C\u5B9E\u65F6\u8FDB\u5EA6", { events: true }),
|
|
4060
|
+
v("message-stream", "messages/stream", "POST", "\u53D1\u9001\u6D88\u606F\u5E76\u8BA2\u9605\u56DE\u5408\u4E8B\u4EF6", { events: true, body: ["text"] }),
|
|
4061
|
+
...[
|
|
4062
|
+
["storyboard-download", "storyboards/:imageKey/download", "image", "\u4E0B\u8F7D\u5173\u952E\u5E27"],
|
|
4063
|
+
["image-download", "images/:assetId/download", "image", "\u4E0B\u8F7D\u4EBA\u7269\u6216\u573A\u666F\u56FE\u7247"],
|
|
4064
|
+
["image-edit-download", "image-edits/:editId/download", "image", "\u4E0B\u8F7D\u56FE\u7247\u7F16\u8F91\u7248"],
|
|
4065
|
+
["area-mask", "image-edits/area/:quoteId/mask", "image", "\u4E0B\u8F7D\u9009\u533A\u8499\u7248"],
|
|
4066
|
+
["area-preview", "image-edits/area/:jobId/preview", "image", "\u4E0B\u8F7D\u5C40\u90E8\u4FEE\u6539\u9884\u89C8"],
|
|
4067
|
+
["edit-subtitles", "edits/:editId/subtitles", "vtt", "\u4E0B\u8F7D\u526A\u8F91\u7248\u5B57\u5E55"],
|
|
4068
|
+
["platform-voice-download", "platform-voices/:voiceId/audio", "audio", "\u4E0B\u8F7D\u5E73\u53F0\u58F0\u97F3\u8BD5\u542C"],
|
|
4069
|
+
["voice-sample-download", "voice-presets/:voiceId/sample", "audio", "\u4E0B\u8F7D\u5E73\u53F0\u6837\u97F3"],
|
|
4070
|
+
["voice-library-download", "voice-library/:candidateId/audio", "audio", "\u4E0B\u8F7D\u58F0\u97F3\u5E93\u7D20\u6750"],
|
|
4071
|
+
["voice-download", "voice-candidates/:candidateId/audio", "audio", "\u4E0B\u8F7D\u5019\u9009\u58F0\u97F3"],
|
|
4072
|
+
["voice-preview-download", "voiceover/previews/:previewId/audio", "audio", "\u4E0B\u8F7D\u914D\u97F3\u8BD5\u542C"],
|
|
4073
|
+
["motion-download", "motion-references/:candidateId/video", "video", "\u4E0B\u8F7D\u52A8\u4F5C\u53C2\u8003\u7247\u6BB5"],
|
|
4074
|
+
["segment-download", "production-segments/:index/download", "video", "\u4E0B\u8F7D\u5DF2\u5B8C\u6210\u5236\u4F5C\u7247\u6BB5"]
|
|
4075
|
+
].map(([command, path, download4, description]) => v(command, path, "GET", description, { download: download4 })),
|
|
4076
|
+
action("graphic", "stop", "/api/open/v1/graphic/runs/:id/stop", "POST", "\u505C\u6B62\u5F53\u524D\u56FE\u6587\u5BFC\u6F14\u56DE\u5408"),
|
|
4077
|
+
action("drama", "stop", `${drama}/director/stop`, "POST", "\u505C\u6B62\u5F53\u524D\u77ED\u5267\u5BFC\u6F14\u56DE\u5408"),
|
|
4078
|
+
action("drama", "script-versions", `${drama}/screenplay/versions`, "GET", "\u5217\u51FA\u5267\u672C\u6587\u7A3F\u7248\u672C", { query: { limit: "limit" } }),
|
|
4079
|
+
action("drama", "script-version", `${drama}/screenplay/versions/:documentId`, "GET", "\u67E5\u770B\u4E00\u7248\u5267\u672C\u6587\u7A3F"),
|
|
4080
|
+
action("drama", "script-compare", `${drama}/screenplay/versions/compare`, "GET", "\u6BD4\u8F83\u4E24\u7248\u5267\u672C\u6587\u7A3F", { query: { "base-version": "baseDocumentId", "target-version": "targetDocumentId", "max-changes": "maxChanges" } }),
|
|
4081
|
+
action("drama", "script-restore", `${drama}/screenplay/versions/:documentId/restore`, "POST", "\u6062\u590D\u6307\u5B9A\u5267\u672C\u6587\u7A3F", { body: ["expectedCurrentDocumentId", "expectedProductionEpoch"] }),
|
|
4082
|
+
action("drama", "edit-sources", `${drama}/edit-sources`, "GET", "\u67E5\u8BE2\u53EF\u526A\u8F91\u7684\u539F\u7247", { query: { "source-output-id": "sourceEpisodeOutputId" } }),
|
|
4083
|
+
action("drama", "speech-adoptions", `${drama}/speech/adoptions`, "GET", "\u67E5\u8BE2\u5DF2\u91C7\u7528\u7684\u914D\u97F3"),
|
|
4084
|
+
action("drama", "edit-subtitles", `${drama}/edits/:editId/subtitles`, "GET", "\u4E0B\u8F7D\u77ED\u5267\u526A\u8F91\u7248\u5B57\u5E55", { download: "vtt" }),
|
|
4085
|
+
action("series", "outline", "/api/open/v1/series/:id/outline", "GET", "\u67E5\u770B\u5267\u96C6\u5927\u7EB2"),
|
|
4086
|
+
action("series", "outline-approve", "/api/open/v1/series/:id/outline/:documentId/approve", "POST", "\u786E\u8BA4\u5927\u7EB2\u5E76\u7EE7\u7EED\u51C6\u5907", { body: ["expectedProductionEpoch"] })
|
|
4087
|
+
];
|
|
4088
|
+
var pathOptions = {
|
|
4089
|
+
gapId: "gap-id",
|
|
4090
|
+
path: "path",
|
|
4091
|
+
versionId: "version-id",
|
|
4092
|
+
candidateId: "candidate-id",
|
|
4093
|
+
taskId: "task-id",
|
|
4094
|
+
documentId: "document-id",
|
|
4095
|
+
assetId: "asset-id",
|
|
4096
|
+
sourceKind: "source-kind",
|
|
4097
|
+
sourceId: "source-id",
|
|
4098
|
+
quoteId: "quote-id",
|
|
4099
|
+
editId: "edit-id",
|
|
4100
|
+
imageKey: "image-key",
|
|
4101
|
+
jobId: "job-id",
|
|
4102
|
+
voiceId: "voice-id",
|
|
4103
|
+
previewId: "preview-id",
|
|
4104
|
+
index: "index"
|
|
4105
|
+
};
|
|
4106
|
+
var STUDIO_ACTION_OPTIONS = [.../* @__PURE__ */ new Set([
|
|
4107
|
+
"yes",
|
|
4108
|
+
"data",
|
|
4109
|
+
"file",
|
|
4110
|
+
"mime",
|
|
4111
|
+
"out",
|
|
4112
|
+
"idempotency-key",
|
|
4113
|
+
"timeout",
|
|
4114
|
+
"text",
|
|
4115
|
+
"expected-version",
|
|
4116
|
+
"expected-epoch",
|
|
4117
|
+
"expected-current-version",
|
|
4118
|
+
"expected-current-document",
|
|
4119
|
+
"expected-credits",
|
|
4120
|
+
"enabled",
|
|
4121
|
+
...Object.values(pathOptions),
|
|
4122
|
+
...STUDIO_ACTIONS.flatMap((item) => Object.keys(item.query ?? {}))
|
|
4123
|
+
])];
|
|
4124
|
+
function STUDIO_ACTION_HELP(resource) {
|
|
4125
|
+
return [
|
|
4126
|
+
"",
|
|
4127
|
+
"\u5DE5\u4F5C\u53F0\u6269\u5C55\u547D\u4EE4\uFF1A",
|
|
4128
|
+
...STUDIO_ACTIONS.filter((item) => item.resource === resource).map((item) => ` buke ${resource} ${item.command}${item.path.includes(":id") ? " <id>" : ""} ${[...item.path.matchAll(/:([A-Za-z]+)/gu)].filter((match) => match[1] !== "id").map((match) => `--${pathOptions[match[1]] ?? match[1]} <\u503C>`).join(" ")}${item.needsYes ? " --yes" : ""} ${item.description}`),
|
|
4129
|
+
" --data <JSON\u6587\u4EF6> \u8BF7\u6C42\u6B63\u6587\uFF1B--file <\u6587\u4EF6> \u4E0A\u4F20\uFF1B--out <\u8DEF\u5F84> \u4E0B\u8F7D\uFF1B--timeout <\u79D2> \u6709\u754C\u7B49\u5F85",
|
|
4130
|
+
" \u5199\u5165\u9700 --yes\uFF1B\u6536\u8D39\u786E\u8BA4\u5FC5\u987B\u63D0\u4F9B\u5DF2\u67E5\u770B\u7684\u62A5\u4EF7\u8EAB\u4EFD\uFF0CCLI \u4E0D\u81EA\u52A8\u63A5\u53D7\u65B0\u62A5\u4EF7\u3002"
|
|
4131
|
+
].join("\n");
|
|
4132
|
+
}
|
|
4133
|
+
function segment(value, label) {
|
|
4134
|
+
if (!value?.trim() || value === "." || value === ".." || new RegExp("\\p{Cc}", "u").test(value) || value.length > 512) throw usageError(`\u8BF7\u63D0\u4F9B\u6709\u6548\u7684 ${label}`);
|
|
4135
|
+
return encodeURIComponent(value);
|
|
4136
|
+
}
|
|
4137
|
+
function numberOption(context, name2) {
|
|
4138
|
+
const value = textOption(context.values, name2);
|
|
4139
|
+
if (value === void 0) return void 0;
|
|
4140
|
+
const number = Number(value);
|
|
4141
|
+
if (!Number.isSafeInteger(number) || number < 0) throw usageError(`--${name2} \u5FC5\u987B\u4E3A\u975E\u8D1F\u6574\u6570`);
|
|
4142
|
+
return number;
|
|
4143
|
+
}
|
|
4144
|
+
function requestPath(spec, context) {
|
|
4145
|
+
const path = spec.path.replace(/:([A-Za-z]+)/gu, (_match, name2) => segment(name2 === "id" ? context.args[1] : textOption(context.values, pathOptions[name2] ?? name2), name2 === "id" ? "\u9879\u76EE\u7F16\u53F7" : `--${pathOptions[name2] ?? name2}`));
|
|
4146
|
+
const query = new URLSearchParams();
|
|
4147
|
+
for (const [option, field] of Object.entries(spec.query ?? {})) {
|
|
4148
|
+
const value = textOption(context.values, option);
|
|
4149
|
+
if (value !== void 0) query.set(field, value);
|
|
4150
|
+
}
|
|
4151
|
+
if ((spec.command === "file-compare" || spec.command === "script-compare") && (!textOption(context.values, "base-version") || !textOption(context.values, "target-version"))) throw usageError("\u6BD4\u8F83\u7248\u672C\u9700\u8981 --base-version \u548C --target-version");
|
|
4152
|
+
if (spec.command === "asset-upload" && textOption(context.values, "expected-version") === void 0) throw usageError("\u4E0A\u4F20\u804C\u8D23\u7D20\u6750\u9700\u8981 --expected-version");
|
|
4153
|
+
return path + (query.size ? `?${query}` : "");
|
|
4154
|
+
}
|
|
4155
|
+
async function requestBody2(spec, context) {
|
|
4156
|
+
const body = await creativeData(context);
|
|
4157
|
+
for (const field of ["ownerId", "workspaceId", "allowPaidConfirmation"]) if (field in body) throw usageError(`--data \u4E0D\u80FD\u63D0\u4F9B ${field}\uFF1B\u5F52\u5C5E\u53CA\u6388\u6743\u7531\u5BC6\u94A5\u51B3\u5B9A`);
|
|
4158
|
+
for (const [option, field] of [["expected-version", "expectedVersion"], ["expected-epoch", "expectedProductionEpoch"], ["expected-credits", "expectedCredits"]]) {
|
|
4159
|
+
const value = numberOption(context, option);
|
|
4160
|
+
if (value !== void 0) body[field] = value;
|
|
4161
|
+
}
|
|
4162
|
+
for (const [option, field] of [["text", "text"], ["quote-id", "quoteId"], ["expected-current-version", "expectedCurrentVersionId"], ["expected-current-document", "expectedCurrentDocumentId"]]) {
|
|
4163
|
+
const value = textOption(context.values, option);
|
|
4164
|
+
if (value !== void 0) body[field] = value;
|
|
4165
|
+
}
|
|
4166
|
+
if (spec.command === "subtitles-set") {
|
|
4167
|
+
const enabled2 = textOption(context.values, "enabled");
|
|
4168
|
+
if (enabled2 !== void 0) {
|
|
4169
|
+
if (enabled2 !== "true" && enabled2 !== "false") throw usageError("--enabled \u53EA\u80FD\u662F true \u6216 false");
|
|
4170
|
+
body.enabled = enabled2 === "true";
|
|
4171
|
+
}
|
|
4172
|
+
}
|
|
4173
|
+
for (const field of spec.body ?? []) if (!(field in body)) throw usageError(`\u8BF7\u5728 --data \u4E2D\u63D0\u4F9B ${field}`);
|
|
4174
|
+
if (spec.confirmation || spec.command === "retry" && body.storyboardTaskId || spec.command === "asset-resolve" && body.action === "generate_personal") body.confirmed = true;
|
|
4175
|
+
if (spec.command === "retry" && body.storyboardTaskId || spec.command === "asset-resolve" && body.action === "generate_personal") {
|
|
4176
|
+
if (!Number.isSafeInteger(body.expectedCredits) || Number(body.expectedCredits) <= 0) throw usageError("\u6536\u8D39\u64CD\u4F5C\u5FC5\u987B\u63D0\u4F9B\u5F53\u524D\u5361\u4E0A\u7684 expectedCredits");
|
|
4177
|
+
}
|
|
4178
|
+
return body;
|
|
4179
|
+
}
|
|
4180
|
+
var mimeTypes = {
|
|
4181
|
+
image: ["image/png", "image/jpeg", "image/webp"],
|
|
4182
|
+
video: ["video/mp4", "video/quicktime"],
|
|
4183
|
+
audio: ["audio/wav", "audio/x-wav", "audio/mpeg", "audio/mp4", "audio/aac", "audio/ogg"],
|
|
4184
|
+
vtt: ["text/vtt", "application/x-subrip"]
|
|
4185
|
+
};
|
|
4186
|
+
async function tryStudioAction(resource, context) {
|
|
4187
|
+
const spec = STUDIO_ACTIONS.find((item) => item.resource === resource && item.command === context.args[0]);
|
|
4188
|
+
if (!spec) return false;
|
|
4189
|
+
if (spec.needsYes && context.values.yes !== true) throw usageError("\u8BF7\u5148\u6838\u5BF9\u64CD\u4F5C\u8303\u56F4\u548C\u8D39\u7528\uFF0C\u6DFB\u52A0 --yes \u540E\u63D0\u4EA4");
|
|
4190
|
+
const path = requestPath(spec, context);
|
|
4191
|
+
const body = spec.method !== "GET" ? await requestBody2(spec, context) : {};
|
|
4192
|
+
const filePath = textOption(context.values, "file");
|
|
4193
|
+
if (spec.fileType && spec.fileType !== "voice" && !filePath) throw usageError("\u8BF7\u63D0\u4F9B --file <\u672C\u5730\u6587\u4EF6>");
|
|
4194
|
+
const upload3 = spec.fileType && filePath ? await readUploadFile(filePath) : void 0;
|
|
4195
|
+
const { baseUrl, apiKey } = await resolveApiKey(context);
|
|
4196
|
+
const id = context.args[1] ?? "", key = spec.method === "GET" ? void 0 : idempotencyKeyOf(context.values);
|
|
4197
|
+
const perform = async () => {
|
|
4198
|
+
if (spec.events) return studioEvents(baseUrl, apiKey, path, spec.method, body, key, context);
|
|
4199
|
+
if (spec.download) {
|
|
4200
|
+
const file = await downloadAssetFile(baseUrl, apiKey, path, context.io, { allowedMimeTypes: mimeTypes[spec.download] });
|
|
4201
|
+
const filename = file.filename ?? `${resource}-${spec.command}-${id || "output"}.${spec.download === "vtt" ? "vtt" : spec.download === "audio" ? "wav" : spec.download === "video" ? "mp4" : "png"}`;
|
|
4202
|
+
const download4 = await saveDownload(textOption(context.values, "out") ?? filename, file.bytes);
|
|
4203
|
+
return { download: { ...download4, filename } };
|
|
4204
|
+
}
|
|
4205
|
+
let response;
|
|
4206
|
+
if (spec.method === "GET") response = await getJson(baseUrl, apiKey, path, context.io);
|
|
4207
|
+
else if (upload3) {
|
|
4208
|
+
let bytes = upload3.bytes, contentType = textOption(context.values, "mime") ?? upload3.contentType;
|
|
4209
|
+
if (spec.fileType === "mask" || spec.fileType === "voice") {
|
|
4210
|
+
const form = new FormData();
|
|
4211
|
+
form.set(spec.fileType === "mask" ? "mask" : "file", new Blob([new Uint8Array(upload3.bytes)], { type: contentType ?? "application/octet-stream" }), basename4(filePath));
|
|
4212
|
+
for (const [name2, value] of Object.entries(body)) if (value !== void 0 && value !== null) form.set(name2, typeof value === "object" ? JSON.stringify(value) : String(value));
|
|
4213
|
+
const prepared = new Request("https://multipart.invalid", { method: "POST", body: form });
|
|
4214
|
+
bytes = new Uint8Array(await prepared.arrayBuffer());
|
|
4215
|
+
contentType = prepared.headers.get("content-type");
|
|
4216
|
+
}
|
|
4217
|
+
response = await (spec.method === "PUT" ? putRaw : postRaw)(baseUrl, apiKey, path, bytes, contentType, key, context.io);
|
|
4218
|
+
} else if (spec.method === "PUT") response = await putRaw(baseUrl, apiKey, path, Buffer.from(JSON.stringify(body)), "application/json", key, context.io);
|
|
4219
|
+
else response = await postJson(baseUrl, apiKey, path, body, key, context.io, { timeoutMs: timeoutSecondsOf(context.values, 120) * 1e3 });
|
|
4220
|
+
if (!response.body || typeof response.body !== "object" || Array.isArray(response.body)) throw new CliError({ code: "CLI_BAD_RESPONSE", message: "\u670D\u52A1\u7AEF\u6CA1\u6709\u8FD4\u56DE\u6709\u6548\u5BF9\u8C61", exitCode: EXIT.SERVER });
|
|
4221
|
+
return response.body;
|
|
4222
|
+
};
|
|
4223
|
+
const result = key ? await retainMutationOnError(resource, id, key, baseUrl, perform) : await perform();
|
|
4224
|
+
const output = { ...result, ...key ? { idempotencyKey: key } : {} };
|
|
4225
|
+
context.out.result([JSON.stringify(result, null, 2), ...key ? [`\u5E42\u7B49\u952E\uFF1A${key}`] : []], output);
|
|
4226
|
+
return true;
|
|
4227
|
+
}
|
|
4228
|
+
async function studioEvents(baseUrl, apiKey, path, method, body, key, context) {
|
|
4229
|
+
const origin = normalizeBaseUrl(baseUrl);
|
|
4230
|
+
assertKeyFormat(apiKey);
|
|
4231
|
+
assertReachedDirectly(origin, context.io.env);
|
|
4232
|
+
const timeout = timeoutSecondsOf(context.values, 30);
|
|
4233
|
+
if (timeout > 600) throw usageError("\u5B9E\u65F6\u4E8B\u4EF6\u5355\u6B21\u6700\u591A\u7B49\u5F85 600 \u79D2");
|
|
4234
|
+
const controller = new AbortController(), events = [];
|
|
4235
|
+
let timedOut = false, completed = false, accepted = false, reader;
|
|
4236
|
+
const recovery = () => ({
|
|
4237
|
+
...taskRecovery("videos", context.args[1] ?? "", void 0, baseUrl),
|
|
4238
|
+
...key ? { idempotencyKey: key, operationOutcome: accepted ? "accepted" : "unknown" } : {}
|
|
4239
|
+
});
|
|
4240
|
+
const stop = () => controller.abort();
|
|
4241
|
+
if (context.io.signal?.aborted) throw interruptedError();
|
|
4242
|
+
context.io.signal?.addEventListener("abort", stop, { once: true });
|
|
4243
|
+
const timer = setTimeout(() => {
|
|
4244
|
+
timedOut = true;
|
|
4245
|
+
controller.abort();
|
|
4246
|
+
}, timeout * 1e3);
|
|
4247
|
+
try {
|
|
4248
|
+
const response = await context.io.fetch(`${origin}${path}`, {
|
|
4249
|
+
method,
|
|
4250
|
+
redirect: "manual",
|
|
4251
|
+
signal: controller.signal,
|
|
4252
|
+
headers: { Authorization: `Bearer ${apiKey}`, Accept: "text/event-stream", ...key ? { "Idempotency-Key": key, "Content-Type": "application/json" } : {} },
|
|
4253
|
+
...method === "GET" ? {} : { body: JSON.stringify(body) }
|
|
4254
|
+
});
|
|
4255
|
+
if (response.status >= 300 && response.status < 400) throw new CliError({ code: "CLI_REDIRECT", message: "\u670D\u52A1\u7AEF\u8DF3\u8F6C\u5DF2\u62D2\u7EDD\uFF0C\u5BC6\u94A5\u6CA1\u6709\u8F6C\u53D1", exitCode: EXIT.SERVER });
|
|
4256
|
+
if (!response.ok) throw new CliError({
|
|
4257
|
+
code: "CLI_EVENT_HTTP_ERROR",
|
|
4258
|
+
message: `\u5B9E\u65F6\u4E8B\u4EF6\u8BF7\u6C42\u8FD4\u56DE HTTP ${response.status}\uFF0C\u8BF7\u67E5\u8BE2\u539F\u4EFB\u52A1`,
|
|
4259
|
+
httpStatus: response.status,
|
|
4260
|
+
exitCode: exitCodeForHttpStatus(response.status),
|
|
4261
|
+
retryable: response.status === 429 || response.status >= 500
|
|
4262
|
+
});
|
|
4263
|
+
if (response.headers.get("content-type")?.split(";")[0] !== "text/event-stream" || !response.body) throw new CliError({ code: "CLI_BAD_RESPONSE", message: "\u670D\u52A1\u7AEF\u672A\u8FD4\u56DE\u4E8B\u4EF6\u6D41", exitCode: EXIT.SERVER });
|
|
4264
|
+
accepted = true;
|
|
4265
|
+
reader = response.body.getReader();
|
|
4266
|
+
const decoder = new TextDecoder();
|
|
4267
|
+
let pending = "", size = 0;
|
|
4268
|
+
stream: for (; ; ) {
|
|
4269
|
+
const next = await reader.read();
|
|
4270
|
+
if (next.done) break;
|
|
4271
|
+
size += next.value.byteLength;
|
|
4272
|
+
if (size > 4 * 1024 * 1024 || events.length >= 1e3) throw new CliError({ code: "CLI_EVENT_LIMIT", message: "\u672C\u6B21\u4E8B\u4EF6\u5DF2\u8FBE\u5230\u8BFB\u53D6\u4E0A\u9650\uFF0C\u8BF7\u67E5\u8BE2\u5F53\u524D\u4EFB\u52A1\u6216\u91CD\u65B0\u8FDE\u63A5", exitCode: EXIT.RETRY_LATER });
|
|
4273
|
+
pending = (pending + decoder.decode(next.value, { stream: true })).replace(/\r\n/gu, "\n");
|
|
4274
|
+
for (let at = pending.indexOf("\n\n"); at >= 0; at = pending.indexOf("\n\n")) {
|
|
4275
|
+
const block = pending.slice(0, at);
|
|
4276
|
+
pending = pending.slice(at + 2);
|
|
4277
|
+
const data = block.split("\n").filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trimStart()).join("\n");
|
|
4278
|
+
const eventName = block.split("\n").find((line) => line.startsWith("event:"))?.slice(6).trim();
|
|
4279
|
+
if (data === "[DONE]") {
|
|
4280
|
+
completed = true;
|
|
4281
|
+
break stream;
|
|
4282
|
+
}
|
|
4283
|
+
if (!data) continue;
|
|
4284
|
+
let event;
|
|
4285
|
+
try {
|
|
4286
|
+
event = JSON.parse(data);
|
|
4287
|
+
} catch {
|
|
4288
|
+
event = { text: singleLine(data) };
|
|
4289
|
+
}
|
|
4290
|
+
if (events.length >= 1e3) throw new CliError({ code: "CLI_EVENT_LIMIT", message: "\u672C\u6B21\u4E8B\u4EF6\u5DF2\u8FBE\u5230\u8BFB\u53D6\u4E0A\u9650\uFF0C\u8BF7\u67E5\u8BE2\u5F53\u524D\u4EFB\u52A1", exitCode: EXIT.RETRY_LATER });
|
|
4291
|
+
events.push(event);
|
|
4292
|
+
const payload = event && typeof event === "object" && !Array.isArray(event) ? event : {};
|
|
4293
|
+
if (payload.type === "error" || eventName === "error") throw new CliError({
|
|
4294
|
+
code: "CLI_EVENT_ERROR",
|
|
4295
|
+
message: singleLine(typeof payload.message === "string" ? payload.message : "\u5BFC\u6F14\u56DE\u5408\u8FD4\u56DE\u9519\u8BEF\uFF0C\u8BF7\u67E5\u8BE2\u539F\u4EFB\u52A1"),
|
|
4296
|
+
exitCode: EXIT.SERVER
|
|
4297
|
+
});
|
|
4298
|
+
if (payload.type === "done" || eventName === "done") {
|
|
4299
|
+
completed = true;
|
|
4300
|
+
break stream;
|
|
4301
|
+
}
|
|
4302
|
+
}
|
|
4303
|
+
}
|
|
4304
|
+
if (!completed) throw new CliError({ code: "CLI_EVENT_INCOMPLETE", message: "\u5B9E\u65F6\u8FDE\u63A5\u5DF2\u7ED3\u675F\uFF0C\u4F46\u672A\u6536\u5230\u5B8C\u6210\u56DE\u6267\uFF0C\u8BF7\u67E5\u8BE2\u539F\u4EFB\u52A1", exitCode: EXIT.RETRY_LATER });
|
|
4305
|
+
} catch (error) {
|
|
4306
|
+
const failure = context.io.signal?.aborted ? interruptedError() : timedOut ? new CliError({ code: "CLI_TIMEOUT", message: "\u5B9E\u65F6\u7B49\u5F85\u5DF2\u8D85\u65F6\uFF0C\u8BF7\u67E5\u8BE2\u539F\u4EFB\u52A1\uFF1B\u6CA1\u6709\u91CD\u65B0\u63D0\u4EA4\u6D88\u606F", exitCode: EXIT.SERVER }) : toCliError(error);
|
|
4307
|
+
if (!timedOut || key || context.io.signal?.aborted) throw accepted ? failure.withRecovery(recovery()) : failure;
|
|
4308
|
+
} finally {
|
|
4309
|
+
clearTimeout(timer);
|
|
4310
|
+
context.io.signal?.removeEventListener("abort", stop);
|
|
4311
|
+
await reader?.cancel().catch(() => void 0);
|
|
4312
|
+
}
|
|
4313
|
+
return { events, timedOut, completed, taskId: context.args[1], recovery: recovery() };
|
|
4314
|
+
}
|
|
4315
|
+
|
|
2479
4316
|
// src/commands/series.ts
|
|
2480
4317
|
async function series(context) {
|
|
2481
|
-
const [
|
|
4318
|
+
const [action2, id] = context.args;
|
|
2482
4319
|
const { baseUrl, apiKey } = await resolveApiKey(context);
|
|
2483
|
-
if (
|
|
2484
|
-
if (
|
|
4320
|
+
if (action2 === "list" || action2 === "show") {
|
|
4321
|
+
if (action2 === "show" && !id) throw usageError("\u8BF7\u63D0\u4F9B\u5267\u96C6\u7F16\u53F7");
|
|
2485
4322
|
const query = new URLSearchParams();
|
|
2486
4323
|
for (const name2 of ["limit", "offset"]) {
|
|
2487
4324
|
const value = textOption(context.values, name2);
|
|
2488
4325
|
if (value) query.set(name2, value);
|
|
2489
4326
|
}
|
|
2490
|
-
const result2 = await getCreative(baseUrl, apiKey, "series",
|
|
4327
|
+
const result2 = await getCreative(baseUrl, apiKey, "series", action2 === "show" ? id : void 0, action2 === "list" && query.size ? `?${query}` : "", context.io);
|
|
2491
4328
|
context.out.result([JSON.stringify(result2, null, 2)], result2);
|
|
2492
4329
|
return;
|
|
2493
4330
|
}
|
|
2494
|
-
if (
|
|
2495
|
-
if (
|
|
4331
|
+
if (action2 !== "create" && action2 !== "episode-create") throw usageError("series \u652F\u6301 list\u3001show\u3001create\u3001episode-create");
|
|
4332
|
+
if (action2 === "episode-create" && !id) throw usageError("\u8BF7\u63D0\u4F9B\u5267\u96C6\u7F16\u53F7");
|
|
2496
4333
|
const body = await creativeData(context);
|
|
2497
4334
|
for (const [option, field] of [["product", "productId"], ["project", "projectId"], ["title", "title"], ["main-line", "mainLine"], ["logline", "logline"], ["previous-episode", "previousEpisodeId"]]) {
|
|
2498
4335
|
const value = textOption(context.values, option);
|
|
@@ -2502,12 +4339,12 @@ async function series(context) {
|
|
|
2502
4339
|
if (epoch !== void 0) body.expectedProductionEpoch = Number(epoch);
|
|
2503
4340
|
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
4341
|
const key = idempotencyKeyOf(context.values);
|
|
2505
|
-
const result = await postCreative(baseUrl, apiKey, "series",
|
|
4342
|
+
const result = await postCreative(baseUrl, apiKey, "series", action2 === "episode-create" ? id : void 0, action2 === "episode-create" ? "episodes" : "", body, key, context.io);
|
|
2506
4343
|
context.out.result([JSON.stringify(result, null, 2), `\u5E42\u7B49\u952E\uFF1A${key}`], { ...result, idempotencyKey: key });
|
|
2507
4344
|
}
|
|
2508
4345
|
|
|
2509
4346
|
// src/commands/assets.ts
|
|
2510
|
-
import { basename as
|
|
4347
|
+
import { basename as basename5 } from "node:path";
|
|
2511
4348
|
|
|
2512
4349
|
// src/client-catalog.ts
|
|
2513
4350
|
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"];
|
|
@@ -2589,26 +4426,26 @@ async function catalogUpload(baseUrl, key, path, bytes, mime, idempotencyKey, de
|
|
|
2589
4426
|
|
|
2590
4427
|
// src/commands/assets.ts
|
|
2591
4428
|
async function assets(context) {
|
|
2592
|
-
const [
|
|
2593
|
-
if (!["list", "search", "show", "upload", "rename", "archive", "restore"].includes(
|
|
2594
|
-
const listing =
|
|
2595
|
-
if (!listing && !rawId) throw usageError(
|
|
4429
|
+
const [action2, rawId] = context.args;
|
|
4430
|
+
if (!["list", "search", "show", "upload", "rename", "archive", "restore"].includes(action2 ?? "")) throw usageError("assets \u652F\u6301 list\u3001search\u3001show\u3001upload\u3001rename\u3001archive\u3001restore");
|
|
4431
|
+
const listing = action2 === "list" || action2 === "search";
|
|
4432
|
+
if (!listing && !rawId) throw usageError(action2 === "upload" ? "\u8BF7\u63D0\u4F9B\u4E0A\u4F20\u6587\u4EF6\u8DEF\u5F84" : "\u8BF7\u63D0\u4F9B\u7D20\u6750\u7F16\u53F7");
|
|
2596
4433
|
const name2 = textOption(context.values, "name");
|
|
2597
|
-
if (
|
|
4434
|
+
if (action2 === "rename" && !name2) throw usageError("\u8BF7\u63D0\u4F9B --name <\u540D\u79F0>");
|
|
2598
4435
|
const source = textOption(context.values, "source") ?? "personal";
|
|
2599
|
-
if (["rename", "archive", "restore"].includes(
|
|
2600
|
-
let
|
|
4436
|
+
if (["rename", "archive", "restore"].includes(action2) && source !== "personal") throw usageError("\u53EA\u6709\u4E2A\u4EBA\u751F\u6210\u7D20\u6750\u652F\u6301\u6539\u540D\u3001\u5F52\u6863\u53CA\u6062\u590D\uFF1B\u5E73\u53F0\u7D20\u6750\u53EA\u8BFB\uFF0C\u4E0A\u4F20\u7D20\u6750\u4FDD\u7559\u6388\u6743\u8BB0\u5F55");
|
|
4437
|
+
let upload3;
|
|
2601
4438
|
let query = "";
|
|
2602
|
-
if (
|
|
4439
|
+
if (action2 === "upload") {
|
|
2603
4440
|
const authorization = textOption(context.values, "authorization"), license = textOption(context.values, "license");
|
|
2604
4441
|
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
|
-
|
|
2606
|
-
query = `?${new URLSearchParams({ name: name2 ??
|
|
4442
|
+
upload3 = await readUploadFile(rawId);
|
|
4443
|
+
query = `?${new URLSearchParams({ name: name2 ?? basename5(rawId), authorization, license })}`;
|
|
2607
4444
|
}
|
|
2608
4445
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2609
|
-
const key = listing ||
|
|
4446
|
+
const key = listing || action2 === "show" ? void 0 : idempotencyKeyOf(context.values);
|
|
2610
4447
|
const path = listing ? `/api/open/v1/assets${catalogQuery(context.values, ["q", "kind", "source", "limit", "offset"])}` : `/api/open/v1/assets/${encodeURIComponent(rawId)}`;
|
|
2611
|
-
const result =
|
|
4448
|
+
const result = upload3 ? await catalogUpload(baseUrl, apiKey, `/api/open/v1/assets/uploads${query}`, upload3.bytes, upload3.contentType, key, context.io) : key ? await catalogWrite(baseUrl, apiKey, `${path}${action2 === "rename" ? "" : `/${action2}`}`, action2 === "rename" ? "PATCH" : "POST", action2 === "rename" ? { name: name2 } : {}, key, context.io) : await catalogGet(baseUrl, apiKey, listing ? path : `${path}?${new URLSearchParams({ source })}`, context.io);
|
|
2612
4449
|
const items = Array.isArray(result.assets) ? result.assets : [result.asset];
|
|
2613
4450
|
context.out.result(items.filter(Boolean).map((item) => {
|
|
2614
4451
|
const r = item;
|
|
@@ -2618,17 +4455,17 @@ async function assets(context) {
|
|
|
2618
4455
|
|
|
2619
4456
|
// src/commands/library.ts
|
|
2620
4457
|
async function library(context) {
|
|
2621
|
-
const [
|
|
2622
|
-
if (!["list", "search", "show", "rename", "archive", "restore"].includes(
|
|
2623
|
-
const listing =
|
|
4458
|
+
const [action2, rawId] = context.args;
|
|
4459
|
+
if (!["list", "search", "show", "rename", "archive", "restore"].includes(action2 ?? "")) throw usageError("library \u652F\u6301 list\u3001search\u3001show\u3001rename\u3001archive\u3001restore");
|
|
4460
|
+
const listing = action2 === "list" || action2 === "search";
|
|
2624
4461
|
const kind = textOption(context.values, "kind");
|
|
2625
4462
|
if (!listing && (!rawId || !kind)) throw usageError("\u8BF7\u63D0\u4F9B\u4F5C\u54C1\u7F16\u53F7\u53CA --kind <commercial_ad|episode|graphic>");
|
|
2626
4463
|
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
4464
|
const name2 = textOption(context.values, "name");
|
|
2628
|
-
if (
|
|
4465
|
+
if (action2 === "rename" && !name2) throw usageError("\u8BF7\u63D0\u4F9B --name <\u540D\u79F0>");
|
|
2629
4466
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
2630
|
-
const key = listing ||
|
|
2631
|
-
const result = key ? await catalogWrite(baseUrl, apiKey, `${path}${
|
|
4467
|
+
const key = listing || action2 === "show" ? void 0 : idempotencyKeyOf(context.values);
|
|
4468
|
+
const result = key ? await catalogWrite(baseUrl, apiKey, `${path}${action2 === "rename" ? "" : `/${action2}`}`, action2 === "rename" ? "PATCH" : "POST", action2 === "rename" ? { name: name2 } : {}, key, context.io) : await catalogGet(baseUrl, apiKey, path, context.io);
|
|
2632
4469
|
const items = Array.isArray(result.items) ? result.items : [result.item];
|
|
2633
4470
|
context.out.result(items.filter(Boolean).map((item) => {
|
|
2634
4471
|
const r = item;
|
|
@@ -2656,12 +4493,12 @@ async function balance(context) {
|
|
|
2656
4493
|
}
|
|
2657
4494
|
|
|
2658
4495
|
// src/commands/creative-attachments.ts
|
|
2659
|
-
import { basename as
|
|
4496
|
+
import { basename as basename6 } from "node:path";
|
|
2660
4497
|
async function creativeAttachments(context, resource) {
|
|
2661
|
-
const [
|
|
4498
|
+
const [action2, id] = context.args;
|
|
2662
4499
|
if (!id) throw usageError("\u8BF7\u63D0\u4F9B\u9879\u76EE\u7F16\u53F7");
|
|
2663
4500
|
const { baseUrl, apiKey } = await resolveApiKey(context);
|
|
2664
|
-
if (
|
|
4501
|
+
if (action2 === "attachments") {
|
|
2665
4502
|
const ids = textOption(context.values, "attachment-ids")?.split(",").map((value) => value.trim());
|
|
2666
4503
|
const params = new URLSearchParams();
|
|
2667
4504
|
const offset = textOption(context.values, "offset");
|
|
@@ -2671,14 +4508,14 @@ async function creativeAttachments(context, resource) {
|
|
|
2671
4508
|
context.out.result([JSON.stringify(result, null, 2)], result);
|
|
2672
4509
|
return;
|
|
2673
4510
|
}
|
|
2674
|
-
if (
|
|
4511
|
+
if (action2 === "upload") {
|
|
2675
4512
|
const path = textOption(context.values, "file");
|
|
2676
4513
|
if (!path) throw usageError("\u8BF7\u63D0\u4F9B --file <\u9644\u4EF6\u8DEF\u5F84>");
|
|
2677
|
-
const
|
|
4514
|
+
const upload3 = await readUploadFile(path);
|
|
2678
4515
|
const key = idempotencyKeyOf(context.values);
|
|
2679
|
-
const suffix = `attachments?${new URLSearchParams({ name:
|
|
4516
|
+
const suffix = `attachments?${new URLSearchParams({ name: basename6(path) })}`;
|
|
2680
4517
|
try {
|
|
2681
|
-
const result = creativeObject((await putRaw(baseUrl, apiKey, creativePath(resource, id, suffix),
|
|
4518
|
+
const result = creativeObject((await putRaw(baseUrl, apiKey, creativePath(resource, id, suffix), upload3.bytes, upload3.contentType, key, context.io)).body);
|
|
2682
4519
|
context.out.result([JSON.stringify(result, null, 2), `\u5E42\u7B49\u952E\uFF1A${key}`], { ...result, idempotencyKey: key });
|
|
2683
4520
|
return;
|
|
2684
4521
|
} catch (error) {
|
|
@@ -2708,7 +4545,8 @@ async function creativeAttachments(context, resource) {
|
|
|
2708
4545
|
// src/commands/drama.ts
|
|
2709
4546
|
var SUBCOMMANDS2 = "create\u3001status\u3001quote\u3001confirm\u3001cancel\u3001download\u3001context\u3001director\u3001document\u3001message\u3001director-confirm\u3001bindings\u3001spec\u3001shot-plan\u3001versions\u3001select-version\u3001redo-quote\u3001redo";
|
|
2710
4547
|
var DURATION_KEYS = ["30s", "60s", "90s"];
|
|
2711
|
-
async function
|
|
4548
|
+
async function drama2(context) {
|
|
4549
|
+
timeoutSecondsOf(context.values, DEFAULT_WAIT_TIMEOUT_MS / 1e3);
|
|
2712
4550
|
const { args } = context;
|
|
2713
4551
|
const [subcommand] = args;
|
|
2714
4552
|
if (subcommand === void 0) {
|
|
@@ -2734,7 +4572,7 @@ function waitControls2(io, values, note) {
|
|
|
2734
4572
|
return {
|
|
2735
4573
|
timeoutMs: timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3) * 1e3,
|
|
2736
4574
|
now: io.now ?? (() => /* @__PURE__ */ new Date()),
|
|
2737
|
-
sleep:
|
|
4575
|
+
sleep: (ms) => sleepFor(io, ms),
|
|
2738
4576
|
note
|
|
2739
4577
|
};
|
|
2740
4578
|
}
|
|
@@ -2847,12 +4685,15 @@ function quoteLines(orderId, quote3) {
|
|
|
2847
4685
|
}
|
|
2848
4686
|
async function create(context) {
|
|
2849
4687
|
const { io, out, values } = context;
|
|
2850
|
-
const
|
|
2851
|
-
|
|
4688
|
+
const dataRef = textOption(values, "data");
|
|
4689
|
+
const data = dataRef ? await readPropsArgument(io, dataRef, "\u77ED\u5267\u53C2\u6570\uFF08--data\uFF09") : {};
|
|
4690
|
+
for (const field of ["ownerId", "workspaceId", "allowPaidConfirmation"]) if (field in data) throw usageError(`--data \u4E0D\u80FD\u63D0\u4F9B ${field}`);
|
|
4691
|
+
const productId = textOption(values, "product") ?? (typeof data.productId === "string" ? data.productId : void 0);
|
|
4692
|
+
if (!productId?.trim()) {
|
|
2852
4693
|
throw usageError("\u8981\u7ED9 --product <\u4EA7\u54C1id>\uFF08buke products create \u56DE\u7684\u90A3\u4E2A\uFF09");
|
|
2853
4694
|
}
|
|
2854
4695
|
const genreId = textOption(values, "genre");
|
|
2855
|
-
const durationKey = textOption(values, "duration");
|
|
4696
|
+
const durationKey = textOption(values, "duration") ?? (typeof data.durationKey === "string" ? data.durationKey : void 0);
|
|
2856
4697
|
if (durationKey !== void 0 && !DURATION_KEYS.includes(durationKey)) {
|
|
2857
4698
|
throw usageError(`--duration \u53EA\u80FD\u662F ${DURATION_KEYS.join("\u3001")}\uFF0C\u5199\u7684\u662F ${durationKey}`);
|
|
2858
4699
|
}
|
|
@@ -2866,6 +4707,7 @@ async function create(context) {
|
|
|
2866
4707
|
baseUrl,
|
|
2867
4708
|
apiKey,
|
|
2868
4709
|
{
|
|
4710
|
+
...data,
|
|
2869
4711
|
productId,
|
|
2870
4712
|
...genreId === void 0 ? {} : { genreId },
|
|
2871
4713
|
...durationKey === void 0 ? {} : { durationKey },
|
|
@@ -2996,6 +4838,7 @@ function errorDocument(error) {
|
|
|
2996
4838
|
if (error.httpStatus !== void 0) document.error.httpStatus = error.httpStatus;
|
|
2997
4839
|
if (error.recovery !== void 0) document.recovery = error.recovery;
|
|
2998
4840
|
if (error.failures !== void 0) document.failures = error.failures;
|
|
4841
|
+
if (error.webRecovery !== void 0) document.webRecovery = error.webRecovery;
|
|
2999
4842
|
return document;
|
|
3000
4843
|
}
|
|
3001
4844
|
function errorLines(error) {
|
|
@@ -3007,16 +4850,23 @@ function errorLines(error) {
|
|
|
3007
4850
|
`\u9519\u8BEF\uFF1A${singleLine(error.message)}`,
|
|
3008
4851
|
`\uFF08${details.join("\uFF1B")}\uFF09`,
|
|
3009
4852
|
...error.hints,
|
|
4853
|
+
...error.webRecovery ? [
|
|
4854
|
+
`\u7F51\u9875\u64CD\u4F5C\uFF1A${singleLine(error.webRecovery.operationId)}\uFF1B\u7ED3\u679C\uFF1A${error.webRecovery.operationOutcome}`,
|
|
4855
|
+
...error.webRecovery.taskId ? [`\u539F\u4EFB\u52A1\uFF1A${singleLine(error.webRecovery.taskId)}`] : [],
|
|
4856
|
+
...error.webRecovery.idempotencyKey ? [`\u539F\u5E42\u7B49\u952E\uFF1A${singleLine(error.webRecovery.idempotencyKey)}\uFF1B\u8BF7\u5148\u67E5\u8BE2\u539F\u64CD\u4F5C\uFF0C\u4E0D\u8981\u6362\u952E\u91CD\u590D\u63D0\u4EA4\u3002`] : [],
|
|
4857
|
+
...error.webRecovery.requestRecord ? [`\u6062\u590D\u8BB0\u5F55\uFF1A${singleLine(error.webRecovery.requestRecord)}`] : []
|
|
4858
|
+
] : [],
|
|
3010
4859
|
...recovery === void 0 ? [] : [
|
|
3011
4860
|
recovery.operation === "confirm" ? `${recovery.acceptance === "confirmed" ? "\u539F\u8BA2\u5355" : "\u76EE\u6807\u8BA2\u5355"}\uFF1A${singleLine(recovery.taskId ?? "")}` : recovery.acceptance === "confirmed" ? `\u5DF2\u53D7\u7406\u4EFB\u52A1\uFF1A${singleLine(recovery.taskId ?? "")}` : "\u63D0\u4EA4\u7ED3\u679C\u5C1A\u672A\u786E\u8BA4\uFF0C\u8BF7\u5148\u5728 Studio \u6838\u5BF9\u539F\u8BF7\u6C42\uFF1B\u4E0D\u8981\u91CD\u65B0\u4E0B\u5355",
|
|
3012
4861
|
...recovery.operation !== "confirm" ? [] : [
|
|
3013
|
-
recovery.operationOutcome === "not_submitted" ? "\u672C\u6B21\u786E\u8BA4\u5C1A\u672A\u63D0\u4EA4\uFF1B\u8BF7\u5148\u67E5\u8BE2\u8BA2\u5355\u72B6\u6001\u5E76\u5904\u7406\u9519\u8BEF\u3002" : recovery.operationOutcome === "rejected" ? "\u672C\u6B21\u786E\u8BA4\u5DF2\u88AB\u62D2\u7EDD\uFF0C\u672A\u53D7\u7406\uFF1B\u8BF7\u5904\u7406\u9519\u8BEF\u540E\u67E5\u8BE2\u539F\u8BA2\u5355\u3002" : "\u672C\u6B21\u786E\u8BA4\u7ED3\u679C\u672A\u77E5\uFF1B\u8BF7\u5148\u67E5\u8BE2\u539F\u8BA2\u5355\uFF0C\u4E0D\u8981\u91CD\u590D\u63D0\u4EA4\u786E\u8BA4\u3002"
|
|
4862
|
+
recovery.operationOutcome === "not_submitted" ? "\u672C\u6B21\u786E\u8BA4\u5C1A\u672A\u63D0\u4EA4\uFF1B\u8BF7\u5148\u67E5\u8BE2\u8BA2\u5355\u72B6\u6001\u5E76\u5904\u7406\u9519\u8BEF\u3002" : recovery.operationOutcome === "rejected" ? "\u672C\u6B21\u786E\u8BA4\u5DF2\u88AB\u62D2\u7EDD\uFF0C\u672A\u53D7\u7406\uFF1B\u8BF7\u5904\u7406\u9519\u8BEF\u540E\u67E5\u8BE2\u539F\u8BA2\u5355\u3002" : recovery.operationOutcome === "accepted" ? "\u672C\u6B21\u786E\u8BA4\u5DF2\u53D7\u7406\uFF1B\u540E\u7EED\u7B49\u5F85\u6216\u67E5\u8BE2\u672A\u5B8C\u6210\uFF0C\u8BF7\u7EE7\u7EED\u67E5\u8BE2\u539F\u4EFB\u52A1\uFF0C\u4E0D\u8981\u91CD\u65B0\u63D0\u4EA4\u751F\u6210\u3002" : "\u672C\u6B21\u786E\u8BA4\u7ED3\u679C\u672A\u77E5\uFF1B\u8BF7\u5148\u67E5\u8BE2\u539F\u8BA2\u5355\uFF0C\u4E0D\u8981\u91CD\u590D\u63D0\u4EA4\u786E\u8BA4\u3002"
|
|
3014
4863
|
],
|
|
3015
4864
|
...recovery.baseUrl === void 0 ? [] : [`\u670D\u52A1\u5730\u5740\uFF1A${singleLine(recovery.baseUrl)}`],
|
|
3016
4865
|
...recovery.status === void 0 ? [] : [`\u6700\u540E\u72B6\u6001\uFF1A${singleLine(recovery.status)}`],
|
|
3017
4866
|
...recovery.failureCode === void 0 ? [] : [`\u4EFB\u52A1\u5931\u8D25\u7801\uFF1A${singleLine(recovery.failureCode)}`],
|
|
3018
4867
|
...recovery.idempotencyKey === void 0 ? [] : [`\u5E42\u7B49\u952E\uFF1A${singleLine(recovery.idempotencyKey)}`],
|
|
3019
4868
|
...recovery.confirmation === void 0 ? [] : [`\u539F\u786E\u8BA4\u7C7B\u578B\uFF1A${singleLine(recovery.confirmation.kind)}`, `\u539F\u786E\u8BA4\u7F16\u53F7\uFF1A${singleLine(recovery.confirmation.confirmationId)}`],
|
|
4869
|
+
...recovery.videoConfirmation === void 0 ? [] : [`\u539F\u786E\u8BA4\u8BF7\u6C42\uFF08\u4FDD\u5B58\u4E3A JSON\uFF0C\u7528 --data \u4E0E\u539F --idempotency-key \u6062\u590D\uFF09\uFF1A${JSON.stringify(recovery.videoConfirmation)}`],
|
|
3020
4870
|
...recovery.statusCommand === void 0 ? [] : [`${recovery.operation === "confirm" ? "\u67E5\u8BE2\u8BA2\u5355\u72B6\u6001" : "\u53EA\u67E5\u8BE2\u539F\u4EFB\u52A1"}\uFF1A${singleLine(recovery.statusCommand)}`]
|
|
3021
4871
|
]
|
|
3022
4872
|
];
|
|
@@ -3257,15 +5107,15 @@ async function confirmLock(context, values, rawId) {
|
|
|
3257
5107
|
);
|
|
3258
5108
|
}
|
|
3259
5109
|
async function manageProducts(context) {
|
|
3260
|
-
const [
|
|
3261
|
-
const listing =
|
|
5110
|
+
const [action2, id] = context.args;
|
|
5111
|
+
const listing = action2 === "list" || action2 === "search";
|
|
3262
5112
|
if (!listing && !id) throw usageError("\u8BF7\u63D0\u4F9B\u4EA7\u54C1\u7F16\u53F7");
|
|
3263
5113
|
const name2 = textOption(context.values, "name");
|
|
3264
|
-
if (
|
|
5114
|
+
if (action2 === "update" && !name2) throw usageError("\u8BF7\u63D0\u4F9B --name <\u540D\u79F0>\uFF1B\u56FE\u7247\u548C\u5916\u89C2\u9501\u4F7F\u7528 set-images\u3001confirm-lock");
|
|
3265
5115
|
const path = listing ? `/api/open/v1/products${catalogQuery(context.values, ["q", "archived", "limit", "offset"])}` : `/api/open/v1/products/${encodeURIComponent(id)}`;
|
|
3266
5116
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
3267
|
-
const key = listing ||
|
|
3268
|
-
const result = key ? await catalogWrite(baseUrl, apiKey, `${path}${
|
|
5117
|
+
const key = listing || action2 === "show" ? void 0 : idempotencyKeyOf(context.values);
|
|
5118
|
+
const result = key ? await catalogWrite(baseUrl, apiKey, `${path}${action2 === "update" ? "" : `/${action2}`}`, action2 === "update" ? "PATCH" : "POST", action2 === "update" ? { name: name2 } : {}, key, context.io) : await catalogGet(baseUrl, apiKey, path, context.io);
|
|
3269
5119
|
const items = Array.isArray(result.products) ? result.products : [result.product];
|
|
3270
5120
|
context.out.result(items.filter(Boolean).map((item) => {
|
|
3271
5121
|
const r = item;
|
|
@@ -3274,7 +5124,7 @@ async function manageProducts(context) {
|
|
|
3274
5124
|
}
|
|
3275
5125
|
|
|
3276
5126
|
// src/commands/video-music.ts
|
|
3277
|
-
function
|
|
5127
|
+
function object2(value) {
|
|
3278
5128
|
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
5129
|
return value;
|
|
3280
5130
|
}
|
|
@@ -3286,24 +5136,32 @@ function safe(value) {
|
|
|
3286
5136
|
return Object.fromEntries(Object.entries(value).filter(([key]) => fields2.has(key)).map(([key, item]) => [key, safe(item)]));
|
|
3287
5137
|
}
|
|
3288
5138
|
function task(value) {
|
|
3289
|
-
const result =
|
|
5139
|
+
const result = object2(safe(value));
|
|
3290
5140
|
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
5141
|
return result;
|
|
3292
5142
|
}
|
|
3293
5143
|
async function videoMusic(context) {
|
|
3294
5144
|
const { args, values, out, io } = context;
|
|
5145
|
+
const timeoutSeconds = timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3);
|
|
3295
5146
|
const command = args[0];
|
|
3296
5147
|
const id = args[1]?.trim();
|
|
3297
5148
|
if (!id) throw usageError("\u8BF7\u63D0\u4F9B\u5546\u54C1\u89C6\u9891\u4EFB\u52A1 ID");
|
|
5149
|
+
for (const option of ["expected-version", "expected-credits"]) {
|
|
5150
|
+
if (values[option] !== void 0) throw usageError(`videos ${command} \u4E0D\u652F\u6301 --${option}\uFF1B\u914D\u4E50\u751F\u6210\u8BF7\u4F7F\u7528\u5DF2\u67E5\u770B\u7684 --quote-hash \u7ED1\u5B9A\u62A5\u4EF7`);
|
|
5151
|
+
}
|
|
5152
|
+
const expectedQuoteHash = textOption(values, "quote-hash")?.toLowerCase();
|
|
5153
|
+
if (["music-quote", "music-compose"].includes(command) && values["quote-hash"] !== void 0 && (expectedQuoteHash === void 0 || !/^[a-f0-9]{64}$/u.test(expectedQuoteHash))) throw usageError("--quote-hash \u5FC5\u987B\u662F\u5DF2\u67E5\u770B\u7684 64 \u4F4D\u5341\u516D\u8FDB\u5236\u62A5\u4EF7\u54C8\u5E0C");
|
|
5154
|
+
if (command === "music-compose" && values.yes === true && expectedQuoteHash === void 0) throw usageError("\u786E\u8BA4\u914D\u4E50\u751F\u6210\u5FC5\u987B\u63D0\u4F9B\u5DF2\u67E5\u770B\u7684 --quote-hash\uFF1B\u5148\u4E0D\u5E26 --yes \u67E5\u770B\u62A5\u4EF7");
|
|
3298
5155
|
const request = ["music-quote", "music-compose", "music-apply"].includes(command) ? await readPropsArgument(io, textOption(values, "props"), "\u914D\u4E50\u8BF7\u6C42") : {};
|
|
3299
5156
|
const key = idempotencyKeyOf(values);
|
|
3300
5157
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
3301
5158
|
const path = `/api/open/v1/videos/${encodeURIComponent(id)}/music`;
|
|
3302
5159
|
let submitted = false;
|
|
5160
|
+
let accepted = false;
|
|
3303
5161
|
let latestTask;
|
|
3304
5162
|
try {
|
|
3305
5163
|
if (command === "music-list") {
|
|
3306
|
-
const data =
|
|
5164
|
+
const data = object2(safe((await getJson(baseUrl, apiKey, path, io)).body));
|
|
3307
5165
|
const tasks = Array.isArray(data.tasks) ? data.tasks.map(task) : [];
|
|
3308
5166
|
out.result(tasks.map((item) => `${singleLine(item.id)} ${singleLine(item.status)} ${singleLine(String(item.title ?? ""))}`), { ...data, tasks });
|
|
3309
5167
|
return;
|
|
@@ -3311,28 +5169,33 @@ async function videoMusic(context) {
|
|
|
3311
5169
|
if (command === "music-apply") {
|
|
3312
5170
|
const taskId = textOption(values, "music-task-id");
|
|
3313
5171
|
if (!taskId) throw usageError("\u8BF7\u63D0\u4F9B --music-task-id <\u914D\u4E50\u4EFB\u52A1ID>");
|
|
3314
|
-
const
|
|
5172
|
+
const timeoutMs = values.timeout === void 0 ? 3e5 : timeoutSeconds * 1e3;
|
|
5173
|
+
const data = object2(safe((await postJson(baseUrl, apiKey, `${path}/${encodeURIComponent(taskId)}/apply`, request, key, io, { timeoutMs })).body));
|
|
3315
5174
|
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
5175
|
return;
|
|
3317
5176
|
}
|
|
3318
|
-
const quote3 =
|
|
5177
|
+
const quote3 = object2(object2(safe((await postJson(baseUrl, apiKey, `${path}/quote`, request, key, io)).body)).quote);
|
|
3319
5178
|
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
|
-
|
|
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" });
|
|
5179
|
+
if (expectedQuoteHash !== void 0 && expectedQuoteHash !== quote3.quoteHash) throw new CliError({ code: "OPEN_API_QUOTE_CHANGED", exitCode: EXIT.QUOTE_CHANGED, message: "\u914D\u4E50\u62A5\u4EF7\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u67E5\u770B\u5E76\u786E\u8BA4" });
|
|
3322
5180
|
if (command === "music-quote" || values.yes !== true) {
|
|
3323
|
-
out.result([
|
|
5181
|
+
out.result([
|
|
5182
|
+
`\u914D\u4E50\u62A5\u4EF7\uFF1A${quote3.credits} \u5E03`,
|
|
5183
|
+
`\u62A5\u4EF7\u54C8\u5E0C\uFF1A${quote3.quoteHash}`,
|
|
5184
|
+
`\u786E\u8BA4\u540E\u4F7F\u7528 buke videos music-compose ${id} --props <\u539F\u914D\u4E50\u8BF7\u6C42\u6587\u4EF6> --quote-hash ${quote3.quoteHash} --yes \u63D0\u4EA4\u751F\u6210\u3002`
|
|
5185
|
+
], { quote: quote3, submitted: false });
|
|
3324
5186
|
return;
|
|
3325
5187
|
}
|
|
3326
5188
|
submitted = true;
|
|
3327
|
-
latestTask = task(
|
|
5189
|
+
latestTask = task(object2((await postJson(baseUrl, apiKey, path, { ...request, confirmed: true, quoteHash: quote3.quoteHash }, key, io)).body).task);
|
|
5190
|
+
accepted = true;
|
|
3328
5191
|
if (values.wait === true) {
|
|
3329
5192
|
const now = io.now ?? (() => /* @__PURE__ */ new Date());
|
|
3330
|
-
const
|
|
3331
|
-
const until = now().getTime() + timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3) * 1e3;
|
|
5193
|
+
const until = now().getTime() + timeoutSeconds * 1e3;
|
|
3332
5194
|
while (["pending", "running"].includes(latestTask.status)) {
|
|
3333
5195
|
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
|
|
3335
|
-
|
|
5196
|
+
await sleepFor(io, Math.min(1500, Math.max(until - now().getTime(), 1)));
|
|
5197
|
+
if (now().getTime() >= until) continue;
|
|
5198
|
+
const data = object2((await getJson(baseUrl, apiKey, path, io)).body);
|
|
3336
5199
|
const found = Array.isArray(data.tasks) ? data.tasks.find((item) => item && typeof item === "object" && item.id === latestTask.id) : null;
|
|
3337
5200
|
latestTask = task(found);
|
|
3338
5201
|
}
|
|
@@ -3354,7 +5217,7 @@ async function videoMusic(context) {
|
|
|
3354
5217
|
acceptance: latestTask ? "confirmed" : "unknown",
|
|
3355
5218
|
idempotencyKey: key,
|
|
3356
5219
|
operation: "confirm",
|
|
3357
|
-
operationOutcome: !submitted ? "not_submitted" : rejected ? "rejected" : "unknown",
|
|
5220
|
+
operationOutcome: accepted ? "accepted" : !submitted ? "not_submitted" : rejected ? "rejected" : "unknown",
|
|
3358
5221
|
statusCommand: taskRecovery("videos", id, latestTask?.status, baseUrl).statusCommand.replace(" videos status ", " videos music-list ")
|
|
3359
5222
|
});
|
|
3360
5223
|
}
|
|
@@ -3363,6 +5226,7 @@ async function videoMusic(context) {
|
|
|
3363
5226
|
// src/commands/videos.ts
|
|
3364
5227
|
var SUBCOMMANDS3 = "create\u3001status\u3001message\u3001confirm\u3001versions\u3001cancel\u3001download\u3001music-quote\u3001music-compose\u3001music-list\u3001music-apply";
|
|
3365
5228
|
async function videos(context) {
|
|
5229
|
+
timeoutSecondsOf(context.values, DEFAULT_WAIT_TIMEOUT_MS / 1e3);
|
|
3366
5230
|
const { args } = context;
|
|
3367
5231
|
const [subcommand] = args;
|
|
3368
5232
|
if (subcommand === void 0) {
|
|
@@ -3388,7 +5252,7 @@ function waitControls3(io, values) {
|
|
|
3388
5252
|
return {
|
|
3389
5253
|
timeoutMs: timeoutSecondsOf(values, DEFAULT_WAIT_TIMEOUT_MS / 1e3) * 1e3,
|
|
3390
5254
|
now: io.now ?? (() => /* @__PURE__ */ new Date()),
|
|
3391
|
-
sleep:
|
|
5255
|
+
sleep: (ms) => sleepFor(io, ms)
|
|
3392
5256
|
};
|
|
3393
5257
|
}
|
|
3394
5258
|
function settleRun(outcome, baseUrl) {
|
|
@@ -3479,6 +5343,9 @@ async function create3(context) {
|
|
|
3479
5343
|
{ run: raw.run, idempotencyKey }
|
|
3480
5344
|
);
|
|
3481
5345
|
}
|
|
5346
|
+
function latestDirectorLine(messages) {
|
|
5347
|
+
return [...messages].reverse().find((message2) => message2.role === "assistant" && !message2.earlierAttemptOf && message2.text.trim() !== "");
|
|
5348
|
+
}
|
|
3482
5349
|
async function status3(context, rawId) {
|
|
3483
5350
|
const { io, out, values } = context;
|
|
3484
5351
|
const runId = runIdOf(rawId);
|
|
@@ -3487,7 +5354,7 @@ async function status3(context, rawId) {
|
|
|
3487
5354
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
3488
5355
|
const current = await getVideoRun(baseUrl, apiKey, runId, io);
|
|
3489
5356
|
const final = shouldWait ? settleRun(await awaitVideoRun(baseUrl, apiKey, current, io, controls), baseUrl) : current;
|
|
3490
|
-
const lastDirectorLine =
|
|
5357
|
+
const lastDirectorLine = latestDirectorLine(final.view.messages);
|
|
3491
5358
|
out.result(
|
|
3492
5359
|
[
|
|
3493
5360
|
...runLines(final.view),
|
|
@@ -3508,8 +5375,8 @@ async function message(context, rawId) {
|
|
|
3508
5375
|
}
|
|
3509
5376
|
const idempotencyKey = idempotencyKeyOf(values);
|
|
3510
5377
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
3511
|
-
const { view, raw } = await runReplyOf(await postJson(baseUrl, apiKey, `/api/open/v1/videos/${encodeURIComponent(runId)}/messages`, { ...data, text }, idempotencyKey, io));
|
|
3512
|
-
const lastDirectorLine =
|
|
5378
|
+
const { view, raw } = await retainMutationOnError("videos", runId, idempotencyKey, baseUrl, async () => runReplyOf(await postJson(baseUrl, apiKey, `/api/open/v1/videos/${encodeURIComponent(runId)}/messages`, { ...data, text }, idempotencyKey, io)));
|
|
5379
|
+
const lastDirectorLine = latestDirectorLine(view.messages);
|
|
3513
5380
|
out.result(
|
|
3514
5381
|
[
|
|
3515
5382
|
...runLines(view),
|
|
@@ -3523,10 +5390,39 @@ async function message(context, rawId) {
|
|
|
3523
5390
|
async function confirm2(context, rawId) {
|
|
3524
5391
|
const { io, out, values } = context;
|
|
3525
5392
|
const runId = runIdOf(rawId);
|
|
5393
|
+
const data = await creativeData(context);
|
|
5394
|
+
const originalKey = textOption(values, "idempotency-key");
|
|
5395
|
+
if (textOption(values, "data")) {
|
|
5396
|
+
if (!originalKey) throw usageError("\u6062\u590D\u539F\u786E\u8BA4\u5FC5\u987B\u63D0\u4F9B\u539F --idempotency-key");
|
|
5397
|
+
if (!Number.isInteger(data.expectedVersion) || Number(data.expectedVersion) < 0 || !data.confirmation || typeof data.confirmation !== "object" || Array.isArray(data.confirmation)) {
|
|
5398
|
+
throw usageError("--data \u5FC5\u987B\u5305\u542B\u539F\u786E\u8BA4\u7684 expectedVersion \u4E0E confirmation");
|
|
5399
|
+
}
|
|
5400
|
+
if (values.yes !== true) throw usageError("\u6062\u590D\u539F\u786E\u8BA4\u8BF7\u6838\u5BF9\u539F\u8BF7\u6C42\uFF0C\u5E76\u6DFB\u52A0 --yes");
|
|
5401
|
+
const { apiKey: apiKey2, baseUrl: baseUrl2 } = await resolveApiKey(context);
|
|
5402
|
+
const outcome2 = await confirmVideoProduction(baseUrl2, apiKey2, runId, Number(data.expectedVersion), data.confirmation, originalKey, io);
|
|
5403
|
+
out.result(
|
|
5404
|
+
[...runLines(outcome2.view), "\u5DF2\u91CD\u653E\u539F\u786E\u8BA4\u8BF7\u6C42", ...waitingLines(outcome2.view), `\u5E42\u7B49\u952E\uFF1A${originalKey}`],
|
|
5405
|
+
{ run: outcome2.raw.run, replayedConfirmation: true, idempotencyKey: originalKey }
|
|
5406
|
+
);
|
|
5407
|
+
return;
|
|
5408
|
+
}
|
|
5409
|
+
const expectedVersionRaw = textOption(values, "expected-version");
|
|
5410
|
+
const expectedCreditsRaw = textOption(values, "expected-credits");
|
|
5411
|
+
const expectedVersion = expectedVersionRaw === void 0 ? void 0 : Number(expectedVersionRaw);
|
|
5412
|
+
const expectedCredits = expectedCreditsRaw === void 0 ? void 0 : Number(expectedCreditsRaw);
|
|
5413
|
+
if (values["expected-version"] !== void 0 && (expectedVersion === void 0 || !Number.isSafeInteger(expectedVersion) || expectedVersion < 0)) {
|
|
5414
|
+
throw usageError("--expected-version \u5FC5\u987B\u662F\u4E4B\u524D\u67E5\u770B\u7684\u975E\u8D1F\u6574\u6570\u7248\u672C\u53F7");
|
|
5415
|
+
}
|
|
5416
|
+
if (values["expected-credits"] !== void 0 && (expectedCredits === void 0 || !Number.isFinite(expectedCredits) || expectedCredits < 0)) {
|
|
5417
|
+
throw usageError("--expected-credits \u5FC5\u987B\u662F\u4E4B\u524D\u67E5\u770B\u7684\u975E\u8D1F\u6709\u9650\u91D1\u989D");
|
|
5418
|
+
}
|
|
5419
|
+
if (values.yes === true && (expectedVersion === void 0 || expectedCredits === void 0)) {
|
|
5420
|
+
throw usageError("\u786E\u8BA4\u652F\u51FA\u5FC5\u987B\u63D0\u4F9B\u4E4B\u524D\u67E5\u770B\u7684 --expected-version \u548C --expected-credits\uFF1B\u5148\u4E0D\u5E26 --yes \u67E5\u770B\u5F53\u524D\u786E\u8BA4\u5361");
|
|
5421
|
+
}
|
|
3526
5422
|
const { apiKey, baseUrl } = await resolveApiKey(context);
|
|
3527
5423
|
const fetched = await getVideoRun(baseUrl, apiKey, runId, io);
|
|
3528
5424
|
const run2 = fetched.view;
|
|
3529
|
-
const card = run2.nextActions.find((
|
|
5425
|
+
const card = run2.nextActions.find((action2) => action2.type === "confirm_production");
|
|
3530
5426
|
if (card === void 0) {
|
|
3531
5427
|
throw new CliError({
|
|
3532
5428
|
code: "CLI_USAGE",
|
|
@@ -3534,25 +5430,48 @@ async function confirm2(context, rawId) {
|
|
|
3534
5430
|
message: `\u73B0\u5728\u6CA1\u6709\u7B49\u7740\u786E\u8BA4\u7684\u5361\uFF08\u5F53\u524D\u72B6\u6001\uFF1A${run2.status}\uFF09\u3002\u5BFC\u6F14\u505C\u4E0B\u6765\u8981\u786E\u8BA4\u65F6\u518D\u8FD0\u884C\u8FD9\u6761\u547D\u4EE4`
|
|
3535
5431
|
});
|
|
3536
5432
|
}
|
|
3537
|
-
if (card.confirmation
|
|
5433
|
+
if (!card.confirmation || typeof card.confirmation !== "object" || Array.isArray(card.confirmation)) {
|
|
3538
5434
|
throw new CliError({
|
|
3539
5435
|
code: "CLI_USAGE",
|
|
3540
5436
|
exitCode: EXIT.USAGE,
|
|
3541
5437
|
message: "\u670D\u52A1\u7AEF\u6302\u51FA\u7684\u8FD9\u5F20\u5361\u4E0D\u5E26\u786E\u8BA4\u8EAB\u4EFD\uFF0C\u786E\u8BA4\u4E0D\u4E86\uFF1B\u7A0D\u540E\u91CD\u65B0\u8FD0\u884C buke videos status \u770B\u6700\u65B0\u72B6\u6001"
|
|
3542
5438
|
});
|
|
3543
5439
|
}
|
|
3544
|
-
const credits = card.credits
|
|
5440
|
+
const credits = card.credits;
|
|
5441
|
+
if (!Number.isSafeInteger(run2.version) || run2.version < 0 || typeof credits !== "number" || !Number.isFinite(credits) || credits < 0 || "credits" in card.confirmation && card.confirmation.credits !== credits) {
|
|
5442
|
+
throw new CliError({
|
|
5443
|
+
code: "CLI_BAD_RESPONSE",
|
|
5444
|
+
exitCode: EXIT.SERVER,
|
|
5445
|
+
message: "\u786E\u8BA4\u5361\u7248\u672C\u6216\u91D1\u989D\u65E0\u6548\uFF0C\u6216\u786E\u8BA4\u8EAB\u4EFD\u5185\u7684\u91D1\u989D\u4E0D\u4E00\u81F4\uFF1B\u672C\u6B21\u672A\u63D0\u4EA4\uFF0C\u8BF7\u91CD\u65B0\u67E5\u8BE2\u5F53\u524D\u786E\u8BA4\u5361"
|
|
5446
|
+
});
|
|
5447
|
+
}
|
|
5448
|
+
if (expectedVersion !== void 0 && expectedVersion !== run2.version || expectedCredits !== void 0 && expectedCredits !== credits) {
|
|
5449
|
+
throw new CliError({
|
|
5450
|
+
code: "OPEN_API_QUOTE_CHANGED",
|
|
5451
|
+
exitCode: EXIT.QUOTE_CHANGED,
|
|
5452
|
+
message: "\u786E\u8BA4\u5361\u7248\u672C\u6216\u91D1\u989D\u5DF2\u53D8\u5316\uFF0C\u672C\u6B21\u672A\u63D0\u4EA4\uFF1B\u8BF7\u91CD\u65B0\u67E5\u770B\u540E\u660E\u786E\u786E\u8BA4"
|
|
5453
|
+
});
|
|
5454
|
+
}
|
|
3545
5455
|
const kind = card.confirmKind === void 0 ? "\u786E\u8BA4" : `\u786E\u8BA4\uFF08${card.confirmKind}\uFF09`;
|
|
3546
5456
|
if (values.yes !== true) {
|
|
3547
5457
|
throw new CliError({
|
|
3548
5458
|
code: "CLI_USAGE",
|
|
3549
5459
|
exitCode: EXIT.USAGE,
|
|
3550
5460
|
message: `\u8FD9\u5F20\u5361\u8981\u82B1 ${credits} \u5E03\u3002\u52A0 --yes \u786E\u8BA4\u8FD9\u7B14\u5E03\u652F\u51FA`,
|
|
3551
|
-
hints: [
|
|
5461
|
+
hints: [
|
|
5462
|
+
`${kind}\uFF1A${singleLine(run2.label)}`,
|
|
5463
|
+
`\u770B\u8FC7\u518D\u786E\u8BA4\uFF1Abuke videos confirm ${run2.rootRunId} --expected-version ${run2.version} --expected-credits ${credits} --yes`
|
|
5464
|
+
]
|
|
3552
5465
|
});
|
|
3553
5466
|
}
|
|
3554
5467
|
const idempotencyKey = idempotencyKeyOf(values);
|
|
3555
|
-
|
|
5468
|
+
let outcome;
|
|
5469
|
+
try {
|
|
5470
|
+
outcome = await confirmVideoProduction(baseUrl, apiKey, runId, run2.version, card.confirmation, idempotencyKey, io);
|
|
5471
|
+
} catch (error) {
|
|
5472
|
+
const failure = toCliError(error);
|
|
5473
|
+
throw failure.withRecovery({ ...taskRecovery("videos", runId, run2.status, baseUrl), ...failure.recovery, acceptance: "confirmed" });
|
|
5474
|
+
}
|
|
3556
5475
|
out.result(
|
|
3557
5476
|
[...runLines(outcome.view), `\u5DF2\u786E\u8BA4\uFF1A\u8FD9\u7B14\u6700\u591A ${credits} \u5E03`, ...waitingLines(outcome.view), `\u5E42\u7B49\u952E\uFF1A${idempotencyKey}`],
|
|
3558
5477
|
{ run: outcome.raw.run, confirmed: { credits, confirmKind: card.confirmKind ?? null }, idempotencyKey }
|
|
@@ -3636,6 +5555,7 @@ var KEY_HOWTO = [
|
|
|
3636
5555
|
" 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"
|
|
3637
5556
|
];
|
|
3638
5557
|
var COMMANDS = {
|
|
5558
|
+
web: webCommand,
|
|
3639
5559
|
graphic: graphicCommand,
|
|
3640
5560
|
login: {
|
|
3641
5561
|
run: login,
|
|
@@ -3781,7 +5701,7 @@ var COMMANDS = {
|
|
|
3781
5701
|
" buke shorts download <\u8BA2\u5355id> [--out <\u8DEF\u5F84>]",
|
|
3782
5702
|
" buke shorts cancel <\u8BA2\u5355id>",
|
|
3783
5703
|
"",
|
|
3784
|
-
"\
|
|
5704
|
+
"\u6A21\u677F\u77ED\u7247\uFF08\u6A21\u677F\u76F4\u51FA\u7684\u7AD6\u5C4F\u5546\u54C1\u77ED\u7247\uFF09\uFF1A",
|
|
3785
5705
|
" catalog \u5217\u51FA\u5168\u90E8\u6A21\u677F\uFF08id\u3001\u65F6\u957F\u3001\u8981\u54EA\u4E9B\u7D20\u6750\uFF09",
|
|
3786
5706
|
" upload \u6258\u7BA1\u4E00\u5F20\u7D20\u6750\u56FE\uFF0C\u6362\u56DE\u53EF\u4EE5\u76F4\u63A5\u586B\u8FDB\u6A21\u677F\u56FE\u7247\u69FD\u7684\u5730\u5740",
|
|
3787
5707
|
" quote \u53EA\u8BFB\u62A5\u4EF7\uFF1B\u6536\u8D39\u7684\u6A21\u677F\u4E0B\u5355\u524D\u5FC5\u987B\u5148\u62FF quoteHash",
|
|
@@ -3861,10 +5781,12 @@ var COMMANDS = {
|
|
|
3861
5781
|
" buke videos versions <\u89C6\u9891id>",
|
|
3862
5782
|
" buke videos music-list <\u89C6\u9891id>",
|
|
3863
5783
|
" buke videos music-quote <\u89C6\u9891id> --props <JSON\u6587\u4EF6|->",
|
|
3864
|
-
" buke videos music-compose <\u89C6\u9891id> --props <JSON\u6587\u4EF6|-> --
|
|
5784
|
+
" buke videos music-compose <\u89C6\u9891id> --props <JSON\u6587\u4EF6|-> --quote-hash <\u5DF2\u67E5\u770B\u62A5\u4EF7\u6807\u8BC6> --yes",
|
|
3865
5785
|
" buke videos music-apply <\u89C6\u9891id> --music-task-id <\u4EFB\u52A1id> --props <JSON\u6587\u4EF6|->",
|
|
3866
5786
|
" buke videos cancel <\u89C6\u9891id>",
|
|
3867
|
-
" buke videos confirm <\u89C6\u9891id>
|
|
5787
|
+
" buke videos confirm <\u89C6\u9891id> \u67E5\u770B\u5F53\u524D\u786E\u8BA4\u5361",
|
|
5788
|
+
" buke videos confirm <\u89C6\u9891id> --expected-version <\u5DF2\u67E5\u770B\u7248\u672C> --expected-credits <\u5DF2\u67E5\u770B\u91D1\u989D> --yes",
|
|
5789
|
+
" buke videos confirm <\u89C6\u9891id> --data <\u539F\u786E\u8BA4JSON> --idempotency-key <\u539F\u952E> --yes \u91CD\u653E\u539F\u786E\u8BA4",
|
|
3868
5790
|
" buke videos download <\u89C6\u9891id> [--production-id <\u5236\u4F5C\u7248\u672C>] [--edit-id <\u526A\u8F91\u7248\u672C>] [--out <\u8DEF\u5F84>]",
|
|
3869
5791
|
" buke videos download <\u89C6\u9891id> --music-task-id <\u4EFB\u52A1id> --track-index <0|1> [--out <\u8DEF\u5F84>]",
|
|
3870
5792
|
" buke videos download <\u89C6\u9891id> [--append-task-id <\u63D2\u6BB5\u4EFB\u52A1>] [--narration-edit-id <\u914D\u97F3\u7248\u672C>] [--out <\u8DEF\u5F84>]",
|
|
@@ -3874,7 +5796,7 @@ var COMMANDS = {
|
|
|
3874
5796
|
" create \u521B\u5EFA\u4EFB\u52A1\uFF1B\u987B\u5148\u5EFA\u7ACB\u4EA7\u54C1\u3002\u53D7\u7406\u540E\u901A\u8FC7 status \u67E5\u8BE2\u8FDB\u5EA6",
|
|
3875
5797
|
" status \u67E5\u8BE2\u8FDB\u5EA6\uFF1B--wait \u7B49\u5F85\u7EC8\u6001\u6216\u9700\u8981\u7528\u6237\u5904\u7406\u7684\u72B6\u6001",
|
|
3876
5798
|
" message \u63D0\u4EA4\u5236\u4F5C\u8981\u6C42\u3001\u95EE\u9898\u56DE\u590D\u3001\u9644\u4EF6\u6216\u7ED3\u6784\u5316\u9009\u9879",
|
|
3877
|
-
" confirm \
|
|
5799
|
+
" confirm \u5BF9\u7167\u5DF2\u67E5\u770B\u7684\u7248\u672C\u548C\u91D1\u989D\uFF0C\u63D0\u4EA4\u540C\u4E00\u786E\u8BA4\u5361\uFF1B\u53D8\u5316\u65F6\u4E0D\u63D0\u4EA4",
|
|
3878
5800
|
" download \u4E0B\u8F7D\u6210\u7247\uFF08mp4\uFF09",
|
|
3879
5801
|
"",
|
|
3880
5802
|
"\u9009\u9879\uFF1A",
|
|
@@ -3896,7 +5818,7 @@ var COMMANDS = {
|
|
|
3896
5818
|
].join("\n")
|
|
3897
5819
|
},
|
|
3898
5820
|
drama: {
|
|
3899
|
-
run:
|
|
5821
|
+
run: drama2,
|
|
3900
5822
|
acceptsBaseUrl: true,
|
|
3901
5823
|
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"],
|
|
3902
5824
|
positionals: ["\u5B50\u547D\u4EE4", "\u8BA2\u5355id"],
|
|
@@ -3947,6 +5869,18 @@ var COMMANDS = {
|
|
|
3947
5869
|
].join("\n")
|
|
3948
5870
|
}
|
|
3949
5871
|
};
|
|
5872
|
+
for (const resource of ["videos", "drama", "graphic", "series"]) {
|
|
5873
|
+
const command = COMMANDS[resource];
|
|
5874
|
+
const runOriginal = command.run;
|
|
5875
|
+
COMMANDS[resource] = {
|
|
5876
|
+
...command,
|
|
5877
|
+
options: [.../* @__PURE__ */ new Set([...command.options, ...STUDIO_ACTION_OPTIONS])],
|
|
5878
|
+
help: command.help + STUDIO_ACTION_HELP(resource),
|
|
5879
|
+
run: async (context) => {
|
|
5880
|
+
if (!await tryStudioAction(resource, context)) await runOriginal(context);
|
|
5881
|
+
}
|
|
5882
|
+
};
|
|
5883
|
+
}
|
|
3950
5884
|
var GENERAL_HELP = [
|
|
3951
5885
|
"buke\uFF1A\u300A\u4E0D\u53EF\u601D\u8BAE\u300B\u7684\u547D\u4EE4\u884C\u5DE5\u5177",
|
|
3952
5886
|
"",
|
|
@@ -3956,13 +5890,14 @@ var GENERAL_HELP = [
|
|
|
3956
5890
|
" buke logout [--json] \u9000\u51FA\u767B\u5F55\uFF0C\u5220\u9664\u672C\u673A\u4FDD\u5B58\u7684\u5BC6\u94A5",
|
|
3957
5891
|
" buke balance [--json] \u67E5\u8BE2\u8D26\u6237\u4F59\u989D",
|
|
3958
5892
|
" buke products <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u4EA7\u54C1\u5EFA\u6863\u4E0E\u7BA1\u7406\uFF1Alist\u3001show\u3001create\u3001update\u3001archive\u3001restore",
|
|
3959
|
-
" buke shorts <\u5B50\u547D\u4EE4> [\u53C2\u6570] \
|
|
5893
|
+
" buke shorts <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u6A21\u677F\u77ED\u7247\uFF1Acatalog\u3001upload\u3001quote\u3001order\u3001status\u3001download\u3001cancel",
|
|
3960
5894
|
" 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
5895
|
" 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
5896
|
" 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
5897
|
" buke assets <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u5E73\u53F0\u4E0E\u4E2A\u4EBA\u7D20\u6750\u67E5\u8BE2\u3001\u4E0A\u4F20\u53CA\u7BA1\u7406",
|
|
3964
5898
|
" buke graphic <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u56FE\u6587\u65B9\u6848\u3001\u62A5\u4EF7\u3001\u751F\u6210\u3001\u7F16\u8F91\u53CA\u4E0B\u8F7D",
|
|
3965
5899
|
" buke series <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u591A\u96C6\u77ED\u5267\u67E5\u8BE2\u3001\u521B\u5EFA\u53CA\u7EED\u96C6",
|
|
5900
|
+
" buke web <\u5B50\u547D\u4EE4> [\u53C2\u6570] \u7F51\u9875\u4F1A\u8BDD\uFF1A\u767B\u5F55\u3001\u64CD\u4F5C\u76EE\u5F55\u4E0E\u7F51\u9875\u529F\u80FD\u8C03\u7528\uFF08\u5145\u503C\u9664\u5916\uFF09",
|
|
3966
5901
|
" buke --help | -h \u663E\u793A\u8FD9\u4EFD\u8BF4\u660E\uFF1Bbuke <\u547D\u4EE4> --help \u770B\u5355\u6761\u547D\u4EE4",
|
|
3967
5902
|
" buke --version | -v \u663E\u793A\u7248\u672C\u53F7",
|
|
3968
5903
|
"",
|
|
@@ -4033,7 +5968,7 @@ var BOOLEAN_OPTIONS = /* @__PURE__ */ new Set(["help", "version", "json", "wait"
|
|
|
4033
5968
|
for (const command of Object.values(COMMANDS)) for (const option of command.options) {
|
|
4034
5969
|
if (!BOOLEAN_OPTIONS.has(option)) STRING_OPTIONS.add(option);
|
|
4035
5970
|
}
|
|
4036
|
-
function
|
|
5971
|
+
function parse2(argv) {
|
|
4037
5972
|
try {
|
|
4038
5973
|
const options = {};
|
|
4039
5974
|
for (const name2 of STRING_OPTIONS) options[name2] = { type: "string" };
|
|
@@ -4076,7 +6011,7 @@ async function dispatch(argv, io, out) {
|
|
|
4076
6011
|
message: "\u5BC6\u94A5\u4E0D\u8981\u5199\u5728\u547D\u4EE4\u884C\u91CC\uFF08\u4F1A\u7559\u5728 shell \u5386\u53F2\u548C\u8FDB\u7A0B\u5217\u8868\u91CC\uFF09\u3002\u8BF7\u7528\u73AF\u5883\u53D8\u91CF BUKE_API_KEY\uFF0C\u6216\u8005\u901A\u8FC7\u7BA1\u9053\u4F20\u7ED9 buke login\u3002\u521A\u624D\u8FD9\u628A\u5982\u679C\u662F\u771F\u7684\uFF0C\u5EFA\u8BAE\u540A\u9500\u540E\u91CD\u65B0\u521B\u5EFA\u3002"
|
|
4077
6012
|
});
|
|
4078
6013
|
}
|
|
4079
|
-
const parsed =
|
|
6014
|
+
const parsed = parse2(argv);
|
|
4080
6015
|
const command = parsed.command !== void 0 && Object.hasOwn(COMMANDS, parsed.command) ? COMMANDS[parsed.command] : void 0;
|
|
4081
6016
|
if (parsed.command !== void 0 && !command) throw usageError(`\u4E0D\u8BA4\u8BC6\u7684\u547D\u4EE4 ${echo(parsed.command)}`);
|
|
4082
6017
|
const args = parsed.positionals.slice(1);
|