@tencentcloudadp/cli 0.1.2 → 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 +943 -356
- 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 +23 -8
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);
|
|
@@ -2024,16 +2025,16 @@ function profileFileName(name) {
|
|
|
2024
2025
|
function createProfileStore(dir = adpProfilesDir(), activePath = adpActiveProfilePath()) {
|
|
2025
2026
|
return {
|
|
2026
2027
|
async load(name) {
|
|
2027
|
-
let
|
|
2028
|
+
let text13;
|
|
2028
2029
|
try {
|
|
2029
|
-
|
|
2030
|
+
text13 = await readFile(path.join(dir, profileFileName(name)), "utf8");
|
|
2030
2031
|
} catch (error) {
|
|
2031
2032
|
if (error.code === "ENOENT") {
|
|
2032
2033
|
return void 0;
|
|
2033
2034
|
}
|
|
2034
2035
|
throw error;
|
|
2035
2036
|
}
|
|
2036
|
-
return parseProfile(name,
|
|
2037
|
+
return parseProfile(name, text13);
|
|
2037
2038
|
},
|
|
2038
2039
|
async save(profile) {
|
|
2039
2040
|
await mkdir(dir, { recursive: true });
|
|
@@ -2072,16 +2073,16 @@ function createProfileStore(dir = adpProfilesDir(), activePath = adpActiveProfil
|
|
|
2072
2073
|
return profiles;
|
|
2073
2074
|
},
|
|
2074
2075
|
async active() {
|
|
2075
|
-
let
|
|
2076
|
+
let text13;
|
|
2076
2077
|
try {
|
|
2077
|
-
|
|
2078
|
+
text13 = await readFile(activePath, "utf8");
|
|
2078
2079
|
} catch (error) {
|
|
2079
2080
|
if (error.code === "ENOENT") {
|
|
2080
2081
|
return void 0;
|
|
2081
2082
|
}
|
|
2082
2083
|
throw error;
|
|
2083
2084
|
}
|
|
2084
|
-
const name =
|
|
2085
|
+
const name = text13.trim();
|
|
2085
2086
|
return name.length > 0 ? name : void 0;
|
|
2086
2087
|
},
|
|
2087
2088
|
async setActive(name) {
|
|
@@ -2093,10 +2094,10 @@ function createProfileStore(dir = adpProfilesDir(), activePath = adpActiveProfil
|
|
|
2093
2094
|
}
|
|
2094
2095
|
};
|
|
2095
2096
|
}
|
|
2096
|
-
function parseProfile(name,
|
|
2097
|
+
function parseProfile(name, text13) {
|
|
2097
2098
|
let raw;
|
|
2098
2099
|
try {
|
|
2099
|
-
raw = JSON.parse(
|
|
2100
|
+
raw = JSON.parse(text13);
|
|
2100
2101
|
} catch {
|
|
2101
2102
|
return void 0;
|
|
2102
2103
|
}
|
|
@@ -2762,7 +2763,8 @@ function createAppPackageGateway(clients) {
|
|
|
2762
2763
|
const response = await callSdk(
|
|
2763
2764
|
() => clients.adp.request("ExportApp", {
|
|
2764
2765
|
AppId: input.appId,
|
|
2765
|
-
...input.releaseId ? { ReleaseId: input.releaseId } : {}
|
|
2766
|
+
...input.releaseId ? { ReleaseId: input.releaseId } : {},
|
|
2767
|
+
Summary: toExportSummary(input.summary, input.appId)
|
|
2766
2768
|
})
|
|
2767
2769
|
);
|
|
2768
2770
|
return { taskId: str(response.TaskId) };
|
|
@@ -2838,19 +2840,23 @@ var COMPONENT_LISTS = [
|
|
|
2838
2840
|
["PluginList", "plugin"],
|
|
2839
2841
|
["SkillList", "skill"]
|
|
2840
2842
|
];
|
|
2843
|
+
var COMPONENT_TYPE = {
|
|
2844
|
+
kb: 2,
|
|
2845
|
+
workflow: 3,
|
|
2846
|
+
agent: 4,
|
|
2847
|
+
plugin: 5,
|
|
2848
|
+
skill: 6
|
|
2849
|
+
};
|
|
2841
2850
|
function toSummary3(summary, appId3) {
|
|
2842
2851
|
const config2 = asRecord2(summary.AppConfig);
|
|
2843
2852
|
const components = [];
|
|
2844
2853
|
for (const [key, kind2] of COMPONENT_LISTS) {
|
|
2845
2854
|
const list5 = Array.isArray(summary[key]) ? summary[key] : [];
|
|
2846
2855
|
for (const item of list5) {
|
|
2847
|
-
const component = asRecord2(item);
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
name: str(component.Name) || void 0,
|
|
2852
|
-
updateTime: num(component.UpdateTime)
|
|
2853
|
-
});
|
|
2856
|
+
const component = toComponent(asRecord2(item), kind2);
|
|
2857
|
+
if (component.id) {
|
|
2858
|
+
components.push(component);
|
|
2859
|
+
}
|
|
2854
2860
|
}
|
|
2855
2861
|
}
|
|
2856
2862
|
return {
|
|
@@ -2858,9 +2864,84 @@ function toSummary3(summary, appId3) {
|
|
|
2858
2864
|
appName: str(config2.AppName) || void 0,
|
|
2859
2865
|
releaseId: str(config2.ReleaseId) || void 0,
|
|
2860
2866
|
releaseVersion: str(config2.ReleaseVersion) || void 0,
|
|
2867
|
+
updateTime: num(config2.UpdateTime),
|
|
2861
2868
|
components
|
|
2862
2869
|
};
|
|
2863
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
|
+
}
|
|
2864
2945
|
function toExportNotices(response) {
|
|
2865
2946
|
const byId = /* @__PURE__ */ new Map();
|
|
2866
2947
|
for (const key of ["PageNotifyList", "CursorNotifyList", "CenterNotifyList"]) {
|
|
@@ -4804,14 +4885,14 @@ function createUsageGateway(client) {
|
|
|
4804
4885
|
const response = await callSdk(
|
|
4805
4886
|
() => client.request("DescribeMsgRecordList", { AppId: input.appId, ...pageParams(input.limit, input.page) })
|
|
4806
4887
|
);
|
|
4807
|
-
const
|
|
4888
|
+
const text13 = (value) => typeof value === "string" && value ? value : void 0;
|
|
4808
4889
|
return readPagedList(response, ["MsgRecordList", "RecordList"], (raw) => ({
|
|
4809
|
-
recordId:
|
|
4810
|
-
conversationId:
|
|
4811
|
-
question:
|
|
4812
|
-
answer:
|
|
4813
|
-
categoryId:
|
|
4814
|
-
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)
|
|
4815
4896
|
}));
|
|
4816
4897
|
}
|
|
4817
4898
|
};
|
|
@@ -5444,13 +5525,13 @@ function toTrace(raw) {
|
|
|
5444
5525
|
}
|
|
5445
5526
|
function toContent(raw) {
|
|
5446
5527
|
const content = { type: String(raw.Type ?? "") };
|
|
5447
|
-
const
|
|
5528
|
+
const text13 = optionalString8(raw.Text);
|
|
5448
5529
|
const references = readList(raw, ["ReferenceList", "References"]).flatMap((item) => toReference(asRecord2(item)));
|
|
5449
5530
|
const quoteInfos = readList(raw, ["QuoteInfoList", "QuoteInfos"]).flatMap((item) => toQuote(asRecord2(item)));
|
|
5450
5531
|
const tasks = readList(raw, ["TaskList", "Tasks"]).flatMap((item) => toTask2(asRecord2(item)));
|
|
5451
5532
|
const mcpApp = toMcpApp(asRecord2(raw.McpApp));
|
|
5452
|
-
if (
|
|
5453
|
-
content.text =
|
|
5533
|
+
if (text13) {
|
|
5534
|
+
content.text = text13;
|
|
5454
5535
|
}
|
|
5455
5536
|
if (references.length > 0) {
|
|
5456
5537
|
content.references = references;
|
|
@@ -6174,17 +6255,17 @@ function optionalString10(value) {
|
|
|
6174
6255
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
6175
6256
|
}
|
|
6176
6257
|
function optionalTime(value) {
|
|
6177
|
-
const
|
|
6178
|
-
if (
|
|
6258
|
+
const text13 = typeof value === "number" && Number.isFinite(value) ? String(value) : optionalString10(value);
|
|
6259
|
+
if (text13 === void 0) {
|
|
6179
6260
|
return void 0;
|
|
6180
6261
|
}
|
|
6181
|
-
return isGoZeroTime(
|
|
6262
|
+
return isGoZeroTime(text13) ? null : text13;
|
|
6182
6263
|
}
|
|
6183
|
-
function isGoZeroTime(
|
|
6184
|
-
if (
|
|
6264
|
+
function isGoZeroTime(text13) {
|
|
6265
|
+
if (text13.startsWith("0001-01-01")) {
|
|
6185
6266
|
return true;
|
|
6186
6267
|
}
|
|
6187
|
-
const seconds2 = Number(
|
|
6268
|
+
const seconds2 = Number(text13);
|
|
6188
6269
|
return Number.isFinite(seconds2) && seconds2 <= 0;
|
|
6189
6270
|
}
|
|
6190
6271
|
function optionalNumber5(value) {
|
|
@@ -6516,8 +6597,8 @@ function optionalNumber6(value) {
|
|
|
6516
6597
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
6517
6598
|
}
|
|
6518
6599
|
function optionalId(value) {
|
|
6519
|
-
const
|
|
6520
|
-
return
|
|
6600
|
+
const text13 = value === void 0 || value === null ? "" : String(value);
|
|
6601
|
+
return text13.length > 0 && text13 !== "0" ? text13 : void 0;
|
|
6521
6602
|
}
|
|
6522
6603
|
function toSummary13(raw) {
|
|
6523
6604
|
const spec = asRecord2(raw.Spec);
|
|
@@ -6712,9 +6793,9 @@ import { chmod as chmod2, mkdir as mkdir2, readFile as readFile3, rm as rm2, wri
|
|
|
6712
6793
|
import path3 from "path";
|
|
6713
6794
|
|
|
6714
6795
|
// src/infrastructure/fs/ini-credentials.ts
|
|
6715
|
-
function parseIni(
|
|
6796
|
+
function parseIni(text13) {
|
|
6716
6797
|
const result = {};
|
|
6717
|
-
for (const rawLine of
|
|
6798
|
+
for (const rawLine of text13.split(/\r?\n/)) {
|
|
6718
6799
|
const line = rawLine.trim();
|
|
6719
6800
|
if (!line || line.startsWith("#") || line.startsWith(";") || line.startsWith("[")) {
|
|
6720
6801
|
continue;
|
|
@@ -6756,8 +6837,8 @@ function createCredentialFileStore(filePath, source2) {
|
|
|
6756
6837
|
return {
|
|
6757
6838
|
async load() {
|
|
6758
6839
|
try {
|
|
6759
|
-
const
|
|
6760
|
-
const parsed = parseIni(
|
|
6840
|
+
const text13 = await readFile3(filePath, "utf8");
|
|
6841
|
+
const parsed = parseIni(text13);
|
|
6761
6842
|
const secretId = parsed.secret_id ?? parsed.secretid;
|
|
6762
6843
|
const secretKey = parsed.secret_key ?? parsed.secretkey;
|
|
6763
6844
|
if (!secretId || !secretKey) {
|
|
@@ -7239,9 +7320,9 @@ function unknownConfigFields(parsed) {
|
|
|
7239
7320
|
return Object.keys(parsed).filter((key) => !known.has(key));
|
|
7240
7321
|
}
|
|
7241
7322
|
async function readConfigFile(configPath) {
|
|
7242
|
-
let
|
|
7323
|
+
let text13;
|
|
7243
7324
|
try {
|
|
7244
|
-
|
|
7325
|
+
text13 = await readFile4(configPath, "utf8");
|
|
7245
7326
|
} catch {
|
|
7246
7327
|
throw new DomainError(`Config not found: ${configPath}`, "usage", "UsageError", {
|
|
7247
7328
|
hint: "Run: adp init or pass --config path/to/adp.jsonc",
|
|
@@ -7254,7 +7335,7 @@ async function readConfigFile(configPath) {
|
|
|
7254
7335
|
]
|
|
7255
7336
|
});
|
|
7256
7337
|
}
|
|
7257
|
-
const parsed = parseJsonc(
|
|
7338
|
+
const parsed = parseJsonc(text13);
|
|
7258
7339
|
const result = adpConfigSchema.safeParse(parsed);
|
|
7259
7340
|
if (!result.success) {
|
|
7260
7341
|
throw usageError(
|
|
@@ -7273,16 +7354,16 @@ async function readConfigFile(configPath) {
|
|
|
7273
7354
|
return { config: fileToAdpConfig(result.data), warnings };
|
|
7274
7355
|
}
|
|
7275
7356
|
async function readOptionalConfig(configPath) {
|
|
7276
|
-
let
|
|
7357
|
+
let text13;
|
|
7277
7358
|
try {
|
|
7278
|
-
|
|
7359
|
+
text13 = await readFile4(configPath, "utf8");
|
|
7279
7360
|
} catch (error) {
|
|
7280
7361
|
if (error.code === "ENOENT") {
|
|
7281
7362
|
return void 0;
|
|
7282
7363
|
}
|
|
7283
7364
|
throw error;
|
|
7284
7365
|
}
|
|
7285
|
-
const parsed = parseJsonc(
|
|
7366
|
+
const parsed = parseJsonc(text13);
|
|
7286
7367
|
if (!parsed || typeof parsed !== "object") {
|
|
7287
7368
|
return void 0;
|
|
7288
7369
|
}
|
|
@@ -8052,8 +8133,8 @@ function str12(value) {
|
|
|
8052
8133
|
return typeof value === "string" || typeof value === "number" ? String(value) : "";
|
|
8053
8134
|
}
|
|
8054
8135
|
function opt(value) {
|
|
8055
|
-
const
|
|
8056
|
-
return
|
|
8136
|
+
const text13 = str12(value);
|
|
8137
|
+
return text13 === "" ? void 0 : text13;
|
|
8057
8138
|
}
|
|
8058
8139
|
function num6(value) {
|
|
8059
8140
|
if (typeof value === "number") {
|
|
@@ -10343,21 +10424,21 @@ function parseDocContent(payload, documentId, productId) {
|
|
|
10343
10424
|
}
|
|
10344
10425
|
const markdown = stringField(content, ["markdown", "Markdown"]) ?? stringField(record, ["markdown", "Markdown"]);
|
|
10345
10426
|
const html = stringField(content, ["body", "html", "HTML", "content"]) ?? stringField(record, ["body", "html", "HTML"]);
|
|
10346
|
-
const
|
|
10427
|
+
const text13 = markdown && markdown.trim() || htmlToText(html ?? "");
|
|
10347
10428
|
return {
|
|
10348
10429
|
documentId: stringField(record, ["id"]) ?? documentId,
|
|
10349
10430
|
title,
|
|
10350
10431
|
keyword: stringField(record, ["keywords", "keyword", "Keywords"]) ?? stringField(content, ["keywords", "keyword"]),
|
|
10351
10432
|
url: documentUrl(productId, documentId),
|
|
10352
|
-
text:
|
|
10433
|
+
text: text13
|
|
10353
10434
|
};
|
|
10354
10435
|
}
|
|
10355
10436
|
function stripSnippetHtml(value) {
|
|
10356
10437
|
if (!value) {
|
|
10357
10438
|
return void 0;
|
|
10358
10439
|
}
|
|
10359
|
-
const
|
|
10360
|
-
return
|
|
10440
|
+
const text13 = value.replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim();
|
|
10441
|
+
return text13 || void 0;
|
|
10361
10442
|
}
|
|
10362
10443
|
function htmlToText(html) {
|
|
10363
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();
|
|
@@ -12951,15 +13032,15 @@ function registerDevCommands(registry, ctx) {
|
|
|
12951
13032
|
);
|
|
12952
13033
|
}
|
|
12953
13034
|
function assertOptionalId(value, name) {
|
|
12954
|
-
const
|
|
12955
|
-
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);
|
|
12956
13037
|
}
|
|
12957
13038
|
function isFollowUpQuestion(reply) {
|
|
12958
|
-
const
|
|
12959
|
-
if (!
|
|
13039
|
+
const text13 = reply?.trim();
|
|
13040
|
+
if (!text13) {
|
|
12960
13041
|
return false;
|
|
12961
13042
|
}
|
|
12962
|
-
return /[??]$/.test(
|
|
13043
|
+
return /[??]$/.test(text13) || /请(提供|输入|告诉|问|补充|说明|选择)/.test(text13);
|
|
12963
13044
|
}
|
|
12964
13045
|
function optionalString13(value) {
|
|
12965
13046
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
@@ -13628,19 +13709,220 @@ function findInZip(zip, suffix, depth = 1) {
|
|
|
13628
13709
|
}
|
|
13629
13710
|
return void 0;
|
|
13630
13711
|
}
|
|
13712
|
+
var EMPTY_INVENTORY = {
|
|
13713
|
+
readable: false,
|
|
13714
|
+
workflowIds: [],
|
|
13715
|
+
hasKnowledgeBases: false,
|
|
13716
|
+
knowledgeBases: []
|
|
13717
|
+
};
|
|
13631
13718
|
function createAppPackageReader() {
|
|
13632
13719
|
return {
|
|
13633
13720
|
async sourceAppId(file) {
|
|
13634
|
-
|
|
13635
|
-
|
|
13636
|
-
|
|
13637
|
-
|
|
13638
|
-
|
|
13639
|
-
|
|
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;
|
|
13640
13906
|
}
|
|
13641
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) }))
|
|
13642
13913
|
};
|
|
13643
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
|
+
}
|
|
13644
13926
|
|
|
13645
13927
|
// src/application/app/export-app.ts
|
|
13646
13928
|
var POLL_INTERVAL_MS2 = 2e3;
|
|
@@ -13650,7 +13932,22 @@ var TASK_FAILED = 3;
|
|
|
13650
13932
|
var TASK_SCAN = 50;
|
|
13651
13933
|
var NOTICE_GRACE = 8;
|
|
13652
13934
|
async function exportApp(deps, input) {
|
|
13653
|
-
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) => {
|
|
13654
13951
|
if (error instanceof DomainError && error.message.includes("450025")) {
|
|
13655
13952
|
throw new DomainError("The app has no release to export", "not_found", "AppNotReleased", {
|
|
13656
13953
|
hint: "Only released apps can be exported; publish the draft first",
|
|
@@ -13658,21 +13955,32 @@ async function exportApp(deps, input) {
|
|
|
13658
13955
|
cause: error,
|
|
13659
13956
|
nextActions: [
|
|
13660
13957
|
{
|
|
13661
|
-
command: `adp versions --app-id ${
|
|
13958
|
+
command: `adp versions --app-id ${appId3} --format json`,
|
|
13662
13959
|
reason: "no release yet: publish the draft (adp deploy from the project, or the console), then export again"
|
|
13663
13960
|
}
|
|
13664
13961
|
]
|
|
13665
13962
|
});
|
|
13666
13963
|
}
|
|
13667
13964
|
throw error;
|
|
13668
|
-
}
|
|
13669
|
-
|
|
13670
|
-
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
|
|
13674
|
-
|
|
13675
|
-
|
|
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
|
+
};
|
|
13676
13984
|
}
|
|
13677
13985
|
async function fetchAppPackage(deps, input) {
|
|
13678
13986
|
const sleep = deps.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
@@ -13751,7 +14059,7 @@ var STATUS_IMPORTING = 4;
|
|
|
13751
14059
|
var SINGLE_WORKFLOW_MODE = 3;
|
|
13752
14060
|
function singleWorkflowFollowUp(appId3, spaceId, sourceAppId, entryWorkflowId) {
|
|
13753
14061
|
const warnings = [
|
|
13754
|
-
"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."
|
|
13755
14063
|
];
|
|
13756
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`;
|
|
13757
14065
|
if (!sourceAppId) {
|
|
@@ -13794,57 +14102,72 @@ function singleWorkflowFollowUp(appId3, spaceId, sourceAppId, entryWorkflowId) {
|
|
|
13794
14102
|
]
|
|
13795
14103
|
};
|
|
13796
14104
|
}
|
|
13797
|
-
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
|
+
}
|
|
13798
14111
|
const warnings = [
|
|
13799
|
-
"
|
|
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."
|
|
13800
14113
|
];
|
|
13801
14114
|
const docs = {
|
|
13802
14115
|
command: `adp kb doc list --kb-id ${sourceAppId ?? appId3} --format json`,
|
|
13803
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`
|
|
13804
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) {
|
|
13805
14123
|
if (!sourceAppId) {
|
|
13806
|
-
return
|
|
13807
|
-
|
|
13808
|
-
|
|
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 [
|
|
13809
14135
|
{
|
|
13810
|
-
command: `adp workflow
|
|
13811
|
-
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)"}`
|
|
13812
14138
|
},
|
|
13813
|
-
|
|
13814
|
-
|
|
13815
|
-
|
|
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
|
+
});
|
|
13816
14145
|
}
|
|
13817
|
-
|
|
13818
|
-
|
|
13819
|
-
|
|
13820
|
-
|
|
13821
|
-
|
|
13822
|
-
|
|
13823
|
-
|
|
13824
|
-
|
|
13825
|
-
|
|
13826
|
-
|
|
13827
|
-
|
|
13828
|
-
|
|
13829
|
-
|
|
13830
|
-
|
|
13831
|
-
|
|
13832
|
-
|
|
13833
|
-
|
|
13834
|
-
|
|
13835
|
-
|
|
13836
|
-
|
|
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
|
+
});
|
|
13837
14169
|
}
|
|
13838
|
-
return {
|
|
13839
|
-
warnings,
|
|
13840
|
-
nextActions: [
|
|
13841
|
-
{
|
|
13842
|
-
command: `adp workflow list --app-id ${sourceAppId} --fields workflowId,name,status,isEnable --format json`,
|
|
13843
|
-
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`
|
|
13844
|
-
},
|
|
13845
|
-
docs
|
|
13846
|
-
]
|
|
13847
|
-
};
|
|
14170
|
+
return { warnings, nextActions };
|
|
13848
14171
|
}
|
|
13849
14172
|
function zipName(workflow) {
|
|
13850
14173
|
const name = (workflow.name ?? "").replace(/[^\w.-]+/g, "_").replace(/^_+|_+$/g, "");
|
|
@@ -13901,8 +14224,15 @@ async function importApp(deps, input) {
|
|
|
13901
14224
|
await sleep(POLL_INTERVAL_MS3);
|
|
13902
14225
|
const app = pickImported((await recent()).filter((a) => !before.has(a.appId)), taskId);
|
|
13903
14226
|
if (app && app.status !== STATUS_IMPORTING) {
|
|
13904
|
-
const
|
|
13905
|
-
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
|
+
);
|
|
13906
14236
|
return {
|
|
13907
14237
|
...base,
|
|
13908
14238
|
status: "imported",
|
|
@@ -13911,7 +14241,7 @@ async function importApp(deps, input) {
|
|
|
13911
14241
|
appMode: app.appMode,
|
|
13912
14242
|
appStatus: app.status,
|
|
13913
14243
|
...sourceAppId ? { sourceAppId } : {},
|
|
13914
|
-
warnings: followUp.warnings,
|
|
14244
|
+
...followUp.warnings ? { warnings: followUp.warnings } : {},
|
|
13915
14245
|
nextActions: [
|
|
13916
14246
|
...followUp.nextActions ?? [],
|
|
13917
14247
|
{
|
|
@@ -13927,6 +14257,12 @@ async function importApp(deps, input) {
|
|
|
13927
14257
|
retryable: true
|
|
13928
14258
|
});
|
|
13929
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
|
+
}
|
|
13930
14266
|
function pickImported(fresh, taskId) {
|
|
13931
14267
|
const expected = /^\d+$/.test(taskId) ? (BigInt(taskId) + 1n).toString() : void 0;
|
|
13932
14268
|
return fresh.find((app) => app.appId === expected) ?? (fresh.length === 1 ? fresh[0] : void 0);
|
|
@@ -13993,6 +14329,250 @@ async function resolveAppId(ctx, args, why) {
|
|
|
13993
14329
|
return appId3;
|
|
13994
14330
|
}
|
|
13995
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
|
+
|
|
13996
14576
|
// src/interfaces/cli/commands/app/package.ts
|
|
13997
14577
|
var appIdFlag = { name: "app-id", type: "string", describe: "App ID (default: adp.jsonc app_id)" };
|
|
13998
14578
|
var taskIdFlag = { name: "task-id", type: "string", describe: "Package task ID", required: true };
|
|
@@ -14786,7 +15366,7 @@ warning: ${result.warnings.join("\nwarning: ")}` : ""}`;
|
|
|
14786
15366
|
registry.define(
|
|
14787
15367
|
createCommand({
|
|
14788
15368
|
command: "app export",
|
|
14789
|
-
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",
|
|
14790
15370
|
effects: "idempotent",
|
|
14791
15371
|
outputKind: "data",
|
|
14792
15372
|
flags: [
|
|
@@ -14798,26 +15378,33 @@ warning: ${result.warnings.join("\nwarning: ")}` : ""}`;
|
|
|
14798
15378
|
type: "boolean",
|
|
14799
15379
|
describe: "Wait for the package (--no-wait only submits and returns the task ID)",
|
|
14800
15380
|
default: true
|
|
14801
|
-
}
|
|
15381
|
+
},
|
|
15382
|
+
...EXPORT_SCOPE_FLAGS
|
|
14802
15383
|
],
|
|
14803
15384
|
examples: [
|
|
14804
15385
|
"adp app export --app-id app-1 --output ./app-1.zip",
|
|
14805
|
-
"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",
|
|
14806
15388
|
"adp app export --app-id app-1 --dry-run"
|
|
14807
15389
|
],
|
|
14808
15390
|
async handler(args) {
|
|
14809
15391
|
const appId3 = assertResourceId(await resolveAppId(ctx, args, "app export packages one app"), "app-id");
|
|
14810
15392
|
const releaseId = typeof args["release-id"] === "string" ? assertResourceId(args["release-id"], "release-id") : void 0;
|
|
15393
|
+
const scope = exportScopeFromArgs(args);
|
|
14811
15394
|
if (ctx.flags.dryRun) {
|
|
14812
|
-
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
|
+
};
|
|
14813
15399
|
}
|
|
14814
15400
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
14815
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;
|
|
14816
15403
|
const result = await exportApp(
|
|
14817
15404
|
{ packages: gateways.appPackage, downloader: gateways.packageDownloader },
|
|
14818
|
-
{ appId: appId3, releaseId, output, wait: args.wait !== false }
|
|
15405
|
+
{ appId: appId3, releaseId, output, wait: args.wait !== false, scope, chooseScope }
|
|
14819
15406
|
);
|
|
14820
|
-
const message =
|
|
15407
|
+
const message = exportMessage(appId3, result);
|
|
14821
15408
|
return { result, message };
|
|
14822
15409
|
}
|
|
14823
15410
|
})
|
|
@@ -15179,13 +15766,13 @@ async function toolRef(ctx, args) {
|
|
|
15179
15766
|
};
|
|
15180
15767
|
}
|
|
15181
15768
|
function parseSince(raw) {
|
|
15182
|
-
const
|
|
15183
|
-
if (/^\d+$/.test(
|
|
15184
|
-
return Number(
|
|
15769
|
+
const text13 = String(raw ?? "");
|
|
15770
|
+
if (/^\d+$/.test(text13)) {
|
|
15771
|
+
return Number(text13);
|
|
15185
15772
|
}
|
|
15186
|
-
const ms = Date.parse(
|
|
15773
|
+
const ms = Date.parse(text13);
|
|
15187
15774
|
if (Number.isNaN(ms)) {
|
|
15188
|
-
throw usageError(`Invalid --since ${
|
|
15775
|
+
throw usageError(`Invalid --since ${text13}`, "Use Unix seconds or an ISO date such as 2026-10-01T00:00:00Z");
|
|
15189
15776
|
}
|
|
15190
15777
|
return Math.floor(ms / 1e3);
|
|
15191
15778
|
}
|
|
@@ -15454,7 +16041,7 @@ function followUpAction(conversationId, type, message) {
|
|
|
15454
16041
|
reason: `adp chat cannot write into a type ${type} conversation; read its messages instead`
|
|
15455
16042
|
};
|
|
15456
16043
|
}
|
|
15457
|
-
function
|
|
16044
|
+
function text3(args, name) {
|
|
15458
16045
|
const value = typeof args[name] === "string" ? args[name].trim() : "";
|
|
15459
16046
|
if (!value) {
|
|
15460
16047
|
throw usageError(`--${name} must not be empty`);
|
|
@@ -15509,7 +16096,7 @@ function registerConversationOpsCommands(registry, ctx) {
|
|
|
15509
16096
|
flags: [appIdFlag4, ...conversationFlags, { name: "title", type: "string", describe: "New title", required: true }],
|
|
15510
16097
|
examples: ['adp conversation rename --conversation-id c-1 --title "\u9000\u6B3E\u54A8\u8BE2" --format json'],
|
|
15511
16098
|
async handler(args) {
|
|
15512
|
-
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") };
|
|
15513
16100
|
if (ctx.flags.dryRun) {
|
|
15514
16101
|
return { result: { dryRun: true, ...ref3 }, message: `Would rename ${ref3.conversationId}.` };
|
|
15515
16102
|
}
|
|
@@ -15628,7 +16215,7 @@ function registerConversationOpsCommands(registry, ctx) {
|
|
|
15628
16215
|
examples: ['adp conversation category create --app-id app-1 --name "\u552E\u540E" --format json'],
|
|
15629
16216
|
async handler(args) {
|
|
15630
16217
|
const appId3 = await resolveAppId(ctx, args, WHY_APP3);
|
|
15631
|
-
const name =
|
|
16218
|
+
const name = text3(args, "name");
|
|
15632
16219
|
const parentId = typeof args["parent-id"] === "string" ? assertResourceId(args["parent-id"], "parent-id") : void 0;
|
|
15633
16220
|
if (ctx.flags.dryRun) {
|
|
15634
16221
|
return { result: { dryRun: true, appId: appId3, name, parentId }, message: `Would create category ${name}.` };
|
|
@@ -15648,7 +16235,7 @@ function registerConversationOpsCommands(registry, ctx) {
|
|
|
15648
16235
|
examples: ['adp conversation category update --category-id 12 --name "\u552E\u540E\u670D\u52A1" --format json'],
|
|
15649
16236
|
async handler(args) {
|
|
15650
16237
|
const appId3 = await resolveAppId(ctx, args, WHY_APP3);
|
|
15651
|
-
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") };
|
|
15652
16239
|
if (ctx.flags.dryRun) {
|
|
15653
16240
|
return { result: { dryRun: true, ...input }, message: `Would rename category ${input.categoryId}.` };
|
|
15654
16241
|
}
|
|
@@ -15778,7 +16365,7 @@ async function describeCredentialAccess(gateway, input) {
|
|
|
15778
16365
|
|
|
15779
16366
|
// src/interfaces/cli/commands/references.ts
|
|
15780
16367
|
var appIdFlag5 = { name: "app-id", type: "string", describe: "App ID (defaults to adp.jsonc)" };
|
|
15781
|
-
function
|
|
16368
|
+
function idList2(args, name, max) {
|
|
15782
16369
|
const raw = args[name];
|
|
15783
16370
|
const values = (Array.isArray(raw) ? raw : [raw]).map(String).filter((value) => value.trim() !== "" && value !== "undefined");
|
|
15784
16371
|
if (values.length === 0 || values.length > max) {
|
|
@@ -15828,7 +16415,7 @@ function registerReferenceCommands(registry, ctx) {
|
|
|
15828
16415
|
const input = {
|
|
15829
16416
|
appId: await resolveAppId(ctx, args, "Trigger runs belong to one app"),
|
|
15830
16417
|
triggerId: assertResourceId(String(args["trigger-id"]), "trigger-id"),
|
|
15831
|
-
instanceIds:
|
|
16418
|
+
instanceIds: idList2(args, "instance-id", 100)
|
|
15832
16419
|
};
|
|
15833
16420
|
if (ctx.flags.dryRun) {
|
|
15834
16421
|
return { result: { dryRun: true, ...input }, message: `Would mark ${input.instanceIds.length} run(s) read.` };
|
|
@@ -15851,7 +16438,7 @@ function registerReferenceCommands(registry, ctx) {
|
|
|
15851
16438
|
examples: ["adp kb doc referrers --kb-id kb-1 --doc-id doc-1 --doc-id doc-2 --format json"],
|
|
15852
16439
|
async handler(args) {
|
|
15853
16440
|
const kbId = assertResourceId(String(args["kb-id"]), "kb-id");
|
|
15854
|
-
const items = await listDocReferrers((await gateways()).knowledgeReferrer, { kbId, docIds:
|
|
16441
|
+
const items = await listDocReferrers((await gateways()).knowledgeReferrer, { kbId, docIds: idList2(args, "doc-id", 50) });
|
|
15855
16442
|
return { result: { kbId, items } };
|
|
15856
16443
|
}
|
|
15857
16444
|
})
|
|
@@ -16089,14 +16676,14 @@ function instant(raw, name, endOfDay) {
|
|
|
16089
16676
|
if (raw === void 0 || raw === "") {
|
|
16090
16677
|
return void 0;
|
|
16091
16678
|
}
|
|
16092
|
-
const
|
|
16093
|
-
if (/^\d+$/.test(
|
|
16094
|
-
return Number(
|
|
16679
|
+
const text13 = String(raw);
|
|
16680
|
+
if (/^\d+$/.test(text13)) {
|
|
16681
|
+
return Number(text13);
|
|
16095
16682
|
}
|
|
16096
|
-
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;
|
|
16097
16684
|
const ms = Date.parse(iso);
|
|
16098
16685
|
if (Number.isNaN(ms)) {
|
|
16099
|
-
throw usageError(`Invalid --${name} ${
|
|
16686
|
+
throw usageError(`Invalid --${name} ${text13}`, "Use YYYY-MM-DD, an ISO time, or Unix seconds");
|
|
16100
16687
|
}
|
|
16101
16688
|
return Math.floor(ms / 1e3);
|
|
16102
16689
|
}
|
|
@@ -16255,20 +16842,20 @@ function registerOpsCommands(registry, ctx) {
|
|
|
16255
16842
|
"Run adp audit list without --page; when more rows exist its next action passes the returned --cursor"
|
|
16256
16843
|
);
|
|
16257
16844
|
}
|
|
16258
|
-
const
|
|
16259
|
-
const cursorText =
|
|
16845
|
+
const text13 = (name) => typeof args[name] === "string" && args[name] ? String(args[name]) : void 0;
|
|
16846
|
+
const cursorText = text13("cursor");
|
|
16260
16847
|
const result = await auditLogs((await gateways()).admin, {
|
|
16261
|
-
spaceId:
|
|
16848
|
+
spaceId: text13("space-id") ? assertResourceId(text13("space-id"), "space-id") : void 0,
|
|
16262
16849
|
limit: Math.min(ctx.flags.limit, 100),
|
|
16263
16850
|
cursor: cursorText ? cursorText.split(",") : void 0,
|
|
16264
|
-
filter: { action:
|
|
16851
|
+
filter: { action: text13("action"), bizObject: text13("biz"), accountUin: text13("account-uin") }
|
|
16265
16852
|
});
|
|
16266
16853
|
const cursor = result.cursor?.join(",");
|
|
16267
16854
|
const carried = [
|
|
16268
|
-
["space-id",
|
|
16269
|
-
["action",
|
|
16270
|
-
["biz",
|
|
16271
|
-
["account-uin",
|
|
16855
|
+
["space-id", text13("space-id")],
|
|
16856
|
+
["action", text13("action")],
|
|
16857
|
+
["biz", text13("biz")],
|
|
16858
|
+
["account-uin", text13("account-uin")]
|
|
16272
16859
|
].filter((pair) => pair[1] !== void 0).map(([flag, value]) => ` --${flag} ${value}`).join("");
|
|
16273
16860
|
return {
|
|
16274
16861
|
result: { total: result.total, items: result.items, cursor, truncated: result.truncated },
|
|
@@ -16931,8 +17518,8 @@ function expandEnv(value, sourcePath, env) {
|
|
|
16931
17518
|
return resolved2;
|
|
16932
17519
|
});
|
|
16933
17520
|
}
|
|
16934
|
-
function parsePluginSpec(
|
|
16935
|
-
const result = pluginSpecFileSchema.safeParse(parseJsonc2(
|
|
17521
|
+
function parsePluginSpec(text13, sourcePath, env = process.env) {
|
|
17522
|
+
const result = pluginSpecFileSchema.safeParse(parseJsonc2(text13));
|
|
16936
17523
|
if (!result.success) {
|
|
16937
17524
|
throw usageError(
|
|
16938
17525
|
`Invalid plugin spec ${sourcePath}: ${result.error.issues.map(describeIssue).join("; ")}`,
|
|
@@ -16958,16 +17545,16 @@ function parsePluginSpec(text12, sourcePath, env = process.env) {
|
|
|
16958
17545
|
}
|
|
16959
17546
|
async function loadPluginSpec(cwd, relativePath) {
|
|
16960
17547
|
const resolved2 = path13.resolve(cwd, relativePath);
|
|
16961
|
-
let
|
|
17548
|
+
let text13;
|
|
16962
17549
|
try {
|
|
16963
|
-
|
|
17550
|
+
text13 = await readFile11(resolved2, "utf8");
|
|
16964
17551
|
} catch {
|
|
16965
17552
|
throw usageError(
|
|
16966
17553
|
`Plugin spec not found: ${resolved2}`,
|
|
16967
17554
|
"Pass --from-config path/to/plugin.jsonc"
|
|
16968
17555
|
);
|
|
16969
17556
|
}
|
|
16970
|
-
return parsePluginSpec(
|
|
17557
|
+
return parsePluginSpec(text13, resolved2);
|
|
16971
17558
|
}
|
|
16972
17559
|
|
|
16973
17560
|
// src/interfaces/cli/commands/plugin/index.ts
|
|
@@ -18143,11 +18730,11 @@ async function discoverCompanionSkills(pack, input) {
|
|
|
18143
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
|
|
18144
18731
|
};
|
|
18145
18732
|
}
|
|
18146
|
-
function truncate(
|
|
18147
|
-
if (
|
|
18148
|
-
return
|
|
18733
|
+
function truncate(text13, max) {
|
|
18734
|
+
if (text13.length <= max) {
|
|
18735
|
+
return text13;
|
|
18149
18736
|
}
|
|
18150
|
-
return `${
|
|
18737
|
+
return `${text13.slice(0, max - 1).trimEnd()}\u2026`;
|
|
18151
18738
|
}
|
|
18152
18739
|
async function readDescription(pack, skillId) {
|
|
18153
18740
|
try {
|
|
@@ -19360,12 +19947,12 @@ function parseCsv(value, name) {
|
|
|
19360
19947
|
return items;
|
|
19361
19948
|
}
|
|
19362
19949
|
function parseSpecJson(raw) {
|
|
19363
|
-
const
|
|
19364
|
-
if (!
|
|
19950
|
+
const text13 = optionalString14(raw);
|
|
19951
|
+
if (!text13) {
|
|
19365
19952
|
return void 0;
|
|
19366
19953
|
}
|
|
19367
19954
|
try {
|
|
19368
|
-
const parsed = JSON.parse(
|
|
19955
|
+
const parsed = JSON.parse(text13);
|
|
19369
19956
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
19370
19957
|
throw new Error("not an object");
|
|
19371
19958
|
}
|
|
@@ -21825,8 +22412,8 @@ function prepareCanvas(input) {
|
|
|
21825
22412
|
const ids4 = /* @__PURE__ */ new Set();
|
|
21826
22413
|
const names2 = /* @__PURE__ */ new Map();
|
|
21827
22414
|
for (const node of nodes) {
|
|
21828
|
-
const id =
|
|
21829
|
-
const type =
|
|
22415
|
+
const id = text4(node.NodeID);
|
|
22416
|
+
const type = text4(node.NodeType);
|
|
21830
22417
|
if (!NODE_ID.test(id)) {
|
|
21831
22418
|
problems.push(`NodeID "${id}" must match ${NODE_ID.source}`);
|
|
21832
22419
|
}
|
|
@@ -21839,7 +22426,7 @@ function prepareCanvas(input) {
|
|
|
21839
22426
|
`node ${id}: NodeType "${type}" is not a workflow node type` + (type === "REPLY" ? " (the reply node is ANSWER)" : "")
|
|
21840
22427
|
);
|
|
21841
22428
|
}
|
|
21842
|
-
const name =
|
|
22429
|
+
const name = text4(node.NodeName);
|
|
21843
22430
|
if (name) {
|
|
21844
22431
|
const other = names2.get(name);
|
|
21845
22432
|
if (other !== void 0) {
|
|
@@ -21860,20 +22447,20 @@ function prepareCanvas(input) {
|
|
|
21860
22447
|
}
|
|
21861
22448
|
const branchUi = /* @__PURE__ */ new Map();
|
|
21862
22449
|
for (const node of nodes) {
|
|
21863
|
-
if (BRANCH_TYPES.has(
|
|
21864
|
-
branchUi.set(
|
|
22450
|
+
if (BRANCH_TYPES.has(text4(node.NodeType))) {
|
|
22451
|
+
branchUi.set(text4(node.NodeID), prepareBranch(node, fixes, problems));
|
|
21865
22452
|
}
|
|
21866
22453
|
}
|
|
21867
22454
|
const successors = /* @__PURE__ */ new Map();
|
|
21868
22455
|
for (const node of nodes) {
|
|
21869
|
-
const id =
|
|
22456
|
+
const id = text4(node.NodeID);
|
|
21870
22457
|
const targets = [...strings8(node.NextNodeIDs), ...branchTargets(node), ...failTargets(node)];
|
|
21871
22458
|
for (const target of targets) {
|
|
21872
22459
|
if (!ids4.has(target)) {
|
|
21873
22460
|
problems.push(`node ${id}: next node "${target}" does not exist`);
|
|
21874
22461
|
}
|
|
21875
22462
|
}
|
|
21876
|
-
successors.set(id,
|
|
22463
|
+
successors.set(id, unique2(targets.filter((target) => ids4.has(target))));
|
|
21877
22464
|
}
|
|
21878
22465
|
const edges = readEdges(canvas.Edge, problems).filter((edge) => {
|
|
21879
22466
|
const keep = ids4.has(edge.source) && ids4.has(edge.target);
|
|
@@ -21883,13 +22470,13 @@ function prepareCanvas(input) {
|
|
|
21883
22470
|
return keep && !(branchUi.has(edge.source) && !edge.sourceHandle.includes("fail_branch"));
|
|
21884
22471
|
});
|
|
21885
22472
|
for (const node of nodes) {
|
|
21886
|
-
const id =
|
|
22473
|
+
const id = text4(node.NodeID);
|
|
21887
22474
|
const content = branchUi.get(id);
|
|
21888
22475
|
if (!content) {
|
|
21889
22476
|
continue;
|
|
21890
22477
|
}
|
|
21891
22478
|
branchSlots(node).forEach((slot, index) => {
|
|
21892
|
-
const handle = `${id}.${
|
|
22479
|
+
const handle = `${id}.${text4(content[index]?.id)}-source`;
|
|
21893
22480
|
for (const target of strings8(slot.NextNodeIDs).filter((target2) => ids4.has(target2))) {
|
|
21894
22481
|
edges.push(makeEdge(id, handle, target));
|
|
21895
22482
|
fixes.push(`added branch edge ${id}[${index}] -> ${target}`);
|
|
@@ -21898,8 +22485,8 @@ function prepareCanvas(input) {
|
|
|
21898
22485
|
}
|
|
21899
22486
|
const connected = new Set(edges.map((edge) => `${edge.source}>${edge.target}`));
|
|
21900
22487
|
for (const node of nodes) {
|
|
21901
|
-
const id =
|
|
21902
|
-
const type =
|
|
22488
|
+
const id = text4(node.NodeID);
|
|
22489
|
+
const type = text4(node.NodeType);
|
|
21903
22490
|
for (const target of strings8(node.NextNodeIDs)) {
|
|
21904
22491
|
if (BRANCH_TYPES.has(type) || connected.has(`${id}>${target}`)) {
|
|
21905
22492
|
continue;
|
|
@@ -21933,9 +22520,9 @@ function prepareCanvas(input) {
|
|
|
21933
22520
|
canvas.Edge = JSON.stringify(edges);
|
|
21934
22521
|
const start = nodes.find((node) => node.NodeType === "START");
|
|
21935
22522
|
if (start) {
|
|
21936
|
-
const reached = reachable(
|
|
22523
|
+
const reached = reachable(text4(start.NodeID), successors);
|
|
21937
22524
|
for (const node of nodes) {
|
|
21938
|
-
const id =
|
|
22525
|
+
const id = text4(node.NodeID);
|
|
21939
22526
|
if (node.NodeType === "COMMENT") {
|
|
21940
22527
|
continue;
|
|
21941
22528
|
}
|
|
@@ -21946,7 +22533,7 @@ function prepareCanvas(input) {
|
|
|
21946
22533
|
problems.push(`node ${id} has no next node; every path must end at END`);
|
|
21947
22534
|
}
|
|
21948
22535
|
}
|
|
21949
|
-
layout(nodes,
|
|
22536
|
+
layout(nodes, text4(start.NodeID), successors, branchUi, fixes);
|
|
21950
22537
|
}
|
|
21951
22538
|
const cycle = findCycle(successors);
|
|
21952
22539
|
if (cycle) {
|
|
@@ -21963,7 +22550,7 @@ function prepareCanvas(input) {
|
|
|
21963
22550
|
}
|
|
21964
22551
|
}
|
|
21965
22552
|
checkReferences(nodes, problems);
|
|
21966
|
-
return { canvas, fixes, problems:
|
|
22553
|
+
return { canvas, fixes, problems: unique2(problems) };
|
|
21967
22554
|
}
|
|
21968
22555
|
function findCycle(successors) {
|
|
21969
22556
|
const state = /* @__PURE__ */ new Map();
|
|
@@ -21999,23 +22586,23 @@ function findCycle(successors) {
|
|
|
21999
22586
|
function declaredOutputs(node) {
|
|
22000
22587
|
if (node.NodeType === "PARAMETER_EXTRACTOR") {
|
|
22001
22588
|
const params = extractorParameters(node);
|
|
22002
|
-
if (params.length === 0 || params.some((param) => !
|
|
22589
|
+
if (params.length === 0 || params.some((param) => !text4(param.Name))) {
|
|
22003
22590
|
return void 0;
|
|
22004
22591
|
}
|
|
22005
|
-
return params.map((param) =>
|
|
22592
|
+
return params.map((param) => text4(param.Name));
|
|
22006
22593
|
}
|
|
22007
22594
|
if (node.NodeType === "CODE_EXECUTOR") {
|
|
22008
22595
|
const outputs = Array.isArray(node.Outputs) ? node.Outputs.filter(isRecord) : [];
|
|
22009
|
-
const root = outputs.find((output) =>
|
|
22596
|
+
const root = outputs.find((output) => text4(output.Title) === "Output") ?? outputs[0];
|
|
22010
22597
|
const properties = Array.isArray(root?.Properties) ? root.Properties.filter(isRecord) : [];
|
|
22011
|
-
return properties.length > 0 ? properties.map((property) =>
|
|
22598
|
+
return properties.length > 0 ? properties.map((property) => text4(property.Title)).filter(Boolean) : void 0;
|
|
22012
22599
|
}
|
|
22013
22600
|
return void 0;
|
|
22014
22601
|
}
|
|
22015
22602
|
function checkReferences(nodes, problems) {
|
|
22016
|
-
const byId = new Map(nodes.map((node) => [
|
|
22603
|
+
const byId = new Map(nodes.map((node) => [text4(node.NodeID), node]));
|
|
22017
22604
|
for (const node of nodes) {
|
|
22018
|
-
const id =
|
|
22605
|
+
const id = text4(node.NodeID);
|
|
22019
22606
|
const walk = (value, label, root = false) => {
|
|
22020
22607
|
if (Array.isArray(value)) {
|
|
22021
22608
|
value.forEach((item) => walk(item, label));
|
|
@@ -22024,21 +22611,21 @@ function checkReferences(nodes, problems) {
|
|
|
22024
22611
|
if (!isRecord(value)) {
|
|
22025
22612
|
return;
|
|
22026
22613
|
}
|
|
22027
|
-
const here = root ? label :
|
|
22028
|
-
const ref3 = isRecord(value.Reference) ? value.Reference : !root && "JsonPath" in value &&
|
|
22029
|
-
if (ref3 &&
|
|
22030
|
-
const target = byId.get(
|
|
22031
|
-
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);
|
|
22032
22619
|
if (!target) {
|
|
22033
22620
|
problems.push(
|
|
22034
|
-
`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(", ")}`
|
|
22035
22622
|
);
|
|
22036
22623
|
} else {
|
|
22037
22624
|
const field = /^Output\.([^.[\]]+)/.exec(path14)?.[1];
|
|
22038
22625
|
const declared = declaredOutputs(target);
|
|
22039
22626
|
if (field && declared && !declared.includes(field)) {
|
|
22040
22627
|
problems.push(
|
|
22041
|
-
`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"}`
|
|
22042
22629
|
);
|
|
22043
22630
|
}
|
|
22044
22631
|
}
|
|
@@ -22058,12 +22645,12 @@ function extractorParameters(node) {
|
|
|
22058
22645
|
return Array.isArray(data.Parameters) ? data.Parameters.filter(isRecord) : [];
|
|
22059
22646
|
}
|
|
22060
22647
|
function checkParameterExtractor(node, fixes, problems) {
|
|
22061
|
-
const id =
|
|
22648
|
+
const id = text4(node.NodeID);
|
|
22062
22649
|
const inputs = Array.isArray(node.Inputs) ? node.Inputs.filter(isRecord) : [];
|
|
22063
22650
|
for (const input of inputs) {
|
|
22064
22651
|
if (isRecord(input.Input) && input.Input.InputType === "SYSTEM_VARIABLE") {
|
|
22065
22652
|
problems.push(
|
|
22066
|
-
`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`
|
|
22067
22654
|
);
|
|
22068
22655
|
}
|
|
22069
22656
|
}
|
|
@@ -22073,17 +22660,17 @@ function checkParameterExtractor(node, fixes, problems) {
|
|
|
22073
22660
|
}
|
|
22074
22661
|
params.forEach((param, index) => {
|
|
22075
22662
|
const where = `node ${id} (PARAMETER_EXTRACTOR) Parameters[${index}]`;
|
|
22076
|
-
if (
|
|
22663
|
+
if (text4(param.RefParameterID)) {
|
|
22077
22664
|
return;
|
|
22078
22665
|
}
|
|
22079
|
-
if (!
|
|
22666
|
+
if (!text4(param.Name)) {
|
|
22080
22667
|
problems.push(`${where}: needs RefParameterID or an inline Name/Type/Desc to register`);
|
|
22081
22668
|
return;
|
|
22082
22669
|
}
|
|
22083
|
-
if (!
|
|
22670
|
+
if (!text4(param.Desc)) {
|
|
22084
22671
|
problems.push(`${where}: Desc is required (the model extracts by this description)`);
|
|
22085
22672
|
}
|
|
22086
|
-
const type =
|
|
22673
|
+
const type = text4(param.Type) || "STRING";
|
|
22087
22674
|
if (!EXTRACTOR_TYPES.has(type)) {
|
|
22088
22675
|
problems.push(`${where}: Type "${type}" must be one of ${[...EXTRACTOR_TYPES].join(", ")}`);
|
|
22089
22676
|
}
|
|
@@ -22100,14 +22687,14 @@ function collectExtractorParameters(canvas) {
|
|
|
22100
22687
|
const nodes = Array.isArray(canvas.Nodes) ? canvas.Nodes.filter(isRecord) : [];
|
|
22101
22688
|
return nodes.filter((node) => node.NodeType === "PARAMETER_EXTRACTOR").flatMap(
|
|
22102
22689
|
(node) => extractorParameters(node).flatMap(
|
|
22103
|
-
(param, index) =>
|
|
22690
|
+
(param, index) => text4(param.RefParameterID) || !text4(param.Name) ? [] : [
|
|
22104
22691
|
{
|
|
22105
|
-
nodeId:
|
|
22106
|
-
nodeName:
|
|
22692
|
+
nodeId: text4(node.NodeID),
|
|
22693
|
+
nodeName: text4(node.NodeName) || text4(node.NodeID),
|
|
22107
22694
|
index,
|
|
22108
|
-
name:
|
|
22109
|
-
type:
|
|
22110
|
-
desc:
|
|
22695
|
+
name: text4(param.Name),
|
|
22696
|
+
type: text4(param.Type) || "STRING",
|
|
22697
|
+
desc: text4(param.Desc),
|
|
22111
22698
|
required: param.Required !== false && param.IsRequired !== false,
|
|
22112
22699
|
correctExamples: examples(param.CorrectExamples),
|
|
22113
22700
|
incorrectExamples: examples(param.IncorrectExamples)
|
|
@@ -22123,7 +22710,7 @@ function bindExtractorParameters(canvas, registered) {
|
|
|
22123
22710
|
const next = structuredClone(canvas);
|
|
22124
22711
|
const nodes = Array.isArray(next.Nodes) ? next.Nodes.filter(isRecord) : [];
|
|
22125
22712
|
for (const { spec, parameterId } of registered) {
|
|
22126
|
-
const node = nodes.find((item) =>
|
|
22713
|
+
const node = nodes.find((item) => text4(item.NodeID) === spec.nodeId);
|
|
22127
22714
|
const params = node ? extractorParameters(node) : [];
|
|
22128
22715
|
if (params[spec.index]) {
|
|
22129
22716
|
params[spec.index] = { RefParameterID: parameterId, Required: spec.required, SubParams: [] };
|
|
@@ -22152,12 +22739,12 @@ function readEdges(raw, problems) {
|
|
|
22152
22739
|
problems.push("Edge must be a JSON string of an edge array");
|
|
22153
22740
|
return [];
|
|
22154
22741
|
}
|
|
22155
|
-
return value.filter(isRecord).filter((edge) =>
|
|
22742
|
+
return value.filter(isRecord).filter((edge) => text4(edge.source) && text4(edge.target)).map((edge) => ({
|
|
22156
22743
|
...edge,
|
|
22157
|
-
source:
|
|
22158
|
-
target:
|
|
22159
|
-
sourceHandle:
|
|
22160
|
-
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`
|
|
22161
22748
|
}));
|
|
22162
22749
|
}
|
|
22163
22750
|
function makeEdge(source2, sourceHandle, target) {
|
|
@@ -22214,17 +22801,17 @@ function branchSlots(node) {
|
|
|
22214
22801
|
const card = dynamicCard(node);
|
|
22215
22802
|
if (card) {
|
|
22216
22803
|
return [
|
|
22217
|
-
{ Content:
|
|
22804
|
+
{ Content: text4(card.DynamicOptionsRefInputName), NextNodeIDs: strings8(card.DynamicOptionsRefNextNodeIDs) },
|
|
22218
22805
|
{ Content: "", NextNodeIDs: strings8(card.DynamicOptionsElseNextNodeIDs) }
|
|
22219
22806
|
];
|
|
22220
22807
|
}
|
|
22221
|
-
const [dataKey, listKey] = BRANCH_LISTS[
|
|
22808
|
+
const [dataKey, listKey] = BRANCH_LISTS[text4(node.NodeType)] ?? ["", ""];
|
|
22222
22809
|
const data = isRecord(node[dataKey]) ? node[dataKey] : void 0;
|
|
22223
22810
|
return data && Array.isArray(data[listKey]) ? data[listKey].filter(isRecord) : [];
|
|
22224
22811
|
}
|
|
22225
22812
|
function prepareBranch(node, fixes, problems) {
|
|
22226
|
-
const id =
|
|
22227
|
-
const type =
|
|
22813
|
+
const id = text4(node.NodeID);
|
|
22814
|
+
const type = text4(node.NodeType);
|
|
22228
22815
|
const [dataKey, listKey] = BRANCH_LISTS[type];
|
|
22229
22816
|
const slots = branchSlots(node);
|
|
22230
22817
|
const loose = strings8(node.NextNodeIDs);
|
|
@@ -22262,7 +22849,7 @@ function prepareBranch(node, fixes, problems) {
|
|
|
22262
22849
|
const existing = Array.isArray(data?.content) ? data.content.filter(isRecord) : [];
|
|
22263
22850
|
const content = slots.map((slot, index) => {
|
|
22264
22851
|
const current = existing[index];
|
|
22265
|
-
if (current &&
|
|
22852
|
+
if (current && text4(current.id)) {
|
|
22266
22853
|
return current;
|
|
22267
22854
|
}
|
|
22268
22855
|
const entryId = `${id}_branch_${index}`;
|
|
@@ -22270,9 +22857,9 @@ function prepareBranch(node, fixes, problems) {
|
|
|
22270
22857
|
return { content: [], index, id: entryId };
|
|
22271
22858
|
}
|
|
22272
22859
|
if (type === "OPTION_CARD") {
|
|
22273
|
-
return { Content:
|
|
22860
|
+
return { Content: text4(slot.Content), id: entryId };
|
|
22274
22861
|
}
|
|
22275
|
-
return { content:
|
|
22862
|
+
return { content: text4(slot.Name) || "intent", id: entryId };
|
|
22276
22863
|
});
|
|
22277
22864
|
if (ui && data && content.some((entry, index) => entry !== existing[index])) {
|
|
22278
22865
|
data.content = content;
|
|
@@ -22301,11 +22888,11 @@ function checkLogical(logical, path14, fixes, problems) {
|
|
|
22301
22888
|
const combined = logical.LogicalOperator === "AND" || logical.LogicalOperator === "OR";
|
|
22302
22889
|
if (combined) {
|
|
22303
22890
|
if (compound.length === 0) {
|
|
22304
|
-
problems.push(`${path14}: LogicalOperator ${
|
|
22891
|
+
problems.push(`${path14}: LogicalOperator ${text4(logical.LogicalOperator)} needs conditions in Compound[]`);
|
|
22305
22892
|
}
|
|
22306
22893
|
if ("Comparison" in logical) {
|
|
22307
22894
|
delete logical.Comparison;
|
|
22308
|
-
fixes.push(`removed ${path14}.Comparison (an ${
|
|
22895
|
+
fixes.push(`removed ${path14}.Comparison (an ${text4(logical.LogicalOperator)} group uses Compound only)`);
|
|
22309
22896
|
}
|
|
22310
22897
|
compound.forEach((child, index) => checkLogical(child, `${path14}.Compound[${index}]`, fixes, problems));
|
|
22311
22898
|
return;
|
|
@@ -22314,13 +22901,13 @@ function checkLogical(logical, path14, fixes, problems) {
|
|
|
22314
22901
|
if (!comparison) {
|
|
22315
22902
|
return;
|
|
22316
22903
|
}
|
|
22317
|
-
const operator =
|
|
22904
|
+
const operator = text4(comparison.Operator);
|
|
22318
22905
|
if (!COMPARISON_OPERATORS.has(operator)) {
|
|
22319
22906
|
problems.push(
|
|
22320
22907
|
`${path14}.Comparison: Operator "${operator || "none"}" is not supported; use one of ${[...COMPARISON_OPERATORS].join(", ")}`
|
|
22321
22908
|
);
|
|
22322
|
-
} else if (NUMERIC_OPERATORS.has(operator) && !["INT", "FLOAT"].includes(
|
|
22323
|
-
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"}`);
|
|
22324
22911
|
}
|
|
22325
22912
|
}
|
|
22326
22913
|
function dynamicCard(node) {
|
|
@@ -22330,7 +22917,7 @@ function dynamicCard(node) {
|
|
|
22330
22917
|
return node.OptionCardNodeData.CardFrom === "DYNAMIC" ? node.OptionCardNodeData : void 0;
|
|
22331
22918
|
}
|
|
22332
22919
|
function prepareDynamicCard(node, slots, loose, fixes, problems) {
|
|
22333
|
-
const id =
|
|
22920
|
+
const id = text4(node.NodeID);
|
|
22334
22921
|
const card = dynamicCard(node);
|
|
22335
22922
|
const fields = ["DynamicOptionsRefNextNodeIDs", "DynamicOptionsElseNextNodeIDs"];
|
|
22336
22923
|
if (loose.length > 0) {
|
|
@@ -22344,24 +22931,24 @@ function prepareDynamicCard(node, slots, loose, fixes, problems) {
|
|
|
22344
22931
|
problems.push(`dynamic option card ${id}: OptionCardNodeData.${fields[index]} is empty`);
|
|
22345
22932
|
}
|
|
22346
22933
|
});
|
|
22347
|
-
const inputName =
|
|
22934
|
+
const inputName = text4(card.DynamicOptionsRefInputName);
|
|
22348
22935
|
const input = (Array.isArray(node.Inputs) ? node.Inputs.filter(isRecord) : []).find((entry) => entry.Name === inputName);
|
|
22349
22936
|
if (!inputName || !input) {
|
|
22350
22937
|
problems.push(
|
|
22351
22938
|
`dynamic option card ${id}: DynamicOptionsRefInputName must name one of the node's Inputs (an ARRAY_STRING reference)`
|
|
22352
22939
|
);
|
|
22353
22940
|
} else if (input.Type !== "ARRAY_STRING") {
|
|
22354
|
-
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"}`);
|
|
22355
22942
|
}
|
|
22356
22943
|
const ui = parseUi(node.NodeUI);
|
|
22357
22944
|
const data = isRecord(ui?.data) ? ui.data : void 0;
|
|
22358
22945
|
const existing = (Array.isArray(data?.content) ? data.content.filter(isRecord) : []).filter((entry) => entry.isDynamic);
|
|
22359
22946
|
const content = slots.map((slot, index) => {
|
|
22360
22947
|
const current = existing[index];
|
|
22361
|
-
if (current &&
|
|
22948
|
+
if (current && text4(current.id)) {
|
|
22362
22949
|
return current;
|
|
22363
22950
|
}
|
|
22364
|
-
const entry = { Content:
|
|
22951
|
+
const entry = { Content: text4(slot.Content), NextNodeIDs: [], id: `${id}_branch_${index}`, isDynamic: true };
|
|
22365
22952
|
if (index === 0) {
|
|
22366
22953
|
entry.hasValue = true;
|
|
22367
22954
|
}
|
|
@@ -22420,7 +23007,7 @@ function layout(nodes, start, successors, branchUi, fixes) {
|
|
|
22420
23007
|
const rows = /* @__PURE__ */ new Map();
|
|
22421
23008
|
let laidOut = 0;
|
|
22422
23009
|
for (const node of nodes) {
|
|
22423
|
-
const id =
|
|
23010
|
+
const id = text4(node.NodeID);
|
|
22424
23011
|
const column = depth.get(id) ?? Math.max(0, ...depth.values()) + 1;
|
|
22425
23012
|
const row = rows.get(column) ?? 0;
|
|
22426
23013
|
rows.set(column, row + 1);
|
|
@@ -22462,9 +23049,9 @@ function rewriteEndReferences(node, fixes) {
|
|
|
22462
23049
|
const value = isRecord(property.Value) ? property.Value : void 0;
|
|
22463
23050
|
if (value?.InputType === "INPUT_REF" && isRecord(value.InputRef)) {
|
|
22464
23051
|
const ref3 = value.InputRef;
|
|
22465
|
-
const path14 =
|
|
22466
|
-
property.Value = { InputType: "REFERENCE_OUTPUT", Reference: { NodeID:
|
|
22467
|
-
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}`);
|
|
22468
23055
|
}
|
|
22469
23056
|
visit(property.Properties);
|
|
22470
23057
|
}
|
|
@@ -22476,18 +23063,18 @@ function rewriteEndReferences(node, fixes) {
|
|
|
22476
23063
|
}
|
|
22477
23064
|
}
|
|
22478
23065
|
function typeOf(nodes, id) {
|
|
22479
|
-
return
|
|
23066
|
+
return text4(nodes.find((node) => node.NodeID === id)?.NodeType);
|
|
22480
23067
|
}
|
|
22481
23068
|
function isRecord(value) {
|
|
22482
23069
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
22483
23070
|
}
|
|
22484
|
-
function
|
|
23071
|
+
function text4(value) {
|
|
22485
23072
|
return typeof value === "string" ? value : typeof value === "number" ? String(value) : "";
|
|
22486
23073
|
}
|
|
22487
23074
|
function strings8(value) {
|
|
22488
|
-
return Array.isArray(value) ? value.map(
|
|
23075
|
+
return Array.isArray(value) ? value.map(text4).filter(Boolean) : [];
|
|
22489
23076
|
}
|
|
22490
|
-
function
|
|
23077
|
+
function unique2(values) {
|
|
22491
23078
|
return [...new Set(values)];
|
|
22492
23079
|
}
|
|
22493
23080
|
|
|
@@ -22890,8 +23477,8 @@ async function findByName(gateway, appId3, name) {
|
|
|
22890
23477
|
return all.filter((item) => item.name === name);
|
|
22891
23478
|
}
|
|
22892
23479
|
function isDuplicateNameError(error) {
|
|
22893
|
-
const
|
|
22894
|
-
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");
|
|
22895
23482
|
}
|
|
22896
23483
|
function isNonEmpty(dialogJson) {
|
|
22897
23484
|
return typeof dialogJson === "string" && dialogJson.trim().length > 0;
|
|
@@ -23306,12 +23893,12 @@ function runId(args) {
|
|
|
23306
23893
|
function parseVariables(raw) {
|
|
23307
23894
|
const values = Array.isArray(raw) ? raw : raw === void 0 ? [] : [raw];
|
|
23308
23895
|
return values.map((entry) => {
|
|
23309
|
-
const
|
|
23310
|
-
const at =
|
|
23896
|
+
const text13 = String(entry);
|
|
23897
|
+
const at = text13.indexOf("=");
|
|
23311
23898
|
if (at <= 0) {
|
|
23312
|
-
throw usageError(`Invalid --var ${
|
|
23899
|
+
throw usageError(`Invalid --var ${text13}`, "Use --var name=value (repeatable)");
|
|
23313
23900
|
}
|
|
23314
|
-
return { name:
|
|
23901
|
+
return { name: text13.slice(0, at), value: text13.slice(at + 1) };
|
|
23315
23902
|
});
|
|
23316
23903
|
}
|
|
23317
23904
|
function runIds(args) {
|
|
@@ -24167,14 +24754,14 @@ var storeIdFlag = {
|
|
|
24167
24754
|
var userIdFlag = { name: "user-id", type: "string", describe: "End-user ID the memory belongs to", required: true };
|
|
24168
24755
|
var typeFlag3 = { name: "type", type: "string", describe: "Store type", choices: ["rich", "flat"] };
|
|
24169
24756
|
var appIdFlag8 = { name: "app-id", type: "string", describe: "App ID (default: adp.jsonc app_id)" };
|
|
24170
|
-
function
|
|
24757
|
+
function text5(args, key) {
|
|
24171
24758
|
return typeof args[key] === "string" ? args[key] : void 0;
|
|
24172
24759
|
}
|
|
24173
24760
|
function bool2(args, key) {
|
|
24174
24761
|
return typeof args[key] === "boolean" ? args[key] : void 0;
|
|
24175
24762
|
}
|
|
24176
24763
|
function required(args, key) {
|
|
24177
|
-
const value =
|
|
24764
|
+
const value = text5(args, key)?.trim();
|
|
24178
24765
|
if (!value) {
|
|
24179
24766
|
throw new DomainError(`Missing --${key}`, "usage", "UsageError");
|
|
24180
24767
|
}
|
|
@@ -24186,7 +24773,7 @@ async function storeRef(ctx, args) {
|
|
|
24186
24773
|
return { spaceId: await resolveSpaceId(ctx, args, WHY_SPACE3), storeId };
|
|
24187
24774
|
}
|
|
24188
24775
|
function storeType(args, fallback) {
|
|
24189
|
-
const name =
|
|
24776
|
+
const name = text5(args, "type");
|
|
24190
24777
|
return name ? MEMORY_STORE_TYPES[name] : fallback;
|
|
24191
24778
|
}
|
|
24192
24779
|
async function guarded(scope, run) {
|
|
@@ -24220,9 +24807,9 @@ function registerMemoryCommands(registry, ctx) {
|
|
|
24220
24807
|
spaceId,
|
|
24221
24808
|
limit: ctx.flags.limit,
|
|
24222
24809
|
page: ctx.flags.page,
|
|
24223
|
-
query:
|
|
24224
|
-
storeType:
|
|
24225
|
-
appId:
|
|
24810
|
+
query: text5(args, "query"),
|
|
24811
|
+
storeType: text5(args, "type") ? storeType(args, 1) : void 0,
|
|
24812
|
+
appId: text5(args, "app-id")
|
|
24226
24813
|
});
|
|
24227
24814
|
return applyListShape(
|
|
24228
24815
|
ctx,
|
|
@@ -24270,7 +24857,7 @@ function registerMemoryCommands(registry, ctx) {
|
|
|
24270
24857
|
const input = {
|
|
24271
24858
|
spaceId,
|
|
24272
24859
|
name: required(args, "name"),
|
|
24273
|
-
description:
|
|
24860
|
+
description: text5(args, "description"),
|
|
24274
24861
|
storeType: storeType(args, 1),
|
|
24275
24862
|
summaryEnabled: bool2(args, "summary"),
|
|
24276
24863
|
ttlDays: typeof args["ttl-days"] === "number" ? args["ttl-days"] : void 0
|
|
@@ -24310,8 +24897,8 @@ function registerMemoryCommands(registry, ctx) {
|
|
|
24310
24897
|
const ref3 = await storeRef(ctx, args);
|
|
24311
24898
|
const rich = storeTypeOf(ref3.storeId) === 1;
|
|
24312
24899
|
const patch = {
|
|
24313
|
-
name:
|
|
24314
|
-
description:
|
|
24900
|
+
name: text5(args, "name"),
|
|
24901
|
+
description: text5(args, "description"),
|
|
24315
24902
|
summaryEnabled: rich ? bool2(args, "summary") : void 0,
|
|
24316
24903
|
ttlDays: !rich && typeof args["ttl-days"] === "number" ? args["ttl-days"] : void 0
|
|
24317
24904
|
};
|
|
@@ -24385,7 +24972,7 @@ function registerMemoryCommands(registry, ctx) {
|
|
|
24385
24972
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
24386
24973
|
const page3 = await guarded(
|
|
24387
24974
|
ref3,
|
|
24388
|
-
() => 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") })
|
|
24389
24976
|
);
|
|
24390
24977
|
return applyListShape(
|
|
24391
24978
|
ctx,
|
|
@@ -24417,8 +25004,8 @@ function registerMemoryCommands(registry, ctx) {
|
|
|
24417
25004
|
...ref3,
|
|
24418
25005
|
limit: ctx.flags.limit,
|
|
24419
25006
|
page: ctx.flags.page,
|
|
24420
|
-
userId:
|
|
24421
|
-
query:
|
|
25007
|
+
userId: text5(args, "user-id"),
|
|
25008
|
+
query: text5(args, "query")
|
|
24422
25009
|
})
|
|
24423
25010
|
);
|
|
24424
25011
|
return applyListShape(
|
|
@@ -24482,9 +25069,9 @@ function registerMemoryCommands(registry, ctx) {
|
|
|
24482
25069
|
userId: required(args, "user-id"),
|
|
24483
25070
|
entryKey: required(args, "entry-key"),
|
|
24484
25071
|
patch: {
|
|
24485
|
-
content:
|
|
24486
|
-
name:
|
|
24487
|
-
frontMatter:
|
|
25072
|
+
content: text5(args, "content"),
|
|
25073
|
+
name: text5(args, "name"),
|
|
25074
|
+
frontMatter: text5(args, "front-matter"),
|
|
24488
25075
|
type: typeof args.type === "number" ? args.type : void 0
|
|
24489
25076
|
}
|
|
24490
25077
|
};
|
|
@@ -24627,9 +25214,9 @@ function registerMemoryCommands(registry, ctx) {
|
|
|
24627
25214
|
async handler(args) {
|
|
24628
25215
|
const spaceId = await resolveSpaceId(ctx, args, WHY_SPACE3);
|
|
24629
25216
|
const appId3 = assertResourceId(await resolveAppId(ctx, args, "memory bindings belong to an app"), "app-id");
|
|
24630
|
-
const storeId =
|
|
25217
|
+
const storeId = text5(args, "store-id") ? assertResourceId(String(args["store-id"]), "store-id") : void 0;
|
|
24631
25218
|
const type = storeId ? storeTypeOf(storeId) : storeType(args, 1);
|
|
24632
|
-
if (storeId &&
|
|
25219
|
+
if (storeId && text5(args, "type") && storeType(args, type) !== type) {
|
|
24633
25220
|
throw new DomainError("--type does not match the --store-id prefix", "usage", "UsageError");
|
|
24634
25221
|
}
|
|
24635
25222
|
const input = { spaceId, appId: appId3, storeType: type, storeId, summaryEnabled: bool2(args, "summary") };
|
|
@@ -24685,7 +25272,7 @@ function registerMemoryCommands(registry, ctx) {
|
|
|
24685
25272
|
examples: ["adp memory export --space-id sp-1 --store-id rms_abc --output ./memory.csv"],
|
|
24686
25273
|
async handler(args) {
|
|
24687
25274
|
const ref3 = await storeRef(ctx, args);
|
|
24688
|
-
const output =
|
|
25275
|
+
const output = text5(args, "output") ? canonicalizeLocalPath(String(args.output), ctx.flags.cwd) : void 0;
|
|
24689
25276
|
if (ctx.flags.dryRun) {
|
|
24690
25277
|
return { result: { dryRun: true, ...ref3, output }, message: `Would export memory store ${ref3.storeId}.` };
|
|
24691
25278
|
}
|
|
@@ -24884,11 +25471,11 @@ var tokenEnvFlag = {
|
|
|
24884
25471
|
type: "string",
|
|
24885
25472
|
describe: "Read the API key from this environment variable (never pass secrets as arguments)"
|
|
24886
25473
|
};
|
|
24887
|
-
function
|
|
25474
|
+
function text6(args, key) {
|
|
24888
25475
|
return typeof args[key] === "string" && args[key].trim() !== "" ? args[key].trim() : void 0;
|
|
24889
25476
|
}
|
|
24890
25477
|
function source(args) {
|
|
24891
|
-
const name =
|
|
25478
|
+
const name = text6(args, "source");
|
|
24892
25479
|
return name ? CREDENTIAL_SOURCES[name] : void 0;
|
|
24893
25480
|
}
|
|
24894
25481
|
function consumer(args) {
|
|
@@ -24904,7 +25491,7 @@ async function credentialRef(ctx, args) {
|
|
|
24904
25491
|
};
|
|
24905
25492
|
}
|
|
24906
25493
|
async function readToken(ctx, args, required3) {
|
|
24907
|
-
const envName =
|
|
25494
|
+
const envName = text6(args, "token-env");
|
|
24908
25495
|
if (envName) {
|
|
24909
25496
|
const value = ctx.deps.env[envName]?.trim();
|
|
24910
25497
|
if (!value) {
|
|
@@ -24948,7 +25535,7 @@ function registerCredentialCommands(registry, ctx) {
|
|
|
24948
25535
|
spaceId,
|
|
24949
25536
|
limit: ctx.flags.limit,
|
|
24950
25537
|
page: ctx.flags.page,
|
|
24951
|
-
query:
|
|
25538
|
+
query: text6(args, "query"),
|
|
24952
25539
|
source: source(args)
|
|
24953
25540
|
});
|
|
24954
25541
|
return applyListShape(
|
|
@@ -24989,7 +25576,7 @@ function registerCredentialCommands(registry, ctx) {
|
|
|
24989
25576
|
spaceId,
|
|
24990
25577
|
limit: ctx.flags.limit,
|
|
24991
25578
|
page: ctx.flags.page,
|
|
24992
|
-
query:
|
|
25579
|
+
query: text6(args, "query"),
|
|
24993
25580
|
source: source(args)
|
|
24994
25581
|
});
|
|
24995
25582
|
return applyListShape(
|
|
@@ -25021,7 +25608,7 @@ function registerCredentialCommands(registry, ctx) {
|
|
|
25021
25608
|
consumer: consumer(args),
|
|
25022
25609
|
limit: ctx.flags.limit,
|
|
25023
25610
|
page: ctx.flags.page,
|
|
25024
|
-
query:
|
|
25611
|
+
query: text6(args, "query"),
|
|
25025
25612
|
allSpaces: args["all-spaces"] === true
|
|
25026
25613
|
});
|
|
25027
25614
|
return applyListShape(
|
|
@@ -25044,7 +25631,7 @@ function registerCredentialCommands(registry, ctx) {
|
|
|
25044
25631
|
],
|
|
25045
25632
|
async handler(args) {
|
|
25046
25633
|
const spaceId = await resolveSpaceId(ctx, args, WHY_SPACE4);
|
|
25047
|
-
const name =
|
|
25634
|
+
const name = text6(args, "name");
|
|
25048
25635
|
if (!name) {
|
|
25049
25636
|
throw new DomainError("Missing --name", "usage", "UsageError");
|
|
25050
25637
|
}
|
|
@@ -25069,10 +25656,10 @@ function registerCredentialCommands(registry, ctx) {
|
|
|
25069
25656
|
examples: ["NEW_KEY=\u2026 adp credential update --space-id sp-1 --credential-id abc --token-env NEW_KEY"],
|
|
25070
25657
|
async handler(args) {
|
|
25071
25658
|
const ref3 = await credentialRef(ctx, args);
|
|
25072
|
-
const name =
|
|
25659
|
+
const name = text6(args, "name");
|
|
25073
25660
|
if (ctx.flags.dryRun) {
|
|
25074
25661
|
return {
|
|
25075
|
-
result: { dryRun: true, ...ref3, name, token:
|
|
25662
|
+
result: { dryRun: true, ...ref3, name, token: text6(args, "token-env") ? "(from env)" : void 0 },
|
|
25076
25663
|
message: `Would update credential ${ref3.credentialId}.`
|
|
25077
25664
|
};
|
|
25078
25665
|
}
|
|
@@ -25137,8 +25724,8 @@ function registerCredentialCommands(registry, ctx) {
|
|
|
25137
25724
|
],
|
|
25138
25725
|
async handler(args) {
|
|
25139
25726
|
const spaceId = await resolveSpaceId(ctx, args, WHY_SPACE4);
|
|
25140
|
-
const hasConsumer = Boolean(
|
|
25141
|
-
const hasCredential = Boolean(
|
|
25727
|
+
const hasConsumer = Boolean(text6(args, "consumer-id"));
|
|
25728
|
+
const hasCredential = Boolean(text6(args, "credential-id"));
|
|
25142
25729
|
if (hasConsumer === hasCredential) {
|
|
25143
25730
|
throw new DomainError("Pass exactly one of --consumer-id or --credential-id", "usage", "UsageError");
|
|
25144
25731
|
}
|
|
@@ -25148,7 +25735,7 @@ function registerCredentialCommands(registry, ctx) {
|
|
|
25148
25735
|
}
|
|
25149
25736
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
25150
25737
|
const result = await guarded2(
|
|
25151
|
-
{ spaceId, credentialId:
|
|
25738
|
+
{ spaceId, credentialId: text6(args, "credential-id") },
|
|
25152
25739
|
() => authorizeCredential(
|
|
25153
25740
|
{
|
|
25154
25741
|
credentials: gateways.credential,
|
|
@@ -25288,7 +25875,7 @@ var promptFlags = [
|
|
|
25288
25875
|
{ name: "prompt", type: "string", describe: "What the task asks the model each run" },
|
|
25289
25876
|
{ name: "prompt-file", type: "string", describe: "Read the prompt from a UTF-8 file" }
|
|
25290
25877
|
];
|
|
25291
|
-
function
|
|
25878
|
+
function text7(args, key) {
|
|
25292
25879
|
const value = args[key];
|
|
25293
25880
|
return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
|
|
25294
25881
|
}
|
|
@@ -25300,17 +25887,17 @@ function list(args, key) {
|
|
|
25300
25887
|
function schedule(args) {
|
|
25301
25888
|
return parseTimerSchedule({
|
|
25302
25889
|
manual: args.manual === true,
|
|
25303
|
-
daily:
|
|
25890
|
+
daily: text7(args, "daily"),
|
|
25304
25891
|
weekly: list(args, "weekly"),
|
|
25305
|
-
every:
|
|
25306
|
-
startAt:
|
|
25307
|
-
once:
|
|
25308
|
-
cron:
|
|
25892
|
+
every: text7(args, "every"),
|
|
25893
|
+
startAt: text7(args, "start-at"),
|
|
25894
|
+
once: text7(args, "once"),
|
|
25895
|
+
cron: text7(args, "cron")
|
|
25309
25896
|
});
|
|
25310
25897
|
}
|
|
25311
25898
|
async function prompt(args) {
|
|
25312
|
-
const inline =
|
|
25313
|
-
const file =
|
|
25899
|
+
const inline = text7(args, "prompt");
|
|
25900
|
+
const file = text7(args, "prompt-file");
|
|
25314
25901
|
if (inline && file) {
|
|
25315
25902
|
throw new DomainError("Pass --prompt or --prompt-file, not both", "usage", "UsageError");
|
|
25316
25903
|
}
|
|
@@ -25352,7 +25939,7 @@ function registerTimerCommands(registry, ctx) {
|
|
|
25352
25939
|
async handler(args) {
|
|
25353
25940
|
const spaceId = await resolveSpaceId(ctx, args, WHY_SPACE5);
|
|
25354
25941
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
25355
|
-
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") });
|
|
25356
25943
|
return applyListShape(
|
|
25357
25944
|
ctx,
|
|
25358
25945
|
pageResult(page3, { limit: ctx.flags.limit, page: ctx.flags.page }),
|
|
@@ -25396,7 +25983,7 @@ function registerTimerCommands(registry, ctx) {
|
|
|
25396
25983
|
],
|
|
25397
25984
|
async handler(args) {
|
|
25398
25985
|
const spaceId = await resolveSpaceId(ctx, args, WHY_SPACE5);
|
|
25399
|
-
const name =
|
|
25986
|
+
const name = text7(args, "name");
|
|
25400
25987
|
if (!name) {
|
|
25401
25988
|
throw new DomainError("Missing --name", "usage", "UsageError");
|
|
25402
25989
|
}
|
|
@@ -25410,7 +25997,7 @@ function registerTimerCommands(registry, ctx) {
|
|
|
25410
25997
|
hint: "Use one of --manual, --daily, --weekly, --every, --once, --cron"
|
|
25411
25998
|
});
|
|
25412
25999
|
}
|
|
25413
|
-
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") };
|
|
25414
26001
|
if (ctx.flags.dryRun) {
|
|
25415
26002
|
return { result: { dryRun: true, ...input }, message: `Would create timer task ${name}.` };
|
|
25416
26003
|
}
|
|
@@ -25446,11 +26033,11 @@ function registerTimerCommands(registry, ctx) {
|
|
|
25446
26033
|
async handler(args) {
|
|
25447
26034
|
const ref3 = await timerRef(ctx, args);
|
|
25448
26035
|
const patch = {
|
|
25449
|
-
name:
|
|
26036
|
+
name: text7(args, "name"),
|
|
25450
26037
|
prompt: await prompt(args),
|
|
25451
|
-
modelId:
|
|
26038
|
+
modelId: text7(args, "model"),
|
|
25452
26039
|
schedule: schedule(args),
|
|
25453
|
-
timezone:
|
|
26040
|
+
timezone: text7(args, "timezone")
|
|
25454
26041
|
};
|
|
25455
26042
|
if (ctx.flags.dryRun) {
|
|
25456
26043
|
return { result: { dryRun: true, ...ref3, ...patch }, message: `Would update timer task ${ref3.timerId}.` };
|
|
@@ -25619,14 +26206,14 @@ function explainGuidelineError(error, input) {
|
|
|
25619
26206
|
return error;
|
|
25620
26207
|
}
|
|
25621
26208
|
function batch(ids4, verb) {
|
|
25622
|
-
const
|
|
25623
|
-
if (
|
|
26209
|
+
const unique3 = [...new Set(ids4)];
|
|
26210
|
+
if (unique3.length === 0) {
|
|
25624
26211
|
throw new DomainError(`Nothing to ${verb}`, "usage", "UsageError", { hint: "Pass --guideline-id at least once" });
|
|
25625
26212
|
}
|
|
25626
|
-
if (
|
|
26213
|
+
if (unique3.length > BATCH_MAX) {
|
|
25627
26214
|
throw new DomainError(`At most ${BATCH_MAX} guidelines per call`, "usage", "UsageError");
|
|
25628
26215
|
}
|
|
25629
|
-
return
|
|
26216
|
+
return unique3;
|
|
25630
26217
|
}
|
|
25631
26218
|
function settle(result, appId3, verb) {
|
|
25632
26219
|
if (result.succeeded.length === 0 && result.failed.length > 0) {
|
|
@@ -25696,7 +26283,7 @@ var appIdFlag9 = { name: "app-id", type: "string", describe: "App ID (defaults t
|
|
|
25696
26283
|
var guidelineIdFlag = { name: "guideline-id", type: "string", describe: "Guideline ID", required: true };
|
|
25697
26284
|
var guidelineIdsFlag = { name: "guideline-id", type: "string", describe: "Guideline ID, repeatable", required: true };
|
|
25698
26285
|
var taskIdFlag2 = { name: "task-id", type: "string", describe: "Generation task ID", required: true };
|
|
25699
|
-
function
|
|
26286
|
+
function text8(args, key) {
|
|
25700
26287
|
const value = args[key];
|
|
25701
26288
|
return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
|
|
25702
26289
|
}
|
|
@@ -25742,15 +26329,15 @@ function registerGuidelineCommands(registry, ctx) {
|
|
|
25742
26329
|
examples: ["adp guideline list --app-id app-1 --status candidate --format json"],
|
|
25743
26330
|
async handler(args) {
|
|
25744
26331
|
const appId3 = await resolveAppId(ctx, args, WHY_APP5);
|
|
25745
|
-
const status =
|
|
26332
|
+
const status = text8(args, "status");
|
|
25746
26333
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
25747
26334
|
const result = await gateways.guideline.list({
|
|
25748
26335
|
appId: appId3,
|
|
25749
26336
|
limit: ctx.flags.limit,
|
|
25750
26337
|
page: ctx.flags.page,
|
|
25751
|
-
query:
|
|
26338
|
+
query: text8(args, "query"),
|
|
25752
26339
|
status: status ? GUIDELINE_STATUSES[status] : void 0,
|
|
25753
|
-
sourceTaskId:
|
|
26340
|
+
sourceTaskId: text8(args, "task-id")
|
|
25754
26341
|
});
|
|
25755
26342
|
return page2(ctx, result, `adp guideline list --app-id ${appId3}`);
|
|
25756
26343
|
}
|
|
@@ -25786,11 +26373,11 @@ function registerGuidelineCommands(registry, ctx) {
|
|
|
25786
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"'],
|
|
25787
26374
|
async handler(args) {
|
|
25788
26375
|
const appId3 = await resolveAppId(ctx, args, WHY_APP5);
|
|
25789
|
-
const content =
|
|
26376
|
+
const content = text8(args, "content");
|
|
25790
26377
|
if (!content) {
|
|
25791
26378
|
throw new DomainError("Missing --content", "usage", "UsageError");
|
|
25792
26379
|
}
|
|
25793
|
-
const input = { appId: appId3, content, applyScene:
|
|
26380
|
+
const input = { appId: appId3, content, applyScene: text8(args, "apply-scene") };
|
|
25794
26381
|
if (ctx.flags.dryRun) {
|
|
25795
26382
|
return { result: { dryRun: true, ...input }, message: "Would create a guideline." };
|
|
25796
26383
|
}
|
|
@@ -25823,7 +26410,7 @@ function registerGuidelineCommands(registry, ctx) {
|
|
|
25823
26410
|
async handler(args) {
|
|
25824
26411
|
const appId3 = await resolveAppId(ctx, args, WHY_APP5);
|
|
25825
26412
|
const guidelineId = assertResourceId(String(args["guideline-id"]), "guideline-id");
|
|
25826
|
-
const input = { appId: appId3, guidelineId, content:
|
|
26413
|
+
const input = { appId: appId3, guidelineId, content: text8(args, "content"), applyScene: optional(args, "apply-scene") };
|
|
25827
26414
|
if (ctx.flags.dryRun) {
|
|
25828
26415
|
return { result: { dryRun: true, ...input }, message: `Would update guideline ${guidelineId}.` };
|
|
25829
26416
|
}
|
|
@@ -25892,8 +26479,8 @@ function registerGuidelineCommands(registry, ctx) {
|
|
|
25892
26479
|
appId: appId3,
|
|
25893
26480
|
limit: ctx.flags.limit,
|
|
25894
26481
|
page: ctx.flags.page,
|
|
25895
|
-
releaseId:
|
|
25896
|
-
query:
|
|
26482
|
+
releaseId: text8(args, "release-id"),
|
|
26483
|
+
query: text8(args, "query")
|
|
25897
26484
|
});
|
|
25898
26485
|
return page2(ctx, result, `adp guideline changes --app-id ${appId3}`);
|
|
25899
26486
|
}
|
|
@@ -25910,7 +26497,7 @@ function registerGuidelineCommands(registry, ctx) {
|
|
|
25910
26497
|
async handler(args) {
|
|
25911
26498
|
const appId3 = await resolveAppId(ctx, args, WHY_APP5);
|
|
25912
26499
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
25913
|
-
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") });
|
|
25914
26501
|
return page2(ctx, result, `adp guideline task list --app-id ${appId3}`);
|
|
25915
26502
|
}
|
|
25916
26503
|
})
|
|
@@ -25950,16 +26537,16 @@ function registerGuidelineCommands(registry, ctx) {
|
|
|
25950
26537
|
],
|
|
25951
26538
|
async handler(args) {
|
|
25952
26539
|
const appId3 = await resolveAppId(ctx, args, WHY_APP5);
|
|
25953
|
-
const fromTaskId =
|
|
25954
|
-
const evaluationId =
|
|
25955
|
-
const modelId =
|
|
26540
|
+
const fromTaskId = text8(args, "from-task-id");
|
|
26541
|
+
const evaluationId = text8(args, "evaluation-id");
|
|
26542
|
+
const modelId = text8(args, "model");
|
|
25956
26543
|
if (Boolean(fromTaskId) === Boolean(evaluationId)) {
|
|
25957
26544
|
throw new DomainError("Pass exactly one of --evaluation-id or --from-task-id", "usage", "UsageError");
|
|
25958
26545
|
}
|
|
25959
26546
|
if (evaluationId && !modelId) {
|
|
25960
26547
|
throw new DomainError("--evaluation-id needs --model", "usage", "UsageError", { hint: "Pick one from adp models" });
|
|
25961
26548
|
}
|
|
25962
|
-
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 };
|
|
25963
26550
|
if (ctx.flags.dryRun) {
|
|
25964
26551
|
return { result: { dryRun: true, ...input }, message: "Would start a guideline generation task." };
|
|
25965
26552
|
}
|
|
@@ -26027,7 +26614,7 @@ function registerGuidelineCommands(registry, ctx) {
|
|
|
26027
26614
|
throw new DomainError("Pass --enable or --disable, not both", "usage", "UsageError");
|
|
26028
26615
|
}
|
|
26029
26616
|
const enabled = args.enable === true ? true : args.disable === true ? false : void 0;
|
|
26030
|
-
const input = { appId: appId3, enabled, modelId:
|
|
26617
|
+
const input = { appId: appId3, enabled, modelId: text8(args, "model") };
|
|
26031
26618
|
if (ctx.flags.dryRun) {
|
|
26032
26619
|
return { result: { dryRun: true, ...input }, message: "Would update auto-distill." };
|
|
26033
26620
|
}
|
|
@@ -26128,7 +26715,7 @@ async function deleteFeedback(deps, input) {
|
|
|
26128
26715
|
var WHY_APP6 = "Feedback belongs to an app";
|
|
26129
26716
|
var appIdFlag10 = { name: "app-id", type: "string", describe: "App ID (defaults to adp.jsonc)" };
|
|
26130
26717
|
var appModeFlag = { name: "app-mode", type: "number", describe: "App mode 1-4 (read from the app when omitted)" };
|
|
26131
|
-
function
|
|
26718
|
+
function text9(args, key) {
|
|
26132
26719
|
const value = args[key];
|
|
26133
26720
|
return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
|
|
26134
26721
|
}
|
|
@@ -26138,7 +26725,7 @@ function list2(args, key) {
|
|
|
26138
26725
|
return items.map(String).filter((item) => item.trim() !== "");
|
|
26139
26726
|
}
|
|
26140
26727
|
function required2(args, key) {
|
|
26141
|
-
const value =
|
|
26728
|
+
const value = text9(args, key);
|
|
26142
26729
|
if (!value) {
|
|
26143
26730
|
throw new DomainError(`Missing --${key}`, "usage", "UsageError", { hint: "The platform rejects feedback without both the question and the reply" });
|
|
26144
26731
|
}
|
|
@@ -26178,8 +26765,8 @@ function registerFeedbackCommands(registry, ctx) {
|
|
|
26178
26765
|
appMode,
|
|
26179
26766
|
limit: ctx.flags.limit,
|
|
26180
26767
|
page: ctx.flags.page,
|
|
26181
|
-
query:
|
|
26182
|
-
reason:
|
|
26768
|
+
query: text9(args, "query"),
|
|
26769
|
+
reason: text9(args, "reason"),
|
|
26183
26770
|
status: typeof args.status === "number" ? args.status : void 0
|
|
26184
26771
|
});
|
|
26185
26772
|
return applyListShape(
|
|
@@ -26237,11 +26824,11 @@ function registerFeedbackCommands(registry, ctx) {
|
|
|
26237
26824
|
appId: appId3,
|
|
26238
26825
|
appMode: mode(args),
|
|
26239
26826
|
recordId: assertResourceId(String(args["record-id"]), "record-id"),
|
|
26240
|
-
sessionId:
|
|
26827
|
+
sessionId: text9(args, "session-id"),
|
|
26241
26828
|
question: required2(args, "question"),
|
|
26242
26829
|
answer: required2(args, "answer"),
|
|
26243
26830
|
reasons: list2(args, "reason"),
|
|
26244
|
-
rightAnswer:
|
|
26831
|
+
rightAnswer: text9(args, "right-answer"),
|
|
26245
26832
|
acceptTerms: args["accept-terms"] === true
|
|
26246
26833
|
};
|
|
26247
26834
|
assertFeedbackTerms(input.acceptTerms);
|
|
@@ -26397,7 +26984,7 @@ var WHY = "File volumes belong to a space";
|
|
|
26397
26984
|
var spaceIdFlag8 = { name: "space-id", type: "string", describe: "Space ID (defaults to adp.jsonc)" };
|
|
26398
26985
|
var volumeIdFlag = { name: "volume-id", type: "string", describe: "Volume ID", required: true };
|
|
26399
26986
|
var pathFlag = { name: "path", type: "string", describe: "Path inside the volume, e.g. docs/report.pdf", required: true };
|
|
26400
|
-
function
|
|
26987
|
+
function text10(value) {
|
|
26401
26988
|
return typeof value === "string" ? value : void 0;
|
|
26402
26989
|
}
|
|
26403
26990
|
async function ref2(ctx, args) {
|
|
@@ -26414,7 +27001,7 @@ function registerVolumeCommands(registry, ctx) {
|
|
|
26414
27001
|
examples: ["adp volume list --space-id sp-1 --format json"],
|
|
26415
27002
|
async handler(args) {
|
|
26416
27003
|
const spaceId = await resolveSpaceId(ctx, args, WHY);
|
|
26417
|
-
const query =
|
|
27004
|
+
const query = text10(args.query);
|
|
26418
27005
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
26419
27006
|
const page3 = await gateways.volume.list({ spaceId, limit: ctx.flags.limit, page: ctx.flags.page, query });
|
|
26420
27007
|
return applyListShape(
|
|
@@ -26458,7 +27045,7 @@ function registerVolumeCommands(registry, ctx) {
|
|
|
26458
27045
|
return { result: { dryRun: true, spaceId, name }, message: `Would create volume ${name}.` };
|
|
26459
27046
|
}
|
|
26460
27047
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
26461
|
-
const result = await createVolume(gateways.volume, { spaceId, name, description:
|
|
27048
|
+
const result = await createVolume(gateways.volume, { spaceId, name, description: text10(args.description) });
|
|
26462
27049
|
return { result, message: `Created volume ${result.name} (${result.volumeId}).` };
|
|
26463
27050
|
}
|
|
26464
27051
|
})
|
|
@@ -26477,7 +27064,7 @@ function registerVolumeCommands(registry, ctx) {
|
|
|
26477
27064
|
return { result: { dryRun: true, ...target }, message: "Would update the volume." };
|
|
26478
27065
|
}
|
|
26479
27066
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
26480
|
-
return { result: await updateVolume(gateways.volume, { ...target, name:
|
|
27067
|
+
return { result: await updateVolume(gateways.volume, { ...target, name: text10(args.name), description: text10(args.description) }) };
|
|
26481
27068
|
}
|
|
26482
27069
|
})
|
|
26483
27070
|
);
|
|
@@ -26516,8 +27103,8 @@ function registerVolumeCommands(registry, ctx) {
|
|
|
26516
27103
|
examples: ["adp volume ls --space-id sp-1 --volume-id v-1 --path docs --format json"],
|
|
26517
27104
|
async handler(args) {
|
|
26518
27105
|
const target = await ref2(ctx, args);
|
|
26519
|
-
const path14 =
|
|
26520
|
-
const query =
|
|
27106
|
+
const path14 = text10(args.path) ?? "";
|
|
27107
|
+
const query = text10(args.query);
|
|
26521
27108
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
26522
27109
|
const page3 = await listVolumeEntries(gateways.volume, { ...target, path: path14, query, limit: ctx.flags.limit, page: ctx.flags.page });
|
|
26523
27110
|
return applyListShape(
|
|
@@ -26604,10 +27191,10 @@ function registerVolumeCommands(registry, ctx) {
|
|
|
26604
27191
|
const target = await ref2(ctx, args);
|
|
26605
27192
|
const localPath = canonicalizeLocalPath(String(args.file), ctx.flags.cwd);
|
|
26606
27193
|
if (ctx.flags.dryRun) {
|
|
26607
|
-
return { result: { dryRun: true, ...target, file: localPath, to:
|
|
27194
|
+
return { result: { dryRun: true, ...target, file: localPath, to: text10(args.to) }, message: `Would upload ${localPath}.` };
|
|
26608
27195
|
}
|
|
26609
27196
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
26610
|
-
const result = await uploadToVolume(gateways.volume, { ...target, localPath, to:
|
|
27197
|
+
const result = await uploadToVolume(gateways.volume, { ...target, localPath, to: text10(args.to) });
|
|
26611
27198
|
return { result: { volumeId: target.volumeId, ...result }, message: `Uploaded ${result.sizeBytes} bytes to ${result.path}.` };
|
|
26612
27199
|
}
|
|
26613
27200
|
})
|
|
@@ -26623,7 +27210,7 @@ function registerVolumeCommands(registry, ctx) {
|
|
|
26623
27210
|
async handler(args) {
|
|
26624
27211
|
const target = await ref2(ctx, args);
|
|
26625
27212
|
const remote = String(args.path);
|
|
26626
|
-
const localPath = canonicalizeLocalPath(
|
|
27213
|
+
const localPath = canonicalizeLocalPath(text10(args.output) ?? baseName(remote), ctx.flags.cwd);
|
|
26627
27214
|
const gateways = await ctx.deps.resolveGateways(ctx.flags);
|
|
26628
27215
|
const result = await downloadFromVolume(gateways.volume, { ...target, path: remote, localPath });
|
|
26629
27216
|
return { result, message: `Saved ${result.bytes} bytes to ${result.output}.` };
|
|
@@ -26950,14 +27537,14 @@ async function updateSynonym(gateway, input) {
|
|
|
26950
27537
|
return { appId: input.appId, synonymId: input.synonymId, standardWord, synonyms: finalSynonyms };
|
|
26951
27538
|
}
|
|
26952
27539
|
function batch2(ids4) {
|
|
26953
|
-
const
|
|
26954
|
-
if (
|
|
27540
|
+
const unique3 = [...new Set(ids4)];
|
|
27541
|
+
if (unique3.length === 0) {
|
|
26955
27542
|
throw new DomainError("Pass --synonym-id at least once", "usage", "UsageError");
|
|
26956
27543
|
}
|
|
26957
|
-
if (
|
|
27544
|
+
if (unique3.length > BATCH_MAX2) {
|
|
26958
27545
|
throw new DomainError(`At most ${BATCH_MAX2} synonyms per call`, "usage", "UsageError");
|
|
26959
27546
|
}
|
|
26960
|
-
return
|
|
27547
|
+
return unique3;
|
|
26961
27548
|
}
|
|
26962
27549
|
function settle2(result, appId3, verb) {
|
|
26963
27550
|
if (result.succeeded.length === 0 && result.failed.length > 0) {
|
|
@@ -27091,7 +27678,7 @@ var filterFlags = [
|
|
|
27091
27678
|
{ name: "category-id", type: "string", describe: "Only this category" },
|
|
27092
27679
|
{ name: "unreleased", type: "boolean", describe: "Only entries not yet released", default: false }
|
|
27093
27680
|
];
|
|
27094
|
-
function
|
|
27681
|
+
function text11(args, key) {
|
|
27095
27682
|
const value = args[key];
|
|
27096
27683
|
return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
|
|
27097
27684
|
}
|
|
@@ -27104,7 +27691,7 @@ function ids3(args, key) {
|
|
|
27104
27691
|
return list3(args, key).map((id) => assertResourceId(id, key));
|
|
27105
27692
|
}
|
|
27106
27693
|
function categoryId(args) {
|
|
27107
|
-
const id =
|
|
27694
|
+
const id = text11(args, "category-id");
|
|
27108
27695
|
return id ? assertResourceId(id, "category-id") : void 0;
|
|
27109
27696
|
}
|
|
27110
27697
|
async function guarded6(ref3, run) {
|
|
@@ -27114,7 +27701,7 @@ async function guarded6(ref3, run) {
|
|
|
27114
27701
|
throw explainSynonymError(error, ref3);
|
|
27115
27702
|
}
|
|
27116
27703
|
}
|
|
27117
|
-
function
|
|
27704
|
+
function exportMessage2(result, what) {
|
|
27118
27705
|
if (result.status === "submitted") {
|
|
27119
27706
|
return `${what} export submitted; the file appears in the console notice center.`;
|
|
27120
27707
|
}
|
|
@@ -27136,7 +27723,7 @@ function registerSynonymCommands(registry, ctx) {
|
|
|
27136
27723
|
appId: appId3,
|
|
27137
27724
|
limit: ctx.flags.limit,
|
|
27138
27725
|
page: ctx.flags.page,
|
|
27139
|
-
query:
|
|
27726
|
+
query: text11(args, "query"),
|
|
27140
27727
|
categoryId: categoryId(args),
|
|
27141
27728
|
unreleasedOnly: args.unreleased === true
|
|
27142
27729
|
});
|
|
@@ -27163,7 +27750,7 @@ function registerSynonymCommands(registry, ctx) {
|
|
|
27163
27750
|
examples: ["adp synonym create --app-id app-1 --word \u53EF\u53E3\u53EF\u4E50 --synonym \u53EF\u4E50 --synonym coke"],
|
|
27164
27751
|
async handler(args) {
|
|
27165
27752
|
const appId3 = await resolveAppId(ctx, args, WHY_APP7);
|
|
27166
|
-
const input = { appId: appId3, standardWord:
|
|
27753
|
+
const input = { appId: appId3, standardWord: text11(args, "word") ?? "", synonyms: list3(args, "synonym"), categoryId: categoryId(args) };
|
|
27167
27754
|
if (ctx.flags.dryRun) {
|
|
27168
27755
|
return { result: { dryRun: true, ...input }, message: `Would add synonym ${input.standardWord}.` };
|
|
27169
27756
|
}
|
|
@@ -27190,7 +27777,7 @@ function registerSynonymCommands(registry, ctx) {
|
|
|
27190
27777
|
const appId3 = await resolveAppId(ctx, args, WHY_APP7);
|
|
27191
27778
|
const synonymId = assertResourceId(String(args["synonym-id"]), "synonym-id");
|
|
27192
27779
|
const synonyms = list3(args, "synonym");
|
|
27193
|
-
const input = { appId: appId3, synonymId, standardWord:
|
|
27780
|
+
const input = { appId: appId3, synonymId, standardWord: text11(args, "word"), synonyms: synonyms.length > 0 ? synonyms : void 0 };
|
|
27194
27781
|
if (ctx.flags.dryRun) {
|
|
27195
27782
|
return { result: { dryRun: true, ...input }, message: `Would update synonym ${synonymId}.` };
|
|
27196
27783
|
}
|
|
@@ -27272,11 +27859,11 @@ function registerSynonymCommands(registry, ctx) {
|
|
|
27272
27859
|
examples: ["adp synonym category create --app-id app-1 --name \u996E\u6599"],
|
|
27273
27860
|
async handler(args) {
|
|
27274
27861
|
const appId3 = await resolveAppId(ctx, args, WHY_APP7);
|
|
27275
|
-
const name =
|
|
27862
|
+
const name = text11(args, "name");
|
|
27276
27863
|
if (!name) {
|
|
27277
27864
|
throw new DomainError("Missing --name", "usage", "UsageError");
|
|
27278
27865
|
}
|
|
27279
|
-
const parentId =
|
|
27866
|
+
const parentId = text11(args, "parent-id") ? assertResourceId(String(args["parent-id"]), "parent-id") : ROOT_CATEGORY_ID;
|
|
27280
27867
|
if (ctx.flags.dryRun) {
|
|
27281
27868
|
return { result: { dryRun: true, appId: appId3, name, parentId }, message: `Would create category ${name}.` };
|
|
27282
27869
|
}
|
|
@@ -27301,7 +27888,7 @@ function registerSynonymCommands(registry, ctx) {
|
|
|
27301
27888
|
async handler(args) {
|
|
27302
27889
|
const appId3 = await resolveAppId(ctx, args, WHY_APP7);
|
|
27303
27890
|
const id = assertResourceId(String(args["category-id"]), "category-id");
|
|
27304
|
-
const name =
|
|
27891
|
+
const name = text11(args, "name");
|
|
27305
27892
|
if (!name) {
|
|
27306
27893
|
throw new DomainError("Missing --name", "usage", "UsageError");
|
|
27307
27894
|
}
|
|
@@ -27350,8 +27937,8 @@ function registerSynonymCommands(registry, ctx) {
|
|
|
27350
27937
|
examples: ["adp synonym export --app-id app-1 --output ./synonyms.xlsx"],
|
|
27351
27938
|
async handler(args) {
|
|
27352
27939
|
const appId3 = await resolveAppId(ctx, args, WHY_APP7);
|
|
27353
|
-
const output =
|
|
27354
|
-
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 };
|
|
27355
27942
|
if (ctx.flags.dryRun) {
|
|
27356
27943
|
return { result: { dryRun: true, ...input, output }, message: "Would export synonyms." };
|
|
27357
27944
|
}
|
|
@@ -27360,7 +27947,7 @@ function registerSynonymCommands(registry, ctx) {
|
|
|
27360
27947
|
{ synonyms: gateways.synonym, downloader: gateways.packageDownloader },
|
|
27361
27948
|
{ ...input, output, wait: args.wait !== false }
|
|
27362
27949
|
);
|
|
27363
|
-
return { result, message:
|
|
27950
|
+
return { result, message: exportMessage2(result, "Synonyms") };
|
|
27364
27951
|
}
|
|
27365
27952
|
})
|
|
27366
27953
|
);
|
|
@@ -27477,7 +28064,7 @@ var filterFlags2 = [
|
|
|
27477
28064
|
{ name: "reason", type: "string", describe: "Reason label, repeatable" },
|
|
27478
28065
|
{ name: "status", type: "string", describe: "Handling status, repeatable", choices: Object.keys(UNSATISFIED_STATUS_FILTERS) }
|
|
27479
28066
|
];
|
|
27480
|
-
function
|
|
28067
|
+
function text12(args, key) {
|
|
27481
28068
|
const value = args[key];
|
|
27482
28069
|
return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
|
|
27483
28070
|
}
|
|
@@ -27488,7 +28075,7 @@ function list4(args, key) {
|
|
|
27488
28075
|
}
|
|
27489
28076
|
function filters5(args) {
|
|
27490
28077
|
return {
|
|
27491
|
-
query:
|
|
28078
|
+
query: text12(args, "query"),
|
|
27492
28079
|
reasons: list4(args, "reason"),
|
|
27493
28080
|
statuses: list4(args, "status").map((status) => UNSATISFIED_STATUS_FILTERS[status])
|
|
27494
28081
|
};
|
|
@@ -27579,7 +28166,7 @@ function registerUnsatisfiedCommands(registry, ctx) {
|
|
|
27579
28166
|
examples: ["adp unsatisfied export --app-id app-1 --status pending --output ./unsatisfied.xlsx"],
|
|
27580
28167
|
async handler(args) {
|
|
27581
28168
|
const appId3 = await resolveAppId(ctx, args, WHY_APP8);
|
|
27582
|
-
const output =
|
|
28169
|
+
const output = text12(args, "output") ? canonicalizeLocalPath(String(args.output), ctx.flags.cwd) : void 0;
|
|
27583
28170
|
const input = { appId: appId3, ...filters5(args), replyIds: list4(args, "reply-id").map((id) => assertResourceId(id, "reply-id")) };
|
|
27584
28171
|
if (ctx.flags.dryRun) {
|
|
27585
28172
|
return { result: { dryRun: true, ...input, output }, message: "Would export unsatisfied replies." };
|
|
@@ -27589,7 +28176,7 @@ function registerUnsatisfiedCommands(registry, ctx) {
|
|
|
27589
28176
|
{ unsatisfied: gateways.unsatisfied, downloader: gateways.packageDownloader },
|
|
27590
28177
|
{ ...input, output, wait: args.wait !== false }
|
|
27591
28178
|
);
|
|
27592
|
-
return { result, message:
|
|
28179
|
+
return { result, message: exportMessage2(result, "Unsatisfied replies") };
|
|
27593
28180
|
}
|
|
27594
28181
|
})
|
|
27595
28182
|
);
|
|
@@ -27624,8 +28211,8 @@ function registerUnsatisfiedCommands(registry, ctx) {
|
|
|
27624
28211
|
examples: ["adp unsatisfied label create --app-id app-1 --group \u7406\u89E3\u6709\u8BEF --name \u6F0F\u770B\u9644\u4EF6"],
|
|
27625
28212
|
async handler(args) {
|
|
27626
28213
|
const appId3 = await resolveAppId(ctx, args, WHY_APP8);
|
|
27627
|
-
const groupName =
|
|
27628
|
-
const labelName =
|
|
28214
|
+
const groupName = text12(args, "group");
|
|
28215
|
+
const labelName = text12(args, "name");
|
|
27629
28216
|
if (!groupName || !labelName) {
|
|
27630
28217
|
throw new DomainError("Missing --group or --name", "usage", "UsageError");
|
|
27631
28218
|
}
|
|
@@ -27653,7 +28240,7 @@ function registerUnsatisfiedCommands(registry, ctx) {
|
|
|
27653
28240
|
examples: ["adp unsatisfied label update --app-id app-1 --label-id l-1 --name \u6F0F\u770B\u56FE\u7247"],
|
|
27654
28241
|
async handler(args) {
|
|
27655
28242
|
const appId3 = await resolveAppId(ctx, args, WHY_APP8);
|
|
27656
|
-
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") };
|
|
27657
28244
|
if (ctx.flags.dryRun) {
|
|
27658
28245
|
return { result: { dryRun: true, ...input }, message: `Would update label ${input.labelId}.` };
|
|
27659
28246
|
}
|
|
@@ -27758,9 +28345,9 @@ async function getDocContent(gateway, input) {
|
|
|
27758
28345
|
};
|
|
27759
28346
|
}
|
|
27760
28347
|
var HEADING = /^(#{1,6})\s+(.+?)\s*#*\s*$/;
|
|
27761
|
-
function extractSection(
|
|
28348
|
+
function extractSection(text13, section, documentId) {
|
|
27762
28349
|
const wanted = section.trim().toLowerCase();
|
|
27763
|
-
const lines =
|
|
28350
|
+
const lines = text13.split("\n");
|
|
27764
28351
|
const start = lines.findIndex((line) => HEADING.exec(line)?.[2]?.trim().toLowerCase() === wanted);
|
|
27765
28352
|
if (start < 0) {
|
|
27766
28353
|
throw notFoundError(
|
|
@@ -28483,12 +29070,12 @@ async function runCli(options) {
|
|
|
28483
29070
|
});
|
|
28484
29071
|
try {
|
|
28485
29072
|
const helpText = await new Promise((resolve, reject) => {
|
|
28486
|
-
parser.parse(argv, (error, _parsed,
|
|
29073
|
+
parser.parse(argv, (error, _parsed, text13) => {
|
|
28487
29074
|
if (error && exitCode === ExitCode.OK && !(error instanceof DomainError)) {
|
|
28488
29075
|
reject(error);
|
|
28489
29076
|
return;
|
|
28490
29077
|
}
|
|
28491
|
-
resolve(
|
|
29078
|
+
resolve(text13 ?? "");
|
|
28492
29079
|
});
|
|
28493
29080
|
});
|
|
28494
29081
|
if (helpText && exitCode === ExitCode.OK) {
|