@thinkingai/ae-cli 6.0.55 → 6.0.57
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 +35 -6
- package/README.zh.md +35 -6
- package/bin/ae-cli.js +5 -0
- package/bin/runtime-capabilities.json +5 -0
- package/cli-installation-guide.md +24 -3
- package/dist/{auth-RQBO6MTY.js → auth-YEIJLBFY.js} +61 -19
- package/dist/{automation-VAAQBM7Y.js → automation-NAR5DDGL.js} +94 -38
- package/dist/{capability-JRIFC4AJ.js → capability-P7DD4Q73.js} +50 -21
- package/dist/{chunk-5XJYLEVC.js → chunk-72NJKS7O.js} +4 -4
- package/dist/chunk-752BSLZC.js +222 -0
- package/dist/{chunk-RGYPSEYD.js → chunk-7ABK2PEJ.js} +3 -3
- package/dist/{chunk-Q5US7JC5.js → chunk-7JAVT5TK.js} +3 -3
- package/dist/{chunk-GHXZK54S.js → chunk-H3K5UGYC.js} +41 -13
- package/dist/{chunk-OP44TT4H.js → chunk-IN7KKL6K.js} +4 -2
- package/dist/{chunk-VZZNLV3I.js → chunk-JCWM2TYP.js} +61 -15
- package/dist/{chunk-S6M42KND.js → chunk-JEUXDY3B.js} +1 -1
- package/dist/{chunk-ZL7SGNIA.js → chunk-JNVVJ273.js} +58 -46
- package/dist/chunk-N6XBLRB7.js +105 -0
- package/dist/{chunk-AP7YP2NX.js → chunk-OAWPT7VP.js} +2 -2
- package/dist/{chunk-7KU2WNQE.js → chunk-QEMQKVHW.js} +37 -15
- package/dist/{chunk-CT7QDJS6.js → chunk-QVRIDN42.js} +2 -2
- package/dist/{chunk-RPBOAQQQ.js → chunk-QZUVLFNR.js} +1 -1
- package/dist/{chunk-3YVEAZUN.js → chunk-RJHGDWSC.js} +32 -21
- package/dist/{chunk-374V5R6N.js → chunk-TKVVACEJ.js} +6 -4
- package/dist/chunk-TULINOLS.js +2283 -0
- package/dist/chunk-YVG6QD3V.js +233 -0
- package/dist/{chunk-WNGFSIOB.js → chunk-Z3Q2AEIN.js} +237 -86
- package/dist/chunk-ZGIYG473.js +132 -0
- package/dist/{community-report-client-PEERQCX2.js → community-report-client-TJVCLZ3K.js} +1 -1
- package/dist/compat-check-PMEGUPZU.js +32 -0
- package/dist/{config-SICKWZ2A.js → config-VWVPR4WW.js} +43 -10
- package/dist/{context-NGVFPCBK.js → context-F6FCGTF3.js} +4 -4
- package/dist/{data-integration-BCLQFTGU.js → data-integration-6UAZO4GG.js} +207 -24
- package/dist/evaluation-4LO2O4AF.js +3714 -0
- package/dist/index.js +343 -79
- package/dist/{local-data-upload-client-TWMHFLUA.js → local-data-upload-client-KCMG6J62.js} +1 -1
- package/dist/{memory-CQKH2JAV.js → memory-HHPX3NF2.js} +6 -6
- package/dist/{metadata-EMFGUI2W.js → metadata-HEQQEEG3.js} +17 -9
- package/dist/{model-VX5M2CJ6.js → model-7UHGWYVR.js} +4 -4
- package/dist/{personal-semantic-preference-SLWVVYZ4.js → personal-semantic-preference-V4L6ZWR2.js} +7 -6
- package/dist/{project-semantic-DPSZBKQD.js → project-semantic-NKHKJX6M.js} +7 -6
- package/dist/{sync-RZIAV37C.js → sync-ZJMXCRIN.js} +8 -7
- package/dist/{te-agent-AORRE2FM.js → te-agent-WBKIFEQD.js} +757 -94
- package/dist/{te-analysis-ISXKJKRT.js → te-analysis-ADX7RKO4.js} +578 -94
- package/dist/{te-community-42M7ICDO.js → te-community-PREDRXG3.js} +722 -228
- package/dist/{te-dataops-BNKNZ4F2.js → te-dataops-ITWJHO2U.js} +9 -6
- package/dist/{te-engage-BZE3MBKT.js → te-engage-VE2NUH5V.js} +7 -6
- package/dist/{te-kb-ULATOTQ3.js → te-kb-WSMOW7WS.js} +407 -83
- package/dist/{te-system-UGHVKBVV.js → te-system-YM657FKO.js} +6 -6
- package/dist/{te-team-YA6SNOJ3.js → te-team-T2WRLOOD.js} +64 -41
- package/dist/{things-DTCOQIQB.js → things-6QOMFXOG.js} +7 -7
- package/dist/{update-ESNYKUVR.js → update-I4MOUYOX.js} +11 -7
- package/dist/{workspace-JEOHKFPX.js → workspace-LYDAP647.js} +6 -6
- package/package.json +25 -11
- package/skills/ae-agent/SKILL.md +20 -3
- package/skills/ae-agent/references/command_index.md +8 -0
- package/skills/ae-agent/references/resource-package.md +57 -0
- package/skills/ae-analysis/SKILL.md +23 -10
- package/skills/ae-analysis/references/adhoc_export.md +1 -1
- package/skills/ae-analysis/references/agent_review_preflight.md +55 -10
- package/skills/ae-analysis/references/agent_review_priorities_comparisons.md +5 -3
- package/skills/ae-analysis/references/agent_review_submit_to_page.md +60 -24
- package/skills/ae-analysis/references/ai_models/event.md +58 -2
- package/skills/ae-analysis/references/ai_models/rank_list.md +1 -0
- package/skills/ae-analysis/references/ai_models/retention.md +2 -0
- package/skills/ae-analysis/references/ai_models/revenue.md +2 -0
- package/skills/ae-analysis/references/analysis_data_export.md +11 -1
- package/skills/ae-analysis/references/asset_batch_info_export.md +2 -2
- package/skills/ae-analysis/references/asset_batch_sql_export.md +2 -2
- package/skills/ae-analysis/references/asset_export.md +1 -1
- package/skills/ae-analysis/references/bi_panel_page_data_export.md +1 -1
- package/skills/ae-analysis/references/check_export.md +1 -1
- package/skills/ae-analysis/references/command_index.md +39 -26
- package/skills/ae-analysis/references/dashboard_report_data_export.md +2 -0
- package/skills/ae-analysis/references/dashboard_report_get.md +6 -2
- package/skills/ae-analysis/references/dashboard_report_update.md +24 -5
- package/skills/ae-analysis/references/feedback_submit.md +1 -1
- package/skills/ae-analysis/references/governance_recommendation_export.md +40 -18
- package/skills/ae-analysis/references/governance_recommendation_run_update.md +13 -0
- package/skills/ae-analysis/references/live_data_export.md +1 -1
- package/skills/ae-analysis/references/metric_create.md +29 -0
- package/skills/ae-analysis/references/metric_get.md +2 -0
- package/skills/ae-analysis/references/metric_update.md +2 -0
- package/skills/ae-analysis/references/operation_record_export.md +1 -1
- package/skills/ae-analysis/references/plan_change_log_export.md +1 -1
- package/skills/ae-analysis/references/plan_export.md +1 -1
- package/skills/ae-analysis/references/project_info_get.md +4 -0
- package/skills/ae-analysis/references/project_member_group_add_members.md +35 -0
- package/skills/ae-analysis/references/project_member_group_create.md +25 -0
- package/skills/ae-analysis/references/project_member_group_delete.md +34 -0
- package/skills/ae-analysis/references/project_member_group_list.md +29 -0
- package/skills/ae-analysis/references/project_member_group_members.md +28 -0
- package/skills/ae-analysis/references/project_member_group_remove_members.md +35 -0
- package/skills/ae-analysis/references/project_member_group_rename.md +26 -0
- package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +9 -1
- package/skills/ae-analysis/references/project_semantic_knowledge_wiki_plan_schema.md +6 -1
- package/skills/ae-analysis/references/report_data_export.md +1 -1
- package/skills/ae-analysis/references/scenario_append.md +31 -0
- package/skills/ae-analysis/references/scenario_begin.md +11 -0
- package/skills/ae-analysis/references/scenario_collect.md +43 -0
- package/skills/ae-analysis/references/scenario_evaluation.md +18 -0
- 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/build-project-semantic-wiki.mjs +73 -4
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/company-kb.mjs +14 -1
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-schema.md +5 -1
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/execution-contract.mjs +173 -0
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/generate-build-ir.mjs +109 -64
- package/skills/ae-automation/SKILL.md +2 -2
- package/skills/ae-automation/references/cli.md +18 -1
- package/skills/ae-capability/SKILL.md +7 -3
- 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-evaluation/SKILL.md +83 -0
- package/skills/ae-evaluation/references/access-and-members.md +55 -0
- package/skills/ae-evaluation/references/connections.md +78 -0
- package/skills/ae-evaluation/references/datasets.md +57 -0
- package/skills/ae-evaluation/references/evaluators.md +81 -0
- package/skills/ae-evaluation/references/files.md +33 -0
- package/skills/ae-evaluation/references/integrations.md +39 -0
- package/skills/ae-evaluation/references/runs.md +160 -0
- package/skills/ae-evaluation/references/schedules.md +31 -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 +3 -2
- package/skills/ae-metadata/references/metadata_data_table_download.md +7 -1
- package/skills/ae-metadata/references/metadata_data_table_get.md +37 -0
- package/skills/ae-team/SKILL.md +2 -2
- package/skills/ae-team/references/run-start.md +1 -0
- package/skills/ae-team/references/run-watch.md +7 -5
- package/skills/ae-things/SKILL.md +53 -51
- package/skills/ae-things/references/cli.md +56 -54
- package/skills/ae-things-progress/SKILL.md +20 -20
- package/skills/ae-things-review/SKILL.md +19 -19
- package/dist/chunk-6VNIR4AP.js +0 -1422
- package/dist/chunk-CI24BDR2.js +0 -43
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
getPendingHostCompatNotice,
|
|
4
|
+
getPendingUpdateNotice
|
|
5
|
+
} from "./chunk-TULINOLS.js";
|
|
6
|
+
import {
|
|
7
|
+
logger,
|
|
8
|
+
redactExternalCliToken
|
|
9
|
+
} from "./chunk-Z3Q2AEIN.js";
|
|
10
|
+
|
|
11
|
+
// src/framework/output.ts
|
|
12
|
+
import Table from "cli-table3";
|
|
13
|
+
import { JqError, json as jqJson } from "jq-wasm";
|
|
14
|
+
var KNOWN_ARRAY_FIELDS = [
|
|
15
|
+
"items",
|
|
16
|
+
"events",
|
|
17
|
+
"reports",
|
|
18
|
+
"dashboards",
|
|
19
|
+
"tags",
|
|
20
|
+
"clusters",
|
|
21
|
+
"flows",
|
|
22
|
+
"tasks",
|
|
23
|
+
"channels",
|
|
24
|
+
"nodes",
|
|
25
|
+
"members",
|
|
26
|
+
"records",
|
|
27
|
+
"entities",
|
|
28
|
+
"metrics",
|
|
29
|
+
"tables",
|
|
30
|
+
"columns",
|
|
31
|
+
"properties"
|
|
32
|
+
];
|
|
33
|
+
var OUTPUT_METADATA = /* @__PURE__ */ Symbol("ae-cli-output-metadata");
|
|
34
|
+
function withOutputMetadata(data, meta) {
|
|
35
|
+
if (!meta || Object.keys(meta).length === 0) return data;
|
|
36
|
+
if (isOutputWithMetadata(data)) {
|
|
37
|
+
return {
|
|
38
|
+
[OUTPUT_METADATA]: true,
|
|
39
|
+
data: data.data,
|
|
40
|
+
meta: { ...data.meta, ...meta }
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
[OUTPUT_METADATA]: true,
|
|
45
|
+
data,
|
|
46
|
+
meta
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function isOutputWithMetadata(value) {
|
|
50
|
+
return Boolean(value?.[OUTPUT_METADATA]);
|
|
51
|
+
}
|
|
52
|
+
function unwrapOutputData(value) {
|
|
53
|
+
return isOutputWithMetadata(value) ? value.data : value;
|
|
54
|
+
}
|
|
55
|
+
function readOutputMetadata(value) {
|
|
56
|
+
return isOutputWithMetadata(value) ? value.meta : void 0;
|
|
57
|
+
}
|
|
58
|
+
function findArrayField(data) {
|
|
59
|
+
if (Array.isArray(data)) return { rows: data };
|
|
60
|
+
if (typeof data !== "object" || data === null) return null;
|
|
61
|
+
for (const key of KNOWN_ARRAY_FIELDS) {
|
|
62
|
+
if (Array.isArray(data[key])) return { key, rows: data[key] };
|
|
63
|
+
}
|
|
64
|
+
for (const key of Object.keys(data)) {
|
|
65
|
+
if (Array.isArray(data[key])) return { key, rows: data[key] };
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
function formatTable(data) {
|
|
70
|
+
if (Array.isArray(data?.title) && data.title.length > 0 && Array.isArray(data?.rows)) {
|
|
71
|
+
const headers = data.title.map((value) => String(value));
|
|
72
|
+
const table2 = new Table({ head: headers, wordWrap: true });
|
|
73
|
+
for (const row of data.rows) {
|
|
74
|
+
const values = Array.isArray(row) ? row : [row];
|
|
75
|
+
table2.push(headers.map((_header, index) => {
|
|
76
|
+
const value = values[index];
|
|
77
|
+
if (value === void 0 || value === null) return "";
|
|
78
|
+
if (typeof value === "object") return JSON.stringify(value);
|
|
79
|
+
return String(value);
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
return table2.toString();
|
|
83
|
+
}
|
|
84
|
+
const arrayField = findArrayField(data);
|
|
85
|
+
if (!arrayField || arrayField.rows.length === 0) {
|
|
86
|
+
return JSON.stringify(data, null, 2);
|
|
87
|
+
}
|
|
88
|
+
const rows = arrayField.rows;
|
|
89
|
+
const allKeys = /* @__PURE__ */ new Set();
|
|
90
|
+
for (const row of rows) {
|
|
91
|
+
if (typeof row === "object" && row !== null) {
|
|
92
|
+
Object.keys(row).forEach((k) => allKeys.add(k));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const keys = Array.from(allKeys);
|
|
96
|
+
if (keys.length === 0) return JSON.stringify(rows, null, 2);
|
|
97
|
+
const table = new Table({ head: keys, wordWrap: true });
|
|
98
|
+
for (const row of rows) {
|
|
99
|
+
table.push(keys.map((k) => {
|
|
100
|
+
const v = row?.[k];
|
|
101
|
+
if (v === void 0 || v === null) return "";
|
|
102
|
+
if (typeof v === "object") return JSON.stringify(v);
|
|
103
|
+
return String(v);
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
const sections = [];
|
|
107
|
+
if (arrayField.key && typeof data === "object" && data !== null) {
|
|
108
|
+
const summaryEntries = Object.entries(data).filter(([key]) => key !== arrayField.key);
|
|
109
|
+
if (summaryEntries.length > 0) {
|
|
110
|
+
const summary = new Table({ head: ["field", "value"], wordWrap: true });
|
|
111
|
+
for (const [key, value] of summaryEntries) {
|
|
112
|
+
summary.push([key, typeof value === "object" && value !== null ? JSON.stringify(value) : String(value ?? "")]);
|
|
113
|
+
}
|
|
114
|
+
sections.push(summary.toString());
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
sections.push(table.toString());
|
|
118
|
+
return sections.join("\n\n");
|
|
119
|
+
}
|
|
120
|
+
async function applyJq(data, expr) {
|
|
121
|
+
const trimmed = expr.trim();
|
|
122
|
+
if (!trimmed) return data;
|
|
123
|
+
let results;
|
|
124
|
+
try {
|
|
125
|
+
results = await jqJson(data ?? null, trimmed);
|
|
126
|
+
} catch (err) {
|
|
127
|
+
const message = err instanceof JqError ? err.message : err?.message || String(err);
|
|
128
|
+
const error = new Error(`Invalid --jq expression: ${message}`);
|
|
129
|
+
error.type = "validation";
|
|
130
|
+
error.code = "OUTPUT_PROJECTION_FAILED";
|
|
131
|
+
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.";
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
if (results.length === 0) return null;
|
|
135
|
+
if (results.length === 1) return results[0];
|
|
136
|
+
return results;
|
|
137
|
+
}
|
|
138
|
+
async function formatOutput(data, format, jqExpr) {
|
|
139
|
+
const outputData = isOutputWithMetadata(data) ? data.data : data;
|
|
140
|
+
const meta = isOutputWithMetadata(data) ? data.meta : void 0;
|
|
141
|
+
let processed = outputData;
|
|
142
|
+
if (jqExpr) {
|
|
143
|
+
processed = await applyJq(outputData, jqExpr);
|
|
144
|
+
}
|
|
145
|
+
if (format === "table") {
|
|
146
|
+
return redactExternalCliToken(formatTable(processed));
|
|
147
|
+
}
|
|
148
|
+
const hostCompat = getPendingHostCompatNotice();
|
|
149
|
+
const updateNotice = getPendingUpdateNotice();
|
|
150
|
+
const notices = {
|
|
151
|
+
...updateNotice ? {} : hostCompat ? { host_compat: hostCompat } : {},
|
|
152
|
+
...updateNotice ? { update: updateNotice } : {}
|
|
153
|
+
};
|
|
154
|
+
const envelope = {
|
|
155
|
+
ok: true,
|
|
156
|
+
data: processed,
|
|
157
|
+
...meta ? { meta } : {},
|
|
158
|
+
// Soft tip lives only under _notice (not mirrored into meta) to avoid duplicate fields.
|
|
159
|
+
...Object.keys(notices).length > 0 ? { _notice: notices } : {}
|
|
160
|
+
};
|
|
161
|
+
return redactExternalCliToken(JSON.stringify(envelope, null, 2));
|
|
162
|
+
}
|
|
163
|
+
function formatError(type, message, hint, code, meta, details) {
|
|
164
|
+
const envelope = {
|
|
165
|
+
ok: false,
|
|
166
|
+
error: { type, message, hint, code, ...details === void 0 ? {} : { details } },
|
|
167
|
+
...meta && Object.keys(meta).length > 0 ? { meta } : {}
|
|
168
|
+
};
|
|
169
|
+
return redactExternalCliToken(JSON.stringify(envelope, null, 2));
|
|
170
|
+
}
|
|
171
|
+
function printError(type, message, hint, code, meta, options = {}) {
|
|
172
|
+
const formatted = formatError(type, message, hint, code, meta, options.details);
|
|
173
|
+
process.stderr.write(formatted + "\n");
|
|
174
|
+
if (options.log !== false) {
|
|
175
|
+
logger.error(`[${type}] ${message}${hint ? " | " + hint : ""}`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function sensitiveRecoveryData(data) {
|
|
179
|
+
const safe = {};
|
|
180
|
+
const item = {};
|
|
181
|
+
if (typeof data?.item?.id === "string") item.id = data.item.id;
|
|
182
|
+
if (Number.isSafeInteger(data?.item?.contentRevision)) item.contentRevision = data.item.contentRevision;
|
|
183
|
+
if (Object.keys(item).length > 0) safe.item = item;
|
|
184
|
+
if (["markdown", "text"].includes(data?.contentFormat)) safe.contentFormat = data.contentFormat;
|
|
185
|
+
if (typeof data?.out === "string") safe.out = data.out;
|
|
186
|
+
return safe;
|
|
187
|
+
}
|
|
188
|
+
async function printOutput(data, format, jqExpr, options = {}) {
|
|
189
|
+
try {
|
|
190
|
+
process.stdout.write(await formatOutput(data, format, jqExpr) + "\n");
|
|
191
|
+
} catch (error) {
|
|
192
|
+
if (error?.code === "OUTPUT_PROJECTION_FAILED") {
|
|
193
|
+
if (options.redactErrors) {
|
|
194
|
+
error.message = "Invalid --jq expression: output projection failed; source content is omitted from diagnostics.";
|
|
195
|
+
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.";
|
|
196
|
+
}
|
|
197
|
+
const recovery = JSON.parse(formatError(
|
|
198
|
+
"validation",
|
|
199
|
+
error.message,
|
|
200
|
+
error.hint,
|
|
201
|
+
error.code,
|
|
202
|
+
options.redactErrors ? void 0 : readOutputMetadata(data)
|
|
203
|
+
));
|
|
204
|
+
const recoveryData = options.redactErrors ? sensitiveRecoveryData(unwrapOutputData(data)) : unwrapOutputData(data);
|
|
205
|
+
await new Promise((resolve, reject) => {
|
|
206
|
+
process.stdout.write(
|
|
207
|
+
redactExternalCliToken(JSON.stringify({ ...recovery, data: recoveryData }, null, 2)) + "\n",
|
|
208
|
+
(error2) => error2 ? reject(error2) : resolve()
|
|
209
|
+
);
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
throw error;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export {
|
|
217
|
+
withOutputMetadata,
|
|
218
|
+
unwrapOutputData,
|
|
219
|
+
readOutputMetadata,
|
|
220
|
+
printError,
|
|
221
|
+
printOutput
|
|
222
|
+
};
|
|
@@ -6,15 +6,15 @@ import {
|
|
|
6
6
|
CapabilityGatewayError,
|
|
7
7
|
fetchCapabilityGateway,
|
|
8
8
|
requestCapabilityGateway
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JCWM2TYP.js";
|
|
10
10
|
import {
|
|
11
11
|
readOutputMetadata,
|
|
12
12
|
unwrapOutputData,
|
|
13
13
|
withOutputMetadata
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-752BSLZC.js";
|
|
15
15
|
import {
|
|
16
16
|
PermissionError
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-Z3Q2AEIN.js";
|
|
18
18
|
|
|
19
19
|
// src/core/analysis-async-artifact.ts
|
|
20
20
|
import { randomBytes } from "crypto";
|
|
@@ -9,15 +9,15 @@ import {
|
|
|
9
9
|
postAgentApi,
|
|
10
10
|
putAgentApi,
|
|
11
11
|
uploadAgentApi
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-N6XBLRB7.js";
|
|
13
13
|
import {
|
|
14
14
|
TeAgentApiError,
|
|
15
15
|
createTeAgentApiError
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-RJHGDWSC.js";
|
|
17
17
|
import {
|
|
18
18
|
CliValidationError,
|
|
19
19
|
isApiErrorType
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-Z3Q2AEIN.js";
|
|
21
21
|
|
|
22
22
|
// src/commands/workspace/client.ts
|
|
23
23
|
var DEFAULT_TE_CLAUDE_BASE_PATH = "/agent";
|
|
@@ -3,14 +3,17 @@ import {
|
|
|
3
3
|
getActiveHost,
|
|
4
4
|
getConfigDir,
|
|
5
5
|
getFallbackCliToken,
|
|
6
|
-
|
|
6
|
+
readSandboxCliTokenEntry,
|
|
7
7
|
safeJsonParse,
|
|
8
8
|
safeReadJsonFile
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JNVVJ273.js";
|
|
10
10
|
import {
|
|
11
11
|
PermissionError,
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
externalCliTokenRequestOptions,
|
|
13
|
+
logger,
|
|
14
|
+
normalizeUrl,
|
|
15
|
+
readExternalCliToken
|
|
16
|
+
} from "./chunk-Z3Q2AEIN.js";
|
|
14
17
|
|
|
15
18
|
// src/core/secure-store.ts
|
|
16
19
|
import crypto from "crypto";
|
|
@@ -696,7 +699,8 @@ async function validateCliTokenOnServer(hostUrl, cliToken) {
|
|
|
696
699
|
try {
|
|
697
700
|
resp = await fetch(url, {
|
|
698
701
|
method: "GET",
|
|
699
|
-
headers: { Accept: "application/json", "cli-token": cliToken }
|
|
702
|
+
headers: { Accept: "application/json", "cli-token": cliToken },
|
|
703
|
+
...externalCliTokenRequestOptions(url)
|
|
700
704
|
});
|
|
701
705
|
} catch (error) {
|
|
702
706
|
throw new CliTokenValidationUnavailableError(`Unable to validate CLI token for ${hostUrl}: ${error.message}`);
|
|
@@ -734,10 +738,14 @@ async function validateCliTokenOnServer(hostUrl, cliToken) {
|
|
|
734
738
|
...cliTokenExpiresAt ? { cliTokenExpiresAt } : {}
|
|
735
739
|
};
|
|
736
740
|
}
|
|
737
|
-
async function renewCliTokenOnServer(hostUrl, cliToken) {
|
|
741
|
+
async function renewCliTokenOnServer(hostUrl, cliToken, external = false) {
|
|
738
742
|
const url = new URL(`${hostUrl.replace(/\/+$/, "")}${CLI_TOKEN_RENEW_PATH}`);
|
|
739
|
-
url.searchParams.set("cli-token", cliToken);
|
|
740
|
-
const resp = await fetch(url.toString(), {
|
|
743
|
+
if (!external) url.searchParams.set("cli-token", cliToken);
|
|
744
|
+
const resp = await fetch(url.toString(), {
|
|
745
|
+
method: "GET",
|
|
746
|
+
headers: { Accept: "application/json", ...external ? { "cli-token": cliToken } : {} },
|
|
747
|
+
...externalCliTokenRequestOptions(url.toString())
|
|
748
|
+
});
|
|
741
749
|
const text = await resp.text();
|
|
742
750
|
let data;
|
|
743
751
|
try {
|
|
@@ -750,10 +758,10 @@ async function renewCliTokenOnServer(hostUrl, cliToken) {
|
|
|
750
758
|
throw new Error(`CLI token renew error: ${data.return_message || "unknown"} (code: ${data.return_code})`);
|
|
751
759
|
}
|
|
752
760
|
}
|
|
753
|
-
async function maybeRenewCliTokenDaily(hostUrl, cliToken) {
|
|
761
|
+
async function maybeRenewCliTokenDaily(hostUrl, cliToken, external = false) {
|
|
754
762
|
const key = renewKey(hostUrl, cliToken);
|
|
755
763
|
const today = localRenewDate();
|
|
756
|
-
if (renewedLocalDate.get(key) === today || persistedRenewDate(hostUrl, cliToken) === today) {
|
|
764
|
+
if (renewedLocalDate.get(key) === today || !external && persistedRenewDate(hostUrl, cliToken) === today) {
|
|
757
765
|
renewedLocalDate.set(key, today);
|
|
758
766
|
return;
|
|
759
767
|
}
|
|
@@ -761,11 +769,12 @@ async function maybeRenewCliTokenDaily(hostUrl, cliToken) {
|
|
|
761
769
|
if (existing) return existing;
|
|
762
770
|
const attempt = (async () => {
|
|
763
771
|
try {
|
|
764
|
-
await renewCliTokenOnServer(hostUrl, cliToken);
|
|
765
|
-
|
|
772
|
+
await renewCliTokenOnServer(hostUrl, cliToken, external);
|
|
773
|
+
if (external) renewedLocalDate.set(key, today);
|
|
774
|
+
else markRenewSucceeded(hostUrl, cliToken, today);
|
|
766
775
|
logger.info(`cli-token: renewed for ${normalizeUrl(hostUrl)} (local day ${today})`);
|
|
767
776
|
} catch (error) {
|
|
768
|
-
logger.warn(`cli-token: renew failed for ${normalizeUrl(hostUrl)}: ${error?.message || error}; business call proceeds`);
|
|
777
|
+
logger.warn(`cli-token: renew failed for ${normalizeUrl(hostUrl)}${external ? "" : `: ${error?.message || error}`}; business call proceeds`);
|
|
769
778
|
} finally {
|
|
770
779
|
renewInFlight.delete(key);
|
|
771
780
|
}
|
|
@@ -774,6 +783,9 @@ async function maybeRenewCliTokenDaily(hostUrl, cliToken) {
|
|
|
774
783
|
await attempt;
|
|
775
784
|
}
|
|
776
785
|
function peekCliToken(hostOverride) {
|
|
786
|
+
const external = readExternalCliToken(hostOverride);
|
|
787
|
+
if (external) return external.token;
|
|
788
|
+
if (process.env.TE_AGENT_CLI_CONFIG_DIR !== void 0) return sessionCliToken(hostOverride);
|
|
777
789
|
const hostUrl = hostOverride || getActiveHost();
|
|
778
790
|
if (!hostUrl) return void 0;
|
|
779
791
|
const normalizedHost = normalizeUrl(hostUrl);
|
|
@@ -791,6 +803,16 @@ function peekCliToken(hostOverride) {
|
|
|
791
803
|
return cliTokenCache.get(normalizedHost) || getFallbackCliToken(normalizedHost) || void 0;
|
|
792
804
|
}
|
|
793
805
|
async function getCliToken(hostOverride) {
|
|
806
|
+
const external = readExternalCliToken(hostOverride);
|
|
807
|
+
if (external) {
|
|
808
|
+
await maybeRenewCliTokenDaily(external.url, external.token, true);
|
|
809
|
+
return external.token;
|
|
810
|
+
}
|
|
811
|
+
if (process.env.TE_AGENT_CLI_CONFIG_DIR !== void 0) {
|
|
812
|
+
const token2 = sessionCliToken(hostOverride);
|
|
813
|
+
if (!token2) throw new SecureStoreAuthError("Current session CLI credential is unavailable or does not match the requested host.");
|
|
814
|
+
return token2;
|
|
815
|
+
}
|
|
794
816
|
const resolvedHost = hostOverride || getActiveHost();
|
|
795
817
|
if (!resolvedHost) throw new SecureStoreAuthError("No AE host configured. Run: ae-cli auth login --host <url>");
|
|
796
818
|
const hostUrl = normalizeUrl(resolvedHost);
|
|
@@ -803,6 +825,12 @@ async function getCliToken(hostOverride) {
|
|
|
803
825
|
await maybeRenewCliTokenDaily(hostUrl, token);
|
|
804
826
|
return token;
|
|
805
827
|
}
|
|
828
|
+
function sessionCliToken(hostOverride) {
|
|
829
|
+
const entry = readSandboxCliTokenEntry();
|
|
830
|
+
if (!entry?.token.startsWith("cli_")) return void 0;
|
|
831
|
+
if (hostOverride && normalizeUrl(entry.url) !== normalizeUrl(hostOverride)) return void 0;
|
|
832
|
+
return entry.token;
|
|
833
|
+
}
|
|
806
834
|
async function mintCliToken(hostUrl, accessToken) {
|
|
807
835
|
logger.info(`Generating CLI token for ${hostUrl}`);
|
|
808
836
|
const cliToken = await generateCliToken(hostUrl, accessToken);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
-
getActiveHost
|
|
3
|
+
getActiveHost
|
|
4
|
+
} from "./chunk-JNVVJ273.js";
|
|
5
|
+
import {
|
|
4
6
|
normalizeUrl
|
|
5
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-Z3Q2AEIN.js";
|
|
6
8
|
|
|
7
9
|
// src/core/auth.ts
|
|
8
10
|
function resolveHost(hostOverride) {
|
|
@@ -6,13 +6,15 @@ import {
|
|
|
6
6
|
SecureStoreAuthError,
|
|
7
7
|
clearCliTokenCache,
|
|
8
8
|
getCliToken
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-H3K5UGYC.js";
|
|
10
10
|
import {
|
|
11
|
-
safeJsonParse
|
|
12
|
-
|
|
11
|
+
safeJsonParse,
|
|
12
|
+
stringifyJsonRequest
|
|
13
|
+
} from "./chunk-JNVVJ273.js";
|
|
13
14
|
import {
|
|
14
|
-
PermissionError
|
|
15
|
-
|
|
15
|
+
PermissionError,
|
|
16
|
+
externalCliTokenRequestOptions
|
|
17
|
+
} from "./chunk-Z3Q2AEIN.js";
|
|
16
18
|
|
|
17
19
|
// src/core/cli-agent-context.ts
|
|
18
20
|
import { readFileSync, statSync } from "fs";
|
|
@@ -306,7 +308,13 @@ async function permissionError(resp) {
|
|
|
306
308
|
const body = safeJsonParse(await codeResponse.text());
|
|
307
309
|
const error = isRecord(body?.error) ? body.error : void 0;
|
|
308
310
|
const code = nonEmptyString(error?.code) ?? nonEmptyString(body?.code);
|
|
309
|
-
return new PermissionError(
|
|
311
|
+
return new PermissionError(
|
|
312
|
+
message,
|
|
313
|
+
code,
|
|
314
|
+
nonEmptyString(error?.hint),
|
|
315
|
+
void 0,
|
|
316
|
+
isRecord(body?.meta) ? body.meta : void 0
|
|
317
|
+
);
|
|
310
318
|
}
|
|
311
319
|
function isInvalidCliTokenMessage(message) {
|
|
312
320
|
return /\byour token is invalid\b/i.test(message) || /\bcli[-_\s]?token\b.*\binvalid\b/i.test(message) || /\binvalid\b.*\bcli[-_\s]?token\b/i.test(message);
|
|
@@ -319,7 +327,10 @@ function parseCapabilityResponse(text) {
|
|
|
319
327
|
return text;
|
|
320
328
|
}
|
|
321
329
|
}
|
|
322
|
-
function
|
|
330
|
+
function isCommunityGatewayRequest(domain, pathAfterV1) {
|
|
331
|
+
return domain.replace(/^\/+|\/+$/g, "") === "community" || /^capabilities\/community\./.test(pathAfterV1.replace(/^\/+/, ""));
|
|
332
|
+
}
|
|
333
|
+
function parseCapabilityEnvelope(body, acceptCommunityLegacyEnvelope = false) {
|
|
323
334
|
if (body == null) {
|
|
324
335
|
throw new CapabilityGatewayError("Empty capability gateway response");
|
|
325
336
|
}
|
|
@@ -344,10 +355,32 @@ function parseCapabilityEnvelope(body) {
|
|
|
344
355
|
err.type === "validation" ? "validation" : "api"
|
|
345
356
|
);
|
|
346
357
|
}
|
|
358
|
+
const legacyReturnCode = acceptCommunityLegacyEnvelope ? body.return_code ?? body.returnCode : void 0;
|
|
359
|
+
if (legacyReturnCode !== void 0 && Number(legacyReturnCode) !== 0) {
|
|
360
|
+
const code = String(legacyReturnCode);
|
|
361
|
+
const rawMessage = nonEmptyString(body.return_message) ?? nonEmptyString(body.returnMessage) ?? nonEmptyString(body.message);
|
|
362
|
+
const message = safeLegacyErrorMessage(rawMessage, code);
|
|
363
|
+
throw new CapabilityGatewayError(
|
|
364
|
+
message,
|
|
365
|
+
code,
|
|
366
|
+
void 0,
|
|
367
|
+
"The community service returned a legacy error envelope. Verify that the capability gateway route is deployed on the current host.",
|
|
368
|
+
{ legacy_return_code: legacyReturnCode }
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
if (legacyReturnCode !== void 0 && Number(legacyReturnCode) === 0 && "data" in body) {
|
|
372
|
+
return { ok: true, data: body.data };
|
|
373
|
+
}
|
|
347
374
|
return { ok: true, data: body };
|
|
348
375
|
}
|
|
349
|
-
function
|
|
350
|
-
|
|
376
|
+
function safeLegacyErrorMessage(message, code) {
|
|
377
|
+
if (!message || /\n\s*at\s|stacktrace|\.java:\d+/i.test(message)) {
|
|
378
|
+
return `Capability service request failed (legacy return code ${code})`;
|
|
379
|
+
}
|
|
380
|
+
return message.slice(0, 500);
|
|
381
|
+
}
|
|
382
|
+
function unwrapCapabilityEnvelope(body, acceptCommunityLegacyEnvelope = false) {
|
|
383
|
+
return parseCapabilityEnvelope(body, acceptCommunityLegacyEnvelope).data;
|
|
351
384
|
}
|
|
352
385
|
function nonEmptyString(value) {
|
|
353
386
|
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
@@ -400,13 +433,14 @@ async function requestOnce(url, method, token, body, accept = "application/json"
|
|
|
400
433
|
const init = { method, headers };
|
|
401
434
|
if (body !== void 0 && method !== "GET") {
|
|
402
435
|
headers["Content-Type"] = "application/json";
|
|
403
|
-
init.body =
|
|
436
|
+
init.body = stringifyJsonRequest(includeClientContextInBody ? withCliAgentContextBody(body, agentContext) : body);
|
|
404
437
|
}
|
|
405
|
-
return fetch(url, init);
|
|
438
|
+
return fetch(url, { ...init, ...externalCliTokenRequestOptions(url) });
|
|
406
439
|
}
|
|
407
440
|
async function requestMultipartOnce(url, token, form) {
|
|
408
441
|
return fetch(url, {
|
|
409
442
|
method: "POST",
|
|
443
|
+
...externalCliTokenRequestOptions(url),
|
|
410
444
|
headers: {
|
|
411
445
|
"cli-token": token,
|
|
412
446
|
"Accept": "application/json",
|
|
@@ -439,7 +473,10 @@ async function callGatewayWithEnvelope(host, domain, pathAfterV1, method, body,
|
|
|
439
473
|
if (!resp.ok) {
|
|
440
474
|
await throwCapabilityHttpError(resp);
|
|
441
475
|
}
|
|
442
|
-
return parseCapabilityEnvelope(
|
|
476
|
+
return parseCapabilityEnvelope(
|
|
477
|
+
parseCapabilityResponse(await resp.text()),
|
|
478
|
+
isCommunityGatewayRequest(domain, pathAfterV1)
|
|
479
|
+
);
|
|
443
480
|
}
|
|
444
481
|
async function fetchCapabilityGateway(host, domain, pathAfterV1, method = "GET", body, accept = "application/json") {
|
|
445
482
|
const url = buildCapabilityGatewayUrl(host, domain, pathAfterV1);
|
|
@@ -459,11 +496,17 @@ async function fetchCapabilityGateway(host, domain, pathAfterV1, method = "GET",
|
|
|
459
496
|
}
|
|
460
497
|
async function requestCapabilityGateway(host, domain, pathAfterV1, method = "GET", body) {
|
|
461
498
|
const resp = await fetchCapabilityGateway(host, domain, pathAfterV1, method, body);
|
|
462
|
-
return unwrapCapabilityEnvelope(
|
|
499
|
+
return unwrapCapabilityEnvelope(
|
|
500
|
+
parseCapabilityResponse(await resp.text()),
|
|
501
|
+
isCommunityGatewayRequest(domain, pathAfterV1)
|
|
502
|
+
);
|
|
463
503
|
}
|
|
464
504
|
async function requestCapabilityGatewayWithEnvelope(host, domain, pathAfterV1, method = "GET", body) {
|
|
465
505
|
const resp = await fetchCapabilityGateway(host, domain, pathAfterV1, method, body);
|
|
466
|
-
return parseCapabilityEnvelope(
|
|
506
|
+
return parseCapabilityEnvelope(
|
|
507
|
+
parseCapabilityResponse(await resp.text()),
|
|
508
|
+
isCommunityGatewayRequest(domain, pathAfterV1)
|
|
509
|
+
);
|
|
467
510
|
}
|
|
468
511
|
async function listCapabilitiesWithEnvelope(host, domain, projectId) {
|
|
469
512
|
return callGatewayWithEnvelope(host, domain, "capabilities", "GET", void 0, { project_id: projectId });
|
|
@@ -544,7 +587,10 @@ async function uploadInputFileBytes(host, domain, projectId, purpose, bytes, fil
|
|
|
544
587
|
if (!resp.ok) {
|
|
545
588
|
await throwCapabilityHttpError(resp);
|
|
546
589
|
}
|
|
547
|
-
return unwrapCapabilityEnvelope(
|
|
590
|
+
return unwrapCapabilityEnvelope(
|
|
591
|
+
parseCapabilityResponse(await resp.text()),
|
|
592
|
+
isCommunityGatewayRequest(domain, "input-files")
|
|
593
|
+
);
|
|
548
594
|
}
|
|
549
595
|
async function callCapabilityApi(host, domain, action, method = "POST", params = {}, options = {}) {
|
|
550
596
|
const isGet = method === "GET";
|
|
@@ -2,7 +2,7 @@ import { createRequire as __createRequire } from 'node:module'; const require =
|
|
|
2
2
|
import {
|
|
3
3
|
__commonJS,
|
|
4
4
|
__require
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-Z3Q2AEIN.js";
|
|
6
6
|
|
|
7
7
|
// node_modules/process-nextick-args/index.js
|
|
8
8
|
var require_process_nextick_args = __commonJS({
|