agent-resource-management 1.4.0 → 1.4.1
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/dist/main.js +444 -0
- package/package.json +1 -1
- package/src/cmd/agent.ts +287 -0
- package/src/lib/client.ts +87 -0
- package/src/main.ts +164 -1
- package/dist//344/273/277/347/234/237/350/260/203/350/257/225/345/212/251/346/211/213/AGENT.md +0 -18
- package/dist//344/273/277/347/234/237/350/260/203/350/257/225/345/212/251/346/211/213/knowledges//344/273/277/347/234/237/345/271/263/345/217/260Loki/346/227/245/345/277/227/346/216/222/346/237/245/346/226/271/346/263/225.md +0 -27
- package/dist//344/273/277/347/234/237/350/260/203/350/257/225/345/212/251/346/211/213/knowledges//344/273/277/347/234/237/345/271/263/345/217/260/344/273/273/345/212/241/350/247/246/345/217/221/345/220/270/346/224/266/345/231/250/344/270/216/345/215/240/344/275/215/350/247/246/345/217/221/345/220/270/346/224/266/345/231/250/344/275/277/347/224/250/345/234/272/346/231/257.md +0 -18
- package/dist//344/273/277/347/234/237/350/260/203/350/257/225/345/212/251/346/211/213/knowledges//344/273/277/347/234/237/345/271/263/345/217/260/345/220/216/347/253/257Swagger/346/216/245/345/217/243/346/226/207/346/241/243.md +0 -22
- package/dist//344/273/277/347/234/237/350/260/203/350/257/225/345/212/251/346/211/213/knowledges//344/273/277/347/234/237/345/271/263/345/217/260/345/275/223/345/211/215/350/277/220/350/241/214/345/256/236/344/276/213/345/217/212/345/256/236/344/276/213/350/277/220/350/241/214/346/227/245/345/277/227/346/216/222/346/237/245.md +0 -39
- package/dist//344/273/277/347/234/237/350/260/203/350/257/225/345/212/251/346/211/213/knowledges//344/273/277/347/234/237/345/271/263/345/217/260/346/216/245/345/217/243/346/216/222/346/237/245/350/203/214/346/231/257/347/237/245/350/257/206.md +0 -49
- package/dist//344/273/277/347/234/237/350/260/203/350/257/225/345/212/251/346/211/213/knowledges//344/273/277/347/234/237/350/264/247/350/275/275/347/224/237/345/221/275/345/221/250/346/234/237/346/237/245/350/257/242/346/265/201/347/250/213.md +0 -165
- package/dist//344/273/277/347/234/237/350/260/203/350/257/225/345/212/251/346/211/213/knowledges//345/244/251/350/275/246/350/260/203/345/272/246/347/263/273/347/273/237/351/207/215/347/273/204/346/216/245/345/217/243/350/260/203/347/224/250/344/270/216/346/227/245/345/277/227/345/210/206/346/236/220/346/226/271/346/263/225.md +0 -137
package/dist/main.js
CHANGED
|
@@ -230,6 +230,72 @@ class ApiClient {
|
|
|
230
230
|
}
|
|
231
231
|
return res.arrayBuffer();
|
|
232
232
|
}
|
|
233
|
+
async createAgent(data) {
|
|
234
|
+
const res = await this.request("/agents", {
|
|
235
|
+
method: "POST",
|
|
236
|
+
body: JSON.stringify(data)
|
|
237
|
+
});
|
|
238
|
+
if (!res.ok) {
|
|
239
|
+
throw new Error(res.msg);
|
|
240
|
+
}
|
|
241
|
+
return res.data;
|
|
242
|
+
}
|
|
243
|
+
async updateAgent(id, data) {
|
|
244
|
+
const res = await this.request(`/agents/${id}`, {
|
|
245
|
+
method: "PUT",
|
|
246
|
+
body: JSON.stringify(data)
|
|
247
|
+
});
|
|
248
|
+
if (!res.ok) {
|
|
249
|
+
throw new Error(res.msg);
|
|
250
|
+
}
|
|
251
|
+
return res.data;
|
|
252
|
+
}
|
|
253
|
+
async deleteAgent(id) {
|
|
254
|
+
const res = await this.request(`/agents/${id}`, {
|
|
255
|
+
method: "DELETE"
|
|
256
|
+
});
|
|
257
|
+
if (!res.ok) {
|
|
258
|
+
throw new Error(res.msg);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
async bindSkillToAgent(agentId, skillId, config) {
|
|
262
|
+
const res = await this.request(`/agents/${agentId}/skills`, {
|
|
263
|
+
method: "POST",
|
|
264
|
+
body: JSON.stringify({ skillId, config })
|
|
265
|
+
});
|
|
266
|
+
if (!res.ok) {
|
|
267
|
+
throw new Error(res.msg);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
async unbindSkillFromAgent(agentId, skillId) {
|
|
271
|
+
const res = await this.request(`/agents/${agentId}/skills?skillId=${skillId}`, {
|
|
272
|
+
method: "DELETE"
|
|
273
|
+
});
|
|
274
|
+
if (!res.ok) {
|
|
275
|
+
throw new Error(res.msg);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
async bindKnowledgeToAgent(agentId, knowledgeId, retrievalConfig) {
|
|
279
|
+
const res = await this.request(`/agents/${agentId}/knowledges`, {
|
|
280
|
+
method: "POST",
|
|
281
|
+
body: JSON.stringify({ knowledgeId, retrievalConfig })
|
|
282
|
+
});
|
|
283
|
+
if (!res.ok) {
|
|
284
|
+
throw new Error(res.msg);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
async unbindKnowledgeFromAgent(agentId, knowledgeId) {
|
|
288
|
+
const res = await this.request(`/agents/${agentId}/knowledges?knowledgeId=${knowledgeId}`, {
|
|
289
|
+
method: "DELETE"
|
|
290
|
+
});
|
|
291
|
+
if (!res.ok) {
|
|
292
|
+
throw new Error(res.msg);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
async getAgentByName(name) {
|
|
296
|
+
const result = await this.listAgents(name, 1, 1);
|
|
297
|
+
return result.agents.find((a) => a.name === name) || null;
|
|
298
|
+
}
|
|
233
299
|
}
|
|
234
300
|
|
|
235
301
|
// src/lib/storage.ts
|
|
@@ -821,6 +887,229 @@ import { writeFileSync as writeFileSync3, existsSync as existsSync4 } from "fs";
|
|
|
821
887
|
import { join as join4 } from "path";
|
|
822
888
|
import { execSync as execSync3 } from "child_process";
|
|
823
889
|
import { mkdtempSync as mkdtempSync3, rmSync as rmSync3 } from "fs";
|
|
890
|
+
function outputJson(result) {
|
|
891
|
+
console.log(JSON.stringify(result, null, 2));
|
|
892
|
+
}
|
|
893
|
+
function getJsonFlag() {
|
|
894
|
+
return process.argv.includes("--json") || process.argv.includes("-j");
|
|
895
|
+
}
|
|
896
|
+
async function createAgent(name, options = {}) {
|
|
897
|
+
const config = loadConfig();
|
|
898
|
+
if (!config?.token) {
|
|
899
|
+
if (getJsonFlag()) {
|
|
900
|
+
outputJson({ success: false, error: { code: "NOT_LOGGED_IN", message: "未登录,请先运行 arm login" } });
|
|
901
|
+
process.exit(1);
|
|
902
|
+
}
|
|
903
|
+
error("未登录,请先运行 arm login");
|
|
904
|
+
process.exit(1);
|
|
905
|
+
}
|
|
906
|
+
const client = new ApiClient(config.serverUrl, config.token);
|
|
907
|
+
try {
|
|
908
|
+
const skills = options.skills?.map((skillId, index) => ({
|
|
909
|
+
skillId,
|
|
910
|
+
config: options.skillConfigs?.[index] ? JSON.parse(options.skillConfigs[index]) : undefined
|
|
911
|
+
}));
|
|
912
|
+
const knowledges = options.knowledges?.map((knowledgeId, index) => ({
|
|
913
|
+
knowledgeId,
|
|
914
|
+
retrievalConfig: options.knowledgeConfigs?.[index] ? JSON.parse(options.knowledgeConfigs[index]) : undefined
|
|
915
|
+
}));
|
|
916
|
+
const result = await client.createAgent({
|
|
917
|
+
name,
|
|
918
|
+
description: options.description,
|
|
919
|
+
prompt: options.prompt,
|
|
920
|
+
avatar: options.avatar,
|
|
921
|
+
skills,
|
|
922
|
+
knowledges
|
|
923
|
+
});
|
|
924
|
+
if (getJsonFlag()) {
|
|
925
|
+
outputJson({ success: true, data: result });
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
928
|
+
success(`Agent "${name}" 创建成功 (ID: ${result.id})`);
|
|
929
|
+
} catch (err) {
|
|
930
|
+
if (getJsonFlag()) {
|
|
931
|
+
outputJson({ success: false, error: { code: "CREATE_FAILED", message: err instanceof Error ? err.message : "未知错误" } });
|
|
932
|
+
process.exit(1);
|
|
933
|
+
}
|
|
934
|
+
error(`创建失败: ${err instanceof Error ? err.message : "未知错误"}`);
|
|
935
|
+
process.exit(1);
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
async function updateAgent(id, options = {}) {
|
|
939
|
+
const config = loadConfig();
|
|
940
|
+
if (!config?.token) {
|
|
941
|
+
if (getJsonFlag()) {
|
|
942
|
+
outputJson({ success: false, error: { code: "NOT_LOGGED_IN", message: "未登录,请先运行 arm login" } });
|
|
943
|
+
process.exit(1);
|
|
944
|
+
}
|
|
945
|
+
error("未登录,请先运行 arm login");
|
|
946
|
+
process.exit(1);
|
|
947
|
+
}
|
|
948
|
+
const client = new ApiClient(config.serverUrl, config.token);
|
|
949
|
+
try {
|
|
950
|
+
const updateData = {};
|
|
951
|
+
if (options.name !== undefined)
|
|
952
|
+
updateData.name = options.name;
|
|
953
|
+
if (options.description !== undefined)
|
|
954
|
+
updateData.description = options.description;
|
|
955
|
+
if (options.prompt !== undefined)
|
|
956
|
+
updateData.prompt = options.prompt;
|
|
957
|
+
if (options.avatar !== undefined)
|
|
958
|
+
updateData.avatar = options.avatar;
|
|
959
|
+
if (options.status !== undefined)
|
|
960
|
+
updateData.status = options.status;
|
|
961
|
+
const result = await client.updateAgent(id, updateData);
|
|
962
|
+
if (getJsonFlag()) {
|
|
963
|
+
outputJson({ success: true, data: result });
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
success(`Agent "${id}" 更新成功`);
|
|
967
|
+
} catch (err) {
|
|
968
|
+
if (getJsonFlag()) {
|
|
969
|
+
outputJson({ success: false, error: { code: "UPDATE_FAILED", message: err instanceof Error ? err.message : "未知错误" } });
|
|
970
|
+
process.exit(1);
|
|
971
|
+
}
|
|
972
|
+
error(`更新失败: ${err instanceof Error ? err.message : "未知错误"}`);
|
|
973
|
+
process.exit(1);
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
async function deleteAgent(id) {
|
|
977
|
+
const config = loadConfig();
|
|
978
|
+
if (!config?.token) {
|
|
979
|
+
if (getJsonFlag()) {
|
|
980
|
+
outputJson({ success: false, error: { code: "NOT_LOGGED_IN", message: "未登录,请先运行 arm login" } });
|
|
981
|
+
process.exit(1);
|
|
982
|
+
}
|
|
983
|
+
error("未登录,请先运行 arm login");
|
|
984
|
+
process.exit(1);
|
|
985
|
+
}
|
|
986
|
+
const client = new ApiClient(config.serverUrl, config.token);
|
|
987
|
+
try {
|
|
988
|
+
await client.deleteAgent(id);
|
|
989
|
+
if (getJsonFlag()) {
|
|
990
|
+
outputJson({ success: true, data: { id } });
|
|
991
|
+
return;
|
|
992
|
+
}
|
|
993
|
+
success(`Agent "${id}" 删除成功`);
|
|
994
|
+
} catch (err) {
|
|
995
|
+
if (getJsonFlag()) {
|
|
996
|
+
outputJson({ success: false, error: { code: "DELETE_FAILED", message: err instanceof Error ? err.message : "未知错误" } });
|
|
997
|
+
process.exit(1);
|
|
998
|
+
}
|
|
999
|
+
error(`删除失败: ${err instanceof Error ? err.message : "未知错误"}`);
|
|
1000
|
+
process.exit(1);
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
async function bindSkill(id, skillId, config) {
|
|
1004
|
+
const configStore = loadConfig();
|
|
1005
|
+
if (!configStore?.token) {
|
|
1006
|
+
if (getJsonFlag()) {
|
|
1007
|
+
outputJson({ success: false, error: { code: "NOT_LOGGED_IN", message: "未登录,请先运行 arm login" } });
|
|
1008
|
+
process.exit(1);
|
|
1009
|
+
}
|
|
1010
|
+
error("未登录,请先运行 arm login");
|
|
1011
|
+
process.exit(1);
|
|
1012
|
+
}
|
|
1013
|
+
const client = new ApiClient(configStore.serverUrl, configStore.token);
|
|
1014
|
+
try {
|
|
1015
|
+
const parsedConfig = config ? JSON.parse(config) : undefined;
|
|
1016
|
+
await client.bindSkillToAgent(id, skillId, parsedConfig);
|
|
1017
|
+
if (getJsonFlag()) {
|
|
1018
|
+
outputJson({ success: true, data: { agentId: id, skillId, config: parsedConfig } });
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
success(`Skill "${skillId}" 已绑定到 Agent "${id}"`);
|
|
1022
|
+
} catch (err) {
|
|
1023
|
+
if (getJsonFlag()) {
|
|
1024
|
+
outputJson({ success: false, error: { code: "BIND_FAILED", message: err instanceof Error ? err.message : "未知错误" } });
|
|
1025
|
+
process.exit(1);
|
|
1026
|
+
}
|
|
1027
|
+
error(`绑定失败: ${err instanceof Error ? err.message : "未知错误"}`);
|
|
1028
|
+
process.exit(1);
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
async function unbindSkill(id, skillId) {
|
|
1032
|
+
const config = loadConfig();
|
|
1033
|
+
if (!config?.token) {
|
|
1034
|
+
if (getJsonFlag()) {
|
|
1035
|
+
outputJson({ success: false, error: { code: "NOT_LOGGED_IN", message: "未登录,请先运行 arm login" } });
|
|
1036
|
+
process.exit(1);
|
|
1037
|
+
}
|
|
1038
|
+
error("未登录,请先运行 arm login");
|
|
1039
|
+
process.exit(1);
|
|
1040
|
+
}
|
|
1041
|
+
const client = new ApiClient(config.serverUrl, config.token);
|
|
1042
|
+
try {
|
|
1043
|
+
await client.unbindSkillFromAgent(id, skillId);
|
|
1044
|
+
if (getJsonFlag()) {
|
|
1045
|
+
outputJson({ success: true, data: { agentId: id, skillId } });
|
|
1046
|
+
return;
|
|
1047
|
+
}
|
|
1048
|
+
success(`Skill "${skillId}" 已从 Agent "${id}" 解绑`);
|
|
1049
|
+
} catch (err) {
|
|
1050
|
+
if (getJsonFlag()) {
|
|
1051
|
+
outputJson({ success: false, error: { code: "UNBIND_FAILED", message: err instanceof Error ? err.message : "未知错误" } });
|
|
1052
|
+
process.exit(1);
|
|
1053
|
+
}
|
|
1054
|
+
error(`解绑失败: ${err instanceof Error ? err.message : "未知错误"}`);
|
|
1055
|
+
process.exit(1);
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
async function bindKnowledge(id, knowledgeId, retrievalConfig) {
|
|
1059
|
+
const configStore = loadConfig();
|
|
1060
|
+
if (!configStore?.token) {
|
|
1061
|
+
if (getJsonFlag()) {
|
|
1062
|
+
outputJson({ success: false, error: { code: "NOT_LOGGED_IN", message: "未登录,请先运行 arm login" } });
|
|
1063
|
+
process.exit(1);
|
|
1064
|
+
}
|
|
1065
|
+
error("未登录,请先运行 arm login");
|
|
1066
|
+
process.exit(1);
|
|
1067
|
+
}
|
|
1068
|
+
const client = new ApiClient(configStore.serverUrl, configStore.token);
|
|
1069
|
+
try {
|
|
1070
|
+
const parsedConfig = retrievalConfig ? JSON.parse(retrievalConfig) : undefined;
|
|
1071
|
+
await client.bindKnowledgeToAgent(id, knowledgeId, parsedConfig);
|
|
1072
|
+
if (getJsonFlag()) {
|
|
1073
|
+
outputJson({ success: true, data: { agentId: id, knowledgeId, retrievalConfig: parsedConfig } });
|
|
1074
|
+
return;
|
|
1075
|
+
}
|
|
1076
|
+
success(`Knowledge "${knowledgeId}" 已绑定到 Agent "${id}"`);
|
|
1077
|
+
} catch (err) {
|
|
1078
|
+
if (getJsonFlag()) {
|
|
1079
|
+
outputJson({ success: false, error: { code: "BIND_FAILED", message: err instanceof Error ? err.message : "未知错误" } });
|
|
1080
|
+
process.exit(1);
|
|
1081
|
+
}
|
|
1082
|
+
error(`绑定失败: ${err instanceof Error ? err.message : "未知错误"}`);
|
|
1083
|
+
process.exit(1);
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
async function unbindKnowledge(id, knowledgeId) {
|
|
1087
|
+
const config = loadConfig();
|
|
1088
|
+
if (!config?.token) {
|
|
1089
|
+
if (getJsonFlag()) {
|
|
1090
|
+
outputJson({ success: false, error: { code: "NOT_LOGGED_IN", message: "未登录,请先运行 arm login" } });
|
|
1091
|
+
process.exit(1);
|
|
1092
|
+
}
|
|
1093
|
+
error("未登录,请先运行 arm login");
|
|
1094
|
+
process.exit(1);
|
|
1095
|
+
}
|
|
1096
|
+
const client = new ApiClient(config.serverUrl, config.token);
|
|
1097
|
+
try {
|
|
1098
|
+
await client.unbindKnowledgeFromAgent(id, knowledgeId);
|
|
1099
|
+
if (getJsonFlag()) {
|
|
1100
|
+
outputJson({ success: true, data: { agentId: id, knowledgeId } });
|
|
1101
|
+
return;
|
|
1102
|
+
}
|
|
1103
|
+
success(`Knowledge "${knowledgeId}" 已从 Agent "${id}" 解绑`);
|
|
1104
|
+
} catch (err) {
|
|
1105
|
+
if (getJsonFlag()) {
|
|
1106
|
+
outputJson({ success: false, error: { code: "UNBIND_FAILED", message: err instanceof Error ? err.message : "未知错误" } });
|
|
1107
|
+
process.exit(1);
|
|
1108
|
+
}
|
|
1109
|
+
error(`解绑失败: ${err instanceof Error ? err.message : "未知错误"}`);
|
|
1110
|
+
process.exit(1);
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
824
1113
|
async function listAgents() {
|
|
825
1114
|
const config = loadConfig();
|
|
826
1115
|
if (!config?.token) {
|
|
@@ -1283,6 +1572,145 @@ async function main() {
|
|
|
1283
1572
|
}
|
|
1284
1573
|
await downloadAgent(args[2], args[3]);
|
|
1285
1574
|
break;
|
|
1575
|
+
case "create":
|
|
1576
|
+
if (!args[2]) {
|
|
1577
|
+
console.error(`用法: arm agent create <name> [--description="..."] [--prompt="..."] [--avatar="..."] [--skill=id] [--knowledge=id] [--skill-config='{...}'] [--knowledge-config='{...}'] [--json]`);
|
|
1578
|
+
process.exit(1);
|
|
1579
|
+
}
|
|
1580
|
+
{
|
|
1581
|
+
const name = args[2];
|
|
1582
|
+
const options = {};
|
|
1583
|
+
const skills = [];
|
|
1584
|
+
const knowledges = [];
|
|
1585
|
+
const skillConfigs = [];
|
|
1586
|
+
const knowledgeConfigs = [];
|
|
1587
|
+
for (let i = 3;i < args.length; i++) {
|
|
1588
|
+
const arg = args[i];
|
|
1589
|
+
if (arg.startsWith("--description=")) {
|
|
1590
|
+
options.description = arg.split("=").slice(1).join("=");
|
|
1591
|
+
} else if (arg.startsWith("--prompt=")) {
|
|
1592
|
+
options.prompt = arg.split("=").slice(1).join("=");
|
|
1593
|
+
} else if (arg.startsWith("--avatar=")) {
|
|
1594
|
+
options.avatar = arg.split("=").slice(1).join("=");
|
|
1595
|
+
} else if (arg.startsWith("--skill=")) {
|
|
1596
|
+
skills.push(arg.split("=").slice(1).join("="));
|
|
1597
|
+
} else if (arg.startsWith("--knowledge=")) {
|
|
1598
|
+
knowledges.push(arg.split("=").slice(1).join("="));
|
|
1599
|
+
} else if (arg.startsWith("--skill-config=")) {
|
|
1600
|
+
skillConfigs.push(arg.split("=").slice(1).join("="));
|
|
1601
|
+
} else if (arg.startsWith("--knowledge-config=")) {
|
|
1602
|
+
knowledgeConfigs.push(arg.split("=").slice(1).join("="));
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
await createAgent(name, {
|
|
1606
|
+
description: options.description,
|
|
1607
|
+
prompt: options.prompt,
|
|
1608
|
+
avatar: options.avatar,
|
|
1609
|
+
skills,
|
|
1610
|
+
knowledges,
|
|
1611
|
+
skillConfigs,
|
|
1612
|
+
knowledgeConfigs
|
|
1613
|
+
});
|
|
1614
|
+
}
|
|
1615
|
+
break;
|
|
1616
|
+
case "update":
|
|
1617
|
+
if (!args[2]) {
|
|
1618
|
+
console.error('用法: arm agent update <id> [--name="..."] [--description="..."] [--prompt="..."] [--avatar="..."] [--status=active|draft] [--json]');
|
|
1619
|
+
process.exit(1);
|
|
1620
|
+
}
|
|
1621
|
+
{
|
|
1622
|
+
const id = args[2];
|
|
1623
|
+
const options = {};
|
|
1624
|
+
for (let i = 3;i < args.length; i++) {
|
|
1625
|
+
const arg = args[i];
|
|
1626
|
+
if (arg.startsWith("--name=")) {
|
|
1627
|
+
options.name = arg.split("=").slice(1).join("=");
|
|
1628
|
+
} else if (arg.startsWith("--description=")) {
|
|
1629
|
+
options.description = arg.split("=").slice(1).join("=");
|
|
1630
|
+
} else if (arg.startsWith("--prompt=")) {
|
|
1631
|
+
options.prompt = arg.split("=").slice(1).join("=");
|
|
1632
|
+
} else if (arg.startsWith("--avatar=")) {
|
|
1633
|
+
options.avatar = arg.split("=").slice(1).join("=");
|
|
1634
|
+
} else if (arg.startsWith("--status=")) {
|
|
1635
|
+
options.status = arg.split("=").slice(1).join("=");
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
await updateAgent(id, {
|
|
1639
|
+
name: options.name,
|
|
1640
|
+
description: options.description,
|
|
1641
|
+
prompt: options.prompt,
|
|
1642
|
+
avatar: options.avatar,
|
|
1643
|
+
status: options.status
|
|
1644
|
+
});
|
|
1645
|
+
}
|
|
1646
|
+
break;
|
|
1647
|
+
case "delete":
|
|
1648
|
+
if (!args[2]) {
|
|
1649
|
+
console.error("用法: arm agent delete <id> [--json]");
|
|
1650
|
+
process.exit(1);
|
|
1651
|
+
}
|
|
1652
|
+
await deleteAgent(args[2]);
|
|
1653
|
+
break;
|
|
1654
|
+
case "bind":
|
|
1655
|
+
if (!args[2]) {
|
|
1656
|
+
console.error("用法: arm agent bind <id> --skill=<skillId> [--skill-config='{...}'] 或 arm agent bind <id> --knowledge=<knowledgeId> [--knowledge-config='{...}'] [--json]");
|
|
1657
|
+
process.exit(1);
|
|
1658
|
+
}
|
|
1659
|
+
{
|
|
1660
|
+
const id = args[2];
|
|
1661
|
+
let skillId;
|
|
1662
|
+
let knowledgeId;
|
|
1663
|
+
let skillConfig;
|
|
1664
|
+
let knowledgeConfig;
|
|
1665
|
+
for (let i = 3;i < args.length; i++) {
|
|
1666
|
+
const arg = args[i];
|
|
1667
|
+
if (arg.startsWith("--skill=")) {
|
|
1668
|
+
skillId = arg.split("=").slice(1).join("=");
|
|
1669
|
+
} else if (arg.startsWith("--knowledge=")) {
|
|
1670
|
+
knowledgeId = arg.split("=").slice(1).join("=");
|
|
1671
|
+
} else if (arg.startsWith("--skill-config=")) {
|
|
1672
|
+
skillConfig = arg.split("=").slice(1).join("=");
|
|
1673
|
+
} else if (arg.startsWith("--knowledge-config=")) {
|
|
1674
|
+
knowledgeConfig = arg.split("=").slice(1).join("=");
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
if (skillId) {
|
|
1678
|
+
await bindSkill(id, skillId, skillConfig);
|
|
1679
|
+
} else if (knowledgeId) {
|
|
1680
|
+
await bindKnowledge(id, knowledgeId, knowledgeConfig);
|
|
1681
|
+
} else {
|
|
1682
|
+
console.error("用法: arm agent bind <id> --skill=<skillId> 或 --knowledge=<knowledgeId>");
|
|
1683
|
+
process.exit(1);
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
break;
|
|
1687
|
+
case "unbind":
|
|
1688
|
+
if (!args[2]) {
|
|
1689
|
+
console.error("用法: arm agent unbind <id> --skill=<skillId> 或 --knowledge=<knowledgeId> [--json]");
|
|
1690
|
+
process.exit(1);
|
|
1691
|
+
}
|
|
1692
|
+
{
|
|
1693
|
+
const id = args[2];
|
|
1694
|
+
let skillId;
|
|
1695
|
+
let knowledgeId;
|
|
1696
|
+
for (let i = 3;i < args.length; i++) {
|
|
1697
|
+
const arg = args[i];
|
|
1698
|
+
if (arg.startsWith("--skill=")) {
|
|
1699
|
+
skillId = arg.split("=").slice(1).join("=");
|
|
1700
|
+
} else if (arg.startsWith("--knowledge=")) {
|
|
1701
|
+
knowledgeId = arg.split("=").slice(1).join("=");
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
if (skillId) {
|
|
1705
|
+
await unbindSkill(id, skillId);
|
|
1706
|
+
} else if (knowledgeId) {
|
|
1707
|
+
await unbindKnowledge(id, knowledgeId);
|
|
1708
|
+
} else {
|
|
1709
|
+
console.error("用法: arm agent unbind <id> --skill=<skillId> 或 --knowledge=<knowledgeId>");
|
|
1710
|
+
process.exit(1);
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
break;
|
|
1286
1714
|
default:
|
|
1287
1715
|
console.log(`
|
|
1288
1716
|
可用命令:
|
|
@@ -1290,6 +1718,14 @@ async function main() {
|
|
|
1290
1718
|
arm agent search <keyword> 搜索 Agent
|
|
1291
1719
|
arm agent info <name> 查看 Agent 详情
|
|
1292
1720
|
arm agent download <name> [dir] 下载 Agent
|
|
1721
|
+
arm agent create <name> 创建 Agent (--description, --prompt, --avatar, --skill, --knowledge)
|
|
1722
|
+
arm agent update <id> 更新 Agent (--name, --description, --prompt, --avatar, --status)
|
|
1723
|
+
arm agent delete <id> 删除 Agent
|
|
1724
|
+
arm agent bind <id> --skill=<id> 绑定 Skill 到 Agent
|
|
1725
|
+
arm agent unbind <id> --skill=<id> 解绑 Skill
|
|
1726
|
+
arm agent bind <id> --knowledge=<id> 绑定 Knowledge 到 Agent
|
|
1727
|
+
arm agent unbind <id> --knowledge=<id> 解绑 Knowledge
|
|
1728
|
+
所有命令支持 --json 参数获取机器可读输出
|
|
1293
1729
|
`);
|
|
1294
1730
|
}
|
|
1295
1731
|
break;
|
|
@@ -1319,8 +1755,16 @@ Agent Resource Management (arm)
|
|
|
1319
1755
|
arm agent search <keyword> 搜索 Agent
|
|
1320
1756
|
arm agent info <name> 查看 Agent 详情
|
|
1321
1757
|
arm agent download <name> [dir] 下载 Agent
|
|
1758
|
+
arm agent create <name> 创建 Agent
|
|
1759
|
+
arm agent update <id> 更新 Agent
|
|
1760
|
+
arm agent delete <id> 删除 Agent
|
|
1761
|
+
arm agent bind <id> --skill=<id> 绑定 Skill
|
|
1762
|
+
arm agent unbind <id> --skill=<id> 解绑 Skill
|
|
1763
|
+
arm agent bind <id> --knowledge=<id> 绑定 Knowledge
|
|
1764
|
+
arm agent unbind <id> --knowledge=<id> 解绑 Knowledge
|
|
1322
1765
|
arm server 显示当前服务端
|
|
1323
1766
|
arm server set <url> 设置服务端
|
|
1767
|
+
使用 arm <entity> -h 查看详细帮助
|
|
1324
1768
|
`);
|
|
1325
1769
|
}
|
|
1326
1770
|
}
|