@thinkingai/ae-cli 6.0.48-customer.1 → 6.0.48-workbuddy

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 (80) hide show
  1. package/README.md +93 -36
  2. package/README.zh.md +93 -36
  3. package/assets/workbuddy-host-page/thinkingai.png +0 -0
  4. package/assets/workbuddy-host-page/workbuddy.png +0 -0
  5. package/bin/ae-cli-workbuddy.js +7 -0
  6. package/dist/auth-HJG2L6DR.js +910 -0
  7. package/dist/{capability-RUSV77CO.js → capability-JHYVQNQ4.js} +47 -34
  8. package/dist/chunk-2BDQB42E.js +15 -0
  9. package/dist/{chunk-GJXRF7Y6.js → chunk-6MXFJVNP.js} +47 -78
  10. package/dist/chunk-6ZIQV5GW.js +26 -0
  11. package/dist/{chunk-KZ6ZHF5J.js → chunk-ARTIHWVD.js} +27 -25
  12. package/dist/{chunk-6QK7SYYY.js → chunk-DU5MZQFQ.js} +29 -37
  13. package/dist/{chunk-BVDST5YT.js → chunk-JFOGWBAT.js} +8 -8
  14. package/dist/{chunk-JYMGHGCE.js → chunk-KSQGGXGA.js} +24 -13
  15. package/dist/{chunk-FR2EDAQM.js → chunk-NXRKDG6E.js} +89 -3
  16. package/dist/{chunk-NSIVXKJH.js → chunk-QSO4SA6C.js} +5 -5
  17. package/dist/{chunk-BE73PUFX.js → chunk-QYJ252CT.js} +2 -2
  18. package/dist/{chunk-B5HMQAOM.js → chunk-UL6SJDYE.js} +1 -1
  19. package/dist/chunk-Y3S2KNNR.js +623 -0
  20. package/dist/{chunk-KEWVSO64.js → chunk-ZCM47ROU.js} +5 -16
  21. package/dist/{community-report-client-6OL6GBQW.js → community-report-client-QE4RC2XG.js} +2 -4
  22. package/dist/{config-XNMACCKX.js → config-XMRP5NDA.js} +8 -9
  23. package/dist/{data-integration-FZQQC3KW.js → data-integration-SGRITHJS.js} +9 -12
  24. package/dist/index.js +53 -80
  25. package/dist/{local-data-upload-client-EFHDLXFG.js → local-data-upload-client-LMVS7YAR.js} +2 -4
  26. package/dist/{memory-HBJQ2GC5.js → memory-5ZC73XBC.js} +4 -6
  27. package/dist/{metadata-PGDJE5RQ.js → metadata-LBX6O24P.js} +7 -9
  28. package/dist/{model-BHLJ2QMT.js → model-CRDIVYN5.js} +4 -6
  29. package/dist/{personal-semantic-preference-E5NZ56DN.js → personal-semantic-preference-7FVUTJZF.js} +6 -8
  30. package/dist/{sync-MUWPRM5I.js → sync-VVNDHU7R.js} +9 -11
  31. package/dist/{te-agent-WQZTMEK4.js → te-agent-4T5TFHD6.js} +393 -90
  32. package/dist/{te-analysis-YWCSSLYL.js → te-analysis-TPYFOIFD.js} +97 -31
  33. package/dist/{te-community-BNE6KREL.js → te-community-PWOTHSEC.js} +9 -32
  34. package/dist/{te-dataops-TXLKM2W6.js → te-dataops-ZJV5QVJU.js} +19 -20
  35. package/dist/{te-engage-VEW4CJHK.js → te-engage-WVHBZAXH.js} +11 -13
  36. package/dist/{te-kb-BUD6N3NI.js → te-kb-PNM2ZKBP.js} +595 -85
  37. package/dist/{te-system-44LZJDTQ.js → te-system-MRCMLAWW.js} +6 -8
  38. package/dist/{te-team-XMP47YXE.js → te-team-Y36TG6AQ.js} +6 -8
  39. package/dist/{update-UODFOZ4P.js → update-UNKCZ5U5.js} +7 -8
  40. package/package.json +15 -10
  41. package/skills/ae-agent/SKILL.md +30 -13
  42. package/skills/ae-agent/references/agent-distribution.md +94 -0
  43. package/skills/ae-agent/references/approval-request.md +4 -0
  44. package/skills/ae-agent/references/command_index.md +9 -2
  45. package/skills/ae-agent/references/create-automation.md +20 -2
  46. package/skills/ae-agent/references/get-agent-context.md +70 -0
  47. package/skills/ae-agent/references/list-automations.md +18 -3
  48. package/skills/ae-agent/references/list-mcp-credentials.md +1 -1
  49. package/skills/ae-agent/references/mcp-token.md +3 -3
  50. package/skills/ae-agent/references/set-mcp-credential.md +0 -1
  51. package/skills/ae-agent/references/update-automation.md +18 -0
  52. package/skills/ae-analysis/SKILL.md +11 -2
  53. package/skills/ae-analysis/references/adhoc_run.md +2 -0
  54. package/skills/ae-analysis/references/ai_models.md +23 -3
  55. package/skills/ae-analysis/references/analysis_gateway_assets.md +2 -2
  56. package/skills/ae-analysis/references/command_index.md +7 -7
  57. package/skills/ae-analysis/references/cross_source_config.md +84 -0
  58. package/skills/ae-analysis/references/dashboard_update.md +1 -1
  59. package/skills/ae-analysis/references/user_tag_create.md +23 -1
  60. package/skills/ae-analysis/references/user_tag_models.md +9 -1
  61. package/skills/ae-analysis/references/user_tag_update.md +14 -2
  62. package/skills/ae-data-integration/SKILL.md +2 -1
  63. package/skills/ae-data-integration/references/dimension-routing.md +36 -0
  64. package/skills/ae-data-integration/references/local-analysis.md +2 -0
  65. package/skills/ae-data-integration/references/source-inspect.md +1 -1
  66. package/skills/ae-data-integration/references/ue-routing.md +17 -1
  67. package/skills/ae-generate-tracking-plan/SKILL.md +16 -5
  68. package/skills/ae-kb/SKILL.md +107 -36
  69. package/skills/ae-kb/references/query-workflow.md +59 -29
  70. package/skills/ae-kb/references/versions.md +46 -0
  71. package/skills/ae-system/SKILL.md +1 -1
  72. package/skills/ae-use-agent/SKILL.md +42 -0
  73. package/skills/ae-use-agent/references/local-agent.md +114 -0
  74. package/dist/auth-QPEVVBKT.js +0 -465
  75. package/dist/auth-UMJAA72O.js +0 -15
  76. package/dist/chunk-533JK3YX.js +0 -72
  77. package/dist/chunk-O6K2ODUE.js +0 -318
  78. package/dist/chunk-RWXIXOZG.js +0 -326
  79. package/dist/client-N7NGZUNI.js +0 -204
  80. package/skills/ae-agent/references/auto-provision-mcp-credentials.md +0 -57
@@ -3,36 +3,38 @@ import {
3
3
  normalizeRiskLevel,
4
4
  requiresConfirmation
5
5
  } from "./chunk-AMBFK2K3.js";
6
- import {
7
- printError,
8
- printOutput
9
- } from "./chunk-KEWVSO64.js";
10
- import {
11
- CapabilityGatewayError,
12
- dryRunCapability,
13
- executeCapability,
14
- inspectCapability,
15
- listCapabilities,
16
- validateCapability
17
- } from "./chunk-GJXRF7Y6.js";
18
6
  import {
19
7
  findGatewayDomain,
20
8
  listRegisteredCapabilityDomains,
21
9
  resolveGatewayDomain
22
10
  } from "./chunk-TKHSULJT.js";
23
- import "./chunk-Y74WTIKJ.js";
24
- import "./chunk-RWXIXOZG.js";
25
11
  import {
26
- SecureStoreAuthError,
27
12
  resolveHost
28
- } from "./chunk-O6K2ODUE.js";
13
+ } from "./chunk-2BDQB42E.js";
14
+ import {
15
+ CapabilityGatewayError,
16
+ dryRunCapabilityWithEnvelope,
17
+ executeCapabilityWithEnvelope,
18
+ inspectCapability,
19
+ inspectCapabilityWithEnvelope,
20
+ listCapabilitiesWithEnvelope,
21
+ validateCapabilityWithEnvelope
22
+ } from "./chunk-6MXFJVNP.js";
23
+ import {
24
+ printError,
25
+ printOutput,
26
+ withOutputMetadata
27
+ } from "./chunk-ZCM47ROU.js";
28
+ import "./chunk-Y74WTIKJ.js";
29
+ import {
30
+ SecureStoreAuthError
31
+ } from "./chunk-Y3S2KNNR.js";
29
32
  import {
30
33
  safeJsonParse
31
- } from "./chunk-KZ6ZHF5J.js";
34
+ } from "./chunk-ARTIHWVD.js";
32
35
  import {
33
36
  PermissionError
34
- } from "./chunk-533JK3YX.js";
35
- import "./chunk-FR2EDAQM.js";
37
+ } from "./chunk-NXRKDG6E.js";
36
38
 
37
39
  // src/commands/capability/index.ts
38
40
  import * as readline from "readline";
@@ -178,15 +180,16 @@ function registerCapability(program) {
178
180
  await executeAndPrint(program, async (host) => {
179
181
  const gatewayDomain = resolveCapabilityListDomain(opts.domain);
180
182
  const projectId = parseOptionalProjectId(opts.projectId);
181
- const catalog = normalizeCapabilityList(await listCapabilities(host, gatewayDomain, projectId));
183
+ const envelope = await listCapabilitiesWithEnvelope(host, gatewayDomain, projectId);
184
+ const catalog = normalizeCapabilityList(envelope.data);
182
185
  const capabilities = filterCapabilities(catalog, opts.domain);
183
186
  const warning = emptyCapabilityCatalogWarning(catalog);
184
- return {
187
+ return withOutputMetadata({
185
188
  domain: opts.domain,
186
189
  count: capabilities.length,
187
190
  capabilities,
188
191
  ...warning ? { warning } : {}
189
- };
192
+ }, envelope.meta);
190
193
  });
191
194
  }).addHelpText(
192
195
  "after",
@@ -196,16 +199,17 @@ function registerCapability(program) {
196
199
  await executeAndPrint(program, async (host) => {
197
200
  const gatewayDomain = resolveCapabilityListDomain(opts.domain);
198
201
  const projectId = parseOptionalProjectId(opts.projectId);
199
- const catalog = normalizeCapabilityList(await listCapabilities(host, gatewayDomain, projectId));
202
+ const envelope = await listCapabilitiesWithEnvelope(host, gatewayDomain, projectId);
203
+ const catalog = normalizeCapabilityList(envelope.data);
200
204
  const capabilities = filterCapabilities(catalog, opts.domain, query);
201
205
  const warning = emptyCapabilityCatalogWarning(catalog);
202
- return {
206
+ return withOutputMetadata({
203
207
  domain: opts.domain,
204
208
  query,
205
209
  count: capabilities.length,
206
210
  capabilities,
207
211
  ...warning ? { warning } : {}
208
- };
212
+ }, envelope.meta);
209
213
  });
210
214
  }).addHelpText(
211
215
  "after",
@@ -214,7 +218,7 @@ function registerCapability(program) {
214
218
  capability.command("inspect").description("Inspect one capability schema, risk, auth, and output metadata").argument("<capability-id>", "Capability ID, such as analysis.report.list").option("--domain <domain>", "Override the capability namespace used for gateway routing").option("--project-id <project-id>", "Check availability in a project before returning metadata").action(async (capabilityId, opts) => {
215
219
  await executeAndPrint(program, async (host) => {
216
220
  const gatewayDomain = resolveCapabilityGatewayDomain(capabilityId, opts.domain);
217
- return inspectCapability(host, gatewayDomain, capabilityId, parseOptionalProjectId(opts.projectId));
221
+ return gatewayOutput(await inspectCapabilityWithEnvelope(host, gatewayDomain, capabilityId, parseOptionalProjectId(opts.projectId)), host);
218
222
  });
219
223
  }).addHelpText(
220
224
  "after",
@@ -225,7 +229,7 @@ function registerCapability(program) {
225
229
  ).argument("<capability-id>", "Capability ID, such as metadata.data_table.sql_write").option("--domain <domain>", "Override the capability namespace used for gateway routing").option("--input <json-or-path>", "Input JSON object, file path, @<path>, or - for stdin").action(async (capabilityId, opts) => {
226
230
  await executeAndPrint(program, async (host) => {
227
231
  const gatewayDomain = resolveCapabilityGatewayDomain(capabilityId, opts.domain);
228
- return validateCapability(host, gatewayDomain, capabilityId, parseCapabilityInput(opts.input));
232
+ return gatewayOutput(await validateCapabilityWithEnvelope(host, gatewayDomain, capabilityId, parseCapabilityInput(opts.input)), host);
229
233
  });
230
234
  }).addHelpText(
231
235
  "after",
@@ -247,7 +251,7 @@ Examples:
247
251
  ).argument("<capability-id>", "Capability ID, such as analysis.query.export").option("--domain <domain>", "Override the capability namespace used for gateway routing").option("--input <json-or-path>", "Input JSON object, file path, @<path>, or - for stdin").action(async (capabilityId, opts) => {
248
252
  await executeAndPrint(program, async (host) => {
249
253
  const gatewayDomain = resolveCapabilityGatewayDomain(capabilityId, opts.domain);
250
- return dryRunCapability(host, gatewayDomain, capabilityId, parseCapabilityInput(opts.input));
254
+ return gatewayOutput(await dryRunCapabilityWithEnvelope(host, gatewayDomain, capabilityId, parseCapabilityInput(opts.input)), host);
251
255
  });
252
256
  }).addHelpText(
253
257
  "after",
@@ -267,10 +271,10 @@ Examples:
267
271
  );
268
272
  }
269
273
  if (globalOpts.validate) {
270
- return validateCapability(host, gatewayDomain, capabilityId, input);
274
+ return gatewayOutput(await validateCapabilityWithEnvelope(host, gatewayDomain, capabilityId, input), host);
271
275
  }
272
276
  if (globalOpts.dryRun) {
273
- return dryRunCapability(host, gatewayDomain, capabilityId, input);
277
+ return gatewayOutput(await dryRunCapabilityWithEnvelope(host, gatewayDomain, capabilityId, input), host);
274
278
  }
275
279
  if (!globalOpts.yes) {
276
280
  const metadata = await inspectCapability(host, gatewayDomain, capabilityId);
@@ -283,7 +287,7 @@ Examples:
283
287
  }
284
288
  }
285
289
  }
286
- return executeCapability(host, gatewayDomain, capabilityId, input);
290
+ return gatewayOutput(await executeCapabilityWithEnvelope(host, gatewayDomain, capabilityId, input), host);
287
291
  });
288
292
  }).addHelpText(
289
293
  "after",
@@ -293,6 +297,15 @@ Examples:
293
297
  ae-cli capability run analysis.dashboard.list --input input.json`
294
298
  );
295
299
  }
300
+ function gatewayOutput(envelope, host) {
301
+ return withOutputMetadata(withPageUrl(envelope.data, host), envelope.meta);
302
+ }
303
+ function withPageUrl(value, host) {
304
+ if (!value || typeof value !== "object" || Array.isArray(value)) return value;
305
+ const record = value;
306
+ if (typeof record.page_path !== "string" || !/^\/(?![\\/])/.test(record.page_path) || record.page_url !== void 0) return value;
307
+ return { ...record, page_url: new URL(record.page_path, host).toString() };
308
+ }
296
309
  async function executeAndPrint(program, action) {
297
310
  const globalOpts = program.opts();
298
311
  const host = resolveHost(globalOpts.host);
@@ -312,11 +325,11 @@ async function executeAndPrint(program, action) {
312
325
  process.exitCode = 1;
313
326
  return;
314
327
  }
315
- printCapabilityError(error);
328
+ printCapabilityError(error, host);
316
329
  process.exitCode = 1;
317
330
  }
318
331
  }
319
- function printCapabilityError(error) {
332
+ function printCapabilityError(error, host) {
320
333
  if (error instanceof CapabilityCommandValidationError) {
321
334
  printError("validation", error.message, error.hint, error.code);
322
335
  return;
@@ -330,7 +343,7 @@ function printCapabilityError(error) {
330
343
  return;
331
344
  }
332
345
  if (error instanceof CapabilityGatewayError) {
333
- printError("api", error.message, error.hint, error.code);
346
+ printError("api", error.message, error.hint, error.code, withPageUrl(error.meta, host));
334
347
  return;
335
348
  }
336
349
  const message = error instanceof Error ? error.message : String(error);
@@ -0,0 +1,15 @@
1
+ import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
+ import {
3
+ getActiveHost,
4
+ normalizeUrl
5
+ } from "./chunk-ARTIHWVD.js";
6
+
7
+ // src/core/auth.ts
8
+ function resolveHost(hostOverride) {
9
+ if (hostOverride) return normalizeUrl(hostOverride);
10
+ return getActiveHost();
11
+ }
12
+
13
+ export {
14
+ resolveHost
15
+ };
@@ -3,18 +3,15 @@ import {
3
3
  internalCallSourceHeaders
4
4
  } from "./chunk-Y74WTIKJ.js";
5
5
  import {
6
- clearCliToken,
6
+ SecureStoreAuthError,
7
7
  getCliToken
8
- } from "./chunk-RWXIXOZG.js";
8
+ } from "./chunk-Y3S2KNNR.js";
9
9
  import {
10
10
  safeJsonParse
11
- } from "./chunk-KZ6ZHF5J.js";
11
+ } from "./chunk-ARTIHWVD.js";
12
12
  import {
13
13
  PermissionError
14
- } from "./chunk-533JK3YX.js";
15
- import {
16
- logger
17
- } from "./chunk-FR2EDAQM.js";
14
+ } from "./chunk-NXRKDG6E.js";
18
15
 
19
16
  // src/core/capability-api.ts
20
17
  import { readFile } from "fs/promises";
@@ -135,7 +132,13 @@ function buildCapabilityHttpError(resp, body) {
135
132
  }
136
133
  async function throwCapabilityHttpError(resp) {
137
134
  const body = parseCapabilityResponse(await resp.text());
138
- throw buildCapabilityHttpError(resp, body);
135
+ const error = buildCapabilityHttpError(resp, body);
136
+ if (resp.status === 401) {
137
+ throw new SecureStoreAuthError(
138
+ `${error.message}. The stored CLI token is invalid or expired; run: ae-cli auth login`
139
+ );
140
+ }
141
+ throw error;
139
142
  }
140
143
  async function requestOnce(url, method, token, body, accept = "application/json") {
141
144
  const headers = {
@@ -167,45 +170,17 @@ async function callGateway(host, domain, pathAfterV1, method, body, queryParams
167
170
  async function callGatewayWithEnvelope(host, domain, pathAfterV1, method, body, queryParams = {}, options = {}) {
168
171
  const url = buildCapabilityGatewayUrl(options.apiBaseUrl ?? host, domain, pathAfterV1, queryParams);
169
172
  const token = await getCliToken(host);
170
- let resp = await requestOnce(url, method, token, body);
171
- let permissionMsg;
173
+ const resp = await requestOnce(url, method, token, body);
172
174
  if (resp.status === 403) {
173
175
  const error = await permissionError(resp);
174
- permissionMsg = error.message;
175
- if (options.retryOnInvalidTokenForbidden === false || !isInvalidCliTokenMessage(permissionMsg)) {
176
- throw error;
176
+ if (options.retryOnInvalidTokenForbidden !== false && isInvalidCliTokenMessage(error.message)) {
177
+ throw new SecureStoreAuthError(
178
+ `${error.message} Run: ae-cli auth login`
179
+ );
177
180
  }
181
+ throw error;
178
182
  }
179
- if (resp.status === 401) {
180
- if (options.retryOnUnauthorized === false) {
181
- await throwCapabilityHttpError(resp);
182
- }
183
- logger.warn(`Capability gateway request failed (HTTP 401) for ${host}, refreshing CLI token`);
184
- clearCliToken(host);
185
- const newToken = await getCliToken(host);
186
- process.stderr.write(`[ae-cli] CLI token refreshed for ${host}
187
- `);
188
- resp = await requestOnce(url, method, newToken, body);
189
- if (resp.status === 403) {
190
- throw new PermissionError(await permissionMessage(resp));
191
- }
192
- if (!resp.ok) {
193
- await throwCapabilityHttpError(resp);
194
- }
195
- } else if (resp.status === 403 && permissionMsg) {
196
- logger.warn(`Capability gateway request failed (${permissionMsg}) for ${host}, refreshing CLI token`);
197
- clearCliToken(host);
198
- const newToken = await getCliToken(host);
199
- process.stderr.write(`[ae-cli] CLI token refreshed for ${host}
200
- `);
201
- resp = await requestOnce(url, method, newToken, body);
202
- if (resp.status === 403) {
203
- throw await permissionError(resp);
204
- }
205
- if (!resp.ok) {
206
- await throwCapabilityHttpError(resp);
207
- }
208
- } else if (!resp.ok) {
183
+ if (!resp.ok) {
209
184
  await throwCapabilityHttpError(resp);
210
185
  }
211
186
  return parseCapabilityEnvelope(parseCapabilityResponse(await resp.text()));
@@ -213,24 +188,15 @@ async function callGatewayWithEnvelope(host, domain, pathAfterV1, method, body,
213
188
  async function fetchCapabilityGateway(host, domain, pathAfterV1, method = "GET", body, accept = "application/json") {
214
189
  const url = buildCapabilityGatewayUrl(host, domain, pathAfterV1);
215
190
  const token = await getCliToken(host);
216
- let resp = await requestOnce(url, method, token, body, accept);
191
+ const resp = await requestOnce(url, method, token, body, accept);
217
192
  if (resp.status === 403) {
218
- throw await permissionError(resp);
219
- }
220
- if (resp.status === 401) {
221
- logger.warn(`Capability gateway request failed (HTTP 401) for ${host}, refreshing CLI token`);
222
- clearCliToken(host);
223
- const newToken = await getCliToken(host);
224
- process.stderr.write(`[ae-cli] CLI token refreshed for ${host}
225
- `);
226
- resp = await requestOnce(url, method, newToken, body, accept);
227
- if (resp.status === 403) {
228
- throw await permissionError(resp);
229
- }
230
- if (!resp.ok) {
231
- await throwCapabilityHttpError(resp);
193
+ const error = await permissionError(resp);
194
+ if (isInvalidCliTokenMessage(error.message)) {
195
+ throw new SecureStoreAuthError(`${error.message} Run: ae-cli auth login`);
232
196
  }
233
- } else if (!resp.ok) {
197
+ throw error;
198
+ }
199
+ if (!resp.ok) {
234
200
  await throwCapabilityHttpError(resp);
235
201
  }
236
202
  return resp;
@@ -243,8 +209,11 @@ async function requestCapabilityGatewayWithEnvelope(host, domain, pathAfterV1, m
243
209
  const resp = await fetchCapabilityGateway(host, domain, pathAfterV1, method, body);
244
210
  return parseCapabilityEnvelope(parseCapabilityResponse(await resp.text()));
245
211
  }
246
- async function listCapabilities(host, domain, projectId) {
247
- return callGateway(host, domain, "capabilities", "GET", void 0, { project_id: projectId });
212
+ async function listCapabilitiesWithEnvelope(host, domain, projectId) {
213
+ return callGatewayWithEnvelope(host, domain, "capabilities", "GET", void 0, { project_id: projectId });
214
+ }
215
+ async function inspectCapabilityWithEnvelope(host, domain, capabilityId, projectId) {
216
+ return callGatewayWithEnvelope(host, domain, `capabilities/${capabilityId}`, "GET", void 0, { project_id: projectId });
248
217
  }
249
218
  async function inspectCapability(host, domain, capabilityId, projectId) {
250
219
  return callGateway(
@@ -265,6 +234,12 @@ async function executeCapabilityWithEnvelope(host, domain, capabilityId, input =
265
234
  async function dryRunCapability(host, domain, capabilityId, input = {}) {
266
235
  return callGateway(host, domain, `capabilities/${capabilityId}/dry-run`, "POST", { input });
267
236
  }
237
+ async function dryRunCapabilityWithEnvelope(host, domain, capabilityId, input = {}) {
238
+ return callGatewayWithEnvelope(host, domain, `capabilities/${capabilityId}/dry-run`, "POST", { input });
239
+ }
240
+ async function validateCapabilityWithEnvelope(host, domain, capabilityId, input = {}) {
241
+ return callGatewayWithEnvelope(host, domain, `capabilities/${capabilityId}/validate`, "POST", { input });
242
+ }
268
243
  async function validateCapability(host, domain, capabilityId, input = {}) {
269
244
  return callGateway(host, domain, `capabilities/${capabilityId}/validate`, "POST", { input });
270
245
  }
@@ -302,24 +277,15 @@ async function uploadInputFileBytes(host, domain, projectId, purpose, bytes, fil
302
277
  form.append("purpose", purpose);
303
278
  form.append("file", new Blob([fileBuffer], { type: contentType }), filename);
304
279
  const token = await getCliToken(host);
305
- let resp = await requestMultipartOnce(url, token, form);
280
+ const resp = await requestMultipartOnce(url, token, form);
306
281
  if (resp.status === 403) {
307
- throw await permissionError(resp);
308
- }
309
- if (resp.status === 401) {
310
- logger.warn(`Capability gateway request failed (HTTP 401) for ${host}, refreshing CLI token`);
311
- clearCliToken(host);
312
- const newToken = await getCliToken(host);
313
- process.stderr.write(`[ae-cli] CLI token refreshed for ${host}
314
- `);
315
- resp = await requestMultipartOnce(url, newToken, form);
316
- if (resp.status === 403) {
317
- throw await permissionError(resp);
318
- }
319
- if (!resp.ok) {
320
- await throwCapabilityHttpError(resp);
282
+ const error = await permissionError(resp);
283
+ if (isInvalidCliTokenMessage(error.message)) {
284
+ throw new SecureStoreAuthError(`${error.message} Run: ae-cli auth login`);
321
285
  }
322
- } else if (!resp.ok) {
286
+ throw error;
287
+ }
288
+ if (!resp.ok) {
323
289
  await throwCapabilityHttpError(resp);
324
290
  }
325
291
  return unwrapCapabilityEnvelope(parseCapabilityResponse(await resp.text()));
@@ -338,11 +304,14 @@ export {
338
304
  fetchCapabilityGateway,
339
305
  requestCapabilityGateway,
340
306
  requestCapabilityGatewayWithEnvelope,
341
- listCapabilities,
307
+ listCapabilitiesWithEnvelope,
308
+ inspectCapabilityWithEnvelope,
342
309
  inspectCapability,
343
310
  executeCapability,
344
311
  executeCapabilityWithEnvelope,
345
312
  dryRunCapability,
313
+ dryRunCapabilityWithEnvelope,
314
+ validateCapabilityWithEnvelope,
346
315
  validateCapability,
347
316
  uploadInputFile,
348
317
  uploadInputFileBytes,
@@ -0,0 +1,26 @@
1
+ import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
+
3
+ // src/core/host-guidance.ts
4
+ var AE_TRIAL_URL = "https://thinkingai.cn/request-demo";
5
+ var AE_HOST_SETUP_COMMAND = "ae-cli config set-host <url>";
6
+ function missingAeHostHint(additionalAction) {
7
+ const actions = [
8
+ `If your organization already uses AgenticEngine, ask your administrator for its AE URL, then run: ${AE_HOST_SETUP_COMMAND}.`,
9
+ `If you do not have an AgenticEngine environment, request a trial: ${AE_TRIAL_URL}`
10
+ ];
11
+ if (additionalAction) actions.push(additionalAction);
12
+ return actions.join(" ");
13
+ }
14
+ function missingAeHostGuidance() {
15
+ return {
16
+ configure_host: AE_HOST_SETUP_COMMAND,
17
+ existing_customer: "Ask your AgenticEngine administrator for the AE environment URL.",
18
+ request_trial_url: AE_TRIAL_URL
19
+ };
20
+ }
21
+
22
+ export {
23
+ AE_TRIAL_URL,
24
+ missingAeHostHint,
25
+ missingAeHostGuidance
26
+ };
@@ -1,7 +1,22 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
+ getConfigDir,
4
+ hasConfigDirOverride,
3
5
  logger
4
- } from "./chunk-FR2EDAQM.js";
6
+ } from "./chunk-NXRKDG6E.js";
7
+
8
+ // src/core/url-utils.ts
9
+ function normalizeUrl(url) {
10
+ if (!url) return url;
11
+ if (!url.startsWith("http://") && !url.startsWith("https://")) {
12
+ url = `https://${url}`;
13
+ }
14
+ return url.replace(/\/$/, "");
15
+ }
16
+
17
+ // src/core/config.ts
18
+ import fs3 from "fs";
19
+ import path from "path";
5
20
 
6
21
  // src/core/json-utils.ts
7
22
  import fs from "fs";
@@ -39,19 +54,6 @@ function safeReadJsonFile(filePath) {
39
54
  return safeJsonParse(content);
40
55
  }
41
56
 
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
57
  // src/core/sandbox-runtime.ts
56
58
  import { homedir } from "os";
57
59
  import { join } from "path";
@@ -86,9 +88,11 @@ function isAeSandboxRuntime() {
86
88
  }
87
89
 
88
90
  // 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 configFile() {
92
+ return path.join(getConfigDir(), "config.json");
93
+ }
91
94
  function sandboxCliTokenCandidatePaths() {
95
+ if (hasConfigDirOverride()) return [];
92
96
  const paths = [getSandboxCliTokenFilePath()];
93
97
  const homeFallback = path.join(process.env.HOME || "", ".ae-config", "cli-token.json");
94
98
  if (!paths.includes(homeFallback)) {
@@ -127,7 +131,8 @@ function getFallbackCliToken(hostUrl) {
127
131
  return null;
128
132
  }
129
133
  function ensureDir() {
130
- if (!fs3.existsSync(CONFIG_DIR)) fs3.mkdirSync(CONFIG_DIR, { recursive: true });
134
+ const configDir = getConfigDir();
135
+ if (!fs3.existsSync(configDir)) fs3.mkdirSync(configDir, { recursive: true });
131
136
  }
132
137
  function dedupeNormalizedHosts(config) {
133
138
  const hosts = {};
@@ -150,8 +155,9 @@ function configNeedsNormalization(config) {
150
155
  }
151
156
  function loadConfig() {
152
157
  try {
153
- if (fs3.existsSync(CONFIG_FILE)) {
154
- const raw = safeReadJsonFile(CONFIG_FILE);
158
+ const file = configFile();
159
+ if (fs3.existsSync(file)) {
160
+ const raw = safeReadJsonFile(file);
155
161
  if (raw.defaultHost && !raw.activeHost) {
156
162
  const migrated = dedupeNormalizedHosts(migrateConfig(raw));
157
163
  saveConfig(migrated);
@@ -188,7 +194,7 @@ function migrateConfig(old) {
188
194
  }
189
195
  function saveConfig(config) {
190
196
  ensureDir();
191
- fs3.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
197
+ fs3.writeFileSync(configFile(), JSON.stringify(config, null, 2));
192
198
  logger.info(`Config saved: activeHost=${config.activeHost}, hosts=${Object.keys(config.hosts).length}`);
193
199
  }
194
200
  function getActiveHost() {
@@ -270,9 +276,6 @@ function resolveHostSelector(env) {
270
276
  if (byLabel.length > 1) return { status: "duplicate-label", matches: byLabel };
271
277
  return { status: "not-found", hosts };
272
278
  }
273
- function getConfigDir() {
274
- return CONFIG_DIR;
275
- }
276
279
 
277
280
  export {
278
281
  safeJsonParse,
@@ -289,6 +292,5 @@ export {
289
292
  updateHostLabel,
290
293
  removeHost,
291
294
  listHosts,
292
- resolveHostSelector,
293
- getConfigDir
295
+ resolveHostSelector
294
296
  };