@thinkingai/ae-cli 6.1.17 → 6.1.19

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 (126) 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-72DTW5M2.js → capability-ASI62I4A.js} +53 -15
  6. package/dist/{chunk-UW5UN47B.js → chunk-533JK3YX.js} +2 -0
  7. package/dist/{chunk-UOUS37JQ.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-VR3LCBHW.js → chunk-DKEXH6Q5.js} +6 -5
  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-O6K2ODUE.js +318 -0
  20. package/dist/chunk-QL6R6TSK.js +25215 -0
  21. package/dist/{chunk-4SGZG4XY.js → chunk-RWXIXOZG.js} +28 -13
  22. package/dist/{chunk-YA6SMTXG.js → chunk-S5PONFBM.js} +5 -4
  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 +137 -1245
  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-UILXHBWF.js → metadata-62EWBEIG.js} +12 -11
  34. package/dist/{model-NR3JHFSJ.js → model-BHLJ2QMT.js} +10 -9
  35. package/dist/personal-semantic-preference-JBVMAI7L.js +240 -0
  36. package/dist/project-semantic-BQ4MPUS5.js +1115 -0
  37. package/dist/sync-MUWPRM5I.js +522 -0
  38. package/dist/{te-agent-4BKBODMF.js → te-agent-WQZTMEK4.js} +12 -10
  39. package/dist/{te-analysis-O6DCO6BS.js → te-analysis-MNCG65LU.js} +534 -48
  40. package/dist/{te-community-HLC43QKH.js → te-community-BNE6KREL.js} +8 -7
  41. package/dist/{te-dataops-EJP56W3K.js → te-dataops-TXLKM2W6.js} +469 -68
  42. package/dist/{te-engage-FGBGQ4IY.js → te-engage-TPKLRVTL.js} +84 -10
  43. package/dist/{te-experiment-SO5MPDMJ.js → te-experiment-6BYKTCY7.js} +303 -12
  44. package/dist/{te-kb-SQCLHG6X.js → te-kb-BUD6N3NI.js} +312 -25
  45. package/dist/{te-system-YARIK4S5.js → te-system-44LZJDTQ.js} +573 -37
  46. package/dist/{te-team-EFKWYKMK.js → te-team-XMP47YXE.js} +10 -7
  47. package/dist/{update-OGPSZM5A.js → update-UODFOZ4P.js} +9 -7
  48. package/package.json +18 -9
  49. package/skills/ae-agent/SKILL.md +3 -4
  50. package/skills/ae-agent/references/edit-skill.md +3 -0
  51. package/skills/ae-agent/references/get-skill-content.md +1 -1
  52. package/skills/ae-agent/references/rescan-skills.md +15 -13
  53. package/skills/ae-agent/references/upload-skill.md +7 -4
  54. package/skills/ae-analysis/SKILL.md +45 -4
  55. package/skills/ae-analysis/metadata_resolution.md +38 -4
  56. package/skills/ae-analysis/references/analysis_data_retrieval.md +29 -0
  57. package/skills/ae-analysis/references/analysis_gateway_assets.md +1 -1
  58. package/skills/ae-analysis/references/asset_authentication_export.md +22 -0
  59. package/skills/ae-analysis/references/asset_authentication_list.md +18 -14
  60. package/skills/ae-analysis/references/asset_authentication_update.md +29 -14
  61. package/skills/ae-analysis/references/audience_models.md +18 -0
  62. package/skills/ae-analysis/references/command_index.md +19 -11
  63. package/skills/ae-analysis/references/dashboard_get.md +18 -1
  64. package/skills/ae-analysis/references/dashboard_update.md +3 -0
  65. package/skills/ae-analysis/references/personal_semantic_preference_add.md +23 -0
  66. package/skills/ae-analysis/references/personal_semantic_preference_delete.md +17 -0
  67. package/skills/ae-analysis/references/personal_semantic_preference_get.md +19 -0
  68. package/skills/ae-analysis/references/personal_semantic_preference_list.md +21 -0
  69. package/skills/ae-analysis/references/personal_semantic_preference_update.md +19 -0
  70. package/skills/ae-analysis/references/project_timezone_update.md +13 -4
  71. package/skills/ae-analysis/references/property_create.md +2 -0
  72. package/skills/ae-analysis/references/super_metadata_batch_create.md +2 -0
  73. package/skills/ae-analysis/references/user_cluster_models.md +2 -0
  74. package/skills/ae-analysis/references/user_cluster_update.md +8 -4
  75. package/skills/ae-analysis/references/user_tag_create.md +7 -1
  76. package/skills/ae-analysis/references/user_tag_models.md +8 -2
  77. package/skills/ae-data-integration/SKILL.md +24 -4
  78. package/skills/ae-data-integration/references/custom-layer.md +93 -0
  79. package/skills/ae-data-integration/references/error-handling.md +145 -0
  80. package/skills/ae-data-integration/references/handoff.md +77 -18
  81. package/skills/ae-data-integration/references/local-analysis.md +1 -1
  82. package/skills/ae-data-integration/references/reuse.md +9 -5
  83. package/skills/ae-data-integration/references/sink-upload.md +1 -1
  84. package/skills/ae-data-integration/references/source-inspect.md +35 -13
  85. package/skills/ae-data-integration/references/tracking-plan.md +7 -5
  86. package/skills/ae-data-integration/references/transform.md +12 -10
  87. package/skills/ae-data-integration/references/ue-mapping.md +33 -11
  88. package/skills/ae-data-integration/references/ue-routing.md +23 -0
  89. package/skills/ae-dataops/SKILL.md +11 -1
  90. package/skills/ae-dataops/references/dataops-backfill.md +135 -0
  91. package/skills/ae-engage/SKILL.md +5 -0
  92. package/skills/ae-engage/references/build-task-save-guide.md +14 -1
  93. package/skills/ae-engage/references/save-flow.md +37 -1
  94. package/skills/ae-engage/references/save-task.md +88 -0
  95. package/skills/ae-experiment/SKILL.md +14 -4
  96. package/skills/ae-experiment/references/manage_feature_whitelist.md +66 -0
  97. package/skills/ae-experiment/references/manage_guardrail_metrics.md +26 -0
  98. package/skills/ae-experiment/references/save_experiment.md +1 -1
  99. package/skills/ae-experiment/references/save_metric.md +20 -8
  100. package/skills/ae-kb/SKILL.md +121 -10
  101. package/skills/ae-project-semantic/SKILL.md +193 -0
  102. package/skills/ae-project-semantic/references/query-routing-v5.md +165 -0
  103. package/skills/ae-project-semantic/references/recommendation-quality.md +68 -0
  104. package/skills/ae-system/SKILL.md +28 -30
  105. package/skills/ae-system/references/channel-management.md +303 -0
  106. package/dist/auth-2WTQOP77.js +0 -14
  107. package/dist/capability-PJHNI4GJ.js +0 -315
  108. package/dist/chunk-4KVPKXFX.js +0 -98
  109. package/dist/chunk-C4MGVGJW.js +0 -13
  110. package/dist/chunk-P3FGXJTU.js +0 -349
  111. package/dist/chunk-QGM4M3NI.js +0 -37
  112. package/dist/chunk-RGKJGKT7.js +0 -71
  113. package/dist/chunk-SAU3QFIQ.js +0 -556
  114. package/dist/chunk-VPKZ7I72.js +0 -509
  115. package/dist/chunk-ZZUOD757.js +0 -598
  116. package/dist/memory-CHRU2F7W.js +0 -893
  117. package/dist/metadata-XXR34N5P.js +0 -339
  118. package/dist/model-K3KLWIW6.js +0 -139
  119. package/dist/sync-FCKOVWWS.js +0 -10261
  120. package/dist/te-agent-HLW4VTQK.js +0 -3893
  121. package/dist/te-analysis-ZMNGOVNW.js +0 -8958
  122. package/dist/te-community-6HPBWJUZ.js +0 -1859
  123. package/dist/te-dataops-HDRUXY4K.js +0 -2208
  124. package/dist/te-engage-RAK5PESW.js +0 -4898
  125. package/dist/te-experiment-VZF7BT6G.js +0 -770
  126. package/dist/te-system-Z77IKZFN.js +0 -2213
@@ -1,3 +1,36 @@
1
+ import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
+ }) : x)(function(x) {
11
+ if (typeof require !== "undefined") return require.apply(this, arguments);
12
+ throw Error('Dynamic require of "' + x + '" is not supported');
13
+ });
14
+ var __commonJS = (cb, mod) => function __require2() {
15
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
16
+ };
17
+ var __copyProps = (to, from, except, desc) => {
18
+ if (from && typeof from === "object" || typeof from === "function") {
19
+ for (let key of __getOwnPropNames(from))
20
+ if (!__hasOwnProp.call(to, key) && key !== except)
21
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22
+ }
23
+ return to;
24
+ };
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26
+ // If the importer is in node compatibility mode or this is not an ESM
27
+ // file that has been converted to a CommonJS file using a Babel-
28
+ // compatible transform (i.e. "__esModule" has not been set), then set
29
+ // "default" to the CommonJS "module.exports" for node compatibility.
30
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31
+ mod
32
+ ));
33
+
1
34
  // src/core/logger.ts
2
35
  import fs from "fs";
3
36
  import path from "path";
@@ -82,5 +115,8 @@ var Logger = class {
82
115
  var logger = new Logger();
83
116
 
84
117
  export {
118
+ __require,
119
+ __commonJS,
120
+ __toESM,
85
121
  logger
86
122
  };
@@ -1,19 +1,20 @@
1
+ import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
1
2
  import {
2
3
  internalCallSourceHeaders
3
- } from "./chunk-6EIJSNBD.js";
4
+ } from "./chunk-Y74WTIKJ.js";
4
5
  import {
5
6
  clearCliToken,
6
7
  getCliToken
7
- } from "./chunk-4SGZG4XY.js";
8
+ } from "./chunk-RWXIXOZG.js";
8
9
  import {
9
10
  safeJsonParse
10
- } from "./chunk-ZZUOD757.js";
11
+ } from "./chunk-KZ6ZHF5J.js";
11
12
  import {
12
13
  PermissionError
13
- } from "./chunk-UW5UN47B.js";
14
+ } from "./chunk-533JK3YX.js";
14
15
  import {
15
16
  logger
16
- } from "./chunk-LYVNONC4.js";
17
+ } from "./chunk-FR2EDAQM.js";
17
18
 
18
19
  // src/core/capability-api.ts
19
20
  import { readFile } from "fs/promises";
@@ -1,3 +1,5 @@
1
+ import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
+
1
3
  // src/commands/sync/scanners.ts
2
4
  import { createHash } from "crypto";
3
5
  import { readdirSync, readFileSync as readFileSync2, statSync, lstatSync, existsSync as existsSync2, realpathSync } from "fs";
@@ -0,0 +1,191 @@
1
+ import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
+ import {
3
+ CapabilityGatewayError
4
+ } from "./chunk-GJXRF7Y6.js";
5
+ import {
6
+ clearCliToken,
7
+ getCliToken
8
+ } from "./chunk-RWXIXOZG.js";
9
+ import {
10
+ safeJsonParse
11
+ } from "./chunk-KZ6ZHF5J.js";
12
+ import {
13
+ PermissionError
14
+ } from "./chunk-533JK3YX.js";
15
+
16
+ // src/core/mcp-access.ts
17
+ function buildUrl(host, path, params = {}) {
18
+ const base = host.replace(/\/$/, "");
19
+ const p = path.startsWith("/") ? path : `/${path}`;
20
+ const url = new URL(`${base}${p}`);
21
+ for (const [key, value] of Object.entries(params)) {
22
+ if (value !== void 0 && value !== null) {
23
+ url.searchParams.set(key, String(value));
24
+ }
25
+ }
26
+ return url.toString();
27
+ }
28
+ var KbUnauthorizedError = class extends Error {
29
+ };
30
+ function optionalString(value) {
31
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
32
+ }
33
+ function responseReturnCode(data) {
34
+ const value = data?.return_code;
35
+ if (value === void 0 || value === null || value === 0 || value === "0") {
36
+ return void 0;
37
+ }
38
+ if (typeof value === "number" && Number.isFinite(value)) return String(value);
39
+ return optionalString(value);
40
+ }
41
+ function responseErrorMetadata(data) {
42
+ const nestedError = data?.error && typeof data.error === "object" ? data.error : void 0;
43
+ return {
44
+ code: optionalString(data?.errorCode) ?? optionalString(data?.error_code) ?? optionalString(data?.code) ?? optionalString(nestedError?.code) ?? responseReturnCode(data),
45
+ hint: optionalString(data?.hint) ?? optionalString(nestedError?.hint)
46
+ };
47
+ }
48
+ function responseErrorMessage(data) {
49
+ const nestedError = data?.error && typeof data.error === "object" ? data.error : void 0;
50
+ return optionalString(typeof data?.error === "string" ? data.error : void 0) ?? optionalString(nestedError?.message) ?? optionalString(data?.message) ?? optionalString(data?.return_message);
51
+ }
52
+ function responseStatus(resp) {
53
+ const statusText = optionalString(resp.statusText);
54
+ return statusText ? `${resp.status} ${statusText}` : String(resp.status);
55
+ }
56
+ function malformedResponseError(resp, detail) {
57
+ if (!resp.ok) {
58
+ return new Error(`KB API HTTP error: ${responseStatus(resp)} (${detail})`);
59
+ }
60
+ return new Error(
61
+ `KB API protocol error: HTTP ${responseStatus(resp)} (${detail})`
62
+ );
63
+ }
64
+ var KbHttpError = class extends CapabilityGatewayError {
65
+ constructor(message, code, status, hint) {
66
+ super(message, code, status, hint);
67
+ this.name = "Error";
68
+ }
69
+ };
70
+ function nonOkResponseError(resp, data, options) {
71
+ const metadata = responseErrorMetadata(data);
72
+ const serverMessage = responseErrorMessage(data);
73
+ const fallbackMessage = `KB API HTTP error: ${responseStatus(resp)}`;
74
+ const businessCode = options.preserveBusinessErrorCode && typeof data?.error === "string" && metadata.code ? metadata.code : void 0;
75
+ const message = businessCode ? `${businessCode}: ${serverMessage ?? fallbackMessage}` : serverMessage ?? fallbackMessage;
76
+ if (metadata.code || metadata.hint) {
77
+ return new KbHttpError(message, metadata.code, resp.status, metadata.hint);
78
+ }
79
+ return new Error(message);
80
+ }
81
+ function parseKbResponse(resp, text, options = {}) {
82
+ if (resp.status === 403) {
83
+ let msg = "Permission denied for this resource (HTTP 403)";
84
+ let metadata = {};
85
+ try {
86
+ const d = safeJsonParse(text);
87
+ const m = d && (typeof d.error === "string" ? d.error : d.error?.message || d.message);
88
+ if (m && typeof m === "string") msg = m;
89
+ if (options.preserveErrorMetadata) metadata = responseErrorMetadata(d);
90
+ } catch {
91
+ }
92
+ throw new PermissionError(msg, metadata.code, metadata.hint);
93
+ }
94
+ if (resp.status === 401) {
95
+ throw new KbUnauthorizedError(
96
+ `KB API token auth failed: HTTP ${resp.status} ${resp.statusText}`
97
+ );
98
+ }
99
+ if (!text.trim()) {
100
+ throw malformedResponseError(resp, "empty response body");
101
+ }
102
+ let data;
103
+ try {
104
+ data = safeJsonParse(text);
105
+ } catch {
106
+ throw malformedResponseError(resp, "non-JSON response");
107
+ }
108
+ if (data?.return_code === -1001) {
109
+ throw new KbUnauthorizedError(
110
+ `KB API token auth failed: ${data.return_message || "unauthorized"} (code: ${data.return_code})`
111
+ );
112
+ }
113
+ if (!resp.ok) {
114
+ throw nonOkResponseError(resp, data, options);
115
+ }
116
+ if (data?.return_code !== 0 && data?.return_code !== void 0) {
117
+ throw new Error(
118
+ `AE API error: ${data.return_message || "unknown"} (code: ${data.return_code})`
119
+ );
120
+ }
121
+ if (data && typeof data === "object" && typeof data.error === "string" && data.error.trim() && data.return_code === void 0 && data.success === void 0) {
122
+ if (options.preserveErrorMetadata) {
123
+ const metadata = responseErrorMetadata(data);
124
+ throw new CapabilityGatewayError(
125
+ data.error,
126
+ metadata.code,
127
+ resp.status,
128
+ metadata.hint
129
+ );
130
+ }
131
+ const businessCode = options.preserveBusinessErrorCode && typeof data.code === "string" && data.code.trim() ? data.code.trim() : "";
132
+ throw new Error(businessCode ? `${businessCode}: ${data.error}` : data.error);
133
+ }
134
+ return data?.data !== void 0 ? data.data : data;
135
+ }
136
+ async function fetchWithCliToken(input, init, cliToken, options = {}) {
137
+ const headers = new Headers(init.headers);
138
+ headers.set("cli-token", cliToken);
139
+ const resp = await fetch(input, { ...init, headers });
140
+ return parseKbResponse(resp, await resp.text(), options);
141
+ }
142
+ async function requestWithCliToken(host, input, init, options) {
143
+ const request = async () => fetchWithCliToken(input, init, await getCliToken(host), options);
144
+ try {
145
+ return await request();
146
+ } catch (error) {
147
+ if (!(error instanceof KbUnauthorizedError) || !options.retryUnauthorized) {
148
+ throw error;
149
+ }
150
+ clearCliToken(host);
151
+ return request();
152
+ }
153
+ }
154
+ async function getAuthHeaders(ctx) {
155
+ const cliToken = await getCliToken(ctx.host());
156
+ return { "cli-token": cliToken };
157
+ }
158
+ async function kbApi(ctx, method, path, params = {}, body, options = {}) {
159
+ const host = ctx.host();
160
+ const upperMethod = method.toUpperCase();
161
+ return requestWithCliToken(
162
+ host,
163
+ buildUrl(host, path, params),
164
+ {
165
+ method: upperMethod,
166
+ headers: {
167
+ "Content-Type": "application/json"
168
+ },
169
+ body: upperMethod === "GET" ? void 0 : JSON.stringify(body ?? {})
170
+ },
171
+ options
172
+ );
173
+ }
174
+ async function kbUpload(ctx, path, form, params = {}, options = {}) {
175
+ const host = ctx.host();
176
+ return requestWithCliToken(
177
+ host,
178
+ buildUrl(host, path, params),
179
+ {
180
+ method: "POST",
181
+ body: form
182
+ },
183
+ options
184
+ );
185
+ }
186
+
187
+ export {
188
+ getAuthHeaders,
189
+ kbApi,
190
+ kbUpload
191
+ };
@@ -1,16 +1,19 @@
1
+ import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
1
2
  import {
2
3
  peekCliToken
3
- } from "./chunk-4SGZG4XY.js";
4
+ } from "./chunk-RWXIXOZG.js";
5
+ import {
6
+ getToken
7
+ } from "./chunk-O6K2ODUE.js";
4
8
  import {
5
9
  getActiveHost,
6
10
  getConfigDir,
7
- getToken,
8
11
  isAeSandboxRuntime,
9
12
  normalizeUrl
10
- } from "./chunk-ZZUOD757.js";
13
+ } from "./chunk-KZ6ZHF5J.js";
11
14
  import {
12
15
  logger
13
- } from "./chunk-LYVNONC4.js";
16
+ } from "./chunk-FR2EDAQM.js";
14
17
 
15
18
  // src/core/version-sync.ts
16
19
  import { spawnSync } from "child_process";
@@ -84,6 +87,7 @@ var HISTORICAL_CLUSTER_TO_PUBLIC_PIN = {
84
87
 
85
88
  // src/core/version-compat.ts
86
89
  var OPEN_SOURCE_AE_CLI_PACKAGE = "@thinkingai/ae-cli";
90
+ var OPEN_SOURCE_NPM_REGISTRY = "https://registry.npmjs.org";
87
91
  var AE_CLI_SKILLS_REPO = "ThinkingAIAgenticEngine/ae-cli";
88
92
  var PUBLISHED_EXTERNAL_VERSIONS = /* @__PURE__ */ new Set([
89
93
  "1.0.15",
@@ -182,7 +186,7 @@ function formatPinCommands(expectedVersion) {
182
186
  const ver = resolvePinTarget(expectedVersion);
183
187
  if (!ver) return [];
184
188
  return [
185
- `npm i -g ${OPEN_SOURCE_AE_CLI_PACKAGE}@${ver}`,
189
+ `npm i -g ${OPEN_SOURCE_AE_CLI_PACKAGE}@${ver} --registry=${OPEN_SOURCE_NPM_REGISTRY}`,
186
190
  `npx skills add ${AE_CLI_SKILLS_REPO}#v${ver} -g -y`
187
191
  ];
188
192
  }
@@ -190,7 +194,7 @@ function formatUpgradeCommands(expectedVersion) {
190
194
  const ver = expectedVersion.trim().replace(/^v/i, "");
191
195
  if (!/^\d+\.\d+\.\d+(?:[-+].*)?$/.test(ver)) return [];
192
196
  return [
193
- `npm i -g ${OPEN_SOURCE_AE_CLI_PACKAGE}@${ver}`,
197
+ `npm i -g ${OPEN_SOURCE_AE_CLI_PACKAGE}@${ver} --registry=${OPEN_SOURCE_NPM_REGISTRY}`,
194
198
  `npx skills add ${AE_CLI_SKILLS_REPO}#v${ver} -g -y`
195
199
  ];
196
200
  }
@@ -353,7 +357,7 @@ function buildVersionInstallPlan(targetRaw, globalRoot = "<npm-root>") {
353
357
  return {
354
358
  target,
355
359
  commands: [
356
- `npm install -g ${OPEN_SOURCE_AE_CLI_PACKAGE}@${target}`,
360
+ `npm install -g ${OPEN_SOURCE_AE_CLI_PACKAGE}@${target} --registry=${OPEN_SOURCE_NPM_REGISTRY}`,
357
361
  `npx -y skills add ${localSkills} -g -y`,
358
362
  `npx -y skills add ${AE_CLI_SKILLS_REPO}#v${target} -g -y`
359
363
  ],
@@ -503,7 +507,13 @@ function installVersion(targetRaw, options = {}) {
503
507
  progress(`[ae-cli] [1/2] Installing ae-cli ${target}...`);
504
508
  const npmResult = runner(
505
509
  npm,
506
- ["install", "-g", `${OPEN_SOURCE_AE_CLI_PACKAGE}@${target}`],
510
+ [
511
+ "install",
512
+ "-g",
513
+ `${OPEN_SOURCE_AE_CLI_PACKAGE}@${target}`,
514
+ "--registry",
515
+ OPEN_SOURCE_NPM_REGISTRY
516
+ ],
507
517
  COMMAND_TIMEOUT_MS
508
518
  );
509
519
  if (!commandSucceeded(npmResult)) {
@@ -0,0 +1,294 @@
1
+ import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
+ import {
3
+ logger
4
+ } from "./chunk-FR2EDAQM.js";
5
+
6
+ // src/core/json-utils.ts
7
+ import fs from "fs";
8
+ import { createRequire } from "module";
9
+ var require2 = createRequire(import.meta.url);
10
+ var JSONbig = require2("json-bigint");
11
+ var jsonParser = JSONbig({ storeAsString: true });
12
+ var INTEGER_TOKEN = /^-?(?:0|[1-9]\d*)$/;
13
+ function normalizeParsedNumbers(lossless, native) {
14
+ if (typeof lossless === "string" && typeof native === "number") {
15
+ if (INTEGER_TOKEN.test(lossless) && !Number.isSafeInteger(native)) {
16
+ return lossless;
17
+ }
18
+ return native;
19
+ }
20
+ if (Array.isArray(lossless) && Array.isArray(native)) {
21
+ for (let index = 0; index < lossless.length; index++) {
22
+ lossless[index] = normalizeParsedNumbers(lossless[index], native[index]);
23
+ }
24
+ return lossless;
25
+ }
26
+ if (lossless !== null && native !== null && typeof lossless === "object" && typeof native === "object") {
27
+ for (const key of Object.keys(lossless)) {
28
+ lossless[key] = normalizeParsedNumbers(lossless[key], native[key]);
29
+ }
30
+ }
31
+ return lossless;
32
+ }
33
+ function safeJsonParse(text) {
34
+ const lossless = jsonParser.parse(text);
35
+ return normalizeParsedNumbers(lossless, JSON.parse(text));
36
+ }
37
+ function safeReadJsonFile(filePath) {
38
+ const content = fs.readFileSync(filePath, "utf-8");
39
+ return safeJsonParse(content);
40
+ }
41
+
42
+ // src/core/url-utils.ts
43
+ function normalizeUrl(url) {
44
+ if (!url) return url;
45
+ if (!url.startsWith("http://") && !url.startsWith("https://")) {
46
+ url = `https://${url}`;
47
+ }
48
+ return url.replace(/\/$/, "");
49
+ }
50
+
51
+ // src/core/config.ts
52
+ import fs3 from "fs";
53
+ import path from "path";
54
+
55
+ // src/core/sandbox-runtime.ts
56
+ import { homedir } from "os";
57
+ import { join } from "path";
58
+ import fs2 from "fs";
59
+ var LINUX_SANDBOX_RUNTIME_ROOT = "/home/ta/te_agent_ta";
60
+ function getDefaultSandboxRuntimeRoot() {
61
+ if (process.platform === "linux") {
62
+ return LINUX_SANDBOX_RUNTIME_ROOT;
63
+ }
64
+ return homedir();
65
+ }
66
+ function getSandboxRuntimeRoot() {
67
+ return process.env.SANDBOX_RUNTIME_ROOT || getDefaultSandboxRuntimeRoot();
68
+ }
69
+ function getSandboxAeConfigDir() {
70
+ return join(getSandboxRuntimeRoot(), ".ae-config");
71
+ }
72
+ function getSandboxCliTokenFilePath() {
73
+ return join(getSandboxAeConfigDir(), "cli-token.json");
74
+ }
75
+ function isAeSandboxRuntime() {
76
+ if (process.env.SANDBOX_RUNTIME_ROOT) {
77
+ return true;
78
+ }
79
+ try {
80
+ if (fs2.existsSync(getSandboxCliTokenFilePath())) {
81
+ return true;
82
+ }
83
+ } catch {
84
+ }
85
+ return false;
86
+ }
87
+
88
+ // src/core/config.ts
89
+ var CONFIG_DIR = path.join(process.env.HOME || "", ".ae-cli");
90
+ var CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
91
+ function sandboxCliTokenCandidatePaths() {
92
+ const paths = [getSandboxCliTokenFilePath()];
93
+ const homeFallback = path.join(process.env.HOME || "", ".ae-config", "cli-token.json");
94
+ if (!paths.includes(homeFallback)) {
95
+ paths.push(homeFallback);
96
+ }
97
+ return paths;
98
+ }
99
+ function readSandboxCliTokenEntry() {
100
+ for (const file of sandboxCliTokenCandidatePaths()) {
101
+ if (!fs3.existsSync(file)) continue;
102
+ try {
103
+ const data = safeReadJsonFile(file);
104
+ if (data && typeof data === "object" && !Array.isArray(data)) {
105
+ const url = data.url;
106
+ const token = data.token ?? data["cli-token"];
107
+ if (url && token) {
108
+ return { url, token };
109
+ }
110
+ }
111
+ } catch {
112
+ }
113
+ }
114
+ return null;
115
+ }
116
+ function forceMigrateFromFallback() {
117
+ const entry = readSandboxCliTokenEntry();
118
+ if (!entry) return null;
119
+ return { [entry.url]: entry.token };
120
+ }
121
+ function getFallbackCliToken(hostUrl) {
122
+ const store = forceMigrateFromFallback();
123
+ if (!store) return null;
124
+ if (hostUrl && store[hostUrl]) return store[hostUrl];
125
+ const entries = Object.values(store);
126
+ if (entries.length === 1) return entries[0];
127
+ return null;
128
+ }
129
+ function ensureDir() {
130
+ if (!fs3.existsSync(CONFIG_DIR)) fs3.mkdirSync(CONFIG_DIR, { recursive: true });
131
+ }
132
+ function dedupeNormalizedHosts(config) {
133
+ const hosts = {};
134
+ for (const [url, entry] of Object.entries(config.hosts)) {
135
+ const key = normalizeUrl(url);
136
+ if (!hosts[key]) {
137
+ hosts[key] = entry;
138
+ }
139
+ }
140
+ return {
141
+ activeHost: config.activeHost ? normalizeUrl(config.activeHost) : "",
142
+ hosts
143
+ };
144
+ }
145
+ function configNeedsNormalization(config) {
146
+ if (config.activeHost && normalizeUrl(config.activeHost) !== config.activeHost) return true;
147
+ const keys = Object.keys(config.hosts);
148
+ if (keys.some((url) => normalizeUrl(url) !== url)) return true;
149
+ return new Set(keys.map(normalizeUrl)).size !== keys.length;
150
+ }
151
+ function loadConfig() {
152
+ try {
153
+ if (fs3.existsSync(CONFIG_FILE)) {
154
+ const raw = safeReadJsonFile(CONFIG_FILE);
155
+ if (raw.defaultHost && !raw.activeHost) {
156
+ const migrated = dedupeNormalizedHosts(migrateConfig(raw));
157
+ saveConfig(migrated);
158
+ return migrated;
159
+ }
160
+ const rawConfig = raw;
161
+ if (configNeedsNormalization(rawConfig)) {
162
+ const config = dedupeNormalizedHosts(rawConfig);
163
+ saveConfig(config);
164
+ return config;
165
+ }
166
+ return rawConfig;
167
+ }
168
+ } catch (err) {
169
+ logger.error(`Error loading config: ${err.message}`);
170
+ console.error(`Error loading config: ${err.message}`);
171
+ }
172
+ return { activeHost: "", hosts: {} };
173
+ }
174
+ function migrateConfig(old) {
175
+ const hosts = {};
176
+ const oldHost = old.defaultHost;
177
+ if (old.hosts) {
178
+ for (const [key, val] of Object.entries(old.hosts)) {
179
+ const url = normalizeUrl(key.startsWith("http") ? key : `https://${key}`);
180
+ hosts[url] = val;
181
+ }
182
+ }
183
+ const activeHost = normalizeUrl(oldHost.startsWith("http") ? oldHost : `https://${oldHost}`);
184
+ if (!hosts[activeHost]) {
185
+ hosts[activeHost] = { label: "default" };
186
+ }
187
+ return { activeHost, hosts };
188
+ }
189
+ function saveConfig(config) {
190
+ ensureDir();
191
+ fs3.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
192
+ logger.info(`Config saved: activeHost=${config.activeHost}, hosts=${Object.keys(config.hosts).length}`);
193
+ }
194
+ function getActiveHost() {
195
+ const sandboxHost = readSandboxCliTokenEntry()?.url;
196
+ if (sandboxHost) return sandboxHost;
197
+ const config = loadConfig();
198
+ return config.activeHost || "";
199
+ }
200
+ function setActiveHost(url) {
201
+ url = normalizeUrl(url);
202
+ const config = loadConfig();
203
+ if (!config.hosts[url]) {
204
+ throw new Error(`Host ${url} is not in the configured hosts list. Add it first.`);
205
+ }
206
+ config.activeHost = url;
207
+ saveConfig(config);
208
+ }
209
+ function addHost(url, label) {
210
+ url = normalizeUrl(url);
211
+ label = normalizeLabel(label);
212
+ const config = loadConfig();
213
+ assertUniqueHostLabel(config, label, url);
214
+ config.hosts[url] = { label };
215
+ if (!config.activeHost) {
216
+ config.activeHost = url;
217
+ }
218
+ saveConfig(config);
219
+ }
220
+ function updateHostLabel(url, label) {
221
+ url = normalizeUrl(url);
222
+ label = normalizeLabel(label);
223
+ const config = loadConfig();
224
+ if (!config.hosts[url]) {
225
+ throw new Error(`Host is not configured: ${url}`);
226
+ }
227
+ assertUniqueHostLabel(config, label, url);
228
+ config.hosts[url].label = label;
229
+ saveConfig(config);
230
+ }
231
+ function normalizeLabel(label) {
232
+ const normalized = label.trim();
233
+ if (!normalized) {
234
+ throw new Error("Label cannot be empty.");
235
+ }
236
+ return normalized;
237
+ }
238
+ function assertUniqueHostLabel(config, label, excludeUrl) {
239
+ const duplicate = Object.entries(config.hosts).find(([url, entry]) => url !== excludeUrl && entry.label === label);
240
+ if (duplicate) {
241
+ throw new Error(`Label already exists: ${label}. Rename the existing label first: ${duplicate[0]}`);
242
+ }
243
+ }
244
+ function removeHost(url) {
245
+ url = normalizeUrl(url);
246
+ const config = loadConfig();
247
+ delete config.hosts[url];
248
+ if (config.activeHost === url) {
249
+ const remaining = Object.keys(config.hosts);
250
+ config.activeHost = remaining.length > 0 ? remaining[0] : "";
251
+ }
252
+ saveConfig(config);
253
+ }
254
+ function listHosts() {
255
+ const config = loadConfig();
256
+ return Object.entries(config.hosts).map(([url, entry]) => ({
257
+ url,
258
+ label: entry.label,
259
+ active: url === config.activeHost
260
+ }));
261
+ }
262
+ function resolveHostSelector(env) {
263
+ const raw = env.trim();
264
+ const selector = raw.startsWith("http://") || raw.startsWith("https://") ? normalizeUrl(raw) : raw;
265
+ const hosts = listHosts();
266
+ const byUrl = hosts.find((host) => host.url === selector);
267
+ if (byUrl) return { status: "found", host: byUrl };
268
+ const byLabel = hosts.filter((host) => host.label === raw);
269
+ if (byLabel.length === 1) return { status: "found", host: byLabel[0] };
270
+ if (byLabel.length > 1) return { status: "duplicate-label", matches: byLabel };
271
+ return { status: "not-found", hosts };
272
+ }
273
+ function getConfigDir() {
274
+ return CONFIG_DIR;
275
+ }
276
+
277
+ export {
278
+ safeJsonParse,
279
+ safeReadJsonFile,
280
+ normalizeUrl,
281
+ getSandboxRuntimeRoot,
282
+ isAeSandboxRuntime,
283
+ getFallbackCliToken,
284
+ loadConfig,
285
+ saveConfig,
286
+ getActiveHost,
287
+ setActiveHost,
288
+ addHost,
289
+ updateHostLabel,
290
+ removeHost,
291
+ listHosts,
292
+ resolveHostSelector,
293
+ getConfigDir
294
+ };