@thinkingai/ae-cli 6.0.45 → 6.0.47

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.
Files changed (114) hide show
  1. package/README.md +2 -0
  2. package/README.zh.md +6 -0
  3. package/dist/{auth-77BUFLGC.js → auth-QPEVVBKT.js} +20 -15
  4. package/dist/auth-UMJAA72O.js +15 -0
  5. package/dist/{capability-ENHWPMTG.js → capability-RUSV77CO.js} +53 -15
  6. package/dist/{chunk-UW5UN47B.js → chunk-533JK3YX.js} +2 -0
  7. package/dist/{chunk-VPKZ7I72.js → chunk-6QK7SYYY.js} +5 -4
  8. package/dist/{chunk-TUKQZTMI.js → chunk-7K24F7T2.js} +2 -0
  9. package/dist/{chunk-OO6XR6LK.js → chunk-AMBFK2K3.js} +2 -0
  10. package/dist/{sync-DAVKYVMW.js → chunk-B5HMQAOM.js} +31 -540
  11. package/dist/{chunk-EE45RGOO.js → chunk-BVDST5YT.js} +5 -4
  12. package/dist/{chunk-VTWMIC5L.js → chunk-E2JKXMVO.js} +2 -0
  13. package/dist/{chunk-LYVNONC4.js → chunk-FR2EDAQM.js} +36 -0
  14. package/dist/{chunk-ILIU36SU.js → chunk-GJXRF7Y6.js} +6 -5
  15. package/dist/{chunk-DWO43OIB.js → chunk-JQ3ENZZH.js} +2 -0
  16. package/dist/chunk-JYMGHGCE.js +191 -0
  17. package/dist/{chunk-GT46FPXN.js → chunk-KEWVSO64.js} +18 -8
  18. package/dist/chunk-KZ6ZHF5J.js +294 -0
  19. package/dist/{chunk-QI524WPY.js → chunk-NSIVXKJH.js} +6 -5
  20. package/dist/chunk-O6K2ODUE.js +318 -0
  21. package/dist/chunk-QL6R6TSK.js +25215 -0
  22. package/dist/{chunk-4SGZG4XY.js → chunk-RWXIXOZG.js} +28 -13
  23. package/dist/{chunk-4NN5IWVN.js → chunk-T6OSFQZD.js} +2 -0
  24. package/dist/{chunk-PTE56QPL.js → chunk-TKHSULJT.js} +6 -0
  25. package/dist/{chunk-6EIJSNBD.js → chunk-Y74WTIKJ.js} +2 -0
  26. package/dist/{client-TKG4WBHN.js → client-N7NGZUNI.js} +6 -4
  27. package/dist/{community-report-client-FI4LNVYS.js → community-report-client-6OL6GBQW.js} +3 -3
  28. package/dist/{config-RE6CMGPK.js → config-XNMACCKX.js} +10 -8
  29. package/dist/{data-integration-XQYB4X4F.js → data-integration-4NZGZ45E.js} +2502 -272
  30. package/dist/index.js +130 -1243
  31. package/dist/{local-data-upload-client-BWHSUQQK.js → local-data-upload-client-EFHDLXFG.js} +3 -3
  32. package/dist/{memory-YK33G4T7.js → memory-HBJQ2GC5.js} +8 -7
  33. package/dist/{metadata-AXVHAAZG.js → metadata-PGDJE5RQ.js} +12 -11
  34. package/dist/{model-K3KLWIW6.js → model-BHLJ2QMT.js} +10 -9
  35. package/dist/personal-semantic-preference-E5NZ56DN.js +240 -0
  36. package/dist/sync-MUWPRM5I.js +522 -0
  37. package/dist/{te-agent-4BKBODMF.js → te-agent-WQZTMEK4.js} +12 -10
  38. package/dist/{te-analysis-WX7LRVAV.js → te-analysis-YWCSSLYL.js} +534 -48
  39. package/dist/{te-community-HLC43QKH.js → te-community-BNE6KREL.js} +8 -7
  40. package/dist/{te-dataops-EJP56W3K.js → te-dataops-TXLKM2W6.js} +469 -68
  41. package/dist/{te-engage-UBHPAJCO.js → te-engage-VEW4CJHK.js} +26 -10
  42. package/dist/{te-kb-SQCLHG6X.js → te-kb-BUD6N3NI.js} +312 -25
  43. package/dist/{te-system-YARIK4S5.js → te-system-44LZJDTQ.js} +573 -37
  44. package/dist/{te-team-EFKWYKMK.js → te-team-XMP47YXE.js} +10 -7
  45. package/dist/{update-OGPSZM5A.js → update-UODFOZ4P.js} +9 -7
  46. package/package.json +18 -9
  47. package/skills/ae-agent/SKILL.md +3 -4
  48. package/skills/ae-agent/references/edit-skill.md +3 -0
  49. package/skills/ae-agent/references/get-skill-content.md +1 -1
  50. package/skills/ae-agent/references/rescan-skills.md +15 -13
  51. package/skills/ae-agent/references/upload-skill.md +7 -4
  52. package/skills/ae-analysis/SKILL.md +29 -4
  53. package/skills/ae-analysis/metadata_resolution.md +38 -4
  54. package/skills/ae-analysis/references/analysis_data_retrieval.md +29 -0
  55. package/skills/ae-analysis/references/analysis_gateway_assets.md +1 -1
  56. package/skills/ae-analysis/references/asset_authentication_export.md +22 -0
  57. package/skills/ae-analysis/references/asset_authentication_list.md +18 -14
  58. package/skills/ae-analysis/references/asset_authentication_update.md +29 -14
  59. package/skills/ae-analysis/references/audience_models.md +18 -0
  60. package/skills/ae-analysis/references/command_index.md +19 -11
  61. package/skills/ae-analysis/references/dashboard_get.md +18 -1
  62. package/skills/ae-analysis/references/dashboard_update.md +3 -0
  63. package/skills/ae-analysis/references/personal_semantic_preference_add.md +23 -0
  64. package/skills/ae-analysis/references/personal_semantic_preference_delete.md +17 -0
  65. package/skills/ae-analysis/references/personal_semantic_preference_get.md +17 -0
  66. package/skills/ae-analysis/references/personal_semantic_preference_list.md +19 -0
  67. package/skills/ae-analysis/references/personal_semantic_preference_update.md +19 -0
  68. package/skills/ae-analysis/references/project_timezone_update.md +13 -4
  69. package/skills/ae-analysis/references/property_create.md +2 -0
  70. package/skills/ae-analysis/references/super_metadata_batch_create.md +2 -0
  71. package/skills/ae-analysis/references/user_cluster_models.md +2 -0
  72. package/skills/ae-analysis/references/user_cluster_update.md +8 -4
  73. package/skills/ae-analysis/references/user_tag_create.md +7 -1
  74. package/skills/ae-analysis/references/user_tag_models.md +8 -2
  75. package/skills/ae-data-integration/SKILL.md +24 -4
  76. package/skills/ae-data-integration/references/custom-layer.md +93 -0
  77. package/skills/ae-data-integration/references/error-handling.md +145 -0
  78. package/skills/ae-data-integration/references/handoff.md +77 -18
  79. package/skills/ae-data-integration/references/local-analysis.md +1 -1
  80. package/skills/ae-data-integration/references/reuse.md +9 -5
  81. package/skills/ae-data-integration/references/sink-upload.md +1 -1
  82. package/skills/ae-data-integration/references/source-inspect.md +35 -13
  83. package/skills/ae-data-integration/references/tracking-plan.md +7 -5
  84. package/skills/ae-data-integration/references/transform.md +12 -10
  85. package/skills/ae-data-integration/references/ue-mapping.md +33 -11
  86. package/skills/ae-data-integration/references/ue-routing.md +23 -0
  87. package/skills/ae-dataops/SKILL.md +11 -1
  88. package/skills/ae-dataops/references/dataops-backfill.md +135 -0
  89. package/skills/ae-engage/SKILL.md +3 -0
  90. package/skills/ae-engage/references/build-task-save-guide.md +14 -1
  91. package/skills/ae-engage/references/save-task.md +88 -0
  92. package/skills/ae-kb/SKILL.md +121 -10
  93. package/skills/ae-system/SKILL.md +28 -30
  94. package/skills/ae-system/references/channel-management.md +303 -0
  95. package/dist/auth-2WTQOP77.js +0 -14
  96. package/dist/capability-WA37LSIR.js +0 -312
  97. package/dist/chunk-4KVPKXFX.js +0 -98
  98. package/dist/chunk-C4MGVGJW.js +0 -13
  99. package/dist/chunk-MGU2N3HW.js +0 -556
  100. package/dist/chunk-P3FGXJTU.js +0 -349
  101. package/dist/chunk-QEFCIRNJ.js +0 -71
  102. package/dist/chunk-QGM4M3NI.js +0 -37
  103. package/dist/chunk-UOUS37JQ.js +0 -509
  104. package/dist/chunk-ZZUOD757.js +0 -598
  105. package/dist/memory-CHRU2F7W.js +0 -893
  106. package/dist/metadata-GGEHHPBE.js +0 -339
  107. package/dist/model-NR3JHFSJ.js +0 -139
  108. package/dist/sync-FCKOVWWS.js +0 -10261
  109. package/dist/te-agent-HLW4VTQK.js +0 -3893
  110. package/dist/te-analysis-YKFDBMA6.js +0 -8958
  111. package/dist/te-community-6HPBWJUZ.js +0 -1859
  112. package/dist/te-dataops-HDRUXY4K.js +0 -2208
  113. package/dist/te-engage-WLDTS5J5.js +0 -4898
  114. package/dist/te-system-Z77IKZFN.js +0 -2213
@@ -0,0 +1,318 @@
1
+ import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
+ import {
3
+ getActiveHost,
4
+ getConfigDir,
5
+ normalizeUrl,
6
+ safeJsonParse
7
+ } from "./chunk-KZ6ZHF5J.js";
8
+ import {
9
+ logger
10
+ } from "./chunk-FR2EDAQM.js";
11
+
12
+ // src/core/secure-store.ts
13
+ import crypto from "crypto";
14
+ import fs from "fs";
15
+ import os from "os";
16
+ import path from "path";
17
+ import { execFileSync } from "child_process";
18
+ var STORE_DIR_SUFFIX = "secure-tokens";
19
+ var SCRYPT_SALT = Buffer.from("ae-cli-secure-store-v1");
20
+ var SCRYPT_N = 16384;
21
+ var SCRYPT_R = 8;
22
+ var SCRYPT_P = 1;
23
+ var KEY_LEN = 32;
24
+ var NONCE_LEN = 12;
25
+ var REFRESH_TOKEN_PATH = "/v1/oauth/refreshForToken";
26
+ function getMachineId() {
27
+ if (process.platform === "darwin") {
28
+ try {
29
+ const out = execFileSync(
30
+ "ioreg",
31
+ ["-rd1", "-c", "IOPlatformExpertDevice"],
32
+ { encoding: "utf8", timeout: 3e3 }
33
+ );
34
+ const m = out.match(/IOPlatformUUID.*?=.*?"([0-9A-F-]{36})"/i);
35
+ if (m?.[1]) return `darwin:${m[1]}`;
36
+ } catch {
37
+ }
38
+ }
39
+ if (process.platform === "linux") {
40
+ for (const p of ["/etc/machine-id", "/var/lib/dbus/machine-id"]) {
41
+ try {
42
+ const id = fs.readFileSync(p, "utf8").trim();
43
+ if (id) return `linux:${id}`;
44
+ } catch {
45
+ }
46
+ }
47
+ }
48
+ if (process.platform === "win32") {
49
+ try {
50
+ const out = execFileSync(
51
+ "reg",
52
+ ["query", "HKLM\\SOFTWARE\\Microsoft\\Cryptography", "/v", "MachineGuid"],
53
+ { encoding: "utf8", timeout: 3e3 }
54
+ );
55
+ const m = out.match(/MachineGuid\s+REG_SZ\s+([0-9a-f-]+)/i);
56
+ if (m?.[1]) return `win32:${m[1]}`;
57
+ } catch {
58
+ }
59
+ }
60
+ const fallback = `${os.homedir()}|${os.hostname()}|${os.platform()}`;
61
+ logger.warn("secure-store: using fallback machine-id (HOME+hostname+platform)");
62
+ return `fallback:${fallback}`;
63
+ }
64
+ var _cachedMachineId;
65
+ function getCachedMachineId() {
66
+ if (!_cachedMachineId) _cachedMachineId = getMachineId();
67
+ return _cachedMachineId;
68
+ }
69
+ function deriveKey(machineId) {
70
+ return crypto.scryptSync(machineId, SCRYPT_SALT, KEY_LEN, {
71
+ N: SCRYPT_N,
72
+ r: SCRYPT_R,
73
+ p: SCRYPT_P
74
+ });
75
+ }
76
+ var _cachedKey;
77
+ function getKey() {
78
+ if (!_cachedKey) _cachedKey = deriveKey(getCachedMachineId());
79
+ return _cachedKey;
80
+ }
81
+ function encrypt(plaintext) {
82
+ const key = getKey();
83
+ const nonce = crypto.randomBytes(NONCE_LEN);
84
+ const cipher = crypto.createCipheriv("aes-256-gcm", key, nonce);
85
+ const encrypted = Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]);
86
+ const tag = cipher.getAuthTag();
87
+ return {
88
+ nonce: nonce.toString("hex"),
89
+ tag: tag.toString("hex"),
90
+ data: encrypted.toString("hex")
91
+ };
92
+ }
93
+ function decrypt(blob) {
94
+ const key = getKey();
95
+ const nonce = Buffer.from(blob.nonce, "hex");
96
+ const tag = Buffer.from(blob.tag, "hex");
97
+ const data = Buffer.from(blob.data, "hex");
98
+ const decipher = crypto.createDecipheriv("aes-256-gcm", key, nonce);
99
+ decipher.setAuthTag(tag);
100
+ const decrypted = Buffer.concat([decipher.update(data), decipher.final()]);
101
+ return decrypted.toString("utf8");
102
+ }
103
+ function storeDir() {
104
+ return path.join(getConfigDir(), STORE_DIR_SUFFIX);
105
+ }
106
+ function tokenFilePath(host) {
107
+ const safe = host.replace(/^https?:\/\//, "").replace(/[^a-zA-Z0-9._-]/g, "_");
108
+ return path.join(storeDir(), `${safe}.enc.json`);
109
+ }
110
+ function ensureStoreDir() {
111
+ const dir = storeDir();
112
+ if (!fs.existsSync(dir)) {
113
+ fs.mkdirSync(dir, { recursive: true });
114
+ try {
115
+ fs.chmodSync(dir, 448);
116
+ } catch {
117
+ }
118
+ }
119
+ }
120
+ function save(host, payload) {
121
+ ensureStoreDir();
122
+ const plaintext = JSON.stringify(payload);
123
+ const blob = encrypt(plaintext);
124
+ const filePath = tokenFilePath(host);
125
+ fs.writeFileSync(filePath, JSON.stringify(blob, null, 2), { encoding: "utf8" });
126
+ try {
127
+ fs.chmodSync(filePath, 384);
128
+ } catch {
129
+ }
130
+ logger.info(`secure-store: token saved for ${host}`);
131
+ }
132
+ function load(host) {
133
+ const filePath = tokenFilePath(host);
134
+ if (!fs.existsSync(filePath)) return null;
135
+ try {
136
+ const raw = fs.readFileSync(filePath, "utf8");
137
+ const blob = safeJsonParse(raw);
138
+ if (!blob?.nonce || !blob?.tag || !blob?.data) {
139
+ logger.warn(`secure-store: malformed blob for ${host}`);
140
+ return null;
141
+ }
142
+ const plaintext = decrypt(blob);
143
+ return JSON.parse(plaintext);
144
+ } catch (e) {
145
+ logger.error(`secure-store: decrypt failed for ${host}: ${e.message}`);
146
+ return null;
147
+ }
148
+ }
149
+ function clear(host) {
150
+ const filePath = tokenFilePath(host);
151
+ if (fs.existsSync(filePath)) {
152
+ fs.rmSync(filePath);
153
+ logger.info(`secure-store: token cleared for ${host}`);
154
+ }
155
+ }
156
+ async function getValidAccessToken(host) {
157
+ const payload = load(host);
158
+ if (!payload) {
159
+ throw new SecureStoreAuthError(
160
+ `No stored token for ${host}. Please run: ae-cli auth login`
161
+ );
162
+ }
163
+ const expiresAt = new Date(payload.accessExpiresAt).getTime();
164
+ const now = Date.now();
165
+ const needsRefresh = expiresAt - now < 6e4;
166
+ if (!needsRefresh) {
167
+ return payload.accessToken;
168
+ }
169
+ if (payload.refreshToken) {
170
+ logger.info(`secure-store: access token past local expiry for ${host}, refreshing\u2026`);
171
+ const refreshed = await doRefresh(host, payload.refreshToken);
172
+ save(host, { ...refreshed, cliToken: payload.cliToken });
173
+ logger.info(`secure-store: token refreshed for ${host}`);
174
+ return refreshed.accessToken;
175
+ }
176
+ logger.info(`secure-store: ${host} past static local expiry, no refresh token \u2014 returning stored token, server validates (lazy)`);
177
+ return payload.accessToken;
178
+ }
179
+ function loadCliToken(host) {
180
+ return load(host)?.cliToken ?? null;
181
+ }
182
+ async function doRefresh(host, refreshToken) {
183
+ const base = host.replace(/\/+$/, "");
184
+ const url = `${base}${REFRESH_TOKEN_PATH}`;
185
+ let resp;
186
+ try {
187
+ resp = await fetch(url, {
188
+ method: "POST",
189
+ headers: { "Content-Type": "application/json" },
190
+ body: JSON.stringify({ refreshToken })
191
+ });
192
+ } catch (e) {
193
+ throw new SecureStoreAuthError(
194
+ `Token refresh network error for ${host}: ${e.message}. Please run: ae-cli auth login`
195
+ );
196
+ }
197
+ if (!resp.ok) {
198
+ throw new SecureStoreAuthError(
199
+ `Token refresh failed (HTTP ${resp.status}) for ${host}. Please run: ae-cli auth login`
200
+ );
201
+ }
202
+ let body;
203
+ try {
204
+ body = safeJsonParse(await resp.text());
205
+ } catch {
206
+ throw new SecureStoreAuthError(
207
+ `Token refresh returned invalid JSON for ${host}. Please run: ae-cli auth login`
208
+ );
209
+ }
210
+ if (body.return_code !== 0) {
211
+ throw new SecureStoreAuthError(
212
+ `Token refresh error (${body.return_code}: ${body.return_message ?? "unknown"}) for ${host}. Please run: ae-cli auth login`
213
+ );
214
+ }
215
+ const d = body.data;
216
+ const newAccess = d?.accessToken ?? d?.access_token ?? "";
217
+ const newRefresh = d?.refreshToken ?? d?.refresh_token ?? refreshToken;
218
+ const expiresIn = d?.expiresIn ?? d?.expires_in ?? 72e3;
219
+ if (!newAccess) {
220
+ throw new SecureStoreAuthError(
221
+ `Token refresh returned empty accessToken for ${host}. Please run: ae-cli auth login`
222
+ );
223
+ }
224
+ return {
225
+ accessToken: newAccess,
226
+ refreshToken: newRefresh,
227
+ accessExpiresAt: new Date(Date.now() + expiresIn * 1e3).toISOString()
228
+ };
229
+ }
230
+ var SecureStoreAuthError = class extends Error {
231
+ constructor(message) {
232
+ super(message);
233
+ this.name = "SecureStoreAuthError";
234
+ }
235
+ };
236
+
237
+ // src/core/host-guidance.ts
238
+ var AE_TRIAL_URL = "https://thinkingai.cn/request-demo";
239
+ var AE_HOST_SETUP_COMMAND = "ae-cli config set-host <url>";
240
+ function missingAeHostHint(additionalAction) {
241
+ const actions = [
242
+ `If your organization already uses AgenticEngine, ask your administrator for its AE URL, then run: ${AE_HOST_SETUP_COMMAND}.`,
243
+ `If you do not have an AgenticEngine environment, request a trial: ${AE_TRIAL_URL}`
244
+ ];
245
+ if (additionalAction) actions.push(additionalAction);
246
+ return actions.join(" ");
247
+ }
248
+ function missingAeHostGuidance() {
249
+ return {
250
+ configure_host: AE_HOST_SETUP_COMMAND,
251
+ existing_customer: "Ask your AgenticEngine administrator for the AE environment URL.",
252
+ request_trial_url: AE_TRIAL_URL
253
+ };
254
+ }
255
+
256
+ // src/core/auth.ts
257
+ function resolveHost(hostOverride) {
258
+ if (hostOverride) return normalizeUrl(hostOverride);
259
+ return getActiveHost();
260
+ }
261
+ async function validateToken(token, hostUrl) {
262
+ const url = `${hostUrl}/v1/oauth/checkToken`;
263
+ try {
264
+ const resp = await fetch(url, {
265
+ method: "POST",
266
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
267
+ body: new URLSearchParams({ accessToken: token }).toString()
268
+ });
269
+ const respJson = safeJsonParse(await resp.text());
270
+ return respJson?.return_code === 0;
271
+ } catch {
272
+ return false;
273
+ }
274
+ }
275
+ function invalidateAccessTokenForRetry(hostUrl) {
276
+ const payload = load(hostUrl);
277
+ if (!payload) return;
278
+ save(hostUrl, { ...payload, accessExpiresAt: (/* @__PURE__ */ new Date(0)).toISOString() });
279
+ logger.info(`auth: marked access token stale for retry on ${hostUrl}`);
280
+ }
281
+ async function getToken(hostUrl) {
282
+ if (!hostUrl) {
283
+ throw new Error(
284
+ `No AE host configured.
285
+ ` + missingAeHostHint()
286
+ );
287
+ }
288
+ try {
289
+ const secureToken = await getValidAccessToken(hostUrl);
290
+ logger.info(`Using secure-store token for ${hostUrl}`);
291
+ return secureToken;
292
+ } catch (e) {
293
+ if (e instanceof SecureStoreAuthError) {
294
+ logger.info(`secure-store: ${e.message}`);
295
+ } else {
296
+ logger.warn(`secure-store unexpected error: ${e.message}`);
297
+ }
298
+ }
299
+ throw new Error(
300
+ `Cannot obtain token for ${hostUrl}.
301
+ Run: ae-cli auth login (device code flow, cross-platform)`
302
+ );
303
+ }
304
+
305
+ export {
306
+ save,
307
+ load,
308
+ clear,
309
+ loadCliToken,
310
+ SecureStoreAuthError,
311
+ AE_TRIAL_URL,
312
+ missingAeHostHint,
313
+ missingAeHostGuidance,
314
+ resolveHost,
315
+ validateToken,
316
+ invalidateAccessTokenForRetry,
317
+ getToken
318
+ };