@thinkingai/ae-cli 6.1.18 → 6.1.20
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 +97 -38
- package/README.zh.md +101 -38
- package/dist/{auth-ROB2EDYV.js → auth-FUM37MHF.js} +241 -126
- package/dist/{capability-DKMYUTLC.js → capability-AXFQW5WM.js} +49 -35
- package/dist/{chunk-JHENBQ5B.js → chunk-4P355ZWB.js} +70 -1
- package/dist/chunk-6ZIQV5GW.js +26 -0
- package/dist/{chunk-TUKQZTMI.js → chunk-7K24F7T2.js} +2 -0
- package/dist/{chunk-OO6XR6LK.js → chunk-AMBFK2K3.js} +2 -0
- package/dist/chunk-ATSM5XAW.js +623 -0
- package/dist/{chunk-4XXOWOTA.js → chunk-BBEFP4SB.js} +31 -38
- package/dist/{chunk-BYYS3ANB.js → chunk-CZU3V3DQ.js} +5 -15
- package/dist/{chunk-VTWMIC5L.js → chunk-E2JKXMVO.js} +2 -0
- package/dist/chunk-ECBLHAZO.js +15 -0
- package/dist/{sync-HKIOZXQE.js → chunk-I4WQAEYB.js} +31 -540
- package/dist/{chunk-DWO43OIB.js → chunk-JQ3ENZZH.js} +2 -0
- package/dist/chunk-LNZBEQXW.js +25216 -0
- package/dist/{chunk-ZQ47LWTI.js → chunk-QJQZH5GQ.js} +49 -79
- package/dist/{chunk-QZ3AS4KK.js → chunk-RSG4ONOI.js} +9 -8
- package/dist/{chunk-4NN5IWVN.js → chunk-T6OSFQZD.js} +2 -0
- package/dist/{chunk-Y3LOALAV.js → chunk-TAL6CZH6.js} +8 -7
- package/dist/{chunk-3KWQYGYI.js → chunk-TKHSULJT.js} +2 -0
- package/dist/chunk-VXNMYUXU.js +202 -0
- package/dist/{chunk-3FY3RJ26.js → chunk-WZ6YVQSF.js} +15 -14
- package/dist/{chunk-6EIJSNBD.js → chunk-Y74WTIKJ.js} +2 -0
- package/dist/{community-report-client-C7WDGET3.js → community-report-client-XXWGSBSD.js} +3 -4
- package/dist/{config-BMYZX2UE.js → config-EXUGQN5T.js} +10 -10
- package/dist/{data-integration-QEKDWQDY.js → data-integration-4NZ53OMT.js} +920 -97
- package/dist/index.js +56 -81
- package/dist/{local-data-upload-client-4YYHSYD6.js → local-data-upload-client-KYOKVYZV.js} +3 -4
- package/dist/{memory-I2WXDTV2.js → memory-ATNKZNW5.js} +6 -7
- package/dist/{metadata-I4C2EWUN.js → metadata-VZVC7YMH.js} +10 -11
- package/dist/{model-HLHIEFMU.js → model-E4JMQ4V2.js} +8 -9
- package/dist/{personal-semantic-preference-LIPACBDX.js → personal-semantic-preference-7S2SQ3UV.js} +9 -10
- package/dist/{project-semantic-RT3R2VQD.js → project-semantic-2SZP2OPO.js} +13 -14
- package/dist/sync-YV3E66IF.js +520 -0
- package/dist/{te-agent-BR6VDBNX.js → te-agent-JB5T3PO7.js} +396 -92
- package/dist/{te-analysis-7VUNUYWZ.js → te-analysis-3YJAAT2D.js} +196 -43
- package/dist/{te-community-5DMNKJWY.js → te-community-UDBI672N.js} +12 -34
- package/dist/{te-dataops-6P5IKWNJ.js → te-dataops-ZLYOCXZ4.js} +480 -81
- package/dist/{te-engage-KZPR5R22.js → te-engage-4XG6OJML.js} +88 -16
- package/dist/{te-experiment-6BITX4RD.js → te-experiment-VXUWPINJ.js} +83 -12
- package/dist/te-kb-WYQWHFSC.js +1732 -0
- package/dist/{te-system-FXITO2JG.js → te-system-7G6F2LJA.js} +569 -35
- package/dist/{te-team-ADOC2ROP.js → te-team-E7FBBXMQ.js} +8 -7
- package/dist/{update-YCYCKJOO.js → update-D47BUG25.js} +8 -8
- package/package.json +22 -10
- package/skills/ae-agent/SKILL.md +30 -13
- package/skills/ae-agent/references/agent-distribution.md +94 -0
- package/skills/ae-agent/references/approval-request.md +4 -0
- package/skills/ae-agent/references/command_index.md +9 -2
- package/skills/ae-agent/references/create-automation.md +20 -2
- package/skills/ae-agent/references/get-agent-context.md +70 -0
- package/skills/ae-agent/references/list-automations.md +18 -3
- package/skills/ae-agent/references/list-mcp-credentials.md +1 -1
- package/skills/ae-agent/references/mcp-token.md +3 -3
- package/skills/ae-agent/references/set-mcp-credential.md +0 -1
- package/skills/ae-agent/references/update-automation.md +18 -0
- package/skills/ae-analysis/SKILL.md +11 -2
- package/skills/ae-analysis/references/adhoc_run.md +2 -0
- package/skills/ae-analysis/references/ai_models.md +23 -3
- package/skills/ae-analysis/references/analysis_gateway_assets.md +3 -3
- package/skills/ae-analysis/references/audience_models.md +18 -0
- package/skills/ae-analysis/references/command_index.md +9 -9
- package/skills/ae-analysis/references/cross_source_config.md +84 -0
- package/skills/ae-analysis/references/dashboard_update.md +1 -1
- package/skills/ae-analysis/references/project_timezone_update.md +13 -4
- package/skills/ae-analysis/references/property_create.md +2 -0
- package/skills/ae-analysis/references/super_metadata_batch_create.md +2 -0
- package/skills/ae-analysis/references/user_cluster_models.md +2 -0
- package/skills/ae-analysis/references/user_cluster_update.md +8 -4
- package/skills/ae-analysis/references/user_tag_create.md +30 -2
- package/skills/ae-analysis/references/user_tag_models.md +17 -3
- package/skills/ae-analysis/references/user_tag_update.md +14 -2
- package/skills/ae-data-integration/SKILL.md +3 -1
- package/skills/ae-data-integration/references/dimension-routing.md +36 -0
- package/skills/ae-data-integration/references/error-handling.md +54 -1
- package/skills/ae-data-integration/references/local-analysis.md +2 -0
- package/skills/ae-data-integration/references/source-inspect.md +18 -2
- package/skills/ae-data-integration/references/tracking-plan.md +1 -1
- package/skills/ae-data-integration/references/transform.md +4 -2
- package/skills/ae-data-integration/references/ue-mapping.md +5 -2
- package/skills/ae-data-integration/references/ue-routing.md +40 -1
- package/skills/ae-dataops/SKILL.md +11 -1
- package/skills/ae-dataops/references/dataops-backfill.md +135 -0
- package/skills/ae-engage/SKILL.md +5 -0
- package/skills/ae-engage/references/build-task-save-guide.md +5 -1
- package/skills/ae-engage/references/save-flow.md +37 -1
- package/skills/ae-engage/references/save-task.md +6 -0
- package/skills/ae-experiment/SKILL.md +6 -2
- package/skills/ae-experiment/references/save_metric.md +20 -8
- package/skills/ae-generate-tracking-plan/SKILL.md +25 -13
- package/skills/ae-generate-tracking-plan/references/business-dimension-mapping.md +1 -1
- package/skills/ae-kb/SKILL.md +218 -36
- package/skills/ae-kb/references/query-workflow.md +59 -29
- package/skills/ae-kb/references/versions.md +46 -0
- package/skills/ae-system/SKILL.md +29 -31
- package/skills/ae-system/references/channel-management.md +303 -0
- package/skills/ae-use-agent/SKILL.md +42 -0
- package/skills/ae-use-agent/references/local-agent.md +114 -0
- package/dist/auth-GBMV6TEJ.js +0 -14
- package/dist/capability-HYVVPG25.js +0 -352
- package/dist/chunk-EFH4XWYC.js +0 -556
- package/dist/chunk-J2DEBMRF.js +0 -313
- package/dist/chunk-JRJY5DMJ.js +0 -71
- package/dist/chunk-OMPRXM3V.js +0 -349
- package/dist/chunk-QNOLN2LJ.js +0 -509
- package/dist/chunk-RJDU7NYP.js +0 -1198
- package/dist/chunk-RNAALWJK.js +0 -98
- package/dist/chunk-SERWF6G5.js +0 -13
- package/dist/chunk-UW5UN47B.js +0 -70
- package/dist/chunk-ZQKDZXDO.js +0 -317
- package/dist/client-L2YDMHQ6.js +0 -203
- package/dist/memory-3ORCR7JH.js +0 -893
- package/dist/metadata-VUOQJE26.js +0 -339
- package/dist/model-UGRDX4MW.js +0 -139
- package/dist/personal-semantic-preference-OEISBRHM.js +0 -239
- package/dist/project-semantic-FFPWFPIW.js +0 -1114
- package/dist/sync-TFHU2UTG.js +0 -10261
- package/dist/te-agent-VLYOV7S4.js +0 -3894
- package/dist/te-analysis-4YGQL5RC.js +0 -9357
- package/dist/te-community-ISDQWJU7.js +0 -1859
- package/dist/te-dataops-CVULXNVB.js +0 -2209
- package/dist/te-engage-N5WI32H6.js +0 -4898
- package/dist/te-experiment-UVR4HLND.js +0 -988
- package/dist/te-kb-RCLSSH2Q.js +0 -935
- package/dist/te-system-K2GYMCTB.js +0 -2213
- package/skills/ae-agent/references/auto-provision-mcp-credentials.md +0 -57
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
1
2
|
import {
|
|
3
|
+
TeAgentApiError,
|
|
2
4
|
deleteFromMainApp,
|
|
3
5
|
downloadFromMainApp,
|
|
4
6
|
getFromMainApp,
|
|
@@ -7,25 +9,28 @@ import {
|
|
|
7
9
|
putToMainApp,
|
|
8
10
|
tryLoadTeAgentSandboxCredentials,
|
|
9
11
|
uploadToMainApp
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-ZQKDZXDO.js";
|
|
12
|
+
} from "./chunk-BBEFP4SB.js";
|
|
13
|
+
import "./chunk-Y74WTIKJ.js";
|
|
14
|
+
import "./chunk-ATSM5XAW.js";
|
|
14
15
|
import {
|
|
15
16
|
safeJsonParse
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-WZ6YVQSF.js";
|
|
17
18
|
import {
|
|
18
|
-
CliValidationError
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
CliValidationError,
|
|
20
|
+
PermissionError
|
|
21
|
+
} from "./chunk-4P355ZWB.js";
|
|
21
22
|
|
|
22
23
|
// src/commands/te-system/shared.ts
|
|
23
24
|
import { readFileSync } from "fs";
|
|
24
25
|
var SECRET_KEYS = /* @__PURE__ */ new Set([
|
|
25
26
|
"appsecret",
|
|
26
27
|
"bottoken",
|
|
28
|
+
"botsecret",
|
|
27
29
|
"apptoken",
|
|
28
30
|
"clientsecret",
|
|
31
|
+
"corpsecret",
|
|
32
|
+
"serviceaccountjson",
|
|
33
|
+
"privatekey",
|
|
29
34
|
"apikey",
|
|
30
35
|
"secret",
|
|
31
36
|
"token"
|
|
@@ -34,6 +39,12 @@ function assertAdminPath(path3) {
|
|
|
34
39
|
if (path3 === "/api/admin" || path3.startsWith("/api/admin/")) return;
|
|
35
40
|
throw new CliValidationError("System commands may only call /api/admin endpoints");
|
|
36
41
|
}
|
|
42
|
+
function assertCliChannelPath(path3) {
|
|
43
|
+
if (path3 === "/api/cli/channel/v1" || path3.startsWith("/api/cli/channel/v1/")) return;
|
|
44
|
+
throw new CliValidationError(
|
|
45
|
+
"Channel commands may only call /api/cli/channel/v1 endpoints"
|
|
46
|
+
);
|
|
47
|
+
}
|
|
37
48
|
async function getAdmin(path3, host) {
|
|
38
49
|
assertAdminPath(path3);
|
|
39
50
|
return getFromMainApp(path3, host);
|
|
@@ -46,8 +57,8 @@ async function downloadAdmin(path3, outputPath, host) {
|
|
|
46
57
|
assertAdminPath(path3);
|
|
47
58
|
return downloadFromMainApp(path3, outputPath, host);
|
|
48
59
|
}
|
|
49
|
-
async function
|
|
50
|
-
|
|
60
|
+
async function executeSignedRequest(ctx, request, assertPath) {
|
|
61
|
+
assertPath(request.path);
|
|
51
62
|
const host = ctx.host();
|
|
52
63
|
switch (request.method) {
|
|
53
64
|
case "GET":
|
|
@@ -62,9 +73,10 @@ async function executeAdminRequest(ctx, request) {
|
|
|
62
73
|
return deleteFromMainApp(request.path, host);
|
|
63
74
|
}
|
|
64
75
|
}
|
|
65
|
-
function
|
|
76
|
+
function createSignedCommand(config, assertPath) {
|
|
66
77
|
return {
|
|
67
78
|
service: "system",
|
|
79
|
+
...config.resource ? { resource: config.resource } : {},
|
|
68
80
|
command: config.command,
|
|
69
81
|
description: config.description,
|
|
70
82
|
flags: config.flags,
|
|
@@ -73,20 +85,36 @@ function createAdminCommand(config) {
|
|
|
73
85
|
validate: config.validate,
|
|
74
86
|
preflight: config.risk === "high-risk-write" ? (ctx) => {
|
|
75
87
|
const request = config.prepare(ctx);
|
|
76
|
-
|
|
88
|
+
assertPath(request.path);
|
|
77
89
|
} : void 0,
|
|
78
90
|
dryRun: (ctx) => {
|
|
79
91
|
const request = config.prepare(ctx);
|
|
80
|
-
|
|
92
|
+
assertPath(request.path);
|
|
81
93
|
return {
|
|
82
94
|
method: request.method,
|
|
83
95
|
url: request.path,
|
|
84
96
|
...request.body === void 0 ? {} : { body: config.redactDryRun ? redactSecrets(request.body) : request.body }
|
|
85
97
|
};
|
|
86
98
|
},
|
|
87
|
-
execute: async (ctx) =>
|
|
99
|
+
execute: async (ctx) => executeSignedRequest(ctx, config.prepare(ctx), assertPath)
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function createAdminCommand(config) {
|
|
103
|
+
return createSignedCommand(config, assertAdminPath);
|
|
104
|
+
}
|
|
105
|
+
function createCliChannelCommand(config) {
|
|
106
|
+
const command = createSignedCommand(config, assertCliChannelPath);
|
|
107
|
+
const execute = command.execute;
|
|
108
|
+
return {
|
|
109
|
+
...command,
|
|
110
|
+
execute: async (ctx) => unwrapCliChannelResponse(await execute(ctx))
|
|
88
111
|
};
|
|
89
112
|
}
|
|
113
|
+
function unwrapCliChannelResponse(value) {
|
|
114
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return value;
|
|
115
|
+
const envelope = value;
|
|
116
|
+
return envelope.ok === true && "data" in envelope ? envelope.data : value;
|
|
117
|
+
}
|
|
90
118
|
function createAdminDownloadCommand(config) {
|
|
91
119
|
return {
|
|
92
120
|
service: "system",
|
|
@@ -199,7 +227,7 @@ function redactSecrets(value) {
|
|
|
199
227
|
return Object.fromEntries(
|
|
200
228
|
Object.entries(value).map(([key, item]) => [
|
|
201
229
|
key,
|
|
202
|
-
SECRET_KEYS.has(key.toLowerCase()) ? "***" : redactSecrets(item)
|
|
230
|
+
SECRET_KEYS.has(key.toLowerCase().replace(/[^a-z0-9]/g, "")) ? "***" : redactSecrets(item)
|
|
203
231
|
])
|
|
204
232
|
);
|
|
205
233
|
}
|
|
@@ -1131,47 +1159,137 @@ var costControlCommands = [
|
|
|
1131
1159
|
];
|
|
1132
1160
|
|
|
1133
1161
|
// src/commands/te-system/channels.ts
|
|
1134
|
-
var CHANNEL_TYPES = /* @__PURE__ */ new Set([
|
|
1162
|
+
var CHANNEL_TYPES = /* @__PURE__ */ new Set([
|
|
1163
|
+
"feishu",
|
|
1164
|
+
"lark",
|
|
1165
|
+
"slack",
|
|
1166
|
+
"discord",
|
|
1167
|
+
"dingtalk",
|
|
1168
|
+
"wecom",
|
|
1169
|
+
"mattermost",
|
|
1170
|
+
"google_chat",
|
|
1171
|
+
"whatsapp"
|
|
1172
|
+
]);
|
|
1173
|
+
var REQUIRED_CONFIG_KEYS = {
|
|
1174
|
+
feishu: ["app_id", "app_secret"],
|
|
1175
|
+
lark: ["app_id", "app_secret"],
|
|
1176
|
+
slack: ["bot_token", "app_token"],
|
|
1177
|
+
discord: ["bot_token"],
|
|
1178
|
+
dingtalk: ["client_id", "client_secret", "corp_id"],
|
|
1179
|
+
wecom: ["bot_id", "bot_secret"],
|
|
1180
|
+
mattermost: ["server_url", "bot_token"],
|
|
1181
|
+
google_chat: ["service_account_json"],
|
|
1182
|
+
whatsapp: []
|
|
1183
|
+
};
|
|
1184
|
+
var OAUTH_REQUIRED_CONFIG_KEYS = {
|
|
1185
|
+
wecom: ["corp_id", "corp_secret", "agent_id"],
|
|
1186
|
+
mattermost: ["client_id", "client_secret"],
|
|
1187
|
+
google_chat: ["client_id", "client_secret"]
|
|
1188
|
+
};
|
|
1189
|
+
var CONFIG_KEY_ALIASES = {
|
|
1190
|
+
appId: "app_id",
|
|
1191
|
+
appSecret: "app_secret",
|
|
1192
|
+
botToken: "bot_token",
|
|
1193
|
+
appToken: "app_token",
|
|
1194
|
+
clientId: "client_id",
|
|
1195
|
+
clientSecret: "client_secret",
|
|
1196
|
+
corpId: "corp_id",
|
|
1197
|
+
corpSecret: "corp_secret",
|
|
1198
|
+
botId: "bot_id",
|
|
1199
|
+
botSecret: "bot_secret",
|
|
1200
|
+
agentId: "agent_id",
|
|
1201
|
+
oauthEnabled: "oauth_enabled",
|
|
1202
|
+
interactionCardTemplateId: "interaction_card_template_id",
|
|
1203
|
+
serverUrl: "server_url",
|
|
1204
|
+
serviceAccountJson: "service_account_json",
|
|
1205
|
+
workspaceAddonServiceAccountEmail: "workspace_addon_service_account_email"
|
|
1206
|
+
};
|
|
1207
|
+
function normalizeKeys(value, aliases) {
|
|
1208
|
+
return Object.fromEntries(
|
|
1209
|
+
Object.entries(value).map(([key, item]) => [aliases[key] ?? key, item])
|
|
1210
|
+
);
|
|
1211
|
+
}
|
|
1212
|
+
function normalizeChannelBody(channel) {
|
|
1213
|
+
const normalized = normalizeKeys(channel, {
|
|
1214
|
+
systemPrompt: "system_prompt",
|
|
1215
|
+
unbindUsers: "unbind_users"
|
|
1216
|
+
});
|
|
1217
|
+
if (normalized.config && typeof normalized.config === "object" && !Array.isArray(normalized.config)) {
|
|
1218
|
+
normalized.config = normalizeKeys(
|
|
1219
|
+
normalized.config,
|
|
1220
|
+
CONFIG_KEY_ALIASES
|
|
1221
|
+
);
|
|
1222
|
+
}
|
|
1223
|
+
return normalized;
|
|
1224
|
+
}
|
|
1135
1225
|
function createChannelBody(ctx) {
|
|
1136
|
-
const channel = requireJsonObject(ctx, "channel");
|
|
1226
|
+
const channel = normalizeChannelBody(requireJsonObject(ctx, "channel"));
|
|
1137
1227
|
if (typeof channel.name !== "string" || !channel.name.trim()) {
|
|
1138
1228
|
throw new CliValidationError("--channel.name is required");
|
|
1139
1229
|
}
|
|
1140
1230
|
if (typeof channel.type !== "string" || !CHANNEL_TYPES.has(channel.type)) {
|
|
1141
|
-
throw new CliValidationError(
|
|
1231
|
+
throw new CliValidationError(
|
|
1232
|
+
`--channel.type must be one of: ${Array.from(CHANNEL_TYPES).join(", ")}`
|
|
1233
|
+
);
|
|
1234
|
+
}
|
|
1235
|
+
if (channel.config === void 0 && channel.type === "whatsapp") {
|
|
1236
|
+
channel.config = {};
|
|
1142
1237
|
}
|
|
1143
1238
|
if (!channel.config || typeof channel.config !== "object" || Array.isArray(channel.config)) {
|
|
1144
1239
|
throw new CliValidationError("--channel.config must be a JSON object");
|
|
1145
1240
|
}
|
|
1146
1241
|
const config = channel.config;
|
|
1147
|
-
const
|
|
1148
|
-
for (const key of requiredConfigKeys) {
|
|
1242
|
+
for (const key of REQUIRED_CONFIG_KEYS[channel.type] ?? []) {
|
|
1149
1243
|
if (typeof config[key] !== "string" || !config[key].trim()) {
|
|
1150
1244
|
throw new CliValidationError(`--channel.config.${key} is required for ${channel.type}`);
|
|
1151
1245
|
}
|
|
1152
1246
|
}
|
|
1247
|
+
if (config.oauth_enabled === true) {
|
|
1248
|
+
for (const key of OAUTH_REQUIRED_CONFIG_KEYS[channel.type] ?? []) {
|
|
1249
|
+
if (typeof config[key] !== "string" || !config[key].trim()) {
|
|
1250
|
+
throw new CliValidationError(
|
|
1251
|
+
`--channel.config.${key} is required when oauth_enabled is true for ${channel.type}`
|
|
1252
|
+
);
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1153
1256
|
return channel;
|
|
1154
1257
|
}
|
|
1155
1258
|
function updateChannelBody(ctx) {
|
|
1156
|
-
const channel = requireJsonObject(ctx, "channel");
|
|
1259
|
+
const channel = normalizeChannelBody(requireJsonObject(ctx, "channel"));
|
|
1157
1260
|
if (Object.keys(channel).length === 0) {
|
|
1158
1261
|
throw new CliValidationError("--channel must contain at least one update field");
|
|
1159
1262
|
}
|
|
1160
|
-
if (
|
|
1161
|
-
throw new CliValidationError(
|
|
1263
|
+
if (channel.type !== void 0 && (typeof channel.type !== "string" || !CHANNEL_TYPES.has(channel.type))) {
|
|
1264
|
+
throw new CliValidationError(
|
|
1265
|
+
`--channel.type must be one of: ${Array.from(CHANNEL_TYPES).join(", ")}`
|
|
1266
|
+
);
|
|
1162
1267
|
}
|
|
1163
1268
|
return channel;
|
|
1164
1269
|
}
|
|
1165
|
-
var listChannels =
|
|
1270
|
+
var listChannels = createCliChannelCommand({
|
|
1166
1271
|
command: "+list-channels",
|
|
1167
|
-
description: "List configured
|
|
1272
|
+
description: "List configured channels",
|
|
1168
1273
|
flags: [],
|
|
1169
1274
|
risk: "read",
|
|
1170
|
-
prepare: () => ({ method: "GET", path: "/api/
|
|
1275
|
+
prepare: () => ({ method: "GET", path: "/api/cli/channel/v1/channels" })
|
|
1171
1276
|
});
|
|
1172
|
-
var
|
|
1277
|
+
var getChannel = createCliChannelCommand({
|
|
1278
|
+
resource: "channel",
|
|
1279
|
+
command: "get",
|
|
1280
|
+
description: "Get one configured channel",
|
|
1281
|
+
flags: [
|
|
1282
|
+
{ name: "id", type: "string", required: true, desc: "Channel ID from +list-channels" }
|
|
1283
|
+
],
|
|
1284
|
+
risk: "read",
|
|
1285
|
+
prepare: (ctx) => ({
|
|
1286
|
+
method: "GET",
|
|
1287
|
+
path: `/api/cli/channel/v1/channels/${encodeId(ctx.str("id"))}`
|
|
1288
|
+
})
|
|
1289
|
+
});
|
|
1290
|
+
var createChannel = createCliChannelCommand({
|
|
1173
1291
|
command: "+create-channel",
|
|
1174
|
-
description: "Create a
|
|
1292
|
+
description: "Create a managed channel",
|
|
1175
1293
|
flags: [
|
|
1176
1294
|
{
|
|
1177
1295
|
name: "channel",
|
|
@@ -1185,11 +1303,11 @@ var createChannel = createAdminCommand({
|
|
|
1185
1303
|
redactDryRun: true,
|
|
1186
1304
|
prepare: (ctx) => ({
|
|
1187
1305
|
method: "POST",
|
|
1188
|
-
path: "/api/
|
|
1306
|
+
path: "/api/cli/channel/v1/channels",
|
|
1189
1307
|
body: createChannelBody(ctx)
|
|
1190
1308
|
})
|
|
1191
1309
|
});
|
|
1192
|
-
var updateChannel =
|
|
1310
|
+
var updateChannel = createCliChannelCommand({
|
|
1193
1311
|
command: "+update-channel",
|
|
1194
1312
|
description: "Update channel settings, credentials, model, prompt, or enabled state",
|
|
1195
1313
|
flags: [
|
|
@@ -1205,12 +1323,12 @@ var updateChannel = createAdminCommand({
|
|
|
1205
1323
|
risk: "write",
|
|
1206
1324
|
redactDryRun: true,
|
|
1207
1325
|
prepare: (ctx) => ({
|
|
1208
|
-
method: "
|
|
1209
|
-
path: `/api/
|
|
1326
|
+
method: "PATCH",
|
|
1327
|
+
path: `/api/cli/channel/v1/channels/${encodeId(ctx.str("id"))}`,
|
|
1210
1328
|
body: updateChannelBody(ctx)
|
|
1211
1329
|
})
|
|
1212
1330
|
});
|
|
1213
|
-
var removeChannel =
|
|
1331
|
+
var removeChannel = createCliChannelCommand({
|
|
1214
1332
|
command: "+remove-channel",
|
|
1215
1333
|
description: "Delete a channel, unbind its users, and stop its runtime connection",
|
|
1216
1334
|
flags: [
|
|
@@ -1219,14 +1337,427 @@ var removeChannel = createAdminCommand({
|
|
|
1219
1337
|
risk: "high-risk-write",
|
|
1220
1338
|
prepare: (ctx) => ({
|
|
1221
1339
|
method: "DELETE",
|
|
1222
|
-
path: `/api/
|
|
1340
|
+
path: `/api/cli/channel/v1/channels/${encodeId(ctx.str("id"))}`
|
|
1341
|
+
})
|
|
1342
|
+
});
|
|
1343
|
+
var verifyChannel = createCliChannelCommand({
|
|
1344
|
+
resource: "channel",
|
|
1345
|
+
command: "verify",
|
|
1346
|
+
description: "Verify channel credentials and discover endpoints",
|
|
1347
|
+
flags: [
|
|
1348
|
+
{ name: "id", type: "string", required: true, desc: "Channel ID from +list-channels" }
|
|
1349
|
+
],
|
|
1350
|
+
risk: "write",
|
|
1351
|
+
prepare: (ctx) => ({
|
|
1352
|
+
method: "POST",
|
|
1353
|
+
path: `/api/cli/channel/v1/channels/${encodeId(ctx.str("id"))}/verify`
|
|
1223
1354
|
})
|
|
1224
1355
|
});
|
|
1225
1356
|
var channelCommands = [
|
|
1226
1357
|
listChannels,
|
|
1358
|
+
getChannel,
|
|
1227
1359
|
createChannel,
|
|
1228
1360
|
updateChannel,
|
|
1229
|
-
removeChannel
|
|
1361
|
+
removeChannel,
|
|
1362
|
+
verifyChannel
|
|
1363
|
+
];
|
|
1364
|
+
|
|
1365
|
+
// src/commands/te-system/channel-routing.ts
|
|
1366
|
+
function routingBody(ctx) {
|
|
1367
|
+
const routing = requireJsonObject(ctx, "routing");
|
|
1368
|
+
if (routing.status !== "enabled" && routing.status !== "disabled") {
|
|
1369
|
+
throw new CliValidationError("--routing.status must be one of: enabled, disabled");
|
|
1370
|
+
}
|
|
1371
|
+
if (!("default_handler" in routing)) {
|
|
1372
|
+
throw new CliValidationError("--routing.default_handler is required and may be null");
|
|
1373
|
+
}
|
|
1374
|
+
if (!Array.isArray(routing.targets)) {
|
|
1375
|
+
throw new CliValidationError("--routing.targets must be a JSON array");
|
|
1376
|
+
}
|
|
1377
|
+
if (routing.targets.length > 19) {
|
|
1378
|
+
throw new CliValidationError("--routing.targets may contain at most 19 items");
|
|
1379
|
+
}
|
|
1380
|
+
return routing;
|
|
1381
|
+
}
|
|
1382
|
+
var getChannelRouting = createCliChannelCommand({
|
|
1383
|
+
resource: "channel routing",
|
|
1384
|
+
command: "get",
|
|
1385
|
+
description: "Get group message routing for one channel endpoint",
|
|
1386
|
+
flags: [
|
|
1387
|
+
{
|
|
1388
|
+
name: "endpoint-id",
|
|
1389
|
+
type: "string",
|
|
1390
|
+
required: true,
|
|
1391
|
+
desc: "Endpoint ID returned by channel get or channel verify"
|
|
1392
|
+
}
|
|
1393
|
+
],
|
|
1394
|
+
risk: "read",
|
|
1395
|
+
prepare: (ctx) => ({
|
|
1396
|
+
method: "GET",
|
|
1397
|
+
path: `/api/cli/channel/v1/endpoints/${encodeId(ctx.str("endpoint-id"))}/routing`
|
|
1398
|
+
})
|
|
1399
|
+
});
|
|
1400
|
+
var setChannelRouting = createCliChannelCommand({
|
|
1401
|
+
resource: "channel routing",
|
|
1402
|
+
command: "set",
|
|
1403
|
+
description: "Replace group message routing for one channel endpoint",
|
|
1404
|
+
flags: [
|
|
1405
|
+
{
|
|
1406
|
+
name: "endpoint-id",
|
|
1407
|
+
type: "string",
|
|
1408
|
+
required: true,
|
|
1409
|
+
desc: "Endpoint ID returned by channel get or channel verify"
|
|
1410
|
+
},
|
|
1411
|
+
{
|
|
1412
|
+
name: "routing",
|
|
1413
|
+
type: "string",
|
|
1414
|
+
required: true,
|
|
1415
|
+
desc: "Routing JSON object, @file, or stdin (-)"
|
|
1416
|
+
}
|
|
1417
|
+
],
|
|
1418
|
+
risk: "write",
|
|
1419
|
+
prepare: (ctx) => ({
|
|
1420
|
+
method: "PUT",
|
|
1421
|
+
path: `/api/cli/channel/v1/endpoints/${encodeId(ctx.str("endpoint-id"))}/routing`,
|
|
1422
|
+
body: routingBody(ctx)
|
|
1423
|
+
})
|
|
1424
|
+
});
|
|
1425
|
+
var channelRoutingCommands = [getChannelRouting, setChannelRouting];
|
|
1426
|
+
|
|
1427
|
+
// src/commands/te-system/channel-whatsapp.ts
|
|
1428
|
+
function whatsappWebPath(channelId) {
|
|
1429
|
+
return `/api/cli/channel/v1/channels/${encodeId(channelId)}/whatsapp-web`;
|
|
1430
|
+
}
|
|
1431
|
+
var getWhatsAppWebStatus = createCliChannelCommand({
|
|
1432
|
+
resource: "channel whatsapp-web",
|
|
1433
|
+
command: "status",
|
|
1434
|
+
description: "Get the WhatsApp Web link status for one channel",
|
|
1435
|
+
flags: [
|
|
1436
|
+
{ name: "id", type: "string", required: true, desc: "WhatsApp channel ID" }
|
|
1437
|
+
],
|
|
1438
|
+
risk: "read",
|
|
1439
|
+
prepare: (ctx) => ({ method: "GET", path: whatsappWebPath(ctx.str("id")) })
|
|
1440
|
+
});
|
|
1441
|
+
var startWhatsAppWebLink = createCliChannelCommand({
|
|
1442
|
+
resource: "channel whatsapp-web",
|
|
1443
|
+
command: "start",
|
|
1444
|
+
description: "Start or resume WhatsApp Web QR linking",
|
|
1445
|
+
flags: [
|
|
1446
|
+
{ name: "id", type: "string", required: true, desc: "WhatsApp channel ID" }
|
|
1447
|
+
],
|
|
1448
|
+
risk: "write",
|
|
1449
|
+
prepare: (ctx) => ({ method: "POST", path: whatsappWebPath(ctx.str("id")) })
|
|
1450
|
+
});
|
|
1451
|
+
var unlinkWhatsAppWeb = createCliChannelCommand({
|
|
1452
|
+
resource: "channel whatsapp-web",
|
|
1453
|
+
command: "unlink",
|
|
1454
|
+
description: "Unlink WhatsApp Web and remove its stored credentials",
|
|
1455
|
+
flags: [
|
|
1456
|
+
{ name: "id", type: "string", required: true, desc: "WhatsApp channel ID" }
|
|
1457
|
+
],
|
|
1458
|
+
risk: "high-risk-write",
|
|
1459
|
+
prepare: (ctx) => ({ method: "DELETE", path: whatsappWebPath(ctx.str("id")) })
|
|
1460
|
+
});
|
|
1461
|
+
var channelWhatsAppCommands = [
|
|
1462
|
+
getWhatsAppWebStatus,
|
|
1463
|
+
startWhatsAppWebLink,
|
|
1464
|
+
unlinkWhatsAppWeb
|
|
1465
|
+
];
|
|
1466
|
+
|
|
1467
|
+
// src/commands/te-system/channel-bindings.ts
|
|
1468
|
+
var BATCH_BINDING_KEYS = /* @__PURE__ */ new Set(["te_user_id", "open_id", "union_id", "agent_id"]);
|
|
1469
|
+
function requiredBatchString(item, key, index) {
|
|
1470
|
+
const value = item[key];
|
|
1471
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
1472
|
+
throw new CliValidationError(`--bindings[${index}].${key} is required`);
|
|
1473
|
+
}
|
|
1474
|
+
return value.trim();
|
|
1475
|
+
}
|
|
1476
|
+
function optionalBatchString(item, key, index) {
|
|
1477
|
+
if (item[key] === void 0) return void 0;
|
|
1478
|
+
return requiredBatchString(item, key, index);
|
|
1479
|
+
}
|
|
1480
|
+
function batchBindingPlan(ctx) {
|
|
1481
|
+
const input = requireJsonArray(ctx, "bindings");
|
|
1482
|
+
if (input.length < 1 || input.length > 100) {
|
|
1483
|
+
throw new CliValidationError("--bindings must contain between 1 and 100 items");
|
|
1484
|
+
}
|
|
1485
|
+
const endpointId = optionalString(ctx, "endpoint-id");
|
|
1486
|
+
const privateOnly = ctx.bool("private-only");
|
|
1487
|
+
if (privateOnly && endpointId) {
|
|
1488
|
+
throw new CliValidationError("--private-only cannot be combined with --endpoint-id");
|
|
1489
|
+
}
|
|
1490
|
+
if (!privateOnly && !endpointId) {
|
|
1491
|
+
throw new CliValidationError("--endpoint-id is required unless --private-only is true");
|
|
1492
|
+
}
|
|
1493
|
+
const bindings = input.map((raw, index) => {
|
|
1494
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
1495
|
+
throw new CliValidationError(`--bindings[${index}] must be a JSON object`);
|
|
1496
|
+
}
|
|
1497
|
+
const item = raw;
|
|
1498
|
+
const unknownKey = Object.keys(item).find((key) => !BATCH_BINDING_KEYS.has(key));
|
|
1499
|
+
if (unknownKey) {
|
|
1500
|
+
throw new CliValidationError(`--bindings[${index}].${unknownKey} is not supported`);
|
|
1501
|
+
}
|
|
1502
|
+
const unionId = optionalBatchString(item, "union_id", index);
|
|
1503
|
+
if (privateOnly && unionId) {
|
|
1504
|
+
throw new CliValidationError(
|
|
1505
|
+
`--bindings[${index}].union_id is not allowed with --private-only`
|
|
1506
|
+
);
|
|
1507
|
+
}
|
|
1508
|
+
if (!privateOnly && !unionId) {
|
|
1509
|
+
throw new CliValidationError(
|
|
1510
|
+
`--bindings[${index}].union_id is required unless --private-only is true`
|
|
1511
|
+
);
|
|
1512
|
+
}
|
|
1513
|
+
const agentId = optionalBatchString(item, "agent_id", index);
|
|
1514
|
+
return {
|
|
1515
|
+
te_user_id: requiredBatchString(item, "te_user_id", index),
|
|
1516
|
+
open_id: requiredBatchString(item, "open_id", index),
|
|
1517
|
+
...unionId ? { union_id: unionId } : {},
|
|
1518
|
+
...agentId ? { agent_id: agentId } : {}
|
|
1519
|
+
};
|
|
1520
|
+
});
|
|
1521
|
+
const defaultAgentId = optionalString(ctx, "default-agent-id");
|
|
1522
|
+
return {
|
|
1523
|
+
channelId: ctx.str("channel-id"),
|
|
1524
|
+
...endpointId ? { endpointId } : {},
|
|
1525
|
+
privateOnly,
|
|
1526
|
+
...defaultAgentId ? { defaultAgentId } : {},
|
|
1527
|
+
bindings
|
|
1528
|
+
};
|
|
1529
|
+
}
|
|
1530
|
+
function batchDryRunBody(plan) {
|
|
1531
|
+
return {
|
|
1532
|
+
channel_id: plan.channelId,
|
|
1533
|
+
...plan.endpointId ? { endpoint_id: plan.endpointId } : {},
|
|
1534
|
+
private_only: plan.privateOnly,
|
|
1535
|
+
...plan.defaultAgentId ? { default_agent_id: plan.defaultAgentId } : {},
|
|
1536
|
+
bindings: plan.bindings.map((binding) => ({
|
|
1537
|
+
...binding,
|
|
1538
|
+
...binding.agent_id || plan.defaultAgentId ? { agent_id: binding.agent_id ?? plan.defaultAgentId } : {}
|
|
1539
|
+
}))
|
|
1540
|
+
};
|
|
1541
|
+
}
|
|
1542
|
+
function batchError(error) {
|
|
1543
|
+
const value = error && typeof error === "object" ? error : {};
|
|
1544
|
+
return {
|
|
1545
|
+
message: typeof value.message === "string" ? value.message : String(error),
|
|
1546
|
+
...typeof value.code === "string" ? { code: value.code } : {},
|
|
1547
|
+
...typeof value.status === "number" ? { status: value.status } : {}
|
|
1548
|
+
};
|
|
1549
|
+
}
|
|
1550
|
+
function feishuBindingBody(ctx) {
|
|
1551
|
+
const unionId = optionalString(ctx, "union-id");
|
|
1552
|
+
const endpointId = optionalString(ctx, "endpoint-id");
|
|
1553
|
+
const privateOnly = ctx.bool("private-only");
|
|
1554
|
+
if (privateOnly && (unionId || endpointId)) {
|
|
1555
|
+
throw new CliValidationError(
|
|
1556
|
+
"--private-only cannot be combined with --union-id or --endpoint-id"
|
|
1557
|
+
);
|
|
1558
|
+
}
|
|
1559
|
+
if (!privateOnly && (!unionId || !endpointId)) {
|
|
1560
|
+
throw new CliValidationError(
|
|
1561
|
+
"--union-id and --endpoint-id are required unless --private-only is true"
|
|
1562
|
+
);
|
|
1563
|
+
}
|
|
1564
|
+
return {
|
|
1565
|
+
channel_id: ctx.str("channel-id"),
|
|
1566
|
+
te_user_id: ctx.str("te-user-id"),
|
|
1567
|
+
open_id: ctx.str("open-id"),
|
|
1568
|
+
...unionId && endpointId ? { union_id: unionId, endpoint_id: endpointId } : {}
|
|
1569
|
+
};
|
|
1570
|
+
}
|
|
1571
|
+
var listChannelBindings = createCliChannelCommand({
|
|
1572
|
+
resource: "channel binding",
|
|
1573
|
+
command: "list",
|
|
1574
|
+
description: "List channel user bindings",
|
|
1575
|
+
flags: [
|
|
1576
|
+
{ name: "channel-id", type: "string", desc: "Filter by channel ID" },
|
|
1577
|
+
{ name: "te-user-id", type: "string", desc: "Filter by AE user ID" },
|
|
1578
|
+
{ name: "open-id", type: "string", desc: "Filter by channel open ID" }
|
|
1579
|
+
],
|
|
1580
|
+
risk: "read",
|
|
1581
|
+
prepare: (ctx) => ({
|
|
1582
|
+
method: "GET",
|
|
1583
|
+
path: withQuery("/api/cli/channel/v1/bindings", {
|
|
1584
|
+
channel_id: optionalString(ctx, "channel-id"),
|
|
1585
|
+
te_user_id: optionalString(ctx, "te-user-id"),
|
|
1586
|
+
open_id: optionalString(ctx, "open-id")
|
|
1587
|
+
})
|
|
1588
|
+
})
|
|
1589
|
+
});
|
|
1590
|
+
var bindFeishuUser = createCliChannelCommand({
|
|
1591
|
+
resource: "channel binding",
|
|
1592
|
+
command: "bind-feishu",
|
|
1593
|
+
description: "Bind one Feishu user to a managed Feishu channel",
|
|
1594
|
+
flags: [
|
|
1595
|
+
{ name: "channel-id", type: "string", required: true, desc: "Feishu channel ID" },
|
|
1596
|
+
{ name: "te-user-id", type: "string", required: true, desc: "AE user ID to bind" },
|
|
1597
|
+
{ name: "open-id", type: "string", required: true, desc: "Feishu open_id" },
|
|
1598
|
+
{ name: "union-id", type: "string", desc: "Feishu union_id for group chat readiness" },
|
|
1599
|
+
{ name: "endpoint-id", type: "string", desc: "Verified Feishu endpoint ID" },
|
|
1600
|
+
{
|
|
1601
|
+
name: "private-only",
|
|
1602
|
+
type: "boolean",
|
|
1603
|
+
default: false,
|
|
1604
|
+
desc: "Create a private-chat-only binding without union_id or endpoint_id"
|
|
1605
|
+
}
|
|
1606
|
+
],
|
|
1607
|
+
risk: "write",
|
|
1608
|
+
prepare: (ctx) => ({
|
|
1609
|
+
method: "PUT",
|
|
1610
|
+
path: "/api/cli/channel/v1/bindings/feishu",
|
|
1611
|
+
body: feishuBindingBody(ctx)
|
|
1612
|
+
})
|
|
1613
|
+
});
|
|
1614
|
+
function createBindFeishuUsersCommand(dependencies = { put: putToMainApp }) {
|
|
1615
|
+
return {
|
|
1616
|
+
service: "system",
|
|
1617
|
+
command: "+bind-feishu-users",
|
|
1618
|
+
description: "Bind 1 to 100 Feishu users and optionally assign default Agents",
|
|
1619
|
+
flags: [
|
|
1620
|
+
{ name: "channel-id", type: "string", required: true, desc: "Feishu channel ID" },
|
|
1621
|
+
{
|
|
1622
|
+
name: "endpoint-id",
|
|
1623
|
+
type: "string",
|
|
1624
|
+
desc: "Verified Feishu endpoint ID shared by all group-ready bindings"
|
|
1625
|
+
},
|
|
1626
|
+
{
|
|
1627
|
+
name: "bindings",
|
|
1628
|
+
type: "string",
|
|
1629
|
+
required: true,
|
|
1630
|
+
sensitive: true,
|
|
1631
|
+
desc: "Array of 1 to 100 binding objects as JSON, @file, or stdin (-)"
|
|
1632
|
+
},
|
|
1633
|
+
{
|
|
1634
|
+
name: "default-agent-id",
|
|
1635
|
+
type: "string",
|
|
1636
|
+
desc: "Agent ID used when a binding does not provide agent_id"
|
|
1637
|
+
},
|
|
1638
|
+
{
|
|
1639
|
+
name: "private-only",
|
|
1640
|
+
type: "boolean",
|
|
1641
|
+
default: false,
|
|
1642
|
+
desc: "Create private-chat-only bindings without union_id or endpoint_id"
|
|
1643
|
+
}
|
|
1644
|
+
],
|
|
1645
|
+
risk: "write",
|
|
1646
|
+
dryRun: (ctx) => ({
|
|
1647
|
+
method: "PUT",
|
|
1648
|
+
url: "/api/cli/channel/v1/bindings/feishu",
|
|
1649
|
+
body: batchDryRunBody(batchBindingPlan(ctx))
|
|
1650
|
+
}),
|
|
1651
|
+
execute: async (ctx) => {
|
|
1652
|
+
const plan = batchBindingPlan(ctx);
|
|
1653
|
+
const host = ctx.host();
|
|
1654
|
+
const results = [];
|
|
1655
|
+
for (const [index, binding] of plan.bindings.entries()) {
|
|
1656
|
+
let bindingId;
|
|
1657
|
+
try {
|
|
1658
|
+
const path3 = "/api/cli/channel/v1/bindings/feishu";
|
|
1659
|
+
assertCliChannelPath(path3);
|
|
1660
|
+
const raw = await dependencies.put(
|
|
1661
|
+
path3,
|
|
1662
|
+
{
|
|
1663
|
+
channel_id: plan.channelId,
|
|
1664
|
+
te_user_id: binding.te_user_id,
|
|
1665
|
+
open_id: binding.open_id,
|
|
1666
|
+
...binding.union_id && plan.endpointId ? { union_id: binding.union_id, endpoint_id: plan.endpointId } : {}
|
|
1667
|
+
},
|
|
1668
|
+
host
|
|
1669
|
+
);
|
|
1670
|
+
const created = unwrapCliChannelResponse(raw);
|
|
1671
|
+
if (typeof created?.binding_id !== "string" || !created.binding_id) {
|
|
1672
|
+
throw new Error("Feishu binding response did not include binding_id");
|
|
1673
|
+
}
|
|
1674
|
+
bindingId = created.binding_id;
|
|
1675
|
+
const agentId = binding.agent_id ?? plan.defaultAgentId;
|
|
1676
|
+
if (agentId) {
|
|
1677
|
+
const agentPath = `/api/cli/channel/v1/bindings/${encodeId(bindingId)}/agent`;
|
|
1678
|
+
assertCliChannelPath(agentPath);
|
|
1679
|
+
await dependencies.put(agentPath, { agent_id: agentId }, host);
|
|
1680
|
+
}
|
|
1681
|
+
results.push({
|
|
1682
|
+
index,
|
|
1683
|
+
te_user_id: binding.te_user_id,
|
|
1684
|
+
status: "succeeded",
|
|
1685
|
+
binding_id: bindingId,
|
|
1686
|
+
group_routing_ready: created.group_routing_ready === true,
|
|
1687
|
+
...agentId ? { agent_id: agentId } : {}
|
|
1688
|
+
});
|
|
1689
|
+
} catch (error) {
|
|
1690
|
+
if (error instanceof PermissionError || error instanceof TeAgentApiError && error.status === 401) {
|
|
1691
|
+
throw error;
|
|
1692
|
+
}
|
|
1693
|
+
results.push({
|
|
1694
|
+
index,
|
|
1695
|
+
te_user_id: binding.te_user_id,
|
|
1696
|
+
status: "failed",
|
|
1697
|
+
stage: bindingId ? "agent_assignment" : "binding",
|
|
1698
|
+
...bindingId ? { binding_id: bindingId } : {},
|
|
1699
|
+
error: batchError(error)
|
|
1700
|
+
});
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
const succeeded = results.filter((result) => result.status === "succeeded").length;
|
|
1704
|
+
return {
|
|
1705
|
+
total: results.length,
|
|
1706
|
+
succeeded,
|
|
1707
|
+
failed: results.length - succeeded,
|
|
1708
|
+
results
|
|
1709
|
+
};
|
|
1710
|
+
}
|
|
1711
|
+
};
|
|
1712
|
+
}
|
|
1713
|
+
var bindFeishuUsers = createBindFeishuUsersCommand();
|
|
1714
|
+
var unbindChannelUser = createCliChannelCommand({
|
|
1715
|
+
resource: "channel binding",
|
|
1716
|
+
command: "unbind",
|
|
1717
|
+
description: "Delete one channel user binding",
|
|
1718
|
+
flags: [
|
|
1719
|
+
{ name: "binding-id", type: "string", required: true, desc: "Binding ID" }
|
|
1720
|
+
],
|
|
1721
|
+
risk: "high-risk-write",
|
|
1722
|
+
prepare: (ctx) => ({
|
|
1723
|
+
method: "DELETE",
|
|
1724
|
+
path: `/api/cli/channel/v1/bindings/${encodeId(ctx.str("binding-id"))}`
|
|
1725
|
+
})
|
|
1726
|
+
});
|
|
1727
|
+
var setChannelUserAgent = createCliChannelCommand({
|
|
1728
|
+
resource: "channel binding",
|
|
1729
|
+
command: "set-agent",
|
|
1730
|
+
description: "Set the private-chat default Agent for one channel user binding",
|
|
1731
|
+
flags: [
|
|
1732
|
+
{ name: "binding-id", type: "string", required: true, desc: "Binding ID" },
|
|
1733
|
+
{ name: "agent-id", type: "string", desc: "Agent ID to assign" },
|
|
1734
|
+
{
|
|
1735
|
+
name: "clear",
|
|
1736
|
+
type: "boolean",
|
|
1737
|
+
default: false,
|
|
1738
|
+
desc: "Clear the binding Agent and restore system-default resolution"
|
|
1739
|
+
}
|
|
1740
|
+
],
|
|
1741
|
+
risk: "write",
|
|
1742
|
+
prepare: (ctx) => {
|
|
1743
|
+
const agentId = optionalString(ctx, "agent-id");
|
|
1744
|
+
const clear = ctx.bool("clear");
|
|
1745
|
+
if (Boolean(agentId) === clear) {
|
|
1746
|
+
throw new CliValidationError("Pass exactly one of --agent-id or --clear");
|
|
1747
|
+
}
|
|
1748
|
+
return {
|
|
1749
|
+
method: "PUT",
|
|
1750
|
+
path: `/api/cli/channel/v1/bindings/${encodeId(ctx.str("binding-id"))}/agent`,
|
|
1751
|
+
body: { agent_id: clear ? null : agentId }
|
|
1752
|
+
};
|
|
1753
|
+
}
|
|
1754
|
+
});
|
|
1755
|
+
var channelBindingCommands = [
|
|
1756
|
+
listChannelBindings,
|
|
1757
|
+
bindFeishuUser,
|
|
1758
|
+
bindFeishuUsers,
|
|
1759
|
+
unbindChannelUser,
|
|
1760
|
+
setChannelUserAgent
|
|
1230
1761
|
];
|
|
1231
1762
|
|
|
1232
1763
|
// src/commands/te-system/sandbox-tools.ts
|
|
@@ -2205,6 +2736,9 @@ var commands = [
|
|
|
2205
2736
|
...usageCommands,
|
|
2206
2737
|
...costControlCommands,
|
|
2207
2738
|
...channelCommands,
|
|
2739
|
+
...channelRoutingCommands,
|
|
2740
|
+
...channelWhatsAppCommands,
|
|
2741
|
+
...channelBindingCommands,
|
|
2208
2742
|
...sandboxToolCommands
|
|
2209
2743
|
];
|
|
2210
2744
|
var te_system_default = commands;
|