@thinkingai/ae-cli 6.0.40 → 6.0.41
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 +0 -2
- package/README.zh.md +0 -2
- package/dist/{auth-NN55553T.js → auth-GBMV6TEJ.js} +2 -2
- package/dist/{auth-GDV3H5I4.js → auth-NDSXE54J.js} +4 -4
- package/dist/{capability-TPORIKRQ.js → capability-CETVHGXF.js} +25 -15
- package/dist/{capability-VQNC5CF7.js → capability-ZSQBMNOE.js} +25 -15
- package/dist/{chunk-GJJA4CQZ.js → chunk-3FY3RJ26.js} +0 -4
- package/dist/chunk-4E3DB4MM.js +556 -0
- package/dist/{chunk-GS2P7LFD.js → chunk-5XUSIK27.js} +2 -2
- package/dist/{chunk-VTXHDCBW.js → chunk-AFXA7BRK.js} +2 -2
- package/dist/{chunk-7KQWSBSL.js → chunk-FNZA5RZA.js} +8 -8
- package/dist/{chunk-TS6BUGUY.js → chunk-J2N4PB56.js} +8 -8
- package/dist/{chunk-RBNKI5ZW.js → chunk-JUW4AJXN.js} +2 -2
- package/dist/{chunk-Z3OXWCIA.js → chunk-S5NTSDBS.js} +2 -2
- package/dist/{chunk-VKD5WQKN.js → chunk-VLWOLBGZ.js} +142 -24
- package/dist/chunk-WANVG6SY.js +556 -0
- package/dist/{chunk-YTG6Q75E.js → chunk-WZRX4KOH.js} +25 -3
- package/dist/{chunk-YV52FB5G.js → chunk-ZQKDZXDO.js} +1 -1
- package/dist/{cli-token-GL5MS5FK.js → cli-token-4UPER74P.js} +3 -3
- package/dist/{chunk-6A2FUCIS.js → client-L2YDMHQ6.js} +5 -6
- package/dist/{config-4VZNLBKF.js → config-OL2LWGBV.js} +4 -33
- package/dist/index.js +31 -44
- package/dist/{memory-RWJW4XFO.js → memory-MUP7PPL7.js} +4 -4
- package/dist/{memory-VO2ZJCRT.js → memory-U4O5PMXH.js} +4 -4
- package/dist/{metadata-YGTHR2XJ.js → metadata-UKZDNLLQ.js} +21 -11
- package/dist/{metadata-ZRN2GHPN.js → metadata-XXMJFN2M.js} +21 -11
- package/dist/{model-CLUIK3K5.js → model-JTUEO5M4.js} +2 -2
- package/dist/{sync-3REDHGY6.js → sync-MOSFNBVR.js} +5 -5
- package/dist/{te-agent-XNPELAKX.js → te-agent-IFKZDHZI.js} +25 -18
- package/dist/{te-analysis-GJI5FZUL.js → te-analysis-3QLLS35K.js} +1231 -456
- package/dist/{te-analysis-N2BRDJZ5.js → te-analysis-YSK2DBVL.js} +1231 -456
- package/dist/{te-community-SQXKE5OO.js → te-community-HNKVTERD.js} +207 -12
- package/dist/{te-community-TYSNU3NQ.js → te-community-IWE5B7W6.js} +208 -12
- package/dist/{te-dataops-OWIADNSM.js → te-dataops-KQPYNAE3.js} +262 -145
- package/dist/{te-dataops-5TM7WZDI.js → te-dataops-KXCEB4CS.js} +262 -145
- package/dist/{te-engage-L72HWRGO.js → te-engage-6RNGK5GH.js} +566 -17
- package/dist/{te-engage-QWM4GFS7.js → te-engage-IRMHTSQK.js} +566 -17
- package/dist/{te-kb-VRMEY3D4.js → te-kb-OIH3T6CS.js} +4 -4
- package/dist/{te-system-XGS5EQIQ.js → te-system-AZ3URMUO.js} +515 -11
- package/dist/{te-team-BZRDV2CM.js → te-team-GZPU6UWA.js} +5 -5
- package/dist/{update-HEDXGOJH.js → update-TOBFXF2V.js} +4 -4
- package/package.json +5 -5
- package/skills/ae-agent/SKILL.md +3 -3
- package/skills/ae-agent/references/list-skill-references.md +4 -4
- package/skills/ae-agent/references/read-skill-reference.md +10 -7
- package/skills/ae-agent/references/upload-skill-reference.md +11 -9
- package/skills/ae-analysis/SKILL.md +15 -12
- package/skills/ae-analysis/metadata_resolution.md +150 -0
- package/skills/ae-analysis/references/adhoc_export.md +17 -2
- package/skills/ae-analysis/references/adhoc_run.md +12 -8
- package/skills/ae-analysis/references/ai_models.md +31 -5
- package/skills/ae-analysis/references/analysis_data_retrieval.md +104 -16
- package/skills/ae-analysis/references/analysis_drilldown_contract.md +4 -4
- package/skills/ae-analysis/references/analysis_gateway_assets.md +12 -10
- package/skills/ae-analysis/references/artifact_download.md +4 -3
- package/skills/ae-analysis/references/asset_abnormal_list.md +5 -3
- package/skills/ae-analysis/references/asset_authentication_list.md +5 -3
- package/skills/ae-analysis/references/asset_search.md +5 -3
- package/skills/ae-analysis/references/bi_panel_page_data_export.md +1 -1
- package/skills/ae-analysis/references/bi_panel_page_data_run.md +4 -4
- package/skills/ae-analysis/references/catalog_export.md +28 -0
- package/skills/ae-analysis/references/catalog_list.md +44 -0
- package/skills/ae-analysis/references/command_index.md +72 -63
- package/skills/ae-analysis/references/dashboard_report_data_run.md +11 -4
- package/skills/ae-analysis/references/datatable_version_list.md +5 -3
- package/skills/ae-analysis/references/drilldown_entities_run.md +4 -4
- package/skills/ae-analysis/references/drilldown_events_run.md +2 -2
- package/skills/ae-analysis/references/drilldown_user_events_export.md +1 -1
- package/skills/ae-analysis/references/drilldown_user_events_run.md +2 -2
- package/skills/ae-analysis/references/entity_detail_run.md +4 -4
- package/skills/ae-analysis/references/entity_id_import_options.md +1 -1
- package/skills/ae-analysis/references/event_detail_run.md +4 -4
- package/skills/ae-analysis/references/event_export.md +21 -0
- package/skills/ae-analysis/references/event_list.md +7 -6
- package/skills/ae-analysis/references/exchange_rule_list.md +5 -3
- package/skills/ae-analysis/references/history_tag_data_drilldown_export.md +4 -2
- package/skills/ae-analysis/references/history_tag_data_drilldown_run.md +2 -2
- package/skills/ae-analysis/references/history_tag_data_run.md +2 -2
- package/skills/ae-analysis/references/metric_export.md +21 -0
- package/skills/ae-analysis/references/metric_list.md +8 -7
- package/skills/ae-analysis/references/property_export.md +21 -0
- package/skills/ae-analysis/references/property_list.md +9 -8
- package/skills/ae-analysis/references/query_context_get.md +20 -0
- package/skills/ae-analysis/references/query_create_result_cluster.md +1 -1
- package/skills/ae-analysis/references/report_change_log_list.md +1 -1
- package/skills/ae-analysis/references/report_create.md +3 -3
- package/skills/ae-analysis/references/report_data_run.md +8 -8
- package/skills/ae-analysis/references/report_update.md +3 -3
- package/skills/ae-analysis/references/report_version_rollback.md +1 -1
- package/skills/ae-analysis/references/rule_list.md +6 -4
- package/skills/ae-analysis/references/run_inspect.md +8 -5
- package/skills/ae-analysis/references/run_wait.md +37 -0
- package/skills/ae-analysis/references/user_cluster_export.md +13 -0
- package/skills/ae-analysis/references/user_cluster_list.md +6 -2
- package/skills/ae-analysis/references/user_cluster_member_export.md +5 -3
- package/skills/ae-analysis/references/user_cluster_member_list.md +4 -4
- package/skills/ae-analysis/references/user_tag_export.md +13 -0
- package/skills/ae-analysis/references/user_tag_list.md +6 -2
- package/skills/ae-analysis/references/user_tag_member_export.md +5 -3
- package/skills/ae-analysis/references/user_tag_member_list.md +4 -4
- package/skills/ae-analysis/references/virtual_property_create.md +2 -2
- package/skills/ae-community/SKILL.md +2 -2
- package/skills/ae-dataops/SKILL.md +4 -3
- package/skills/ae-dataops/references/dataops-flow-create.md +47 -3
- package/skills/ae-engage/SKILL.md +46 -6
- package/skills/ae-engage/references/build-task-save-guide.md +12 -0
- package/skills/ae-engage/references/cancel-query-run.md +31 -0
- package/skills/ae-engage/references/config-item-analysis-report.md +14 -1
- package/skills/ae-engage/references/config-item-strategy-comparison.md +11 -1
- package/skills/ae-engage/references/config-item-trigger-report.md +15 -1
- package/skills/ae-engage/references/flow-metric-detail-report.md +134 -0
- package/skills/ae-engage/references/flow-metric-update.md +77 -0
- package/skills/ae-engage/references/flow-metric-user.md +118 -0
- package/skills/ae-engage/references/flow-node-metric-user.md +122 -0
- package/skills/ae-engage/references/flow-node-user.md +122 -0
- package/skills/ae-engage/references/push-record-query.md +32 -1
- package/skills/ae-engage/references/save-task.md +9 -0
- package/skills/ae-engage/references/task-data-detail.md +9 -2
- package/skills/ae-engage/references/task-metric-detail.md +9 -2
- package/skills/ae-engage/references/task-submit-approval.md +3 -0
- package/skills/ae-metadata/SKILL.md +2 -1
- package/skills/ae-metadata/references/metadata_data_table_download.md +10 -2
- package/skills/ae-metadata/references/metadata_data_table_list.md +5 -2
- package/skills/ae-system/SKILL.md +66 -3
- package/dist/chunk-DT6Y3TD7.js +0 -232
- package/dist/chunk-MVDZ7DBQ.js +0 -231
- package/dist/chunk-NBPKWKRA.js +0 -51
- package/dist/client-DAIPF7XN.js +0 -23
- package/dist/raw-52B4UKO4.js +0 -71
- package/dist/te-meta-53BVXPFI.js +0 -95
- package/dist/te-meta-TOCBPBXI.js +0 -95
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
deleteFromMainApp,
|
|
3
|
+
downloadFromMainApp,
|
|
3
4
|
getFromMainApp,
|
|
4
5
|
patchToMainApp,
|
|
5
6
|
postToMainApp,
|
|
6
7
|
putToMainApp,
|
|
7
8
|
tryLoadTeAgentSandboxCredentials,
|
|
8
9
|
uploadToMainApp
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-VLWOLBGZ.js";
|
|
10
11
|
import {
|
|
11
12
|
safeJsonParse
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-3FY3RJ26.js";
|
|
13
14
|
import {
|
|
14
15
|
CliValidationError
|
|
15
16
|
} from "./chunk-AXDXJTPC.js";
|
|
@@ -38,6 +39,10 @@ async function uploadAdminForm(path3, formData, host) {
|
|
|
38
39
|
assertAdminPath(path3);
|
|
39
40
|
return uploadToMainApp(path3, formData, host);
|
|
40
41
|
}
|
|
42
|
+
async function downloadAdmin(path3, outputPath, host) {
|
|
43
|
+
assertAdminPath(path3);
|
|
44
|
+
return downloadFromMainApp(path3, outputPath, host);
|
|
45
|
+
}
|
|
41
46
|
async function executeAdminRequest(ctx, request) {
|
|
42
47
|
assertAdminPath(request.path);
|
|
43
48
|
const host = ctx.host();
|
|
@@ -79,6 +84,30 @@ function createAdminCommand(config) {
|
|
|
79
84
|
execute: async (ctx) => executeAdminRequest(ctx, config.prepare(ctx))
|
|
80
85
|
};
|
|
81
86
|
}
|
|
87
|
+
function createAdminDownloadCommand(config) {
|
|
88
|
+
return {
|
|
89
|
+
service: "system",
|
|
90
|
+
command: config.command,
|
|
91
|
+
description: config.description,
|
|
92
|
+
flags: config.flags,
|
|
93
|
+
risk: "read",
|
|
94
|
+
helpText: config.helpText,
|
|
95
|
+
validate: config.validate,
|
|
96
|
+
dryRun: (ctx) => {
|
|
97
|
+
const request = config.prepare(ctx);
|
|
98
|
+
assertAdminPath(request.path);
|
|
99
|
+
return {
|
|
100
|
+
method: "GET",
|
|
101
|
+
url: request.path,
|
|
102
|
+
body: { outputPath: request.outputPath }
|
|
103
|
+
};
|
|
104
|
+
},
|
|
105
|
+
execute: async (ctx) => {
|
|
106
|
+
const request = config.prepare(ctx);
|
|
107
|
+
return downloadAdmin(request.path, request.outputPath, ctx.host());
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
82
111
|
function optionalString(ctx, name) {
|
|
83
112
|
const value = ctx.str(name).trim();
|
|
84
113
|
return value || void 0;
|
|
@@ -133,6 +162,10 @@ function requireJsonObject(ctx, name) {
|
|
|
133
162
|
}
|
|
134
163
|
return value;
|
|
135
164
|
}
|
|
165
|
+
function optionalJsonObject(ctx, name) {
|
|
166
|
+
if (!optionalString(ctx, name)) return void 0;
|
|
167
|
+
return requireJsonObject(ctx, name);
|
|
168
|
+
}
|
|
136
169
|
function requireJsonArray(ctx, name) {
|
|
137
170
|
const value = readJsonFlag(ctx, name);
|
|
138
171
|
if (!Array.isArray(value)) {
|
|
@@ -145,7 +178,17 @@ function requireStringArray(ctx, name) {
|
|
|
145
178
|
if (value.length === 0 || value.some((item) => typeof item !== "string" || !item.trim())) {
|
|
146
179
|
throw new CliValidationError(`--${name} must be a non-empty JSON array of strings`);
|
|
147
180
|
}
|
|
148
|
-
return value;
|
|
181
|
+
return value.map((item) => item.trim());
|
|
182
|
+
}
|
|
183
|
+
function requireBoundedStringArray(ctx, name, max) {
|
|
184
|
+
const values = requireStringArray(ctx, name);
|
|
185
|
+
if (values.length > max) {
|
|
186
|
+
throw new CliValidationError(`--${name} supports at most ${max} values`);
|
|
187
|
+
}
|
|
188
|
+
if (new Set(values).size !== values.length) {
|
|
189
|
+
throw new CliValidationError(`--${name} must not contain duplicate values`);
|
|
190
|
+
}
|
|
191
|
+
return values;
|
|
149
192
|
}
|
|
150
193
|
function redactSecrets(value) {
|
|
151
194
|
if (Array.isArray(value)) return value.map(redactSecrets);
|
|
@@ -306,13 +349,29 @@ var removeMember = createAdminCommand({
|
|
|
306
349
|
path: `/api/admin/members/${encodeId(ctx.str("user-id"))}`
|
|
307
350
|
})
|
|
308
351
|
});
|
|
352
|
+
var getMemberStats = createAdminCommand({
|
|
353
|
+
command: "+get-member-stats",
|
|
354
|
+
description: "Get token usage and recent conversation statistics for one company member",
|
|
355
|
+
flags: [
|
|
356
|
+
{ name: "user-id", type: "string", required: true, desc: "Agent database user ID from +list-members" },
|
|
357
|
+
{ name: "days", type: "number", min: 1, max: 365, desc: "Recent range in days (1-365, default: 30)" }
|
|
358
|
+
],
|
|
359
|
+
risk: "read",
|
|
360
|
+
prepare: (ctx) => ({
|
|
361
|
+
method: "GET",
|
|
362
|
+
path: withQuery(`/api/admin/members/${encodeId(ctx.str("user-id"))}/stats`, {
|
|
363
|
+
days: ctx.optionalNum("days")
|
|
364
|
+
})
|
|
365
|
+
})
|
|
366
|
+
});
|
|
309
367
|
var memberCommands = [
|
|
310
368
|
listMemberCandidates,
|
|
311
369
|
listMembers,
|
|
312
370
|
addMembers,
|
|
313
371
|
setMemberStatus,
|
|
314
372
|
setMemberRole,
|
|
315
|
-
removeMember
|
|
373
|
+
removeMember,
|
|
374
|
+
getMemberStats
|
|
316
375
|
];
|
|
317
376
|
|
|
318
377
|
// src/commands/te-system/sandboxes.ts
|
|
@@ -333,6 +392,13 @@ var listSandboxes = createAdminCommand({
|
|
|
333
392
|
risk: "read",
|
|
334
393
|
prepare: () => ({ method: "GET", path: "/api/admin/sandboxes" })
|
|
335
394
|
});
|
|
395
|
+
var getSandboxConfig = createAdminCommand({
|
|
396
|
+
command: "+get-sandbox-config",
|
|
397
|
+
description: "Get sandbox feature status and company create/active seat limits",
|
|
398
|
+
flags: [],
|
|
399
|
+
risk: "read",
|
|
400
|
+
prepare: () => ({ method: "GET", path: "/api/admin/sandbox/config" })
|
|
401
|
+
});
|
|
336
402
|
var batchCreateSandboxes = createAdminCommand({
|
|
337
403
|
command: "+batch-create-sandboxes",
|
|
338
404
|
description: "Create personal sandboxes for up to 100 company members",
|
|
@@ -471,6 +537,7 @@ var removeSandbox = createAdminCommand({
|
|
|
471
537
|
});
|
|
472
538
|
var sandboxCommands = [
|
|
473
539
|
listSandboxes,
|
|
540
|
+
getSandboxConfig,
|
|
474
541
|
batchCreateSandboxes,
|
|
475
542
|
updateSandbox,
|
|
476
543
|
setSandboxEnabled,
|
|
@@ -505,6 +572,45 @@ var setSystemModelEnabled = createAdminCommand({
|
|
|
505
572
|
body: { enabled: ctx.bool("enabled") }
|
|
506
573
|
})
|
|
507
574
|
});
|
|
575
|
+
var getModelSyncSettings = createAdminCommand({
|
|
576
|
+
command: "+get-model-sync-settings",
|
|
577
|
+
description: "Get the company policy for newly synchronized system models",
|
|
578
|
+
flags: [],
|
|
579
|
+
risk: "read",
|
|
580
|
+
prepare: () => ({ method: "GET", path: "/api/admin/models/sync-settings" })
|
|
581
|
+
});
|
|
582
|
+
var setModelSyncSettings = createAdminCommand({
|
|
583
|
+
command: "+set-model-sync-settings",
|
|
584
|
+
description: "Set whether newly synchronized system models are enabled for the company",
|
|
585
|
+
flags: [
|
|
586
|
+
{
|
|
587
|
+
name: "new-system-models-enabled-by-default",
|
|
588
|
+
type: "boolean",
|
|
589
|
+
required: true,
|
|
590
|
+
desc: "Whether future system models are enabled for this company by default"
|
|
591
|
+
}
|
|
592
|
+
],
|
|
593
|
+
risk: "write",
|
|
594
|
+
prepare: (ctx) => ({
|
|
595
|
+
method: "PATCH",
|
|
596
|
+
path: "/api/admin/models/sync-settings",
|
|
597
|
+
body: {
|
|
598
|
+
newSystemModelsEnabledByDefault: ctx.bool("new-system-models-enabled-by-default")
|
|
599
|
+
}
|
|
600
|
+
})
|
|
601
|
+
});
|
|
602
|
+
var getSystemModelPriceRules = createAdminCommand({
|
|
603
|
+
command: "+get-system-model-price-rules",
|
|
604
|
+
description: "Get the stored pricing rule snapshot for one managed system model",
|
|
605
|
+
flags: [
|
|
606
|
+
{ name: "model-id", type: "string", required: true, desc: "System Model.id from +list-system-models" }
|
|
607
|
+
],
|
|
608
|
+
risk: "read",
|
|
609
|
+
prepare: (ctx) => ({
|
|
610
|
+
method: "GET",
|
|
611
|
+
path: `/api/admin/system-models/${encodeId(ctx.str("model-id"))}/price-rules`
|
|
612
|
+
})
|
|
613
|
+
});
|
|
508
614
|
var listCompanyModels = createAdminCommand({
|
|
509
615
|
command: "+list-company-models",
|
|
510
616
|
description: "List all company models, including disabled models",
|
|
@@ -579,6 +685,9 @@ var clearDefaultModel = createAdminCommand({
|
|
|
579
685
|
var modelCommands = [
|
|
580
686
|
listSystemModels,
|
|
581
687
|
setSystemModelEnabled,
|
|
688
|
+
getModelSyncSettings,
|
|
689
|
+
setModelSyncSettings,
|
|
690
|
+
getSystemModelPriceRules,
|
|
582
691
|
listCompanyModels,
|
|
583
692
|
setCompanyModelEnabled,
|
|
584
693
|
getDefaultModels,
|
|
@@ -587,18 +696,27 @@ var modelCommands = [
|
|
|
587
696
|
];
|
|
588
697
|
|
|
589
698
|
// src/commands/te-system/usage.ts
|
|
699
|
+
import { resolve } from "path";
|
|
590
700
|
var GROUP_BY = ["user", "model", "date", "app_type"];
|
|
591
701
|
var SORT_BY = ["totalTokens", "cost", "share", "requestCount"];
|
|
592
702
|
var SORT_DIRECTIONS2 = ["asc", "desc"];
|
|
703
|
+
var EXPORT_SCOPES = ["full", "drill"];
|
|
593
704
|
var DATE_PATTERN = "^\\d{4}-\\d{2}-\\d{2}$";
|
|
594
|
-
function validateDatePair(ctx, required) {
|
|
705
|
+
function validateDatePair(ctx, required, supportsDays = false) {
|
|
595
706
|
const startDate = optionalString(ctx, "start-date");
|
|
596
707
|
const endDate = optionalString(ctx, "end-date");
|
|
708
|
+
const days = ctx.optionalNum("days");
|
|
597
709
|
if (Boolean(startDate) !== Boolean(endDate)) {
|
|
598
710
|
throw new CliValidationError("--start-date and --end-date must be provided together");
|
|
599
711
|
}
|
|
600
712
|
if (required && (!startDate || !endDate)) {
|
|
601
|
-
throw new CliValidationError("--start-date and --end-date are required
|
|
713
|
+
throw new CliValidationError("--start-date and --end-date are required");
|
|
714
|
+
}
|
|
715
|
+
if (supportsDays && days !== void 0 && startDate) {
|
|
716
|
+
throw new CliValidationError("--days cannot be combined with --start-date/--end-date");
|
|
717
|
+
}
|
|
718
|
+
if (startDate && endDate && startDate > endDate) {
|
|
719
|
+
throw new CliValidationError("--start-date cannot be later than --end-date");
|
|
602
720
|
}
|
|
603
721
|
}
|
|
604
722
|
function usageRangeQuery(ctx) {
|
|
@@ -608,6 +726,64 @@ function usageRangeQuery(ctx) {
|
|
|
608
726
|
endDate: optionalString(ctx, "end-date")
|
|
609
727
|
};
|
|
610
728
|
}
|
|
729
|
+
function usageCombinationQuery(ctx) {
|
|
730
|
+
return {
|
|
731
|
+
startDate: ctx.str("start-date"),
|
|
732
|
+
endDate: ctx.str("end-date"),
|
|
733
|
+
parentDimension: ctx.str("parent-dimension"),
|
|
734
|
+
openId: optionalString(ctx, "open-id"),
|
|
735
|
+
modelId: optionalString(ctx, "model-id"),
|
|
736
|
+
modelScope: optionalString(ctx, "model-scope"),
|
|
737
|
+
appType: optionalString(ctx, "app-type"),
|
|
738
|
+
date: optionalString(ctx, "date"),
|
|
739
|
+
page: ctx.optionalNum("page"),
|
|
740
|
+
pageSize: ctx.optionalNum("page-size"),
|
|
741
|
+
sortBy: optionalString(ctx, "sort-by") || "totalTokens",
|
|
742
|
+
sortDir: optionalString(ctx, "sort-dir") || "desc"
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
function validateUsageCombination(ctx) {
|
|
746
|
+
validateDatePair(ctx, true);
|
|
747
|
+
const parent = optionalString(ctx, "parent-dimension");
|
|
748
|
+
assertEnum("parent-dimension", parent, GROUP_BY);
|
|
749
|
+
assertEnum("sort-by", optionalString(ctx, "sort-by"), SORT_BY);
|
|
750
|
+
assertEnum("sort-dir", optionalString(ctx, "sort-dir"), SORT_DIRECTIONS2);
|
|
751
|
+
const openId = optionalString(ctx, "open-id");
|
|
752
|
+
const modelId = optionalString(ctx, "model-id");
|
|
753
|
+
const modelScope = optionalString(ctx, "model-scope");
|
|
754
|
+
const appType = optionalString(ctx, "app-type");
|
|
755
|
+
const date = optionalString(ctx, "date");
|
|
756
|
+
const supplied = [openId, modelId, modelScope, appType, date].filter(Boolean).length;
|
|
757
|
+
if (parent === "user" && (!openId || supplied !== 1)) {
|
|
758
|
+
throw new CliValidationError("user drill-down requires only --open-id");
|
|
759
|
+
}
|
|
760
|
+
if (parent === "model" && (!modelId || !modelScope || supplied !== 2)) {
|
|
761
|
+
throw new CliValidationError("model drill-down requires only --model-id and --model-scope");
|
|
762
|
+
}
|
|
763
|
+
if (parent === "app_type" && (!appType || supplied !== 1)) {
|
|
764
|
+
throw new CliValidationError("app_type drill-down requires only --app-type");
|
|
765
|
+
}
|
|
766
|
+
if (parent === "date" && (!date || supplied !== 1)) {
|
|
767
|
+
throw new CliValidationError("date drill-down requires only --date");
|
|
768
|
+
}
|
|
769
|
+
if (date && (date < ctx.str("start-date") || date > ctx.str("end-date"))) {
|
|
770
|
+
throw new CliValidationError("--date must be within --start-date and --end-date");
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
var COMBINATION_FLAGS = [
|
|
774
|
+
{ name: "start-date", type: "string", required: true, pattern: DATE_PATTERN, desc: "Start date (YYYY-MM-DD)" },
|
|
775
|
+
{ name: "end-date", type: "string", required: true, pattern: DATE_PATTERN, desc: "End date (YYYY-MM-DD)" },
|
|
776
|
+
{ name: "parent-dimension", type: "string", required: true, desc: `Parent dimension: ${GROUP_BY.join(" | ")}` },
|
|
777
|
+
{ name: "open-id", type: "string", desc: "Required only for user drill-down" },
|
|
778
|
+
{ name: "model-id", type: "string", desc: "Required only for model drill-down" },
|
|
779
|
+
{ name: "model-scope", type: "string", desc: "Required only for model drill-down" },
|
|
780
|
+
{ name: "app-type", type: "string", desc: "Required only for app_type drill-down" },
|
|
781
|
+
{ name: "date", type: "string", pattern: DATE_PATTERN, desc: "Required only for date drill-down" },
|
|
782
|
+
{ name: "page", type: "number", min: 1, desc: "Page number (default: 1)" },
|
|
783
|
+
{ name: "page-size", type: "number", min: 1, max: 100, desc: "Page size (1-100, default: 20)" },
|
|
784
|
+
{ name: "sort-by", type: "string", default: "totalTokens", desc: `Sort by: ${SORT_BY.join(" | ")}` },
|
|
785
|
+
{ name: "sort-dir", type: "string", default: "desc", desc: `Sort direction: ${SORT_DIRECTIONS2.join(" | ")}` }
|
|
786
|
+
];
|
|
611
787
|
var getUsageSummary = createAdminCommand({
|
|
612
788
|
command: "+get-usage-summary",
|
|
613
789
|
description: "Get company token and cost usage summary",
|
|
@@ -624,13 +800,17 @@ var getUsageSummary = createAdminCommand({
|
|
|
624
800
|
type: "string",
|
|
625
801
|
pattern: DATE_PATTERN,
|
|
626
802
|
desc: "End date (YYYY-MM-DD); requires --start-date"
|
|
627
|
-
}
|
|
803
|
+
},
|
|
804
|
+
{ name: "refresh", type: "boolean", desc: "Bypass the cached overview and refresh from the source" }
|
|
628
805
|
],
|
|
629
806
|
risk: "read",
|
|
630
|
-
validate: (ctx) => validateDatePair(ctx, false),
|
|
807
|
+
validate: (ctx) => validateDatePair(ctx, false, true),
|
|
631
808
|
prepare: (ctx) => ({
|
|
632
809
|
method: "GET",
|
|
633
|
-
path: withQuery("/api/admin/stats/summary",
|
|
810
|
+
path: withQuery("/api/admin/stats/summary", {
|
|
811
|
+
...usageRangeQuery(ctx),
|
|
812
|
+
refresh: ctx.bool("refresh") ? "true" : void 0
|
|
813
|
+
})
|
|
634
814
|
})
|
|
635
815
|
});
|
|
636
816
|
var getUsageDetails = createAdminCommand({
|
|
@@ -690,7 +870,117 @@ var getUsageDetails = createAdminCommand({
|
|
|
690
870
|
})
|
|
691
871
|
})
|
|
692
872
|
});
|
|
693
|
-
var
|
|
873
|
+
var getAgentToolCalls = createAdminCommand({
|
|
874
|
+
command: "+get-agent-tool-calls",
|
|
875
|
+
description: "Get the company Agent tool-call count for a usage range",
|
|
876
|
+
flags: [
|
|
877
|
+
{ name: "days", type: "number", min: 1, max: 365, desc: "Relative range in days (1-365, default: 30)" },
|
|
878
|
+
{ name: "start-date", type: "string", pattern: DATE_PATTERN, desc: "Start date (YYYY-MM-DD); requires --end-date" },
|
|
879
|
+
{ name: "end-date", type: "string", pattern: DATE_PATTERN, desc: "End date (YYYY-MM-DD); requires --start-date" },
|
|
880
|
+
{ name: "refresh", type: "boolean", desc: "Bypass the cached overview and refresh from the source" }
|
|
881
|
+
],
|
|
882
|
+
risk: "read",
|
|
883
|
+
validate: (ctx) => validateDatePair(ctx, false, true),
|
|
884
|
+
prepare: (ctx) => ({
|
|
885
|
+
method: "GET",
|
|
886
|
+
path: withQuery("/api/admin/stats/agent-tool-calls", {
|
|
887
|
+
...usageRangeQuery(ctx),
|
|
888
|
+
refresh: ctx.bool("refresh") ? "true" : void 0
|
|
889
|
+
})
|
|
890
|
+
})
|
|
891
|
+
});
|
|
892
|
+
var getUsageCombinations = createAdminCommand({
|
|
893
|
+
command: "+get-usage-combinations",
|
|
894
|
+
description: "Drill one usage group into the remaining dimensions",
|
|
895
|
+
flags: COMBINATION_FLAGS,
|
|
896
|
+
risk: "read",
|
|
897
|
+
validate: validateUsageCombination,
|
|
898
|
+
prepare: (ctx) => ({
|
|
899
|
+
method: "GET",
|
|
900
|
+
path: withQuery("/api/admin/stats/combinations", usageCombinationQuery(ctx))
|
|
901
|
+
})
|
|
902
|
+
});
|
|
903
|
+
var exportUsage = createAdminDownloadCommand({
|
|
904
|
+
command: "+export-usage",
|
|
905
|
+
description: "Export filtered one-dimension usage groups to a CSV file",
|
|
906
|
+
flags: [
|
|
907
|
+
{ name: "start-date", type: "string", required: true, pattern: DATE_PATTERN, desc: "Start date (YYYY-MM-DD)" },
|
|
908
|
+
{ name: "end-date", type: "string", required: true, pattern: DATE_PATTERN, desc: "End date (YYYY-MM-DD)" },
|
|
909
|
+
{ name: "group-by", type: "string", default: "user", desc: `Group by: ${GROUP_BY.join(" | ")}` },
|
|
910
|
+
{ name: "search", type: "string", maxLength: 100, desc: "Optional search text (max 100 characters)" },
|
|
911
|
+
{ name: "open-id", type: "string", desc: "Filter by TE user openId" },
|
|
912
|
+
{ name: "model-id", type: "string", desc: "Filter by model ID" },
|
|
913
|
+
{ name: "model-scope", type: "string", desc: "Model scope; requires --model-id" },
|
|
914
|
+
{ name: "app-type", type: "string", desc: "Filter by product/application type" },
|
|
915
|
+
{ name: "sort-by", type: "string", default: "totalTokens", desc: `Sort by: ${SORT_BY.join(" | ")}` },
|
|
916
|
+
{ name: "sort-dir", type: "string", default: "desc", desc: `Sort direction: ${SORT_DIRECTIONS2.join(" | ")}` },
|
|
917
|
+
{ name: "output", type: "string", required: true, desc: "New local CSV path; existing files are never overwritten" }
|
|
918
|
+
],
|
|
919
|
+
validate: (ctx) => {
|
|
920
|
+
validateDatePair(ctx, true);
|
|
921
|
+
assertEnum("group-by", optionalString(ctx, "group-by"), GROUP_BY);
|
|
922
|
+
assertEnum("sort-by", optionalString(ctx, "sort-by"), SORT_BY);
|
|
923
|
+
assertEnum("sort-dir", optionalString(ctx, "sort-dir"), SORT_DIRECTIONS2);
|
|
924
|
+
if (optionalString(ctx, "model-scope") && !optionalString(ctx, "model-id")) {
|
|
925
|
+
throw new CliValidationError("--model-scope requires --model-id");
|
|
926
|
+
}
|
|
927
|
+
},
|
|
928
|
+
prepare: (ctx) => ({
|
|
929
|
+
path: withQuery("/api/admin/stats/export", {
|
|
930
|
+
startDate: ctx.str("start-date"),
|
|
931
|
+
endDate: ctx.str("end-date"),
|
|
932
|
+
groupBy: ctx.str("group-by") || "user",
|
|
933
|
+
search: optionalString(ctx, "search"),
|
|
934
|
+
openId: optionalString(ctx, "open-id"),
|
|
935
|
+
modelId: optionalString(ctx, "model-id"),
|
|
936
|
+
modelScope: optionalString(ctx, "model-scope"),
|
|
937
|
+
appType: optionalString(ctx, "app-type"),
|
|
938
|
+
sortBy: ctx.str("sort-by") || "totalTokens",
|
|
939
|
+
sortDir: ctx.str("sort-dir") || "desc"
|
|
940
|
+
}),
|
|
941
|
+
outputPath: resolve(ctx.str("output"))
|
|
942
|
+
})
|
|
943
|
+
});
|
|
944
|
+
var exportUsageDetails = createAdminDownloadCommand({
|
|
945
|
+
command: "+export-usage-details",
|
|
946
|
+
description: "Export full or drill-down multi-dimension usage details to a streamed CSV file",
|
|
947
|
+
flags: [
|
|
948
|
+
{ name: "scope", type: "string", required: true, desc: `Export scope: ${EXPORT_SCOPES.join(" | ")}` },
|
|
949
|
+
{ name: "days", type: "number", min: 1, max: 365, desc: "Relative range for full export (1-365, default: 30)" },
|
|
950
|
+
{ name: "start-date", type: "string", pattern: DATE_PATTERN, desc: "Start date (YYYY-MM-DD)" },
|
|
951
|
+
{ name: "end-date", type: "string", pattern: DATE_PATTERN, desc: "End date (YYYY-MM-DD)" },
|
|
952
|
+
...COMBINATION_FLAGS.filter((flag) => !["start-date", "end-date", "page", "page-size", "sort-by", "sort-dir"].includes(flag.name)).map((flag) => ({ ...flag, required: false })),
|
|
953
|
+
{ name: "output", type: "string", required: true, desc: "New local CSV path; existing files are never overwritten" }
|
|
954
|
+
],
|
|
955
|
+
validate: (ctx) => {
|
|
956
|
+
const scope = optionalString(ctx, "scope");
|
|
957
|
+
assertEnum("scope", scope, EXPORT_SCOPES);
|
|
958
|
+
if (scope === "drill") {
|
|
959
|
+
validateUsageCombination(ctx);
|
|
960
|
+
} else {
|
|
961
|
+
validateDatePair(ctx, false, true);
|
|
962
|
+
if (optionalString(ctx, "parent-dimension") || optionalString(ctx, "open-id") || optionalString(ctx, "model-id") || optionalString(ctx, "model-scope") || optionalString(ctx, "app-type") || optionalString(ctx, "date")) {
|
|
963
|
+
throw new CliValidationError("full export does not accept drill-down filters");
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
},
|
|
967
|
+
prepare: (ctx) => ({
|
|
968
|
+
path: withQuery("/api/admin/stats/detailed-export", {
|
|
969
|
+
scope: ctx.str("scope"),
|
|
970
|
+
...usageRangeQuery(ctx),
|
|
971
|
+
...ctx.str("scope") === "drill" ? usageCombinationQuery(ctx) : {}
|
|
972
|
+
}),
|
|
973
|
+
outputPath: resolve(ctx.str("output"))
|
|
974
|
+
})
|
|
975
|
+
});
|
|
976
|
+
var usageCommands = [
|
|
977
|
+
getUsageSummary,
|
|
978
|
+
getUsageDetails,
|
|
979
|
+
getAgentToolCalls,
|
|
980
|
+
getUsageCombinations,
|
|
981
|
+
exportUsage,
|
|
982
|
+
exportUsageDetails
|
|
983
|
+
];
|
|
694
984
|
|
|
695
985
|
// src/commands/te-system/cost-control.ts
|
|
696
986
|
function createRuleBody(ctx) {
|
|
@@ -709,6 +999,20 @@ var getCostSummary = createAdminCommand({
|
|
|
709
999
|
risk: "read",
|
|
710
1000
|
prepare: () => ({ method: "GET", path: "/api/admin/cost-control/summary" })
|
|
711
1001
|
});
|
|
1002
|
+
var getBalance = createAdminCommand({
|
|
1003
|
+
command: "+get-balance",
|
|
1004
|
+
description: "Get the current company model account balance and currency",
|
|
1005
|
+
flags: [],
|
|
1006
|
+
risk: "read",
|
|
1007
|
+
prepare: () => ({ method: "GET", path: "/api/admin/cost-control/balance" })
|
|
1008
|
+
});
|
|
1009
|
+
var listOverLimitUsers = createAdminCommand({
|
|
1010
|
+
command: "+list-over-limit-users",
|
|
1011
|
+
description: "List company members currently over cost or token quota limits",
|
|
1012
|
+
flags: [],
|
|
1013
|
+
risk: "read",
|
|
1014
|
+
prepare: () => ({ method: "GET", path: "/api/admin/cost-control/over-limit-users" })
|
|
1015
|
+
});
|
|
712
1016
|
var getBalanceAlert = createAdminCommand({
|
|
713
1017
|
command: "+get-balance-alert",
|
|
714
1018
|
description: "Get the company balance alert configuration and current status",
|
|
@@ -812,6 +1116,8 @@ var bindQuotaRuleUser = createAdminCommand({
|
|
|
812
1116
|
});
|
|
813
1117
|
var costControlCommands = [
|
|
814
1118
|
getCostSummary,
|
|
1119
|
+
getBalance,
|
|
1120
|
+
listOverLimitUsers,
|
|
815
1121
|
getBalanceAlert,
|
|
816
1122
|
setBalanceAlert,
|
|
817
1123
|
listQuotaRules,
|
|
@@ -1427,10 +1733,90 @@ async function removeTemporaryTree(root) {
|
|
|
1427
1733
|
var TOOL_UPLOAD_PATH = "/api/admin/sandbox-tools";
|
|
1428
1734
|
var TOOL_UPLOAD_POLICY_PATH = "/api/admin/sandbox-tools/upload-policy";
|
|
1429
1735
|
var NPM_INSTALL_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
1736
|
+
var TARGET_MODES = ["selected", "all-running"];
|
|
1737
|
+
var OPERATION_ACTIONS = ["activate", "deactivate"];
|
|
1738
|
+
var SORT_ORDERS = ["asc", "desc"];
|
|
1430
1739
|
function optionalFlag(ctx, name) {
|
|
1431
1740
|
const value = ctx.str(name).trim();
|
|
1432
1741
|
return value || void 0;
|
|
1433
1742
|
}
|
|
1743
|
+
function optionalBoundedStringArray(ctx, name, max) {
|
|
1744
|
+
return optionalString(ctx, name) ? requireBoundedStringArray(ctx, name, max) : void 0;
|
|
1745
|
+
}
|
|
1746
|
+
function validateCommandNamesByToolId(value, toolIds) {
|
|
1747
|
+
if (!value) return void 0;
|
|
1748
|
+
const normalized = {};
|
|
1749
|
+
for (const [toolId, commandNames] of Object.entries(value)) {
|
|
1750
|
+
if (!toolIds.includes(toolId)) {
|
|
1751
|
+
throw new CliValidationError("--command-names-by-tool-id keys must exist in --tool-ids");
|
|
1752
|
+
}
|
|
1753
|
+
if (!Array.isArray(commandNames) || commandNames.length === 0 || commandNames.length > 64 || commandNames.some((name) => typeof name !== "string" || !name.trim())) {
|
|
1754
|
+
throw new CliValidationError(
|
|
1755
|
+
"--command-names-by-tool-id values must be arrays of 1-64 non-empty command names"
|
|
1756
|
+
);
|
|
1757
|
+
}
|
|
1758
|
+
normalized[toolId] = commandNames.map((name) => name.trim());
|
|
1759
|
+
}
|
|
1760
|
+
return normalized;
|
|
1761
|
+
}
|
|
1762
|
+
function validateExpectedSnapshots(value, toolIds) {
|
|
1763
|
+
if (!value) return void 0;
|
|
1764
|
+
const normalized = {};
|
|
1765
|
+
for (const [toolId, snapshot] of Object.entries(value)) {
|
|
1766
|
+
if (!toolIds.includes(toolId)) {
|
|
1767
|
+
throw new CliValidationError("--expected-tool-snapshots-by-id keys must exist in --tool-ids");
|
|
1768
|
+
}
|
|
1769
|
+
if (!snapshot || typeof snapshot !== "object" || Array.isArray(snapshot)) {
|
|
1770
|
+
throw new CliValidationError("--expected-tool-snapshots-by-id values must be objects");
|
|
1771
|
+
}
|
|
1772
|
+
const item = snapshot;
|
|
1773
|
+
if (typeof item.name !== "string" || !item.name.trim() || item.version !== null && typeof item.version !== "string" || typeof item.packagePath !== "string" || !item.packagePath.trim() || !Array.isArray(item.commands) || item.commands.length === 0 || item.commands.length > 64 || item.commands.some((name) => typeof name !== "string" || !name.trim())) {
|
|
1774
|
+
throw new CliValidationError(
|
|
1775
|
+
"--expected-tool-snapshots-by-id contains an invalid tool snapshot"
|
|
1776
|
+
);
|
|
1777
|
+
}
|
|
1778
|
+
normalized[toolId] = {
|
|
1779
|
+
name: item.name.trim(),
|
|
1780
|
+
version: item.version,
|
|
1781
|
+
packagePath: item.packagePath.trim(),
|
|
1782
|
+
commands: item.commands.map((name) => name.trim())
|
|
1783
|
+
};
|
|
1784
|
+
}
|
|
1785
|
+
return normalized;
|
|
1786
|
+
}
|
|
1787
|
+
function sandboxToolOperationBody(ctx) {
|
|
1788
|
+
const mode = optionalString(ctx, "target-mode");
|
|
1789
|
+
assertEnum("target-mode", mode, TARGET_MODES);
|
|
1790
|
+
const sandboxIds = optionalBoundedStringArray(ctx, "sandbox-ids", 50);
|
|
1791
|
+
if (mode === "selected" && !sandboxIds) {
|
|
1792
|
+
throw new CliValidationError("selected mode requires --sandbox-ids with 1-50 sandbox IDs");
|
|
1793
|
+
}
|
|
1794
|
+
if (mode === "all-running" && sandboxIds) {
|
|
1795
|
+
throw new CliValidationError("all-running mode does not accept --sandbox-ids");
|
|
1796
|
+
}
|
|
1797
|
+
const toolIds = requireBoundedStringArray(ctx, "tool-ids", 20);
|
|
1798
|
+
const commandNamesByToolId = validateCommandNamesByToolId(
|
|
1799
|
+
optionalJsonObject(ctx, "command-names-by-tool-id"),
|
|
1800
|
+
toolIds
|
|
1801
|
+
);
|
|
1802
|
+
const expectedToolSnapshotsById = validateExpectedSnapshots(
|
|
1803
|
+
optionalJsonObject(ctx, "expected-tool-snapshots-by-id"),
|
|
1804
|
+
toolIds
|
|
1805
|
+
);
|
|
1806
|
+
return {
|
|
1807
|
+
target: { mode, ...sandboxIds ? { sandboxIds } : {} },
|
|
1808
|
+
toolIds,
|
|
1809
|
+
...commandNamesByToolId ? { commandNamesByToolId } : {},
|
|
1810
|
+
...expectedToolSnapshotsById ? { expectedToolSnapshotsById } : {}
|
|
1811
|
+
};
|
|
1812
|
+
}
|
|
1813
|
+
var TOOL_OPERATION_FLAGS = [
|
|
1814
|
+
{ name: "target-mode", type: "string", required: true, desc: `Target mode: ${TARGET_MODES.join(" | ")}` },
|
|
1815
|
+
{ name: "sandbox-ids", type: "string", sensitive: true, desc: "Selected mode only: JSON/@file array of 1-50 sandbox IDs" },
|
|
1816
|
+
{ name: "tool-ids", type: "string", required: true, desc: "JSON/@file array of 1-20 sandbox tool IDs" },
|
|
1817
|
+
{ name: "command-names-by-tool-id", type: "string", desc: "Optional JSON/@file map of tool ID to selected command names" },
|
|
1818
|
+
{ name: "expected-tool-snapshots-by-id", type: "string", sensitive: true, desc: "Optional JSON/@file optimistic-lock snapshots keyed by tool ID" }
|
|
1819
|
+
];
|
|
1434
1820
|
async function requireUploadPolicy(ctx) {
|
|
1435
1821
|
const policy = await getAdmin(
|
|
1436
1822
|
TOOL_UPLOAD_POLICY_PATH,
|
|
@@ -1685,9 +2071,127 @@ var npmInstallSandboxTool = {
|
|
|
1685
2071
|
}
|
|
1686
2072
|
}
|
|
1687
2073
|
};
|
|
2074
|
+
var listSandboxTools = createAdminCommand({
|
|
2075
|
+
command: "+list-sandbox-tools",
|
|
2076
|
+
description: "List preset and custom sandbox tools registered for the current company",
|
|
2077
|
+
flags: [],
|
|
2078
|
+
risk: "read",
|
|
2079
|
+
prepare: () => ({ method: "GET", path: "/api/admin/sandbox-tools" })
|
|
2080
|
+
});
|
|
2081
|
+
var syncSandboxTools = createAdminCommand({
|
|
2082
|
+
command: "+sync-sandbox-tools",
|
|
2083
|
+
description: "Synchronize the current company sandbox tool registry from the system manifest",
|
|
2084
|
+
flags: [],
|
|
2085
|
+
risk: "write",
|
|
2086
|
+
prepare: () => ({ method: "POST", path: "/api/admin/sandbox-tools/sync", body: {} })
|
|
2087
|
+
});
|
|
2088
|
+
var getSandboxToolDistribution = createAdminCommand({
|
|
2089
|
+
command: "+get-sandbox-tool-distribution",
|
|
2090
|
+
description: "Get the sandboxes to which one tool is currently distributed",
|
|
2091
|
+
flags: [
|
|
2092
|
+
{ name: "id", type: "string", required: true, desc: "Sandbox tool ID from +list-sandbox-tools" }
|
|
2093
|
+
],
|
|
2094
|
+
risk: "read",
|
|
2095
|
+
prepare: (ctx) => ({
|
|
2096
|
+
method: "GET",
|
|
2097
|
+
path: `/api/admin/sandbox-tools/${encodeId(ctx.str("id"))}/distribution`
|
|
2098
|
+
})
|
|
2099
|
+
});
|
|
2100
|
+
var setSandboxToolEnabled = createAdminCommand({
|
|
2101
|
+
command: "+set-sandbox-tool-enabled",
|
|
2102
|
+
description: "Enable or disable a sandbox tool in the company registry",
|
|
2103
|
+
flags: [
|
|
2104
|
+
{ name: "id", type: "string", required: true, desc: "Sandbox tool ID from +list-sandbox-tools" },
|
|
2105
|
+
{ name: "enabled", type: "boolean", required: true, desc: "Whether the sandbox tool is enabled" }
|
|
2106
|
+
],
|
|
2107
|
+
risk: "write",
|
|
2108
|
+
prepare: (ctx) => ({
|
|
2109
|
+
method: "PATCH",
|
|
2110
|
+
path: `/api/admin/sandbox-tools/${encodeId(ctx.str("id"))}`,
|
|
2111
|
+
body: { enabled: ctx.bool("enabled") }
|
|
2112
|
+
})
|
|
2113
|
+
});
|
|
2114
|
+
var removeSandboxTool = createAdminCommand({
|
|
2115
|
+
command: "+remove-sandbox-tool",
|
|
2116
|
+
description: "Delete a sandbox tool after the server verifies it is fully reclaimed",
|
|
2117
|
+
flags: [
|
|
2118
|
+
{ name: "id", type: "string", required: true, desc: "Sandbox tool ID from +list-sandbox-tools" }
|
|
2119
|
+
],
|
|
2120
|
+
risk: "high-risk-write",
|
|
2121
|
+
prepare: (ctx) => ({
|
|
2122
|
+
method: "DELETE",
|
|
2123
|
+
path: `/api/admin/sandbox-tools/${encodeId(ctx.str("id"))}`
|
|
2124
|
+
})
|
|
2125
|
+
});
|
|
2126
|
+
function createSandboxToolOperationCommand(command, description, route) {
|
|
2127
|
+
return createAdminCommand({
|
|
2128
|
+
command,
|
|
2129
|
+
description,
|
|
2130
|
+
flags: TOOL_OPERATION_FLAGS,
|
|
2131
|
+
risk: "write",
|
|
2132
|
+
validate: (ctx) => {
|
|
2133
|
+
sandboxToolOperationBody(ctx);
|
|
2134
|
+
},
|
|
2135
|
+
prepare: (ctx) => ({
|
|
2136
|
+
method: "POST",
|
|
2137
|
+
path: `/api/admin/sandbox-tools/${route}`,
|
|
2138
|
+
body: sandboxToolOperationBody(ctx)
|
|
2139
|
+
})
|
|
2140
|
+
});
|
|
2141
|
+
}
|
|
2142
|
+
var activateSandboxTools = createSandboxToolOperationCommand(
|
|
2143
|
+
"+activate-sandbox-tools",
|
|
2144
|
+
"Activate selected tool commands in selected or all running sandboxes",
|
|
2145
|
+
"activate"
|
|
2146
|
+
);
|
|
2147
|
+
var deactivateSandboxTools = createSandboxToolOperationCommand(
|
|
2148
|
+
"+deactivate-sandbox-tools",
|
|
2149
|
+
"Deactivate selected managed tool commands in selected or all running sandboxes",
|
|
2150
|
+
"deactivate"
|
|
2151
|
+
);
|
|
2152
|
+
var refreshSandboxToolStatus = createSandboxToolOperationCommand(
|
|
2153
|
+
"+refresh-sandbox-tool-status",
|
|
2154
|
+
"Refresh the observed tool state in selected or all running sandboxes",
|
|
2155
|
+
"status"
|
|
2156
|
+
);
|
|
2157
|
+
var listSandboxToolOperations = createAdminCommand({
|
|
2158
|
+
command: "+list-sandbox-tool-operations",
|
|
2159
|
+
description: "List sandbox tool activation and deactivation operation history",
|
|
2160
|
+
flags: [
|
|
2161
|
+
{ name: "page", type: "number", min: 1, desc: "Page number (default: 1)" },
|
|
2162
|
+
{ name: "page-size", type: "number", min: 1, max: 100, desc: "Page size (1-100, default: 20)" },
|
|
2163
|
+
{ name: "action", type: "string", desc: `Operation action: ${OPERATION_ACTIONS.join(" | ")}` },
|
|
2164
|
+
{ name: "operator", type: "string", maxLength: 100, desc: "Operator name or ID filter" },
|
|
2165
|
+
{ name: "sort-order", type: "string", desc: `Sort order: ${SORT_ORDERS.join(" | ")}` }
|
|
2166
|
+
],
|
|
2167
|
+
risk: "read",
|
|
2168
|
+
validate: (ctx) => {
|
|
2169
|
+
assertEnum("action", optionalString(ctx, "action"), OPERATION_ACTIONS);
|
|
2170
|
+
assertEnum("sort-order", optionalString(ctx, "sort-order"), SORT_ORDERS);
|
|
2171
|
+
},
|
|
2172
|
+
prepare: (ctx) => ({
|
|
2173
|
+
method: "GET",
|
|
2174
|
+
path: withQuery("/api/admin/sandbox-tools/operations", {
|
|
2175
|
+
page: ctx.optionalNum("page"),
|
|
2176
|
+
pageSize: ctx.optionalNum("page-size"),
|
|
2177
|
+
action: optionalString(ctx, "action"),
|
|
2178
|
+
operator: optionalString(ctx, "operator"),
|
|
2179
|
+
sortOrder: optionalString(ctx, "sort-order")
|
|
2180
|
+
})
|
|
2181
|
+
})
|
|
2182
|
+
});
|
|
1688
2183
|
var sandboxToolCommands = [
|
|
1689
2184
|
uploadSandboxTool,
|
|
1690
|
-
npmInstallSandboxTool
|
|
2185
|
+
npmInstallSandboxTool,
|
|
2186
|
+
listSandboxTools,
|
|
2187
|
+
syncSandboxTools,
|
|
2188
|
+
getSandboxToolDistribution,
|
|
2189
|
+
setSandboxToolEnabled,
|
|
2190
|
+
removeSandboxTool,
|
|
2191
|
+
activateSandboxTools,
|
|
2192
|
+
deactivateSandboxTools,
|
|
2193
|
+
refreshSandboxToolStatus,
|
|
2194
|
+
listSandboxToolOperations
|
|
1691
2195
|
];
|
|
1692
2196
|
|
|
1693
2197
|
// src/commands/te-system/index.ts
|