@thinkingai/ae-cli 6.1.28 → 6.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -4
- package/README.zh.md +24 -4
- package/bin/ae-cli.js +5 -0
- package/bin/runtime-capabilities.json +5 -0
- package/cli-installation-guide.md +24 -3
- package/dist/{auth-NKD5Z5BQ.js → auth-OBQ5KVQM.js} +30 -12
- package/dist/{automation-K32V2NKP.js → automation-NAR5DDGL.js} +6 -6
- package/dist/{capability-4CGSL7PK.js → capability-LFSVNI5B.js} +54 -26
- package/dist/chunk-2UW3Y463.js +2289 -0
- package/dist/{chunk-QW3R6O7L.js → chunk-3SDHJOCR.js} +57 -15
- package/dist/chunk-6HAUVWOQ.js +132 -0
- package/dist/{chunk-KHS64JZQ.js → chunk-72NJKS7O.js} +4 -4
- package/dist/{chunk-UUD5RB36.js → chunk-7JAVT5TK.js} +3 -3
- package/dist/{chunk-GTPWDLTE.js → chunk-CVCTFLSO.js} +35 -14
- package/dist/{chunk-P7KL7IOH.js → chunk-H3K5UGYC.js} +2 -2
- package/dist/{chunk-P6VFCH3P.js → chunk-IN7KKL6K.js} +2 -2
- package/dist/{chunk-T44M3PLZ.js → chunk-JEUXDY3B.js} +1 -1
- package/dist/{chunk-LMCYSVVA.js → chunk-JNVVJ273.js} +51 -37
- package/dist/{chunk-JJJIP2XQ.js → chunk-N6XBLRB7.js} +2 -2
- package/dist/{chunk-QSAR3GHY.js → chunk-OAWPT7VP.js} +2 -2
- package/dist/{chunk-UF244C5C.js → chunk-PWXDWMCW.js} +7 -7
- package/dist/{chunk-2IYIYSUO.js → chunk-QVRIDN42.js} +2 -2
- package/dist/chunk-QZLRHGVH.js +222 -0
- package/dist/{chunk-GI5BMEZO.js → chunk-QZUVLFNR.js} +1 -1
- package/dist/{chunk-2UWS5CUP.js → chunk-RJHGDWSC.js} +3 -3
- package/dist/{chunk-UJ7UPRXK.js → chunk-VCZE3IWO.js} +10 -8
- package/dist/{chunk-X7DRLE62.js → chunk-YVG6QD3V.js} +1 -1
- package/dist/{chunk-ZW4VMY5H.js → chunk-Z3Q2AEIN.js} +152 -98
- package/dist/{community-report-client-S2K3A3Q6.js → community-report-client-TJVCLZ3K.js} +1 -1
- package/dist/compat-check-CII6B74E.js +32 -0
- package/dist/{config-ASSAAIOI.js → config-YZ6O2UQ2.js} +38 -6
- package/dist/{context-6RWLVOM5.js → context-F6FCGTF3.js} +4 -4
- package/dist/{data-integration-EXSUPUDZ.js → data-integration-6UAZO4GG.js} +207 -24
- package/dist/{evaluation-5YT4QLCL.js → evaluation-4LO2O4AF.js} +4 -4
- package/dist/index.js +297 -70
- package/dist/{local-data-upload-client-7HCPGIS3.js → local-data-upload-client-KCMG6J62.js} +1 -1
- package/dist/{memory-VCYLVPMI.js → memory-HHPX3NF2.js} +6 -6
- package/dist/{metadata-YGI5M6OF.js → metadata-TIFY24LW.js} +16 -8
- package/dist/{model-DPJHSD73.js → model-7UHGWYVR.js} +4 -4
- package/dist/{personal-semantic-preference-76TBKAPY.js → personal-semantic-preference-WKJEGPTM.js} +7 -6
- package/dist/{project-semantic-XOEBO2Q5.js → project-semantic-EIQVZNHW.js} +11 -10
- package/dist/{sync-7PP6KQ75.js → sync-RV3OPCTI.js} +8 -7
- package/dist/{te-agent-PJVAPKBD.js → te-agent-5ENVZJUH.js} +11 -7
- package/dist/{te-analysis-OX62G5VD.js → te-analysis-USIK6ZZG.js} +185 -33
- package/dist/{te-community-QN3WMPNT.js → te-community-WE2UU4XV.js} +720 -228
- package/dist/{te-dataops-UKD2XN3E.js → te-dataops-XNMO7MBF.js} +6 -5
- package/dist/{te-engage-X3DIXPRA.js → te-engage-6C3HCFQR.js} +13 -12
- package/dist/{te-experiment-MEIIK3DP.js → te-experiment-LVTRI3QK.js} +55 -21
- package/dist/{te-kb-73EWDFDF.js → te-kb-TUPGMVBY.js} +409 -85
- package/dist/{te-system-IE7NCKC3.js → te-system-YM657FKO.js} +6 -6
- package/dist/{te-team-MGQ5CNRW.js → te-team-G4VEJJNL.js} +7 -6
- package/dist/{things-4JIBCA55.js → things-22KQWC23.js} +7 -7
- package/dist/{update-AX66IFMJ.js → update-XX4ILU7X.js} +11 -7
- package/dist/{workspace-Q5NMEKEN.js → workspace-LYDAP647.js} +6 -6
- package/package.json +17 -7
- package/skills/ae-agent/references/resource-package.md +4 -0
- package/skills/ae-analysis/SKILL.md +14 -10
- package/skills/ae-analysis/references/agent_review_preflight.md +52 -11
- package/skills/ae-analysis/references/agent_review_priorities_comparisons.md +5 -3
- package/skills/ae-analysis/references/agent_review_submit_to_page.md +57 -25
- package/skills/ae-analysis/references/command_index.md +7 -3
- package/skills/ae-analysis/references/governance_recommendation_export.md +31 -17
- package/skills/ae-analysis/references/governance_recommendation_run_update.md +13 -0
- package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +9 -1
- package/skills/ae-analysis/references/scenario_append.md +6 -0
- package/skills/ae-analysis/references/scenario_begin.md +11 -0
- package/skills/ae-analysis/references/scenario_collect.md +10 -2
- package/skills/ae-analysis/references/scenario_evaluation.md +6 -18
- package/skills/ae-analysis/references/scenario_get.md +15 -0
- package/skills/ae-analysis/references/scenario_list.md +64 -0
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/company-kb.mjs +14 -1
- package/skills/ae-community/SKILL.md +77 -27
- package/skills/ae-community/references/community-analyzing-theme-comment.md +10 -8
- package/skills/ae-community/references/community-data-quality.md +68 -0
- package/skills/ae-community/references/community-query-evidence.md +85 -0
- package/skills/ae-community/references/community-scenario-capabilities.md +137 -0
- package/skills/ae-community/references/community-weekly-report.md +6 -3
- package/skills/ae-community/references/get_channel_info.md +7 -4
- package/skills/ae-community/references/get_comment_tag_analysis.md +3 -3
- package/skills/ae-community/references/get_comments_summary.md +4 -4
- package/skills/ae-community/references/get_corpus_tags.md +3 -3
- package/skills/ae-community/references/get_daily_summary.md +3 -3
- package/skills/ae-community/references/get_hot_topics.md +3 -3
- package/skills/ae-community/references/get_livestream_analysis.md +3 -3
- package/skills/ae-community/references/get_livestream_detail.md +4 -4
- package/skills/ae-community/references/get_livestream_list.md +3 -3
- package/skills/ae-community/references/get_livestream_overview.md +3 -3
- package/skills/ae-community/references/get_livestream_room_metrics.md +3 -3
- package/skills/ae-community/references/get_livestream_rooms.md +3 -3
- package/skills/ae-community/references/get_overview_metrics.md +3 -3
- package/skills/ae-community/references/get_post_detail.md +4 -4
- package/skills/ae-community/references/get_risk_content.md +5 -5
- package/skills/ae-community/references/get_sentiment_overview.md +4 -4
- package/skills/ae-community/references/get_tag_trends.md +3 -3
- package/skills/ae-community/references/get_topic_detail.md +3 -3
- package/skills/ae-community/references/list_sources.md +28 -0
- package/skills/ae-community/references/list_spaces.md +39 -0
- package/skills/ae-community/references/search_posts.md +21 -7
- package/skills/ae-data-integration/SKILL.md +6 -4
- package/skills/ae-data-integration/references/error-handling.md +1 -0
- package/skills/ae-data-integration/references/handoff.md +1 -1
- package/skills/ae-data-integration/references/sink-upload.md +11 -0
- package/skills/ae-data-integration/references/source-inspect.md +2 -1
- package/skills/ae-data-integration/references/transform.md +1 -1
- package/skills/ae-data-integration/references/ue-mapping.md +1 -1
- package/skills/ae-experiment/SKILL.md +7 -1
- package/skills/ae-experiment/references/manage_experiment.md +18 -1
- package/skills/ae-experiment/references/query_experiment_detail.md +7 -0
- package/skills/ae-experiment/references/save_experiment.md +76 -2
- package/skills/ae-experiment/references/save_submit_experiment.md +7 -0
- package/skills/ae-kb/SKILL.md +33 -6
- package/skills/ae-kb/references/publication.md +81 -0
- package/skills/ae-kb/references/query-workflow.md +14 -1
- package/skills/ae-metadata/SKILL.md +2 -2
- package/skills/ae-metadata/references/metadata_data_table_get.md +35 -0
- package/dist/chunk-ELCR235M.js +0 -1429
package/dist/chunk-ELCR235M.js
DELETED
|
@@ -1,1429 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
peekCliToken
|
|
4
|
-
} from "./chunk-P7KL7IOH.js";
|
|
5
|
-
import {
|
|
6
|
-
getActiveHost,
|
|
7
|
-
getConfigDir,
|
|
8
|
-
isAeSandboxRuntime
|
|
9
|
-
} from "./chunk-LMCYSVVA.js";
|
|
10
|
-
import {
|
|
11
|
-
externalCliTokenRequestOptions,
|
|
12
|
-
logger,
|
|
13
|
-
normalizeUrl,
|
|
14
|
-
readExternalCliToken,
|
|
15
|
-
redactExternalCliToken
|
|
16
|
-
} from "./chunk-ZW4VMY5H.js";
|
|
17
|
-
|
|
18
|
-
// src/core/install-process.ts
|
|
19
|
-
import spawn from "cross-spawn";
|
|
20
|
-
import fs from "fs";
|
|
21
|
-
import path from "path";
|
|
22
|
-
var INSTALL_TIMEOUT_MS = 12e4;
|
|
23
|
-
var SKILLS_TOOL = "skills@1.5.12";
|
|
24
|
-
var defaultInstallRunner = (command, args, timeoutMs) => {
|
|
25
|
-
const result = spawn.sync(command, args, {
|
|
26
|
-
encoding: "utf8",
|
|
27
|
-
maxBuffer: 8 * 1024 * 1024,
|
|
28
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
29
|
-
timeout: timeoutMs,
|
|
30
|
-
windowsHide: true,
|
|
31
|
-
env: {
|
|
32
|
-
...process.env,
|
|
33
|
-
DISABLE_TELEMETRY: "1",
|
|
34
|
-
NO_COLOR: "1",
|
|
35
|
-
// Select installed clients, not only the AI that launched AE CLI.
|
|
36
|
-
...args[1] === SKILLS_TOOL && args[2] === "add" ? { AI_AGENT: "ae-cli" } : {}
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
return { ...result, stdout: result.stdout || "", stderr: result.stderr || "" };
|
|
40
|
-
};
|
|
41
|
-
function resolveNodeTool(tool, execPath = process.execPath, platform = process.platform) {
|
|
42
|
-
const filename = platform === "win32" ? `${tool}.cmd` : tool;
|
|
43
|
-
const sibling = path.join(path.dirname(execPath), filename);
|
|
44
|
-
return fs.existsSync(sibling) ? sibling : filename;
|
|
45
|
-
}
|
|
46
|
-
function commandSucceeded(result) {
|
|
47
|
-
return !result.error && !result.signal && result.status === 0;
|
|
48
|
-
}
|
|
49
|
-
function exactVersion(raw) {
|
|
50
|
-
const version = raw.trim().replace(/^v/i, "");
|
|
51
|
-
if (!/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.test(version)) {
|
|
52
|
-
throw new Error("Expected an exact version such as 6.0.49 or 6.1.9.");
|
|
53
|
-
}
|
|
54
|
-
return version;
|
|
55
|
-
}
|
|
56
|
-
function installHost(raw) {
|
|
57
|
-
if (!raw) return null;
|
|
58
|
-
const normalized = normalizeUrl(raw.trim());
|
|
59
|
-
try {
|
|
60
|
-
if (raw.includes("://") && !/^https?:\/\//.test(raw.trim())) throw new Error();
|
|
61
|
-
const url = new URL(normalized);
|
|
62
|
-
if (!["https:", "http:"].includes(url.protocol) || !url.hostname || url.username || url.password || url.search || url.hash || /[\s'"`$\\<>]/.test(normalized)) throw new Error();
|
|
63
|
-
return normalized;
|
|
64
|
-
} catch {
|
|
65
|
-
throw new Error("Host must be an HTTP(S) URL without credentials, query parameters, or fragments.");
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function classifyInstallFailure(result) {
|
|
69
|
-
const text = `${result.error?.message || ""}
|
|
70
|
-
${result.stderr}
|
|
71
|
-
${result.stdout}`;
|
|
72
|
-
if (result.error?.code === "ETIMEDOUT" || /timed?\s*out|ETIMEDOUT/i.test(text)) return "timeout";
|
|
73
|
-
if (/EACCES|EPERM|permission denied|access is denied/i.test(text)) return "permission";
|
|
74
|
-
if (/EAI_AGAIN|ENOTFOUND|ECONNRESET|ECONNREFUSED|network|unable to access|could not resolve|certificate|SSL/i.test(text)) return "network";
|
|
75
|
-
if (/E404|404 Not Found|no matching version|couldn't find remote ref/i.test(text)) return "package_missing";
|
|
76
|
-
return "unknown";
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// src/core/package-info.ts
|
|
80
|
-
import fs2 from "fs";
|
|
81
|
-
import path2 from "path";
|
|
82
|
-
import { fileURLToPath } from "url";
|
|
83
|
-
function getLocalCliPackageInfo() {
|
|
84
|
-
let dir = path2.dirname(fileURLToPath(import.meta.url));
|
|
85
|
-
for (let i = 0; i < 8; i += 1) {
|
|
86
|
-
const candidate = path2.join(dir, "package.json");
|
|
87
|
-
try {
|
|
88
|
-
if (fs2.existsSync(candidate)) {
|
|
89
|
-
const pkg = JSON.parse(fs2.readFileSync(candidate, "utf8"));
|
|
90
|
-
if (pkg.name && pkg.version && String(pkg.name).includes("ae-cli")) {
|
|
91
|
-
return { name: pkg.name, version: pkg.version, root: dir };
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
} catch {
|
|
95
|
-
}
|
|
96
|
-
const parent = path2.dirname(dir);
|
|
97
|
-
if (parent === dir) break;
|
|
98
|
-
dir = parent;
|
|
99
|
-
}
|
|
100
|
-
return { name: "@tant/ae-cli", version: "0.0.0", root: "" };
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// src/core/version-sync.ts
|
|
104
|
-
import fs5 from "fs";
|
|
105
|
-
import path5 from "path";
|
|
106
|
-
|
|
107
|
-
// src/core/update-check.ts
|
|
108
|
-
function shouldSkipUpdateCheck(argv = process.argv) {
|
|
109
|
-
if (process.env.AE_CLI_NO_UPDATE_CHECK === "1") return true;
|
|
110
|
-
if (process.env.CI === "true" || process.env.CI === "1") return true;
|
|
111
|
-
return argv.slice(2).some((arg, index, args) => {
|
|
112
|
-
if (arg === "--no-update-check") return true;
|
|
113
|
-
if (arg === "--version") {
|
|
114
|
-
const value = args[index + 1];
|
|
115
|
-
return !value || value.startsWith("-");
|
|
116
|
-
}
|
|
117
|
-
if (arg === "-V" || arg === "--help" || arg === "-h") return true;
|
|
118
|
-
return false;
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
function parseVersion(version) {
|
|
122
|
-
const core = version.trim().split("-")[0];
|
|
123
|
-
return core.split(".").map((part) => {
|
|
124
|
-
const n = Number.parseInt(part, 10);
|
|
125
|
-
return Number.isFinite(n) ? n : 0;
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
function isNewer(latest, current) {
|
|
129
|
-
const a = parseVersion(latest);
|
|
130
|
-
const b = parseVersion(current);
|
|
131
|
-
const len = Math.max(a.length, b.length, 3);
|
|
132
|
-
for (let i = 0; i < len; i += 1) {
|
|
133
|
-
const av = a[i] ?? 0;
|
|
134
|
-
const bv = b[i] ?? 0;
|
|
135
|
-
if (av > bv) return true;
|
|
136
|
-
if (av < bv) return false;
|
|
137
|
-
}
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// src/core/legacy-cli-version-map.ts
|
|
142
|
-
var HISTORICAL_CLUSTER_TO_PUBLIC_PIN = {
|
|
143
|
-
"6.0.0": "1.0.15",
|
|
144
|
-
"6.0.1": "1.0.15",
|
|
145
|
-
"6.0.2": "1.0.18",
|
|
146
|
-
"6.0.3": "1.0.18",
|
|
147
|
-
"6.0.4": "1.0.20",
|
|
148
|
-
"6.0.5": "1.0.21",
|
|
149
|
-
"6.0.6": "1.0.22",
|
|
150
|
-
"6.0.7": "1.0.22",
|
|
151
|
-
"6.0.8": "1.0.22",
|
|
152
|
-
"6.0.9": "1.0.22",
|
|
153
|
-
"6.0.10": "1.0.24",
|
|
154
|
-
"6.0.11": "1.0.24",
|
|
155
|
-
"6.0.12": "1.0.27",
|
|
156
|
-
"6.0.13": "1.0.28",
|
|
157
|
-
"6.0.14": "1.0.28",
|
|
158
|
-
"6.0.15": "1.0.30",
|
|
159
|
-
"6.0.16": "6.0.16",
|
|
160
|
-
"6.0.17": "6.0.17",
|
|
161
|
-
"6.0.18": "6.0.18",
|
|
162
|
-
"6.0.19": "6.0.18",
|
|
163
|
-
"6.0.20": "6.0.20",
|
|
164
|
-
"6.0.21": "6.0.20",
|
|
165
|
-
"6.0.22": "6.0.22",
|
|
166
|
-
"6.0.23": "6.0.22",
|
|
167
|
-
"6.0.24": "6.0.24",
|
|
168
|
-
"6.0.25": "6.0.24",
|
|
169
|
-
"6.0.26": "6.0.24"
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
// src/core/version-compat.ts
|
|
173
|
-
var OPEN_SOURCE_AE_CLI_PACKAGE = "@thinkingai/ae-cli";
|
|
174
|
-
var PUBLISHED_EXTERNAL_VERSIONS = /* @__PURE__ */ new Set([
|
|
175
|
-
"1.0.15",
|
|
176
|
-
"1.0.18",
|
|
177
|
-
"1.0.20",
|
|
178
|
-
"1.0.21",
|
|
179
|
-
"1.0.22",
|
|
180
|
-
"1.0.24",
|
|
181
|
-
"1.0.27",
|
|
182
|
-
"1.0.28",
|
|
183
|
-
"1.0.30",
|
|
184
|
-
"6.0.16",
|
|
185
|
-
"6.0.17",
|
|
186
|
-
"6.0.18",
|
|
187
|
-
"6.0.20",
|
|
188
|
-
"6.0.22",
|
|
189
|
-
"6.0.24",
|
|
190
|
-
"6.0.27",
|
|
191
|
-
"6.0.28",
|
|
192
|
-
"6.0.29",
|
|
193
|
-
"6.0.30",
|
|
194
|
-
"6.0.31"
|
|
195
|
-
]);
|
|
196
|
-
function normalizeCliVersion(version) {
|
|
197
|
-
return version.trim().replace(/^v/i, "");
|
|
198
|
-
}
|
|
199
|
-
function versionLine(version) {
|
|
200
|
-
const parts = normalizeCliVersion(version).split(/[.-]/);
|
|
201
|
-
if (parts.length < 2) return normalizeCliVersion(version);
|
|
202
|
-
return `${parts[0]}.${parts[1]}`;
|
|
203
|
-
}
|
|
204
|
-
function sameVersionLine(a, b) {
|
|
205
|
-
return versionLine(a) === versionLine(b);
|
|
206
|
-
}
|
|
207
|
-
function parseVersionParts(version) {
|
|
208
|
-
const core = normalizeCliVersion(version).split("-")[0];
|
|
209
|
-
return core.split(".").map((p) => {
|
|
210
|
-
const n = Number.parseInt(p, 10);
|
|
211
|
-
return Number.isFinite(n) ? n : 0;
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
function compareNormalized(a, b) {
|
|
215
|
-
const pa = parseVersionParts(a);
|
|
216
|
-
const pb = parseVersionParts(b);
|
|
217
|
-
const len = Math.max(pa.length, pb.length, 3);
|
|
218
|
-
for (let i = 0; i < len; i += 1) {
|
|
219
|
-
const av = pa[i] ?? 0;
|
|
220
|
-
const bv = pb[i] ?? 0;
|
|
221
|
-
if (av > bv) return 1;
|
|
222
|
-
if (av < bv) return -1;
|
|
223
|
-
}
|
|
224
|
-
return 0;
|
|
225
|
-
}
|
|
226
|
-
function evaluateCompat(localRaw, expectedRaw, clusterLine) {
|
|
227
|
-
const local = normalizeCliVersion(localRaw);
|
|
228
|
-
const expected = normalizeCliVersion(expectedRaw);
|
|
229
|
-
if (!local || !expected) return { kind: "ok" };
|
|
230
|
-
const line = clusterLine && clusterLine.trim() || versionLine(expected);
|
|
231
|
-
if (!sameVersionLine(local, expected)) {
|
|
232
|
-
return { kind: "line_mismatch", local, expected, line };
|
|
233
|
-
}
|
|
234
|
-
if (clusterLine && clusterLine.trim()) {
|
|
235
|
-
const clusterNorm = clusterLine.trim();
|
|
236
|
-
const localLine = versionLine(local);
|
|
237
|
-
if (localLine !== clusterNorm && localLine !== versionLine(clusterNorm)) {
|
|
238
|
-
return { kind: "line_mismatch", local, expected, line: clusterNorm };
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
if (local === expected) return { kind: "ok" };
|
|
242
|
-
if (isNewer(local, expected)) {
|
|
243
|
-
return { kind: "local_newer", local, expected, line };
|
|
244
|
-
}
|
|
245
|
-
if (isNewer(expected, local)) {
|
|
246
|
-
return { kind: "local_older", local, expected, line };
|
|
247
|
-
}
|
|
248
|
-
return { kind: "ok" };
|
|
249
|
-
}
|
|
250
|
-
function resolvePinTarget(expectedVersion) {
|
|
251
|
-
const expected = expectedVersion.trim().replace(/^v/i, "");
|
|
252
|
-
if (!expected) return null;
|
|
253
|
-
if (PUBLISHED_EXTERNAL_VERSIONS.has(expected)) return expected;
|
|
254
|
-
const historical = HISTORICAL_CLUSTER_TO_PUBLIC_PIN[expected];
|
|
255
|
-
if (historical && PUBLISHED_EXTERNAL_VERSIONS.has(historical)) {
|
|
256
|
-
return historical;
|
|
257
|
-
}
|
|
258
|
-
const line = versionLine(expected);
|
|
259
|
-
const candidates = [...PUBLISHED_EXTERNAL_VERSIONS].filter((tag) => {
|
|
260
|
-
if (versionLine(tag) !== line) return false;
|
|
261
|
-
return compareNormalized(tag, expected) <= 0;
|
|
262
|
-
});
|
|
263
|
-
if (candidates.length === 0) return null;
|
|
264
|
-
candidates.sort((a, b) => compareNormalized(a, b));
|
|
265
|
-
return candidates[candidates.length - 1] ?? null;
|
|
266
|
-
}
|
|
267
|
-
function formatPinCommands(expectedVersion) {
|
|
268
|
-
const ver = resolvePinTarget(expectedVersion);
|
|
269
|
-
if (!ver) return [];
|
|
270
|
-
return [
|
|
271
|
-
`npx ${OPEN_SOURCE_AE_CLI_PACKAGE}@latest update --target ${ver}`
|
|
272
|
-
];
|
|
273
|
-
}
|
|
274
|
-
function formatUpgradeCommands(expectedVersion) {
|
|
275
|
-
let ver;
|
|
276
|
-
try {
|
|
277
|
-
ver = exactVersion(expectedVersion);
|
|
278
|
-
} catch {
|
|
279
|
-
return [];
|
|
280
|
-
}
|
|
281
|
-
return [
|
|
282
|
-
`npx ${OPEN_SOURCE_AE_CLI_PACKAGE}@latest update --target ${ver}`
|
|
283
|
-
];
|
|
284
|
-
}
|
|
285
|
-
function formatUnifiedUpdateCommand() {
|
|
286
|
-
return "ae-cli update";
|
|
287
|
-
}
|
|
288
|
-
function formatCompatNotice(verdict) {
|
|
289
|
-
if (verdict.kind === "ok") return void 0;
|
|
290
|
-
const canUpdateToHost = formatUpgradeCommands(verdict.expected).length > 0;
|
|
291
|
-
if (verdict.kind === "local_newer") {
|
|
292
|
-
if (canUpdateToHost) {
|
|
293
|
-
return [
|
|
294
|
-
`[ae-cli] Host compat: local ${verdict.local} > environment ${verdict.expected} (cluster ${verdict.line}).`,
|
|
295
|
-
` Run: ${formatUnifiedUpdateCommand()} to sync CLI + skills to this host.`,
|
|
296
|
-
` Or update cluster components to the latest version.`
|
|
297
|
-
].join("\n");
|
|
298
|
-
}
|
|
299
|
-
return [
|
|
300
|
-
`[ae-cli] Host compat: local ${verdict.local} > environment ${verdict.expected} (cluster ${verdict.line}).`,
|
|
301
|
-
` No public GitHub/npm release on this line is \u2264 environment ${verdict.expected}.`,
|
|
302
|
-
` Update cluster components to the latest version to match your CLI.`
|
|
303
|
-
].join("\n");
|
|
304
|
-
}
|
|
305
|
-
if (verdict.kind === "local_older") {
|
|
306
|
-
if (canUpdateToHost) {
|
|
307
|
-
return [
|
|
308
|
-
`[ae-cli] Host compat: local ${verdict.local} < environment ${verdict.expected} (cluster ${verdict.line}).`,
|
|
309
|
-
` Run: ${formatUnifiedUpdateCommand()} to sync CLI + skills to this host.`
|
|
310
|
-
].join("\n");
|
|
311
|
-
}
|
|
312
|
-
return [
|
|
313
|
-
`[ae-cli] Host compat: local ${verdict.local} < environment ${verdict.expected} (cluster ${verdict.line}).`,
|
|
314
|
-
` No installable semver target for environment ${verdict.expected}.`,
|
|
315
|
-
` Ask the platform owner for the install package, or wait for a published build.`
|
|
316
|
-
].join("\n");
|
|
317
|
-
}
|
|
318
|
-
if (canUpdateToHost) {
|
|
319
|
-
return [
|
|
320
|
-
`[ae-cli] Host compat: local ${verdict.local} line mismatches environment ${verdict.expected} (cluster ${verdict.line}).`,
|
|
321
|
-
` Run: ${formatUnifiedUpdateCommand()} to sync CLI + skills to this host.`,
|
|
322
|
-
` Or update cluster components to the latest version to match your CLI line.`
|
|
323
|
-
].join("\n");
|
|
324
|
-
}
|
|
325
|
-
return [
|
|
326
|
-
`[ae-cli] Host compat: local ${verdict.local} line mismatches environment ${verdict.expected} (cluster ${verdict.line}).`,
|
|
327
|
-
` No public GitHub/npm release for this line; update cluster components to the latest version, or install a published build on the same line.`
|
|
328
|
-
].join("\n");
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// src/core/installation.ts
|
|
332
|
-
import fs4 from "fs";
|
|
333
|
-
import path4 from "path";
|
|
334
|
-
|
|
335
|
-
// src/core/skills-install.ts
|
|
336
|
-
import fs3 from "fs";
|
|
337
|
-
import os from "os";
|
|
338
|
-
import path3 from "path";
|
|
339
|
-
import { parseDocument } from "yaml";
|
|
340
|
-
function globalSkillsDirectory() {
|
|
341
|
-
return path3.join(os.homedir(), ".agents", "skills");
|
|
342
|
-
}
|
|
343
|
-
function skillName(content) {
|
|
344
|
-
const frontmatter = content.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);
|
|
345
|
-
if (!frontmatter) throw new Error("Missing YAML frontmatter.");
|
|
346
|
-
const parsed = parseDocument(frontmatter[1], { uniqueKeys: true });
|
|
347
|
-
if (parsed.errors.length) throw new Error("Invalid YAML frontmatter.");
|
|
348
|
-
const data = parsed.toJS({ maxAliasCount: 100 });
|
|
349
|
-
if (!data || typeof data.name !== "string" || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(data.name) || typeof data.description !== "string" || !data.description.trim()) throw new Error("Invalid Skill metadata.");
|
|
350
|
-
return data.name;
|
|
351
|
-
}
|
|
352
|
-
function readFiles(root, prefix = "", files = /* @__PURE__ */ new Map()) {
|
|
353
|
-
for (const entry of fs3.readdirSync(path3.join(root, prefix), { withFileTypes: true })) {
|
|
354
|
-
if (entry.name.startsWith(".") || ["metadata.json", "__pycache__", "__pypackages__"].includes(entry.name)) continue;
|
|
355
|
-
const relative = path3.join(prefix, entry.name);
|
|
356
|
-
if (entry.isSymbolicLink()) throw new Error("Bundled Skills must contain regular files.");
|
|
357
|
-
if (entry.isDirectory()) readFiles(root, relative, files);
|
|
358
|
-
else if (entry.isFile()) files.set(relative, fs3.readFileSync(path3.join(root, relative)));
|
|
359
|
-
}
|
|
360
|
-
return files;
|
|
361
|
-
}
|
|
362
|
-
function readBundledSkills(directory) {
|
|
363
|
-
const skills = fs3.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => {
|
|
364
|
-
try {
|
|
365
|
-
const files = readFiles(path3.join(directory, entry.name));
|
|
366
|
-
return { name: skillName(files.get("SKILL.md").toString("utf8")), files };
|
|
367
|
-
} catch {
|
|
368
|
-
const name = /^[a-z0-9-]+$/.test(entry.name) ? entry.name : "(invalid name)";
|
|
369
|
-
throw new Error(`Invalid bundled Skill ${name}: missing files or YAML/frontmatter error.`);
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
if (!skills.length || new Set(skills.map((skill) => skill.name)).size !== skills.length) {
|
|
373
|
-
throw new Error("Bundled Skills are empty or contain duplicate names.");
|
|
374
|
-
}
|
|
375
|
-
return skills;
|
|
376
|
-
}
|
|
377
|
-
function verifyGlobalSkills(skills, directory) {
|
|
378
|
-
return skills.flatMap((skill) => {
|
|
379
|
-
let reason = "";
|
|
380
|
-
try {
|
|
381
|
-
const target = path3.join(directory, skill.name);
|
|
382
|
-
if (skillName(fs3.readFileSync(path3.join(target, "SKILL.md"), "utf8")) !== skill.name) {
|
|
383
|
-
reason = "Installed Skill name does not match the bundled Skill.";
|
|
384
|
-
} else {
|
|
385
|
-
for (const [file, expected] of skill.files) {
|
|
386
|
-
if (!fs3.readFileSync(path3.join(target, file)).equals(expected)) {
|
|
387
|
-
reason = "Installed files do not match the CLI package version.";
|
|
388
|
-
break;
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
} catch (error) {
|
|
393
|
-
reason = error.code === "ENOENT" ? "Expected Skill file is missing." : "Installed Skill has invalid YAML/frontmatter or unreadable files.";
|
|
394
|
-
}
|
|
395
|
-
return reason ? [{ skill: skill.name, reason }] : [];
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
function skillProcessProblem(result) {
|
|
399
|
-
const output = `${result.stdout}
|
|
400
|
-
${result.stderr}`.replace(/\x1b\[[0-9;]*m/g, "");
|
|
401
|
-
if (/(?:YAML|frontmatter)[^\n]*(?:parse|invalid|error)|(?:parse|invalid|error)[^\n]*(?:YAML|frontmatter)/i.test(output)) {
|
|
402
|
-
return "Skills reported a YAML/frontmatter parsing error.";
|
|
403
|
-
}
|
|
404
|
-
const lines = output.split(/\r?\n/);
|
|
405
|
-
const ignored = lines.filter((line) => /(?:PromptScript|Eve) does not support global skill installation\s*$/.test(line));
|
|
406
|
-
const failures = [...output.matchAll(/Failed to install (\d+)/g)].reduce((sum, match) => sum + Number(match[1]), 0);
|
|
407
|
-
const remaining = lines.filter((line) => !ignored.includes(line) && !/Failed to install \d+/.test(line)).join("\n");
|
|
408
|
-
if (failures > ignored.length || /✗|(?:^|\n)[^\w\n]*(?:Error\b|Installation failed\b|Failed\b)/i.test(remaining)) {
|
|
409
|
-
return "Skills installation failed for a supported client. Check directory permissions and retry.";
|
|
410
|
-
}
|
|
411
|
-
if (commandSucceeded(result)) return null;
|
|
412
|
-
if (!result.error && !result.signal && ignored.length > 0 && failures === ignored.length && !/EACCES|EPERM|ETIMEDOUT|ENOTFOUND|ECONN|network|permission denied/i.test(remaining)) return null;
|
|
413
|
-
return "Skills process failed. Check network access and directory permissions, then retry.";
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
// src/core/installation.ts
|
|
417
|
-
function distribution(packageName) {
|
|
418
|
-
if (packageName === "@thinkingai/ae-cli") return { registry: "https://registry.npmjs.org", repository: "ThinkingAIAgenticEngine/ae-cli" };
|
|
419
|
-
if (packageName === "@tant/ae-cli") return { registry: "https://npm.thinkingdata.cn:3443", repository: "http://10.27.249.150:8888/te-ai/te-cli.git" };
|
|
420
|
-
throw new Error("Unsupported CLI package. Use an official AE CLI distribution.");
|
|
421
|
-
}
|
|
422
|
-
function newInstallationReport(packageName, version, dryRun = false) {
|
|
423
|
-
return {
|
|
424
|
-
ok: false,
|
|
425
|
-
dry_run: dryRun,
|
|
426
|
-
cli: { package: packageName, version, path: null, verified: false, action: "pending", warnings: [] },
|
|
427
|
-
skills: {
|
|
428
|
-
directory: globalSkillsDirectory(),
|
|
429
|
-
expected_count: 0,
|
|
430
|
-
installed_count: 0,
|
|
431
|
-
missing: [],
|
|
432
|
-
source: null,
|
|
433
|
-
version,
|
|
434
|
-
status: "pending",
|
|
435
|
-
failures: [],
|
|
436
|
-
attempts: []
|
|
437
|
-
},
|
|
438
|
-
auth: { host: null, authenticated: null, warnings: [] },
|
|
439
|
-
next_steps: []
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
function failInstallation(report, stage, message, cause = "validation") {
|
|
443
|
-
report.ok = false;
|
|
444
|
-
report.error = { type: "config", code: "AE_CLI_INSTALL_FAILED", message, stage, cause };
|
|
445
|
-
if (!report.next_steps.length) report.next_steps.push("Fix the reported problem and rerun the same install or update command.");
|
|
446
|
-
return report;
|
|
447
|
-
}
|
|
448
|
-
function installPlan(packageName, version, root = "<npm-root>") {
|
|
449
|
-
const config = distribution(packageName);
|
|
450
|
-
const target = exactVersion(version);
|
|
451
|
-
const source = path4.join(root, packageName, "skills");
|
|
452
|
-
return [
|
|
453
|
-
`npm install -g ${packageName}@${target} --registry=${config.registry}`,
|
|
454
|
-
`npx -y ${SKILLS_TOOL} add ${JSON.stringify(source)} -g -y --agent universal`,
|
|
455
|
-
`npx -y ${SKILLS_TOOL} add ${config.repository}#v${target} -g -y --agent universal`,
|
|
456
|
-
`npx -y ${SKILLS_TOOL} add ${JSON.stringify(globalSkillsDirectory())} -g -y --copy`
|
|
457
|
-
];
|
|
458
|
-
}
|
|
459
|
-
function verifySkillsAttempt(report, skills, result, stage, source) {
|
|
460
|
-
const problem = skillProcessProblem(result);
|
|
461
|
-
report.skills.failures = verifyGlobalSkills(skills, report.skills.directory);
|
|
462
|
-
if (problem) {
|
|
463
|
-
for (const skill of skills) {
|
|
464
|
-
if (!report.skills.failures.some((failure) => failure.skill === skill.name)) {
|
|
465
|
-
report.skills.failures.push({ skill: skill.name, reason: problem });
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
report.skills.missing = report.skills.failures.map((failure) => failure.skill);
|
|
470
|
-
report.skills.installed_count = skills.length - report.skills.missing.length;
|
|
471
|
-
const cause = commandSucceeded(result) ? "validation" : classifyInstallFailure(result);
|
|
472
|
-
report.skills.attempts.push({
|
|
473
|
-
source,
|
|
474
|
-
stage,
|
|
475
|
-
cause: report.skills.missing.length ? cause : null,
|
|
476
|
-
failures: [...report.skills.failures]
|
|
477
|
-
});
|
|
478
|
-
report.skills.status = !report.skills.missing.length ? "success" : report.skills.installed_count ? "partial" : "failed";
|
|
479
|
-
return report.skills.status === "success";
|
|
480
|
-
}
|
|
481
|
-
function readPackage(root) {
|
|
482
|
-
try {
|
|
483
|
-
return JSON.parse(fs4.readFileSync(path4.join(root, "package.json"), "utf8"));
|
|
484
|
-
} catch {
|
|
485
|
-
return null;
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
function linked(root) {
|
|
489
|
-
try {
|
|
490
|
-
return fs4.lstatSync(root).isSymbolicLink();
|
|
491
|
-
} catch {
|
|
492
|
-
return false;
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
function cliBinBelongsToPackage(bin, packageRoot, platform) {
|
|
496
|
-
const entry = fs4.realpathSync(path4.join(packageRoot, "bin", "ae-cli.js"));
|
|
497
|
-
if (platform !== "win32") return fs4.realpathSync(bin) === entry;
|
|
498
|
-
const shim = fs4.readFileSync(bin, "utf8");
|
|
499
|
-
const targets = [...shim.matchAll(/"%(?:dp0%|~dp0)[\\/]([^"\r\n]+)"/gi)];
|
|
500
|
-
return targets.some(([, relative]) => {
|
|
501
|
-
try {
|
|
502
|
-
const target = path4.resolve(path4.dirname(bin), relative.replace(/\\/g, path4.sep));
|
|
503
|
-
return fs4.realpathSync(target).toLowerCase() === entry.toLowerCase();
|
|
504
|
-
} catch {
|
|
505
|
-
return false;
|
|
506
|
-
}
|
|
507
|
-
});
|
|
508
|
-
}
|
|
509
|
-
function runInstallation(options = {}) {
|
|
510
|
-
const local = getLocalCliPackageInfo();
|
|
511
|
-
const packageName = options.packageName ?? local.name;
|
|
512
|
-
const report = newInstallationReport(packageName, "", Boolean(options.dryRun));
|
|
513
|
-
const runner = options.runner ?? defaultInstallRunner;
|
|
514
|
-
const progress = options.progress ?? (() => {
|
|
515
|
-
});
|
|
516
|
-
const platform = options.platform ?? process.platform;
|
|
517
|
-
report.skills.directory = options.skillsDirectory ?? globalSkillsDirectory();
|
|
518
|
-
let stage = "environment";
|
|
519
|
-
try {
|
|
520
|
-
const target = exactVersion(options.target ?? local.version);
|
|
521
|
-
report.cli.version = target;
|
|
522
|
-
report.skills.version = target;
|
|
523
|
-
const config = distribution(packageName);
|
|
524
|
-
report.auth.host = installHost(options.host);
|
|
525
|
-
const major = Number((options.nodeVersion ?? process.versions.node).split(".")[0]);
|
|
526
|
-
if (!Number.isInteger(major) || major < 20) return failInstallation(report, stage, "AE CLI requires Node.js 20 or later. Select an existing supported Node runtime and rerun.");
|
|
527
|
-
if (options.dryRun) {
|
|
528
|
-
report.ok = true;
|
|
529
|
-
report.commands = installPlan(packageName, target);
|
|
530
|
-
report.next_steps.push("Dry run only; CLI, global Skills, and authentication have not been verified.");
|
|
531
|
-
return report;
|
|
532
|
-
}
|
|
533
|
-
const npm = resolveNodeTool("npm", process.execPath, platform);
|
|
534
|
-
progress("[ae-cli] [1/4] Checking Node.js, npm, and npx...");
|
|
535
|
-
for (const tool of [npm, resolveNodeTool("npx", process.execPath, platform)]) {
|
|
536
|
-
const result = runner(tool, ["--version"], 15e3);
|
|
537
|
-
if (!commandSucceeded(result)) return failInstallation(report, stage, "npm and npx must be available alongside the selected Node.js runtime.", classifyInstallFailure(result));
|
|
538
|
-
}
|
|
539
|
-
stage = "package_validation";
|
|
540
|
-
const rootResult = runner(npm, ["root", "-g"], 15e3);
|
|
541
|
-
const prefixResult = runner(npm, ["prefix", "-g"], 15e3);
|
|
542
|
-
const globalRoot = rootResult.stdout.trim();
|
|
543
|
-
const prefix = prefixResult.stdout.trim();
|
|
544
|
-
if (!commandSucceeded(rootResult) || !commandSucceeded(prefixResult) || !path4.isAbsolute(globalRoot) || !path4.isAbsolute(prefix) || /[\r\n]/.test(globalRoot + prefix)) return failInstallation(report, stage, "Cannot resolve npm global root and prefix. Check npm configuration.");
|
|
545
|
-
const packageRoot = path4.join(globalRoot, packageName);
|
|
546
|
-
const bin = platform === "win32" ? path4.join(prefix, "ae-cli.cmd") : path4.join(prefix, "bin", "ae-cli");
|
|
547
|
-
report.cli.path = bin;
|
|
548
|
-
const env = options.env ?? process.env;
|
|
549
|
-
const installedBefore = readPackage(packageRoot);
|
|
550
|
-
if (linked(packageRoot) && !options.skipCliInstall) return failInstallation(report, stage, "The global CLI is npm-linked to source. Preserve the link; use a separate npm prefix for a packaged installation.");
|
|
551
|
-
if (options.skipCliInstall || installedBefore?.name === packageName && installedBefore.version === target && fs4.existsSync(bin)) {
|
|
552
|
-
report.cli.action = "skipped";
|
|
553
|
-
progress("[ae-cli] [2/4] Verifying the existing CLI...");
|
|
554
|
-
} else {
|
|
555
|
-
stage = "npm_install";
|
|
556
|
-
progress(`[ae-cli] [2/4] Installing ${packageName}@${target}...`);
|
|
557
|
-
const result = runner(npm, ["install", "-g", `${packageName}@${target}`, "--registry", config.registry], INSTALL_TIMEOUT_MS);
|
|
558
|
-
if (!commandSucceeded(result)) return failInstallation(report, stage, "npm installation failed. Check network access and a user-writable npm prefix; do not use sudo.", classifyInstallFailure(result));
|
|
559
|
-
report.cli.action = "installed";
|
|
560
|
-
}
|
|
561
|
-
stage = "package_validation";
|
|
562
|
-
const installed = readPackage(packageRoot);
|
|
563
|
-
if (installed?.name !== packageName || installed.version !== target) return failInstallation(report, stage, "Installed CLI package identity or version does not match the requested distribution.");
|
|
564
|
-
if (!fs4.existsSync(bin)) return failInstallation(report, stage, "npm did not create the global ae-cli executable. Enable npm bin-links, reinstall, and add the global executable directory to PATH.");
|
|
565
|
-
if (!cliBinBelongsToPackage(bin, packageRoot, platform)) return failInstallation(report, stage, "The global executable does not belong to the installed CLI package.");
|
|
566
|
-
const versionResult = runner(bin, ["--version"], 15e3);
|
|
567
|
-
if (!commandSucceeded(versionResult) || versionResult.stdout.trim() !== target) return failInstallation(report, stage, "ae-cli --version did not return the requested version. Refresh the shell command cache and check npm bin links.");
|
|
568
|
-
report.cli.verified = true;
|
|
569
|
-
const pathKey = platform === "win32" ? Object.keys(env).find((key) => key.toLowerCase() === "path") : "PATH";
|
|
570
|
-
const installedPathBin = (env[pathKey ?? "PATH"] ?? "").split(platform === "win32" ? ";" : path4.delimiter).filter(Boolean).map((dir) => path4.join(dir.replace(/^"(.*)"$/, "$1"), platform === "win32" ? "ae-cli.cmd" : "ae-cli")).find((file) => fs4.existsSync(file) && !file.includes(`${path4.sep}_npx${path4.sep}`));
|
|
571
|
-
if (!installedPathBin || fs4.realpathSync(installedPathBin) !== fs4.realpathSync(bin)) {
|
|
572
|
-
report.cli.warnings.push(`Add ${path4.dirname(bin)} to the front of PATH and refresh the shell command cache. The absolute executable was verified.`);
|
|
573
|
-
report.next_steps.push(`Use the verified executable at ${bin}, or correct PATH before invoking ae-cli.`);
|
|
574
|
-
}
|
|
575
|
-
stage = "skills_local";
|
|
576
|
-
const skillsPath = path4.join(packageRoot, "skills");
|
|
577
|
-
const skills = readBundledSkills(skillsPath);
|
|
578
|
-
report.skills.expected_count = skills.length;
|
|
579
|
-
for (const source of [skillsPath, `${config.repository}#v${target}`]) {
|
|
580
|
-
stage = source === skillsPath ? "skills_local" : "skills_github";
|
|
581
|
-
report.skills.source = source === skillsPath ? "installed-package" : source;
|
|
582
|
-
progress("[ae-cli] [3/4] Installing and verifying global Skills...");
|
|
583
|
-
const result = runner(resolveNodeTool("npx", process.execPath, platform), [
|
|
584
|
-
"-y",
|
|
585
|
-
SKILLS_TOOL,
|
|
586
|
-
"add",
|
|
587
|
-
source,
|
|
588
|
-
"-g",
|
|
589
|
-
"-y",
|
|
590
|
-
"--agent",
|
|
591
|
-
"universal",
|
|
592
|
-
"--skill",
|
|
593
|
-
...skills.map((skill) => skill.name)
|
|
594
|
-
], INSTALL_TIMEOUT_MS);
|
|
595
|
-
if (verifySkillsAttempt(report, skills, result, stage, report.skills.source)) break;
|
|
596
|
-
}
|
|
597
|
-
if (report.skills.status !== "success") {
|
|
598
|
-
report.skills.status = report.skills.installed_count ? "partial" : "failed";
|
|
599
|
-
const first = report.skills.attempts[0];
|
|
600
|
-
return failInstallation(
|
|
601
|
-
report,
|
|
602
|
-
first.stage,
|
|
603
|
-
"Global Skills installation is incomplete. See skills.attempts for the original and fallback failures.",
|
|
604
|
-
first.cause ?? "validation"
|
|
605
|
-
);
|
|
606
|
-
}
|
|
607
|
-
stage = "skills_clients";
|
|
608
|
-
progress("[ae-cli] [3/4] Distributing Skills to detected clients...");
|
|
609
|
-
const clientResult = runner(
|
|
610
|
-
resolveNodeTool("npx", process.execPath, platform),
|
|
611
|
-
["-y", SKILLS_TOOL, "add", report.skills.directory, "-g", "-y", "--copy", "--skill", ...skills.map((skill) => skill.name)],
|
|
612
|
-
INSTALL_TIMEOUT_MS
|
|
613
|
-
);
|
|
614
|
-
if (!verifySkillsAttempt(report, skills, clientResult, stage, report.skills.directory)) {
|
|
615
|
-
return failInstallation(
|
|
616
|
-
report,
|
|
617
|
-
stage,
|
|
618
|
-
"Global Skills were installed, but client distribution is incomplete. See skills.attempts for details.",
|
|
619
|
-
report.skills.attempts.at(-1).cause ?? "validation"
|
|
620
|
-
);
|
|
621
|
-
}
|
|
622
|
-
progress("[ae-cli] [4/4] Checking authentication guidance...");
|
|
623
|
-
if (report.auth.host) {
|
|
624
|
-
const result = runner(bin, ["--no-update-check", "--format", "json", "auth", "status", "--host", report.auth.host], INSTALL_TIMEOUT_MS);
|
|
625
|
-
try {
|
|
626
|
-
const body = JSON.parse(result.stdout);
|
|
627
|
-
if (!commandSucceeded(result) || !body.ok || typeof body.data?.authenticated !== "boolean") throw new Error();
|
|
628
|
-
report.auth.authenticated = body.data.authenticated;
|
|
629
|
-
} catch {
|
|
630
|
-
report.auth.warnings.push("Authentication status could not be verified. Run auth status for this host.");
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
if (report.auth.authenticated !== true) {
|
|
634
|
-
report.next_steps.push(`ae-cli auth login --host ${report.auth.host ?? "<AE_HOST>"} --no-wait`);
|
|
635
|
-
report.next_steps.push("Complete browser authorization, then run ae-cli auth login --host <AE_HOST> --device-code <DEVICE_CODE>.");
|
|
636
|
-
}
|
|
637
|
-
report.ok = true;
|
|
638
|
-
return report;
|
|
639
|
-
} catch (error) {
|
|
640
|
-
const safe = error instanceof Error && /^(Expected an exact|Unsupported CLI package|Host must|Invalid bundled Skill|Bundled Skills are empty)/.test(error.message);
|
|
641
|
-
return failInstallation(report, stage, safe ? error.message : "Installation could not complete at this stage. Check file permissions, package contents, and global Skills directory.");
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
// src/core/version-sync.ts
|
|
646
|
-
var AUTO_ATTEMPT_INTERVAL_MS = 60 * 60 * 1e3;
|
|
647
|
-
var MAX_AUTO_ATTEMPTS_PER_DAY = 3;
|
|
648
|
-
var LOCK_STALE_MS = 10 * 60 * 1e3;
|
|
649
|
-
var SYNC_STATE_FILE = "version-sync.json";
|
|
650
|
-
var SYNC_LOCK_FILE = "version-sync.lock";
|
|
651
|
-
function syncStatePath() {
|
|
652
|
-
return path5.join(getConfigDir(), SYNC_STATE_FILE);
|
|
653
|
-
}
|
|
654
|
-
function syncLockPath() {
|
|
655
|
-
return path5.join(getConfigDir(), SYNC_LOCK_FILE);
|
|
656
|
-
}
|
|
657
|
-
function readSyncStore() {
|
|
658
|
-
try {
|
|
659
|
-
const raw = JSON.parse(fs5.readFileSync(syncStatePath(), "utf8"));
|
|
660
|
-
if (raw && typeof raw === "object" && raw.hosts && typeof raw.hosts === "object") {
|
|
661
|
-
return raw;
|
|
662
|
-
}
|
|
663
|
-
} catch {
|
|
664
|
-
}
|
|
665
|
-
return { hosts: {} };
|
|
666
|
-
}
|
|
667
|
-
function writeSyncStore(store) {
|
|
668
|
-
try {
|
|
669
|
-
fs5.mkdirSync(getConfigDir(), { recursive: true });
|
|
670
|
-
fs5.writeFileSync(syncStatePath(), JSON.stringify(store, null, 2));
|
|
671
|
-
} catch {
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
function localDay(now) {
|
|
675
|
-
const year = now.getFullYear();
|
|
676
|
-
const month = String(now.getMonth() + 1).padStart(2, "0");
|
|
677
|
-
const day = String(now.getDate()).padStart(2, "0");
|
|
678
|
-
return `${year}-${month}-${day}`;
|
|
679
|
-
}
|
|
680
|
-
function freshAttemptEntry(target, now) {
|
|
681
|
-
return {
|
|
682
|
-
target,
|
|
683
|
-
attemptDay: localDay(now),
|
|
684
|
-
attemptsToday: 0
|
|
685
|
-
};
|
|
686
|
-
}
|
|
687
|
-
function evaluateAutoAttempt(existing, target, now = /* @__PURE__ */ new Date()) {
|
|
688
|
-
const today = localDay(now);
|
|
689
|
-
const entry = !existing || existing.target !== target || existing.attemptDay !== today ? freshAttemptEntry(target, now) : { ...existing };
|
|
690
|
-
if (entry.attemptsToday >= MAX_AUTO_ATTEMPTS_PER_DAY) {
|
|
691
|
-
return { allowed: false, reason: "daily_limit", entry };
|
|
692
|
-
}
|
|
693
|
-
if (entry.lastAttemptAt) {
|
|
694
|
-
const elapsed = now.getTime() - new Date(entry.lastAttemptAt).getTime();
|
|
695
|
-
if (Number.isFinite(elapsed) && elapsed < AUTO_ATTEMPT_INTERVAL_MS) {
|
|
696
|
-
return { allowed: false, reason: "hourly_limit", entry };
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
return { allowed: true, entry };
|
|
700
|
-
}
|
|
701
|
-
function reserveAutoAttempt(host, target, now = /* @__PURE__ */ new Date()) {
|
|
702
|
-
const store = readSyncStore();
|
|
703
|
-
const key = normalizeUrl(host);
|
|
704
|
-
const decision = evaluateAutoAttempt(store.hosts[key], target, now);
|
|
705
|
-
if (!decision.allowed) return decision;
|
|
706
|
-
decision.entry.attemptsToday += 1;
|
|
707
|
-
decision.entry.lastAttemptAt = now.toISOString();
|
|
708
|
-
store.hosts[key] = decision.entry;
|
|
709
|
-
writeSyncStore(store);
|
|
710
|
-
return decision;
|
|
711
|
-
}
|
|
712
|
-
function getPendingSkillsTarget(host) {
|
|
713
|
-
const entry = readSyncStore().hosts[normalizeUrl(host)];
|
|
714
|
-
return entry?.pendingSkills ? entry.target : void 0;
|
|
715
|
-
}
|
|
716
|
-
function recordVersionSyncResult(host, target, result) {
|
|
717
|
-
const store = readSyncStore();
|
|
718
|
-
const key = normalizeUrl(host);
|
|
719
|
-
const existing = store.hosts[key] ?? freshAttemptEntry(target, /* @__PURE__ */ new Date());
|
|
720
|
-
const entry = existing.target === target ? existing : freshAttemptEntry(target, /* @__PURE__ */ new Date());
|
|
721
|
-
if (result.ok) {
|
|
722
|
-
entry.pendingSkills = false;
|
|
723
|
-
delete entry.lastFailureStage;
|
|
724
|
-
} else {
|
|
725
|
-
entry.pendingSkills = result.skillsPending;
|
|
726
|
-
entry.lastFailureStage = result.stage;
|
|
727
|
-
}
|
|
728
|
-
store.hosts[key] = entry;
|
|
729
|
-
writeSyncStore(store);
|
|
730
|
-
}
|
|
731
|
-
function isRegularCliVersion(version) {
|
|
732
|
-
const normalized = normalizeCliVersion(version);
|
|
733
|
-
return /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(normalized) && normalized.split(".").every((part) => Number.isSafeInteger(Number(part)));
|
|
734
|
-
}
|
|
735
|
-
function isAutoSyncTargetEligible(version) {
|
|
736
|
-
if (!isRegularCliVersion(version)) return false;
|
|
737
|
-
const [major, minor, patch] = normalizeCliVersion(version).split(".").map(Number);
|
|
738
|
-
if (major > 6) return true;
|
|
739
|
-
if (major !== 6) return false;
|
|
740
|
-
if (minor > 1) return true;
|
|
741
|
-
if (minor === 1) return patch >= 5;
|
|
742
|
-
if (minor === 0) return patch >= 33;
|
|
743
|
-
return false;
|
|
744
|
-
}
|
|
745
|
-
function isPublicAeCliPackage(packageName) {
|
|
746
|
-
return packageName === OPEN_SOURCE_AE_CLI_PACKAGE;
|
|
747
|
-
}
|
|
748
|
-
function buildVersionInstallPlan(targetRaw, globalRoot = "<npm-root>", packageName = OPEN_SOURCE_AE_CLI_PACKAGE) {
|
|
749
|
-
const target = normalizeCliVersion(targetRaw);
|
|
750
|
-
return { target, commands: installPlan(packageName, target, globalRoot), skillsSources: ["installed-package", "github-fallback"] };
|
|
751
|
-
}
|
|
752
|
-
function friendlyVersionSyncFailure(result) {
|
|
753
|
-
if (result.cause === "busy") {
|
|
754
|
-
return "Another ae-cli process is synchronizing the global installation.";
|
|
755
|
-
}
|
|
756
|
-
if (result.cause === "permission") {
|
|
757
|
-
return "The global npm installation directory is not writable.";
|
|
758
|
-
}
|
|
759
|
-
if (result.cause === "timeout") {
|
|
760
|
-
return "The npm or Skills download timed out.";
|
|
761
|
-
}
|
|
762
|
-
if (result.cause === "network") {
|
|
763
|
-
return "The npm registry or Skills source could not be reached.";
|
|
764
|
-
}
|
|
765
|
-
if (result.cause === "package_missing") {
|
|
766
|
-
return "The required CLI package or Skills tag is not available.";
|
|
767
|
-
}
|
|
768
|
-
if (result.cause === "validation") {
|
|
769
|
-
return "The installed package could not be validated.";
|
|
770
|
-
}
|
|
771
|
-
return `Version synchronization failed at ${result.stage}.`;
|
|
772
|
-
}
|
|
773
|
-
function acquireInstallLock(now) {
|
|
774
|
-
fs5.mkdirSync(getConfigDir(), { recursive: true });
|
|
775
|
-
const file = syncLockPath();
|
|
776
|
-
try {
|
|
777
|
-
return fs5.openSync(file, "wx");
|
|
778
|
-
} catch {
|
|
779
|
-
try {
|
|
780
|
-
const age = now.getTime() - fs5.statSync(file).mtimeMs;
|
|
781
|
-
if (age >= LOCK_STALE_MS) {
|
|
782
|
-
fs5.unlinkSync(file);
|
|
783
|
-
return fs5.openSync(file, "wx");
|
|
784
|
-
}
|
|
785
|
-
} catch {
|
|
786
|
-
try {
|
|
787
|
-
return fs5.openSync(file, "wx");
|
|
788
|
-
} catch {
|
|
789
|
-
return null;
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
return null;
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
function releaseInstallLock(fd) {
|
|
796
|
-
try {
|
|
797
|
-
fs5.closeSync(fd);
|
|
798
|
-
} catch {
|
|
799
|
-
}
|
|
800
|
-
try {
|
|
801
|
-
fs5.unlinkSync(syncLockPath());
|
|
802
|
-
} catch {
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
function installVersion(targetRaw, options = {}) {
|
|
806
|
-
const run = () => {
|
|
807
|
-
const report = runInstallation({ ...options, target: targetRaw });
|
|
808
|
-
const cliInstalled = report.cli.verified || report.cli.action === "installed";
|
|
809
|
-
if (report.ok) return { ok: true, cliInstalled, skillsSource: report.skills.source === "installed-package" ? "local" : "github", report };
|
|
810
|
-
return {
|
|
811
|
-
ok: false,
|
|
812
|
-
stage: report.error?.stage ?? "environment",
|
|
813
|
-
cliInstalled,
|
|
814
|
-
skillsPending: cliInstalled,
|
|
815
|
-
cause: report.error?.cause ?? "validation",
|
|
816
|
-
message: report.error?.message ?? "Installation failed.",
|
|
817
|
-
report
|
|
818
|
-
};
|
|
819
|
-
};
|
|
820
|
-
if (options.dryRun) return run();
|
|
821
|
-
let lock;
|
|
822
|
-
try {
|
|
823
|
-
lock = acquireInstallLock(options.now ?? /* @__PURE__ */ new Date());
|
|
824
|
-
} catch {
|
|
825
|
-
return {
|
|
826
|
-
ok: false,
|
|
827
|
-
stage: "lock",
|
|
828
|
-
cliInstalled: false,
|
|
829
|
-
skillsPending: Boolean(options.skipCliInstall),
|
|
830
|
-
cause: "permission",
|
|
831
|
-
message: "The installation lock directory is not writable."
|
|
832
|
-
};
|
|
833
|
-
}
|
|
834
|
-
if (lock === null) return {
|
|
835
|
-
ok: false,
|
|
836
|
-
stage: "lock",
|
|
837
|
-
cliInstalled: false,
|
|
838
|
-
skillsPending: Boolean(options.skipCliInstall),
|
|
839
|
-
cause: "busy",
|
|
840
|
-
message: "Another ae-cli process is already synchronizing the global installation."
|
|
841
|
-
};
|
|
842
|
-
try {
|
|
843
|
-
return run();
|
|
844
|
-
} finally {
|
|
845
|
-
releaseInstallLock(lock);
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
function autoSyncDirection(current, expected) {
|
|
849
|
-
if (versionLine(current) !== versionLine(expected)) return "switch";
|
|
850
|
-
const currentParts = normalizeCliVersion(current).split("-")[0].split(".").map(Number);
|
|
851
|
-
const expectedParts = normalizeCliVersion(expected).split("-")[0].split(".").map(Number);
|
|
852
|
-
for (let i = 0; i < Math.max(currentParts.length, expectedParts.length, 3); i += 1) {
|
|
853
|
-
const local = currentParts[i] ?? 0;
|
|
854
|
-
const target = expectedParts[i] ?? 0;
|
|
855
|
-
if (local < target) return "upgrade";
|
|
856
|
-
if (local > target) return "downgrade";
|
|
857
|
-
}
|
|
858
|
-
return "switch";
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
// src/core/feature-config.ts
|
|
862
|
-
import crypto from "crypto";
|
|
863
|
-
import fs6 from "fs";
|
|
864
|
-
import path6 from "path";
|
|
865
|
-
var FEATURE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
866
|
-
var UNAVAILABLE_TTL_MS = 5 * 60 * 1e3;
|
|
867
|
-
function cachePath() {
|
|
868
|
-
return path6.join(getConfigDir(), "feature-config.json");
|
|
869
|
-
}
|
|
870
|
-
function cacheKey(host, token) {
|
|
871
|
-
const fingerprint = crypto.createHash("sha256").update(token).digest("hex");
|
|
872
|
-
return `${normalizeUrl(host)}#${fingerprint}`;
|
|
873
|
-
}
|
|
874
|
-
function readStore() {
|
|
875
|
-
try {
|
|
876
|
-
const value = JSON.parse(fs6.readFileSync(cachePath(), "utf8"));
|
|
877
|
-
return value?.entries && typeof value.entries === "object" ? value : { entries: {} };
|
|
878
|
-
} catch {
|
|
879
|
-
return { entries: {} };
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
function writeStore(store) {
|
|
883
|
-
const target = cachePath();
|
|
884
|
-
const temp = `${target}.${process.pid}.${crypto.randomBytes(6).toString("hex")}.tmp`;
|
|
885
|
-
try {
|
|
886
|
-
fs6.mkdirSync(path6.dirname(target), { recursive: true });
|
|
887
|
-
fs6.writeFileSync(temp, JSON.stringify(store), { encoding: "utf8", mode: 384 });
|
|
888
|
-
fs6.renameSync(temp, target);
|
|
889
|
-
fs6.chmodSync(target, 384);
|
|
890
|
-
} catch {
|
|
891
|
-
try {
|
|
892
|
-
fs6.rmSync(temp, { force: true });
|
|
893
|
-
} catch {
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
function remember(host, token, entry) {
|
|
898
|
-
const store = readStore();
|
|
899
|
-
store.entries[cacheKey(host, token)] = entry;
|
|
900
|
-
writeStore(store);
|
|
901
|
-
}
|
|
902
|
-
function rememberKbAutoDiscoveryFeature(host, token, enabled) {
|
|
903
|
-
remember(host, token, { enabled, available: true, fetchedAt: Date.now() });
|
|
904
|
-
}
|
|
905
|
-
async function resolveKbAutoDiscoveryFeature(host, token, fetchRemote) {
|
|
906
|
-
const entry = readStore().entries[cacheKey(host, token)];
|
|
907
|
-
const ttl = entry?.available ? FEATURE_TTL_MS : UNAVAILABLE_TTL_MS;
|
|
908
|
-
if (entry && Date.now() >= entry.fetchedAt && Date.now() - entry.fetchedAt < ttl) {
|
|
909
|
-
return { enabled: entry.enabled, source: entry.available ? "cache" : "unavailable" };
|
|
910
|
-
}
|
|
911
|
-
const remote = await fetchRemote().catch(() => null);
|
|
912
|
-
if (!remote) {
|
|
913
|
-
remember(host, token, { enabled: false, available: false, fetchedAt: Date.now() });
|
|
914
|
-
return { enabled: false, source: "unavailable" };
|
|
915
|
-
}
|
|
916
|
-
const enabled = remote.projectSemanticKbAutoDiscovery === true;
|
|
917
|
-
remember(host, token, { enabled, available: true, fetchedAt: Date.now() });
|
|
918
|
-
return { enabled, source: "remote" };
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
// src/core/compat-check.ts
|
|
922
|
-
import fs7 from "fs";
|
|
923
|
-
import path7 from "path";
|
|
924
|
-
var CHECK_INTERVAL_MS = 60 * 60 * 1e3;
|
|
925
|
-
var NOTIFY_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
926
|
-
var FETCH_TIMEOUT_MS = 3e3;
|
|
927
|
-
var CLI_CONFIG_PATH = "/v1/ta/cli/config";
|
|
928
|
-
function cacheFilePath() {
|
|
929
|
-
return path7.join(getConfigDir(), "compat-check.json");
|
|
930
|
-
}
|
|
931
|
-
function readStore2() {
|
|
932
|
-
try {
|
|
933
|
-
const file = cacheFilePath();
|
|
934
|
-
if (!fs7.existsSync(file)) return { hosts: {} };
|
|
935
|
-
const raw = JSON.parse(fs7.readFileSync(file, "utf8"));
|
|
936
|
-
if (!raw || typeof raw !== "object" || !raw.hosts) return { hosts: {} };
|
|
937
|
-
return raw;
|
|
938
|
-
} catch {
|
|
939
|
-
return { hosts: {} };
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
function writeStore2(store) {
|
|
943
|
-
try {
|
|
944
|
-
const dir = getConfigDir();
|
|
945
|
-
if (!fs7.existsSync(dir)) fs7.mkdirSync(dir, { recursive: true });
|
|
946
|
-
fs7.writeFileSync(cacheFilePath(), JSON.stringify(store, null, 2));
|
|
947
|
-
} catch {
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
function hostKey(host) {
|
|
951
|
-
return normalizeUrl(host);
|
|
952
|
-
}
|
|
953
|
-
function isCompatCacheStale(entry, now = Date.now()) {
|
|
954
|
-
if (!entry?.lastFetchedAt) return true;
|
|
955
|
-
const age = now - new Date(entry.lastFetchedAt).getTime();
|
|
956
|
-
return age >= CHECK_INTERVAL_MS;
|
|
957
|
-
}
|
|
958
|
-
function shouldNotifyCompat(entry, now = Date.now()) {
|
|
959
|
-
if (!entry?.lastNotifiedAt) return true;
|
|
960
|
-
const age = now - new Date(entry.lastNotifiedAt).getTime();
|
|
961
|
-
return age >= NOTIFY_INTERVAL_MS;
|
|
962
|
-
}
|
|
963
|
-
function shouldSkipCompatCheck(argv = process.argv) {
|
|
964
|
-
if (process.env.AE_CLI_NO_COMPAT_CHECK === "1") return true;
|
|
965
|
-
if (isAeSandboxRuntime()) return true;
|
|
966
|
-
return shouldSkipUpdateCheck(argv);
|
|
967
|
-
}
|
|
968
|
-
function rootCommand(argv) {
|
|
969
|
-
const args = argv.slice(2);
|
|
970
|
-
for (let i = 0; i < args.length; i += 1) {
|
|
971
|
-
const token = args[i];
|
|
972
|
-
if (token === "--") return void 0;
|
|
973
|
-
if (token.startsWith("-")) {
|
|
974
|
-
if (!token.includes("=") && ["--host", "--cli-token-file", "--mcp-url", "--format", "--jq"].includes(token)) {
|
|
975
|
-
i += 1;
|
|
976
|
-
}
|
|
977
|
-
continue;
|
|
978
|
-
}
|
|
979
|
-
return token;
|
|
980
|
-
}
|
|
981
|
-
return void 0;
|
|
982
|
-
}
|
|
983
|
-
function shouldSkipAutoSync(argv = process.argv) {
|
|
984
|
-
const command = rootCommand(argv);
|
|
985
|
-
return command === "update" || command === "install" || command === "auth" || command === "config";
|
|
986
|
-
}
|
|
987
|
-
async function fetchCliConfig(host, cliToken) {
|
|
988
|
-
const url = new URL(CLI_CONFIG_PATH, host.endsWith("/") ? host : `${host}/`);
|
|
989
|
-
const external = readExternalCliToken(host)?.token === cliToken;
|
|
990
|
-
if (!external) url.searchParams.set("cli-token", cliToken);
|
|
991
|
-
const controller = new AbortController();
|
|
992
|
-
const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
993
|
-
try {
|
|
994
|
-
const resp = await fetch(url.toString(), {
|
|
995
|
-
signal: controller.signal,
|
|
996
|
-
headers: { Accept: "application/json", ...external ? { "cli-token": cliToken } : {} },
|
|
997
|
-
...externalCliTokenRequestOptions(url.toString())
|
|
998
|
-
});
|
|
999
|
-
if (!resp.ok) return null;
|
|
1000
|
-
const body = await resp.json();
|
|
1001
|
-
const data = body.data ?? body;
|
|
1002
|
-
const versions = data.versions;
|
|
1003
|
-
if (!versions) return null;
|
|
1004
|
-
const clusterVersion = versions.clusterVersion ?? versions.cluster_version ?? null;
|
|
1005
|
-
const aeCliVersion = versions.aeCliVersion ?? versions.ae_cli_version ?? null;
|
|
1006
|
-
return {
|
|
1007
|
-
clusterVersion: clusterVersion?.trim() || null,
|
|
1008
|
-
aeCliVersion: aeCliVersion?.trim() || null,
|
|
1009
|
-
...typeof data.features?.projectSemanticKbAutoDiscovery === "boolean" ? { projectSemanticKbAutoDiscovery: data.features.projectSemanticKbAutoDiscovery } : {}
|
|
1010
|
-
};
|
|
1011
|
-
} catch {
|
|
1012
|
-
return null;
|
|
1013
|
-
} finally {
|
|
1014
|
-
clearTimeout(timer);
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
function printNotice(text) {
|
|
1018
|
-
process.stderr.write(`${text}
|
|
1019
|
-
`);
|
|
1020
|
-
}
|
|
1021
|
-
var pendingHostCompatNotice;
|
|
1022
|
-
var pendingUpdateNotice;
|
|
1023
|
-
function getPendingHostCompatNotice() {
|
|
1024
|
-
return pendingHostCompatNotice;
|
|
1025
|
-
}
|
|
1026
|
-
function getPendingUpdateNotice() {
|
|
1027
|
-
return pendingUpdateNotice;
|
|
1028
|
-
}
|
|
1029
|
-
function getCachedCompatForHost(host) {
|
|
1030
|
-
return readStore2().hosts[hostKey(host)];
|
|
1031
|
-
}
|
|
1032
|
-
function formatCapabilityMissCompatHint(host) {
|
|
1033
|
-
if (shouldSkipCompatCheck()) return void 0;
|
|
1034
|
-
const active = host || getActiveHost();
|
|
1035
|
-
if (!active) {
|
|
1036
|
-
return "This capability may be missing on the current private cluster. Update cluster components to the latest version, or pin this machine to the environment ae-cli version.";
|
|
1037
|
-
}
|
|
1038
|
-
const cached = getCachedCompatForHost(active);
|
|
1039
|
-
if (cached?.expectedVersion) {
|
|
1040
|
-
const pins = formatPinCommands(cached.expectedVersion);
|
|
1041
|
-
if (pins.length > 0) {
|
|
1042
|
-
return [
|
|
1043
|
-
`Host may be older than this CLI (environment ae-cli ${cached.expectedVersion}, cluster ${cached.clusterVersion || "?"}).`,
|
|
1044
|
-
`Update cluster components to the latest version, or pin locally:`,
|
|
1045
|
-
...pins.map((c) => ` ${c}`)
|
|
1046
|
-
].join("\n");
|
|
1047
|
-
}
|
|
1048
|
-
return [
|
|
1049
|
-
`Host may be older than this CLI (environment ae-cli ${cached.expectedVersion}, cluster ${cached.clusterVersion || "?"}).`,
|
|
1050
|
-
`No public GitHub/npm release matches that environment version; update cluster components to the latest version instead of pinning.`
|
|
1051
|
-
].join("\n");
|
|
1052
|
-
}
|
|
1053
|
-
return "This capability may be missing on the current private cluster. Update cluster components to the latest version, or pin this machine CLI + skills to the environment version (see ae-cli host compat notices after auth login).";
|
|
1054
|
-
}
|
|
1055
|
-
function setUpdateNotice(pkg, expected, cluster, verdict, state, stage, message) {
|
|
1056
|
-
pendingHostCompatNotice = void 0;
|
|
1057
|
-
pendingUpdateNotice = {
|
|
1058
|
-
command: "ae-cli update",
|
|
1059
|
-
current: pkg.version,
|
|
1060
|
-
expected,
|
|
1061
|
-
cluster,
|
|
1062
|
-
reason: verdict.kind === "ok" && state === "skills_pending" ? "skills_pending" : verdict.kind,
|
|
1063
|
-
state,
|
|
1064
|
-
...stage ? { stage } : {},
|
|
1065
|
-
message: message ?? `Current ae-cli is ${pkg.version}; this host requires ${expected}. Run: ae-cli update`
|
|
1066
|
-
};
|
|
1067
|
-
}
|
|
1068
|
-
async function refreshAndMaybeNotify(host, pkg, allowAutoSync) {
|
|
1069
|
-
const token = peekCliToken(host);
|
|
1070
|
-
if (!token) return { status: "continue" };
|
|
1071
|
-
const store = readStore2();
|
|
1072
|
-
const key = hostKey(host);
|
|
1073
|
-
const existing = store.hosts[key];
|
|
1074
|
-
let expected = existing?.expectedVersion;
|
|
1075
|
-
let cluster = existing?.clusterVersion;
|
|
1076
|
-
let fetchedAt = existing?.lastFetchedAt;
|
|
1077
|
-
if (isCompatCacheStale(existing)) {
|
|
1078
|
-
const remote = await fetchCliConfig(host, token);
|
|
1079
|
-
if (remote) rememberKbAutoDiscoveryFeature(host, token, remote.projectSemanticKbAutoDiscovery ?? false);
|
|
1080
|
-
if (!remote?.aeCliVersion) {
|
|
1081
|
-
return { status: "continue" };
|
|
1082
|
-
}
|
|
1083
|
-
expected = remote.aeCliVersion;
|
|
1084
|
-
cluster = remote.clusterVersion ?? "";
|
|
1085
|
-
fetchedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1086
|
-
store.hosts[key] = {
|
|
1087
|
-
host: key,
|
|
1088
|
-
localVersion: pkg.version,
|
|
1089
|
-
expectedVersion: expected,
|
|
1090
|
-
clusterVersion: cluster,
|
|
1091
|
-
lastFetchedAt: fetchedAt,
|
|
1092
|
-
lastNotifiedAt: existing?.lastNotifiedAt
|
|
1093
|
-
};
|
|
1094
|
-
writeStore2(store);
|
|
1095
|
-
}
|
|
1096
|
-
if (!expected) return { status: "continue" };
|
|
1097
|
-
let verdict = evaluateCompat(pkg.version, expected, cluster);
|
|
1098
|
-
let pendingSkills = getPendingSkillsTarget(host) === expected;
|
|
1099
|
-
if (verdict.kind === "ok" && !pendingSkills) {
|
|
1100
|
-
pendingHostCompatNotice = void 0;
|
|
1101
|
-
pendingUpdateNotice = void 0;
|
|
1102
|
-
return { status: "continue" };
|
|
1103
|
-
}
|
|
1104
|
-
let entry = store.hosts[key] ?? {
|
|
1105
|
-
host: key,
|
|
1106
|
-
localVersion: pkg.version,
|
|
1107
|
-
expectedVersion: expected,
|
|
1108
|
-
clusterVersion: cluster || "",
|
|
1109
|
-
lastFetchedAt: fetchedAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
1110
|
-
};
|
|
1111
|
-
entry.localVersion = pkg.version;
|
|
1112
|
-
entry.expectedVersion = expected;
|
|
1113
|
-
entry.clusterVersion = cluster || entry.clusterVersion;
|
|
1114
|
-
const canAutoSync = allowAutoSync && isPublicAeCliPackage(pkg.name) && isRegularCliVersion(pkg.version) && isAutoSyncTargetEligible(expected);
|
|
1115
|
-
if (canAutoSync) {
|
|
1116
|
-
const confirmed = await fetchCliConfig(host, token);
|
|
1117
|
-
if (confirmed) rememberKbAutoDiscoveryFeature(host, token, confirmed.projectSemanticKbAutoDiscovery ?? false);
|
|
1118
|
-
if (confirmed?.aeCliVersion) {
|
|
1119
|
-
expected = confirmed.aeCliVersion;
|
|
1120
|
-
cluster = confirmed.clusterVersion ?? cluster ?? "";
|
|
1121
|
-
verdict = evaluateCompat(pkg.version, expected, cluster);
|
|
1122
|
-
pendingSkills = getPendingSkillsTarget(host) === expected;
|
|
1123
|
-
entry = {
|
|
1124
|
-
...entry,
|
|
1125
|
-
localVersion: pkg.version,
|
|
1126
|
-
expectedVersion: expected,
|
|
1127
|
-
clusterVersion: cluster || "",
|
|
1128
|
-
lastFetchedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1129
|
-
};
|
|
1130
|
-
store.hosts[key] = entry;
|
|
1131
|
-
writeStore2(store);
|
|
1132
|
-
if (verdict.kind === "ok" && !pendingSkills) {
|
|
1133
|
-
pendingHostCompatNotice = void 0;
|
|
1134
|
-
pendingUpdateNotice = void 0;
|
|
1135
|
-
return { status: "continue" };
|
|
1136
|
-
}
|
|
1137
|
-
if (isAutoSyncTargetEligible(expected)) {
|
|
1138
|
-
const attempt = reserveAutoAttempt(host, expected);
|
|
1139
|
-
if (attempt.allowed) {
|
|
1140
|
-
const direction = verdict.kind === "ok" && pendingSkills ? "skills" : autoSyncDirection(pkg.version, expected);
|
|
1141
|
-
const verb = direction === "upgrade" ? "upgrading" : direction === "downgrade" ? "downgrading" : direction === "skills" ? "repairing" : "switching";
|
|
1142
|
-
printNotice(
|
|
1143
|
-
`[ae-cli] Current version ${pkg.version}; this host requires ${expected}. Automatically ${verb} CLI and Skills, please wait...`
|
|
1144
|
-
);
|
|
1145
|
-
const result = installVersion(expected, {
|
|
1146
|
-
skipCliInstall: verdict.kind === "ok" && pendingSkills,
|
|
1147
|
-
progress: printNotice
|
|
1148
|
-
});
|
|
1149
|
-
recordVersionSyncResult(host, expected, result);
|
|
1150
|
-
if (result.ok) {
|
|
1151
|
-
printNotice(
|
|
1152
|
-
`[ae-cli] Synchronized to ${expected}. Re-run the previous command to use the new version.`
|
|
1153
|
-
);
|
|
1154
|
-
pendingHostCompatNotice = void 0;
|
|
1155
|
-
pendingUpdateNotice = void 0;
|
|
1156
|
-
return {
|
|
1157
|
-
status: "synced",
|
|
1158
|
-
current: pkg.version,
|
|
1159
|
-
expected,
|
|
1160
|
-
cluster: cluster || "",
|
|
1161
|
-
direction
|
|
1162
|
-
};
|
|
1163
|
-
}
|
|
1164
|
-
const state = result.skillsPending ? "skills_pending" : "auto_sync_failed";
|
|
1165
|
-
const friendlyCause = friendlyVersionSyncFailure(result);
|
|
1166
|
-
const failure = result.skillsPending ? `CLI switched to ${expected}, but Skills synchronization failed. ${friendlyCause} This command will continue; run ae-cli update after access is restored.` : `${friendlyCause} This command will continue; run ae-cli update after fixing access.`;
|
|
1167
|
-
printNotice(`[ae-cli] ${failure}`);
|
|
1168
|
-
setUpdateNotice(pkg, expected, cluster || "", verdict, state, result.stage, failure);
|
|
1169
|
-
entry.lastNotifiedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1170
|
-
store.hosts[key] = entry;
|
|
1171
|
-
writeStore2(store);
|
|
1172
|
-
return { status: "continue" };
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
}
|
|
1177
|
-
const notice = verdict.kind === "ok" && pendingSkills ? `[ae-cli] CLI ${expected} is installed, but its Skills are not synchronized.
|
|
1178
|
-
Run: ae-cli update` : formatCompatNotice(verdict);
|
|
1179
|
-
if (!notice) return { status: "continue" };
|
|
1180
|
-
const dueForTip = shouldNotifyCompat(entry);
|
|
1181
|
-
if (!dueForTip) {
|
|
1182
|
-
pendingHostCompatNotice = void 0;
|
|
1183
|
-
pendingUpdateNotice = void 0;
|
|
1184
|
-
store.hosts[key] = entry;
|
|
1185
|
-
writeStore2(store);
|
|
1186
|
-
return { status: "continue" };
|
|
1187
|
-
}
|
|
1188
|
-
setUpdateNotice(
|
|
1189
|
-
pkg,
|
|
1190
|
-
expected,
|
|
1191
|
-
cluster || "",
|
|
1192
|
-
verdict,
|
|
1193
|
-
pendingSkills ? "skills_pending" : "prompt_only",
|
|
1194
|
-
void 0,
|
|
1195
|
-
pendingSkills ? `Skills for ae-cli ${expected} are not synchronized. Run: ae-cli update` : void 0
|
|
1196
|
-
);
|
|
1197
|
-
printNotice(notice);
|
|
1198
|
-
entry.lastNotifiedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1199
|
-
store.hosts[key] = entry;
|
|
1200
|
-
writeStore2(store);
|
|
1201
|
-
return { status: "continue" };
|
|
1202
|
-
}
|
|
1203
|
-
async function runHostCompatCheck(pkg, hostOverride, argv = process.argv) {
|
|
1204
|
-
pendingHostCompatNotice = void 0;
|
|
1205
|
-
pendingUpdateNotice = void 0;
|
|
1206
|
-
if (shouldSkipCompatCheck(argv)) return { status: "continue" };
|
|
1207
|
-
const host = hostOverride || getActiveHost();
|
|
1208
|
-
if (!host) return { status: "continue" };
|
|
1209
|
-
try {
|
|
1210
|
-
return await refreshAndMaybeNotify(host, pkg, !shouldSkipAutoSync(argv));
|
|
1211
|
-
} catch {
|
|
1212
|
-
return { status: "continue" };
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
// src/framework/output.ts
|
|
1217
|
-
import Table from "cli-table3";
|
|
1218
|
-
import { JqError, json as jqJson } from "jq-wasm";
|
|
1219
|
-
var KNOWN_ARRAY_FIELDS = [
|
|
1220
|
-
"items",
|
|
1221
|
-
"events",
|
|
1222
|
-
"reports",
|
|
1223
|
-
"dashboards",
|
|
1224
|
-
"tags",
|
|
1225
|
-
"clusters",
|
|
1226
|
-
"flows",
|
|
1227
|
-
"tasks",
|
|
1228
|
-
"channels",
|
|
1229
|
-
"nodes",
|
|
1230
|
-
"members",
|
|
1231
|
-
"records",
|
|
1232
|
-
"entities",
|
|
1233
|
-
"metrics",
|
|
1234
|
-
"tables",
|
|
1235
|
-
"columns",
|
|
1236
|
-
"properties"
|
|
1237
|
-
];
|
|
1238
|
-
var OUTPUT_METADATA = /* @__PURE__ */ Symbol("ae-cli-output-metadata");
|
|
1239
|
-
function withOutputMetadata(data, meta) {
|
|
1240
|
-
if (!meta || Object.keys(meta).length === 0) return data;
|
|
1241
|
-
if (isOutputWithMetadata(data)) {
|
|
1242
|
-
return {
|
|
1243
|
-
[OUTPUT_METADATA]: true,
|
|
1244
|
-
data: data.data,
|
|
1245
|
-
meta: { ...data.meta, ...meta }
|
|
1246
|
-
};
|
|
1247
|
-
}
|
|
1248
|
-
return {
|
|
1249
|
-
[OUTPUT_METADATA]: true,
|
|
1250
|
-
data,
|
|
1251
|
-
meta
|
|
1252
|
-
};
|
|
1253
|
-
}
|
|
1254
|
-
function isOutputWithMetadata(value) {
|
|
1255
|
-
return Boolean(value?.[OUTPUT_METADATA]);
|
|
1256
|
-
}
|
|
1257
|
-
function unwrapOutputData(value) {
|
|
1258
|
-
return isOutputWithMetadata(value) ? value.data : value;
|
|
1259
|
-
}
|
|
1260
|
-
function readOutputMetadata(value) {
|
|
1261
|
-
return isOutputWithMetadata(value) ? value.meta : void 0;
|
|
1262
|
-
}
|
|
1263
|
-
function findArrayField(data) {
|
|
1264
|
-
if (Array.isArray(data)) return data;
|
|
1265
|
-
if (typeof data !== "object" || data === null) return null;
|
|
1266
|
-
for (const key of KNOWN_ARRAY_FIELDS) {
|
|
1267
|
-
if (Array.isArray(data[key])) return data[key];
|
|
1268
|
-
}
|
|
1269
|
-
for (const key of Object.keys(data)) {
|
|
1270
|
-
if (Array.isArray(data[key])) return data[key];
|
|
1271
|
-
}
|
|
1272
|
-
return null;
|
|
1273
|
-
}
|
|
1274
|
-
function formatTable(data) {
|
|
1275
|
-
if (Array.isArray(data?.title) && data.title.length > 0 && Array.isArray(data?.rows)) {
|
|
1276
|
-
const headers = data.title.map((value) => String(value));
|
|
1277
|
-
const table2 = new Table({ head: headers, wordWrap: true });
|
|
1278
|
-
for (const row of data.rows) {
|
|
1279
|
-
const values = Array.isArray(row) ? row : [row];
|
|
1280
|
-
table2.push(headers.map((_header, index) => {
|
|
1281
|
-
const value = values[index];
|
|
1282
|
-
if (value === void 0 || value === null) return "";
|
|
1283
|
-
if (typeof value === "object") return JSON.stringify(value);
|
|
1284
|
-
return String(value);
|
|
1285
|
-
}));
|
|
1286
|
-
}
|
|
1287
|
-
return table2.toString();
|
|
1288
|
-
}
|
|
1289
|
-
const rows = findArrayField(data);
|
|
1290
|
-
if (!rows || rows.length === 0) {
|
|
1291
|
-
return JSON.stringify(data, null, 2);
|
|
1292
|
-
}
|
|
1293
|
-
const allKeys = /* @__PURE__ */ new Set();
|
|
1294
|
-
for (const row of rows) {
|
|
1295
|
-
if (typeof row === "object" && row !== null) {
|
|
1296
|
-
Object.keys(row).forEach((k) => allKeys.add(k));
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1299
|
-
const keys = Array.from(allKeys);
|
|
1300
|
-
if (keys.length === 0) return JSON.stringify(rows, null, 2);
|
|
1301
|
-
const table = new Table({ head: keys, wordWrap: true });
|
|
1302
|
-
for (const row of rows) {
|
|
1303
|
-
table.push(keys.map((k) => {
|
|
1304
|
-
const v = row?.[k];
|
|
1305
|
-
if (v === void 0 || v === null) return "";
|
|
1306
|
-
if (typeof v === "object") return JSON.stringify(v);
|
|
1307
|
-
return String(v);
|
|
1308
|
-
}));
|
|
1309
|
-
}
|
|
1310
|
-
return table.toString();
|
|
1311
|
-
}
|
|
1312
|
-
async function applyJq(data, expr) {
|
|
1313
|
-
const trimmed = expr.trim();
|
|
1314
|
-
if (!trimmed) return data;
|
|
1315
|
-
let results;
|
|
1316
|
-
try {
|
|
1317
|
-
results = await jqJson(data ?? null, trimmed);
|
|
1318
|
-
} catch (err) {
|
|
1319
|
-
const message = err instanceof JqError ? err.message : err?.message || String(err);
|
|
1320
|
-
const error = new Error(`Invalid --jq expression: ${message}`);
|
|
1321
|
-
error.type = "validation";
|
|
1322
|
-
error.code = "OUTPUT_PROJECTION_FAILED";
|
|
1323
|
-
error.hint = "The command completed. Original data and metadata are preserved in stdout; fix the jq expression locally without executing the command again. --jq applies to the command data before envelope wrapping.";
|
|
1324
|
-
throw error;
|
|
1325
|
-
}
|
|
1326
|
-
if (results.length === 0) return null;
|
|
1327
|
-
if (results.length === 1) return results[0];
|
|
1328
|
-
return results;
|
|
1329
|
-
}
|
|
1330
|
-
async function formatOutput(data, format, jqExpr) {
|
|
1331
|
-
const outputData = isOutputWithMetadata(data) ? data.data : data;
|
|
1332
|
-
const meta = isOutputWithMetadata(data) ? data.meta : void 0;
|
|
1333
|
-
let processed = outputData;
|
|
1334
|
-
if (jqExpr) {
|
|
1335
|
-
processed = await applyJq(outputData, jqExpr);
|
|
1336
|
-
}
|
|
1337
|
-
if (format === "table") {
|
|
1338
|
-
return redactExternalCliToken(formatTable(processed));
|
|
1339
|
-
}
|
|
1340
|
-
const hostCompat = getPendingHostCompatNotice();
|
|
1341
|
-
const updateNotice = getPendingUpdateNotice();
|
|
1342
|
-
const notices = {
|
|
1343
|
-
...updateNotice ? {} : hostCompat ? { host_compat: hostCompat } : {},
|
|
1344
|
-
...updateNotice ? { update: updateNotice } : {}
|
|
1345
|
-
};
|
|
1346
|
-
const envelope = {
|
|
1347
|
-
ok: true,
|
|
1348
|
-
data: processed,
|
|
1349
|
-
...meta ? { meta } : {},
|
|
1350
|
-
// Soft tip lives only under _notice (not mirrored into meta) to avoid duplicate fields.
|
|
1351
|
-
...Object.keys(notices).length > 0 ? { _notice: notices } : {}
|
|
1352
|
-
};
|
|
1353
|
-
return redactExternalCliToken(JSON.stringify(envelope, null, 2));
|
|
1354
|
-
}
|
|
1355
|
-
function formatError(type, message, hint, code, meta, details) {
|
|
1356
|
-
const envelope = {
|
|
1357
|
-
ok: false,
|
|
1358
|
-
error: { type, message, hint, code, ...details === void 0 ? {} : { details } },
|
|
1359
|
-
...meta && Object.keys(meta).length > 0 ? { meta } : {}
|
|
1360
|
-
};
|
|
1361
|
-
return redactExternalCliToken(JSON.stringify(envelope, null, 2));
|
|
1362
|
-
}
|
|
1363
|
-
function printError(type, message, hint, code, meta, options = {}) {
|
|
1364
|
-
const formatted = formatError(type, message, hint, code, meta, options.details);
|
|
1365
|
-
process.stderr.write(formatted + "\n");
|
|
1366
|
-
if (options.log !== false) {
|
|
1367
|
-
logger.error(`[${type}] ${message}${hint ? " | " + hint : ""}`);
|
|
1368
|
-
}
|
|
1369
|
-
}
|
|
1370
|
-
function sensitiveRecoveryData(data) {
|
|
1371
|
-
const safe = {};
|
|
1372
|
-
const item = {};
|
|
1373
|
-
if (typeof data?.item?.id === "string") item.id = data.item.id;
|
|
1374
|
-
if (Number.isSafeInteger(data?.item?.contentRevision)) item.contentRevision = data.item.contentRevision;
|
|
1375
|
-
if (Object.keys(item).length > 0) safe.item = item;
|
|
1376
|
-
if (["markdown", "text"].includes(data?.contentFormat)) safe.contentFormat = data.contentFormat;
|
|
1377
|
-
if (typeof data?.out === "string") safe.out = data.out;
|
|
1378
|
-
return safe;
|
|
1379
|
-
}
|
|
1380
|
-
async function printOutput(data, format, jqExpr, options = {}) {
|
|
1381
|
-
try {
|
|
1382
|
-
process.stdout.write(await formatOutput(data, format, jqExpr) + "\n");
|
|
1383
|
-
} catch (error) {
|
|
1384
|
-
if (error?.code === "OUTPUT_PROJECTION_FAILED") {
|
|
1385
|
-
if (options.redactErrors) {
|
|
1386
|
-
error.message = "Invalid --jq expression: output projection failed; source content is omitted from diagnostics.";
|
|
1387
|
-
error.hint = "The read completed. Fix --jq and explicitly run read-text again without --out, or inspect the file at data.out if present. This error result excludes source content.";
|
|
1388
|
-
}
|
|
1389
|
-
const recovery = JSON.parse(formatError(
|
|
1390
|
-
"validation",
|
|
1391
|
-
error.message,
|
|
1392
|
-
error.hint,
|
|
1393
|
-
error.code,
|
|
1394
|
-
options.redactErrors ? void 0 : readOutputMetadata(data)
|
|
1395
|
-
));
|
|
1396
|
-
const recoveryData = options.redactErrors ? sensitiveRecoveryData(unwrapOutputData(data)) : unwrapOutputData(data);
|
|
1397
|
-
await new Promise((resolve, reject) => {
|
|
1398
|
-
process.stdout.write(
|
|
1399
|
-
redactExternalCliToken(JSON.stringify({ ...recovery, data: recoveryData }, null, 2)) + "\n",
|
|
1400
|
-
(error2) => error2 ? reject(error2) : resolve()
|
|
1401
|
-
);
|
|
1402
|
-
});
|
|
1403
|
-
}
|
|
1404
|
-
throw error;
|
|
1405
|
-
}
|
|
1406
|
-
}
|
|
1407
|
-
|
|
1408
|
-
export {
|
|
1409
|
-
exactVersion,
|
|
1410
|
-
installHost,
|
|
1411
|
-
getLocalCliPackageInfo,
|
|
1412
|
-
newInstallationReport,
|
|
1413
|
-
failInstallation,
|
|
1414
|
-
recordVersionSyncResult,
|
|
1415
|
-
buildVersionInstallPlan,
|
|
1416
|
-
friendlyVersionSyncFailure,
|
|
1417
|
-
installVersion,
|
|
1418
|
-
resolveKbAutoDiscoveryFeature,
|
|
1419
|
-
shouldSkipAutoSync,
|
|
1420
|
-
fetchCliConfig,
|
|
1421
|
-
getCachedCompatForHost,
|
|
1422
|
-
formatCapabilityMissCompatHint,
|
|
1423
|
-
runHostCompatCheck,
|
|
1424
|
-
withOutputMetadata,
|
|
1425
|
-
unwrapOutputData,
|
|
1426
|
-
readOutputMetadata,
|
|
1427
|
-
printError,
|
|
1428
|
-
printOutput
|
|
1429
|
-
};
|