maoda-commander-tt 0.0.60 → 0.0.61
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.
|
@@ -602,7 +602,7 @@ function createAgentProgressReporter(options) {
|
|
|
602
602
|
// src/commands/ai/ai-audio-command.ts
|
|
603
603
|
import { resolve as resolve5 } from "node:path";
|
|
604
604
|
import { Option as Option3 } from "commander";
|
|
605
|
-
import { ok as
|
|
605
|
+
import { ok as ok16 } from "rockbed/error";
|
|
606
606
|
|
|
607
607
|
// src/bedrock/download/download-file.ts
|
|
608
608
|
import { randomUUID } from "node:crypto";
|
|
@@ -660,11 +660,11 @@ function findFirstAudioUrl(task) {
|
|
|
660
660
|
}
|
|
661
661
|
|
|
662
662
|
// src/modules/xyq-tasks/audio-task-runner.ts
|
|
663
|
-
import { err as err7, ok as
|
|
663
|
+
import { err as err7, ok as ok11 } from "rockbed/error";
|
|
664
664
|
|
|
665
665
|
// src/modules/xyq/xyq-client.ts
|
|
666
666
|
import { createHash as createHash2 } from "node:crypto";
|
|
667
|
-
import { ok as
|
|
667
|
+
import { ok as ok10 } from "rockbed/error";
|
|
668
668
|
|
|
669
669
|
// src/bedrock/cross-app-settings/file-cross-app-settings-reader.ts
|
|
670
670
|
import * as fs2 from "node:fs/promises";
|
|
@@ -1022,7 +1022,7 @@ function isRecord3(value) {
|
|
|
1022
1022
|
import * as fs5 from "node:fs/promises";
|
|
1023
1023
|
import * as path5 from "node:path";
|
|
1024
1024
|
import { createHash, randomUUID as randomUUID4 } from "node:crypto";
|
|
1025
|
-
import { ok as
|
|
1025
|
+
import { ok as ok9 } from "rockbed/error";
|
|
1026
1026
|
|
|
1027
1027
|
// src/modules/xyq/xyq-asset-cache.ts
|
|
1028
1028
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
@@ -1351,8 +1351,30 @@ function sleep(delayMs) {
|
|
|
1351
1351
|
return new Promise((resolve17) => setTimeout(resolve17, delayMs));
|
|
1352
1352
|
}
|
|
1353
1353
|
|
|
1354
|
-
// src/modules/xyq/xyq-
|
|
1354
|
+
// src/modules/xyq/xyq-generation-routing.ts
|
|
1355
1355
|
import { ok as ok7 } from "rockbed/error";
|
|
1356
|
+
var XYQ_PPE_CONFIG_KEY = "seedance.ppe";
|
|
1357
|
+
var XYQ_DEFAULT_PPE = "ppe_wyfree";
|
|
1358
|
+
async function readXyqGenerationPpeHeaders(settingsReader) {
|
|
1359
|
+
let ppe = XYQ_DEFAULT_PPE;
|
|
1360
|
+
if (settingsReader) {
|
|
1361
|
+
const settingResult = await settingsReader.getString(XYQ_PPE_CONFIG_KEY);
|
|
1362
|
+
if (!settingResult.ok) {
|
|
1363
|
+
return xyqError(
|
|
1364
|
+
XyqErrorCode.SettingsReadFailed,
|
|
1365
|
+
`\u8BFB\u53D6 XYQ \u751F\u6210\u6CF3\u9053\u914D\u7F6E\u5931\u8D25: ${settingResult.msg}`
|
|
1366
|
+
);
|
|
1367
|
+
}
|
|
1368
|
+
ppe = settingResult.value?.trim() || XYQ_DEFAULT_PPE;
|
|
1369
|
+
}
|
|
1370
|
+
return ok7({
|
|
1371
|
+
"x-tt-env": ppe,
|
|
1372
|
+
"x-use-ppe": "1"
|
|
1373
|
+
});
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
// src/modules/xyq/xyq-image-models.ts
|
|
1377
|
+
import { ok as ok8 } from "rockbed/error";
|
|
1356
1378
|
var XYQ_IMAGE_MODELS = [
|
|
1357
1379
|
{ id: "gpt_image_2", name: "image2", efforts: ["medium", "high"], defaultEffort: "high" },
|
|
1358
1380
|
{ id: "gpt_image_2_5_sunburst", name: "image2.5 Sunburst", efforts: ["high", "xhigh", "max"], defaultEffort: "max" }
|
|
@@ -1368,14 +1390,12 @@ function resolveXyqImageModel(modelInput, effortInput) {
|
|
|
1368
1390
|
`XYQ \u56FE\u7247\u6A21\u578B ${model} \u7684 effort \u5FC5\u987B\u662F ${config.efforts.join("\u3001")} \u4E4B\u4E00\uFF08\u9ED8\u8BA4 ${config.defaultEffort}\uFF09`
|
|
1369
1391
|
);
|
|
1370
1392
|
}
|
|
1371
|
-
return
|
|
1393
|
+
return ok8({ model, effort });
|
|
1372
1394
|
}
|
|
1373
1395
|
|
|
1374
1396
|
// src/modules/xyq/xyq-types.ts
|
|
1375
1397
|
var XYQ_ORIGIN = "https://xyq.jianying.com";
|
|
1376
1398
|
var XYQ_SESSION_COOKIE_NAME = "sessionid_pippitcn_web";
|
|
1377
|
-
var SEEDANCE_PPE_CONFIG_KEY = "seedance.ppe";
|
|
1378
|
-
var SEEDANCE_DEFAULT_PPE = "ppe_wyfree";
|
|
1379
1399
|
var XYQ_TASK_ID_PREFIX = "xyq:";
|
|
1380
1400
|
var XYQ_IMAGE_TASK_ID_PREFIX = "xyq-image:";
|
|
1381
1401
|
var XYQ_VIDEO_MODEL_ID_MAP = {
|
|
@@ -1456,7 +1476,9 @@ var XyqSession = class {
|
|
|
1456
1476
|
if (!normalizedInputResult.ok) {
|
|
1457
1477
|
return normalizedInputResult;
|
|
1458
1478
|
}
|
|
1459
|
-
const
|
|
1479
|
+
const ppeHeadersResult = await readXyqGenerationPpeHeaders(this._settingsReader);
|
|
1480
|
+
if (!ppeHeadersResult.ok) return ppeHeadersResult;
|
|
1481
|
+
const projectResult = await this._createImageProject(ppeHeadersResult.value);
|
|
1460
1482
|
if (!projectResult.ok) return projectResult;
|
|
1461
1483
|
const threadId = `p${projectResult.value.projectId}_${randomUUID4()}`;
|
|
1462
1484
|
const clientRunId = `canvas_run_${randomUUID4()}`;
|
|
@@ -1484,7 +1506,11 @@ var XyqSession = class {
|
|
|
1484
1506
|
submitUrl.toString(),
|
|
1485
1507
|
{
|
|
1486
1508
|
method: "POST",
|
|
1487
|
-
headers: {
|
|
1509
|
+
headers: {
|
|
1510
|
+
...this._headers(),
|
|
1511
|
+
...ppeHeadersResult.value,
|
|
1512
|
+
"content-type": "application/json"
|
|
1513
|
+
},
|
|
1488
1514
|
body: JSON.stringify(body)
|
|
1489
1515
|
},
|
|
1490
1516
|
{
|
|
@@ -1494,7 +1520,7 @@ var XyqSession = class {
|
|
|
1494
1520
|
}
|
|
1495
1521
|
);
|
|
1496
1522
|
if (!responseResult.ok) return responseResult;
|
|
1497
|
-
return
|
|
1523
|
+
return ok9({
|
|
1498
1524
|
taskId: `${XYQ_IMAGE_TASK_ID_PREFIX}${threadId}`,
|
|
1499
1525
|
threadId,
|
|
1500
1526
|
clientRunId,
|
|
@@ -1511,12 +1537,18 @@ var XyqSession = class {
|
|
|
1511
1537
|
if (!threadId) {
|
|
1512
1538
|
return xyqError(XyqErrorCode.InvalidImageRequest, "\u67E5\u8BE2 XYQ \u56FE\u7247\u4EFB\u52A1\u65F6 threadId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
1513
1539
|
}
|
|
1540
|
+
const ppeHeadersResult = await readXyqGenerationPpeHeaders(this._settingsReader);
|
|
1541
|
+
if (!ppeHeadersResult.ok) return ppeHeadersResult;
|
|
1514
1542
|
const threadResult = await requestXyqJson(
|
|
1515
1543
|
this._fetcher,
|
|
1516
1544
|
`${XYQ_ORIGIN}/api/biz/v1/agent/get_thread`,
|
|
1517
1545
|
{
|
|
1518
1546
|
method: "POST",
|
|
1519
|
-
headers: {
|
|
1547
|
+
headers: {
|
|
1548
|
+
...this._headers(),
|
|
1549
|
+
...ppeHeadersResult.value,
|
|
1550
|
+
"content-type": "application/json"
|
|
1551
|
+
},
|
|
1520
1552
|
body: JSON.stringify({
|
|
1521
1553
|
thread_id: threadId,
|
|
1522
1554
|
...requestedRunId ? { run_id: requestedRunId } : {},
|
|
@@ -1541,7 +1573,7 @@ var XyqSession = class {
|
|
|
1541
1573
|
const artifacts = entryList.map(extractImageArtifact).filter((artifact) => artifact !== void 0);
|
|
1542
1574
|
const providerState = mapXyqRunState(toNumber(runRecord.state));
|
|
1543
1575
|
const state = hasUsableImageOutput(artifacts) ? "completed" : providerState;
|
|
1544
|
-
return
|
|
1576
|
+
return ok9({
|
|
1545
1577
|
taskId: `${XYQ_IMAGE_TASK_ID_PREFIX}${threadId}`,
|
|
1546
1578
|
threadId,
|
|
1547
1579
|
...serverRunId ? { runId: serverRunId } : {},
|
|
@@ -1564,10 +1596,10 @@ var XyqSession = class {
|
|
|
1564
1596
|
const result = await this.queryImage(input);
|
|
1565
1597
|
if (!result.ok) return result;
|
|
1566
1598
|
if (isTerminalXyqTaskState(result.value.state)) {
|
|
1567
|
-
return
|
|
1599
|
+
return ok9({ ...result.value, timedOut: false });
|
|
1568
1600
|
}
|
|
1569
1601
|
const remainingMs = deadline - this._now();
|
|
1570
|
-
if (remainingMs <= 0) return
|
|
1602
|
+
if (remainingMs <= 0) return ok9({ ...result.value, timedOut: true });
|
|
1571
1603
|
try {
|
|
1572
1604
|
await this._sleep(Math.min(result.value.retryAfterSeconds * 1e3, remainingMs), input.signal);
|
|
1573
1605
|
} catch (caughtError) {
|
|
@@ -1578,13 +1610,17 @@ var XyqSession = class {
|
|
|
1578
1610
|
}
|
|
1579
1611
|
}
|
|
1580
1612
|
}
|
|
1581
|
-
async _createImageProject() {
|
|
1613
|
+
async _createImageProject(ppeHeaders) {
|
|
1582
1614
|
const responseResult = await requestXyqJson(
|
|
1583
1615
|
this._fetcher,
|
|
1584
1616
|
`${XYQ_ORIGIN}/api/biz/v1/agent/create_creative_project_canvas`,
|
|
1585
1617
|
{
|
|
1586
1618
|
method: "POST",
|
|
1587
|
-
headers: {
|
|
1619
|
+
headers: {
|
|
1620
|
+
...this._headers(),
|
|
1621
|
+
...ppeHeaders,
|
|
1622
|
+
"content-type": "application/json"
|
|
1623
|
+
},
|
|
1588
1624
|
body: JSON.stringify({
|
|
1589
1625
|
user_info: {
|
|
1590
1626
|
consumer_uid: this.context.uid,
|
|
@@ -1611,7 +1647,7 @@ var XyqSession = class {
|
|
|
1611
1647
|
"\u521B\u5EFA XYQ \u56FE\u7247\u753B\u5E03\u9879\u76EE\u6210\u529F\uFF0C\u4F46\u54CD\u5E94\u7F3A\u5C11 project_id \u6216 canvas_asset_id"
|
|
1612
1648
|
);
|
|
1613
1649
|
}
|
|
1614
|
-
return
|
|
1650
|
+
return ok9({ projectId, canvasAssetId });
|
|
1615
1651
|
}
|
|
1616
1652
|
async submitAudio(input) {
|
|
1617
1653
|
const prompt = input.prompt.trim();
|
|
@@ -1621,11 +1657,14 @@ var XyqSession = class {
|
|
|
1621
1657
|
"XYQ \u97F3\u9891\u63D0\u793A\u8BCD\u4E0D\u80FD\u4E3A\u7A7A"
|
|
1622
1658
|
);
|
|
1623
1659
|
}
|
|
1660
|
+
const ppeHeadersResult = await readXyqGenerationPpeHeaders(this._settingsReader);
|
|
1661
|
+
if (!ppeHeadersResult.ok) return ppeHeadersResult;
|
|
1624
1662
|
const threadId = randomUUID4();
|
|
1625
1663
|
const clientRunId = `canvas_run_${randomUUID4()}`;
|
|
1626
1664
|
const messageId = randomUUID4();
|
|
1627
1665
|
const requestId = randomUUID4();
|
|
1628
1666
|
const submittedAt = this._now();
|
|
1667
|
+
const runExtra = buildAudioRunExtra(clientRunId, messageId);
|
|
1629
1668
|
const body = buildSubmitAudioBody({
|
|
1630
1669
|
prompt,
|
|
1631
1670
|
referenceAudioPippitAssetId: normalizeString2(input.pippitAssetId),
|
|
@@ -1634,15 +1673,20 @@ var XyqSession = class {
|
|
|
1634
1673
|
messageId,
|
|
1635
1674
|
requestId,
|
|
1636
1675
|
submittedAt,
|
|
1637
|
-
context: this.context
|
|
1676
|
+
context: this.context,
|
|
1677
|
+
runExtra
|
|
1638
1678
|
});
|
|
1679
|
+
const submitUrl = new URL(`${XYQ_ORIGIN}/api/biz/v1/agent/submit_run`);
|
|
1680
|
+
const { generate_id: _generateId, ...queryBabiParam } = runExtra.babi_param;
|
|
1681
|
+
submitUrl.searchParams.set("babi_param", JSON.stringify(queryBabiParam));
|
|
1639
1682
|
const responseResult = await requestXyqJson(
|
|
1640
1683
|
this._fetcher,
|
|
1641
|
-
|
|
1684
|
+
submitUrl.toString(),
|
|
1642
1685
|
{
|
|
1643
1686
|
method: "POST",
|
|
1644
1687
|
headers: {
|
|
1645
1688
|
...this._headers(),
|
|
1689
|
+
...ppeHeadersResult.value,
|
|
1646
1690
|
"content-type": "application/json"
|
|
1647
1691
|
},
|
|
1648
1692
|
body: JSON.stringify(body)
|
|
@@ -1656,7 +1700,7 @@ var XyqSession = class {
|
|
|
1656
1700
|
if (!responseResult.ok) {
|
|
1657
1701
|
return responseResult;
|
|
1658
1702
|
}
|
|
1659
|
-
return
|
|
1703
|
+
return ok9({
|
|
1660
1704
|
taskId: createXyqTaskId(threadId),
|
|
1661
1705
|
threadId,
|
|
1662
1706
|
clientRunId,
|
|
@@ -1674,6 +1718,8 @@ var XyqSession = class {
|
|
|
1674
1718
|
"\u67E5\u8BE2 XYQ \u97F3\u9891\u4EFB\u52A1\u65F6 threadId \u4E0D\u80FD\u4E3A\u7A7A"
|
|
1675
1719
|
);
|
|
1676
1720
|
}
|
|
1721
|
+
const ppeHeadersResult = await readXyqGenerationPpeHeaders(this._settingsReader);
|
|
1722
|
+
if (!ppeHeadersResult.ok) return ppeHeadersResult;
|
|
1677
1723
|
const threadResult = await requestXyqJson(
|
|
1678
1724
|
this._fetcher,
|
|
1679
1725
|
`${XYQ_ORIGIN}/api/biz/v1/agent/get_thread`,
|
|
@@ -1681,6 +1727,7 @@ var XyqSession = class {
|
|
|
1681
1727
|
method: "POST",
|
|
1682
1728
|
headers: {
|
|
1683
1729
|
...this._headers(),
|
|
1730
|
+
...ppeHeadersResult.value,
|
|
1684
1731
|
"content-type": "application/json"
|
|
1685
1732
|
},
|
|
1686
1733
|
body: JSON.stringify({
|
|
@@ -1712,7 +1759,7 @@ var XyqSession = class {
|
|
|
1712
1759
|
const providerState = mapXyqRunState(toNumber(runRecord.state));
|
|
1713
1760
|
const state = hasUsableAudioOutput(artifacts) ? "completed" : providerState;
|
|
1714
1761
|
const retryAfterSeconds = isTerminalXyqTaskState(state) ? 0 : 2;
|
|
1715
|
-
return
|
|
1762
|
+
return ok9({
|
|
1716
1763
|
taskId: createXyqTaskId(threadId),
|
|
1717
1764
|
threadId,
|
|
1718
1765
|
...serverRunId ? { runId: serverRunId } : {},
|
|
@@ -1743,11 +1790,11 @@ var XyqSession = class {
|
|
|
1743
1790
|
return result;
|
|
1744
1791
|
}
|
|
1745
1792
|
if (isTerminalXyqTaskState(result.value.state)) {
|
|
1746
|
-
return
|
|
1793
|
+
return ok9({ ...result.value, timedOut: false });
|
|
1747
1794
|
}
|
|
1748
1795
|
const remainingMs = deadline - this._now();
|
|
1749
1796
|
if (remainingMs <= 0) {
|
|
1750
|
-
return
|
|
1797
|
+
return ok9({ ...result.value, timedOut: true });
|
|
1751
1798
|
}
|
|
1752
1799
|
try {
|
|
1753
1800
|
await this._sleep(
|
|
@@ -1770,7 +1817,7 @@ var XyqSession = class {
|
|
|
1770
1817
|
if (!normalizedInputResult.ok) {
|
|
1771
1818
|
return normalizedInputResult;
|
|
1772
1819
|
}
|
|
1773
|
-
const ppeHeadersResult = await this.
|
|
1820
|
+
const ppeHeadersResult = await readXyqGenerationPpeHeaders(this._settingsReader);
|
|
1774
1821
|
if (!ppeHeadersResult.ok) {
|
|
1775
1822
|
return ppeHeadersResult;
|
|
1776
1823
|
}
|
|
@@ -1815,7 +1862,7 @@ var XyqSession = class {
|
|
|
1815
1862
|
if (!responseResult.ok) {
|
|
1816
1863
|
return responseResult;
|
|
1817
1864
|
}
|
|
1818
|
-
return
|
|
1865
|
+
return ok9({
|
|
1819
1866
|
taskId: threadId,
|
|
1820
1867
|
threadId,
|
|
1821
1868
|
clientRunId,
|
|
@@ -1833,6 +1880,8 @@ var XyqSession = class {
|
|
|
1833
1880
|
"\u67E5\u8BE2 XYQ \u89C6\u9891\u4EFB\u52A1\u65F6 threadId \u4E0D\u80FD\u4E3A\u7A7A"
|
|
1834
1881
|
);
|
|
1835
1882
|
}
|
|
1883
|
+
const ppeHeadersResult = await readXyqGenerationPpeHeaders(this._settingsReader);
|
|
1884
|
+
if (!ppeHeadersResult.ok) return ppeHeadersResult;
|
|
1836
1885
|
const threadResult = await requestXyqJson(
|
|
1837
1886
|
this._fetcher,
|
|
1838
1887
|
`${XYQ_ORIGIN}/api/biz/v1/agent/get_thread`,
|
|
@@ -1840,6 +1889,7 @@ var XyqSession = class {
|
|
|
1840
1889
|
method: "POST",
|
|
1841
1890
|
headers: {
|
|
1842
1891
|
...this._headers(),
|
|
1892
|
+
...ppeHeadersResult.value,
|
|
1843
1893
|
"content-type": "application/json"
|
|
1844
1894
|
},
|
|
1845
1895
|
body: JSON.stringify({
|
|
@@ -1871,7 +1921,7 @@ var XyqSession = class {
|
|
|
1871
1921
|
const providerState = mapXyqRunState(toNumber(runRecord.state));
|
|
1872
1922
|
const state = hasUsableVideoOutput(artifacts) ? "completed" : providerState;
|
|
1873
1923
|
const retryAfterSeconds = isTerminalXyqTaskState(state) ? 0 : VIDEO_POLL_INTERVAL_SECONDS;
|
|
1874
|
-
return
|
|
1924
|
+
return ok9({
|
|
1875
1925
|
taskId: threadId,
|
|
1876
1926
|
threadId,
|
|
1877
1927
|
...serverRunId ? { runId: serverRunId } : {},
|
|
@@ -1903,11 +1953,11 @@ var XyqSession = class {
|
|
|
1903
1953
|
return result;
|
|
1904
1954
|
}
|
|
1905
1955
|
if (isTerminalXyqTaskState(result.value.state)) {
|
|
1906
|
-
return
|
|
1956
|
+
return ok9({ ...result.value, timedOut: false });
|
|
1907
1957
|
}
|
|
1908
1958
|
const remainingMs = deadline - this._now();
|
|
1909
1959
|
if (remainingMs <= 0) {
|
|
1910
|
-
return
|
|
1960
|
+
return ok9({ ...result.value, timedOut: true });
|
|
1911
1961
|
}
|
|
1912
1962
|
try {
|
|
1913
1963
|
await this._sleep(
|
|
@@ -1959,7 +2009,7 @@ var XyqSession = class {
|
|
|
1959
2009
|
if (!result.ok) {
|
|
1960
2010
|
return result;
|
|
1961
2011
|
}
|
|
1962
|
-
return
|
|
2012
|
+
return ok9({
|
|
1963
2013
|
...result.value,
|
|
1964
2014
|
metadata: {
|
|
1965
2015
|
...result.value.metadata,
|
|
@@ -2045,7 +2095,7 @@ var XyqSession = class {
|
|
|
2045
2095
|
...uploadData,
|
|
2046
2096
|
...preview
|
|
2047
2097
|
});
|
|
2048
|
-
return
|
|
2098
|
+
return ok9({
|
|
2049
2099
|
...camelizedAsset,
|
|
2050
2100
|
assetId,
|
|
2051
2101
|
pippitAssetId,
|
|
@@ -2073,28 +2123,6 @@ var XyqSession = class {
|
|
|
2073
2123
|
referer: `${XYQ_ORIGIN}/`
|
|
2074
2124
|
};
|
|
2075
2125
|
}
|
|
2076
|
-
async _readSubmitPpeHeaders() {
|
|
2077
|
-
if (!this._settingsReader) {
|
|
2078
|
-
return ok8({
|
|
2079
|
-
"x-tt-env": SEEDANCE_DEFAULT_PPE,
|
|
2080
|
-
"x-use-ppe": "1"
|
|
2081
|
-
});
|
|
2082
|
-
}
|
|
2083
|
-
const settingResult = await this._settingsReader.getString(
|
|
2084
|
-
SEEDANCE_PPE_CONFIG_KEY
|
|
2085
|
-
);
|
|
2086
|
-
if (!settingResult.ok) {
|
|
2087
|
-
return xyqError(
|
|
2088
|
-
XyqErrorCode.SettingsReadFailed,
|
|
2089
|
-
`\u8BFB\u53D6 Seedance PPE \u8BBE\u7F6E\u5931\u8D25: ${settingResult.msg}`
|
|
2090
|
-
);
|
|
2091
|
-
}
|
|
2092
|
-
const ppe = normalizeString2(settingResult.value) ?? SEEDANCE_DEFAULT_PPE;
|
|
2093
|
-
return ok8({
|
|
2094
|
-
"x-tt-env": ppe,
|
|
2095
|
-
"x-use-ppe": "1"
|
|
2096
|
-
});
|
|
2097
|
-
}
|
|
2098
2126
|
};
|
|
2099
2127
|
function normalizeImageInput(input) {
|
|
2100
2128
|
const modelResult = resolveXyqImageModel(input.model, input.effort);
|
|
@@ -2115,7 +2143,7 @@ function normalizeImageInput(input) {
|
|
|
2115
2143
|
}
|
|
2116
2144
|
pippitAssetIds.push(id);
|
|
2117
2145
|
}
|
|
2118
|
-
return
|
|
2146
|
+
return ok9({
|
|
2119
2147
|
prompt,
|
|
2120
2148
|
pippitAssetIds,
|
|
2121
2149
|
imageCount,
|
|
@@ -2210,29 +2238,6 @@ function buildSubmitAudioBody(input) {
|
|
|
2210
2238
|
]
|
|
2211
2239
|
} : {}
|
|
2212
2240
|
};
|
|
2213
|
-
const runExtra = {
|
|
2214
|
-
babi_param: {
|
|
2215
|
-
generate_id: input.clientRunId,
|
|
2216
|
-
user_message_id: input.messageId,
|
|
2217
|
-
section_id: input.clientRunId,
|
|
2218
|
-
scene_lv1: "ai_agent",
|
|
2219
|
-
scene_lv2: "front_tool",
|
|
2220
|
-
tool_id: "novel_canvas",
|
|
2221
|
-
tab_name: "canvas",
|
|
2222
|
-
edit_type: "novel",
|
|
2223
|
-
enter_from: "web"
|
|
2224
|
-
},
|
|
2225
|
-
client_extra: {
|
|
2226
|
-
canvas_type: "novel",
|
|
2227
|
-
edit_type: "novel",
|
|
2228
|
-
position: "canvas",
|
|
2229
|
-
entrance_from: "web",
|
|
2230
|
-
tab_name: "canvas",
|
|
2231
|
-
target: "audio",
|
|
2232
|
-
run_source: "canvas_raw_audio_generation",
|
|
2233
|
-
placement_name: "canvas"
|
|
2234
|
-
}
|
|
2235
|
-
};
|
|
2236
2241
|
return {
|
|
2237
2242
|
message: {
|
|
2238
2243
|
content: [
|
|
@@ -2259,10 +2264,35 @@ function buildSubmitAudioBody(input) {
|
|
|
2259
2264
|
},
|
|
2260
2265
|
agent_name: "pippit_audio_part_agent",
|
|
2261
2266
|
entrance_from: "web_audio_direct",
|
|
2262
|
-
run_extra: JSON.stringify(runExtra),
|
|
2267
|
+
run_extra: JSON.stringify(input.runExtra),
|
|
2263
2268
|
request_id: input.requestId
|
|
2264
2269
|
};
|
|
2265
2270
|
}
|
|
2271
|
+
function buildAudioRunExtra(clientRunId, messageId) {
|
|
2272
|
+
return {
|
|
2273
|
+
babi_param: {
|
|
2274
|
+
generate_id: clientRunId,
|
|
2275
|
+
user_message_id: messageId,
|
|
2276
|
+
section_id: clientRunId,
|
|
2277
|
+
scene_lv1: "ai_agent",
|
|
2278
|
+
scene_lv2: "front_tool",
|
|
2279
|
+
tool_id: "novel_canvas",
|
|
2280
|
+
tab_name: "canvas",
|
|
2281
|
+
edit_type: "novel",
|
|
2282
|
+
enter_from: "web"
|
|
2283
|
+
},
|
|
2284
|
+
client_extra: {
|
|
2285
|
+
canvas_type: "novel",
|
|
2286
|
+
edit_type: "novel",
|
|
2287
|
+
position: "canvas",
|
|
2288
|
+
entrance_from: "web",
|
|
2289
|
+
tab_name: "canvas",
|
|
2290
|
+
target: "audio",
|
|
2291
|
+
run_source: "canvas_raw_audio_generation",
|
|
2292
|
+
placement_name: "canvas"
|
|
2293
|
+
}
|
|
2294
|
+
};
|
|
2295
|
+
}
|
|
2266
2296
|
function normalizeVideoPartInput(input) {
|
|
2267
2297
|
const prompt = input.prompt.trim();
|
|
2268
2298
|
if (!prompt) {
|
|
@@ -2301,7 +2331,7 @@ function normalizeVideoPartInput(input) {
|
|
|
2301
2331
|
if (!audiosResult.ok) {
|
|
2302
2332
|
return audiosResult;
|
|
2303
2333
|
}
|
|
2304
|
-
return
|
|
2334
|
+
return ok9({
|
|
2305
2335
|
prompt,
|
|
2306
2336
|
images: imagesResult.value,
|
|
2307
2337
|
videos: videosResult.value,
|
|
@@ -2325,7 +2355,7 @@ function normalizeVideoAssetReferences(assets, label) {
|
|
|
2325
2355
|
}
|
|
2326
2356
|
normalized.push({ asset_id: assetId, pippit_asset_id: pippitAssetId });
|
|
2327
2357
|
}
|
|
2328
|
-
return
|
|
2358
|
+
return ok9(normalized);
|
|
2329
2359
|
}
|
|
2330
2360
|
function buildVideoPartRunExtra(clientRunId, messageId) {
|
|
2331
2361
|
return {
|
|
@@ -2405,7 +2435,7 @@ function parseXyqTaskId(taskId) {
|
|
|
2405
2435
|
if (!threadId) {
|
|
2406
2436
|
return xyqError(XyqErrorCode.InvalidVideoRequest, "XYQ taskId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
2407
2437
|
}
|
|
2408
|
-
return
|
|
2438
|
+
return ok9(threadId);
|
|
2409
2439
|
}
|
|
2410
2440
|
function mapXyqRunState(stateCode) {
|
|
2411
2441
|
switch (stateCode) {
|
|
@@ -2775,7 +2805,7 @@ async function resolveAssetFile(filePath, assetType) {
|
|
|
2775
2805
|
`XYQ ${assetTypeLabel(assetType)}\u683C\u5F0F\u4E0D\u53D7\u652F\u6301: ${resolvedPath}`
|
|
2776
2806
|
);
|
|
2777
2807
|
}
|
|
2778
|
-
return
|
|
2808
|
+
return ok9({ resolvedPath, fileName: path5.basename(resolvedPath) });
|
|
2779
2809
|
}
|
|
2780
2810
|
function assetTypeLabel(assetType) {
|
|
2781
2811
|
if (assetType === "image") {
|
|
@@ -2854,7 +2884,7 @@ var XyqClient = class {
|
|
|
2854
2884
|
if (!options.forceRefresh) {
|
|
2855
2885
|
const session = this._sessions.get(fingerprint);
|
|
2856
2886
|
if (session) {
|
|
2857
|
-
return
|
|
2887
|
+
return ok10(session);
|
|
2858
2888
|
}
|
|
2859
2889
|
const pendingSession2 = this._pendingSessions.get(fingerprint);
|
|
2860
2890
|
if (pendingSession2) {
|
|
@@ -2904,13 +2934,13 @@ var XyqClient = class {
|
|
|
2904
2934
|
`${XYQ_SESSION_COOKIE_NAME} \u5FC5\u987B\u662F\u975E\u7A7A\u7684\u5355\u4E2A Cookie \u503C`
|
|
2905
2935
|
);
|
|
2906
2936
|
}
|
|
2907
|
-
return
|
|
2937
|
+
return ok10(cookie);
|
|
2908
2938
|
}
|
|
2909
2939
|
async _resolveSession(cookie, fingerprint, forceRefresh) {
|
|
2910
2940
|
if (!forceRefresh) {
|
|
2911
2941
|
const cached = await this._readCacheBestEffort();
|
|
2912
2942
|
if (cached?.cookieFingerprint === fingerprint) {
|
|
2913
|
-
return
|
|
2943
|
+
return ok10(this._createSession(cookie, cached));
|
|
2914
2944
|
}
|
|
2915
2945
|
}
|
|
2916
2946
|
const contextResult = await this._fetchSessionContext(cookie);
|
|
@@ -2927,7 +2957,7 @@ var XyqClient = class {
|
|
|
2927
2957
|
if (this._activeFingerprint === fingerprint) {
|
|
2928
2958
|
await this._writeCacheBestEffort(cacheRecord);
|
|
2929
2959
|
}
|
|
2930
|
-
return
|
|
2960
|
+
return ok10(
|
|
2931
2961
|
new XyqSession(contextResult.value, this._fetcher, {
|
|
2932
2962
|
settingsReader: this._settingsReader
|
|
2933
2963
|
})
|
|
@@ -3004,7 +3034,7 @@ var XyqClient = class {
|
|
|
3004
3034
|
"\u83B7\u53D6 XYQ workspace \u6210\u529F\uFF0C\u4F46\u672A\u627E\u5230 workspace_id"
|
|
3005
3035
|
);
|
|
3006
3036
|
}
|
|
3007
|
-
return
|
|
3037
|
+
return ok10({
|
|
3008
3038
|
cookies: { [XYQ_SESSION_COOKIE_NAME]: cookie },
|
|
3009
3039
|
uid,
|
|
3010
3040
|
workspaceId,
|
|
@@ -3103,7 +3133,7 @@ function validateAudioWaitOptions(options) {
|
|
|
3103
3133
|
if (options.outputPath !== void 0 && !options.outputPath.trim()) {
|
|
3104
3134
|
return err7(1, "--output \u4E00\u65E6\u4F20\u5165\u5C31\u5FC5\u987B\u662F\u975E\u7A7A\u8DEF\u5F84");
|
|
3105
3135
|
}
|
|
3106
|
-
return
|
|
3136
|
+
return ok11();
|
|
3107
3137
|
}
|
|
3108
3138
|
async function createDefaultAudioSession() {
|
|
3109
3139
|
return createDefaultXyqClient().createSession();
|
|
@@ -3140,7 +3170,7 @@ async function runAudioTaskToCompletion(options, createSession = createDefaultAu
|
|
|
3140
3170
|
task = waitResult.value;
|
|
3141
3171
|
const outputPath = options.outputPath?.trim();
|
|
3142
3172
|
if (!outputPath || task.timedOut || task.state !== "completed") {
|
|
3143
|
-
return
|
|
3173
|
+
return ok11({ task });
|
|
3144
3174
|
}
|
|
3145
3175
|
stage = "download";
|
|
3146
3176
|
const downloadUrl = findFirstAudioUrl(task);
|
|
@@ -3151,7 +3181,7 @@ async function runAudioTaskToCompletion(options, createSession = createDefaultAu
|
|
|
3151
3181
|
if (!downloaded.ok) {
|
|
3152
3182
|
return err7(downloaded.code, downloaded.msg, context());
|
|
3153
3183
|
}
|
|
3154
|
-
return
|
|
3184
|
+
return ok11({ task, localPath: downloaded.value });
|
|
3155
3185
|
} catch (caughtError) {
|
|
3156
3186
|
const message = caughtError instanceof Error ? caughtError.message : String(caughtError);
|
|
3157
3187
|
return err7(1, message, context());
|
|
@@ -3160,7 +3190,7 @@ async function runAudioTaskToCompletion(options, createSession = createDefaultAu
|
|
|
3160
3190
|
|
|
3161
3191
|
// src/modules/xyq-tasks/video-outputs.ts
|
|
3162
3192
|
import * as path6 from "node:path";
|
|
3163
|
-
import { ok as
|
|
3193
|
+
import { ok as ok12 } from "rockbed/error";
|
|
3164
3194
|
function collectTaskVideoOutputs(result) {
|
|
3165
3195
|
const outputs = /* @__PURE__ */ new Map();
|
|
3166
3196
|
for (const artifact of result.artifacts) {
|
|
@@ -3198,21 +3228,21 @@ async function downloadVideoOutputs(outputs, outputPath, fetcher = globalThis.fe
|
|
|
3198
3228
|
return downloadResult;
|
|
3199
3229
|
}
|
|
3200
3230
|
}
|
|
3201
|
-
return
|
|
3231
|
+
return ok12(targetPaths);
|
|
3202
3232
|
}
|
|
3203
3233
|
function qualityScore(output) {
|
|
3204
3234
|
return (output.width ?? 0) * (output.height ?? 0);
|
|
3205
3235
|
}
|
|
3206
3236
|
|
|
3207
3237
|
// src/modules/xyq-tasks/video-task-runner.ts
|
|
3208
|
-
import { err as err8, ok as
|
|
3238
|
+
import { err as err8, ok as ok13 } from "rockbed/error";
|
|
3209
3239
|
var DEFAULT_VIDEO_WAIT_SECONDS = 360;
|
|
3210
3240
|
var MAX_VIDEO_WAIT_SECONDS = 600;
|
|
3211
3241
|
function validateVideoWaitSeconds(timeoutSeconds) {
|
|
3212
3242
|
if (!Number.isInteger(timeoutSeconds) || timeoutSeconds < 1 || timeoutSeconds > MAX_VIDEO_WAIT_SECONDS) {
|
|
3213
3243
|
return err8(1, `--timeout-seconds \u5FC5\u987B\u662F 1-${MAX_VIDEO_WAIT_SECONDS} \u7684\u6574\u6570`);
|
|
3214
3244
|
}
|
|
3215
|
-
return
|
|
3245
|
+
return ok13();
|
|
3216
3246
|
}
|
|
3217
3247
|
async function runVideoTaskToCompletion(options) {
|
|
3218
3248
|
const timeoutResult = validateVideoWaitSeconds(options.timeoutSeconds);
|
|
@@ -3250,7 +3280,7 @@ async function runVideoTaskToCompletion(options) {
|
|
|
3250
3280
|
}
|
|
3251
3281
|
localPaths = downloadResult.value;
|
|
3252
3282
|
}
|
|
3253
|
-
return
|
|
3283
|
+
return ok13({
|
|
3254
3284
|
task: waitResult.value,
|
|
3255
3285
|
...localPaths ? { localPaths } : {}
|
|
3256
3286
|
});
|
|
@@ -3258,7 +3288,7 @@ async function runVideoTaskToCompletion(options) {
|
|
|
3258
3288
|
|
|
3259
3289
|
// src/commands/ai/ai-audio-status-command.ts
|
|
3260
3290
|
import { Option } from "commander";
|
|
3261
|
-
import { ok as
|
|
3291
|
+
import { ok as ok14 } from "rockbed/error";
|
|
3262
3292
|
|
|
3263
3293
|
// src/commands/ai/ai-audio-task-output.ts
|
|
3264
3294
|
function audioWaitNextCommand(taskId, outputPath) {
|
|
@@ -3326,7 +3356,7 @@ var AiAudioStatusCommand = class extends BaseCommand {
|
|
|
3326
3356
|
if (!result.ok) {
|
|
3327
3357
|
return failFrom(result, context());
|
|
3328
3358
|
}
|
|
3329
|
-
return
|
|
3359
|
+
return ok14(toAudioTaskOutput(result.value));
|
|
3330
3360
|
} catch (caughtError) {
|
|
3331
3361
|
return fail(1, caughtError instanceof Error ? caughtError.message : String(caughtError), context());
|
|
3332
3362
|
}
|
|
@@ -3336,7 +3366,7 @@ var AiAudioStatusCommand = class extends BaseCommand {
|
|
|
3336
3366
|
// src/commands/ai/ai-audio-wait-command.ts
|
|
3337
3367
|
import { resolve as resolve4 } from "node:path";
|
|
3338
3368
|
import { Option as Option2 } from "commander";
|
|
3339
|
-
import { ok as
|
|
3369
|
+
import { ok as ok15 } from "rockbed/error";
|
|
3340
3370
|
var AiAudioWaitCommand = class extends BaseCommand {
|
|
3341
3371
|
constructor(_createSession = createDefaultAudioSession, _downloadAudio = downloadAudioOutput) {
|
|
3342
3372
|
super();
|
|
@@ -3385,7 +3415,7 @@ var AiAudioWaitCommand = class extends BaseCommand {
|
|
|
3385
3415
|
nextCommand: audioWaitNextCommand(options.taskId, outputPath)
|
|
3386
3416
|
});
|
|
3387
3417
|
}
|
|
3388
|
-
return
|
|
3418
|
+
return ok15(toAudioTaskOutput(result.value.task, { localPath: result.value.localPath, outputPath }));
|
|
3389
3419
|
}
|
|
3390
3420
|
};
|
|
3391
3421
|
|
|
@@ -3492,14 +3522,14 @@ var AiAudioCommand = class extends BaseCommandGroup {
|
|
|
3492
3522
|
taskId = submitResult.value.taskId;
|
|
3493
3523
|
progress.dispose();
|
|
3494
3524
|
if (!shouldWait) {
|
|
3495
|
-
return
|
|
3525
|
+
return ok16(toAudioSubmitOutput(taskId));
|
|
3496
3526
|
}
|
|
3497
3527
|
stage = "wait";
|
|
3498
3528
|
const completionResult = await runAudioTaskToCompletion({
|
|
3499
3529
|
taskId,
|
|
3500
3530
|
timeoutSeconds: ctx.options.timeoutSeconds,
|
|
3501
3531
|
outputPath
|
|
3502
|
-
}, async () =>
|
|
3532
|
+
}, async () => ok16(session), this._downloadAudio);
|
|
3503
3533
|
if (!completionResult.ok) {
|
|
3504
3534
|
return failFrom(completionResult, {
|
|
3505
3535
|
taskId,
|
|
@@ -3507,7 +3537,7 @@ var AiAudioCommand = class extends BaseCommandGroup {
|
|
|
3507
3537
|
nextCommand: audioWaitNextCommand(taskId, outputPath)
|
|
3508
3538
|
});
|
|
3509
3539
|
}
|
|
3510
|
-
return
|
|
3540
|
+
return ok16(toAudioTaskOutput(completionResult.value.task, {
|
|
3511
3541
|
localPath: completionResult.value.localPath,
|
|
3512
3542
|
outputPath
|
|
3513
3543
|
}));
|
|
@@ -3528,14 +3558,14 @@ function appendAudioPath(value, previous) {
|
|
|
3528
3558
|
// src/commands/ai/ai-image-command.ts
|
|
3529
3559
|
import * as path10 from "node:path";
|
|
3530
3560
|
import { Option as Option6 } from "commander";
|
|
3531
|
-
import { ok as
|
|
3561
|
+
import { ok as ok24 } from "rockbed/error";
|
|
3532
3562
|
|
|
3533
3563
|
// src/modules/image-generation/image-task-service.ts
|
|
3534
3564
|
import * as path7 from "node:path";
|
|
3535
3565
|
import { fileURLToPath } from "node:url";
|
|
3536
3566
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
3537
3567
|
import { Disposable as Disposable4 } from "rockbed/dispose";
|
|
3538
|
-
import { err as err9, ok as
|
|
3568
|
+
import { err as err9, ok as ok17 } from "rockbed/error";
|
|
3539
3569
|
var ImageTaskService = class extends Disposable4 {
|
|
3540
3570
|
_taskStore;
|
|
3541
3571
|
_launchWorker;
|
|
@@ -3581,17 +3611,17 @@ var ImageTaskService = class extends Disposable4 {
|
|
|
3581
3611
|
const record = await this._taskStore.read(taskId);
|
|
3582
3612
|
const artifact = this._taskStore.artifactPath(taskId);
|
|
3583
3613
|
if ((await validateImageArtifact(artifact)).ok) {
|
|
3584
|
-
return
|
|
3614
|
+
return ok17(toOutput(record, "completed", [{ localPath: artifact }]));
|
|
3585
3615
|
}
|
|
3586
3616
|
if (record.state === "completed") {
|
|
3587
|
-
return
|
|
3617
|
+
return ok17({ ...toOutput(record, "unknown"), failReason: "\u4EFB\u52A1\u66FE\u5B8C\u6210\uFF0C\u4F46\u672C\u5730\u5F52\u6863\u56FE\u7247\u7F3A\u5931\u6216\u635F\u574F\uFF1B\u672A\u91CD\u65B0\u751F\u6210" });
|
|
3588
3618
|
}
|
|
3589
|
-
if (record.state === "failed" || record.state === "unknown") return
|
|
3590
|
-
if (await this._isWorkerAlive(record)) return
|
|
3619
|
+
if (record.state === "failed" || record.state === "unknown") return ok17(toOutput(record));
|
|
3620
|
+
if (await this._isWorkerAlive(record)) return ok17({ ...toOutput(record), retryAfterSeconds: 1 });
|
|
3591
3621
|
const latest = await this._taskStore.read(taskId);
|
|
3592
|
-
if ((await validateImageArtifact(artifact)).ok) return
|
|
3593
|
-
if (latest.state === "failed") return
|
|
3594
|
-
return
|
|
3622
|
+
if ((await validateImageArtifact(artifact)).ok) return ok17(toOutput(latest, "completed", [{ localPath: artifact }]));
|
|
3623
|
+
if (latest.state === "failed") return ok17(toOutput(latest));
|
|
3624
|
+
return ok17({ ...toOutput(latest, "unknown"), failReason: "\u65E0\u6CD5\u786E\u8BA4\u539F\u56FE\u7247 worker \u4ECD\u5728\u8FD0\u884C\uFF0C\u4E14\u672A\u53D1\u73B0\u5B8C\u6574\u5F52\u6863\u4EA7\u7269\uFF1B\u8BF7\u7A0D\u540E\u67E5\u8BE2\u539F\u4EFB\u52A1\uFF0C\u672A\u81EA\u52A8\u6062\u590D\u6216\u91CD\u65B0\u751F\u6210" });
|
|
3595
3625
|
} catch (error) {
|
|
3596
3626
|
return taskError(error, taskId);
|
|
3597
3627
|
}
|
|
@@ -3610,11 +3640,11 @@ var ImageTaskService = class extends Disposable4 {
|
|
|
3610
3640
|
if (!localPath) return err9(1, "\u56FE\u7247\u4EFB\u52A1\u5DF2\u5B8C\u6210\uFF0C\u4F46\u672C\u5730\u5F52\u6863\u8DEF\u5F84\u7F3A\u5931", { taskId });
|
|
3611
3641
|
const copied = await copyImageArtifact(localPath, outputPath);
|
|
3612
3642
|
if (!copied.ok) return err9(copied.code, copied.msg, { taskId, state: "completed", outputs: current.value.outputs, recoverable: true });
|
|
3613
|
-
return
|
|
3643
|
+
return ok17({ ...current.value, outputs: [{ localPath: copied.value }] });
|
|
3614
3644
|
}
|
|
3615
3645
|
if (current.value.state === "failed" || current.value.state === "unknown") return current;
|
|
3616
3646
|
const remaining = deadline - this._now();
|
|
3617
|
-
if (remaining <= 0) return
|
|
3647
|
+
if (remaining <= 0) return ok17({ ...current.value, timedOut: true });
|
|
3618
3648
|
await this._delay(Math.min(remaining, this._pollIntervalMs));
|
|
3619
3649
|
}
|
|
3620
3650
|
}
|
|
@@ -3625,7 +3655,7 @@ var ImageTaskService = class extends Disposable4 {
|
|
|
3625
3655
|
const current = await this.status(taskId);
|
|
3626
3656
|
results.push(current.ok ? current.value : { taskId, state: "unknown", outputs: [], failReason: current.msg });
|
|
3627
3657
|
}
|
|
3628
|
-
return
|
|
3658
|
+
return ok17(results.sort((a, b) => (b.createdAt ?? "").localeCompare(a.createdAt ?? "")));
|
|
3629
3659
|
} catch (error) {
|
|
3630
3660
|
return err9(1, `\u8BFB\u53D6\u56FE\u7247\u4EFB\u52A1\u5217\u8868\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`);
|
|
3631
3661
|
}
|
|
@@ -3669,13 +3699,13 @@ ${constraints.join("\n")}` : void 0
|
|
|
3669
3699
|
}
|
|
3670
3700
|
|
|
3671
3701
|
// src/modules/image-generation/routed-image-task-service.ts
|
|
3672
|
-
import { err as err11, ok as
|
|
3702
|
+
import { err as err11, ok as ok19 } from "rockbed/error";
|
|
3673
3703
|
|
|
3674
3704
|
// src/modules/image-generation/xyq-image-task-service.ts
|
|
3675
3705
|
import * as fs6 from "node:fs/promises";
|
|
3676
3706
|
import { homedir as homedir3 } from "node:os";
|
|
3677
3707
|
import * as path8 from "node:path";
|
|
3678
|
-
import { err as err10, ok as
|
|
3708
|
+
import { err as err10, ok as ok18 } from "rockbed/error";
|
|
3679
3709
|
var XyqImageTaskService = class {
|
|
3680
3710
|
_createSession;
|
|
3681
3711
|
_downloadDirectory;
|
|
@@ -3711,7 +3741,7 @@ var XyqImageTaskService = class {
|
|
|
3711
3741
|
aspectRatio: request.aspectRatio
|
|
3712
3742
|
});
|
|
3713
3743
|
if (!submit.ok) return submit;
|
|
3714
|
-
return
|
|
3744
|
+
return ok18({
|
|
3715
3745
|
taskId: submit.value.taskId,
|
|
3716
3746
|
state: "submitted",
|
|
3717
3747
|
outputs: [],
|
|
@@ -3726,7 +3756,7 @@ var XyqImageTaskService = class {
|
|
|
3726
3756
|
const sessionResult = await this._createSession();
|
|
3727
3757
|
if (!sessionResult.ok) return sessionResult;
|
|
3728
3758
|
const result = await sessionResult.value.queryImage({ threadId: threadIdResult.value });
|
|
3729
|
-
return result.ok ?
|
|
3759
|
+
return result.ok ? ok18(await this._toTaskResult(result.value)) : result;
|
|
3730
3760
|
}
|
|
3731
3761
|
async wait(options) {
|
|
3732
3762
|
const threadIdResult = parseXyqImageTaskId(options.taskId);
|
|
@@ -3740,11 +3770,11 @@ var XyqImageTaskService = class {
|
|
|
3740
3770
|
if (!result.ok) return result;
|
|
3741
3771
|
const task = await this._toTaskResult(result.value);
|
|
3742
3772
|
if (task.state !== "completed") {
|
|
3743
|
-
return
|
|
3773
|
+
return ok18({ ...task, ...result.value.timedOut ? { timedOut: true } : {} });
|
|
3744
3774
|
}
|
|
3745
3775
|
const remoteOutputs = collectXyqImageOutputs(result.value);
|
|
3746
3776
|
if (remoteOutputs.length === 0) return err10(1, "XYQ \u56FE\u7247\u4EFB\u52A1\u5DF2\u5B8C\u6210\uFF0C\u4F46\u6CA1\u6709\u627E\u5230\u56FE\u7247\u4E0B\u8F7D\u5730\u5740");
|
|
3747
|
-
if (!options.outputPath) return
|
|
3777
|
+
if (!options.outputPath) return ok18(task);
|
|
3748
3778
|
const targets = resolveImageOutputPaths(
|
|
3749
3779
|
options.outputPath,
|
|
3750
3780
|
remoteOutputs.length
|
|
@@ -3758,10 +3788,10 @@ var XyqImageTaskService = class {
|
|
|
3758
3788
|
if (!downloaded.ok) return downloaded;
|
|
3759
3789
|
outputs.push(toTaskOutput(output, downloaded.value));
|
|
3760
3790
|
}
|
|
3761
|
-
return
|
|
3791
|
+
return ok18({ ...task, outputs });
|
|
3762
3792
|
}
|
|
3763
3793
|
async list() {
|
|
3764
|
-
return
|
|
3794
|
+
return ok18([]);
|
|
3765
3795
|
}
|
|
3766
3796
|
async _toTaskResult(result) {
|
|
3767
3797
|
const remoteOutputs = collectXyqImageOutputs(result);
|
|
@@ -3789,7 +3819,7 @@ function parseXyqImageTaskId(taskId) {
|
|
|
3789
3819
|
return err10(1, `XYQ \u56FE\u7247 task-id \u683C\u5F0F\u5FC5\u987B\u662F ${XYQ_IMAGE_TASK_ID_PREFIX}<threadId>`);
|
|
3790
3820
|
}
|
|
3791
3821
|
const threadId = normalized.slice(XYQ_IMAGE_TASK_ID_PREFIX.length).trim();
|
|
3792
|
-
return threadId ?
|
|
3822
|
+
return threadId ? ok18(threadId) : err10(1, "XYQ \u56FE\u7247 taskId \u4E0D\u80FD\u4E3A\u7A7A");
|
|
3793
3823
|
}
|
|
3794
3824
|
function collectXyqImageOutputs(result) {
|
|
3795
3825
|
const outputs = /* @__PURE__ */ new Map();
|
|
@@ -3863,7 +3893,7 @@ var RoutedImageTaskService = class {
|
|
|
3863
3893
|
}
|
|
3864
3894
|
async list() {
|
|
3865
3895
|
const local = await this._localService.list();
|
|
3866
|
-
return local.ok ?
|
|
3896
|
+
return local.ok ? ok19(local.value) : local;
|
|
3867
3897
|
}
|
|
3868
3898
|
_serviceForTask(taskId) {
|
|
3869
3899
|
return taskId.trim().startsWith(XYQ_IMAGE_TASK_ID_PREFIX) ? this._xyqService : this._localService;
|
|
@@ -3878,10 +3908,10 @@ function createDefaultImageTaskService() {
|
|
|
3878
3908
|
}
|
|
3879
3909
|
|
|
3880
3910
|
// src/commands/ai/ai-image-list-command.ts
|
|
3881
|
-
import { ok as
|
|
3911
|
+
import { ok as ok21 } from "rockbed/error";
|
|
3882
3912
|
|
|
3883
3913
|
// src/commands/ai/ai-image-task-output.ts
|
|
3884
|
-
import { ok as
|
|
3914
|
+
import { ok as ok20 } from "rockbed/error";
|
|
3885
3915
|
var DEFAULT_IMAGE_WAIT_SECONDS = 360;
|
|
3886
3916
|
var MAX_IMAGE_WAIT_SECONDS = 600;
|
|
3887
3917
|
function validateImageWaitOptions(timeoutSeconds, outputPath) {
|
|
@@ -3891,7 +3921,7 @@ function validateImageWaitOptions(timeoutSeconds, outputPath) {
|
|
|
3891
3921
|
if (outputPath !== void 0 && !outputPath.trim()) {
|
|
3892
3922
|
return fail(1, "--output \u4E00\u65E6\u4F20\u5165\u5C31\u5FC5\u987B\u662F\u975E\u7A7A\u8DEF\u5F84", { stage: "input" });
|
|
3893
3923
|
}
|
|
3894
|
-
return
|
|
3924
|
+
return ok20();
|
|
3895
3925
|
}
|
|
3896
3926
|
function imageWaitCommand(taskId, outputPath) {
|
|
3897
3927
|
return `tt ai image wait --task-id ${quoteArgument2(taskId)}${outputPath ? ` --output ${quoteArgument2(outputPath)}` : ""}`;
|
|
@@ -3935,13 +3965,13 @@ var AiImageListCommand = class extends BaseCommand {
|
|
|
3935
3965
|
}
|
|
3936
3966
|
async _execute() {
|
|
3937
3967
|
const result = await this._service.list();
|
|
3938
|
-
return result.ok ?
|
|
3968
|
+
return result.ok ? ok21({ tasks: result.value.map((task) => toImageTaskOutput(task)) }) : failFrom(result, { stage: "query" });
|
|
3939
3969
|
}
|
|
3940
3970
|
};
|
|
3941
3971
|
|
|
3942
3972
|
// src/commands/ai/ai-image-status-command.ts
|
|
3943
3973
|
import { Option as Option4 } from "commander";
|
|
3944
|
-
import { ok as
|
|
3974
|
+
import { ok as ok22 } from "rockbed/error";
|
|
3945
3975
|
var AiImageStatusCommand = class extends BaseCommand {
|
|
3946
3976
|
constructor(_service = createDefaultImageTaskService()) {
|
|
3947
3977
|
super();
|
|
@@ -3966,14 +3996,14 @@ var AiImageStatusCommand = class extends BaseCommand {
|
|
|
3966
3996
|
}
|
|
3967
3997
|
async _execute(ctx) {
|
|
3968
3998
|
const result = await this._service.status(ctx.options.taskId);
|
|
3969
|
-
return result.ok ?
|
|
3999
|
+
return result.ok ? ok22(toImageTaskOutput(result.value)) : failFrom(result, { taskId: ctx.options.taskId, stage: "query" });
|
|
3970
4000
|
}
|
|
3971
4001
|
};
|
|
3972
4002
|
|
|
3973
4003
|
// src/commands/ai/ai-image-wait-command.ts
|
|
3974
4004
|
import * as path9 from "node:path";
|
|
3975
4005
|
import { Option as Option5 } from "commander";
|
|
3976
|
-
import { ok as
|
|
4006
|
+
import { ok as ok23 } from "rockbed/error";
|
|
3977
4007
|
var AiImageWaitCommand = class extends BaseCommand {
|
|
3978
4008
|
constructor(_service = createDefaultImageTaskService()) {
|
|
3979
4009
|
super();
|
|
@@ -4006,7 +4036,7 @@ var AiImageWaitCommand = class extends BaseCommand {
|
|
|
4006
4036
|
const outputPath = options.output === void 0 ? void 0 : path9.resolve(options.output.trim());
|
|
4007
4037
|
try {
|
|
4008
4038
|
const result = await this._service.wait({ taskId: options.taskId, timeoutSeconds: options.timeoutSeconds, outputPath });
|
|
4009
|
-
return result.ok ?
|
|
4039
|
+
return result.ok ? ok23(toImageTaskOutput(result.value, outputPath)) : imageTaskFailure(result, options.taskId, outputPath);
|
|
4010
4040
|
} catch (error) {
|
|
4011
4041
|
return imageTaskFailure(fail(1, error instanceof Error ? error.message : String(error)), options.taskId, outputPath);
|
|
4012
4042
|
}
|
|
@@ -4113,11 +4143,11 @@ var AiImageCommand = class extends BaseCommandGroup {
|
|
|
4113
4143
|
...source === "xyq" ? {} : { nextCommand: "tt ai image list" }
|
|
4114
4144
|
});
|
|
4115
4145
|
}
|
|
4116
|
-
if (!options.wait && options.output === void 0) return
|
|
4146
|
+
if (!options.wait && options.output === void 0) return ok24(toImageTaskOutput(submit.value));
|
|
4117
4147
|
const taskId = submit.value.taskId;
|
|
4118
4148
|
try {
|
|
4119
4149
|
const result = await this._service.wait({ taskId, timeoutSeconds: options.timeoutSeconds, outputPath });
|
|
4120
|
-
return result.ok ?
|
|
4150
|
+
return result.ok ? ok24(toImageTaskOutput(result.value, outputPath)) : imageTaskFailure(result, taskId, outputPath);
|
|
4121
4151
|
} catch (error) {
|
|
4122
4152
|
return imageTaskFailure(fail(1, error instanceof Error ? error.message : String(error)), taskId, outputPath);
|
|
4123
4153
|
}
|
|
@@ -4133,7 +4163,7 @@ function readFailureSource(value) {
|
|
|
4133
4163
|
}
|
|
4134
4164
|
|
|
4135
4165
|
// src/commands/ai/ai-querytask-command.ts
|
|
4136
|
-
import { ok as
|
|
4166
|
+
import { ok as ok25 } from "rockbed/error";
|
|
4137
4167
|
var BIN = "xx";
|
|
4138
4168
|
var PPE_ENV = "ppe_new_login_cli";
|
|
4139
4169
|
var POLL_INTERVAL_MS = 5e3;
|
|
@@ -4179,7 +4209,7 @@ var AiQueryTaskCommand = class extends BaseCommand {
|
|
|
4179
4209
|
const parsed = tryParseJson(queryResult.value.stdout.trim());
|
|
4180
4210
|
const status = extractStatus(parsed);
|
|
4181
4211
|
if (status !== RUNNING_STATUS) {
|
|
4182
|
-
return
|
|
4212
|
+
return ok25({
|
|
4183
4213
|
taskId,
|
|
4184
4214
|
...status ? { status } : {},
|
|
4185
4215
|
result: parsed ?? queryResult.value.stdout
|
|
@@ -4235,13 +4265,13 @@ function delay(ms) {
|
|
|
4235
4265
|
// src/commands/ai/ai-run-command.ts
|
|
4236
4266
|
import { homedir as homedir5 } from "node:os";
|
|
4237
4267
|
import { join as join6 } from "node:path";
|
|
4238
|
-
import { err as err13, ok as
|
|
4268
|
+
import { err as err13, ok as ok27 } from "rockbed/error";
|
|
4239
4269
|
|
|
4240
4270
|
// src/commands/ai/ai-context-path.ts
|
|
4241
4271
|
import { existsSync } from "node:fs";
|
|
4242
4272
|
import { homedir as homedir4 } from "node:os";
|
|
4243
4273
|
import { join as join5 } from "node:path";
|
|
4244
|
-
import { err as err12, ok as
|
|
4274
|
+
import { err as err12, ok as ok26 } from "rockbed/error";
|
|
4245
4275
|
function getCurrentCloudRootPath() {
|
|
4246
4276
|
if (process.platform !== "darwin") {
|
|
4247
4277
|
return err12(1, "`--my` \u4EC5\u652F\u6301\u5728 macOS \u4E0A\u4F7F\u7528");
|
|
@@ -4255,13 +4285,13 @@ function getCurrentCloudRootPath() {
|
|
|
4255
4285
|
if (!existsSync(cloudRootPath)) {
|
|
4256
4286
|
return err12(1, `\u672A\u627E\u5230 iCloud \u76EE\u5F55: ${cloudRootPath}`);
|
|
4257
4287
|
}
|
|
4258
|
-
return
|
|
4288
|
+
return ok26(cloudRootPath);
|
|
4259
4289
|
}
|
|
4260
4290
|
function ensureDirectoryExists(dirPath) {
|
|
4261
4291
|
if (!existsSync(dirPath)) {
|
|
4262
4292
|
return err12(1, `\u672A\u627E\u5230\u76EE\u5F55: ${dirPath}`);
|
|
4263
4293
|
}
|
|
4264
|
-
return
|
|
4294
|
+
return ok26(dirPath);
|
|
4265
4295
|
}
|
|
4266
4296
|
|
|
4267
4297
|
// src/commands/ai/ai-run-command.ts
|
|
@@ -4336,7 +4366,7 @@ function buildPromptWithContext(options, prompt) {
|
|
|
4336
4366
|
}
|
|
4337
4367
|
reminders.push(createSystemReminder(referenceDir.value));
|
|
4338
4368
|
}
|
|
4339
|
-
return
|
|
4369
|
+
return ok27(reminders.length === 0 ? prompt : [...reminders, prompt].join("\n"));
|
|
4340
4370
|
}
|
|
4341
4371
|
function createSystemReminder(referenceDir) {
|
|
4342
4372
|
return `<system-reminder>
|
|
@@ -4351,7 +4381,7 @@ user_prompt:
|
|
|
4351
4381
|
|
|
4352
4382
|
// src/commands/ai/ai-video-command.ts
|
|
4353
4383
|
import { Option as Option9 } from "commander";
|
|
4354
|
-
import { ok as
|
|
4384
|
+
import { ok as ok32 } from "rockbed/error";
|
|
4355
4385
|
|
|
4356
4386
|
// src/modules/video-generation/video-generation-provider-registry.ts
|
|
4357
4387
|
var VideoGenerationProviderRegistry = class {
|
|
@@ -4383,7 +4413,7 @@ var VideoGenerationProviderRegistry = class {
|
|
|
4383
4413
|
};
|
|
4384
4414
|
|
|
4385
4415
|
// src/modules/video-generation/video-generation-error.ts
|
|
4386
|
-
import { err as err14, ok as
|
|
4416
|
+
import { err as err14, ok as ok28 } from "rockbed/error";
|
|
4387
4417
|
function makeVideoGenerationError(options) {
|
|
4388
4418
|
const errorInfo = {
|
|
4389
4419
|
code: options.code,
|
|
@@ -4397,7 +4427,7 @@ function makeVideoGenerationError(options) {
|
|
|
4397
4427
|
return err14(options.number, options.message, errorInfo);
|
|
4398
4428
|
}
|
|
4399
4429
|
function makeVideoGenerationOk(value) {
|
|
4400
|
-
return
|
|
4430
|
+
return ok28(value);
|
|
4401
4431
|
}
|
|
4402
4432
|
|
|
4403
4433
|
// src/modules/video-generation/video-generation-types.ts
|
|
@@ -4887,7 +4917,7 @@ function createDefaultVideoGenerationService() {
|
|
|
4887
4917
|
}
|
|
4888
4918
|
|
|
4889
4919
|
// src/commands/ai/ai-video-cache-clear-command.ts
|
|
4890
|
-
import { ok as
|
|
4920
|
+
import { ok as ok29 } from "rockbed/error";
|
|
4891
4921
|
var AiVideoCacheClearCommand = class extends BaseCommand {
|
|
4892
4922
|
constructor(_clearAssetCache = clearDefaultXyqAssetCache) {
|
|
4893
4923
|
super();
|
|
@@ -4903,7 +4933,7 @@ var AiVideoCacheClearCommand = class extends BaseCommand {
|
|
|
4903
4933
|
return ["data.clearedEntries:number \u662F\u6E05\u9664\u7684\u7F13\u5B58\u6761\u76EE\u6570\u3002"];
|
|
4904
4934
|
}
|
|
4905
4935
|
async _execute(_ctx) {
|
|
4906
|
-
return
|
|
4936
|
+
return ok29(this._clearAssetCache());
|
|
4907
4937
|
}
|
|
4908
4938
|
};
|
|
4909
4939
|
|
|
@@ -4922,7 +4952,7 @@ var AiVideoCacheCommand = class extends BaseCommandGroup {
|
|
|
4922
4952
|
|
|
4923
4953
|
// src/commands/ai/ai-video-status-command.ts
|
|
4924
4954
|
import { Option as Option7 } from "commander";
|
|
4925
|
-
import { ok as
|
|
4955
|
+
import { ok as ok30 } from "rockbed/error";
|
|
4926
4956
|
|
|
4927
4957
|
// src/commands/ai/ai-video-task-output.ts
|
|
4928
4958
|
function toVideoSubmitOutput(result) {
|
|
@@ -5006,13 +5036,13 @@ var AiVideoStatusCommand = class extends BaseCommand {
|
|
|
5006
5036
|
if (!result.ok) {
|
|
5007
5037
|
return failFrom(result, { stage: "query", taskId: threadIdResult.value });
|
|
5008
5038
|
}
|
|
5009
|
-
return
|
|
5039
|
+
return ok30(toVideoTaskOutput(result.value));
|
|
5010
5040
|
}
|
|
5011
5041
|
};
|
|
5012
5042
|
|
|
5013
5043
|
// src/commands/ai/ai-video-wait-command.ts
|
|
5014
5044
|
import { Option as Option8 } from "commander";
|
|
5015
|
-
import { ok as
|
|
5045
|
+
import { ok as ok31 } from "rockbed/error";
|
|
5016
5046
|
var AiVideoWaitCommand = class extends BaseCommand {
|
|
5017
5047
|
constructor(_runVideoTask = runVideoTaskToCompletion) {
|
|
5018
5048
|
super();
|
|
@@ -5073,7 +5103,7 @@ var AiVideoWaitCommand = class extends BaseCommand {
|
|
|
5073
5103
|
nextCommand: `tt ai video wait --task-id ${taskId}`
|
|
5074
5104
|
});
|
|
5075
5105
|
}
|
|
5076
|
-
return
|
|
5106
|
+
return ok31(
|
|
5077
5107
|
toVideoTaskOutput(result.value.task, {
|
|
5078
5108
|
localPaths: result.value.localPaths
|
|
5079
5109
|
})
|
|
@@ -5232,7 +5262,7 @@ var AiVideoCommand = class extends BaseCommandGroup {
|
|
|
5232
5262
|
return submitResult;
|
|
5233
5263
|
}
|
|
5234
5264
|
if (!shouldWait) {
|
|
5235
|
-
return
|
|
5265
|
+
return ok32(toVideoSubmitOutput(submitResult.value));
|
|
5236
5266
|
}
|
|
5237
5267
|
const taskId = submitResult.value.taskId;
|
|
5238
5268
|
if (!taskId) {
|
|
@@ -5253,7 +5283,7 @@ var AiVideoCommand = class extends BaseCommandGroup {
|
|
|
5253
5283
|
nextCommand: `tt ai video wait --task-id ${taskId}`
|
|
5254
5284
|
});
|
|
5255
5285
|
}
|
|
5256
|
-
return
|
|
5286
|
+
return ok32(
|
|
5257
5287
|
toVideoEndToEndOutput(submitResult.value, completionResult.value.task, {
|
|
5258
5288
|
localPaths: completionResult.value.localPaths
|
|
5259
5289
|
})
|
|
@@ -5269,7 +5299,7 @@ function parseIntegerWithoutThrowing(value) {
|
|
|
5269
5299
|
|
|
5270
5300
|
// src/modules/ark/ark-web-search.ts
|
|
5271
5301
|
import { Disposable as Disposable5 } from "rockbed/dispose";
|
|
5272
|
-
import { err as err15, ok as
|
|
5302
|
+
import { err as err15, ok as ok33 } from "rockbed/error";
|
|
5273
5303
|
|
|
5274
5304
|
// src/constants/ak.ts
|
|
5275
5305
|
var LEGACY_ARK_API_KEY = "6990de07-83be-487d-930d-f5dd3b6d5993";
|
|
@@ -5282,14 +5312,14 @@ var ARK_WEB_SEARCH_MODEL = "doubao-seed-2-0-mini-260215";
|
|
|
5282
5312
|
async function resolveArkApiKey(settingsReader, env = process.env) {
|
|
5283
5313
|
const fromEnv = env[ARK_API_KEY_ENV]?.trim();
|
|
5284
5314
|
if (fromEnv) {
|
|
5285
|
-
return
|
|
5315
|
+
return ok33(fromEnv);
|
|
5286
5316
|
}
|
|
5287
5317
|
const fromSettings = await settingsReader.getString(ARK_API_KEY_SETTING_KEY);
|
|
5288
5318
|
if (!fromSettings.ok) {
|
|
5289
5319
|
return fromSettings;
|
|
5290
5320
|
}
|
|
5291
5321
|
const value = fromSettings.value?.trim();
|
|
5292
|
-
return
|
|
5322
|
+
return ok33(value || LEGACY_ARK_API_KEY);
|
|
5293
5323
|
}
|
|
5294
5324
|
var ArkWebSearchClient = class extends Disposable5 {
|
|
5295
5325
|
_fetcher;
|
|
@@ -5347,7 +5377,7 @@ var ArkWebSearchClient = class extends Disposable5 {
|
|
|
5347
5377
|
if (!content) {
|
|
5348
5378
|
return err15(1, "\u8FD4\u56DE\u6570\u636E\u683C\u5F0F\u5F02\u5E38");
|
|
5349
5379
|
}
|
|
5350
|
-
return
|
|
5380
|
+
return ok33({
|
|
5351
5381
|
query,
|
|
5352
5382
|
model: ARK_WEB_SEARCH_MODEL,
|
|
5353
5383
|
text: extractOutputText(content),
|
|
@@ -5435,7 +5465,7 @@ var AiCommand = class extends BaseCommandGroup {
|
|
|
5435
5465
|
import { stat as stat3 } from "node:fs/promises";
|
|
5436
5466
|
import { resolve as resolve10 } from "node:path";
|
|
5437
5467
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
5438
|
-
import { err as err16, ok as
|
|
5468
|
+
import { err as err16, ok as ok34 } from "rockbed/error";
|
|
5439
5469
|
var DEFAULT_CODEX_CWD = "/Users/bytedance/work/autogen";
|
|
5440
5470
|
var DEFAULT_CODEX_MODEL = "gpt-6-astra";
|
|
5441
5471
|
var DEFAULT_CODEX_REASONING = "high";
|
|
@@ -5454,7 +5484,7 @@ async function launchCodex(input, launch = launchDefaultCodexWorker) {
|
|
|
5454
5484
|
}
|
|
5455
5485
|
const result = await launch({ ...input, cwd });
|
|
5456
5486
|
if (!result.ok) return result;
|
|
5457
|
-
return
|
|
5487
|
+
return ok34({ status: "launched", pid: result.value.pid, cwd, model: input.model, reasoning: input.reasoning, ...result.value.data });
|
|
5458
5488
|
}
|
|
5459
5489
|
function launchDefaultCodexWorker(input) {
|
|
5460
5490
|
const source = import.meta.url.endsWith(".ts");
|
|
@@ -5509,7 +5539,7 @@ var CodexCommand = class extends BaseCommand {
|
|
|
5509
5539
|
import { stat as stat4 } from "node:fs/promises";
|
|
5510
5540
|
import { resolve as resolve11 } from "node:path";
|
|
5511
5541
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
5512
|
-
import { err as err17, ok as
|
|
5542
|
+
import { err as err17, ok as ok35 } from "rockbed/error";
|
|
5513
5543
|
var DEFAULT_TRAEX_CWD = "/Users/bytedance/work/autogen";
|
|
5514
5544
|
var DEFAULT_TRAEX_MODEL = "gpt-5.6-sol";
|
|
5515
5545
|
var DEFAULT_TRAEX_REASONING = "xhigh";
|
|
@@ -5528,7 +5558,7 @@ async function launchTraex(input, launch = launchDefaultTraexWorker) {
|
|
|
5528
5558
|
}
|
|
5529
5559
|
const result = await launch({ ...input, cwd });
|
|
5530
5560
|
if (!result.ok) return result;
|
|
5531
|
-
return
|
|
5561
|
+
return ok35({ status: "launched", pid: result.value.pid, cwd, model: input.model, reasoning: input.reasoning, ...result.value.data });
|
|
5532
5562
|
}
|
|
5533
5563
|
function launchDefaultTraexWorker(input) {
|
|
5534
5564
|
const source = import.meta.url.endsWith(".ts");
|
|
@@ -5580,7 +5610,7 @@ var TraexCommand = class extends BaseCommand {
|
|
|
5580
5610
|
};
|
|
5581
5611
|
|
|
5582
5612
|
// src/commands/deploy/deploy-command.ts
|
|
5583
|
-
import { ok as
|
|
5613
|
+
import { ok as ok38 } from "rockbed/error";
|
|
5584
5614
|
|
|
5585
5615
|
// src/modules/static-deploy/static-deploy-service.ts
|
|
5586
5616
|
import { spawn } from "node:child_process";
|
|
@@ -5599,7 +5629,7 @@ import * as path12 from "node:path";
|
|
|
5599
5629
|
import * as path11 from "node:path";
|
|
5600
5630
|
import * as fs7 from "node:fs";
|
|
5601
5631
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
5602
|
-
import { ok as
|
|
5632
|
+
import { ok as ok36, err as err18 } from "rockbed/error";
|
|
5603
5633
|
var _thisDir = path11.dirname(fileURLToPath4(import.meta.url));
|
|
5604
5634
|
var DEFAULT_MAX_DEPTH = 10;
|
|
5605
5635
|
function findClosestPackageJson(maxDepth = DEFAULT_MAX_DEPTH) {
|
|
@@ -5607,7 +5637,7 @@ function findClosestPackageJson(maxDepth = DEFAULT_MAX_DEPTH) {
|
|
|
5607
5637
|
for (let i = 0; i < maxDepth; i++) {
|
|
5608
5638
|
const candidate = path11.join(currentDir, "package.json");
|
|
5609
5639
|
if (fs7.existsSync(candidate)) {
|
|
5610
|
-
return
|
|
5640
|
+
return ok36(candidate);
|
|
5611
5641
|
}
|
|
5612
5642
|
const parentDir = path11.dirname(currentDir);
|
|
5613
5643
|
if (parentDir === currentDir) {
|
|
@@ -5619,7 +5649,7 @@ function findClosestPackageJson(maxDepth = DEFAULT_MAX_DEPTH) {
|
|
|
5619
5649
|
}
|
|
5620
5650
|
|
|
5621
5651
|
// src/bedrock/config/local-config.ts
|
|
5622
|
-
import { err as err19, ok as
|
|
5652
|
+
import { err as err19, ok as ok37 } from "rockbed/error";
|
|
5623
5653
|
function normalizeAppName(rawName) {
|
|
5624
5654
|
const lastSegment = rawName.split("/").pop() ?? rawName;
|
|
5625
5655
|
const sanitized = lastSegment.trim().replace(/[<>:"/\\|?*\u0000-\u001F]/g, "-").replace(/-+/g, "-").replace(/^[-.]+|[-.]+$/g, "");
|
|
@@ -5639,7 +5669,7 @@ async function readClosestPackageName() {
|
|
|
5639
5669
|
`package.json at ${packageJsonResult.value} does not contain a valid name field`
|
|
5640
5670
|
);
|
|
5641
5671
|
}
|
|
5642
|
-
return
|
|
5672
|
+
return ok37(normalizeAppName(parsed.name));
|
|
5643
5673
|
} catch (error) {
|
|
5644
5674
|
const message = error instanceof Error ? error.message : String(error);
|
|
5645
5675
|
return err19(
|
|
@@ -5661,7 +5691,7 @@ async function resolveConfigLocation() {
|
|
|
5661
5691
|
}
|
|
5662
5692
|
const baseDir = await getBaseConfigDir();
|
|
5663
5693
|
const configDir = path12.join(baseDir, appNameResult.value);
|
|
5664
|
-
return
|
|
5694
|
+
return ok37({
|
|
5665
5695
|
packageName: appNameResult.value,
|
|
5666
5696
|
configDir,
|
|
5667
5697
|
configFilePath: path12.join(configDir, `${appNameResult.value}.json`)
|
|
@@ -5737,7 +5767,7 @@ async function ensureConfigFile(configFilePath) {
|
|
|
5737
5767
|
await fs8.access(configFilePath).catch(async () => {
|
|
5738
5768
|
await fs8.writeFile(configFilePath, "{}\n", "utf8");
|
|
5739
5769
|
});
|
|
5740
|
-
return
|
|
5770
|
+
return ok37();
|
|
5741
5771
|
} catch (error) {
|
|
5742
5772
|
const message = error instanceof Error ? error.message : String(error);
|
|
5743
5773
|
return err19(
|
|
@@ -5763,9 +5793,9 @@ async function readConfig() {
|
|
|
5763
5793
|
"utf8"
|
|
5764
5794
|
);
|
|
5765
5795
|
if (content.trim().length === 0) {
|
|
5766
|
-
return
|
|
5796
|
+
return ok37({});
|
|
5767
5797
|
}
|
|
5768
|
-
return
|
|
5798
|
+
return ok37(JSON.parse(content));
|
|
5769
5799
|
} catch (error) {
|
|
5770
5800
|
const message = error instanceof Error ? error.message : String(error);
|
|
5771
5801
|
return err19(
|
|
@@ -5789,7 +5819,7 @@ async function writeConfig(config) {
|
|
|
5789
5819
|
const content = `${JSON.stringify(config, null, 2)}
|
|
5790
5820
|
`;
|
|
5791
5821
|
await fs8.writeFile(locationResult.value.configFilePath, content, "utf8");
|
|
5792
|
-
return
|
|
5822
|
+
return ok37();
|
|
5793
5823
|
} catch (error) {
|
|
5794
5824
|
const message = error instanceof Error ? error.message : String(error);
|
|
5795
5825
|
return err19(
|
|
@@ -5803,7 +5833,7 @@ async function readConfigValue(configPath, defaultValue) {
|
|
|
5803
5833
|
if (!configResult.ok) {
|
|
5804
5834
|
return configResult;
|
|
5805
5835
|
}
|
|
5806
|
-
return
|
|
5836
|
+
return ok37(
|
|
5807
5837
|
getConfigValue(configResult.value, configPath, defaultValue)
|
|
5808
5838
|
);
|
|
5809
5839
|
}
|
|
@@ -6244,12 +6274,12 @@ var DeployCommand = class extends BaseCommand {
|
|
|
6244
6274
|
try {
|
|
6245
6275
|
const service = this._createService();
|
|
6246
6276
|
if (operation === "list") {
|
|
6247
|
-
return
|
|
6277
|
+
return ok38(await service.list());
|
|
6248
6278
|
}
|
|
6249
6279
|
if (operation === "delete") {
|
|
6250
|
-
return
|
|
6280
|
+
return ok38(await service.delete(deleteName));
|
|
6251
6281
|
}
|
|
6252
|
-
return
|
|
6282
|
+
return ok38(
|
|
6253
6283
|
await service.deploy({
|
|
6254
6284
|
sourcePath,
|
|
6255
6285
|
...name !== void 0 ? { name } : {}
|
|
@@ -6269,7 +6299,7 @@ function inputError(msg) {
|
|
|
6269
6299
|
}
|
|
6270
6300
|
|
|
6271
6301
|
// src/modules/git/git-cli.ts
|
|
6272
|
-
import { err as err20, ok as
|
|
6302
|
+
import { err as err20, ok as ok39 } from "rockbed/error";
|
|
6273
6303
|
function runGit(args) {
|
|
6274
6304
|
return runProcess("git", args);
|
|
6275
6305
|
}
|
|
@@ -6278,7 +6308,7 @@ async function captureGit(args) {
|
|
|
6278
6308
|
if (!result.ok) {
|
|
6279
6309
|
return result;
|
|
6280
6310
|
}
|
|
6281
|
-
return
|
|
6311
|
+
return ok39(result.value.stdout.trim());
|
|
6282
6312
|
}
|
|
6283
6313
|
function gitAddAll() {
|
|
6284
6314
|
return runGit(["add", "."]);
|
|
@@ -6407,7 +6437,7 @@ var GitMmCommand = class extends GitBaseCommand {
|
|
|
6407
6437
|
};
|
|
6408
6438
|
|
|
6409
6439
|
// src/commands/git/git-mr-command.ts
|
|
6410
|
-
import { ok as
|
|
6440
|
+
import { ok as ok40 } from "rockbed/error";
|
|
6411
6441
|
var GitMrCommand = class extends GitBaseCommand {
|
|
6412
6442
|
_meta() {
|
|
6413
6443
|
return {
|
|
@@ -6433,7 +6463,7 @@ var GitMrCommand = class extends GitBaseCommand {
|
|
|
6433
6463
|
if (!openResult.ok) {
|
|
6434
6464
|
this._debug(openResult.msg);
|
|
6435
6465
|
}
|
|
6436
|
-
return
|
|
6466
|
+
return ok40();
|
|
6437
6467
|
}
|
|
6438
6468
|
};
|
|
6439
6469
|
|
|
@@ -6481,7 +6511,7 @@ var GitCommand = class extends BaseCommandGroup {
|
|
|
6481
6511
|
};
|
|
6482
6512
|
|
|
6483
6513
|
// src/commands/hello/hello-greet-command.ts
|
|
6484
|
-
import { ok as
|
|
6514
|
+
import { ok as ok41 } from "rockbed/error";
|
|
6485
6515
|
var HelloGreetCommand = class extends BaseCommand {
|
|
6486
6516
|
_meta() {
|
|
6487
6517
|
return {
|
|
@@ -6497,14 +6527,14 @@ var HelloGreetCommand = class extends BaseCommand {
|
|
|
6497
6527
|
}
|
|
6498
6528
|
async _execute(ctx) {
|
|
6499
6529
|
const message = `Hello, ${readStringArg(ctx.args, 0) || "World"}!`;
|
|
6500
|
-
return
|
|
6530
|
+
return ok41({
|
|
6501
6531
|
message: ctx.options.uppercase ? message.toUpperCase() : message
|
|
6502
6532
|
});
|
|
6503
6533
|
}
|
|
6504
6534
|
};
|
|
6505
6535
|
|
|
6506
6536
|
// src/commands/hello/hello-info-command.ts
|
|
6507
|
-
import { ok as
|
|
6537
|
+
import { ok as ok42 } from "rockbed/error";
|
|
6508
6538
|
var HelloInfoCommand = class extends BaseCommand {
|
|
6509
6539
|
_meta() {
|
|
6510
6540
|
return {
|
|
@@ -6513,7 +6543,7 @@ var HelloInfoCommand = class extends BaseCommand {
|
|
|
6513
6543
|
};
|
|
6514
6544
|
}
|
|
6515
6545
|
async _execute(_ctx) {
|
|
6516
|
-
return
|
|
6546
|
+
return ok42({
|
|
6517
6547
|
version: "1.0.0",
|
|
6518
6548
|
description: "Hello \u547D\u4EE4\u7EC4 - \u7528\u4E8E\u6253\u62DB\u547C\u7684\u793A\u4F8B\u547D\u4EE4"
|
|
6519
6549
|
});
|
|
@@ -6540,14 +6570,14 @@ var HelloCommand = class extends BaseCommandGroup {
|
|
|
6540
6570
|
import { Option as Option10 } from "commander";
|
|
6541
6571
|
|
|
6542
6572
|
// src/modules/pippit/asset-get/cn-asset-get.ts
|
|
6543
|
-
import { err as err21, ok as
|
|
6573
|
+
import { err as err21, ok as ok45 } from "rockbed/error";
|
|
6544
6574
|
|
|
6545
6575
|
// src/modules/pippit/request-json.ts
|
|
6546
|
-
import { ok as
|
|
6576
|
+
import { ok as ok43 } from "rockbed/error";
|
|
6547
6577
|
async function readJsonBody(response, url, responseParseFailed2) {
|
|
6548
6578
|
const bodyText = await response.text();
|
|
6549
6579
|
try {
|
|
6550
|
-
return
|
|
6580
|
+
return ok43(JSON.parse(bodyText));
|
|
6551
6581
|
} catch (error) {
|
|
6552
6582
|
const cause = error instanceof Error ? ` (${error.message})` : "";
|
|
6553
6583
|
return responseParseFailed2(`\u63A5\u53E3\u8FD4\u56DE\u975E JSON \u54CD\u5E94: ${url}${cause}`);
|
|
@@ -6601,7 +6631,7 @@ async function readWebToken(region) {
|
|
|
6601
6631
|
}
|
|
6602
6632
|
|
|
6603
6633
|
// src/modules/pippit/web-token/web-context.ts
|
|
6604
|
-
import { ok as
|
|
6634
|
+
import { ok as ok44 } from "rockbed/error";
|
|
6605
6635
|
|
|
6606
6636
|
// src/modules/pippit/web-token/errors.ts
|
|
6607
6637
|
import { defineError } from "rockbed/error";
|
|
@@ -6733,7 +6763,7 @@ async function fetchUserId(token) {
|
|
|
6733
6763
|
if (!uid) {
|
|
6734
6764
|
return userInfoNotFoundError();
|
|
6735
6765
|
}
|
|
6736
|
-
return
|
|
6766
|
+
return ok44(uid);
|
|
6737
6767
|
}
|
|
6738
6768
|
async function fetchWorkspace(token, uid) {
|
|
6739
6769
|
const responseResult = await requestJson2(WORKSPACE_URL, {
|
|
@@ -6760,7 +6790,7 @@ async function fetchWorkspace(token, uid) {
|
|
|
6760
6790
|
if (!workspaceId || !spaceId) {
|
|
6761
6791
|
return workspaceNotFoundError();
|
|
6762
6792
|
}
|
|
6763
|
-
return
|
|
6793
|
+
return ok44({
|
|
6764
6794
|
uid,
|
|
6765
6795
|
workspaceId,
|
|
6766
6796
|
spaceId
|
|
@@ -6810,7 +6840,7 @@ async function readWebContext(region) {
|
|
|
6810
6840
|
if (!webContext) {
|
|
6811
6841
|
return missingWebContextError();
|
|
6812
6842
|
}
|
|
6813
|
-
return
|
|
6843
|
+
return ok44(webContext);
|
|
6814
6844
|
}
|
|
6815
6845
|
|
|
6816
6846
|
// src/modules/pippit/asset-get/errors.ts
|
|
@@ -6955,7 +6985,7 @@ async function getAssetInfoCn(options) {
|
|
|
6955
6985
|
if (!assets) {
|
|
6956
6986
|
return requestFailedError("\u8FD4\u56DE\u7684 data \u4E0D\u662F\u6570\u7EC4\u3002");
|
|
6957
6987
|
}
|
|
6958
|
-
return
|
|
6988
|
+
return ok45(assets);
|
|
6959
6989
|
}
|
|
6960
6990
|
|
|
6961
6991
|
// src/modules/pippit/asset-get/i18n-asset-get.ts
|
|
@@ -6974,7 +7004,7 @@ async function getAssetInfo(options) {
|
|
|
6974
7004
|
// src/modules/pippit/asset-upload/cn-asset-upload.ts
|
|
6975
7005
|
import * as fs11 from "node:fs/promises";
|
|
6976
7006
|
import * as path15 from "node:path";
|
|
6977
|
-
import { err as err22, ok as
|
|
7007
|
+
import { err as err22, ok as ok46 } from "rockbed/error";
|
|
6978
7008
|
|
|
6979
7009
|
// src/modules/pippit/asset-upload/errors.ts
|
|
6980
7010
|
import { defineError as defineError3 } from "rockbed/error";
|
|
@@ -7132,7 +7162,7 @@ async function uploadAssetCn(options) {
|
|
|
7132
7162
|
if (!assetId) {
|
|
7133
7163
|
return err22(1, "\u4E0A\u4F20\u6210\u529F\uFF0C\u4F46\u672A\u8FD4\u56DE asset_id\u3002");
|
|
7134
7164
|
}
|
|
7135
|
-
return
|
|
7165
|
+
return ok46({
|
|
7136
7166
|
assetId,
|
|
7137
7167
|
fileInfo,
|
|
7138
7168
|
region: "cn" /* CN */
|
|
@@ -7153,7 +7183,7 @@ async function uploadAsset(options) {
|
|
|
7153
7183
|
}
|
|
7154
7184
|
|
|
7155
7185
|
// src/modules/pippit/douyin-video/cn-douyin-video.ts
|
|
7156
|
-
import { err as err23, ok as
|
|
7186
|
+
import { err as err23, ok as ok47 } from "rockbed/error";
|
|
7157
7187
|
|
|
7158
7188
|
// src/modules/pippit/douyin-video/errors.ts
|
|
7159
7189
|
import { defineError as defineError4 } from "rockbed/error";
|
|
@@ -7259,7 +7289,7 @@ async function fetchDouyinVideoCn(options) {
|
|
|
7259
7289
|
const response = responseResult.value;
|
|
7260
7290
|
const videoUrl = parseVideoUrl(response.data);
|
|
7261
7291
|
if (videoUrl) {
|
|
7262
|
-
return
|
|
7292
|
+
return ok47({ video_url: videoUrl });
|
|
7263
7293
|
}
|
|
7264
7294
|
if (response.ret !== void 0 && String(response.ret) !== "0") {
|
|
7265
7295
|
return err23(
|
|
@@ -7288,10 +7318,10 @@ async function readFornaxToken(region) {
|
|
|
7288
7318
|
}
|
|
7289
7319
|
|
|
7290
7320
|
// src/modules/pippit/get-thread/get-thread.ts
|
|
7291
|
-
import { ok as
|
|
7321
|
+
import { ok as ok49 } from "rockbed/error";
|
|
7292
7322
|
|
|
7293
7323
|
// src/modules/pippit/get-thread/fetch-thread.ts
|
|
7294
|
-
import { ok as
|
|
7324
|
+
import { ok as ok48 } from "rockbed/error";
|
|
7295
7325
|
|
|
7296
7326
|
// src/modules/pippit/get-thread/errors.ts
|
|
7297
7327
|
import { defineError as defineError5 } from "rockbed/error";
|
|
@@ -7356,7 +7386,7 @@ async function fetchThread(threadId, region) {
|
|
|
7356
7386
|
if (!thread?.run_list) {
|
|
7357
7387
|
return threadNotFoundError();
|
|
7358
7388
|
}
|
|
7359
|
-
return
|
|
7389
|
+
return ok48(thread);
|
|
7360
7390
|
}
|
|
7361
7391
|
|
|
7362
7392
|
// src/modules/pippit/get-thread/trim-thread.ts
|
|
@@ -7454,11 +7484,11 @@ async function _fetchAndProcess(threadId, region, trim) {
|
|
|
7454
7484
|
if (trim) {
|
|
7455
7485
|
trimThread(thread);
|
|
7456
7486
|
}
|
|
7457
|
-
return
|
|
7487
|
+
return ok49({ thread, region });
|
|
7458
7488
|
}
|
|
7459
7489
|
|
|
7460
7490
|
// src/modules/pippit/search-log/cn-search-log.ts
|
|
7461
|
-
import { ok as
|
|
7491
|
+
import { ok as ok51 } from "rockbed/error";
|
|
7462
7492
|
|
|
7463
7493
|
// src/modules/pippit/search-log/errors.ts
|
|
7464
7494
|
import { defineError as defineError6 } from "rockbed/error";
|
|
@@ -7519,7 +7549,7 @@ var payloadParseFailedError = defineError6(
|
|
|
7519
7549
|
);
|
|
7520
7550
|
|
|
7521
7551
|
// src/modules/pippit/search-log/common.ts
|
|
7522
|
-
import { ok as
|
|
7552
|
+
import { ok as ok50 } from "rockbed/error";
|
|
7523
7553
|
function normalizeToken4(token) {
|
|
7524
7554
|
const trimmed = token.trim();
|
|
7525
7555
|
const prefix = "prompt-platform-session=";
|
|
@@ -7569,7 +7599,7 @@ function resolveTimeWindow(baseOffsetInDays, daysLater) {
|
|
|
7569
7599
|
function parseDetailPayload(input) {
|
|
7570
7600
|
if (typeof input === "string") {
|
|
7571
7601
|
try {
|
|
7572
|
-
return
|
|
7602
|
+
return ok50(JSON.parse(input));
|
|
7573
7603
|
} catch (error) {
|
|
7574
7604
|
return payloadParseFailedError(
|
|
7575
7605
|
error instanceof Error ? error : void 0
|
|
@@ -7577,7 +7607,7 @@ function parseDetailPayload(input) {
|
|
|
7577
7607
|
}
|
|
7578
7608
|
}
|
|
7579
7609
|
if (input !== null && typeof input === "object") {
|
|
7580
|
-
return
|
|
7610
|
+
return ok50(input);
|
|
7581
7611
|
}
|
|
7582
7612
|
return payloadNotFoundError();
|
|
7583
7613
|
}
|
|
@@ -7730,7 +7760,7 @@ async function searchLogCn(options) {
|
|
|
7730
7760
|
if (!payload.ok) {
|
|
7731
7761
|
return payload;
|
|
7732
7762
|
}
|
|
7733
|
-
return
|
|
7763
|
+
return ok51({
|
|
7734
7764
|
meta: {
|
|
7735
7765
|
region: "cn" /* CN */,
|
|
7736
7766
|
spanName: detailSpan.span_name || ""
|
|
@@ -7740,7 +7770,7 @@ async function searchLogCn(options) {
|
|
|
7740
7770
|
}
|
|
7741
7771
|
|
|
7742
7772
|
// src/modules/pippit/search-log/i18n-search-log.ts
|
|
7743
|
-
import { ok as
|
|
7773
|
+
import { ok as ok52 } from "rockbed/error";
|
|
7744
7774
|
var CONFIG2 = {
|
|
7745
7775
|
BASE_URL: "https://fornax-i18n.byteintl.net",
|
|
7746
7776
|
WORKSPACE_ID: "7517207223651532851",
|
|
@@ -7811,7 +7841,7 @@ async function searchLogI18n(options) {
|
|
|
7811
7841
|
if (!payload.ok) {
|
|
7812
7842
|
return payload;
|
|
7813
7843
|
}
|
|
7814
|
-
return
|
|
7844
|
+
return ok52({
|
|
7815
7845
|
meta: {
|
|
7816
7846
|
region: "i18n" /* I18N */,
|
|
7817
7847
|
spanName: detailSpan.span_name || ""
|
|
@@ -7884,7 +7914,7 @@ var PippitAssetGetCommand = class extends BaseCommand {
|
|
|
7884
7914
|
// src/commands/pippit/pippit-asset-upload-command.ts
|
|
7885
7915
|
import * as path16 from "node:path";
|
|
7886
7916
|
import { Option as Option11 } from "commander";
|
|
7887
|
-
import { ok as
|
|
7917
|
+
import { ok as ok53 } from "rockbed/error";
|
|
7888
7918
|
var PippitAssetUploadCommand = class extends BaseCommand {
|
|
7889
7919
|
_meta() {
|
|
7890
7920
|
return {
|
|
@@ -7916,7 +7946,7 @@ var PippitAssetUploadCommand = class extends BaseCommand {
|
|
|
7916
7946
|
if (!result.ok) {
|
|
7917
7947
|
return result;
|
|
7918
7948
|
}
|
|
7919
|
-
return
|
|
7949
|
+
return ok53({
|
|
7920
7950
|
asset_id: result.value.assetId,
|
|
7921
7951
|
file_path: path16.resolve(process.cwd(), filePath),
|
|
7922
7952
|
region: result.value.region,
|
|
@@ -7947,7 +7977,7 @@ var PippitDouyinVideoCommand = class extends BaseCommand {
|
|
|
7947
7977
|
|
|
7948
7978
|
// src/commands/pippit/pippit-fornax-token-command.ts
|
|
7949
7979
|
import { Option as Option12 } from "commander";
|
|
7950
|
-
import { ok as
|
|
7980
|
+
import { ok as ok54 } from "rockbed/error";
|
|
7951
7981
|
var PippitFornaxTokenCommand = class extends BaseCommand {
|
|
7952
7982
|
_meta() {
|
|
7953
7983
|
return {
|
|
@@ -7969,7 +7999,7 @@ var PippitFornaxTokenCommand = class extends BaseCommand {
|
|
|
7969
7999
|
if (!result.ok) {
|
|
7970
8000
|
return result;
|
|
7971
8001
|
}
|
|
7972
|
-
return
|
|
8002
|
+
return ok54({ region, stored: true });
|
|
7973
8003
|
}
|
|
7974
8004
|
};
|
|
7975
8005
|
|
|
@@ -8005,7 +8035,7 @@ var PippitGetThreadCommand = class extends BaseCommand {
|
|
|
8005
8035
|
import * as fs12 from "node:fs/promises";
|
|
8006
8036
|
import * as path17 from "node:path";
|
|
8007
8037
|
import { Option as Option14 } from "commander";
|
|
8008
|
-
import { err as err24, ok as
|
|
8038
|
+
import { err as err24, ok as ok55 } from "rockbed/error";
|
|
8009
8039
|
var PippitSaveThreadFornaxCommand = class extends BaseCommand {
|
|
8010
8040
|
_meta() {
|
|
8011
8041
|
return {
|
|
@@ -8053,7 +8083,7 @@ var PippitSaveThreadFornaxCommand = class extends BaseCommand {
|
|
|
8053
8083
|
const message = error instanceof Error ? error.message : String(error);
|
|
8054
8084
|
return err24(1, `\u5199\u5165\u6587\u4EF6\u5931\u8D25: ${message}`);
|
|
8055
8085
|
}
|
|
8056
|
-
return
|
|
8086
|
+
return ok55({
|
|
8057
8087
|
thread_id: threadId,
|
|
8058
8088
|
output_dir: targetDir,
|
|
8059
8089
|
files: { thread: threadPath, fornax: fornaxPath }
|
|
@@ -8117,7 +8147,7 @@ var PippitSearchFornaxLogCommand = class extends BaseCommand {
|
|
|
8117
8147
|
|
|
8118
8148
|
// src/commands/pippit/pippit-web-token-command.ts
|
|
8119
8149
|
import { Option as Option16 } from "commander";
|
|
8120
|
-
import { ok as
|
|
8150
|
+
import { ok as ok56 } from "rockbed/error";
|
|
8121
8151
|
var PippitWebTokenCommand = class extends BaseCommand {
|
|
8122
8152
|
_meta() {
|
|
8123
8153
|
return {
|
|
@@ -8141,13 +8171,13 @@ var PippitWebTokenCommand = class extends BaseCommand {
|
|
|
8141
8171
|
return result;
|
|
8142
8172
|
}
|
|
8143
8173
|
if (region !== "cn" /* CN */) {
|
|
8144
|
-
return
|
|
8174
|
+
return ok56({ region, stored: true, refreshed: false });
|
|
8145
8175
|
}
|
|
8146
8176
|
const refreshResult = await refreshWebContext(region, token);
|
|
8147
8177
|
if (!refreshResult.ok) {
|
|
8148
8178
|
return refreshResult;
|
|
8149
8179
|
}
|
|
8150
|
-
return
|
|
8180
|
+
return ok56({
|
|
8151
8181
|
region,
|
|
8152
8182
|
stored: true,
|
|
8153
8183
|
refreshed: true,
|
|
@@ -8266,7 +8296,7 @@ var ShortcutCommand = class extends BaseCommandGroup {
|
|
|
8266
8296
|
};
|
|
8267
8297
|
|
|
8268
8298
|
// src/commands/tool/tool-draw-command.ts
|
|
8269
|
-
import { err as err25, ok as
|
|
8299
|
+
import { err as err25, ok as ok57 } from "rockbed/error";
|
|
8270
8300
|
var ToolDrawCommand = class extends BaseCommand {
|
|
8271
8301
|
_meta() {
|
|
8272
8302
|
return {
|
|
@@ -8303,7 +8333,7 @@ var ToolDrawCommand = class extends BaseCommand {
|
|
|
8303
8333
|
if (!distributionResult.ok) {
|
|
8304
8334
|
return distributionResult;
|
|
8305
8335
|
}
|
|
8306
|
-
return
|
|
8336
|
+
return ok57({
|
|
8307
8337
|
items: drawWeightedItems(countResult.value, distributionResult.value)
|
|
8308
8338
|
});
|
|
8309
8339
|
}
|
|
@@ -8313,7 +8343,7 @@ function parseCount(value) {
|
|
|
8313
8343
|
if (!Number.isInteger(count) || count <= 0) {
|
|
8314
8344
|
return err25(1, "\u62BD\u53D6\u4E2A\u6570\u5FC5\u987B\u662F\u6B63\u6574\u6570");
|
|
8315
8345
|
}
|
|
8316
|
-
return
|
|
8346
|
+
return ok57(count);
|
|
8317
8347
|
}
|
|
8318
8348
|
function stringifyDistributionArg(value) {
|
|
8319
8349
|
if (Array.isArray(value)) {
|
|
@@ -8361,7 +8391,7 @@ function parseJsonDistributionEntry(value, index) {
|
|
|
8361
8391
|
if (!weightResult.ok) {
|
|
8362
8392
|
return weightResult;
|
|
8363
8393
|
}
|
|
8364
|
-
return
|
|
8394
|
+
return ok57({ name: nameResult.value, weight: weightResult.value });
|
|
8365
8395
|
}
|
|
8366
8396
|
function getJsonWeightValue(record) {
|
|
8367
8397
|
if ("weight" in record) {
|
|
@@ -8410,7 +8440,7 @@ function parseEntryName(value, label) {
|
|
|
8410
8440
|
if (!name) {
|
|
8411
8441
|
return err25(1, `${label}\u7684\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A`);
|
|
8412
8442
|
}
|
|
8413
|
-
return
|
|
8443
|
+
return ok57(name);
|
|
8414
8444
|
}
|
|
8415
8445
|
function parseWeight(value, label) {
|
|
8416
8446
|
const rawValue = typeof value === "string" ? value.trim().replace(/[%%]$/, "") : value;
|
|
@@ -8418,13 +8448,13 @@ function parseWeight(value, label) {
|
|
|
8418
8448
|
if (!Number.isFinite(weight) || weight <= 0) {
|
|
8419
8449
|
return err25(1, `${label}\u7684\u6982\u7387\u5FC5\u987B\u662F\u5927\u4E8E 0 \u7684\u6570\u5B57`);
|
|
8420
8450
|
}
|
|
8421
|
-
return
|
|
8451
|
+
return ok57(weight);
|
|
8422
8452
|
}
|
|
8423
8453
|
function validateDistribution(entries) {
|
|
8424
8454
|
if (entries.length === 0) {
|
|
8425
8455
|
return err25(1, "\u6982\u7387\u5206\u5E03\u81F3\u5C11\u9700\u8981 1 \u9879");
|
|
8426
8456
|
}
|
|
8427
|
-
return
|
|
8457
|
+
return ok57(entries);
|
|
8428
8458
|
}
|
|
8429
8459
|
function drawWeightedItems(count, entries) {
|
|
8430
8460
|
const totalWeight = entries.reduce((sum, entry) => sum + entry.weight, 0);
|
|
@@ -8452,7 +8482,7 @@ function asRecord(value) {
|
|
|
8452
8482
|
}
|
|
8453
8483
|
|
|
8454
8484
|
// src/commands/tool/tool-get-config-command.ts
|
|
8455
|
-
import { err as err26, ok as
|
|
8485
|
+
import { err as err26, ok as ok58 } from "rockbed/error";
|
|
8456
8486
|
var ToolGetConfigCommand = class extends BaseCommand {
|
|
8457
8487
|
constructor(_settingsReader = new FileCrossAppSettingsReader()) {
|
|
8458
8488
|
super();
|
|
@@ -8515,9 +8545,9 @@ async function readConfigValue2(settingsReader, key) {
|
|
|
8515
8545
|
}
|
|
8516
8546
|
const entry = snapshotResult.value.document.settings[key];
|
|
8517
8547
|
if (!entry) {
|
|
8518
|
-
return
|
|
8548
|
+
return ok58({ key, configured: false });
|
|
8519
8549
|
}
|
|
8520
|
-
return
|
|
8550
|
+
return ok58({
|
|
8521
8551
|
key,
|
|
8522
8552
|
configured: true,
|
|
8523
8553
|
value: entry.value,
|
|
@@ -8530,7 +8560,7 @@ async function readConfigValue2(settingsReader, key) {
|
|
|
8530
8560
|
import { readdir as readdir2, stat as stat6 } from "node:fs/promises";
|
|
8531
8561
|
import { homedir as homedir8 } from "node:os";
|
|
8532
8562
|
import { extname as extname5, join as join13, resolve as resolve16 } from "node:path";
|
|
8533
|
-
import { err as err27, ok as
|
|
8563
|
+
import { err as err27, ok as ok59 } from "rockbed/error";
|
|
8534
8564
|
var DEFAULT_COUNT = 1;
|
|
8535
8565
|
var DEFAULT_SUFFIXES = ["png", "jpeg", "jpg"];
|
|
8536
8566
|
var DEFAULT_DEPTH = 3;
|
|
@@ -8606,7 +8636,7 @@ var ToolRandomFilesCommand = class extends BaseCommand {
|
|
|
8606
8636
|
`\u5339\u914D\u6587\u4EF6\u6570\u91CF\u4E0D\u8DB3: \u9700\u8981 ${countResult.value} \u4E2A\uFF0C\u627E\u5230 ${candidates.length} \u4E2A`
|
|
8607
8637
|
);
|
|
8608
8638
|
}
|
|
8609
|
-
return
|
|
8639
|
+
return ok59({ files: pickRandomFiles(candidates, countResult.value) });
|
|
8610
8640
|
}
|
|
8611
8641
|
};
|
|
8612
8642
|
function parseFolderInput(value) {
|
|
@@ -8614,7 +8644,7 @@ function parseFolderInput(value) {
|
|
|
8614
8644
|
if (!folder) {
|
|
8615
8645
|
return err27(1, "\u76EE\u6807\u6587\u4EF6\u5939\u4E0D\u80FD\u4E3A\u7A7A");
|
|
8616
8646
|
}
|
|
8617
|
-
return
|
|
8647
|
+
return ok59({ raw: folder, candidates: createFolderCandidates(folder) });
|
|
8618
8648
|
}
|
|
8619
8649
|
function stringifyFolderArg(value) {
|
|
8620
8650
|
if (Array.isArray(value)) {
|
|
@@ -8655,7 +8685,7 @@ async function resolveFolder(folderInput) {
|
|
|
8655
8685
|
continue;
|
|
8656
8686
|
}
|
|
8657
8687
|
if (folderStat.isDirectory()) {
|
|
8658
|
-
return
|
|
8688
|
+
return ok59(candidate);
|
|
8659
8689
|
}
|
|
8660
8690
|
firstExistingPath ??= candidate;
|
|
8661
8691
|
}
|
|
@@ -8669,14 +8699,14 @@ function parsePositiveInteger(value, defaultValue, label) {
|
|
|
8669
8699
|
if (!Number.isInteger(parsedValue) || parsedValue <= 0) {
|
|
8670
8700
|
return err27(1, `${label}\u5FC5\u987B\u662F\u6B63\u6574\u6570`);
|
|
8671
8701
|
}
|
|
8672
|
-
return
|
|
8702
|
+
return ok59(parsedValue);
|
|
8673
8703
|
}
|
|
8674
8704
|
function parseSuffixes(value) {
|
|
8675
8705
|
const suffixes = String(value ?? DEFAULT_SUFFIXES.join(",")).split(/[,,\s]+/).map((suffix) => normalizeSuffix(suffix)).filter((suffix) => suffix.length > 0);
|
|
8676
8706
|
if (suffixes.length === 0) {
|
|
8677
8707
|
return err27(1, "\u6587\u4EF6\u540E\u7F00\u4E0D\u80FD\u4E3A\u7A7A");
|
|
8678
8708
|
}
|
|
8679
|
-
return
|
|
8709
|
+
return ok59(new Set(suffixes));
|
|
8680
8710
|
}
|
|
8681
8711
|
function normalizeSuffix(value) {
|
|
8682
8712
|
return value.trim().replace(/^\.+/, "").toLowerCase();
|
|
@@ -8804,4 +8834,4 @@ export {
|
|
|
8804
8834
|
ToolCommand,
|
|
8805
8835
|
createRootCommands
|
|
8806
8836
|
};
|
|
8807
|
-
//# sourceMappingURL=chunk-
|
|
8837
|
+
//# sourceMappingURL=chunk-BIWQYBMS.js.map
|