@thinkingai/ae-cli 6.0.53 → 6.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -9
- package/README.zh.md +25 -9
- package/bin/ae-cli.js +6 -1
- package/cli-installation-guide.md +91 -0
- package/dist/{auth-LHM7NQPR.js → auth-MBWRZTB6.js} +9 -11
- package/dist/automation-NWWVLWG2.js +459 -0
- package/dist/{capability-F2RIR5DS.js → capability-7SSN6PNZ.js} +6 -6
- package/dist/chunk-4655PUNX.js +43 -0
- package/dist/{chunk-KS4DE3MX.js → chunk-5XJYLEVC.js} +4 -4
- package/dist/{chunk-N4BLPJC7.js → chunk-7QXISROD.js} +1 -1
- package/dist/{chunk-7WZACOAI.js → chunk-AP7YP2NX.js} +2 -2
- package/dist/{chunk-SO5LKIWP.js → chunk-CT7QDJS6.js} +2 -2
- package/dist/chunk-D6ACFILC.js +56 -0
- package/dist/{chunk-QYXDJOLA.js → chunk-EOYSKMXN.js} +19 -11
- package/dist/{chunk-5XRQ3CZR.js → chunk-FMNNGNYO.js} +43 -8
- package/dist/{chunk-DU72X2IO.js → chunk-GIK6EDUG.js} +22 -10
- package/dist/{chunk-PGCIKZRE.js → chunk-HBLK3ZHW.js} +3 -3
- package/dist/chunk-HVHR4SCP.js +133 -0
- package/dist/{chunk-BW7JUDEI.js → chunk-KFNMQTZI.js} +514 -213
- package/dist/{chunk-KJDOTPYU.js → chunk-PLE722AJ.js} +28 -11
- package/dist/chunk-RK6GLDGI.js +27 -0
- package/dist/{chunk-GK7WDY7E.js → chunk-S6M42KND.js} +1 -1
- package/dist/{chunk-IG3DYEIR.js → chunk-UQ77JXYH.js} +4 -3
- package/dist/{chunk-YVGXGTD6.js → chunk-WNGFSIOB.js} +7 -1
- package/dist/{chunk-647BRKZK.js → chunk-ZIQWCZTS.js} +3 -3
- package/dist/{community-report-client-6VJDDMJJ.js → community-report-client-PEERQCX2.js} +1 -1
- package/dist/{config-XQWOPDHN.js → config-FF6YVJKI.js} +8 -8
- package/dist/context-YAE3QXP3.js +136 -0
- package/dist/{data-integration-XBTCGXQT.js → data-integration-HESZET7E.js} +6 -6
- package/dist/index.js +125 -48
- package/dist/{local-data-upload-client-3P7NIVQ4.js → local-data-upload-client-TWMHFLUA.js} +1 -1
- package/dist/memory-62BJOULV.js +580 -0
- package/dist/{metadata-V5ZDTKWZ.js → metadata-7CUMWIB4.js} +7 -7
- package/dist/{model-ZS7HVGKN.js → model-SBV2JFJI.js} +9 -5
- package/dist/{personal-semantic-preference-2XANU3F6.js → personal-semantic-preference-6SRCYPGE.js} +117 -11
- package/dist/{project-semantic-LP3LY7QP.js → project-semantic-YYEM4OSU.js} +6 -6
- package/dist/{sync-EQLSTUS7.js → sync-SU33KYX7.js} +12 -8
- package/dist/{te-agent-Z3HCTKR7.js → te-agent-F5QBZSQA.js} +90 -454
- package/dist/{te-analysis-3EVYQ3IO.js → te-analysis-U4I2W2WC.js} +297 -20
- package/dist/{te-community-Z7JACGF3.js → te-community-PFLDLPP4.js} +3 -3
- package/dist/{te-dataops-F7GQOIS6.js → te-dataops-FOQSRIAZ.js} +5 -5
- package/dist/{te-engage-LFBU6WWH.js → te-engage-ZX76CNAB.js} +6 -6
- package/dist/{te-kb-QJLJEX5K.js → te-kb-MHDOST62.js} +494 -214
- package/dist/{te-system-IXC43QHZ.js → te-system-J2FQF5ER.js} +6 -6
- package/dist/{te-team-BIZIKIHZ.js → te-team-5UOZPTU3.js} +6 -6
- package/dist/things-VPPXXLHB.js +1091 -0
- package/dist/{update-W2SGQNKT.js → update-EEUTEI6R.js} +59 -51
- package/dist/workspace-O3EEIYQM.js +554 -0
- package/package.json +21 -9
- package/skills/ae-agent/SKILL.md +89 -139
- package/skills/ae-agent/references/add-model.md +1 -1
- package/skills/ae-agent/references/create-agent.md +1 -1
- package/skills/ae-agent/references/find-archived-conversations.md +12 -5
- package/skills/ae-agent/references/get-agent.md +1 -1
- package/skills/ae-agent/references/list-agents.md +2 -2
- package/skills/ae-agent/references/list-models.md +2 -2
- package/skills/ae-agent/references/restore-conversation.md +3 -1
- package/skills/ae-analysis/SKILL.md +15 -6
- package/skills/ae-analysis/references/ai_models/funnel.md +5 -3
- package/skills/ae-analysis/references/ai_models.md +27 -0
- package/skills/ae-analysis/references/command_index.md +12 -4
- package/skills/ae-analysis/references/dashboard_move.md +21 -0
- package/skills/ae-analysis/references/dashboard_report_add.md +2 -0
- package/skills/ae-analysis/references/dashboard_report_get.md +19 -0
- package/skills/ae-analysis/references/dashboard_report_update.md +27 -0
- package/skills/ae-analysis/references/dashboard_update.md +1 -1
- package/skills/ae-analysis/references/event_report_presentation.md +76 -0
- package/skills/ae-analysis/references/feedback_submit.md +37 -0
- package/skills/ae-analysis/references/metadata_resolution.md +15 -0
- package/skills/ae-analysis/references/personal_semantic_preference_review.md +9 -0
- package/skills/ae-analysis/references/personal_semantic_preference_review_list.md +7 -0
- package/skills/ae-analysis/references/personal_semantic_preference_submit.md +7 -0
- package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +90 -31
- package/skills/ae-analysis/references/project_semantic_knowledge_wiki_plan_schema.md +99 -1
- package/skills/ae-analysis/references/report_create.md +13 -3
- package/skills/ae-analysis/references/report_get.md +5 -1
- package/skills/ae-analysis/references/report_update.md +15 -4
- package/skills/ae-analysis/references/system_query_monitor_overview.md +2 -0
- package/skills/ae-analysis/references/system_query_task_cancel.md +2 -0
- package/skills/ae-analysis/references/system_query_task_export.md +6 -2
- package/skills/ae-analysis/references/system_query_task_get.md +2 -0
- package/skills/ae-analysis/references/system_query_task_list.md +7 -3
- package/skills/ae-analysis/references/system_query_task_options.md +2 -2
- package/skills/ae-analysis/references/system_query_task_realtime_list.md +15 -0
- package/skills/ae-analysis/references/user_tag_models.md +2 -0
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/build-empty-skeleton.mjs +105 -0
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/build-project-semantic-wiki.mjs +669 -29
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/company-kb.mjs +21 -8
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-rules.md +28 -10
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-schema.md +66 -0
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/generate-build-ir.mjs +285 -24
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/package-wiki-source-zip.mjs +262 -30
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/plan-kb-source-sync.mjs +1 -1
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/precompiled-source.mjs +46 -2
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/prepare-compile-schema.mjs +64 -0
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/refresh-state-parts.mjs +91 -0
- package/skills/ae-automation/SKILL.md +16 -0
- package/skills/ae-automation/references/cli.md +53 -0
- package/skills/ae-automation/references/command_index.md +17 -0
- package/skills/ae-capability/SKILL.md +15 -6
- package/skills/ae-current-context/SKILL.md +3 -2
- package/skills/ae-kb/SKILL.md +62 -12
- package/skills/ae-kb/references/analysis-workflow.md +73 -36
- package/skills/ae-kb/references/query-workflow.md +67 -33
- package/skills/ae-kb/references/schema-import.md +5 -3
- package/skills/ae-kb/references/source-mutations.md +6 -4
- package/skills/ae-kb/references/text-sources.md +53 -0
- package/skills/ae-kb-discovery/SKILL.md +1 -1
- package/skills/ae-team/SKILL.md +23 -17
- package/skills/ae-things/SKILL.md +85 -0
- package/skills/ae-things/references/cli.md +103 -0
- package/skills/ae-things-progress/SKILL.md +43 -0
- package/skills/ae-things-review/SKILL.md +42 -0
- package/skills/ae-workspace/SKILL.md +43 -0
- package/skills/ae-workspace/references/commands.md +51 -0
- package/dist/chunk-E2JKXMVO.js +0 -29
- package/dist/context-M3HDGEIR.js +0 -46
- package/dist/memory-6APEB2JB.js +0 -892
- package/skills/ae-agent/references/create-automation.md +0 -125
- package/skills/ae-agent/references/list-automations.md +0 -56
- 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-
|
|
7
|
+
} from "./chunk-GIK6EDUG.js";
|
|
8
8
|
import {
|
|
9
9
|
getActiveHost,
|
|
10
10
|
getSandboxRuntimeRoot
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-UQ77JXYH.js";
|
|
12
12
|
import {
|
|
13
|
-
PermissionError
|
|
14
|
-
|
|
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
|
-
|
|
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
|
|
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-
|
|
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-
|
|
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 ||
|
|
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 ||
|
|
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,
|
|
@@ -6,13 +6,13 @@ import {
|
|
|
6
6
|
dryRunCapability,
|
|
7
7
|
executeCapabilityWithEnvelope,
|
|
8
8
|
validateCapability
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-EOYSKMXN.js";
|
|
10
10
|
import {
|
|
11
11
|
withOutputMetadata
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-KFNMQTZI.js";
|
|
13
13
|
import {
|
|
14
14
|
CliValidationError
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-WNGFSIOB.js";
|
|
16
16
|
|
|
17
17
|
// src/core/definition-intent.ts
|
|
18
18
|
import { createHash } from "crypto";
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
MultiselectCancelled,
|
|
4
|
-
promptSingleSelect
|
|
5
|
-
} from "./chunk-7K24F7T2.js";
|
|
6
2
|
import {
|
|
7
3
|
AE_TRIAL_URL,
|
|
8
4
|
missingAeHostHint
|
|
9
5
|
} from "./chunk-6ZIQV5GW.js";
|
|
6
|
+
import {
|
|
7
|
+
MultiselectCancelled,
|
|
8
|
+
promptSingleSelect
|
|
9
|
+
} from "./chunk-7K24F7T2.js";
|
|
10
10
|
import {
|
|
11
11
|
fetchCliConfig,
|
|
12
12
|
printError,
|
|
13
13
|
printOutput,
|
|
14
14
|
resolveKbAutoDiscoveryFeature
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-KFNMQTZI.js";
|
|
16
16
|
import {
|
|
17
17
|
peekCliToken
|
|
18
|
-
} from "./chunk-
|
|
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-
|
|
30
|
-
import "./chunk-
|
|
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-
|
|
12
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-5XJYLEVC.js";
|
|
12
|
+
import "./chunk-CT7QDJS6.js";
|
|
13
13
|
import {
|
|
14
14
|
require_archiver
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
15
|
+
} from "./chunk-AP7YP2NX.js";
|
|
16
|
+
import "./chunk-S6M42KND.js";
|
|
17
17
|
import {
|
|
18
18
|
getConfigDir
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-UQ77JXYH.js";
|
|
20
20
|
import {
|
|
21
21
|
CliValidationError,
|
|
22
22
|
LocalDataUploadError,
|
|
23
23
|
__toESM
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-WNGFSIOB.js";
|
|
25
25
|
|
|
26
26
|
// src/commands/data-integration/inspect.ts
|
|
27
27
|
import { basename as basename3 } from "path";
|