bukesiyi-cli 0.6.0 → 0.7.0

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