@thinkingai/ae-cli 6.1.25 → 6.1.26

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 (121) hide show
  1. package/README.md +28 -9
  2. package/README.zh.md +25 -9
  3. package/bin/ae-cli.js +6 -1
  4. package/cli-installation-guide.md +91 -0
  5. package/dist/{auth-LHM7NQPR.js → auth-YHMC3GDH.js} +6 -8
  6. package/dist/automation-NWWVLWG2.js +459 -0
  7. package/dist/{capability-SJI5KOCK.js → capability-3QLLIVFB.js} +6 -6
  8. package/dist/chunk-4655PUNX.js +43 -0
  9. package/dist/{chunk-KS4DE3MX.js → chunk-5XJYLEVC.js} +4 -4
  10. package/dist/{chunk-N4BLPJC7.js → chunk-7QXISROD.js} +1 -1
  11. package/dist/{chunk-7WZACOAI.js → chunk-AP7YP2NX.js} +2 -2
  12. package/dist/{chunk-SO5LKIWP.js → chunk-CT7QDJS6.js} +2 -2
  13. package/dist/chunk-D6ACFILC.js +56 -0
  14. package/dist/{chunk-QYXDJOLA.js → chunk-EOYSKMXN.js} +19 -11
  15. package/dist/{chunk-5XRQ3CZR.js → chunk-FMNNGNYO.js} +43 -8
  16. package/dist/{chunk-DU72X2IO.js → chunk-GIK6EDUG.js} +22 -10
  17. package/dist/chunk-HVHR4SCP.js +133 -0
  18. package/dist/{chunk-2FJM4HRV.js → chunk-KAEHZZH4.js} +3 -3
  19. package/dist/{chunk-BW7JUDEI.js → chunk-KFNMQTZI.js} +514 -213
  20. package/dist/{chunk-KJDOTPYU.js → chunk-PLE722AJ.js} +28 -11
  21. package/dist/chunk-RK6GLDGI.js +27 -0
  22. package/dist/{chunk-GK7WDY7E.js → chunk-S6M42KND.js} +1 -1
  23. package/dist/{chunk-IG3DYEIR.js → chunk-UQ77JXYH.js} +4 -3
  24. package/dist/{chunk-YVGXGTD6.js → chunk-WNGFSIOB.js} +7 -1
  25. package/dist/{chunk-XKIW3QMF.js → chunk-XCHAYMSF.js} +3 -3
  26. package/dist/{community-report-client-6VJDDMJJ.js → community-report-client-PEERQCX2.js} +1 -1
  27. package/dist/{config-XQWOPDHN.js → config-AHPMEW5A.js} +4 -4
  28. package/dist/context-YAE3QXP3.js +136 -0
  29. package/dist/{data-integration-XBTCGXQT.js → data-integration-HESZET7E.js} +6 -6
  30. package/dist/index.js +123 -46
  31. package/dist/{local-data-upload-client-3P7NIVQ4.js → local-data-upload-client-TWMHFLUA.js} +1 -1
  32. package/dist/memory-62BJOULV.js +580 -0
  33. package/dist/{metadata-JRYKNUS5.js → metadata-C7CEDHOJ.js} +7 -7
  34. package/dist/{model-ZS7HVGKN.js → model-SBV2JFJI.js} +9 -5
  35. package/dist/{personal-semantic-preference-IDE2GE5T.js → personal-semantic-preference-QECDPHND.js} +117 -11
  36. package/dist/{project-semantic-36KOCYN7.js → project-semantic-Z4QAMBWF.js} +6 -6
  37. package/dist/{sync-EQLSTUS7.js → sync-SU33KYX7.js} +12 -8
  38. package/dist/{te-agent-Z3HCTKR7.js → te-agent-F5QBZSQA.js} +90 -454
  39. package/dist/{te-analysis-5ZZ6YHVH.js → te-analysis-2ECAAIFK.js} +297 -20
  40. package/dist/{te-community-Z7JACGF3.js → te-community-PFLDLPP4.js} +3 -3
  41. package/dist/{te-dataops-F7GQOIS6.js → te-dataops-FOQSRIAZ.js} +5 -5
  42. package/dist/{te-engage-RNRMYDO3.js → te-engage-QKUGIWSR.js} +6 -6
  43. package/dist/{te-experiment-BTAC2UNK.js → te-experiment-26PXR2UO.js} +6 -6
  44. package/dist/{te-kb-QJLJEX5K.js → te-kb-MHDOST62.js} +494 -214
  45. package/dist/{te-system-IXC43QHZ.js → te-system-J2FQF5ER.js} +6 -6
  46. package/dist/{te-team-BIZIKIHZ.js → te-team-5UOZPTU3.js} +6 -6
  47. package/dist/things-VPPXXLHB.js +1091 -0
  48. package/dist/{update-W2SGQNKT.js → update-EEUTEI6R.js} +59 -51
  49. package/dist/workspace-O3EEIYQM.js +554 -0
  50. package/package.json +21 -9
  51. package/skills/ae-agent/SKILL.md +89 -139
  52. package/skills/ae-agent/references/add-model.md +1 -1
  53. package/skills/ae-agent/references/create-agent.md +1 -1
  54. package/skills/ae-agent/references/find-archived-conversations.md +12 -5
  55. package/skills/ae-agent/references/get-agent.md +1 -1
  56. package/skills/ae-agent/references/list-agents.md +2 -2
  57. package/skills/ae-agent/references/list-models.md +2 -2
  58. package/skills/ae-agent/references/restore-conversation.md +3 -1
  59. package/skills/ae-analysis/SKILL.md +15 -6
  60. package/skills/ae-analysis/references/ai_models/funnel.md +5 -3
  61. package/skills/ae-analysis/references/ai_models.md +27 -0
  62. package/skills/ae-analysis/references/command_index.md +12 -4
  63. package/skills/ae-analysis/references/dashboard_move.md +21 -0
  64. package/skills/ae-analysis/references/dashboard_report_add.md +2 -0
  65. package/skills/ae-analysis/references/dashboard_report_get.md +19 -0
  66. package/skills/ae-analysis/references/dashboard_report_update.md +27 -0
  67. package/skills/ae-analysis/references/dashboard_update.md +1 -1
  68. package/skills/ae-analysis/references/event_report_presentation.md +76 -0
  69. package/skills/ae-analysis/references/feedback_submit.md +37 -0
  70. package/skills/ae-analysis/references/metadata_resolution.md +15 -0
  71. package/skills/ae-analysis/references/personal_semantic_preference_review.md +9 -0
  72. package/skills/ae-analysis/references/personal_semantic_preference_review_list.md +7 -0
  73. package/skills/ae-analysis/references/personal_semantic_preference_submit.md +7 -0
  74. package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +68 -27
  75. package/skills/ae-analysis/references/project_semantic_knowledge_wiki_plan_schema.md +40 -1
  76. package/skills/ae-analysis/references/report_create.md +13 -3
  77. package/skills/ae-analysis/references/report_get.md +5 -1
  78. package/skills/ae-analysis/references/report_update.md +15 -4
  79. package/skills/ae-analysis/references/system_query_monitor_overview.md +2 -0
  80. package/skills/ae-analysis/references/system_query_task_cancel.md +2 -0
  81. package/skills/ae-analysis/references/system_query_task_export.md +6 -2
  82. package/skills/ae-analysis/references/system_query_task_get.md +2 -0
  83. package/skills/ae-analysis/references/system_query_task_list.md +7 -3
  84. package/skills/ae-analysis/references/system_query_task_options.md +2 -2
  85. package/skills/ae-analysis/references/system_query_task_realtime_list.md +15 -0
  86. package/skills/ae-analysis/references/user_tag_models.md +2 -0
  87. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/build-empty-skeleton.mjs +105 -0
  88. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/build-project-semantic-wiki.mjs +337 -22
  89. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/company-kb.mjs +21 -8
  90. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-rules.md +24 -11
  91. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-schema.md +66 -0
  92. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/generate-build-ir.mjs +1 -0
  93. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/package-wiki-source-zip.mjs +109 -40
  94. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/plan-kb-source-sync.mjs +1 -1
  95. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/prepare-compile-schema.mjs +64 -0
  96. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/refresh-state-parts.mjs +91 -0
  97. package/skills/ae-automation/SKILL.md +16 -0
  98. package/skills/ae-automation/references/cli.md +53 -0
  99. package/skills/ae-automation/references/command_index.md +17 -0
  100. package/skills/ae-capability/SKILL.md +15 -6
  101. package/skills/ae-current-context/SKILL.md +3 -2
  102. package/skills/ae-kb/SKILL.md +62 -12
  103. package/skills/ae-kb/references/analysis-workflow.md +73 -36
  104. package/skills/ae-kb/references/query-workflow.md +67 -33
  105. package/skills/ae-kb/references/schema-import.md +5 -3
  106. package/skills/ae-kb/references/source-mutations.md +6 -4
  107. package/skills/ae-kb/references/text-sources.md +53 -0
  108. package/skills/ae-kb-discovery/SKILL.md +1 -1
  109. package/skills/ae-team/SKILL.md +23 -17
  110. package/skills/ae-things/SKILL.md +85 -0
  111. package/skills/ae-things/references/cli.md +103 -0
  112. package/skills/ae-things-progress/SKILL.md +43 -0
  113. package/skills/ae-things-review/SKILL.md +42 -0
  114. package/skills/ae-workspace/SKILL.md +43 -0
  115. package/skills/ae-workspace/references/commands.md +51 -0
  116. package/dist/chunk-E2JKXMVO.js +0 -29
  117. package/dist/context-M3HDGEIR.js +0 -46
  118. package/dist/memory-6APEB2JB.js +0 -892
  119. package/skills/ae-agent/references/create-automation.md +0 -125
  120. package/skills/ae-agent/references/list-automations.md +0 -56
  121. package/skills/ae-agent/references/update-automation.md +0 -107
@@ -4,14 +4,15 @@ import {
4
4
  } from "./chunk-Y74WTIKJ.js";
5
5
  import {
6
6
  getCliToken
7
- } from "./chunk-DU72X2IO.js";
7
+ } from "./chunk-GIK6EDUG.js";
8
8
  import {
9
9
  getActiveHost,
10
10
  getSandboxRuntimeRoot
11
- } from "./chunk-IG3DYEIR.js";
11
+ } from "./chunk-UQ77JXYH.js";
12
12
  import {
13
- PermissionError
14
- } from "./chunk-YVGXGTD6.js";
13
+ PermissionError,
14
+ isApiErrorType
15
+ } from "./chunk-WNGFSIOB.js";
15
16
 
16
17
  // src/core/te-agent-credentials.ts
17
18
  import { readFileSync } from "fs";
@@ -120,16 +121,22 @@ function resolveTeClaudeBaseUrl(host) {
120
121
 
121
122
  // src/core/te-agent-client.ts
122
123
  var TeAgentApiError = class extends Error {
123
- constructor(message, status, code, body) {
124
+ constructor(message, status, code, body, errorType = "api", hint, details) {
124
125
  super(message);
125
126
  this.status = status;
126
127
  this.code = code;
127
128
  this.body = body;
129
+ this.errorType = errorType;
130
+ this.hint = hint;
131
+ this.details = details;
128
132
  this.name = "TeAgentApiError";
129
133
  }
130
134
  status;
131
135
  code;
132
136
  body;
137
+ errorType;
138
+ hint;
139
+ details;
133
140
  };
134
141
  var DEFAULT_TIMEOUT_MS = 3e4;
135
142
  var UPLOAD_TIMEOUT_MS = 12e4;
@@ -241,7 +248,13 @@ function errorDetails(parsed, defaultErrorPrefix, status) {
241
248
  const message = typeof parsed?.error === "string" ? parsed.error : typeof nested?.message === "string" ? nested.message : typeof parsed?.message === "string" ? parsed.message : typeof parsed?.return_message === "string" ? parsed.return_message : `${defaultErrorPrefix} ${status}`;
242
249
  const code = typeof nested?.code === "string" ? nested.code : typeof parsed?.code === "string" ? parsed.code : void 0;
243
250
  const hint = typeof nested?.hint === "string" ? nested.hint : typeof parsed?.hint === "string" ? parsed.hint : void 0;
244
- return { message, code, hint };
251
+ const declaredType = isApiErrorType(nested?.type) ? nested.type : void 0;
252
+ const type = status === 401 ? "auth" : status === 403 ? "permission" : declaredType ?? ([400, 413, 422].includes(status) ? "validation" : status === 404 ? "not_found" : "api");
253
+ return { message, code, hint, type, details: declaredType ? nested?.details : void 0 };
254
+ }
255
+ function createTeAgentApiError(body, status, defaultErrorPrefix = "Main app returned") {
256
+ const error = errorDetails(body, defaultErrorPrefix, status);
257
+ return new TeAgentApiError(error.message, status, error.code, body, error.type, error.hint, error.details);
245
258
  }
246
259
  async function parseResponse(response, defaultErrorPrefix) {
247
260
  const text = await response.text();
@@ -256,17 +269,20 @@ async function parseResponse(response, defaultErrorPrefix) {
256
269
  if (!response.ok) {
257
270
  const details = errorDetails(parsed, defaultErrorPrefix, response.status);
258
271
  if (response.status === 403) {
259
- throw new PermissionError(details.message, details.code, details.hint);
272
+ throw new PermissionError(details.message, details.code, details.hint, details.details);
260
273
  }
261
274
  if (response.status === 401) {
262
275
  throw new TeAgentApiError(
263
- "Session expired or unauthorized. Please run: ae-cli auth login",
276
+ isApiErrorType(parsed?.error?.type) && typeof parsed.error.message === "string" && parsed.error.message.trim() ? details.message : "Session expired or unauthorized. Please run: ae-cli auth login",
264
277
  response.status,
265
- "auth_expired",
266
- parsed
278
+ details.code ?? "auth_expired",
279
+ parsed,
280
+ "auth",
281
+ details.hint ?? "Run: ae-cli auth login",
282
+ details.details
267
283
  );
268
284
  }
269
- throw new TeAgentApiError(details.message, response.status, details.code, parsed);
285
+ throw createTeAgentApiError(parsed, response.status, defaultErrorPrefix);
270
286
  }
271
287
  return parsed;
272
288
  }
@@ -487,6 +503,7 @@ export {
487
503
  getClaudeConfigDir,
488
504
  resolveTeClaudeBaseUrl,
489
505
  TeAgentApiError,
506
+ createTeAgentApiError,
490
507
  postToMainApp,
491
508
  getFromMainApp,
492
509
  getSandboxModels,
@@ -0,0 +1,27 @@
1
+ import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
+
3
+ // src/core/agent-space-context.ts
4
+ function value(name) {
5
+ const current = process.env[name]?.trim();
6
+ return current || void 0;
7
+ }
8
+ function currentAgentSpaceId() {
9
+ const explicit = value("TE_AGENT_CURRENT_AGENT_SPACE_ID");
10
+ if (explicit) return explicit;
11
+ const match = /(?:^|\/)spaces\/actived\/([^/]+)(?:\/|$)/.exec(process.cwd());
12
+ return match?.[1];
13
+ }
14
+ function isAgentSpaceRuntime() {
15
+ return Boolean(currentAgentSpaceId());
16
+ }
17
+ function assertLegacyWorkspaceCommand(command) {
18
+ if (!isAgentSpaceRuntime()) return;
19
+ throw new Error(
20
+ `ae-cli ${command} manages the legacy sandbox Workspace and is disabled in an AgentSpace runtime. Use ae-cli workspace capability list/set for AgentSpace capabilities.`
21
+ );
22
+ }
23
+
24
+ export {
25
+ currentAgentSpaceId,
26
+ assertLegacyWorkspaceCommand
27
+ };
@@ -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-YVGXGTD6.js";
5
+ } from "./chunk-WNGFSIOB.js";
6
6
 
7
7
  // node_modules/process-nextick-args/index.js
8
8
  var require_process_nextick_args = __commonJS({
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  logger
4
- } from "./chunk-YVGXGTD6.js";
4
+ } from "./chunk-WNGFSIOB.js";
5
5
 
6
6
  // src/core/url-utils.ts
7
7
  function normalizeUrl(url) {
@@ -15,6 +15,7 @@ function normalizeUrl(url) {
15
15
  // src/core/config.ts
16
16
  import fs3 from "fs";
17
17
  import path from "path";
18
+ import os from "os";
18
19
 
19
20
  // src/core/json-utils.ts
20
21
  import fs from "fs";
@@ -89,11 +90,11 @@ function isAeSandboxRuntime() {
89
90
  }
90
91
 
91
92
  // src/core/config.ts
92
- var CONFIG_DIR = path.join(process.env.HOME || "", ".ae-cli");
93
+ var CONFIG_DIR = path.join(process.env.HOME || os.homedir(), ".ae-cli");
93
94
  var CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
94
95
  function sandboxCliTokenCandidatePaths() {
95
96
  const paths = [getSandboxCliTokenFilePath()];
96
- const homeFallback = path.join(process.env.HOME || "", ".ae-config", "cli-token.json");
97
+ const homeFallback = path.join(process.env.HOME || os.homedir(), ".ae-config", "cli-token.json");
97
98
  if (!paths.includes(homeFallback)) {
98
99
  paths.push(homeFallback);
99
100
  }
@@ -133,15 +133,20 @@ var logger = new Logger();
133
133
 
134
134
  // src/core/errors.ts
135
135
  var PermissionError = class extends Error {
136
- constructor(message, code, hint) {
136
+ constructor(message, code, hint, details) {
137
137
  super(message);
138
138
  this.code = code;
139
139
  this.hint = hint;
140
+ this.details = details;
140
141
  this.name = "PermissionError";
141
142
  }
142
143
  code;
143
144
  hint;
145
+ details;
144
146
  };
147
+ function isApiErrorType(value) {
148
+ return value === "auth" || value === "permission" || value === "validation" || value === "not_found" || value === "api";
149
+ }
145
150
  var CliValidationError = class extends Error {
146
151
  code;
147
152
  hint;
@@ -216,6 +221,7 @@ export {
216
221
  __toCommonJS,
217
222
  logger,
218
223
  PermissionError,
224
+ isApiErrorType,
219
225
  CliValidationError,
220
226
  CliApiError,
221
227
  CommunityReportError,
@@ -3,7 +3,7 @@ import {
3
3
  CapabilityGatewayError,
4
4
  fetchCapabilityGateway,
5
5
  requestCapabilityGateway
6
- } from "./chunk-QYXDJOLA.js";
6
+ } from "./chunk-EOYSKMXN.js";
7
7
  import {
8
8
  resolveGatewayDomain
9
9
  } from "./chunk-KPQY44JQ.js";
@@ -11,10 +11,10 @@ import {
11
11
  readOutputMetadata,
12
12
  unwrapOutputData,
13
13
  withOutputMetadata
14
- } from "./chunk-BW7JUDEI.js";
14
+ } from "./chunk-KFNMQTZI.js";
15
15
  import {
16
16
  PermissionError
17
- } from "./chunk-YVGXGTD6.js";
17
+ } from "./chunk-WNGFSIOB.js";
18
18
 
19
19
  // src/core/analysis-async-artifact.ts
20
20
  import { randomBytes } from "crypto";
@@ -2,7 +2,7 @@ import { createRequire as __createRequire } from 'node:module'; const require =
2
2
  import {
3
3
  CommunityReportError,
4
4
  logger
5
- } from "./chunk-YVGXGTD6.js";
5
+ } from "./chunk-WNGFSIOB.js";
6
6
 
7
7
  // src/core/community-report-client.ts
8
8
  var DEFAULT_TIMEOUT_MS = 3e4;
@@ -12,10 +12,10 @@ import {
12
12
  printError,
13
13
  printOutput,
14
14
  resolveKbAutoDiscoveryFeature
15
- } from "./chunk-BW7JUDEI.js";
15
+ } from "./chunk-KFNMQTZI.js";
16
16
  import {
17
17
  peekCliToken
18
- } from "./chunk-DU72X2IO.js";
18
+ } from "./chunk-GIK6EDUG.js";
19
19
  import {
20
20
  addHost,
21
21
  getActiveHost,
@@ -26,8 +26,8 @@ import {
26
26
  resolveHostSelector,
27
27
  setActiveHost,
28
28
  updateHostLabel
29
- } from "./chunk-IG3DYEIR.js";
30
- import "./chunk-YVGXGTD6.js";
29
+ } from "./chunk-UQ77JXYH.js";
30
+ import "./chunk-WNGFSIOB.js";
31
31
 
32
32
  // src/commands/config.ts
33
33
  import * as readline2 from "readline";
@@ -0,0 +1,136 @@
1
+ import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
2
+ import {
3
+ TeAgentApiError,
4
+ getFromMainApp
5
+ } from "./chunk-PLE722AJ.js";
6
+ import "./chunk-Y74WTIKJ.js";
7
+ import "./chunk-GIK6EDUG.js";
8
+ import {
9
+ safeJsonParse
10
+ } from "./chunk-UQ77JXYH.js";
11
+ import {
12
+ CliValidationError
13
+ } from "./chunk-WNGFSIOB.js";
14
+
15
+ // src/core/current-page-context-client.ts
16
+ async function readCurrentPageContext(path) {
17
+ const url = process.env.TE_AGENT_PAGE_CONTEXT_MCP_URL;
18
+ const grant = process.env.TE_AGENT_PAGE_CONTEXT_TOKEN;
19
+ if (url === void 0 && grant === void 0) return getFromMainApp(path);
20
+ let endpoint;
21
+ try {
22
+ endpoint = new URL(url ?? "");
23
+ if (!grant || !["http:", "https:"].includes(endpoint.protocol) || endpoint.username || endpoint.password || endpoint.search || endpoint.hash || !endpoint.pathname.endsWith("/api/internal/dashboard-context/mcp")) throw new Error();
24
+ } catch {
25
+ throw new TeAgentApiError("Current page context Run binding is invalid.", 0, "CURRENT_PAGE_CONTEXT_BINDING_INVALID");
26
+ }
27
+ let response;
28
+ try {
29
+ response = await fetch(endpoint.toString(), {
30
+ method: "POST",
31
+ redirect: "error",
32
+ signal: AbortSignal.timeout(3e4),
33
+ headers: {
34
+ "Content-Type": "application/json",
35
+ Accept: "application/json, text/event-stream",
36
+ "MCP-Protocol-Version": "2025-03-26",
37
+ "X-TE-Page-Context-Token": grant
38
+ },
39
+ body: JSON.stringify({
40
+ jsonrpc: "2.0",
41
+ id: 1,
42
+ method: "tools/call",
43
+ params: { name: "read_current_page_context", arguments: {} }
44
+ })
45
+ });
46
+ } catch {
47
+ throw new TeAgentApiError("Current page context MCP request failed.", 0, "CURRENT_PAGE_CONTEXT_NETWORK_ERROR");
48
+ }
49
+ if (!response.ok) {
50
+ await response.body?.cancel();
51
+ throw new TeAgentApiError(
52
+ `Current page context authorization/request failed (HTTP ${response.status}).`,
53
+ response.status,
54
+ "CURRENT_PAGE_CONTEXT_UNAVAILABLE",
55
+ void 0,
56
+ response.status === 403 ? "permission" : response.status === 401 ? "auth" : "api"
57
+ );
58
+ }
59
+ const reader = response.body?.getReader();
60
+ if (!reader) throw invalidResponse();
61
+ const chunks = [];
62
+ let size = 0;
63
+ try {
64
+ while (true) {
65
+ const { value, done } = await reader.read();
66
+ if (done) break;
67
+ size += value.byteLength;
68
+ if (size > 4 * 1024 * 1024) throw invalidResponse();
69
+ chunks.push(value);
70
+ }
71
+ } catch {
72
+ await reader.cancel().catch(() => void 0);
73
+ throw invalidResponse();
74
+ } finally {
75
+ reader.releaseLock();
76
+ }
77
+ let envelope;
78
+ try {
79
+ envelope = safeJsonParse(Buffer.concat(chunks).toString("utf8"));
80
+ } catch {
81
+ throw invalidResponse();
82
+ }
83
+ if (envelope?.error || envelope?.result?.isError) {
84
+ throw new TeAgentApiError(
85
+ "Current page context is unavailable for this Run; authorization may have expired or been revoked.",
86
+ 403,
87
+ "CURRENT_PAGE_CONTEXT_UNAVAILABLE"
88
+ );
89
+ }
90
+ const content = envelope?.result?.content;
91
+ if (envelope?.jsonrpc !== "2.0" || envelope.id !== 1 || !Array.isArray(content) || content.length !== 1 || content[0]?.type !== "text") throw invalidResponse();
92
+ try {
93
+ return safeJsonParse(content[0].text);
94
+ } catch {
95
+ throw invalidResponse();
96
+ }
97
+ }
98
+ function invalidResponse() {
99
+ return new TeAgentApiError("Invalid current page context MCP response.", 0, "CURRENT_PAGE_CONTEXT_RESPONSE_INVALID");
100
+ }
101
+
102
+ // src/commands/context/current.ts
103
+ var CURRENT_PAGE_CONTEXT_PATH = "/api/sandbox/agent/context/current";
104
+ function createCurrentPageContextCommand(read = readCurrentPageContext, readConversationId = () => process.env.TE_AGENT_CONVERSATION_ID) {
105
+ return {
106
+ service: "context",
107
+ command: "+current",
108
+ description: "Read the current page context bound to the active Agent Run",
109
+ flags: [],
110
+ risk: "read",
111
+ usesAeHost: false,
112
+ execute: async () => {
113
+ const conversationId = readConversationId()?.trim();
114
+ if (!conversationId) {
115
+ throw new CliValidationError(
116
+ "Current page context is available only inside an active Agent Run.",
117
+ {
118
+ code: "CURRENT_PAGE_CONTEXT_RUN_REQUIRED",
119
+ hint: "Open AE Agent from a supported product page and ask about the current page."
120
+ }
121
+ );
122
+ }
123
+ const query = new URLSearchParams({ conversationId });
124
+ return read(`${CURRENT_PAGE_CONTEXT_PATH}?${query.toString()}`);
125
+ }
126
+ };
127
+ }
128
+ var currentPageContext = createCurrentPageContextCommand();
129
+
130
+ // src/commands/context/index.ts
131
+ var commands = [currentPageContext];
132
+ var context_default = commands;
133
+ export {
134
+ currentPageContext,
135
+ context_default as default
136
+ };
@@ -8,20 +8,20 @@ import {
8
8
  utils,
9
9
  validateAndFix,
10
10
  validateDraft
11
- } from "./chunk-KS4DE3MX.js";
12
- import "./chunk-SO5LKIWP.js";
11
+ } from "./chunk-5XJYLEVC.js";
12
+ import "./chunk-CT7QDJS6.js";
13
13
  import {
14
14
  require_archiver
15
- } from "./chunk-7WZACOAI.js";
16
- import "./chunk-GK7WDY7E.js";
15
+ } from "./chunk-AP7YP2NX.js";
16
+ import "./chunk-S6M42KND.js";
17
17
  import {
18
18
  getConfigDir
19
- } from "./chunk-IG3DYEIR.js";
19
+ } from "./chunk-UQ77JXYH.js";
20
20
  import {
21
21
  CliValidationError,
22
22
  LocalDataUploadError,
23
23
  __toESM
24
- } from "./chunk-YVGXGTD6.js";
24
+ } from "./chunk-WNGFSIOB.js";
25
25
 
26
26
  // src/commands/data-integration/inspect.ts
27
27
  import { basename as basename3 } from "path";