@tencentcloudadp/cli 0.1.1 → 0.1.4
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/cli.js +971 -369
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
- package/skills/adp/SKILL.md +10 -7
- package/skills/adp/create/SKILL.md +7 -3
- package/skills/adp/gotchas/SKILL.md +3 -3
- package/skills/adp/references/app-modes.md +1 -1
- package/skills/adp/references/auth.md +24 -9
package/dist/cli.js
CHANGED
|
@@ -607,9 +607,9 @@ function createLogger(options) {
|
|
|
607
607
|
// src/interfaces/cli/core/output/display-width.ts
|
|
608
608
|
var WIDE = /[\u1100-\u115f\u2e80-\u303e\u3041-\u33ff\u3400-\u4dbf\u4e00-\u9fff\ua000-\ua4cf\ua960-\ua97f\uac00-\ud7a3\uf900-\ufaff\ufe10-\ufe19\ufe30-\ufe6f\uff00-\uff60\uffe0-\uffe6]|[\u{16fe0}-\u{16fe4}\u{17000}-\u{18aff}\u{1b000}-\u{1b16f}\u{1f004}\u{1f0cf}\u{1f18e}\u{1f191}-\u{1f19a}\u{1f200}-\u{1f320}\u{1f32d}-\u{1f335}\u{1f337}-\u{1f37c}\u{1f37e}-\u{1f393}\u{1f3a0}-\u{1f3ca}\u{1f3cf}-\u{1f3d3}\u{1f3e0}-\u{1f3f0}\u{1f3f4}\u{1f3f8}-\u{1f43e}\u{1f440}\u{1f442}-\u{1f4fc}\u{1f4ff}-\u{1f53d}\u{1f54b}-\u{1f54e}\u{1f550}-\u{1f567}\u{1f57a}\u{1f595}-\u{1f596}\u{1f5a4}\u{1f5fb}-\u{1f64f}\u{1f680}-\u{1f6c5}\u{1f6cc}\u{1f6d0}-\u{1f6d2}\u{1f6eb}-\u{1f6ec}\u{1f6f4}-\u{1f6fc}\u{1f7e0}-\u{1f7eb}\u{1f90c}-\u{1f93a}\u{1f93c}-\u{1f945}\u{1f947}-\u{1f9ff}\u{1fa70}-\u{1faff}\u{20000}-\u{3fffd}]/u;
|
|
609
609
|
var ZERO = /[\p{Mn}\p{Me}\u200b-\u200f\ufeff]/u;
|
|
610
|
-
function displayWidth(
|
|
610
|
+
function displayWidth(text13) {
|
|
611
611
|
let width = 0;
|
|
612
|
-
for (const char of
|
|
612
|
+
for (const char of text13) {
|
|
613
613
|
const code = char.codePointAt(0) ?? 0;
|
|
614
614
|
if (code < 32 || code >= 127 && code < 160) {
|
|
615
615
|
continue;
|
|
@@ -621,13 +621,13 @@ function displayWidth(text12) {
|
|
|
621
621
|
}
|
|
622
622
|
return width;
|
|
623
623
|
}
|
|
624
|
-
function fitToWidth(
|
|
624
|
+
function fitToWidth(text13, width) {
|
|
625
625
|
if (width <= 0) {
|
|
626
626
|
return "";
|
|
627
627
|
}
|
|
628
628
|
let used = 0;
|
|
629
629
|
let out = "";
|
|
630
|
-
for (const char of
|
|
630
|
+
for (const char of text13) {
|
|
631
631
|
const size = displayWidth(char);
|
|
632
632
|
if (used + size > width) {
|
|
633
633
|
break;
|
|
@@ -686,15 +686,15 @@ function shrink(widths, floors, budget) {
|
|
|
686
686
|
over -= 1;
|
|
687
687
|
}
|
|
688
688
|
}
|
|
689
|
-
function maxLineWidth(
|
|
690
|
-
return Math.max(0, ...
|
|
689
|
+
function maxLineWidth(text13) {
|
|
690
|
+
return Math.max(0, ...text13.split("\n").map(displayWidth));
|
|
691
691
|
}
|
|
692
|
-
function longestWord(
|
|
693
|
-
return Math.max(0, ...
|
|
692
|
+
function longestWord(text13) {
|
|
693
|
+
return Math.max(0, ...text13.split(/\s+/).map(displayWidth));
|
|
694
694
|
}
|
|
695
|
-
function wrapCell(
|
|
695
|
+
function wrapCell(text13, width) {
|
|
696
696
|
const lines = [];
|
|
697
|
-
for (const paragraph of
|
|
697
|
+
for (const paragraph of text13.split("\n")) {
|
|
698
698
|
let line = "";
|
|
699
699
|
for (const word of paragraph.split(/(\s+)/)) {
|
|
700
700
|
if (word === "") {
|
|
@@ -719,10 +719,10 @@ function wrapCell(text12, width) {
|
|
|
719
719
|
}
|
|
720
720
|
return lines;
|
|
721
721
|
}
|
|
722
|
-
function splitAtWidth(
|
|
722
|
+
function splitAtWidth(text13, width) {
|
|
723
723
|
let used = 0;
|
|
724
724
|
let head = "";
|
|
725
|
-
const chars = [...
|
|
725
|
+
const chars = [...text13];
|
|
726
726
|
let index = 0;
|
|
727
727
|
for (; index < chars.length; index += 1) {
|
|
728
728
|
const size = displayWidth(chars[index] ?? "");
|
|
@@ -773,8 +773,8 @@ var OutputWriter = class {
|
|
|
773
773
|
get format() {
|
|
774
774
|
return this.io.format;
|
|
775
775
|
}
|
|
776
|
-
writeNotice(
|
|
777
|
-
this.logger.info(
|
|
776
|
+
writeNotice(text13) {
|
|
777
|
+
this.logger.info(text13.endsWith("\n") ? text13.slice(0, -1) : text13);
|
|
778
778
|
}
|
|
779
779
|
async writeSuccess(command, rawResult, nextActions = [], options) {
|
|
780
780
|
const projected = this.projectResult(rawResult);
|
|
@@ -1250,8 +1250,9 @@ function applyDefinition(cmd, definition) {
|
|
|
1250
1250
|
type: flag.type,
|
|
1251
1251
|
describe: flag.describe,
|
|
1252
1252
|
demandOption: flag.required,
|
|
1253
|
-
choices: flag.choices,
|
|
1254
|
-
default: flag.default
|
|
1253
|
+
...flag.choices ? { choices: flag.choices } : {},
|
|
1254
|
+
...flag.default !== void 0 ? { default: flag.default } : {},
|
|
1255
|
+
...flag.list === true ? { array: true } : {}
|
|
1255
1256
|
});
|
|
1256
1257
|
}
|
|
1257
1258
|
const detail = helpDetail(definition);
|
|
@@ -1688,6 +1689,7 @@ function createLocalCredentialForm() {
|
|
|
1688
1689
|
}
|
|
1689
1690
|
async function openForm(input) {
|
|
1690
1691
|
const token = randomBytes(32).toString("base64url");
|
|
1692
|
+
const csrf = randomBytes(32).toString("base64url");
|
|
1691
1693
|
const expectedPath = `/login/${token}`;
|
|
1692
1694
|
let host = "";
|
|
1693
1695
|
let state = "open";
|
|
@@ -1699,7 +1701,7 @@ async function openForm(input) {
|
|
|
1699
1701
|
const server = createServer((req, res) => {
|
|
1700
1702
|
void handle(req, res).catch(() => {
|
|
1701
1703
|
if (!res.headersSent) {
|
|
1702
|
-
send(res, 500, page({ error: "Internal error" }));
|
|
1704
|
+
send(res, 500, page({ error: "Internal error", csrf }));
|
|
1703
1705
|
}
|
|
1704
1706
|
});
|
|
1705
1707
|
});
|
|
@@ -1718,19 +1720,15 @@ async function openForm(input) {
|
|
|
1718
1720
|
return;
|
|
1719
1721
|
}
|
|
1720
1722
|
if (req.method === "GET") {
|
|
1721
|
-
send(res, 200, page({ site: input.defaultSite }));
|
|
1723
|
+
send(res, 200, page({ site: input.defaultSite, csrf }));
|
|
1722
1724
|
return;
|
|
1723
1725
|
}
|
|
1724
1726
|
if (req.method !== "POST") {
|
|
1725
1727
|
send(res, 405, "Method not allowed", "text/plain");
|
|
1726
1728
|
return;
|
|
1727
1729
|
}
|
|
1728
|
-
if (!isSameOrigin(req, host)) {
|
|
1729
|
-
send(res, 403, "Cross-origin request rejected", "text/plain");
|
|
1730
|
-
return;
|
|
1731
|
-
}
|
|
1732
1730
|
if (state === "verifying") {
|
|
1733
|
-
send(res, 409, page({ error: "A submission is already being verified. Wait a moment and reload." }));
|
|
1731
|
+
send(res, 409, page({ error: "A submission is already being verified. Wait a moment and reload.", csrf }));
|
|
1734
1732
|
return;
|
|
1735
1733
|
}
|
|
1736
1734
|
const body = await readBody(req);
|
|
@@ -1738,9 +1736,17 @@ async function openForm(input) {
|
|
|
1738
1736
|
send(res, 413, "Request body too large", "text/plain");
|
|
1739
1737
|
return;
|
|
1740
1738
|
}
|
|
1741
|
-
const
|
|
1739
|
+
const params = new URLSearchParams(body);
|
|
1740
|
+
if (!isSameOrigin(req, host) && !sameSecret(params.get("csrf") ?? "", csrf)) {
|
|
1741
|
+
send(res, 403, page({
|
|
1742
|
+
error: "\u6D4F\u89C8\u5668\u628A\u8FD9\u6B21\u63D0\u4EA4\u5F53\u6210\u4E86\u8DE8\u7AD9\u8BF7\u6C42\u3002\u8BF7\u5728\u672C\u9875\u91CD\u65B0\u586B\u5199\u5E76\u70B9\u300C\u9A8C\u8BC1\u5E76\u4FDD\u5B58\u300D\u3002",
|
|
1743
|
+
csrf
|
|
1744
|
+
}));
|
|
1745
|
+
return;
|
|
1746
|
+
}
|
|
1747
|
+
const parsed = parseSubmission(params);
|
|
1742
1748
|
if ("error" in parsed) {
|
|
1743
|
-
send(res, 400, page({ error: parsed.error, site: parsed.site, secretId: parsed.secretId }));
|
|
1749
|
+
send(res, 400, page({ error: parsed.error, site: parsed.site, secretId: parsed.secretId, csrf }));
|
|
1744
1750
|
return;
|
|
1745
1751
|
}
|
|
1746
1752
|
state = "verifying";
|
|
@@ -1749,7 +1755,7 @@ async function openForm(input) {
|
|
|
1749
1755
|
} catch (error) {
|
|
1750
1756
|
state = "open";
|
|
1751
1757
|
const message = error instanceof Error ? error.message : "Verification failed";
|
|
1752
|
-
send(res, 400, page({ error: message, site: parsed.credential.site, secretId: parsed.credential.secretId }));
|
|
1758
|
+
send(res, 400, page({ error: message, site: parsed.credential.site, secretId: parsed.credential.secretId, csrf }));
|
|
1753
1759
|
return;
|
|
1754
1760
|
}
|
|
1755
1761
|
state = "done";
|
|
@@ -1850,6 +1856,11 @@ body{font:14px/1.6 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;max-wi
|
|
|
1850
1856
|
label{display:block;margin:14px 0 4px;font-weight:600}input,select{width:100%;padding:8px;box-sizing:border-box;border:1px solid #c9cdd4;border-radius:6px;font:inherit}
|
|
1851
1857
|
button{margin-top:20px;padding:9px 18px;border:0;border-radius:6px;background:#0052d9;color:#fff;font:inherit;cursor:pointer}
|
|
1852
1858
|
.err{background:#fff1f0;border:1px solid #ffccc7;padding:8px 12px;border-radius:6px}.hint{color:#646a73;font-size:13px}
|
|
1859
|
+
.site-hint,.endpoint-field{display:none}
|
|
1860
|
+
form:has(#site option[value="cloud"]:checked) .hint-cloud,
|
|
1861
|
+
form:has(#site option[value="independent"]:checked) .hint-independent,
|
|
1862
|
+
form:has(#site option[value="custom"]:checked) .hint-custom,
|
|
1863
|
+
form:has(#site option[value="custom"]:checked) .endpoint-field{display:block}
|
|
1853
1864
|
</style></head><body>${body}</body></html>`;
|
|
1854
1865
|
}
|
|
1855
1866
|
function form(input) {
|
|
@@ -1859,15 +1870,20 @@ function form(input) {
|
|
|
1859
1870
|
<p class="hint">\u51ED\u636E\u53EA\u4FDD\u5B58\u5728\u672C\u673A\uFF08~/.adp/profiles\uFF0C\u6743\u9650 0600\uFF09\uFF0C\u4E0D\u4F1A\u53D1\u9001\u5230\u5BF9\u8BDD\u3002\u8BF7\u4E0D\u8981\u628A\u5BC6\u94A5\u7C98\u8D34\u5230\u804A\u5929\u91CC\u3002</p>
|
|
1860
1871
|
${input.error ? `<p class="err">${escapeHtml(input.error)}</p>` : ""}
|
|
1861
1872
|
<form method="post" autocomplete="off">
|
|
1873
|
+
<input type="hidden" name="csrf" value="${escapeHtml(input.csrf ?? "")}">
|
|
1862
1874
|
<label for="site">\u7AD9\u70B9</label>
|
|
1863
1875
|
<select id="site" name="site">${option("cloud", "\u516C\u6709\u4E91\uFF08adp.tencentcloudapi.com\uFF09")}${option("independent", "\u72EC\u7ACB\u7AD9\uFF08capi.adp.tencent.com\uFF09")}${option("custom", "\u81EA\u5B9A\u4E49\u5730\u5740")}</select>
|
|
1864
|
-
<
|
|
1876
|
+
<div class="endpoint-field">
|
|
1877
|
+
<label for="endpoint">\u81EA\u5B9A\u4E49\u5730\u5740</label>
|
|
1865
1878
|
<input id="endpoint" name="endpoint" placeholder="capi.internal.example.com">
|
|
1879
|
+
</div>
|
|
1866
1880
|
<label for="secretId">SecretId</label>
|
|
1867
|
-
<input id="secretId" name="secretId" required value="${escapeHtml(input.secretId ?? "")}"
|
|
1881
|
+
<input id="secretId" name="secretId" required value="${escapeHtml(input.secretId ?? "")}">
|
|
1868
1882
|
<label for="secretKey">SecretKey</label>
|
|
1869
1883
|
<input id="secretKey" name="secretKey" type="password" required>
|
|
1870
|
-
<p class="hint">\u516C\u6709\u4E91\u5BC6\u94A5\u5728 <a href="https://console.cloud.tencent.com/cam/capi" target="_blank" rel="noreferrer">CAM \u63A7\u5236\u53F0</a> \u521B\u5EFA\u3002</p>
|
|
1884
|
+
<p class="hint site-hint hint-cloud">\u516C\u6709\u4E91\u5BC6\u94A5\u5728 <a href="https://console.cloud.tencent.com/cam/capi" target="_blank" rel="noreferrer">CAM \u63A7\u5236\u53F0</a> \u521B\u5EFA\uFF0CSecretId \u4EE5 AKID \u5F00\u5934\u3002</p>
|
|
1885
|
+
<p class="hint site-hint hint-independent">\u72EC\u7ACB\u7AD9\u5BC6\u94A5\u5728 <a href="https://adp.tencent.com/adp#/key-manage" target="_blank" rel="noreferrer">\u4F01\u4E1A\u7BA1\u7406 \u2192 \u5BC6\u94A5\u7BA1\u7406 \u2192 \u65B0\u5EFAAPI\u5BC6\u94A5</a>\uFF0C\u4E0D\u8981\u6C42 AKID \u524D\u7F00\u3002</p>
|
|
1886
|
+
<p class="hint site-hint hint-custom">\u4F7F\u7528\u76EE\u6807\u73AF\u5883\u7B7E\u53D1\u7684 SecretId / SecretKey\u3002</p>
|
|
1871
1887
|
<button type="submit">\u9A8C\u8BC1\u5E76\u4FDD\u5B58</button>
|
|
1872
1888
|
</form>`;
|
|
1873
1889
|
}
|
|
@@ -2009,16 +2025,16 @@ function profileFileName(name) {
|
|
|
2009
2025
|
function createProfileStore(dir = adpProfilesDir(), activePath = adpActiveProfilePath()) {
|
|
2010
2026
|
return {
|
|
2011
2027
|
async load(name) {
|
|
2012
|
-
let
|
|
2028
|
+
let text13;
|
|
2013
2029
|
try {
|
|
2014
|
-
|
|
2030
|
+
text13 = await readFile(path.join(dir, profileFileName(name)), "utf8");
|
|
2015
2031
|
} catch (error) {
|
|
2016
2032
|
if (error.code === "ENOENT") {
|
|
2017
2033
|
return void 0;
|
|
2018
2034
|
}
|
|
2019
2035
|
throw error;
|
|
2020
2036
|
}
|
|
2021
|
-
return parseProfile(name,
|
|
2037
|
+
return parseProfile(name, text13);
|
|
2022
2038
|
},
|
|
2023
2039
|
async save(profile) {
|
|
2024
2040
|
await mkdir(dir, { recursive: true });
|
|
@@ -2057,16 +2073,16 @@ function createProfileStore(dir = adpProfilesDir(), activePath = adpActiveProfil
|
|
|
2057
2073
|
return profiles;
|
|
2058
2074
|
},
|
|
2059
2075
|
async active() {
|
|
2060
|
-
let
|
|
2076
|
+
let text13;
|
|
2061
2077
|
try {
|
|
2062
|
-
|
|
2078
|
+
text13 = await readFile(activePath, "utf8");
|
|
2063
2079
|
} catch (error) {
|
|
2064
2080
|
if (error.code === "ENOENT") {
|
|
2065
2081
|
return void 0;
|
|
2066
2082
|
}
|
|
2067
2083
|
throw error;
|
|
2068
2084
|
}
|
|
2069
|
-
const name =
|
|
2085
|
+
const name = text13.trim();
|
|
2070
2086
|
return name.length > 0 ? name : void 0;
|
|
2071
2087
|
},
|
|
2072
2088
|
async setActive(name) {
|
|
@@ -2078,10 +2094,10 @@ function createProfileStore(dir = adpProfilesDir(), activePath = adpActiveProfil
|
|
|
2078
2094
|
}
|
|
2079
2095
|
};
|
|
2080
2096
|
}
|
|
2081
|
-
function parseProfile(name,
|
|
2097
|
+
function parseProfile(name, text13) {
|
|
2082
2098
|
let raw;
|
|
2083
2099
|
try {
|
|
2084
|
-
raw = JSON.parse(
|
|
2100
|
+
raw = JSON.parse(text13);
|
|
2085
2101
|
} catch {
|
|
2086
2102
|
return void 0;
|
|
2087
2103
|
}
|
|
@@ -2747,7 +2763,8 @@ function createAppPackageGateway(clients) {
|
|
|
2747
2763
|
const response = await callSdk(
|
|
2748
2764
|
() => clients.adp.request("ExportApp", {
|
|
2749
2765
|
AppId: input.appId,
|
|
2750
|
-
...input.releaseId ? { ReleaseId: input.releaseId } : {}
|
|
2766
|
+
...input.releaseId ? { ReleaseId: input.releaseId } : {},
|
|
2767
|
+
Summary: toExportSummary(input.summary, input.appId)
|
|
2751
2768
|
})
|
|
2752
2769
|
);
|
|
2753
2770
|
return { taskId: str(response.TaskId) };
|
|
@@ -2823,19 +2840,23 @@ var COMPONENT_LISTS = [
|
|
|
2823
2840
|
["PluginList", "plugin"],
|
|
2824
2841
|
["SkillList", "skill"]
|
|
2825
2842
|
];
|
|
2843
|
+
var COMPONENT_TYPE = {
|
|
2844
|
+
kb: 2,
|
|
2845
|
+
workflow: 3,
|
|
2846
|
+
agent: 4,
|
|
2847
|
+
plugin: 5,
|
|
2848
|
+
skill: 6
|
|
2849
|
+
};
|
|
2826
2850
|
function toSummary3(summary, appId3) {
|
|
2827
2851
|
const config2 = asRecord2(summary.AppConfig);
|
|
2828
2852
|
const components = [];
|
|
2829
2853
|
for (const [key, kind2] of COMPONENT_LISTS) {
|
|
2830
2854
|
const list5 = Array.isArray(summary[key]) ? summary[key] : [];
|
|
2831
2855
|
for (const item of list5) {
|
|
2832
|
-
const component = asRecord2(item);
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
name: str(component.Name) || void 0,
|
|
2837
|
-
updateTime: num(component.UpdateTime)
|
|
2838
|
-
});
|
|
2856
|
+
const component = toComponent(asRecord2(item), kind2);
|
|
2857
|
+
if (component.id) {
|
|
2858
|
+
components.push(component);
|
|
2859
|
+
}
|
|
2839
2860
|
}
|
|
2840
2861
|
}
|
|
2841
2862
|
return {
|
|
@@ -2843,9 +2864,84 @@ function toSummary3(summary, appId3) {
|
|
|
2843
2864
|
appName: str(config2.AppName) || void 0,
|
|
2844
2865
|
releaseId: str(config2.ReleaseId) || void 0,
|
|
2845
2866
|
releaseVersion: str(config2.ReleaseVersion) || void 0,
|
|
2867
|
+
updateTime: num(config2.UpdateTime),
|
|
2846
2868
|
components
|
|
2847
2869
|
};
|
|
2848
2870
|
}
|
|
2871
|
+
function toComponent(component, kind2) {
|
|
2872
|
+
const refs = componentRefs(component);
|
|
2873
|
+
return {
|
|
2874
|
+
kind: kind2,
|
|
2875
|
+
id: str(component.ComponentId),
|
|
2876
|
+
name: str(component.Name) || void 0,
|
|
2877
|
+
updateTime: num(component.UpdateTime),
|
|
2878
|
+
componentType: num(component.ComponentType),
|
|
2879
|
+
...refs ? { refs } : {}
|
|
2880
|
+
};
|
|
2881
|
+
}
|
|
2882
|
+
function componentRefs(component) {
|
|
2883
|
+
const refs = {
|
|
2884
|
+
agentIds: idList(component.AgentIdList),
|
|
2885
|
+
kbIds: idList(component.KbIdList),
|
|
2886
|
+
pluginIds: idList(component.PluginIdList),
|
|
2887
|
+
skillIds: idList(component.SkillIdList),
|
|
2888
|
+
workflowIds: idList(component.WorkflowIdList)
|
|
2889
|
+
};
|
|
2890
|
+
const present = Object.keys(refs).filter((key) => (refs[key]?.length ?? 0) > 0);
|
|
2891
|
+
if (present.length === 0) {
|
|
2892
|
+
return void 0;
|
|
2893
|
+
}
|
|
2894
|
+
const kept = {};
|
|
2895
|
+
for (const key of present) {
|
|
2896
|
+
kept[key] = refs[key];
|
|
2897
|
+
}
|
|
2898
|
+
return kept;
|
|
2899
|
+
}
|
|
2900
|
+
function toExportSummary(summary, appId3) {
|
|
2901
|
+
const lists = {
|
|
2902
|
+
KbList: [],
|
|
2903
|
+
WorkflowList: [],
|
|
2904
|
+
AgentList: [],
|
|
2905
|
+
PluginList: [],
|
|
2906
|
+
SkillList: []
|
|
2907
|
+
};
|
|
2908
|
+
for (const component of summary.components) {
|
|
2909
|
+
const key = COMPONENT_LISTS.find(([, kind2]) => kind2 === component.kind)?.[0];
|
|
2910
|
+
if (key) {
|
|
2911
|
+
lists[key].push(toComponentInfo(component));
|
|
2912
|
+
}
|
|
2913
|
+
}
|
|
2914
|
+
return {
|
|
2915
|
+
AppConfig: {
|
|
2916
|
+
AppId: summary.appId || appId3,
|
|
2917
|
+
...summary.appName ? { AppName: summary.appName } : {},
|
|
2918
|
+
...summary.releaseId ? { ReleaseId: summary.releaseId } : {},
|
|
2919
|
+
...summary.releaseVersion ? { ReleaseVersion: summary.releaseVersion } : {},
|
|
2920
|
+
...summary.updateTime !== void 0 ? { UpdateTime: summary.updateTime } : {}
|
|
2921
|
+
},
|
|
2922
|
+
...lists
|
|
2923
|
+
};
|
|
2924
|
+
}
|
|
2925
|
+
function toComponentInfo(component) {
|
|
2926
|
+
const refs = component.refs;
|
|
2927
|
+
return {
|
|
2928
|
+
ComponentId: component.id,
|
|
2929
|
+
ComponentType: component.componentType ?? COMPONENT_TYPE[component.kind],
|
|
2930
|
+
...component.name ? { Name: component.name } : {},
|
|
2931
|
+
...component.updateTime !== void 0 ? { UpdateTime: component.updateTime } : {},
|
|
2932
|
+
...refs?.agentIds?.length ? { AgentIdList: refs.agentIds } : {},
|
|
2933
|
+
...refs?.kbIds?.length ? { KbIdList: refs.kbIds } : {},
|
|
2934
|
+
...refs?.pluginIds?.length ? { PluginIdList: refs.pluginIds } : {},
|
|
2935
|
+
...refs?.skillIds?.length ? { SkillIdList: refs.skillIds } : {},
|
|
2936
|
+
...refs?.workflowIds?.length ? { WorkflowIdList: refs.workflowIds } : {}
|
|
2937
|
+
};
|
|
2938
|
+
}
|
|
2939
|
+
function idList(value) {
|
|
2940
|
+
if (!Array.isArray(value)) {
|
|
2941
|
+
return [];
|
|
2942
|
+
}
|
|
2943
|
+
return value.map((item) => str(item)).filter((item) => item.length > 0);
|
|
2944
|
+
}
|
|
2849
2945
|
function toExportNotices(response) {
|
|
2850
2946
|
const byId = /* @__PURE__ */ new Map();
|
|
2851
2947
|
for (const key of ["PageNotifyList", "CursorNotifyList", "CenterNotifyList"]) {
|
|
@@ -4789,14 +4885,14 @@ function createUsageGateway(client) {
|
|
|
4789
4885
|
const response = await callSdk(
|
|
4790
4886
|
() => client.request("DescribeMsgRecordList", { AppId: input.appId, ...pageParams(input.limit, input.page) })
|
|
4791
4887
|
);
|
|
4792
|
-
const
|
|
4888
|
+
const text13 = (value) => typeof value === "string" && value ? value : void 0;
|
|
4793
4889
|
return readPagedList(response, ["MsgRecordList", "RecordList"], (raw) => ({
|
|
4794
|
-
recordId:
|
|
4795
|
-
conversationId:
|
|
4796
|
-
question:
|
|
4797
|
-
answer:
|
|
4798
|
-
categoryId:
|
|
4799
|
-
createdAt:
|
|
4890
|
+
recordId: text13(raw.RecordId),
|
|
4891
|
+
conversationId: text13(raw.SessionId),
|
|
4892
|
+
question: text13(raw.Question),
|
|
4893
|
+
answer: text13(raw.Answer),
|
|
4894
|
+
categoryId: text13(raw.CategoryId),
|
|
4895
|
+
createdAt: text13(raw.CreateTime)
|
|
4800
4896
|
}));
|
|
4801
4897
|
}
|
|
4802
4898
|
};
|
|
@@ -5429,13 +5525,13 @@ function toTrace(raw) {
|
|
|
5429
5525
|
}
|
|
5430
5526
|
function toContent(raw) {
|
|
5431
5527
|
const content = { type: String(raw.Type ?? "") };
|
|
5432
|
-
const
|
|
5528
|
+
const text13 = optionalString8(raw.Text);
|
|
5433
5529
|
const references = readList(raw, ["ReferenceList", "References"]).flatMap((item) => toReference(asRecord2(item)));
|
|
5434
5530
|
const quoteInfos = readList(raw, ["QuoteInfoList", "QuoteInfos"]).flatMap((item) => toQuote(asRecord2(item)));
|
|
5435
5531
|
const tasks = readList(raw, ["TaskList", "Tasks"]).flatMap((item) => toTask2(asRecord2(item)));
|
|
5436
5532
|
const mcpApp = toMcpApp(asRecord2(raw.McpApp));
|
|
5437
|
-
if (
|
|
5438
|
-
content.text =
|
|
5533
|
+
if (text13) {
|
|
5534
|
+
content.text = text13;
|
|
5439
5535
|
}
|
|
5440
5536
|
if (references.length > 0) {
|
|
5441
5537
|
content.references = references;
|
|
@@ -6159,17 +6255,17 @@ function optionalString10(value) {
|
|
|
6159
6255
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
6160
6256
|
}
|
|
6161
6257
|
function optionalTime(value) {
|
|
6162
|
-
const
|
|
6163
|
-
if (
|
|
6258
|
+
const text13 = typeof value === "number" && Number.isFinite(value) ? String(value) : optionalString10(value);
|
|
6259
|
+
if (text13 === void 0) {
|
|
6164
6260
|
return void 0;
|
|
6165
6261
|
}
|
|
6166
|
-
return isGoZeroTime(
|
|
6262
|
+
return isGoZeroTime(text13) ? null : text13;
|
|
6167
6263
|
}
|
|
6168
|
-
function isGoZeroTime(
|
|
6169
|
-
if (
|
|
6264
|
+
function isGoZeroTime(text13) {
|
|
6265
|
+
if (text13.startsWith("0001-01-01")) {
|
|
6170
6266
|
return true;
|
|
6171
6267
|
}
|
|
6172
|
-
const seconds2 = Number(
|
|
6268
|
+
const seconds2 = Number(text13);
|
|
6173
6269
|
return Number.isFinite(seconds2) && seconds2 <= 0;
|
|
6174
6270
|
}
|
|
6175
6271
|
function optionalNumber5(value) {
|
|
@@ -6501,8 +6597,8 @@ function optionalNumber6(value) {
|
|
|
6501
6597
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
6502
6598
|
}
|
|
6503
6599
|
function optionalId(value) {
|
|
6504
|
-
const
|
|
6505
|
-
return
|
|
6600
|
+
const text13 = value === void 0 || value === null ? "" : String(value);
|
|
6601
|
+
return text13.length > 0 && text13 !== "0" ? text13 : void 0;
|
|
6506
6602
|
}
|
|
6507
6603
|
function toSummary13(raw) {
|
|
6508
6604
|
const spec = asRecord2(raw.Spec);
|
|
@@ -6697,9 +6793,9 @@ import { chmod as chmod2, mkdir as mkdir2, readFile as readFile3, rm as rm2, wri
|
|
|
6697
6793
|
import path3 from "path";
|
|
6698
6794
|
|
|
6699
6795
|
// src/infrastructure/fs/ini-credentials.ts
|
|
6700
|
-
function parseIni(
|
|
6796
|
+
function parseIni(text13) {
|
|
6701
6797
|
const result = {};
|
|
6702
|
-
for (const rawLine of
|
|
6798
|
+
for (const rawLine of text13.split(/\r?\n/)) {
|
|
6703
6799
|
const line = rawLine.trim();
|
|
6704
6800
|
if (!line || line.startsWith("#") || line.startsWith(";") || line.startsWith("[")) {
|
|
6705
6801
|
continue;
|
|
@@ -6741,8 +6837,8 @@ function createCredentialFileStore(filePath, source2) {
|
|
|
6741
6837
|
return {
|
|
6742
6838
|
async load() {
|
|
6743
6839
|
try {
|
|
6744
|
-
const
|
|
6745
|
-
const parsed = parseIni(
|
|
6840
|
+
const text13 = await readFile3(filePath, "utf8");
|
|
6841
|
+
const parsed = parseIni(text13);
|
|
6746
6842
|
const secretId = parsed.secret_id ?? parsed.secretid;
|
|
6747
6843
|
const secretKey = parsed.secret_key ?? parsed.secretkey;
|
|
6748
6844
|
if (!secretId || !secretKey) {
|
|
@@ -7224,9 +7320,9 @@ function unknownConfigFields(parsed) {
|
|
|
7224
7320
|
return Object.keys(parsed).filter((key) => !known.has(key));
|
|
7225
7321
|
}
|
|
7226
7322
|
async function readConfigFile(configPath) {
|
|
7227
|
-
let
|
|
7323
|
+
let text13;
|
|
7228
7324
|
try {
|
|
7229
|
-
|
|
7325
|
+
text13 = await readFile4(configPath, "utf8");
|
|
7230
7326
|
} catch {
|
|
7231
7327
|
throw new DomainError(`Config not found: ${configPath}`, "usage", "UsageError", {
|
|
7232
7328
|
hint: "Run: adp init or pass --config path/to/adp.jsonc",
|
|
@@ -7239,7 +7335,7 @@ async function readConfigFile(configPath) {
|
|
|
7239
7335
|
]
|
|
7240
7336
|
});
|
|
7241
7337
|
}
|
|
7242
|
-
const parsed = parseJsonc(
|
|
7338
|
+
const parsed = parseJsonc(text13);
|
|
7243
7339
|
const result = adpConfigSchema.safeParse(parsed);
|
|
7244
7340
|
if (!result.success) {
|
|
7245
7341
|
throw usageError(
|
|
@@ -7258,16 +7354,16 @@ async function readConfigFile(configPath) {
|
|
|
7258
7354
|
return { config: fileToAdpConfig(result.data), warnings };
|
|
7259
7355
|
}
|
|
7260
7356
|
async function readOptionalConfig(configPath) {
|
|
7261
|
-
let
|
|
7357
|
+
let text13;
|
|
7262
7358
|
try {
|
|
7263
|
-
|
|
7359
|
+
text13 = await readFile4(configPath, "utf8");
|
|
7264
7360
|
} catch (error) {
|
|
7265
7361
|
if (error.code === "ENOENT") {
|
|
7266
7362
|
return void 0;
|
|
7267
7363
|
}
|
|
7268
7364
|
throw error;
|
|
7269
7365
|
}
|
|
7270
|
-
const parsed = parseJsonc(
|
|
7366
|
+
const parsed = parseJsonc(text13);
|
|
7271
7367
|
if (!parsed || typeof parsed !== "object") {
|
|
7272
7368
|
return void 0;
|
|
7273
7369
|
}
|
|
@@ -8037,8 +8133,8 @@ function str12(value) {
|
|
|
8037
8133
|
return typeof value === "string" || typeof value === "number" ? String(value) : "";
|
|
8038
8134
|
}
|
|
8039
8135
|
function opt(value) {
|
|
8040
|
-
const
|
|
8041
|
-
return
|
|
8136
|
+
const text13 = str12(value);
|
|
8137
|
+
return text13 === "" ? void 0 : text13;
|
|
8042
8138
|
}
|
|
8043
8139
|
function num6(value) {
|
|
8044
8140
|
if (typeof value === "number") {
|
|
@@ -10328,21 +10424,21 @@ function parseDocContent(payload, documentId, productId) {
|
|
|
10328
10424
|
}
|
|
10329
10425
|
const markdown = stringField(content, ["markdown", "Markdown"]) ?? stringField(record, ["markdown", "Markdown"]);
|
|
10330
10426
|
const html = stringField(content, ["body", "html", "HTML", "content"]) ?? stringField(record, ["body", "html", "HTML"]);
|
|
10331
|
-
const
|
|
10427
|
+
const text13 = markdown && markdown.trim() || htmlToText(html ?? "");
|
|
10332
10428
|
return {
|
|
10333
10429
|
documentId: stringField(record, ["id"]) ?? documentId,
|
|
10334
10430
|
title,
|
|
10335
10431
|
keyword: stringField(record, ["keywords", "keyword", "Keywords"]) ?? stringField(content, ["keywords", "keyword"]),
|
|
10336
10432
|
url: documentUrl(productId, documentId),
|
|
10337
|
-
text:
|
|
10433
|
+
text: text13
|
|
10338
10434
|
};
|
|
10339
10435
|
}
|
|
10340
10436
|
function stripSnippetHtml(value) {
|
|
10341
10437
|
if (!value) {
|
|
10342
10438
|
return void 0;
|
|
10343
10439
|
}
|
|
10344
|
-
const
|
|
10345
|
-
return
|
|
10440
|
+
const text13 = value.replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim();
|
|
10441
|
+
return text13 || void 0;
|
|
10346
10442
|
}
|
|
10347
10443
|
function htmlToText(html) {
|
|
10348
10444
|
return html.replace(/<script[\s\S]*?<\/script>/gi, " ").replace(/<style[\s\S]*?<\/style>/gi, " ").replace(/<[^>]+>/g, " ").replace(/ /gi, " ").replace(/</gi, "<").replace(/>/gi, ">").replace(/&/gi, "&").replace(/"/gi, '"').replace(/\s+/g, " ").trim();
|
|
@@ -12936,15 +13032,15 @@ function registerDevCommands(registry, ctx) {
|
|
|
12936
13032
|
);
|
|
12937
13033
|
}
|
|
12938
13034
|
function assertOptionalId(value, name) {
|
|
12939
|
-
const
|
|
12940
|
-
return
|
|
13035
|
+
const text13 = optionalString13(value);
|
|
13036
|
+
return text13 === void 0 ? void 0 : name === "app-id" ? assertNumericId(text13, name, "adp app list --all-spaces --fields appId,name,spaceId --format json") : assertResourceId(text13, name);
|
|
12941
13037
|
}
|
|
12942
13038
|
function isFollowUpQuestion(reply) {
|
|
12943
|
-
const
|
|
12944
|
-
if (!
|
|
13039
|
+
const text13 = reply?.trim();
|
|
13040
|
+
if (!text13) {
|
|
12945
13041
|
return false;
|
|
12946
13042
|
}
|
|
12947
|
-
return /[??]$/.test(
|
|
13043
|
+
return /[??]$/.test(text13) || /请(提供|输入|告诉|问|补充|说明|选择)/.test(text13);
|
|
12948
13044
|
}
|
|
12949
13045
|
function optionalString13(value) {
|
|
12950
13046
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
@@ -13613,19 +13709,220 @@ function findInZip(zip, suffix, depth = 1) {
|
|
|
13613
13709
|
}
|
|
13614
13710
|
return void 0;
|
|
13615
13711
|
}
|
|
13712
|
+
var EMPTY_INVENTORY = {
|
|
13713
|
+
readable: false,
|
|
13714
|
+
workflowIds: [],
|
|
13715
|
+
hasKnowledgeBases: false,
|
|
13716
|
+
knowledgeBases: []
|
|
13717
|
+
};
|
|
13616
13718
|
function createAppPackageReader() {
|
|
13617
13719
|
return {
|
|
13618
13720
|
async sourceAppId(file) {
|
|
13619
|
-
|
|
13620
|
-
|
|
13621
|
-
|
|
13622
|
-
|
|
13623
|
-
|
|
13624
|
-
|
|
13721
|
+
return (await readInventory(file)).sourceAppId;
|
|
13722
|
+
},
|
|
13723
|
+
async inventory(file) {
|
|
13724
|
+
return readInventory(file);
|
|
13725
|
+
}
|
|
13726
|
+
};
|
|
13727
|
+
}
|
|
13728
|
+
async function readInventory(file) {
|
|
13729
|
+
try {
|
|
13730
|
+
const zip = await readFile10(file);
|
|
13731
|
+
const entries = listEntries(zip);
|
|
13732
|
+
if (entries.length === 0 && zip.length > 0 && !looksLikeZip(zip)) {
|
|
13733
|
+
return EMPTY_INVENTORY;
|
|
13734
|
+
}
|
|
13735
|
+
const names2 = nestedNames(zip);
|
|
13736
|
+
const config2 = findInZip(zip, "app_config/base_config.json");
|
|
13737
|
+
const appId3 = config2 ? JSON.parse(config2.toString("utf8")).AppId : void 0;
|
|
13738
|
+
const sourceAppId = typeof appId3 === "string" && appId3.length > 0 ? appId3 : void 0;
|
|
13739
|
+
const knowledgeBases = mergeKnowledgeBases(
|
|
13740
|
+
readKnowledgeBases(readOuter(zip, "metadata.json")),
|
|
13741
|
+
readKnowledgeBases(readNestedMetadata(zip, "knowledge_bases.zip"))
|
|
13742
|
+
);
|
|
13743
|
+
const hasKnowledgeZip = entries.some((entry) => entry.name.endsWith("knowledge_bases.zip"));
|
|
13744
|
+
return {
|
|
13745
|
+
readable: true,
|
|
13746
|
+
...sourceAppId ? { sourceAppId } : {},
|
|
13747
|
+
workflowIds: workflowIdsFrom(names2),
|
|
13748
|
+
hasKnowledgeBases: hasKnowledgeZip || knowledgeBases.length > 0,
|
|
13749
|
+
knowledgeBases
|
|
13750
|
+
};
|
|
13751
|
+
} catch {
|
|
13752
|
+
return EMPTY_INVENTORY;
|
|
13753
|
+
}
|
|
13754
|
+
}
|
|
13755
|
+
function looksLikeZip(zip) {
|
|
13756
|
+
return zip.length >= 4 && zip.readUInt32LE(0) === LOCAL_FILE_HEADER;
|
|
13757
|
+
}
|
|
13758
|
+
function nestedNames(zip) {
|
|
13759
|
+
const names2 = [];
|
|
13760
|
+
for (const entry of listEntries(zip)) {
|
|
13761
|
+
names2.push(entry.name);
|
|
13762
|
+
if (!entry.name.endsWith(".zip")) {
|
|
13763
|
+
continue;
|
|
13764
|
+
}
|
|
13765
|
+
const inner = readEntry(zip, entry);
|
|
13766
|
+
if (!inner) {
|
|
13767
|
+
continue;
|
|
13768
|
+
}
|
|
13769
|
+
for (const child of listEntries(inner)) {
|
|
13770
|
+
names2.push(child.name);
|
|
13771
|
+
}
|
|
13772
|
+
}
|
|
13773
|
+
return names2;
|
|
13774
|
+
}
|
|
13775
|
+
function readOuter(zip, suffix) {
|
|
13776
|
+
const entry = listEntries(zip).find((item) => item.name.endsWith(suffix) && !item.name.endsWith(".zip"));
|
|
13777
|
+
return entry ? readEntry(zip, entry) : void 0;
|
|
13778
|
+
}
|
|
13779
|
+
function readNestedMetadata(zip, zipSuffix) {
|
|
13780
|
+
const entry = listEntries(zip).find((item) => item.name.endsWith(zipSuffix));
|
|
13781
|
+
const inner = entry ? readEntry(zip, entry) : void 0;
|
|
13782
|
+
return inner ? readOuter(inner, "metadata.json") : void 0;
|
|
13783
|
+
}
|
|
13784
|
+
function workflowIdsFrom(names2) {
|
|
13785
|
+
const ids4 = [];
|
|
13786
|
+
for (const name of names2) {
|
|
13787
|
+
const match = /(?:^|\/)workflow_([^/]+)\.json$/.exec(name);
|
|
13788
|
+
if (!match || match[1] === "config") {
|
|
13789
|
+
continue;
|
|
13790
|
+
}
|
|
13791
|
+
ids4.push(match[1]);
|
|
13792
|
+
}
|
|
13793
|
+
return [...new Set(ids4)];
|
|
13794
|
+
}
|
|
13795
|
+
function readKnowledgeBases(metadata) {
|
|
13796
|
+
if (!metadata) {
|
|
13797
|
+
return [];
|
|
13798
|
+
}
|
|
13799
|
+
let parsed;
|
|
13800
|
+
try {
|
|
13801
|
+
parsed = JSON.parse(metadata.toString("utf8"));
|
|
13802
|
+
} catch {
|
|
13803
|
+
return [];
|
|
13804
|
+
}
|
|
13805
|
+
const root = asObject(parsed);
|
|
13806
|
+
const components = asObject(root.Components ?? root.components);
|
|
13807
|
+
const list5 = knowledgeBaseList(components.KnowledgeBases ?? components.knowledgeBases ?? root.KnowledgeBases ?? root.knowledgeBases);
|
|
13808
|
+
return list5.flatMap(toKnowledgeBase);
|
|
13809
|
+
}
|
|
13810
|
+
function knowledgeBaseList(value) {
|
|
13811
|
+
if (Array.isArray(value)) {
|
|
13812
|
+
return value;
|
|
13813
|
+
}
|
|
13814
|
+
const record = asObject(value);
|
|
13815
|
+
if (Array.isArray(record.Items)) {
|
|
13816
|
+
return record.Items;
|
|
13817
|
+
}
|
|
13818
|
+
if (Array.isArray(record.items)) {
|
|
13819
|
+
return record.items;
|
|
13820
|
+
}
|
|
13821
|
+
return [];
|
|
13822
|
+
}
|
|
13823
|
+
function toKnowledgeBase(item) {
|
|
13824
|
+
if (typeof item === "string" && item.length > 0) {
|
|
13825
|
+
return [{ id: item }];
|
|
13826
|
+
}
|
|
13827
|
+
const record = asObject(item);
|
|
13828
|
+
const id = text2(record.KnowledgeBaseId ?? record.ComponentId ?? record.Id ?? record.KbId ?? record.id);
|
|
13829
|
+
const name = text2(record.Name ?? record.name);
|
|
13830
|
+
if (!id && !name) {
|
|
13831
|
+
return [];
|
|
13832
|
+
}
|
|
13833
|
+
return [{ ...id ? { id } : {}, ...name ? { name } : {} }];
|
|
13834
|
+
}
|
|
13835
|
+
function mergeKnowledgeBases(outer, inner) {
|
|
13836
|
+
if (outer.length === 0) {
|
|
13837
|
+
return inner;
|
|
13838
|
+
}
|
|
13839
|
+
const names2 = new Map(inner.flatMap((item) => item.id && item.name ? [[item.id, item.name]] : []));
|
|
13840
|
+
return outer.map((item) => {
|
|
13841
|
+
const name = item.id ? names2.get(item.id) : void 0;
|
|
13842
|
+
return !item.name && name ? { ...item, name } : item;
|
|
13843
|
+
});
|
|
13844
|
+
}
|
|
13845
|
+
function asObject(value) {
|
|
13846
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
13847
|
+
}
|
|
13848
|
+
function text2(value) {
|
|
13849
|
+
return typeof value === "string" || typeof value === "number" ? String(value) : "";
|
|
13850
|
+
}
|
|
13851
|
+
|
|
13852
|
+
// src/domain/app/package-scope.ts
|
|
13853
|
+
function selectAppPackageSummary(summary, scope = {}) {
|
|
13854
|
+
const includeKinds = scope.includeKinds ? new Set(scope.includeKinds) : void 0;
|
|
13855
|
+
const includeIds = scope.includeIds ? new Set(scope.includeIds) : void 0;
|
|
13856
|
+
const excludeKinds = new Set(scope.excludeKinds ?? []);
|
|
13857
|
+
const excludeIds = new Set(scope.excludeIds ?? []);
|
|
13858
|
+
if (includeIds) {
|
|
13859
|
+
const known = new Set(summary.components.map((component) => component.id));
|
|
13860
|
+
const missing = [...includeIds].filter((id) => !known.has(id));
|
|
13861
|
+
if (missing.length > 0) {
|
|
13862
|
+
throw new DomainError(`Unknown package component: ${missing.join(", ")}`, "usage", "UnknownPackageComponent", {
|
|
13863
|
+
hint: "Pass a component id from the package summary",
|
|
13864
|
+
nextActions: [
|
|
13865
|
+
{
|
|
13866
|
+
command: "adp app package summary --format json",
|
|
13867
|
+
reason: "list the component ids in this release"
|
|
13868
|
+
}
|
|
13869
|
+
]
|
|
13870
|
+
});
|
|
13871
|
+
}
|
|
13872
|
+
}
|
|
13873
|
+
const initialIds = new Set(
|
|
13874
|
+
summary.components.filter((component) => {
|
|
13875
|
+
if (includeKinds && !includeKinds.has(component.kind)) {
|
|
13876
|
+
return false;
|
|
13877
|
+
}
|
|
13878
|
+
if (includeIds && !includeIds.has(component.id)) {
|
|
13879
|
+
return false;
|
|
13880
|
+
}
|
|
13881
|
+
if (excludeKinds.has(component.kind) || excludeIds.has(component.id)) {
|
|
13882
|
+
return false;
|
|
13883
|
+
}
|
|
13884
|
+
return true;
|
|
13885
|
+
}).map((component) => component.id)
|
|
13886
|
+
);
|
|
13887
|
+
const selected = new Set(initialIds);
|
|
13888
|
+
const requiredBy = /* @__PURE__ */ new Map();
|
|
13889
|
+
const byId = new Map(summary.components.map((component) => [component.id, component]));
|
|
13890
|
+
let changed = true;
|
|
13891
|
+
while (changed) {
|
|
13892
|
+
changed = false;
|
|
13893
|
+
for (const component of summary.components) {
|
|
13894
|
+
if (!selected.has(component.id) || component.kind !== "workflow") {
|
|
13895
|
+
continue;
|
|
13896
|
+
}
|
|
13897
|
+
for (const target of referencedConnectorsAndKnowledge(component, byId)) {
|
|
13898
|
+
if (selected.has(target.id)) {
|
|
13899
|
+
continue;
|
|
13900
|
+
}
|
|
13901
|
+
selected.add(target.id);
|
|
13902
|
+
const reasons = requiredBy.get(target.id) ?? [];
|
|
13903
|
+
reasons.push(component.id);
|
|
13904
|
+
requiredBy.set(target.id, reasons);
|
|
13905
|
+
changed = true;
|
|
13625
13906
|
}
|
|
13626
13907
|
}
|
|
13908
|
+
}
|
|
13909
|
+
const components = summary.components.filter((component) => selected.has(component.id));
|
|
13910
|
+
return {
|
|
13911
|
+
summary: { ...summary, components },
|
|
13912
|
+
includedByReference: components.filter((component) => requiredBy.has(component.id)).map((component) => ({ ...component, requiredBy: requiredBy.get(component.id) }))
|
|
13627
13913
|
};
|
|
13628
13914
|
}
|
|
13915
|
+
function referencedConnectorsAndKnowledge(workflow, byId) {
|
|
13916
|
+
const ids4 = [...workflow.refs?.kbIds ?? [], ...workflow.refs?.pluginIds ?? []];
|
|
13917
|
+
const found = [];
|
|
13918
|
+
for (const id of ids4) {
|
|
13919
|
+
const target = byId.get(id);
|
|
13920
|
+
if (target && (target.kind === "kb" || target.kind === "plugin")) {
|
|
13921
|
+
found.push(target);
|
|
13922
|
+
}
|
|
13923
|
+
}
|
|
13924
|
+
return found;
|
|
13925
|
+
}
|
|
13629
13926
|
|
|
13630
13927
|
// src/application/app/export-app.ts
|
|
13631
13928
|
var POLL_INTERVAL_MS2 = 2e3;
|
|
@@ -13635,7 +13932,22 @@ var TASK_FAILED = 3;
|
|
|
13635
13932
|
var TASK_SCAN = 50;
|
|
13636
13933
|
var NOTICE_GRACE = 8;
|
|
13637
13934
|
async function exportApp(deps, input) {
|
|
13638
|
-
const
|
|
13935
|
+
const described = await deps.packages.describeSummary({ appId: input.appId, releaseId: input.releaseId }).catch(unreleased(input.appId));
|
|
13936
|
+
const chosen = input.scope ?? await input.chooseScope?.(described);
|
|
13937
|
+
const selected = selectAppPackageSummary(described, chosen);
|
|
13938
|
+
const { taskId } = await deps.packages.exportPackage({ appId: input.appId, releaseId: input.releaseId, summary: selected.summary }).catch(unreleased(input.appId));
|
|
13939
|
+
if (!taskId) {
|
|
13940
|
+
throw new DomainError("ExportApp returned no TaskId", "upstream", "AppExportFailed", { retryable: true });
|
|
13941
|
+
}
|
|
13942
|
+
const scopeFields = exportedScope(selected.summary.components, selected.includedByReference);
|
|
13943
|
+
if (!input.wait) {
|
|
13944
|
+
return { appId: input.appId, taskId, status: "submitted", ...scopeFields };
|
|
13945
|
+
}
|
|
13946
|
+
const ready = await fetchAppPackage(deps, { appId: input.appId, taskId, output: input.output });
|
|
13947
|
+
return { ...ready, ...scopeFields };
|
|
13948
|
+
}
|
|
13949
|
+
function unreleased(appId3) {
|
|
13950
|
+
return (error) => {
|
|
13639
13951
|
if (error instanceof DomainError && error.message.includes("450025")) {
|
|
13640
13952
|
throw new DomainError("The app has no release to export", "not_found", "AppNotReleased", {
|
|
13641
13953
|
hint: "Only released apps can be exported; publish the draft first",
|
|
@@ -13643,21 +13955,32 @@ async function exportApp(deps, input) {
|
|
|
13643
13955
|
cause: error,
|
|
13644
13956
|
nextActions: [
|
|
13645
13957
|
{
|
|
13646
|
-
command: `adp versions --app-id ${
|
|
13958
|
+
command: `adp versions --app-id ${appId3} --format json`,
|
|
13647
13959
|
reason: "no release yet: publish the draft (adp deploy from the project, or the console), then export again"
|
|
13648
13960
|
}
|
|
13649
13961
|
]
|
|
13650
13962
|
});
|
|
13651
13963
|
}
|
|
13652
13964
|
throw error;
|
|
13653
|
-
}
|
|
13654
|
-
|
|
13655
|
-
|
|
13656
|
-
|
|
13657
|
-
|
|
13658
|
-
|
|
13659
|
-
|
|
13660
|
-
|
|
13965
|
+
};
|
|
13966
|
+
}
|
|
13967
|
+
function exportedScope(components, includedByReference) {
|
|
13968
|
+
return {
|
|
13969
|
+
components: components.map(exportedComponent),
|
|
13970
|
+
...includedByReference.length > 0 ? {
|
|
13971
|
+
includedByReference: includedByReference.map((component) => ({
|
|
13972
|
+
...exportedComponent(component),
|
|
13973
|
+
requiredBy: component.requiredBy
|
|
13974
|
+
}))
|
|
13975
|
+
} : {}
|
|
13976
|
+
};
|
|
13977
|
+
}
|
|
13978
|
+
function exportedComponent(component) {
|
|
13979
|
+
return {
|
|
13980
|
+
kind: component.kind,
|
|
13981
|
+
id: component.id,
|
|
13982
|
+
...component.name ? { name: component.name } : {}
|
|
13983
|
+
};
|
|
13661
13984
|
}
|
|
13662
13985
|
async function fetchAppPackage(deps, input) {
|
|
13663
13986
|
const sleep = deps.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
@@ -13736,7 +14059,7 @@ var STATUS_IMPORTING = 4;
|
|
|
13736
14059
|
var SINGLE_WORKFLOW_MODE = 3;
|
|
13737
14060
|
function singleWorkflowFollowUp(appId3, spaceId, sourceAppId, entryWorkflowId) {
|
|
13738
14061
|
const warnings = [
|
|
13739
|
-
"This single-workflow (app_mode 3) copy is not runnable yet:
|
|
14062
|
+
"This single-workflow (app_mode 3) copy is not runnable yet: this package includes no workflows, so its entry workflow does not exist (500304). Copy the workflow from the source app and bind it."
|
|
13740
14063
|
];
|
|
13741
14064
|
const copySteps = () => `export the entry workflow with adp workflow export and that ID as --workflow-id, --output ./wf.zip (it also writes the canvas, named after the workflow ID with a _workflow.json suffix, next to the ZIP), import it with adp workflow import --app-id ${appId3} --file ./wf.zip --enable (the result lists the new workflowId), then bind it with adp workflow deploy --app-id ${appId3} --bind --yes, the new workflowId as --workflow-id and that canvas file as --canvas-file`;
|
|
13742
14065
|
if (!sourceAppId) {
|
|
@@ -13779,57 +14102,72 @@ function singleWorkflowFollowUp(appId3, spaceId, sourceAppId, entryWorkflowId) {
|
|
|
13779
14102
|
]
|
|
13780
14103
|
};
|
|
13781
14104
|
}
|
|
13782
|
-
function contentFollowUp(appId3, sourceAppId, sourceWorkflows) {
|
|
14105
|
+
function contentFollowUp(appId3, sourceAppId, sourceWorkflows, seen) {
|
|
14106
|
+
const skipWorkflows = seen?.workflows === true;
|
|
14107
|
+
const skipKnowledge = seen?.knowledgeBases === true;
|
|
14108
|
+
if (skipWorkflows && skipKnowledge) {
|
|
14109
|
+
return {};
|
|
14110
|
+
}
|
|
13783
14111
|
const warnings = [
|
|
13784
|
-
"
|
|
14112
|
+
skipWorkflows ? "No knowledge bases were found in this package: re-import documents the source app uses." : skipKnowledge ? "No workflows were found in this package: copy any workflows the source app uses (workflow export, then workflow import --enable into this app)." : "This package includes no workflows and no knowledge-base documents or QA: copy any workflows the source app uses (workflow export, then workflow import --enable into this app) and re-import its documents."
|
|
13785
14113
|
];
|
|
13786
14114
|
const docs = {
|
|
13787
14115
|
command: `adp kb doc list --kb-id ${sourceAppId ?? appId3} --format json`,
|
|
13788
14116
|
reason: sourceAppId ? `the source app's default knowledge-base documents; re-import each original file into the copy with adp kb doc import --kb-id ${appId3} and --file pointing at that file` : `the copy's default knowledge base (expected empty); re-import each original file with adp kb doc import --kb-id ${appId3} and --file pointing at that file`
|
|
13789
14117
|
};
|
|
14118
|
+
const workflowActions = skipWorkflows ? [] : workflowCopyActions(appId3, sourceAppId, sourceWorkflows);
|
|
14119
|
+
const knowledgeActions = skipKnowledge ? [] : [docs];
|
|
14120
|
+
return { warnings, nextActions: [...workflowActions, ...knowledgeActions] };
|
|
14121
|
+
}
|
|
14122
|
+
function workflowCopyActions(appId3, sourceAppId, sourceWorkflows) {
|
|
13790
14123
|
if (!sourceAppId) {
|
|
13791
|
-
return
|
|
13792
|
-
|
|
13793
|
-
|
|
14124
|
+
return [
|
|
14125
|
+
{
|
|
14126
|
+
command: `adp workflow list --app-id ${appId3} --fields workflowId,name,status --format json`,
|
|
14127
|
+
reason: "the copy's workflows (expected empty); the package does not name its source app, so list that app's workflows, export each with adp workflow export and import it here with adp workflow import --enable"
|
|
14128
|
+
}
|
|
14129
|
+
];
|
|
14130
|
+
}
|
|
14131
|
+
if (sourceWorkflows && sourceWorkflows.length > 0) {
|
|
14132
|
+
return sourceWorkflows.flatMap((workflow) => {
|
|
14133
|
+
const file = `./${zipName(workflow)}.zip`;
|
|
14134
|
+
return [
|
|
13794
14135
|
{
|
|
13795
|
-
command: `adp workflow
|
|
13796
|
-
reason:
|
|
14136
|
+
command: `adp workflow export --app-id ${sourceAppId} --workflow-id ${workflow.workflowId} --output ${file} --format json`,
|
|
14137
|
+
reason: `export source workflow ${workflow.name ?? workflow.workflowId}${workflow.isEnable ? "" : " (disabled in the source app)"}`
|
|
13797
14138
|
},
|
|
13798
|
-
|
|
13799
|
-
|
|
13800
|
-
|
|
14139
|
+
{
|
|
14140
|
+
command: `adp workflow import --app-id ${appId3} --file ${file} --enable --format json`,
|
|
14141
|
+
reason: `import ${workflow.name ?? workflow.workflowId} into the copy and enable it; the next adp deploy publishes it`
|
|
14142
|
+
}
|
|
14143
|
+
];
|
|
14144
|
+
});
|
|
13801
14145
|
}
|
|
13802
|
-
|
|
13803
|
-
|
|
13804
|
-
|
|
13805
|
-
|
|
13806
|
-
|
|
13807
|
-
|
|
13808
|
-
|
|
13809
|
-
|
|
13810
|
-
|
|
13811
|
-
|
|
13812
|
-
|
|
13813
|
-
|
|
13814
|
-
|
|
13815
|
-
|
|
13816
|
-
|
|
13817
|
-
|
|
13818
|
-
|
|
13819
|
-
|
|
13820
|
-
|
|
13821
|
-
|
|
14146
|
+
return [
|
|
14147
|
+
{
|
|
14148
|
+
command: `adp workflow list --app-id ${sourceAppId} --fields workflowId,name,status,isEnable --format json`,
|
|
14149
|
+
reason: `the source app's workflows; export each one this app needs with adp workflow export --app-id ${sourceAppId} and its workflowId, then import the ZIP with adp workflow import --app-id ${appId3} --enable`
|
|
14150
|
+
}
|
|
14151
|
+
];
|
|
14152
|
+
}
|
|
14153
|
+
function importedWorkflowFollowUp(appId3, sourceAppId, hasKnowledgeBases) {
|
|
14154
|
+
const warnings = [
|
|
14155
|
+
"This package includes workflows. If a run returns 500304, the entry workflow is not bound on the copy."
|
|
14156
|
+
];
|
|
14157
|
+
const nextActions = [
|
|
14158
|
+
{
|
|
14159
|
+
command: `adp workflow list --app-id ${appId3} --fields workflowId,name,isEnable --format json`,
|
|
14160
|
+
reason: "imported workflows; bind one as the entry with workflow deploy --bind if a run returns 500304"
|
|
14161
|
+
}
|
|
14162
|
+
];
|
|
14163
|
+
if (!hasKnowledgeBases) {
|
|
14164
|
+
warnings.push("No knowledge bases were found in this package: re-import documents the source app uses.");
|
|
14165
|
+
nextActions.push({
|
|
14166
|
+
command: `adp kb doc list --kb-id ${sourceAppId ?? appId3} --format json`,
|
|
14167
|
+
reason: sourceAppId ? `the source app's default knowledge-base documents; re-import each original file into the copy with adp kb doc import --kb-id ${appId3} and --file pointing at that file` : `the copy's default knowledge base (expected empty); re-import each original file with adp kb doc import --kb-id ${appId3} and --file pointing at that file`
|
|
14168
|
+
});
|
|
13822
14169
|
}
|
|
13823
|
-
return {
|
|
13824
|
-
warnings,
|
|
13825
|
-
nextActions: [
|
|
13826
|
-
{
|
|
13827
|
-
command: `adp workflow list --app-id ${sourceAppId} --fields workflowId,name,status,isEnable --format json`,
|
|
13828
|
-
reason: `the source app's workflows; export each one this app needs with adp workflow export --app-id ${sourceAppId} and its workflowId, then import the ZIP with adp workflow import --app-id ${appId3} --enable`
|
|
13829
|
-
},
|
|
13830
|
-
docs
|
|
13831
|
-
]
|
|
13832
|
-
};
|
|
14170
|
+
return { warnings, nextActions };
|
|
13833
14171
|
}
|
|
13834
14172
|
function zipName(workflow) {
|
|
13835
14173
|
const name = (workflow.name ?? "").replace(/[^\w.-]+/g, "_").replace(/^_+|_+$/g, "");
|
|
@@ -13886,8 +14224,15 @@ async function importApp(deps, input) {
|
|
|
13886
14224
|
await sleep(POLL_INTERVAL_MS3);
|
|
13887
14225
|
const app = pickImported((await recent()).filter((a) => !before.has(a.appId)), taskId);
|
|
13888
14226
|
if (app && app.status !== STATUS_IMPORTING) {
|
|
13889
|
-
const
|
|
13890
|
-
const
|
|
14227
|
+
const inventory = await deps.reader?.inventory?.(input.file).catch(() => void 0);
|
|
14228
|
+
const sourceAppId = inventory?.sourceAppId ?? await deps.reader?.sourceAppId(input.file).catch(() => void 0);
|
|
14229
|
+
const seen = seenContents(inventory);
|
|
14230
|
+
const followUp = app.appMode === SINGLE_WORKFLOW_MODE ? seen?.workflows ? importedWorkflowFollowUp(app.appId, sourceAppId, seen.knowledgeBases) : singleWorkflowFollowUp(app.appId, input.spaceId, sourceAppId, await readEntryWorkflow(deps.apps, sourceAppId)) : contentFollowUp(
|
|
14231
|
+
app.appId,
|
|
14232
|
+
sourceAppId,
|
|
14233
|
+
seen?.workflows ? void 0 : await listSourceWorkflows(deps.workflows, sourceAppId),
|
|
14234
|
+
seen
|
|
14235
|
+
);
|
|
13891
14236
|
return {
|
|
13892
14237
|
...base,
|
|
13893
14238
|
status: "imported",
|
|
@@ -13896,7 +14241,7 @@ async function importApp(deps, input) {
|
|
|
13896
14241
|
appMode: app.appMode,
|
|
13897
14242
|
appStatus: app.status,
|
|
13898
14243
|
...sourceAppId ? { sourceAppId } : {},
|
|
13899
|
-
warnings: followUp.warnings,
|
|
14244
|
+
...followUp.warnings ? { warnings: followUp.warnings } : {},
|
|
13900
14245
|
nextActions: [
|
|
13901
14246
|
...followUp.nextActions ?? [],
|
|
13902
14247
|
{
|
|
@@ -13912,6 +14257,12 @@ async function importApp(deps, input) {
|
|
|
13912
14257
|
retryable: true
|
|
13913
14258
|
});
|
|
13914
14259
|
}
|
|
14260
|
+
function seenContents(inventory) {
|
|
14261
|
+
if (!inventory?.readable) {
|
|
14262
|
+
return void 0;
|
|
14263
|
+
}
|
|
14264
|
+
return { workflows: inventory.workflowIds.length > 0, knowledgeBases: inventory.hasKnowledgeBases };
|
|
14265
|
+
}
|
|
13915
14266
|
function pickImported(fresh, taskId) {
|
|
13916
14267
|
const expected = /^\d+$/.test(taskId) ? (BigInt(taskId) + 1n).toString() : void 0;
|
|
13917
14268
|
return fresh.find((app) => app.appId === expected) ?? (fresh.length === 1 ? fresh[0] : void 0);
|
|
@@ -13978,6 +14329,250 @@ async function resolveAppId(ctx, args, why) {
|
|
|
13978
14329
|
return appId3;
|
|
13979
14330
|
}
|
|
13980
14331
|
|
|
14332
|
+
// src/interfaces/cli/commands/app/export-scope.ts
|
|
14333
|
+
var KINDS = ["kb", "workflow", "agent", "plugin", "skill"];
|
|
14334
|
+
var KIND_ALIASES = {
|
|
14335
|
+
kb: "kb",
|
|
14336
|
+
knowledge: "kb",
|
|
14337
|
+
"knowledge-base": "kb",
|
|
14338
|
+
knowledgebase: "kb",
|
|
14339
|
+
workflow: "workflow",
|
|
14340
|
+
workflows: "workflow",
|
|
14341
|
+
agent: "agent",
|
|
14342
|
+
agents: "agent",
|
|
14343
|
+
plugin: "plugin",
|
|
14344
|
+
plugins: "plugin",
|
|
14345
|
+
connector: "plugin",
|
|
14346
|
+
connectors: "plugin",
|
|
14347
|
+
tool: "plugin",
|
|
14348
|
+
tools: "plugin",
|
|
14349
|
+
skill: "skill",
|
|
14350
|
+
skills: "skill"
|
|
14351
|
+
};
|
|
14352
|
+
var SETTINGS = /* @__PURE__ */ new Set(["config", "settings", "app", "app-settings"]);
|
|
14353
|
+
var KIND_LABEL = {
|
|
14354
|
+
kb: "knowledge bases",
|
|
14355
|
+
workflow: "workflows",
|
|
14356
|
+
agent: "agents",
|
|
14357
|
+
plugin: "connectors and tools",
|
|
14358
|
+
skill: "skills"
|
|
14359
|
+
};
|
|
14360
|
+
var PROMPT_ORDER = ["workflow", "plugin", "kb", "agent", "skill"];
|
|
14361
|
+
var EXPORT_SCOPE_FLAGS = [
|
|
14362
|
+
{
|
|
14363
|
+
name: "include",
|
|
14364
|
+
type: "string",
|
|
14365
|
+
list: true,
|
|
14366
|
+
describe: "Component kinds to export: kb, workflow, agent, plugin, skill (comma-separated or repeatable). App settings are always included"
|
|
14367
|
+
},
|
|
14368
|
+
{
|
|
14369
|
+
name: "exclude",
|
|
14370
|
+
type: "string",
|
|
14371
|
+
list: true,
|
|
14372
|
+
describe: "Component kinds to leave out. A selected workflow still exports the connectors and knowledge bases it references"
|
|
14373
|
+
},
|
|
14374
|
+
{
|
|
14375
|
+
name: "component-id",
|
|
14376
|
+
type: "string",
|
|
14377
|
+
list: true,
|
|
14378
|
+
describe: "Export only these component ids (repeatable or comma-separated), plus connectors and knowledge bases a selected workflow references"
|
|
14379
|
+
},
|
|
14380
|
+
{
|
|
14381
|
+
name: "kb",
|
|
14382
|
+
type: "boolean",
|
|
14383
|
+
default: true,
|
|
14384
|
+
describe: "Include knowledge bases (--no-kb omits ones no selected workflow references)"
|
|
14385
|
+
},
|
|
14386
|
+
{
|
|
14387
|
+
name: "workflow",
|
|
14388
|
+
type: "boolean",
|
|
14389
|
+
default: true,
|
|
14390
|
+
describe: "Include workflows (--no-workflow leaves them out)"
|
|
14391
|
+
},
|
|
14392
|
+
{
|
|
14393
|
+
name: "agent",
|
|
14394
|
+
type: "boolean",
|
|
14395
|
+
default: true,
|
|
14396
|
+
describe: "Include agents (--no-agent leaves them out)"
|
|
14397
|
+
},
|
|
14398
|
+
{
|
|
14399
|
+
name: "plugin",
|
|
14400
|
+
type: "boolean",
|
|
14401
|
+
default: true,
|
|
14402
|
+
describe: "Include connectors and tools (--no-plugin omits ones no selected workflow references)"
|
|
14403
|
+
},
|
|
14404
|
+
{
|
|
14405
|
+
name: "skill",
|
|
14406
|
+
type: "boolean",
|
|
14407
|
+
default: true,
|
|
14408
|
+
describe: "Include skills (--no-skill leaves them out)"
|
|
14409
|
+
}
|
|
14410
|
+
];
|
|
14411
|
+
function exportScopeFromArgs(args) {
|
|
14412
|
+
const includeTokens = stringList(args.include);
|
|
14413
|
+
const excludeTokens = stringList(args.exclude);
|
|
14414
|
+
const componentIds = stringList(args["component-id"]);
|
|
14415
|
+
const negated = KINDS.filter((kind2) => args[kind2] === false);
|
|
14416
|
+
if (includeTokens.length === 0 && excludeTokens.length === 0 && componentIds.length === 0 && negated.length === 0) {
|
|
14417
|
+
return void 0;
|
|
14418
|
+
}
|
|
14419
|
+
const included = parseKindList(includeTokens, "include");
|
|
14420
|
+
const excluded = parseKindList(excludeTokens, "exclude");
|
|
14421
|
+
if (excluded.settingsOnly) {
|
|
14422
|
+
throw usageError("App settings are always exported", "Use --exclude with kb, workflow, agent, plugin, or skill");
|
|
14423
|
+
}
|
|
14424
|
+
const excludeKinds = unique([...excluded.kinds, ...negated]);
|
|
14425
|
+
const overlap = included.kinds.filter((kind2) => excludeKinds.includes(kind2));
|
|
14426
|
+
if (overlap.length > 0) {
|
|
14427
|
+
throw usageError(`--include and --exclude both list ${overlap.join(", ")}`, "Name each component kind only once");
|
|
14428
|
+
}
|
|
14429
|
+
const scope = {};
|
|
14430
|
+
if (included.settingsOnly) {
|
|
14431
|
+
scope.includeKinds = [];
|
|
14432
|
+
} else if (included.kinds.length > 0) {
|
|
14433
|
+
scope.includeKinds = included.kinds;
|
|
14434
|
+
}
|
|
14435
|
+
if (excludeKinds.length > 0) {
|
|
14436
|
+
scope.excludeKinds = excludeKinds;
|
|
14437
|
+
}
|
|
14438
|
+
if (componentIds.length > 0) {
|
|
14439
|
+
scope.includeIds = componentIds;
|
|
14440
|
+
}
|
|
14441
|
+
return scope;
|
|
14442
|
+
}
|
|
14443
|
+
async function promptExportScope(prompter, summary) {
|
|
14444
|
+
const present = PROMPT_ORDER.filter((kind2) => summary.components.some((component) => component.kind === kind2));
|
|
14445
|
+
if (present.length === 0) {
|
|
14446
|
+
return void 0;
|
|
14447
|
+
}
|
|
14448
|
+
const choice = await prompter.choice({
|
|
14449
|
+
question: "What should this package include? App settings are always exported.",
|
|
14450
|
+
prompt: "Scope",
|
|
14451
|
+
defaultValue: "all",
|
|
14452
|
+
options: [
|
|
14453
|
+
{ value: "all", title: "All components", description: describeCounts(summary), aliases: ["all"] },
|
|
14454
|
+
{
|
|
14455
|
+
value: "settings",
|
|
14456
|
+
title: "App settings only",
|
|
14457
|
+
description: "No workflows, connectors, knowledge bases, agents, or skills",
|
|
14458
|
+
aliases: ["settings", "config"]
|
|
14459
|
+
},
|
|
14460
|
+
{ value: "custom", title: "Choose component types", description: "Workflows pull in the connectors and knowledge bases they reference", aliases: ["choose"] }
|
|
14461
|
+
]
|
|
14462
|
+
});
|
|
14463
|
+
if (choice === "all") {
|
|
14464
|
+
return void 0;
|
|
14465
|
+
}
|
|
14466
|
+
if (choice === "settings") {
|
|
14467
|
+
return { includeKinds: [] };
|
|
14468
|
+
}
|
|
14469
|
+
const includeKinds = [];
|
|
14470
|
+
const includeIds = [];
|
|
14471
|
+
for (const kind2 of present) {
|
|
14472
|
+
const items = summary.components.filter((component) => component.kind === kind2);
|
|
14473
|
+
const accepted = await prompter.confirm(kindQuestion(kind2, items), true);
|
|
14474
|
+
if (!accepted) {
|
|
14475
|
+
continue;
|
|
14476
|
+
}
|
|
14477
|
+
includeKinds.push(kind2);
|
|
14478
|
+
const chosen = await chooseComponents(prompter, kind2, items);
|
|
14479
|
+
includeIds.push(...chosen);
|
|
14480
|
+
}
|
|
14481
|
+
if (includeKinds.length === 0 || includeIds.length === 0) {
|
|
14482
|
+
return { includeKinds: [] };
|
|
14483
|
+
}
|
|
14484
|
+
return { includeKinds, includeIds };
|
|
14485
|
+
}
|
|
14486
|
+
async function chooseComponents(prompter, kind2, items) {
|
|
14487
|
+
if (items.length <= 1) {
|
|
14488
|
+
return items.map((item) => item.id);
|
|
14489
|
+
}
|
|
14490
|
+
const how = await prompter.choice({
|
|
14491
|
+
question: `Which ${KIND_LABEL[kind2]} should be included?`,
|
|
14492
|
+
prompt: KIND_LABEL[kind2],
|
|
14493
|
+
defaultValue: "all",
|
|
14494
|
+
options: [
|
|
14495
|
+
{ value: "all", title: "All of them", description: `${items.length} ${KIND_LABEL[kind2]}` },
|
|
14496
|
+
{ value: "pick", title: "Choose which ones", aliases: ["choose"] }
|
|
14497
|
+
]
|
|
14498
|
+
});
|
|
14499
|
+
if (how === "all") {
|
|
14500
|
+
return items.map((item) => item.id);
|
|
14501
|
+
}
|
|
14502
|
+
const picked = [];
|
|
14503
|
+
for (const item of items) {
|
|
14504
|
+
const yes = await prompter.confirm(`Include ${KIND_LABEL[kind2]} ${item.name ?? item.id} (${item.id})?`, true);
|
|
14505
|
+
if (yes) {
|
|
14506
|
+
picked.push(item.id);
|
|
14507
|
+
}
|
|
14508
|
+
}
|
|
14509
|
+
return picked;
|
|
14510
|
+
}
|
|
14511
|
+
function exportMessage(appId3, result) {
|
|
14512
|
+
const scopeText = formatExported(result);
|
|
14513
|
+
if (result.status === "submitted") {
|
|
14514
|
+
return `Export of app ${appId3} submitted (task ${result.taskId}); ${scopeText}. The package will appear as a console notice.`;
|
|
14515
|
+
}
|
|
14516
|
+
if (result.output) {
|
|
14517
|
+
return `Exported app ${appId3} to ${result.output} (${result.bytes} bytes); ${scopeText}.`;
|
|
14518
|
+
}
|
|
14519
|
+
return `Exported app ${appId3}; ${scopeText}. downloadUrl is valid for about 30 minutes.`;
|
|
14520
|
+
}
|
|
14521
|
+
function formatExported(result) {
|
|
14522
|
+
const components = result.components ?? [];
|
|
14523
|
+
if (components.length === 0) {
|
|
14524
|
+
return "app settings only";
|
|
14525
|
+
}
|
|
14526
|
+
const parts = PROMPT_ORDER.map((kind2) => {
|
|
14527
|
+
const count = components.filter((component) => component.kind === kind2).length;
|
|
14528
|
+
return count > 0 ? `${count} ${KIND_LABEL[kind2]}` : void 0;
|
|
14529
|
+
}).filter((part) => part !== void 0);
|
|
14530
|
+
const pulled = result.includedByReference ?? [];
|
|
14531
|
+
const extra = pulled.length > 0 ? `; also included ${pulled.map((component) => component.name ?? component.id).join(", ")} because a selected workflow references them` : "";
|
|
14532
|
+
return `includes ${parts.join(", ")}${extra}`;
|
|
14533
|
+
}
|
|
14534
|
+
function kindQuestion(kind2, items) {
|
|
14535
|
+
const sample = items.slice(0, 3).map((item) => item.name ?? item.id).join(", ");
|
|
14536
|
+
const extra = items.length > 3 ? `, +${items.length - 3}` : "";
|
|
14537
|
+
const note = kind2 === "kb" || kind2 === "plugin" ? " Ones a selected workflow references are included either way." : "";
|
|
14538
|
+
return `Include ${items.length} ${KIND_LABEL[kind2]}${sample ? ` (${sample}${extra})` : ""}?${note}`;
|
|
14539
|
+
}
|
|
14540
|
+
function describeCounts(summary) {
|
|
14541
|
+
const parts = PROMPT_ORDER.map((kind2) => {
|
|
14542
|
+
const count = summary.components.filter((component) => component.kind === kind2).length;
|
|
14543
|
+
return count > 0 ? `${count} ${KIND_LABEL[kind2]}` : void 0;
|
|
14544
|
+
}).filter((part) => part !== void 0);
|
|
14545
|
+
return parts.join(", ");
|
|
14546
|
+
}
|
|
14547
|
+
function parseKindList(tokens, flag) {
|
|
14548
|
+
const kinds = [];
|
|
14549
|
+
let settings = false;
|
|
14550
|
+
for (const token of tokens) {
|
|
14551
|
+
const normalized = token.trim().toLowerCase();
|
|
14552
|
+
if (SETTINGS.has(normalized)) {
|
|
14553
|
+
settings = true;
|
|
14554
|
+
continue;
|
|
14555
|
+
}
|
|
14556
|
+
const kind2 = KIND_ALIASES[normalized];
|
|
14557
|
+
if (!kind2) {
|
|
14558
|
+
throw usageError(
|
|
14559
|
+
`--${flag} has unknown component kind ${token}`,
|
|
14560
|
+
"Use kb, workflow, agent, plugin, skill, or config for app settings only"
|
|
14561
|
+
);
|
|
14562
|
+
}
|
|
14563
|
+
kinds.push(kind2);
|
|
14564
|
+
}
|
|
14565
|
+
const uniqueKinds = unique(kinds);
|
|
14566
|
+
return { kinds: uniqueKinds, settingsOnly: settings && uniqueKinds.length === 0 };
|
|
14567
|
+
}
|
|
14568
|
+
function stringList(value) {
|
|
14569
|
+
const raw = Array.isArray(value) ? value : value === void 0 || value === false || value === true || value === null ? [] : [value];
|
|
14570
|
+
return raw.filter((item) => item !== void 0 && item !== null).flatMap((item) => String(item).split(",")).map((item) => item.trim()).filter((item) => item.length > 0);
|
|
14571
|
+
}
|
|
14572
|
+
function unique(values) {
|
|
14573
|
+
return [...new Set(values)];
|
|
14574
|
+
}
|
|
14575
|
+
|
|
13981
14576
|
// src/interfaces/cli/commands/app/package.ts
|
|
13982
14577
|
var appIdFlag = { name: "app-id", type: "string", describe: "App ID (default: adp.jsonc app_id)" };
|
|
13983
14578
|
var taskIdFlag = { name: "task-id", type: "string", describe: "Package task ID", required: true };
|
|
@@ -14771,7 +15366,7 @@ warning: ${result.warnings.join("\nwarning: ")}` : ""}`;
|
|
|
14771
15366
|
registry.define(
|
|
14772
15367
|
createCommand({
|
|
14773
15368
|
command: "app export",
|
|
14774
|
-
describe: "Export a released app as a package ZIP
|
|
15369
|
+
describe: "Export a released app as a package ZIP, including workflows, connectors, knowledge bases, agents, and skills by default",
|
|
14775
15370
|
effects: "idempotent",
|
|
14776
15371
|
outputKind: "data",
|
|
14777
15372
|
flags: [
|
|
@@ -14783,26 +15378,33 @@ warning: ${result.warnings.join("\nwarning: ")}` : ""}`;
|
|
|
14783
15378
|
type: "boolean",
|
|
14784
15379
|
describe: "Wait for the package (--no-wait only submits and returns the task ID)",
|
|
14785
15380
|
default: true
|
|
14786
|
-
}
|
|
15381
|
+
},
|
|
15382
|
+
...EXPORT_SCOPE_FLAGS
|
|
14787
15383
|
],
|
|
14788
15384
|
examples: [
|
|
14789
15385
|
"adp app export --app-id app-1 --output ./app-1.zip",
|
|
14790
|
-
"adp app export --app-id app-1 --format json",
|
|
15386
|
+
"adp app export --app-id app-1 --include workflow,kb --format json",
|
|
15387
|
+
"adp app export --app-id app-1 --no-skill --format json",
|
|
14791
15388
|
"adp app export --app-id app-1 --dry-run"
|
|
14792
15389
|
],
|
|
14793
15390
|
async handler(args) {
|
|
14794
15391
|
const appId3 = assertResourceId(await resolveAppId(ctx, args, "app export packages one app"), "app-id");
|
|
14795
15392
|
const releaseId = typeof args["release-id"] === "string" ? assertResourceId(args["release-id"], "release-id") : void 0;
|
|
15393
|
+
const scope = exportScopeFromArgs(args);
|
|
14796
15394
|
if (ctx.flags.dryRun) {
|
|
14797
|
-
return {
|
|
15395
|
+
return {
|
|
15396
|
+
result: { dryRun: true, appId: appId3, releaseId, ...scope ? { scope } : {} },
|
|
15397
|
+
message: scope ? `Would export app ${appId3} with the selected components.` : `Would export app ${appId3}.`
|
|
15398
|
+
};
|
|
14798
15399
|
}
|
|
14799
15400
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
14800
15401
|
const output = typeof args.output === "string" ? canonicalizeLocalPath(args.output, ctx.flags.cwd) : void 0;
|
|
15402
|
+
const chooseScope = !scope && canPrompt(ctx.deps) && !ctx.flags.yes ? (summary) => promptExportScope(ctx.deps.prompter, summary) : void 0;
|
|
14801
15403
|
const result = await exportApp(
|
|
14802
15404
|
{ packages: gateways.appPackage, downloader: gateways.packageDownloader },
|
|
14803
|
-
{ appId: appId3, releaseId, output, wait: args.wait !== false }
|
|
15405
|
+
{ appId: appId3, releaseId, output, wait: args.wait !== false, scope, chooseScope }
|
|
14804
15406
|
);
|
|
14805
|
-
const message =
|
|
15407
|
+
const message = exportMessage(appId3, result);
|
|
14806
15408
|
return { result, message };
|
|
14807
15409
|
}
|
|
14808
15410
|
})
|
|
@@ -15164,13 +15766,13 @@ async function toolRef(ctx, args) {
|
|
|
15164
15766
|
};
|
|
15165
15767
|
}
|
|
15166
15768
|
function parseSince(raw) {
|
|
15167
|
-
const
|
|
15168
|
-
if (/^\d+$/.test(
|
|
15169
|
-
return Number(
|
|
15769
|
+
const text13 = String(raw ?? "");
|
|
15770
|
+
if (/^\d+$/.test(text13)) {
|
|
15771
|
+
return Number(text13);
|
|
15170
15772
|
}
|
|
15171
|
-
const ms = Date.parse(
|
|
15773
|
+
const ms = Date.parse(text13);
|
|
15172
15774
|
if (Number.isNaN(ms)) {
|
|
15173
|
-
throw usageError(`Invalid --since ${
|
|
15775
|
+
throw usageError(`Invalid --since ${text13}`, "Use Unix seconds or an ISO date such as 2026-10-01T00:00:00Z");
|
|
15174
15776
|
}
|
|
15175
15777
|
return Math.floor(ms / 1e3);
|
|
15176
15778
|
}
|
|
@@ -15439,7 +16041,7 @@ function followUpAction(conversationId, type, message) {
|
|
|
15439
16041
|
reason: `adp chat cannot write into a type ${type} conversation; read its messages instead`
|
|
15440
16042
|
};
|
|
15441
16043
|
}
|
|
15442
|
-
function
|
|
16044
|
+
function text3(args, name) {
|
|
15443
16045
|
const value = typeof args[name] === "string" ? args[name].trim() : "";
|
|
15444
16046
|
if (!value) {
|
|
15445
16047
|
throw usageError(`--${name} must not be empty`);
|
|
@@ -15494,7 +16096,7 @@ function registerConversationOpsCommands(registry, ctx) {
|
|
|
15494
16096
|
flags: [appIdFlag4, ...conversationFlags, { name: "title", type: "string", describe: "New title", required: true }],
|
|
15495
16097
|
examples: ['adp conversation rename --conversation-id c-1 --title "\u9000\u6B3E\u54A8\u8BE2" --format json'],
|
|
15496
16098
|
async handler(args) {
|
|
15497
|
-
const ref3 = { appId: await resolveAppId(ctx, args, WHY_APP3), ...conversationRef(args), title:
|
|
16099
|
+
const ref3 = { appId: await resolveAppId(ctx, args, WHY_APP3), ...conversationRef(args), title: text3(args, "title") };
|
|
15498
16100
|
if (ctx.flags.dryRun) {
|
|
15499
16101
|
return { result: { dryRun: true, ...ref3 }, message: `Would rename ${ref3.conversationId}.` };
|
|
15500
16102
|
}
|
|
@@ -15613,7 +16215,7 @@ function registerConversationOpsCommands(registry, ctx) {
|
|
|
15613
16215
|
examples: ['adp conversation category create --app-id app-1 --name "\u552E\u540E" --format json'],
|
|
15614
16216
|
async handler(args) {
|
|
15615
16217
|
const appId3 = await resolveAppId(ctx, args, WHY_APP3);
|
|
15616
|
-
const name =
|
|
16218
|
+
const name = text3(args, "name");
|
|
15617
16219
|
const parentId = typeof args["parent-id"] === "string" ? assertResourceId(args["parent-id"], "parent-id") : void 0;
|
|
15618
16220
|
if (ctx.flags.dryRun) {
|
|
15619
16221
|
return { result: { dryRun: true, appId: appId3, name, parentId }, message: `Would create category ${name}.` };
|
|
@@ -15633,7 +16235,7 @@ function registerConversationOpsCommands(registry, ctx) {
|
|
|
15633
16235
|
examples: ['adp conversation category update --category-id 12 --name "\u552E\u540E\u670D\u52A1" --format json'],
|
|
15634
16236
|
async handler(args) {
|
|
15635
16237
|
const appId3 = await resolveAppId(ctx, args, WHY_APP3);
|
|
15636
|
-
const input = { appId: appId3, categoryId: assertResourceId(String(args["category-id"]), "category-id"), name:
|
|
16238
|
+
const input = { appId: appId3, categoryId: assertResourceId(String(args["category-id"]), "category-id"), name: text3(args, "name") };
|
|
15637
16239
|
if (ctx.flags.dryRun) {
|
|
15638
16240
|
return { result: { dryRun: true, ...input }, message: `Would rename category ${input.categoryId}.` };
|
|
15639
16241
|
}
|
|
@@ -15763,7 +16365,7 @@ async function describeCredentialAccess(gateway, input) {
|
|
|
15763
16365
|
|
|
15764
16366
|
// src/interfaces/cli/commands/references.ts
|
|
15765
16367
|
var appIdFlag5 = { name: "app-id", type: "string", describe: "App ID (defaults to adp.jsonc)" };
|
|
15766
|
-
function
|
|
16368
|
+
function idList2(args, name, max) {
|
|
15767
16369
|
const raw = args[name];
|
|
15768
16370
|
const values = (Array.isArray(raw) ? raw : [raw]).map(String).filter((value) => value.trim() !== "" && value !== "undefined");
|
|
15769
16371
|
if (values.length === 0 || values.length > max) {
|
|
@@ -15813,7 +16415,7 @@ function registerReferenceCommands(registry, ctx) {
|
|
|
15813
16415
|
const input = {
|
|
15814
16416
|
appId: await resolveAppId(ctx, args, "Trigger runs belong to one app"),
|
|
15815
16417
|
triggerId: assertResourceId(String(args["trigger-id"]), "trigger-id"),
|
|
15816
|
-
instanceIds:
|
|
16418
|
+
instanceIds: idList2(args, "instance-id", 100)
|
|
15817
16419
|
};
|
|
15818
16420
|
if (ctx.flags.dryRun) {
|
|
15819
16421
|
return { result: { dryRun: true, ...input }, message: `Would mark ${input.instanceIds.length} run(s) read.` };
|
|
@@ -15836,7 +16438,7 @@ function registerReferenceCommands(registry, ctx) {
|
|
|
15836
16438
|
examples: ["adp kb doc referrers --kb-id kb-1 --doc-id doc-1 --doc-id doc-2 --format json"],
|
|
15837
16439
|
async handler(args) {
|
|
15838
16440
|
const kbId = assertResourceId(String(args["kb-id"]), "kb-id");
|
|
15839
|
-
const items = await listDocReferrers((await gateways()).knowledgeReferrer, { kbId, docIds:
|
|
16441
|
+
const items = await listDocReferrers((await gateways()).knowledgeReferrer, { kbId, docIds: idList2(args, "doc-id", 50) });
|
|
15840
16442
|
return { result: { kbId, items } };
|
|
15841
16443
|
}
|
|
15842
16444
|
})
|
|
@@ -16074,14 +16676,14 @@ function instant(raw, name, endOfDay) {
|
|
|
16074
16676
|
if (raw === void 0 || raw === "") {
|
|
16075
16677
|
return void 0;
|
|
16076
16678
|
}
|
|
16077
|
-
const
|
|
16078
|
-
if (/^\d+$/.test(
|
|
16079
|
-
return Number(
|
|
16679
|
+
const text13 = String(raw);
|
|
16680
|
+
if (/^\d+$/.test(text13)) {
|
|
16681
|
+
return Number(text13);
|
|
16080
16682
|
}
|
|
16081
|
-
const iso = /^\d{4}-\d{2}-\d{2}$/.test(
|
|
16683
|
+
const iso = /^\d{4}-\d{2}-\d{2}$/.test(text13) ? `${text13}T${endOfDay ? "23:59:59" : "00:00:00"}+08:00` : text13;
|
|
16082
16684
|
const ms = Date.parse(iso);
|
|
16083
16685
|
if (Number.isNaN(ms)) {
|
|
16084
|
-
throw usageError(`Invalid --${name} ${
|
|
16686
|
+
throw usageError(`Invalid --${name} ${text13}`, "Use YYYY-MM-DD, an ISO time, or Unix seconds");
|
|
16085
16687
|
}
|
|
16086
16688
|
return Math.floor(ms / 1e3);
|
|
16087
16689
|
}
|
|
@@ -16240,20 +16842,20 @@ function registerOpsCommands(registry, ctx) {
|
|
|
16240
16842
|
"Run adp audit list without --page; when more rows exist its next action passes the returned --cursor"
|
|
16241
16843
|
);
|
|
16242
16844
|
}
|
|
16243
|
-
const
|
|
16244
|
-
const cursorText =
|
|
16845
|
+
const text13 = (name) => typeof args[name] === "string" && args[name] ? String(args[name]) : void 0;
|
|
16846
|
+
const cursorText = text13("cursor");
|
|
16245
16847
|
const result = await auditLogs((await gateways()).admin, {
|
|
16246
|
-
spaceId:
|
|
16848
|
+
spaceId: text13("space-id") ? assertResourceId(text13("space-id"), "space-id") : void 0,
|
|
16247
16849
|
limit: Math.min(ctx.flags.limit, 100),
|
|
16248
16850
|
cursor: cursorText ? cursorText.split(",") : void 0,
|
|
16249
|
-
filter: { action:
|
|
16851
|
+
filter: { action: text13("action"), bizObject: text13("biz"), accountUin: text13("account-uin") }
|
|
16250
16852
|
});
|
|
16251
16853
|
const cursor = result.cursor?.join(",");
|
|
16252
16854
|
const carried = [
|
|
16253
|
-
["space-id",
|
|
16254
|
-
["action",
|
|
16255
|
-
["biz",
|
|
16256
|
-
["account-uin",
|
|
16855
|
+
["space-id", text13("space-id")],
|
|
16856
|
+
["action", text13("action")],
|
|
16857
|
+
["biz", text13("biz")],
|
|
16858
|
+
["account-uin", text13("account-uin")]
|
|
16257
16859
|
].filter((pair) => pair[1] !== void 0).map(([flag, value]) => ` --${flag} ${value}`).join("");
|
|
16258
16860
|
return {
|
|
16259
16861
|
result: { total: result.total, items: result.items, cursor, truncated: result.truncated },
|
|
@@ -16916,8 +17518,8 @@ function expandEnv(value, sourcePath, env) {
|
|
|
16916
17518
|
return resolved2;
|
|
16917
17519
|
});
|
|
16918
17520
|
}
|
|
16919
|
-
function parsePluginSpec(
|
|
16920
|
-
const result = pluginSpecFileSchema.safeParse(parseJsonc2(
|
|
17521
|
+
function parsePluginSpec(text13, sourcePath, env = process.env) {
|
|
17522
|
+
const result = pluginSpecFileSchema.safeParse(parseJsonc2(text13));
|
|
16921
17523
|
if (!result.success) {
|
|
16922
17524
|
throw usageError(
|
|
16923
17525
|
`Invalid plugin spec ${sourcePath}: ${result.error.issues.map(describeIssue).join("; ")}`,
|
|
@@ -16943,16 +17545,16 @@ function parsePluginSpec(text12, sourcePath, env = process.env) {
|
|
|
16943
17545
|
}
|
|
16944
17546
|
async function loadPluginSpec(cwd, relativePath) {
|
|
16945
17547
|
const resolved2 = path13.resolve(cwd, relativePath);
|
|
16946
|
-
let
|
|
17548
|
+
let text13;
|
|
16947
17549
|
try {
|
|
16948
|
-
|
|
17550
|
+
text13 = await readFile11(resolved2, "utf8");
|
|
16949
17551
|
} catch {
|
|
16950
17552
|
throw usageError(
|
|
16951
17553
|
`Plugin spec not found: ${resolved2}`,
|
|
16952
17554
|
"Pass --from-config path/to/plugin.jsonc"
|
|
16953
17555
|
);
|
|
16954
17556
|
}
|
|
16955
|
-
return parsePluginSpec(
|
|
17557
|
+
return parsePluginSpec(text13, resolved2);
|
|
16956
17558
|
}
|
|
16957
17559
|
|
|
16958
17560
|
// src/interfaces/cli/commands/plugin/index.ts
|
|
@@ -18128,11 +18730,11 @@ async function discoverCompanionSkills(pack, input) {
|
|
|
18128
18730
|
hint: detectedAgents.length === 0 ? `No coding agents detected here. Pass --agent with one or more of: ${AGENT_KINDS.join(", ")}.` : pending.length === 0 && installed.length > 0 ? "Ready. No CLI action needed; ask your coding agent to use adp." : void 0
|
|
18129
18731
|
};
|
|
18130
18732
|
}
|
|
18131
|
-
function truncate(
|
|
18132
|
-
if (
|
|
18133
|
-
return
|
|
18733
|
+
function truncate(text13, max) {
|
|
18734
|
+
if (text13.length <= max) {
|
|
18735
|
+
return text13;
|
|
18134
18736
|
}
|
|
18135
|
-
return `${
|
|
18737
|
+
return `${text13.slice(0, max - 1).trimEnd()}\u2026`;
|
|
18136
18738
|
}
|
|
18137
18739
|
async function readDescription(pack, skillId) {
|
|
18138
18740
|
try {
|
|
@@ -19345,12 +19947,12 @@ function parseCsv(value, name) {
|
|
|
19345
19947
|
return items;
|
|
19346
19948
|
}
|
|
19347
19949
|
function parseSpecJson(raw) {
|
|
19348
|
-
const
|
|
19349
|
-
if (!
|
|
19950
|
+
const text13 = optionalString14(raw);
|
|
19951
|
+
if (!text13) {
|
|
19350
19952
|
return void 0;
|
|
19351
19953
|
}
|
|
19352
19954
|
try {
|
|
19353
|
-
const parsed = JSON.parse(
|
|
19955
|
+
const parsed = JSON.parse(text13);
|
|
19354
19956
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
19355
19957
|
throw new Error("not an object");
|
|
19356
19958
|
}
|
|
@@ -21810,8 +22412,8 @@ function prepareCanvas(input) {
|
|
|
21810
22412
|
const ids4 = /* @__PURE__ */ new Set();
|
|
21811
22413
|
const names2 = /* @__PURE__ */ new Map();
|
|
21812
22414
|
for (const node of nodes) {
|
|
21813
|
-
const id =
|
|
21814
|
-
const type =
|
|
22415
|
+
const id = text4(node.NodeID);
|
|
22416
|
+
const type = text4(node.NodeType);
|
|
21815
22417
|
if (!NODE_ID.test(id)) {
|
|
21816
22418
|
problems.push(`NodeID "${id}" must match ${NODE_ID.source}`);
|
|
21817
22419
|
}
|
|
@@ -21824,7 +22426,7 @@ function prepareCanvas(input) {
|
|
|
21824
22426
|
`node ${id}: NodeType "${type}" is not a workflow node type` + (type === "REPLY" ? " (the reply node is ANSWER)" : "")
|
|
21825
22427
|
);
|
|
21826
22428
|
}
|
|
21827
|
-
const name =
|
|
22429
|
+
const name = text4(node.NodeName);
|
|
21828
22430
|
if (name) {
|
|
21829
22431
|
const other = names2.get(name);
|
|
21830
22432
|
if (other !== void 0) {
|
|
@@ -21845,20 +22447,20 @@ function prepareCanvas(input) {
|
|
|
21845
22447
|
}
|
|
21846
22448
|
const branchUi = /* @__PURE__ */ new Map();
|
|
21847
22449
|
for (const node of nodes) {
|
|
21848
|
-
if (BRANCH_TYPES.has(
|
|
21849
|
-
branchUi.set(
|
|
22450
|
+
if (BRANCH_TYPES.has(text4(node.NodeType))) {
|
|
22451
|
+
branchUi.set(text4(node.NodeID), prepareBranch(node, fixes, problems));
|
|
21850
22452
|
}
|
|
21851
22453
|
}
|
|
21852
22454
|
const successors = /* @__PURE__ */ new Map();
|
|
21853
22455
|
for (const node of nodes) {
|
|
21854
|
-
const id =
|
|
22456
|
+
const id = text4(node.NodeID);
|
|
21855
22457
|
const targets = [...strings8(node.NextNodeIDs), ...branchTargets(node), ...failTargets(node)];
|
|
21856
22458
|
for (const target of targets) {
|
|
21857
22459
|
if (!ids4.has(target)) {
|
|
21858
22460
|
problems.push(`node ${id}: next node "${target}" does not exist`);
|
|
21859
22461
|
}
|
|
21860
22462
|
}
|
|
21861
|
-
successors.set(id,
|
|
22463
|
+
successors.set(id, unique2(targets.filter((target) => ids4.has(target))));
|
|
21862
22464
|
}
|
|
21863
22465
|
const edges = readEdges(canvas.Edge, problems).filter((edge) => {
|
|
21864
22466
|
const keep = ids4.has(edge.source) && ids4.has(edge.target);
|
|
@@ -21868,13 +22470,13 @@ function prepareCanvas(input) {
|
|
|
21868
22470
|
return keep && !(branchUi.has(edge.source) && !edge.sourceHandle.includes("fail_branch"));
|
|
21869
22471
|
});
|
|
21870
22472
|
for (const node of nodes) {
|
|
21871
|
-
const id =
|
|
22473
|
+
const id = text4(node.NodeID);
|
|
21872
22474
|
const content = branchUi.get(id);
|
|
21873
22475
|
if (!content) {
|
|
21874
22476
|
continue;
|
|
21875
22477
|
}
|
|
21876
22478
|
branchSlots(node).forEach((slot, index) => {
|
|
21877
|
-
const handle = `${id}.${
|
|
22479
|
+
const handle = `${id}.${text4(content[index]?.id)}-source`;
|
|
21878
22480
|
for (const target of strings8(slot.NextNodeIDs).filter((target2) => ids4.has(target2))) {
|
|
21879
22481
|
edges.push(makeEdge(id, handle, target));
|
|
21880
22482
|
fixes.push(`added branch edge ${id}[${index}] -> ${target}`);
|
|
@@ -21883,8 +22485,8 @@ function prepareCanvas(input) {
|
|
|
21883
22485
|
}
|
|
21884
22486
|
const connected = new Set(edges.map((edge) => `${edge.source}>${edge.target}`));
|
|
21885
22487
|
for (const node of nodes) {
|
|
21886
|
-
const id =
|
|
21887
|
-
const type =
|
|
22488
|
+
const id = text4(node.NodeID);
|
|
22489
|
+
const type = text4(node.NodeType);
|
|
21888
22490
|
for (const target of strings8(node.NextNodeIDs)) {
|
|
21889
22491
|
if (BRANCH_TYPES.has(type) || connected.has(`${id}>${target}`)) {
|
|
21890
22492
|
continue;
|
|
@@ -21918,9 +22520,9 @@ function prepareCanvas(input) {
|
|
|
21918
22520
|
canvas.Edge = JSON.stringify(edges);
|
|
21919
22521
|
const start = nodes.find((node) => node.NodeType === "START");
|
|
21920
22522
|
if (start) {
|
|
21921
|
-
const reached = reachable(
|
|
22523
|
+
const reached = reachable(text4(start.NodeID), successors);
|
|
21922
22524
|
for (const node of nodes) {
|
|
21923
|
-
const id =
|
|
22525
|
+
const id = text4(node.NodeID);
|
|
21924
22526
|
if (node.NodeType === "COMMENT") {
|
|
21925
22527
|
continue;
|
|
21926
22528
|
}
|
|
@@ -21931,7 +22533,7 @@ function prepareCanvas(input) {
|
|
|
21931
22533
|
problems.push(`node ${id} has no next node; every path must end at END`);
|
|
21932
22534
|
}
|
|
21933
22535
|
}
|
|
21934
|
-
layout(nodes,
|
|
22536
|
+
layout(nodes, text4(start.NodeID), successors, branchUi, fixes);
|
|
21935
22537
|
}
|
|
21936
22538
|
const cycle = findCycle(successors);
|
|
21937
22539
|
if (cycle) {
|
|
@@ -21948,7 +22550,7 @@ function prepareCanvas(input) {
|
|
|
21948
22550
|
}
|
|
21949
22551
|
}
|
|
21950
22552
|
checkReferences(nodes, problems);
|
|
21951
|
-
return { canvas, fixes, problems:
|
|
22553
|
+
return { canvas, fixes, problems: unique2(problems) };
|
|
21952
22554
|
}
|
|
21953
22555
|
function findCycle(successors) {
|
|
21954
22556
|
const state = /* @__PURE__ */ new Map();
|
|
@@ -21984,23 +22586,23 @@ function findCycle(successors) {
|
|
|
21984
22586
|
function declaredOutputs(node) {
|
|
21985
22587
|
if (node.NodeType === "PARAMETER_EXTRACTOR") {
|
|
21986
22588
|
const params = extractorParameters(node);
|
|
21987
|
-
if (params.length === 0 || params.some((param) => !
|
|
22589
|
+
if (params.length === 0 || params.some((param) => !text4(param.Name))) {
|
|
21988
22590
|
return void 0;
|
|
21989
22591
|
}
|
|
21990
|
-
return params.map((param) =>
|
|
22592
|
+
return params.map((param) => text4(param.Name));
|
|
21991
22593
|
}
|
|
21992
22594
|
if (node.NodeType === "CODE_EXECUTOR") {
|
|
21993
22595
|
const outputs = Array.isArray(node.Outputs) ? node.Outputs.filter(isRecord) : [];
|
|
21994
|
-
const root = outputs.find((output) =>
|
|
22596
|
+
const root = outputs.find((output) => text4(output.Title) === "Output") ?? outputs[0];
|
|
21995
22597
|
const properties = Array.isArray(root?.Properties) ? root.Properties.filter(isRecord) : [];
|
|
21996
|
-
return properties.length > 0 ? properties.map((property) =>
|
|
22598
|
+
return properties.length > 0 ? properties.map((property) => text4(property.Title)).filter(Boolean) : void 0;
|
|
21997
22599
|
}
|
|
21998
22600
|
return void 0;
|
|
21999
22601
|
}
|
|
22000
22602
|
function checkReferences(nodes, problems) {
|
|
22001
|
-
const byId = new Map(nodes.map((node) => [
|
|
22603
|
+
const byId = new Map(nodes.map((node) => [text4(node.NodeID), node]));
|
|
22002
22604
|
for (const node of nodes) {
|
|
22003
|
-
const id =
|
|
22605
|
+
const id = text4(node.NodeID);
|
|
22004
22606
|
const walk = (value, label, root = false) => {
|
|
22005
22607
|
if (Array.isArray(value)) {
|
|
22006
22608
|
value.forEach((item) => walk(item, label));
|
|
@@ -22009,21 +22611,21 @@ function checkReferences(nodes, problems) {
|
|
|
22009
22611
|
if (!isRecord(value)) {
|
|
22010
22612
|
return;
|
|
22011
22613
|
}
|
|
22012
|
-
const here = root ? label :
|
|
22013
|
-
const ref3 = isRecord(value.Reference) ? value.Reference : !root && "JsonPath" in value &&
|
|
22014
|
-
if (ref3 &&
|
|
22015
|
-
const target = byId.get(
|
|
22016
|
-
const path14 =
|
|
22614
|
+
const here = root ? label : text4(value.Name) || text4(value.Title) || label;
|
|
22615
|
+
const ref3 = isRecord(value.Reference) ? value.Reference : !root && "JsonPath" in value && text4(value.NodeID) ? value : void 0;
|
|
22616
|
+
if (ref3 && text4(ref3.NodeID)) {
|
|
22617
|
+
const target = byId.get(text4(ref3.NodeID));
|
|
22618
|
+
const path14 = text4(ref3.JsonPath);
|
|
22017
22619
|
if (!target) {
|
|
22018
22620
|
problems.push(
|
|
22019
|
-
`node ${id}: "${here}" references node "${
|
|
22621
|
+
`node ${id}: "${here}" references node "${text4(ref3.NodeID)}", which does not exist; point Reference.NodeID at one of ${[...byId.keys()].join(", ")}`
|
|
22020
22622
|
);
|
|
22021
22623
|
} else {
|
|
22022
22624
|
const field = /^Output\.([^.[\]]+)/.exec(path14)?.[1];
|
|
22023
22625
|
const declared = declaredOutputs(target);
|
|
22024
22626
|
if (field && declared && !declared.includes(field)) {
|
|
22025
22627
|
problems.push(
|
|
22026
|
-
`node ${id}: "${here}" reads ${
|
|
22628
|
+
`node ${id}: "${here}" reads ${text4(ref3.NodeID)}.${path14}, but ${text4(ref3.NodeID)} (${text4(target.NodeType)}) declares only ${declared.map((name) => `Output.${name}`).join(", ")}; rename the reference or the ${text4(target.NodeType) === "PARAMETER_EXTRACTOR" ? "parameter" : "output"}`
|
|
22027
22629
|
);
|
|
22028
22630
|
}
|
|
22029
22631
|
}
|
|
@@ -22043,12 +22645,12 @@ function extractorParameters(node) {
|
|
|
22043
22645
|
return Array.isArray(data.Parameters) ? data.Parameters.filter(isRecord) : [];
|
|
22044
22646
|
}
|
|
22045
22647
|
function checkParameterExtractor(node, fixes, problems) {
|
|
22046
|
-
const id =
|
|
22648
|
+
const id = text4(node.NodeID);
|
|
22047
22649
|
const inputs = Array.isArray(node.Inputs) ? node.Inputs.filter(isRecord) : [];
|
|
22048
22650
|
for (const input of inputs) {
|
|
22049
22651
|
if (isRecord(input.Input) && input.Input.InputType === "SYSTEM_VARIABLE") {
|
|
22050
22652
|
problems.push(
|
|
22051
|
-
`node ${id} (PARAMETER_EXTRACTOR): input "${
|
|
22653
|
+
`node ${id} (PARAMETER_EXTRACTOR): input "${text4(input.Name)}" references a system variable, which the platform rejects (\u53C2\u6570\u63D0\u53D6\u8282\u70B9\u4E2D\u4E0D\u5141\u8BB8\u5F15\u7528\u7CFB\u7EDF\u53D8\u91CF); drop it \u2014 the node reads the user query from the dialog itself`
|
|
22052
22654
|
);
|
|
22053
22655
|
}
|
|
22054
22656
|
}
|
|
@@ -22058,17 +22660,17 @@ function checkParameterExtractor(node, fixes, problems) {
|
|
|
22058
22660
|
}
|
|
22059
22661
|
params.forEach((param, index) => {
|
|
22060
22662
|
const where = `node ${id} (PARAMETER_EXTRACTOR) Parameters[${index}]`;
|
|
22061
|
-
if (
|
|
22663
|
+
if (text4(param.RefParameterID)) {
|
|
22062
22664
|
return;
|
|
22063
22665
|
}
|
|
22064
|
-
if (!
|
|
22666
|
+
if (!text4(param.Name)) {
|
|
22065
22667
|
problems.push(`${where}: needs RefParameterID or an inline Name/Type/Desc to register`);
|
|
22066
22668
|
return;
|
|
22067
22669
|
}
|
|
22068
|
-
if (!
|
|
22670
|
+
if (!text4(param.Desc)) {
|
|
22069
22671
|
problems.push(`${where}: Desc is required (the model extracts by this description)`);
|
|
22070
22672
|
}
|
|
22071
|
-
const type =
|
|
22673
|
+
const type = text4(param.Type) || "STRING";
|
|
22072
22674
|
if (!EXTRACTOR_TYPES.has(type)) {
|
|
22073
22675
|
problems.push(`${where}: Type "${type}" must be one of ${[...EXTRACTOR_TYPES].join(", ")}`);
|
|
22074
22676
|
}
|
|
@@ -22085,14 +22687,14 @@ function collectExtractorParameters(canvas) {
|
|
|
22085
22687
|
const nodes = Array.isArray(canvas.Nodes) ? canvas.Nodes.filter(isRecord) : [];
|
|
22086
22688
|
return nodes.filter((node) => node.NodeType === "PARAMETER_EXTRACTOR").flatMap(
|
|
22087
22689
|
(node) => extractorParameters(node).flatMap(
|
|
22088
|
-
(param, index) =>
|
|
22690
|
+
(param, index) => text4(param.RefParameterID) || !text4(param.Name) ? [] : [
|
|
22089
22691
|
{
|
|
22090
|
-
nodeId:
|
|
22091
|
-
nodeName:
|
|
22692
|
+
nodeId: text4(node.NodeID),
|
|
22693
|
+
nodeName: text4(node.NodeName) || text4(node.NodeID),
|
|
22092
22694
|
index,
|
|
22093
|
-
name:
|
|
22094
|
-
type:
|
|
22095
|
-
desc:
|
|
22695
|
+
name: text4(param.Name),
|
|
22696
|
+
type: text4(param.Type) || "STRING",
|
|
22697
|
+
desc: text4(param.Desc),
|
|
22096
22698
|
required: param.Required !== false && param.IsRequired !== false,
|
|
22097
22699
|
correctExamples: examples(param.CorrectExamples),
|
|
22098
22700
|
incorrectExamples: examples(param.IncorrectExamples)
|
|
@@ -22108,7 +22710,7 @@ function bindExtractorParameters(canvas, registered) {
|
|
|
22108
22710
|
const next = structuredClone(canvas);
|
|
22109
22711
|
const nodes = Array.isArray(next.Nodes) ? next.Nodes.filter(isRecord) : [];
|
|
22110
22712
|
for (const { spec, parameterId } of registered) {
|
|
22111
|
-
const node = nodes.find((item) =>
|
|
22713
|
+
const node = nodes.find((item) => text4(item.NodeID) === spec.nodeId);
|
|
22112
22714
|
const params = node ? extractorParameters(node) : [];
|
|
22113
22715
|
if (params[spec.index]) {
|
|
22114
22716
|
params[spec.index] = { RefParameterID: parameterId, Required: spec.required, SubParams: [] };
|
|
@@ -22137,12 +22739,12 @@ function readEdges(raw, problems) {
|
|
|
22137
22739
|
problems.push("Edge must be a JSON string of an edge array");
|
|
22138
22740
|
return [];
|
|
22139
22741
|
}
|
|
22140
|
-
return value.filter(isRecord).filter((edge) =>
|
|
22742
|
+
return value.filter(isRecord).filter((edge) => text4(edge.source) && text4(edge.target)).map((edge) => ({
|
|
22141
22743
|
...edge,
|
|
22142
|
-
source:
|
|
22143
|
-
target:
|
|
22144
|
-
sourceHandle:
|
|
22145
|
-
targetHandle:
|
|
22744
|
+
source: text4(edge.source),
|
|
22745
|
+
target: text4(edge.target),
|
|
22746
|
+
sourceHandle: text4(edge.sourceHandle) || `${text4(edge.source)}-source`,
|
|
22747
|
+
targetHandle: text4(edge.targetHandle) || `${text4(edge.target)}-target`
|
|
22146
22748
|
}));
|
|
22147
22749
|
}
|
|
22148
22750
|
function makeEdge(source2, sourceHandle, target) {
|
|
@@ -22199,17 +22801,17 @@ function branchSlots(node) {
|
|
|
22199
22801
|
const card = dynamicCard(node);
|
|
22200
22802
|
if (card) {
|
|
22201
22803
|
return [
|
|
22202
|
-
{ Content:
|
|
22804
|
+
{ Content: text4(card.DynamicOptionsRefInputName), NextNodeIDs: strings8(card.DynamicOptionsRefNextNodeIDs) },
|
|
22203
22805
|
{ Content: "", NextNodeIDs: strings8(card.DynamicOptionsElseNextNodeIDs) }
|
|
22204
22806
|
];
|
|
22205
22807
|
}
|
|
22206
|
-
const [dataKey, listKey] = BRANCH_LISTS[
|
|
22808
|
+
const [dataKey, listKey] = BRANCH_LISTS[text4(node.NodeType)] ?? ["", ""];
|
|
22207
22809
|
const data = isRecord(node[dataKey]) ? node[dataKey] : void 0;
|
|
22208
22810
|
return data && Array.isArray(data[listKey]) ? data[listKey].filter(isRecord) : [];
|
|
22209
22811
|
}
|
|
22210
22812
|
function prepareBranch(node, fixes, problems) {
|
|
22211
|
-
const id =
|
|
22212
|
-
const type =
|
|
22813
|
+
const id = text4(node.NodeID);
|
|
22814
|
+
const type = text4(node.NodeType);
|
|
22213
22815
|
const [dataKey, listKey] = BRANCH_LISTS[type];
|
|
22214
22816
|
const slots = branchSlots(node);
|
|
22215
22817
|
const loose = strings8(node.NextNodeIDs);
|
|
@@ -22247,7 +22849,7 @@ function prepareBranch(node, fixes, problems) {
|
|
|
22247
22849
|
const existing = Array.isArray(data?.content) ? data.content.filter(isRecord) : [];
|
|
22248
22850
|
const content = slots.map((slot, index) => {
|
|
22249
22851
|
const current = existing[index];
|
|
22250
|
-
if (current &&
|
|
22852
|
+
if (current && text4(current.id)) {
|
|
22251
22853
|
return current;
|
|
22252
22854
|
}
|
|
22253
22855
|
const entryId = `${id}_branch_${index}`;
|
|
@@ -22255,9 +22857,9 @@ function prepareBranch(node, fixes, problems) {
|
|
|
22255
22857
|
return { content: [], index, id: entryId };
|
|
22256
22858
|
}
|
|
22257
22859
|
if (type === "OPTION_CARD") {
|
|
22258
|
-
return { Content:
|
|
22860
|
+
return { Content: text4(slot.Content), id: entryId };
|
|
22259
22861
|
}
|
|
22260
|
-
return { content:
|
|
22862
|
+
return { content: text4(slot.Name) || "intent", id: entryId };
|
|
22261
22863
|
});
|
|
22262
22864
|
if (ui && data && content.some((entry, index) => entry !== existing[index])) {
|
|
22263
22865
|
data.content = content;
|
|
@@ -22286,11 +22888,11 @@ function checkLogical(logical, path14, fixes, problems) {
|
|
|
22286
22888
|
const combined = logical.LogicalOperator === "AND" || logical.LogicalOperator === "OR";
|
|
22287
22889
|
if (combined) {
|
|
22288
22890
|
if (compound.length === 0) {
|
|
22289
|
-
problems.push(`${path14}: LogicalOperator ${
|
|
22891
|
+
problems.push(`${path14}: LogicalOperator ${text4(logical.LogicalOperator)} needs conditions in Compound[]`);
|
|
22290
22892
|
}
|
|
22291
22893
|
if ("Comparison" in logical) {
|
|
22292
22894
|
delete logical.Comparison;
|
|
22293
|
-
fixes.push(`removed ${path14}.Comparison (an ${
|
|
22895
|
+
fixes.push(`removed ${path14}.Comparison (an ${text4(logical.LogicalOperator)} group uses Compound only)`);
|
|
22294
22896
|
}
|
|
22295
22897
|
compound.forEach((child, index) => checkLogical(child, `${path14}.Compound[${index}]`, fixes, problems));
|
|
22296
22898
|
return;
|
|
@@ -22299,13 +22901,13 @@ function checkLogical(logical, path14, fixes, problems) {
|
|
|
22299
22901
|
if (!comparison) {
|
|
22300
22902
|
return;
|
|
22301
22903
|
}
|
|
22302
|
-
const operator =
|
|
22904
|
+
const operator = text4(comparison.Operator);
|
|
22303
22905
|
if (!COMPARISON_OPERATORS.has(operator)) {
|
|
22304
22906
|
problems.push(
|
|
22305
22907
|
`${path14}.Comparison: Operator "${operator || "none"}" is not supported; use one of ${[...COMPARISON_OPERATORS].join(", ")}`
|
|
22306
22908
|
);
|
|
22307
|
-
} else if (NUMERIC_OPERATORS.has(operator) && !["INT", "FLOAT"].includes(
|
|
22308
|
-
problems.push(`${path14}.Comparison: ${operator} compares numbers; LeftType must be INT or FLOAT, got ${
|
|
22909
|
+
} else if (NUMERIC_OPERATORS.has(operator) && !["INT", "FLOAT"].includes(text4(comparison.LeftType))) {
|
|
22910
|
+
problems.push(`${path14}.Comparison: ${operator} compares numbers; LeftType must be INT or FLOAT, got ${text4(comparison.LeftType) || "none"}`);
|
|
22309
22911
|
}
|
|
22310
22912
|
}
|
|
22311
22913
|
function dynamicCard(node) {
|
|
@@ -22315,7 +22917,7 @@ function dynamicCard(node) {
|
|
|
22315
22917
|
return node.OptionCardNodeData.CardFrom === "DYNAMIC" ? node.OptionCardNodeData : void 0;
|
|
22316
22918
|
}
|
|
22317
22919
|
function prepareDynamicCard(node, slots, loose, fixes, problems) {
|
|
22318
|
-
const id =
|
|
22920
|
+
const id = text4(node.NodeID);
|
|
22319
22921
|
const card = dynamicCard(node);
|
|
22320
22922
|
const fields = ["DynamicOptionsRefNextNodeIDs", "DynamicOptionsElseNextNodeIDs"];
|
|
22321
22923
|
if (loose.length > 0) {
|
|
@@ -22329,24 +22931,24 @@ function prepareDynamicCard(node, slots, loose, fixes, problems) {
|
|
|
22329
22931
|
problems.push(`dynamic option card ${id}: OptionCardNodeData.${fields[index]} is empty`);
|
|
22330
22932
|
}
|
|
22331
22933
|
});
|
|
22332
|
-
const inputName =
|
|
22934
|
+
const inputName = text4(card.DynamicOptionsRefInputName);
|
|
22333
22935
|
const input = (Array.isArray(node.Inputs) ? node.Inputs.filter(isRecord) : []).find((entry) => entry.Name === inputName);
|
|
22334
22936
|
if (!inputName || !input) {
|
|
22335
22937
|
problems.push(
|
|
22336
22938
|
`dynamic option card ${id}: DynamicOptionsRefInputName must name one of the node's Inputs (an ARRAY_STRING reference)`
|
|
22337
22939
|
);
|
|
22338
22940
|
} else if (input.Type !== "ARRAY_STRING") {
|
|
22339
|
-
problems.push(`dynamic option card ${id}: input "${inputName}" must be Type ARRAY_STRING, got ${
|
|
22941
|
+
problems.push(`dynamic option card ${id}: input "${inputName}" must be Type ARRAY_STRING, got ${text4(input.Type) || "none"}`);
|
|
22340
22942
|
}
|
|
22341
22943
|
const ui = parseUi(node.NodeUI);
|
|
22342
22944
|
const data = isRecord(ui?.data) ? ui.data : void 0;
|
|
22343
22945
|
const existing = (Array.isArray(data?.content) ? data.content.filter(isRecord) : []).filter((entry) => entry.isDynamic);
|
|
22344
22946
|
const content = slots.map((slot, index) => {
|
|
22345
22947
|
const current = existing[index];
|
|
22346
|
-
if (current &&
|
|
22948
|
+
if (current && text4(current.id)) {
|
|
22347
22949
|
return current;
|
|
22348
22950
|
}
|
|
22349
|
-
const entry = { Content:
|
|
22951
|
+
const entry = { Content: text4(slot.Content), NextNodeIDs: [], id: `${id}_branch_${index}`, isDynamic: true };
|
|
22350
22952
|
if (index === 0) {
|
|
22351
22953
|
entry.hasValue = true;
|
|
22352
22954
|
}
|
|
@@ -22405,7 +23007,7 @@ function layout(nodes, start, successors, branchUi, fixes) {
|
|
|
22405
23007
|
const rows = /* @__PURE__ */ new Map();
|
|
22406
23008
|
let laidOut = 0;
|
|
22407
23009
|
for (const node of nodes) {
|
|
22408
|
-
const id =
|
|
23010
|
+
const id = text4(node.NodeID);
|
|
22409
23011
|
const column = depth.get(id) ?? Math.max(0, ...depth.values()) + 1;
|
|
22410
23012
|
const row = rows.get(column) ?? 0;
|
|
22411
23013
|
rows.set(column, row + 1);
|
|
@@ -22447,9 +23049,9 @@ function rewriteEndReferences(node, fixes) {
|
|
|
22447
23049
|
const value = isRecord(property.Value) ? property.Value : void 0;
|
|
22448
23050
|
if (value?.InputType === "INPUT_REF" && isRecord(value.InputRef)) {
|
|
22449
23051
|
const ref3 = value.InputRef;
|
|
22450
|
-
const path14 =
|
|
22451
|
-
property.Value = { InputType: "REFERENCE_OUTPUT", Reference: { NodeID:
|
|
22452
|
-
fixes.push(`END ${
|
|
23052
|
+
const path14 = text4(ref3.JsonPath) || `Output.${text4(ref3.Name)}`;
|
|
23053
|
+
property.Value = { InputType: "REFERENCE_OUTPUT", Reference: { NodeID: text4(ref3.NodeID), JsonPath: path14 } };
|
|
23054
|
+
fixes.push(`END ${text4(node.NodeID)}: output ${text4(property.Title)} INPUT_REF -> REFERENCE_OUTPUT ${path14}`);
|
|
22453
23055
|
}
|
|
22454
23056
|
visit(property.Properties);
|
|
22455
23057
|
}
|
|
@@ -22461,18 +23063,18 @@ function rewriteEndReferences(node, fixes) {
|
|
|
22461
23063
|
}
|
|
22462
23064
|
}
|
|
22463
23065
|
function typeOf(nodes, id) {
|
|
22464
|
-
return
|
|
23066
|
+
return text4(nodes.find((node) => node.NodeID === id)?.NodeType);
|
|
22465
23067
|
}
|
|
22466
23068
|
function isRecord(value) {
|
|
22467
23069
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
22468
23070
|
}
|
|
22469
|
-
function
|
|
23071
|
+
function text4(value) {
|
|
22470
23072
|
return typeof value === "string" ? value : typeof value === "number" ? String(value) : "";
|
|
22471
23073
|
}
|
|
22472
23074
|
function strings8(value) {
|
|
22473
|
-
return Array.isArray(value) ? value.map(
|
|
23075
|
+
return Array.isArray(value) ? value.map(text4).filter(Boolean) : [];
|
|
22474
23076
|
}
|
|
22475
|
-
function
|
|
23077
|
+
function unique2(values) {
|
|
22476
23078
|
return [...new Set(values)];
|
|
22477
23079
|
}
|
|
22478
23080
|
|
|
@@ -22875,8 +23477,8 @@ async function findByName(gateway, appId3, name) {
|
|
|
22875
23477
|
return all.filter((item) => item.name === name);
|
|
22876
23478
|
}
|
|
22877
23479
|
function isDuplicateNameError(error) {
|
|
22878
|
-
const
|
|
22879
|
-
return
|
|
23480
|
+
const text13 = error instanceof Error ? error.message.toLowerCase() : String(error).toLowerCase();
|
|
23481
|
+
return text13.includes("500300") || text13.includes("\u5DE5\u4F5C\u6D41\u540D\u79F0\u5DF2\u7ECF\u5B58\u5728") || text13.includes("workflow name already exists");
|
|
22880
23482
|
}
|
|
22881
23483
|
function isNonEmpty(dialogJson) {
|
|
22882
23484
|
return typeof dialogJson === "string" && dialogJson.trim().length > 0;
|
|
@@ -23291,12 +23893,12 @@ function runId(args) {
|
|
|
23291
23893
|
function parseVariables(raw) {
|
|
23292
23894
|
const values = Array.isArray(raw) ? raw : raw === void 0 ? [] : [raw];
|
|
23293
23895
|
return values.map((entry) => {
|
|
23294
|
-
const
|
|
23295
|
-
const at =
|
|
23896
|
+
const text13 = String(entry);
|
|
23897
|
+
const at = text13.indexOf("=");
|
|
23296
23898
|
if (at <= 0) {
|
|
23297
|
-
throw usageError(`Invalid --var ${
|
|
23899
|
+
throw usageError(`Invalid --var ${text13}`, "Use --var name=value (repeatable)");
|
|
23298
23900
|
}
|
|
23299
|
-
return { name:
|
|
23901
|
+
return { name: text13.slice(0, at), value: text13.slice(at + 1) };
|
|
23300
23902
|
});
|
|
23301
23903
|
}
|
|
23302
23904
|
function runIds(args) {
|
|
@@ -24152,14 +24754,14 @@ var storeIdFlag = {
|
|
|
24152
24754
|
var userIdFlag = { name: "user-id", type: "string", describe: "End-user ID the memory belongs to", required: true };
|
|
24153
24755
|
var typeFlag3 = { name: "type", type: "string", describe: "Store type", choices: ["rich", "flat"] };
|
|
24154
24756
|
var appIdFlag8 = { name: "app-id", type: "string", describe: "App ID (default: adp.jsonc app_id)" };
|
|
24155
|
-
function
|
|
24757
|
+
function text5(args, key) {
|
|
24156
24758
|
return typeof args[key] === "string" ? args[key] : void 0;
|
|
24157
24759
|
}
|
|
24158
24760
|
function bool2(args, key) {
|
|
24159
24761
|
return typeof args[key] === "boolean" ? args[key] : void 0;
|
|
24160
24762
|
}
|
|
24161
24763
|
function required(args, key) {
|
|
24162
|
-
const value =
|
|
24764
|
+
const value = text5(args, key)?.trim();
|
|
24163
24765
|
if (!value) {
|
|
24164
24766
|
throw new DomainError(`Missing --${key}`, "usage", "UsageError");
|
|
24165
24767
|
}
|
|
@@ -24171,7 +24773,7 @@ async function storeRef(ctx, args) {
|
|
|
24171
24773
|
return { spaceId: await resolveSpaceId(ctx, args, WHY_SPACE3), storeId };
|
|
24172
24774
|
}
|
|
24173
24775
|
function storeType(args, fallback) {
|
|
24174
|
-
const name =
|
|
24776
|
+
const name = text5(args, "type");
|
|
24175
24777
|
return name ? MEMORY_STORE_TYPES[name] : fallback;
|
|
24176
24778
|
}
|
|
24177
24779
|
async function guarded(scope, run) {
|
|
@@ -24205,9 +24807,9 @@ function registerMemoryCommands(registry, ctx) {
|
|
|
24205
24807
|
spaceId,
|
|
24206
24808
|
limit: ctx.flags.limit,
|
|
24207
24809
|
page: ctx.flags.page,
|
|
24208
|
-
query:
|
|
24209
|
-
storeType:
|
|
24210
|
-
appId:
|
|
24810
|
+
query: text5(args, "query"),
|
|
24811
|
+
storeType: text5(args, "type") ? storeType(args, 1) : void 0,
|
|
24812
|
+
appId: text5(args, "app-id")
|
|
24211
24813
|
});
|
|
24212
24814
|
return applyListShape(
|
|
24213
24815
|
ctx,
|
|
@@ -24255,7 +24857,7 @@ function registerMemoryCommands(registry, ctx) {
|
|
|
24255
24857
|
const input = {
|
|
24256
24858
|
spaceId,
|
|
24257
24859
|
name: required(args, "name"),
|
|
24258
|
-
description:
|
|
24860
|
+
description: text5(args, "description"),
|
|
24259
24861
|
storeType: storeType(args, 1),
|
|
24260
24862
|
summaryEnabled: bool2(args, "summary"),
|
|
24261
24863
|
ttlDays: typeof args["ttl-days"] === "number" ? args["ttl-days"] : void 0
|
|
@@ -24295,8 +24897,8 @@ function registerMemoryCommands(registry, ctx) {
|
|
|
24295
24897
|
const ref3 = await storeRef(ctx, args);
|
|
24296
24898
|
const rich = storeTypeOf(ref3.storeId) === 1;
|
|
24297
24899
|
const patch = {
|
|
24298
|
-
name:
|
|
24299
|
-
description:
|
|
24900
|
+
name: text5(args, "name"),
|
|
24901
|
+
description: text5(args, "description"),
|
|
24300
24902
|
summaryEnabled: rich ? bool2(args, "summary") : void 0,
|
|
24301
24903
|
ttlDays: !rich && typeof args["ttl-days"] === "number" ? args["ttl-days"] : void 0
|
|
24302
24904
|
};
|
|
@@ -24370,7 +24972,7 @@ function registerMemoryCommands(registry, ctx) {
|
|
|
24370
24972
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
24371
24973
|
const page3 = await guarded(
|
|
24372
24974
|
ref3,
|
|
24373
|
-
() => gateways.memory.listUsers({ ...ref3, limit: ctx.flags.limit, page: ctx.flags.page, query:
|
|
24975
|
+
() => gateways.memory.listUsers({ ...ref3, limit: ctx.flags.limit, page: ctx.flags.page, query: text5(args, "query") })
|
|
24374
24976
|
);
|
|
24375
24977
|
return applyListShape(
|
|
24376
24978
|
ctx,
|
|
@@ -24402,8 +25004,8 @@ function registerMemoryCommands(registry, ctx) {
|
|
|
24402
25004
|
...ref3,
|
|
24403
25005
|
limit: ctx.flags.limit,
|
|
24404
25006
|
page: ctx.flags.page,
|
|
24405
|
-
userId:
|
|
24406
|
-
query:
|
|
25007
|
+
userId: text5(args, "user-id"),
|
|
25008
|
+
query: text5(args, "query")
|
|
24407
25009
|
})
|
|
24408
25010
|
);
|
|
24409
25011
|
return applyListShape(
|
|
@@ -24467,9 +25069,9 @@ function registerMemoryCommands(registry, ctx) {
|
|
|
24467
25069
|
userId: required(args, "user-id"),
|
|
24468
25070
|
entryKey: required(args, "entry-key"),
|
|
24469
25071
|
patch: {
|
|
24470
|
-
content:
|
|
24471
|
-
name:
|
|
24472
|
-
frontMatter:
|
|
25072
|
+
content: text5(args, "content"),
|
|
25073
|
+
name: text5(args, "name"),
|
|
25074
|
+
frontMatter: text5(args, "front-matter"),
|
|
24473
25075
|
type: typeof args.type === "number" ? args.type : void 0
|
|
24474
25076
|
}
|
|
24475
25077
|
};
|
|
@@ -24612,9 +25214,9 @@ function registerMemoryCommands(registry, ctx) {
|
|
|
24612
25214
|
async handler(args) {
|
|
24613
25215
|
const spaceId = await resolveSpaceId(ctx, args, WHY_SPACE3);
|
|
24614
25216
|
const appId3 = assertResourceId(await resolveAppId(ctx, args, "memory bindings belong to an app"), "app-id");
|
|
24615
|
-
const storeId =
|
|
25217
|
+
const storeId = text5(args, "store-id") ? assertResourceId(String(args["store-id"]), "store-id") : void 0;
|
|
24616
25218
|
const type = storeId ? storeTypeOf(storeId) : storeType(args, 1);
|
|
24617
|
-
if (storeId &&
|
|
25219
|
+
if (storeId && text5(args, "type") && storeType(args, type) !== type) {
|
|
24618
25220
|
throw new DomainError("--type does not match the --store-id prefix", "usage", "UsageError");
|
|
24619
25221
|
}
|
|
24620
25222
|
const input = { spaceId, appId: appId3, storeType: type, storeId, summaryEnabled: bool2(args, "summary") };
|
|
@@ -24670,7 +25272,7 @@ function registerMemoryCommands(registry, ctx) {
|
|
|
24670
25272
|
examples: ["adp memory export --space-id sp-1 --store-id rms_abc --output ./memory.csv"],
|
|
24671
25273
|
async handler(args) {
|
|
24672
25274
|
const ref3 = await storeRef(ctx, args);
|
|
24673
|
-
const output =
|
|
25275
|
+
const output = text5(args, "output") ? canonicalizeLocalPath(String(args.output), ctx.flags.cwd) : void 0;
|
|
24674
25276
|
if (ctx.flags.dryRun) {
|
|
24675
25277
|
return { result: { dryRun: true, ...ref3, output }, message: `Would export memory store ${ref3.storeId}.` };
|
|
24676
25278
|
}
|
|
@@ -24869,11 +25471,11 @@ var tokenEnvFlag = {
|
|
|
24869
25471
|
type: "string",
|
|
24870
25472
|
describe: "Read the API key from this environment variable (never pass secrets as arguments)"
|
|
24871
25473
|
};
|
|
24872
|
-
function
|
|
25474
|
+
function text6(args, key) {
|
|
24873
25475
|
return typeof args[key] === "string" && args[key].trim() !== "" ? args[key].trim() : void 0;
|
|
24874
25476
|
}
|
|
24875
25477
|
function source(args) {
|
|
24876
|
-
const name =
|
|
25478
|
+
const name = text6(args, "source");
|
|
24877
25479
|
return name ? CREDENTIAL_SOURCES[name] : void 0;
|
|
24878
25480
|
}
|
|
24879
25481
|
function consumer(args) {
|
|
@@ -24889,7 +25491,7 @@ async function credentialRef(ctx, args) {
|
|
|
24889
25491
|
};
|
|
24890
25492
|
}
|
|
24891
25493
|
async function readToken(ctx, args, required3) {
|
|
24892
|
-
const envName =
|
|
25494
|
+
const envName = text6(args, "token-env");
|
|
24893
25495
|
if (envName) {
|
|
24894
25496
|
const value = ctx.deps.env[envName]?.trim();
|
|
24895
25497
|
if (!value) {
|
|
@@ -24933,7 +25535,7 @@ function registerCredentialCommands(registry, ctx) {
|
|
|
24933
25535
|
spaceId,
|
|
24934
25536
|
limit: ctx.flags.limit,
|
|
24935
25537
|
page: ctx.flags.page,
|
|
24936
|
-
query:
|
|
25538
|
+
query: text6(args, "query"),
|
|
24937
25539
|
source: source(args)
|
|
24938
25540
|
});
|
|
24939
25541
|
return applyListShape(
|
|
@@ -24974,7 +25576,7 @@ function registerCredentialCommands(registry, ctx) {
|
|
|
24974
25576
|
spaceId,
|
|
24975
25577
|
limit: ctx.flags.limit,
|
|
24976
25578
|
page: ctx.flags.page,
|
|
24977
|
-
query:
|
|
25579
|
+
query: text6(args, "query"),
|
|
24978
25580
|
source: source(args)
|
|
24979
25581
|
});
|
|
24980
25582
|
return applyListShape(
|
|
@@ -25006,7 +25608,7 @@ function registerCredentialCommands(registry, ctx) {
|
|
|
25006
25608
|
consumer: consumer(args),
|
|
25007
25609
|
limit: ctx.flags.limit,
|
|
25008
25610
|
page: ctx.flags.page,
|
|
25009
|
-
query:
|
|
25611
|
+
query: text6(args, "query"),
|
|
25010
25612
|
allSpaces: args["all-spaces"] === true
|
|
25011
25613
|
});
|
|
25012
25614
|
return applyListShape(
|
|
@@ -25029,7 +25631,7 @@ function registerCredentialCommands(registry, ctx) {
|
|
|
25029
25631
|
],
|
|
25030
25632
|
async handler(args) {
|
|
25031
25633
|
const spaceId = await resolveSpaceId(ctx, args, WHY_SPACE4);
|
|
25032
|
-
const name =
|
|
25634
|
+
const name = text6(args, "name");
|
|
25033
25635
|
if (!name) {
|
|
25034
25636
|
throw new DomainError("Missing --name", "usage", "UsageError");
|
|
25035
25637
|
}
|
|
@@ -25054,10 +25656,10 @@ function registerCredentialCommands(registry, ctx) {
|
|
|
25054
25656
|
examples: ["NEW_KEY=\u2026 adp credential update --space-id sp-1 --credential-id abc --token-env NEW_KEY"],
|
|
25055
25657
|
async handler(args) {
|
|
25056
25658
|
const ref3 = await credentialRef(ctx, args);
|
|
25057
|
-
const name =
|
|
25659
|
+
const name = text6(args, "name");
|
|
25058
25660
|
if (ctx.flags.dryRun) {
|
|
25059
25661
|
return {
|
|
25060
|
-
result: { dryRun: true, ...ref3, name, token:
|
|
25662
|
+
result: { dryRun: true, ...ref3, name, token: text6(args, "token-env") ? "(from env)" : void 0 },
|
|
25061
25663
|
message: `Would update credential ${ref3.credentialId}.`
|
|
25062
25664
|
};
|
|
25063
25665
|
}
|
|
@@ -25122,8 +25724,8 @@ function registerCredentialCommands(registry, ctx) {
|
|
|
25122
25724
|
],
|
|
25123
25725
|
async handler(args) {
|
|
25124
25726
|
const spaceId = await resolveSpaceId(ctx, args, WHY_SPACE4);
|
|
25125
|
-
const hasConsumer = Boolean(
|
|
25126
|
-
const hasCredential = Boolean(
|
|
25727
|
+
const hasConsumer = Boolean(text6(args, "consumer-id"));
|
|
25728
|
+
const hasCredential = Boolean(text6(args, "credential-id"));
|
|
25127
25729
|
if (hasConsumer === hasCredential) {
|
|
25128
25730
|
throw new DomainError("Pass exactly one of --consumer-id or --credential-id", "usage", "UsageError");
|
|
25129
25731
|
}
|
|
@@ -25133,7 +25735,7 @@ function registerCredentialCommands(registry, ctx) {
|
|
|
25133
25735
|
}
|
|
25134
25736
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
25135
25737
|
const result = await guarded2(
|
|
25136
|
-
{ spaceId, credentialId:
|
|
25738
|
+
{ spaceId, credentialId: text6(args, "credential-id") },
|
|
25137
25739
|
() => authorizeCredential(
|
|
25138
25740
|
{
|
|
25139
25741
|
credentials: gateways.credential,
|
|
@@ -25273,7 +25875,7 @@ var promptFlags = [
|
|
|
25273
25875
|
{ name: "prompt", type: "string", describe: "What the task asks the model each run" },
|
|
25274
25876
|
{ name: "prompt-file", type: "string", describe: "Read the prompt from a UTF-8 file" }
|
|
25275
25877
|
];
|
|
25276
|
-
function
|
|
25878
|
+
function text7(args, key) {
|
|
25277
25879
|
const value = args[key];
|
|
25278
25880
|
return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
|
|
25279
25881
|
}
|
|
@@ -25285,17 +25887,17 @@ function list(args, key) {
|
|
|
25285
25887
|
function schedule(args) {
|
|
25286
25888
|
return parseTimerSchedule({
|
|
25287
25889
|
manual: args.manual === true,
|
|
25288
|
-
daily:
|
|
25890
|
+
daily: text7(args, "daily"),
|
|
25289
25891
|
weekly: list(args, "weekly"),
|
|
25290
|
-
every:
|
|
25291
|
-
startAt:
|
|
25292
|
-
once:
|
|
25293
|
-
cron:
|
|
25892
|
+
every: text7(args, "every"),
|
|
25893
|
+
startAt: text7(args, "start-at"),
|
|
25894
|
+
once: text7(args, "once"),
|
|
25895
|
+
cron: text7(args, "cron")
|
|
25294
25896
|
});
|
|
25295
25897
|
}
|
|
25296
25898
|
async function prompt(args) {
|
|
25297
|
-
const inline =
|
|
25298
|
-
const file =
|
|
25899
|
+
const inline = text7(args, "prompt");
|
|
25900
|
+
const file = text7(args, "prompt-file");
|
|
25299
25901
|
if (inline && file) {
|
|
25300
25902
|
throw new DomainError("Pass --prompt or --prompt-file, not both", "usage", "UsageError");
|
|
25301
25903
|
}
|
|
@@ -25337,7 +25939,7 @@ function registerTimerCommands(registry, ctx) {
|
|
|
25337
25939
|
async handler(args) {
|
|
25338
25940
|
const spaceId = await resolveSpaceId(ctx, args, WHY_SPACE5);
|
|
25339
25941
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
25340
|
-
const page3 = await gateways.timer.list({ spaceId, limit: ctx.flags.limit, page: ctx.flags.page, query:
|
|
25942
|
+
const page3 = await gateways.timer.list({ spaceId, limit: ctx.flags.limit, page: ctx.flags.page, query: text7(args, "query") });
|
|
25341
25943
|
return applyListShape(
|
|
25342
25944
|
ctx,
|
|
25343
25945
|
pageResult(page3, { limit: ctx.flags.limit, page: ctx.flags.page }),
|
|
@@ -25381,7 +25983,7 @@ function registerTimerCommands(registry, ctx) {
|
|
|
25381
25983
|
],
|
|
25382
25984
|
async handler(args) {
|
|
25383
25985
|
const spaceId = await resolveSpaceId(ctx, args, WHY_SPACE5);
|
|
25384
|
-
const name =
|
|
25986
|
+
const name = text7(args, "name");
|
|
25385
25987
|
if (!name) {
|
|
25386
25988
|
throw new DomainError("Missing --name", "usage", "UsageError");
|
|
25387
25989
|
}
|
|
@@ -25395,7 +25997,7 @@ function registerTimerCommands(registry, ctx) {
|
|
|
25395
25997
|
hint: "Use one of --manual, --daily, --weekly, --every, --once, --cron"
|
|
25396
25998
|
});
|
|
25397
25999
|
}
|
|
25398
|
-
const input = { spaceId, name, prompt: body, schedule: plan, modelId:
|
|
26000
|
+
const input = { spaceId, name, prompt: body, schedule: plan, modelId: text7(args, "model"), timezone: text7(args, "timezone") };
|
|
25399
26001
|
if (ctx.flags.dryRun) {
|
|
25400
26002
|
return { result: { dryRun: true, ...input }, message: `Would create timer task ${name}.` };
|
|
25401
26003
|
}
|
|
@@ -25431,11 +26033,11 @@ function registerTimerCommands(registry, ctx) {
|
|
|
25431
26033
|
async handler(args) {
|
|
25432
26034
|
const ref3 = await timerRef(ctx, args);
|
|
25433
26035
|
const patch = {
|
|
25434
|
-
name:
|
|
26036
|
+
name: text7(args, "name"),
|
|
25435
26037
|
prompt: await prompt(args),
|
|
25436
|
-
modelId:
|
|
26038
|
+
modelId: text7(args, "model"),
|
|
25437
26039
|
schedule: schedule(args),
|
|
25438
|
-
timezone:
|
|
26040
|
+
timezone: text7(args, "timezone")
|
|
25439
26041
|
};
|
|
25440
26042
|
if (ctx.flags.dryRun) {
|
|
25441
26043
|
return { result: { dryRun: true, ...ref3, ...patch }, message: `Would update timer task ${ref3.timerId}.` };
|
|
@@ -25604,14 +26206,14 @@ function explainGuidelineError(error, input) {
|
|
|
25604
26206
|
return error;
|
|
25605
26207
|
}
|
|
25606
26208
|
function batch(ids4, verb) {
|
|
25607
|
-
const
|
|
25608
|
-
if (
|
|
26209
|
+
const unique3 = [...new Set(ids4)];
|
|
26210
|
+
if (unique3.length === 0) {
|
|
25609
26211
|
throw new DomainError(`Nothing to ${verb}`, "usage", "UsageError", { hint: "Pass --guideline-id at least once" });
|
|
25610
26212
|
}
|
|
25611
|
-
if (
|
|
26213
|
+
if (unique3.length > BATCH_MAX) {
|
|
25612
26214
|
throw new DomainError(`At most ${BATCH_MAX} guidelines per call`, "usage", "UsageError");
|
|
25613
26215
|
}
|
|
25614
|
-
return
|
|
26216
|
+
return unique3;
|
|
25615
26217
|
}
|
|
25616
26218
|
function settle(result, appId3, verb) {
|
|
25617
26219
|
if (result.succeeded.length === 0 && result.failed.length > 0) {
|
|
@@ -25681,7 +26283,7 @@ var appIdFlag9 = { name: "app-id", type: "string", describe: "App ID (defaults t
|
|
|
25681
26283
|
var guidelineIdFlag = { name: "guideline-id", type: "string", describe: "Guideline ID", required: true };
|
|
25682
26284
|
var guidelineIdsFlag = { name: "guideline-id", type: "string", describe: "Guideline ID, repeatable", required: true };
|
|
25683
26285
|
var taskIdFlag2 = { name: "task-id", type: "string", describe: "Generation task ID", required: true };
|
|
25684
|
-
function
|
|
26286
|
+
function text8(args, key) {
|
|
25685
26287
|
const value = args[key];
|
|
25686
26288
|
return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
|
|
25687
26289
|
}
|
|
@@ -25727,15 +26329,15 @@ function registerGuidelineCommands(registry, ctx) {
|
|
|
25727
26329
|
examples: ["adp guideline list --app-id app-1 --status candidate --format json"],
|
|
25728
26330
|
async handler(args) {
|
|
25729
26331
|
const appId3 = await resolveAppId(ctx, args, WHY_APP5);
|
|
25730
|
-
const status =
|
|
26332
|
+
const status = text8(args, "status");
|
|
25731
26333
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
25732
26334
|
const result = await gateways.guideline.list({
|
|
25733
26335
|
appId: appId3,
|
|
25734
26336
|
limit: ctx.flags.limit,
|
|
25735
26337
|
page: ctx.flags.page,
|
|
25736
|
-
query:
|
|
26338
|
+
query: text8(args, "query"),
|
|
25737
26339
|
status: status ? GUIDELINE_STATUSES[status] : void 0,
|
|
25738
|
-
sourceTaskId:
|
|
26340
|
+
sourceTaskId: text8(args, "task-id")
|
|
25739
26341
|
});
|
|
25740
26342
|
return page2(ctx, result, `adp guideline list --app-id ${appId3}`);
|
|
25741
26343
|
}
|
|
@@ -25771,11 +26373,11 @@ function registerGuidelineCommands(registry, ctx) {
|
|
|
25771
26373
|
examples: ['adp guideline create --app-id app-1 --content "\u62A5\u4EF7\u65F6\u6CE8\u660E\u6570\u636E\u65E5\u671F" --apply-scene "\u884C\u60C5\u62A5\u4EF7\u7C7B\u95EE\u9898"'],
|
|
25772
26374
|
async handler(args) {
|
|
25773
26375
|
const appId3 = await resolveAppId(ctx, args, WHY_APP5);
|
|
25774
|
-
const content =
|
|
26376
|
+
const content = text8(args, "content");
|
|
25775
26377
|
if (!content) {
|
|
25776
26378
|
throw new DomainError("Missing --content", "usage", "UsageError");
|
|
25777
26379
|
}
|
|
25778
|
-
const input = { appId: appId3, content, applyScene:
|
|
26380
|
+
const input = { appId: appId3, content, applyScene: text8(args, "apply-scene") };
|
|
25779
26381
|
if (ctx.flags.dryRun) {
|
|
25780
26382
|
return { result: { dryRun: true, ...input }, message: "Would create a guideline." };
|
|
25781
26383
|
}
|
|
@@ -25808,7 +26410,7 @@ function registerGuidelineCommands(registry, ctx) {
|
|
|
25808
26410
|
async handler(args) {
|
|
25809
26411
|
const appId3 = await resolveAppId(ctx, args, WHY_APP5);
|
|
25810
26412
|
const guidelineId = assertResourceId(String(args["guideline-id"]), "guideline-id");
|
|
25811
|
-
const input = { appId: appId3, guidelineId, content:
|
|
26413
|
+
const input = { appId: appId3, guidelineId, content: text8(args, "content"), applyScene: optional(args, "apply-scene") };
|
|
25812
26414
|
if (ctx.flags.dryRun) {
|
|
25813
26415
|
return { result: { dryRun: true, ...input }, message: `Would update guideline ${guidelineId}.` };
|
|
25814
26416
|
}
|
|
@@ -25877,8 +26479,8 @@ function registerGuidelineCommands(registry, ctx) {
|
|
|
25877
26479
|
appId: appId3,
|
|
25878
26480
|
limit: ctx.flags.limit,
|
|
25879
26481
|
page: ctx.flags.page,
|
|
25880
|
-
releaseId:
|
|
25881
|
-
query:
|
|
26482
|
+
releaseId: text8(args, "release-id"),
|
|
26483
|
+
query: text8(args, "query")
|
|
25882
26484
|
});
|
|
25883
26485
|
return page2(ctx, result, `adp guideline changes --app-id ${appId3}`);
|
|
25884
26486
|
}
|
|
@@ -25895,7 +26497,7 @@ function registerGuidelineCommands(registry, ctx) {
|
|
|
25895
26497
|
async handler(args) {
|
|
25896
26498
|
const appId3 = await resolveAppId(ctx, args, WHY_APP5);
|
|
25897
26499
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
25898
|
-
const result = await gateways.guideline.listTasks({ appId: appId3, limit: ctx.flags.limit, page: ctx.flags.page, query:
|
|
26500
|
+
const result = await gateways.guideline.listTasks({ appId: appId3, limit: ctx.flags.limit, page: ctx.flags.page, query: text8(args, "query") });
|
|
25899
26501
|
return page2(ctx, result, `adp guideline task list --app-id ${appId3}`);
|
|
25900
26502
|
}
|
|
25901
26503
|
})
|
|
@@ -25935,16 +26537,16 @@ function registerGuidelineCommands(registry, ctx) {
|
|
|
25935
26537
|
],
|
|
25936
26538
|
async handler(args) {
|
|
25937
26539
|
const appId3 = await resolveAppId(ctx, args, WHY_APP5);
|
|
25938
|
-
const fromTaskId =
|
|
25939
|
-
const evaluationId =
|
|
25940
|
-
const modelId =
|
|
26540
|
+
const fromTaskId = text8(args, "from-task-id");
|
|
26541
|
+
const evaluationId = text8(args, "evaluation-id");
|
|
26542
|
+
const modelId = text8(args, "model");
|
|
25941
26543
|
if (Boolean(fromTaskId) === Boolean(evaluationId)) {
|
|
25942
26544
|
throw new DomainError("Pass exactly one of --evaluation-id or --from-task-id", "usage", "UsageError");
|
|
25943
26545
|
}
|
|
25944
26546
|
if (evaluationId && !modelId) {
|
|
25945
26547
|
throw new DomainError("--evaluation-id needs --model", "usage", "UsageError", { hint: "Pick one from adp models" });
|
|
25946
26548
|
}
|
|
25947
|
-
const input = fromTaskId ? { appId: appId3, name:
|
|
26549
|
+
const input = fromTaskId ? { appId: appId3, name: text8(args, "name"), fromTaskId: assertResourceId(fromTaskId, "from-task-id") } : { appId: appId3, name: text8(args, "name"), evaluationId: assertResourceId(evaluationId, "evaluation-id"), modelId };
|
|
25948
26550
|
if (ctx.flags.dryRun) {
|
|
25949
26551
|
return { result: { dryRun: true, ...input }, message: "Would start a guideline generation task." };
|
|
25950
26552
|
}
|
|
@@ -26012,7 +26614,7 @@ function registerGuidelineCommands(registry, ctx) {
|
|
|
26012
26614
|
throw new DomainError("Pass --enable or --disable, not both", "usage", "UsageError");
|
|
26013
26615
|
}
|
|
26014
26616
|
const enabled = args.enable === true ? true : args.disable === true ? false : void 0;
|
|
26015
|
-
const input = { appId: appId3, enabled, modelId:
|
|
26617
|
+
const input = { appId: appId3, enabled, modelId: text8(args, "model") };
|
|
26016
26618
|
if (ctx.flags.dryRun) {
|
|
26017
26619
|
return { result: { dryRun: true, ...input }, message: "Would update auto-distill." };
|
|
26018
26620
|
}
|
|
@@ -26113,7 +26715,7 @@ async function deleteFeedback(deps, input) {
|
|
|
26113
26715
|
var WHY_APP6 = "Feedback belongs to an app";
|
|
26114
26716
|
var appIdFlag10 = { name: "app-id", type: "string", describe: "App ID (defaults to adp.jsonc)" };
|
|
26115
26717
|
var appModeFlag = { name: "app-mode", type: "number", describe: "App mode 1-4 (read from the app when omitted)" };
|
|
26116
|
-
function
|
|
26718
|
+
function text9(args, key) {
|
|
26117
26719
|
const value = args[key];
|
|
26118
26720
|
return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
|
|
26119
26721
|
}
|
|
@@ -26123,7 +26725,7 @@ function list2(args, key) {
|
|
|
26123
26725
|
return items.map(String).filter((item) => item.trim() !== "");
|
|
26124
26726
|
}
|
|
26125
26727
|
function required2(args, key) {
|
|
26126
|
-
const value =
|
|
26728
|
+
const value = text9(args, key);
|
|
26127
26729
|
if (!value) {
|
|
26128
26730
|
throw new DomainError(`Missing --${key}`, "usage", "UsageError", { hint: "The platform rejects feedback without both the question and the reply" });
|
|
26129
26731
|
}
|
|
@@ -26163,8 +26765,8 @@ function registerFeedbackCommands(registry, ctx) {
|
|
|
26163
26765
|
appMode,
|
|
26164
26766
|
limit: ctx.flags.limit,
|
|
26165
26767
|
page: ctx.flags.page,
|
|
26166
|
-
query:
|
|
26167
|
-
reason:
|
|
26768
|
+
query: text9(args, "query"),
|
|
26769
|
+
reason: text9(args, "reason"),
|
|
26168
26770
|
status: typeof args.status === "number" ? args.status : void 0
|
|
26169
26771
|
});
|
|
26170
26772
|
return applyListShape(
|
|
@@ -26222,11 +26824,11 @@ function registerFeedbackCommands(registry, ctx) {
|
|
|
26222
26824
|
appId: appId3,
|
|
26223
26825
|
appMode: mode(args),
|
|
26224
26826
|
recordId: assertResourceId(String(args["record-id"]), "record-id"),
|
|
26225
|
-
sessionId:
|
|
26827
|
+
sessionId: text9(args, "session-id"),
|
|
26226
26828
|
question: required2(args, "question"),
|
|
26227
26829
|
answer: required2(args, "answer"),
|
|
26228
26830
|
reasons: list2(args, "reason"),
|
|
26229
|
-
rightAnswer:
|
|
26831
|
+
rightAnswer: text9(args, "right-answer"),
|
|
26230
26832
|
acceptTerms: args["accept-terms"] === true
|
|
26231
26833
|
};
|
|
26232
26834
|
assertFeedbackTerms(input.acceptTerms);
|
|
@@ -26382,7 +26984,7 @@ var WHY = "File volumes belong to a space";
|
|
|
26382
26984
|
var spaceIdFlag8 = { name: "space-id", type: "string", describe: "Space ID (defaults to adp.jsonc)" };
|
|
26383
26985
|
var volumeIdFlag = { name: "volume-id", type: "string", describe: "Volume ID", required: true };
|
|
26384
26986
|
var pathFlag = { name: "path", type: "string", describe: "Path inside the volume, e.g. docs/report.pdf", required: true };
|
|
26385
|
-
function
|
|
26987
|
+
function text10(value) {
|
|
26386
26988
|
return typeof value === "string" ? value : void 0;
|
|
26387
26989
|
}
|
|
26388
26990
|
async function ref2(ctx, args) {
|
|
@@ -26399,7 +27001,7 @@ function registerVolumeCommands(registry, ctx) {
|
|
|
26399
27001
|
examples: ["adp volume list --space-id sp-1 --format json"],
|
|
26400
27002
|
async handler(args) {
|
|
26401
27003
|
const spaceId = await resolveSpaceId(ctx, args, WHY);
|
|
26402
|
-
const query =
|
|
27004
|
+
const query = text10(args.query);
|
|
26403
27005
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
26404
27006
|
const page3 = await gateways.volume.list({ spaceId, limit: ctx.flags.limit, page: ctx.flags.page, query });
|
|
26405
27007
|
return applyListShape(
|
|
@@ -26443,7 +27045,7 @@ function registerVolumeCommands(registry, ctx) {
|
|
|
26443
27045
|
return { result: { dryRun: true, spaceId, name }, message: `Would create volume ${name}.` };
|
|
26444
27046
|
}
|
|
26445
27047
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
26446
|
-
const result = await createVolume(gateways.volume, { spaceId, name, description:
|
|
27048
|
+
const result = await createVolume(gateways.volume, { spaceId, name, description: text10(args.description) });
|
|
26447
27049
|
return { result, message: `Created volume ${result.name} (${result.volumeId}).` };
|
|
26448
27050
|
}
|
|
26449
27051
|
})
|
|
@@ -26462,7 +27064,7 @@ function registerVolumeCommands(registry, ctx) {
|
|
|
26462
27064
|
return { result: { dryRun: true, ...target }, message: "Would update the volume." };
|
|
26463
27065
|
}
|
|
26464
27066
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
26465
|
-
return { result: await updateVolume(gateways.volume, { ...target, name:
|
|
27067
|
+
return { result: await updateVolume(gateways.volume, { ...target, name: text10(args.name), description: text10(args.description) }) };
|
|
26466
27068
|
}
|
|
26467
27069
|
})
|
|
26468
27070
|
);
|
|
@@ -26501,8 +27103,8 @@ function registerVolumeCommands(registry, ctx) {
|
|
|
26501
27103
|
examples: ["adp volume ls --space-id sp-1 --volume-id v-1 --path docs --format json"],
|
|
26502
27104
|
async handler(args) {
|
|
26503
27105
|
const target = await ref2(ctx, args);
|
|
26504
|
-
const path14 =
|
|
26505
|
-
const query =
|
|
27106
|
+
const path14 = text10(args.path) ?? "";
|
|
27107
|
+
const query = text10(args.query);
|
|
26506
27108
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
26507
27109
|
const page3 = await listVolumeEntries(gateways.volume, { ...target, path: path14, query, limit: ctx.flags.limit, page: ctx.flags.page });
|
|
26508
27110
|
return applyListShape(
|
|
@@ -26589,10 +27191,10 @@ function registerVolumeCommands(registry, ctx) {
|
|
|
26589
27191
|
const target = await ref2(ctx, args);
|
|
26590
27192
|
const localPath = canonicalizeLocalPath(String(args.file), ctx.flags.cwd);
|
|
26591
27193
|
if (ctx.flags.dryRun) {
|
|
26592
|
-
return { result: { dryRun: true, ...target, file: localPath, to:
|
|
27194
|
+
return { result: { dryRun: true, ...target, file: localPath, to: text10(args.to) }, message: `Would upload ${localPath}.` };
|
|
26593
27195
|
}
|
|
26594
27196
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
26595
|
-
const result = await uploadToVolume(gateways.volume, { ...target, localPath, to:
|
|
27197
|
+
const result = await uploadToVolume(gateways.volume, { ...target, localPath, to: text10(args.to) });
|
|
26596
27198
|
return { result: { volumeId: target.volumeId, ...result }, message: `Uploaded ${result.sizeBytes} bytes to ${result.path}.` };
|
|
26597
27199
|
}
|
|
26598
27200
|
})
|
|
@@ -26608,7 +27210,7 @@ function registerVolumeCommands(registry, ctx) {
|
|
|
26608
27210
|
async handler(args) {
|
|
26609
27211
|
const target = await ref2(ctx, args);
|
|
26610
27212
|
const remote = String(args.path);
|
|
26611
|
-
const localPath = canonicalizeLocalPath(
|
|
27213
|
+
const localPath = canonicalizeLocalPath(text10(args.output) ?? baseName(remote), ctx.flags.cwd);
|
|
26612
27214
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
26613
27215
|
const result = await downloadFromVolume(gateways.volume, { ...target, path: remote, localPath });
|
|
26614
27216
|
return { result, message: `Saved ${result.bytes} bytes to ${result.output}.` };
|
|
@@ -26935,14 +27537,14 @@ async function updateSynonym(gateway, input) {
|
|
|
26935
27537
|
return { appId: input.appId, synonymId: input.synonymId, standardWord, synonyms: finalSynonyms };
|
|
26936
27538
|
}
|
|
26937
27539
|
function batch2(ids4) {
|
|
26938
|
-
const
|
|
26939
|
-
if (
|
|
27540
|
+
const unique3 = [...new Set(ids4)];
|
|
27541
|
+
if (unique3.length === 0) {
|
|
26940
27542
|
throw new DomainError("Pass --synonym-id at least once", "usage", "UsageError");
|
|
26941
27543
|
}
|
|
26942
|
-
if (
|
|
27544
|
+
if (unique3.length > BATCH_MAX2) {
|
|
26943
27545
|
throw new DomainError(`At most ${BATCH_MAX2} synonyms per call`, "usage", "UsageError");
|
|
26944
27546
|
}
|
|
26945
|
-
return
|
|
27547
|
+
return unique3;
|
|
26946
27548
|
}
|
|
26947
27549
|
function settle2(result, appId3, verb) {
|
|
26948
27550
|
if (result.succeeded.length === 0 && result.failed.length > 0) {
|
|
@@ -27076,7 +27678,7 @@ var filterFlags = [
|
|
|
27076
27678
|
{ name: "category-id", type: "string", describe: "Only this category" },
|
|
27077
27679
|
{ name: "unreleased", type: "boolean", describe: "Only entries not yet released", default: false }
|
|
27078
27680
|
];
|
|
27079
|
-
function
|
|
27681
|
+
function text11(args, key) {
|
|
27080
27682
|
const value = args[key];
|
|
27081
27683
|
return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
|
|
27082
27684
|
}
|
|
@@ -27089,7 +27691,7 @@ function ids3(args, key) {
|
|
|
27089
27691
|
return list3(args, key).map((id) => assertResourceId(id, key));
|
|
27090
27692
|
}
|
|
27091
27693
|
function categoryId(args) {
|
|
27092
|
-
const id =
|
|
27694
|
+
const id = text11(args, "category-id");
|
|
27093
27695
|
return id ? assertResourceId(id, "category-id") : void 0;
|
|
27094
27696
|
}
|
|
27095
27697
|
async function guarded6(ref3, run) {
|
|
@@ -27099,7 +27701,7 @@ async function guarded6(ref3, run) {
|
|
|
27099
27701
|
throw explainSynonymError(error, ref3);
|
|
27100
27702
|
}
|
|
27101
27703
|
}
|
|
27102
|
-
function
|
|
27704
|
+
function exportMessage2(result, what) {
|
|
27103
27705
|
if (result.status === "submitted") {
|
|
27104
27706
|
return `${what} export submitted; the file appears in the console notice center.`;
|
|
27105
27707
|
}
|
|
@@ -27121,7 +27723,7 @@ function registerSynonymCommands(registry, ctx) {
|
|
|
27121
27723
|
appId: appId3,
|
|
27122
27724
|
limit: ctx.flags.limit,
|
|
27123
27725
|
page: ctx.flags.page,
|
|
27124
|
-
query:
|
|
27726
|
+
query: text11(args, "query"),
|
|
27125
27727
|
categoryId: categoryId(args),
|
|
27126
27728
|
unreleasedOnly: args.unreleased === true
|
|
27127
27729
|
});
|
|
@@ -27148,7 +27750,7 @@ function registerSynonymCommands(registry, ctx) {
|
|
|
27148
27750
|
examples: ["adp synonym create --app-id app-1 --word \u53EF\u53E3\u53EF\u4E50 --synonym \u53EF\u4E50 --synonym coke"],
|
|
27149
27751
|
async handler(args) {
|
|
27150
27752
|
const appId3 = await resolveAppId(ctx, args, WHY_APP7);
|
|
27151
|
-
const input = { appId: appId3, standardWord:
|
|
27753
|
+
const input = { appId: appId3, standardWord: text11(args, "word") ?? "", synonyms: list3(args, "synonym"), categoryId: categoryId(args) };
|
|
27152
27754
|
if (ctx.flags.dryRun) {
|
|
27153
27755
|
return { result: { dryRun: true, ...input }, message: `Would add synonym ${input.standardWord}.` };
|
|
27154
27756
|
}
|
|
@@ -27175,7 +27777,7 @@ function registerSynonymCommands(registry, ctx) {
|
|
|
27175
27777
|
const appId3 = await resolveAppId(ctx, args, WHY_APP7);
|
|
27176
27778
|
const synonymId = assertResourceId(String(args["synonym-id"]), "synonym-id");
|
|
27177
27779
|
const synonyms = list3(args, "synonym");
|
|
27178
|
-
const input = { appId: appId3, synonymId, standardWord:
|
|
27780
|
+
const input = { appId: appId3, synonymId, standardWord: text11(args, "word"), synonyms: synonyms.length > 0 ? synonyms : void 0 };
|
|
27179
27781
|
if (ctx.flags.dryRun) {
|
|
27180
27782
|
return { result: { dryRun: true, ...input }, message: `Would update synonym ${synonymId}.` };
|
|
27181
27783
|
}
|
|
@@ -27257,11 +27859,11 @@ function registerSynonymCommands(registry, ctx) {
|
|
|
27257
27859
|
examples: ["adp synonym category create --app-id app-1 --name \u996E\u6599"],
|
|
27258
27860
|
async handler(args) {
|
|
27259
27861
|
const appId3 = await resolveAppId(ctx, args, WHY_APP7);
|
|
27260
|
-
const name =
|
|
27862
|
+
const name = text11(args, "name");
|
|
27261
27863
|
if (!name) {
|
|
27262
27864
|
throw new DomainError("Missing --name", "usage", "UsageError");
|
|
27263
27865
|
}
|
|
27264
|
-
const parentId =
|
|
27866
|
+
const parentId = text11(args, "parent-id") ? assertResourceId(String(args["parent-id"]), "parent-id") : ROOT_CATEGORY_ID;
|
|
27265
27867
|
if (ctx.flags.dryRun) {
|
|
27266
27868
|
return { result: { dryRun: true, appId: appId3, name, parentId }, message: `Would create category ${name}.` };
|
|
27267
27869
|
}
|
|
@@ -27286,7 +27888,7 @@ function registerSynonymCommands(registry, ctx) {
|
|
|
27286
27888
|
async handler(args) {
|
|
27287
27889
|
const appId3 = await resolveAppId(ctx, args, WHY_APP7);
|
|
27288
27890
|
const id = assertResourceId(String(args["category-id"]), "category-id");
|
|
27289
|
-
const name =
|
|
27891
|
+
const name = text11(args, "name");
|
|
27290
27892
|
if (!name) {
|
|
27291
27893
|
throw new DomainError("Missing --name", "usage", "UsageError");
|
|
27292
27894
|
}
|
|
@@ -27335,8 +27937,8 @@ function registerSynonymCommands(registry, ctx) {
|
|
|
27335
27937
|
examples: ["adp synonym export --app-id app-1 --output ./synonyms.xlsx"],
|
|
27336
27938
|
async handler(args) {
|
|
27337
27939
|
const appId3 = await resolveAppId(ctx, args, WHY_APP7);
|
|
27338
|
-
const output =
|
|
27339
|
-
const input = { appId: appId3, query:
|
|
27940
|
+
const output = text11(args, "output") ? canonicalizeLocalPath(String(args.output), ctx.flags.cwd) : void 0;
|
|
27941
|
+
const input = { appId: appId3, query: text11(args, "query"), categoryId: categoryId(args), unreleasedOnly: args.unreleased === true };
|
|
27340
27942
|
if (ctx.flags.dryRun) {
|
|
27341
27943
|
return { result: { dryRun: true, ...input, output }, message: "Would export synonyms." };
|
|
27342
27944
|
}
|
|
@@ -27345,7 +27947,7 @@ function registerSynonymCommands(registry, ctx) {
|
|
|
27345
27947
|
{ synonyms: gateways.synonym, downloader: gateways.packageDownloader },
|
|
27346
27948
|
{ ...input, output, wait: args.wait !== false }
|
|
27347
27949
|
);
|
|
27348
|
-
return { result, message:
|
|
27950
|
+
return { result, message: exportMessage2(result, "Synonyms") };
|
|
27349
27951
|
}
|
|
27350
27952
|
})
|
|
27351
27953
|
);
|
|
@@ -27462,7 +28064,7 @@ var filterFlags2 = [
|
|
|
27462
28064
|
{ name: "reason", type: "string", describe: "Reason label, repeatable" },
|
|
27463
28065
|
{ name: "status", type: "string", describe: "Handling status, repeatable", choices: Object.keys(UNSATISFIED_STATUS_FILTERS) }
|
|
27464
28066
|
];
|
|
27465
|
-
function
|
|
28067
|
+
function text12(args, key) {
|
|
27466
28068
|
const value = args[key];
|
|
27467
28069
|
return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
|
|
27468
28070
|
}
|
|
@@ -27473,7 +28075,7 @@ function list4(args, key) {
|
|
|
27473
28075
|
}
|
|
27474
28076
|
function filters5(args) {
|
|
27475
28077
|
return {
|
|
27476
|
-
query:
|
|
28078
|
+
query: text12(args, "query"),
|
|
27477
28079
|
reasons: list4(args, "reason"),
|
|
27478
28080
|
statuses: list4(args, "status").map((status) => UNSATISFIED_STATUS_FILTERS[status])
|
|
27479
28081
|
};
|
|
@@ -27564,7 +28166,7 @@ function registerUnsatisfiedCommands(registry, ctx) {
|
|
|
27564
28166
|
examples: ["adp unsatisfied export --app-id app-1 --status pending --output ./unsatisfied.xlsx"],
|
|
27565
28167
|
async handler(args) {
|
|
27566
28168
|
const appId3 = await resolveAppId(ctx, args, WHY_APP8);
|
|
27567
|
-
const output =
|
|
28169
|
+
const output = text12(args, "output") ? canonicalizeLocalPath(String(args.output), ctx.flags.cwd) : void 0;
|
|
27568
28170
|
const input = { appId: appId3, ...filters5(args), replyIds: list4(args, "reply-id").map((id) => assertResourceId(id, "reply-id")) };
|
|
27569
28171
|
if (ctx.flags.dryRun) {
|
|
27570
28172
|
return { result: { dryRun: true, ...input, output }, message: "Would export unsatisfied replies." };
|
|
@@ -27574,7 +28176,7 @@ function registerUnsatisfiedCommands(registry, ctx) {
|
|
|
27574
28176
|
{ unsatisfied: gateways.unsatisfied, downloader: gateways.packageDownloader },
|
|
27575
28177
|
{ ...input, output, wait: args.wait !== false }
|
|
27576
28178
|
);
|
|
27577
|
-
return { result, message:
|
|
28179
|
+
return { result, message: exportMessage2(result, "Unsatisfied replies") };
|
|
27578
28180
|
}
|
|
27579
28181
|
})
|
|
27580
28182
|
);
|
|
@@ -27609,8 +28211,8 @@ function registerUnsatisfiedCommands(registry, ctx) {
|
|
|
27609
28211
|
examples: ["adp unsatisfied label create --app-id app-1 --group \u7406\u89E3\u6709\u8BEF --name \u6F0F\u770B\u9644\u4EF6"],
|
|
27610
28212
|
async handler(args) {
|
|
27611
28213
|
const appId3 = await resolveAppId(ctx, args, WHY_APP8);
|
|
27612
|
-
const groupName =
|
|
27613
|
-
const labelName =
|
|
28214
|
+
const groupName = text12(args, "group");
|
|
28215
|
+
const labelName = text12(args, "name");
|
|
27614
28216
|
if (!groupName || !labelName) {
|
|
27615
28217
|
throw new DomainError("Missing --group or --name", "usage", "UsageError");
|
|
27616
28218
|
}
|
|
@@ -27638,7 +28240,7 @@ function registerUnsatisfiedCommands(registry, ctx) {
|
|
|
27638
28240
|
examples: ["adp unsatisfied label update --app-id app-1 --label-id l-1 --name \u6F0F\u770B\u56FE\u7247"],
|
|
27639
28241
|
async handler(args) {
|
|
27640
28242
|
const appId3 = await resolveAppId(ctx, args, WHY_APP8);
|
|
27641
|
-
const input = { appId: appId3, labelId: assertResourceId(String(args["label-id"]), "label-id"), groupName:
|
|
28243
|
+
const input = { appId: appId3, labelId: assertResourceId(String(args["label-id"]), "label-id"), groupName: text12(args, "group"), labelName: text12(args, "name") };
|
|
27642
28244
|
if (ctx.flags.dryRun) {
|
|
27643
28245
|
return { result: { dryRun: true, ...input }, message: `Would update label ${input.labelId}.` };
|
|
27644
28246
|
}
|
|
@@ -27743,9 +28345,9 @@ async function getDocContent(gateway, input) {
|
|
|
27743
28345
|
};
|
|
27744
28346
|
}
|
|
27745
28347
|
var HEADING = /^(#{1,6})\s+(.+?)\s*#*\s*$/;
|
|
27746
|
-
function extractSection(
|
|
28348
|
+
function extractSection(text13, section, documentId) {
|
|
27747
28349
|
const wanted = section.trim().toLowerCase();
|
|
27748
|
-
const lines =
|
|
28350
|
+
const lines = text13.split("\n");
|
|
27749
28351
|
const start = lines.findIndex((line) => HEADING.exec(line)?.[2]?.trim().toLowerCase() === wanted);
|
|
27750
28352
|
if (start < 0) {
|
|
27751
28353
|
throw notFoundError(
|
|
@@ -28468,12 +29070,12 @@ async function runCli(options) {
|
|
|
28468
29070
|
});
|
|
28469
29071
|
try {
|
|
28470
29072
|
const helpText = await new Promise((resolve, reject) => {
|
|
28471
|
-
parser.parse(argv, (error, _parsed,
|
|
29073
|
+
parser.parse(argv, (error, _parsed, text13) => {
|
|
28472
29074
|
if (error && exitCode === ExitCode.OK && !(error instanceof DomainError)) {
|
|
28473
29075
|
reject(error);
|
|
28474
29076
|
return;
|
|
28475
29077
|
}
|
|
28476
|
-
resolve(
|
|
29078
|
+
resolve(text13 ?? "");
|
|
28477
29079
|
});
|
|
28478
29080
|
});
|
|
28479
29081
|
if (helpText && exitCode === ExitCode.OK) {
|