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.
Files changed (13) hide show
  1. package/dist/main.js +444 -0
  2. package/package.json +1 -1
  3. package/src/cmd/agent.ts +287 -0
  4. package/src/lib/client.ts +87 -0
  5. package/src/main.ts +164 -1
  6. package/dist//344/273/277/347/234/237/350/260/203/350/257/225/345/212/251/346/211/213/AGENT.md +0 -18
  7. 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
  8. 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
  9. 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
  10. 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
  11. 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
  12. 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
  13. 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/src/cmd/agent.ts CHANGED
@@ -6,6 +6,293 @@ import { join } from 'path';
6
6
  import { execSync } from 'child_process';
7
7
  import { mkdtempSync, rmSync } from 'fs';
8
8
 
9
+ interface JsonResult<T = unknown> {
10
+ success: boolean;
11
+ data?: T;
12
+ error?: {
13
+ code: string;
14
+ message: string;
15
+ };
16
+ }
17
+
18
+ function outputJson<T>(result: JsonResult<T>): void {
19
+ console.log(JSON.stringify(result, null, 2));
20
+ }
21
+
22
+ function getJsonFlag(): boolean {
23
+ return process.argv.includes('--json') || process.argv.includes('-j');
24
+ }
25
+
26
+ function getAgentIdentifier(identifier: string): { id: string; name: string } {
27
+ if (identifier.includes('-')) {
28
+ return { id: identifier, name: identifier };
29
+ }
30
+ return { id: identifier, name: identifier };
31
+ }
32
+
33
+ export async function createAgent(
34
+ name: string,
35
+ options: {
36
+ description?: string;
37
+ prompt?: string;
38
+ avatar?: string;
39
+ skills?: string[];
40
+ knowledges?: string[];
41
+ skillConfigs?: string[];
42
+ knowledgeConfigs?: string[];
43
+ } = {}
44
+ ): Promise<void> {
45
+ const config = loadConfig();
46
+ if (!config?.token) {
47
+ if (getJsonFlag()) {
48
+ outputJson({ success: false, error: { code: 'NOT_LOGGED_IN', message: '未登录,请先运行 arm login' } });
49
+ process.exit(1);
50
+ }
51
+ error('未登录,请先运行 arm login');
52
+ process.exit(1);
53
+ }
54
+
55
+ const client = new ApiClient(config.serverUrl, config.token);
56
+ try {
57
+ const skills = options.skills?.map((skillId, index) => ({
58
+ skillId,
59
+ config: options.skillConfigs?.[index] ? JSON.parse(options.skillConfigs[index]) : undefined,
60
+ }));
61
+
62
+ const knowledges = options.knowledges?.map((knowledgeId, index) => ({
63
+ knowledgeId,
64
+ retrievalConfig: options.knowledgeConfigs?.[index] ? JSON.parse(options.knowledgeConfigs[index]) : undefined,
65
+ }));
66
+
67
+ const result = await client.createAgent({
68
+ name,
69
+ description: options.description,
70
+ prompt: options.prompt,
71
+ avatar: options.avatar,
72
+ skills,
73
+ knowledges,
74
+ });
75
+
76
+ if (getJsonFlag()) {
77
+ outputJson({ success: true, data: result });
78
+ return;
79
+ }
80
+ success(`Agent "${name}" 创建成功 (ID: ${result.id})`);
81
+ } catch (err) {
82
+ if (getJsonFlag()) {
83
+ outputJson({ success: false, error: { code: 'CREATE_FAILED', message: err instanceof Error ? err.message : '未知错误' } });
84
+ process.exit(1);
85
+ }
86
+ error(`创建失败: ${err instanceof Error ? err.message : '未知错误'}`);
87
+ process.exit(1);
88
+ }
89
+ }
90
+
91
+ export async function updateAgent(
92
+ id: string,
93
+ options: {
94
+ name?: string;
95
+ description?: string;
96
+ prompt?: string;
97
+ avatar?: string;
98
+ status?: 'active' | 'draft';
99
+ } = {}
100
+ ): Promise<void> {
101
+ const config = loadConfig();
102
+ if (!config?.token) {
103
+ if (getJsonFlag()) {
104
+ outputJson({ success: false, error: { code: 'NOT_LOGGED_IN', message: '未登录,请先运行 arm login' } });
105
+ process.exit(1);
106
+ }
107
+ error('未登录,请先运行 arm login');
108
+ process.exit(1);
109
+ }
110
+
111
+ const client = new ApiClient(config.serverUrl, config.token);
112
+ try {
113
+ const updateData: Partial<{
114
+ name: string;
115
+ description: string;
116
+ prompt: string;
117
+ avatar: string;
118
+ status: 'active' | 'draft';
119
+ }> = {};
120
+
121
+ if (options.name !== undefined) updateData.name = options.name;
122
+ if (options.description !== undefined) updateData.description = options.description;
123
+ if (options.prompt !== undefined) updateData.prompt = options.prompt;
124
+ if (options.avatar !== undefined) updateData.avatar = options.avatar;
125
+ if (options.status !== undefined) updateData.status = options.status;
126
+
127
+ const result = await client.updateAgent(id, updateData);
128
+
129
+ if (getJsonFlag()) {
130
+ outputJson({ success: true, data: result });
131
+ return;
132
+ }
133
+ success(`Agent "${id}" 更新成功`);
134
+ } catch (err) {
135
+ if (getJsonFlag()) {
136
+ outputJson({ success: false, error: { code: 'UPDATE_FAILED', message: err instanceof Error ? err.message : '未知错误' } });
137
+ process.exit(1);
138
+ }
139
+ error(`更新失败: ${err instanceof Error ? err.message : '未知错误'}`);
140
+ process.exit(1);
141
+ }
142
+ }
143
+
144
+ export async function deleteAgent(id: string): Promise<void> {
145
+ const config = loadConfig();
146
+ if (!config?.token) {
147
+ if (getJsonFlag()) {
148
+ outputJson({ success: false, error: { code: 'NOT_LOGGED_IN', message: '未登录,请先运行 arm login' } });
149
+ process.exit(1);
150
+ }
151
+ error('未登录,请先运行 arm login');
152
+ process.exit(1);
153
+ }
154
+
155
+ const client = new ApiClient(config.serverUrl, config.token);
156
+ try {
157
+ await client.deleteAgent(id);
158
+
159
+ if (getJsonFlag()) {
160
+ outputJson({ success: true, data: { id } });
161
+ return;
162
+ }
163
+ success(`Agent "${id}" 删除成功`);
164
+ } catch (err) {
165
+ if (getJsonFlag()) {
166
+ outputJson({ success: false, error: { code: 'DELETE_FAILED', message: err instanceof Error ? err.message : '未知错误' } });
167
+ process.exit(1);
168
+ }
169
+ error(`删除失败: ${err instanceof Error ? err.message : '未知错误'}`);
170
+ process.exit(1);
171
+ }
172
+ }
173
+
174
+ export async function bindSkill(id: string, skillId: string, config?: string): Promise<void> {
175
+ const configStore = loadConfig();
176
+ if (!configStore?.token) {
177
+ if (getJsonFlag()) {
178
+ outputJson({ success: false, error: { code: 'NOT_LOGGED_IN', message: '未登录,请先运行 arm login' } });
179
+ process.exit(1);
180
+ }
181
+ error('未登录,请先运行 arm login');
182
+ process.exit(1);
183
+ }
184
+
185
+ const client = new ApiClient(configStore.serverUrl, configStore.token);
186
+ try {
187
+ const parsedConfig = config ? JSON.parse(config) : undefined;
188
+ await client.bindSkillToAgent(id, skillId, parsedConfig);
189
+
190
+ if (getJsonFlag()) {
191
+ outputJson({ success: true, data: { agentId: id, skillId, config: parsedConfig } });
192
+ return;
193
+ }
194
+ success(`Skill "${skillId}" 已绑定到 Agent "${id}"`);
195
+ } catch (err) {
196
+ if (getJsonFlag()) {
197
+ outputJson({ success: false, error: { code: 'BIND_FAILED', message: err instanceof Error ? err.message : '未知错误' } });
198
+ process.exit(1);
199
+ }
200
+ error(`绑定失败: ${err instanceof Error ? err.message : '未知错误'}`);
201
+ process.exit(1);
202
+ }
203
+ }
204
+
205
+ export async function unbindSkill(id: string, skillId: string): Promise<void> {
206
+ const config = loadConfig();
207
+ if (!config?.token) {
208
+ if (getJsonFlag()) {
209
+ outputJson({ success: false, error: { code: 'NOT_LOGGED_IN', message: '未登录,请先运行 arm login' } });
210
+ process.exit(1);
211
+ }
212
+ error('未登录,请先运行 arm login');
213
+ process.exit(1);
214
+ }
215
+
216
+ const client = new ApiClient(config.serverUrl, config.token);
217
+ try {
218
+ await client.unbindSkillFromAgent(id, skillId);
219
+
220
+ if (getJsonFlag()) {
221
+ outputJson({ success: true, data: { agentId: id, skillId } });
222
+ return;
223
+ }
224
+ success(`Skill "${skillId}" 已从 Agent "${id}" 解绑`);
225
+ } catch (err) {
226
+ if (getJsonFlag()) {
227
+ outputJson({ success: false, error: { code: 'UNBIND_FAILED', message: err instanceof Error ? err.message : '未知错误' } });
228
+ process.exit(1);
229
+ }
230
+ error(`解绑失败: ${err instanceof Error ? err.message : '未知错误'}`);
231
+ process.exit(1);
232
+ }
233
+ }
234
+
235
+ export async function bindKnowledge(id: string, knowledgeId: string, retrievalConfig?: string): Promise<void> {
236
+ const configStore = loadConfig();
237
+ if (!configStore?.token) {
238
+ if (getJsonFlag()) {
239
+ outputJson({ success: false, error: { code: 'NOT_LOGGED_IN', message: '未登录,请先运行 arm login' } });
240
+ process.exit(1);
241
+ }
242
+ error('未登录,请先运行 arm login');
243
+ process.exit(1);
244
+ }
245
+
246
+ const client = new ApiClient(configStore.serverUrl, configStore.token);
247
+ try {
248
+ const parsedConfig = retrievalConfig ? JSON.parse(retrievalConfig) : undefined;
249
+ await client.bindKnowledgeToAgent(id, knowledgeId, parsedConfig);
250
+
251
+ if (getJsonFlag()) {
252
+ outputJson({ success: true, data: { agentId: id, knowledgeId, retrievalConfig: parsedConfig } });
253
+ return;
254
+ }
255
+ success(`Knowledge "${knowledgeId}" 已绑定到 Agent "${id}"`);
256
+ } catch (err) {
257
+ if (getJsonFlag()) {
258
+ outputJson({ success: false, error: { code: 'BIND_FAILED', message: err instanceof Error ? err.message : '未知错误' } });
259
+ process.exit(1);
260
+ }
261
+ error(`绑定失败: ${err instanceof Error ? err.message : '未知错误'}`);
262
+ process.exit(1);
263
+ }
264
+ }
265
+
266
+ export async function unbindKnowledge(id: string, knowledgeId: string): Promise<void> {
267
+ const config = loadConfig();
268
+ if (!config?.token) {
269
+ if (getJsonFlag()) {
270
+ outputJson({ success: false, error: { code: 'NOT_LOGGED_IN', message: '未登录,请先运行 arm login' } });
271
+ process.exit(1);
272
+ }
273
+ error('未登录,请先运行 arm login');
274
+ process.exit(1);
275
+ }
276
+
277
+ const client = new ApiClient(config.serverUrl, config.token);
278
+ try {
279
+ await client.unbindKnowledgeFromAgent(id, knowledgeId);
280
+
281
+ if (getJsonFlag()) {
282
+ outputJson({ success: true, data: { agentId: id, knowledgeId } });
283
+ return;
284
+ }
285
+ success(`Knowledge "${knowledgeId}" 已从 Agent "${id}" 解绑`);
286
+ } catch (err) {
287
+ if (getJsonFlag()) {
288
+ outputJson({ success: false, error: { code: 'UNBIND_FAILED', message: err instanceof Error ? err.message : '未知错误' } });
289
+ process.exit(1);
290
+ }
291
+ error(`解绑失败: ${err instanceof Error ? err.message : '未知错误'}`);
292
+ process.exit(1);
293
+ }
294
+ }
295
+
9
296
  export async function listAgents(): Promise<void> {
10
297
  const config = loadConfig();
11
298
  if (!config?.token) {
package/src/lib/client.ts CHANGED
@@ -271,4 +271,91 @@ export class ApiClient {
271
271
 
272
272
  return res.arrayBuffer();
273
273
  }
274
+
275
+ async createAgent(data: {
276
+ name: string;
277
+ description?: string;
278
+ prompt?: string;
279
+ avatar?: string;
280
+ skills?: Array<{ skillId: string; config?: Record<string, unknown> }>;
281
+ knowledges?: Array<{ knowledgeId: string; retrievalConfig?: { topK?: number; similarityThreshold?: number } }>;
282
+ }): Promise<Agent> {
283
+ const res = await this.request<Agent>('/agents', {
284
+ method: 'POST',
285
+ body: JSON.stringify(data),
286
+ });
287
+ if (!res.ok) {
288
+ throw new Error(res.msg);
289
+ }
290
+ return res.data;
291
+ }
292
+
293
+ async updateAgent(id: string, data: Partial<{
294
+ name: string;
295
+ description: string;
296
+ prompt: string;
297
+ avatar: string;
298
+ status: 'active' | 'draft';
299
+ }>): Promise<Agent> {
300
+ const res = await this.request<Agent>(`/agents/${id}`, {
301
+ method: 'PUT',
302
+ body: JSON.stringify(data),
303
+ });
304
+ if (!res.ok) {
305
+ throw new Error(res.msg);
306
+ }
307
+ return res.data;
308
+ }
309
+
310
+ async deleteAgent(id: string): Promise<void> {
311
+ const res = await this.request<null>(`/agents/${id}`, {
312
+ method: 'DELETE',
313
+ });
314
+ if (!res.ok) {
315
+ throw new Error(res.msg);
316
+ }
317
+ }
318
+
319
+ async bindSkillToAgent(agentId: string, skillId: string, config?: Record<string, unknown>): Promise<void> {
320
+ const res = await this.request<null>(`/agents/${agentId}/skills`, {
321
+ method: 'POST',
322
+ body: JSON.stringify({ skillId, config }),
323
+ });
324
+ if (!res.ok) {
325
+ throw new Error(res.msg);
326
+ }
327
+ }
328
+
329
+ async unbindSkillFromAgent(agentId: string, skillId: string): Promise<void> {
330
+ const res = await this.request<null>(`/agents/${agentId}/skills?skillId=${skillId}`, {
331
+ method: 'DELETE',
332
+ });
333
+ if (!res.ok) {
334
+ throw new Error(res.msg);
335
+ }
336
+ }
337
+
338
+ async bindKnowledgeToAgent(agentId: string, knowledgeId: string, retrievalConfig?: { topK?: number; similarityThreshold?: number }): Promise<void> {
339
+ const res = await this.request<null>(`/agents/${agentId}/knowledges`, {
340
+ method: 'POST',
341
+ body: JSON.stringify({ knowledgeId, retrievalConfig }),
342
+ });
343
+ if (!res.ok) {
344
+ throw new Error(res.msg);
345
+ }
346
+ }
347
+
348
+ async unbindKnowledgeFromAgent(agentId: string, knowledgeId: string): Promise<void> {
349
+ const res = await this.request<null>(`/agents/${agentId}/knowledges?knowledgeId=${knowledgeId}`, {
350
+ method: 'DELETE',
351
+ });
352
+ if (!res.ok) {
353
+ throw new Error(res.msg);
354
+ }
355
+ }
356
+
357
+ async getAgentByName(name: string): Promise<Agent | null> {
358
+ const result = await this.listAgents(name, 1, 1);
359
+ return result.agents.find(a => a.name === name) || null;
360
+ }
274
361
  }
package/src/main.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { login, logout, getCurrentUser } from './cmd/auth';
2
2
  import { listSkills, searchSkills, infoSkill, downloadSkill, uploadSkill, mySkills, deleteSkill, validateSkill } from './cmd/skill';
3
- import { listAgents, searchAgents, infoAgent, downloadAgent } from './cmd/agent';
3
+ import { listAgents, searchAgents, infoAgent, downloadAgent, createAgent, updateAgent, deleteAgent, bindSkill, unbindSkill, bindKnowledge, unbindKnowledge } from './cmd/agent';
4
4
  import { listKnowledge, searchKnowledge, infoKnowledge, downloadKnowledge, uploadKnowledge, myKnowledge, deleteKnowledge } from './cmd/knowledge';
5
5
  import { showServer, setServer } from './cmd/server';
6
6
 
@@ -186,6 +186,153 @@ async function main() {
186
186
  }
187
187
  await downloadAgent(args[2], args[3]);
188
188
  break;
189
+ case 'create':
190
+ if (!args[2]) {
191
+ console.error('用法: arm agent create <name> [--description="..."] [--prompt="..."] [--avatar="..."] [--skill=id] [--knowledge=id] [--skill-config=\'{...}\'] [--knowledge-config=\'{...}\'] [--json]');
192
+ process.exit(1);
193
+ }
194
+ {
195
+ const name = args[2];
196
+ const options: Record<string, string | undefined> = {};
197
+ const skills: string[] = [];
198
+ const knowledges: string[] = [];
199
+ const skillConfigs: string[] = [];
200
+ const knowledgeConfigs: string[] = [];
201
+
202
+ for (let i = 3; i < args.length; i++) {
203
+ const arg = args[i];
204
+ if (arg.startsWith('--description=')) {
205
+ options.description = arg.split('=').slice(1).join('=');
206
+ } else if (arg.startsWith('--prompt=')) {
207
+ options.prompt = arg.split('=').slice(1).join('=');
208
+ } else if (arg.startsWith('--avatar=')) {
209
+ options.avatar = arg.split('=').slice(1).join('=');
210
+ } else if (arg.startsWith('--skill=')) {
211
+ skills.push(arg.split('=').slice(1).join('='));
212
+ } else if (arg.startsWith('--knowledge=')) {
213
+ knowledges.push(arg.split('=').slice(1).join('='));
214
+ } else if (arg.startsWith('--skill-config=')) {
215
+ skillConfigs.push(arg.split('=').slice(1).join('='));
216
+ } else if (arg.startsWith('--knowledge-config=')) {
217
+ knowledgeConfigs.push(arg.split('=').slice(1).join('='));
218
+ }
219
+ }
220
+
221
+ await createAgent(name, {
222
+ description: options.description,
223
+ prompt: options.prompt,
224
+ avatar: options.avatar,
225
+ skills,
226
+ knowledges,
227
+ skillConfigs,
228
+ knowledgeConfigs,
229
+ });
230
+ }
231
+ break;
232
+ case 'update':
233
+ if (!args[2]) {
234
+ console.error('用法: arm agent update <id> [--name="..."] [--description="..."] [--prompt="..."] [--avatar="..."] [--status=active|draft] [--json]');
235
+ process.exit(1);
236
+ }
237
+ {
238
+ const id = args[2];
239
+ const options: Record<string, string | undefined> = {};
240
+
241
+ for (let i = 3; i < args.length; i++) {
242
+ const arg = args[i];
243
+ if (arg.startsWith('--name=')) {
244
+ options.name = arg.split('=').slice(1).join('=');
245
+ } else if (arg.startsWith('--description=')) {
246
+ options.description = arg.split('=').slice(1).join('=');
247
+ } else if (arg.startsWith('--prompt=')) {
248
+ options.prompt = arg.split('=').slice(1).join('=');
249
+ } else if (arg.startsWith('--avatar=')) {
250
+ options.avatar = arg.split('=').slice(1).join('=');
251
+ } else if (arg.startsWith('--status=')) {
252
+ options.status = arg.split('=').slice(1).join('=');
253
+ }
254
+ }
255
+
256
+ await updateAgent(id, {
257
+ name: options.name,
258
+ description: options.description,
259
+ prompt: options.prompt,
260
+ avatar: options.avatar,
261
+ status: options.status as 'active' | 'draft' | undefined,
262
+ });
263
+ }
264
+ break;
265
+ case 'delete':
266
+ if (!args[2]) {
267
+ console.error('用法: arm agent delete <id> [--json]');
268
+ process.exit(1);
269
+ }
270
+ await deleteAgent(args[2]);
271
+ break;
272
+ case 'bind':
273
+ if (!args[2]) {
274
+ console.error('用法: arm agent bind <id> --skill=<skillId> [--skill-config=\'{...}\'] 或 arm agent bind <id> --knowledge=<knowledgeId> [--knowledge-config=\'{...}\'] [--json]');
275
+ process.exit(1);
276
+ }
277
+ {
278
+ const id = args[2];
279
+ let skillId: string | undefined;
280
+ let knowledgeId: string | undefined;
281
+ let skillConfig: string | undefined;
282
+ let knowledgeConfig: string | undefined;
283
+
284
+ for (let i = 3; i < args.length; i++) {
285
+ const arg = args[i];
286
+ if (arg.startsWith('--skill=')) {
287
+ skillId = arg.split('=').slice(1).join('=');
288
+ } else if (arg.startsWith('--knowledge=')) {
289
+ knowledgeId = arg.split('=').slice(1).join('=');
290
+ } else if (arg.startsWith('--skill-config=')) {
291
+ skillConfig = arg.split('=').slice(1).join('=');
292
+ } else if (arg.startsWith('--knowledge-config=')) {
293
+ knowledgeConfig = arg.split('=').slice(1).join('=');
294
+ }
295
+ }
296
+
297
+ if (skillId) {
298
+ await bindSkill(id, skillId, skillConfig);
299
+ } else if (knowledgeId) {
300
+ await bindKnowledge(id, knowledgeId, knowledgeConfig);
301
+ } else {
302
+ console.error('用法: arm agent bind <id> --skill=<skillId> 或 --knowledge=<knowledgeId>');
303
+ process.exit(1);
304
+ }
305
+ }
306
+ break;
307
+ case 'unbind':
308
+ if (!args[2]) {
309
+ console.error('用法: arm agent unbind <id> --skill=<skillId> 或 --knowledge=<knowledgeId> [--json]');
310
+ process.exit(1);
311
+ }
312
+ {
313
+ const id = args[2];
314
+ let skillId: string | undefined;
315
+ let knowledgeId: string | undefined;
316
+
317
+ for (let i = 3; i < args.length; i++) {
318
+ const arg = args[i];
319
+ if (arg.startsWith('--skill=')) {
320
+ skillId = arg.split('=').slice(1).join('=');
321
+ } else if (arg.startsWith('--knowledge=')) {
322
+ knowledgeId = arg.split('=').slice(1).join('=');
323
+ }
324
+ }
325
+
326
+ if (skillId) {
327
+ await unbindSkill(id, skillId);
328
+ } else if (knowledgeId) {
329
+ await unbindKnowledge(id, knowledgeId);
330
+ } else {
331
+ console.error('用法: arm agent unbind <id> --skill=<skillId> 或 --knowledge=<knowledgeId>');
332
+ process.exit(1);
333
+ }
334
+ }
335
+ break;
189
336
  default:
190
337
  console.log(`
191
338
  可用命令:
@@ -193,6 +340,14 @@ async function main() {
193
340
  arm agent search <keyword> 搜索 Agent
194
341
  arm agent info <name> 查看 Agent 详情
195
342
  arm agent download <name> [dir] 下载 Agent
343
+ arm agent create <name> 创建 Agent (--description, --prompt, --avatar, --skill, --knowledge)
344
+ arm agent update <id> 更新 Agent (--name, --description, --prompt, --avatar, --status)
345
+ arm agent delete <id> 删除 Agent
346
+ arm agent bind <id> --skill=<id> 绑定 Skill 到 Agent
347
+ arm agent unbind <id> --skill=<id> 解绑 Skill
348
+ arm agent bind <id> --knowledge=<id> 绑定 Knowledge 到 Agent
349
+ arm agent unbind <id> --knowledge=<id> 解绑 Knowledge
350
+ 所有命令支持 --json 参数获取机器可读输出
196
351
  `);
197
352
  }
198
353
  break;
@@ -223,8 +378,16 @@ Agent Resource Management (arm)
223
378
  arm agent search <keyword> 搜索 Agent
224
379
  arm agent info <name> 查看 Agent 详情
225
380
  arm agent download <name> [dir] 下载 Agent
381
+ arm agent create <name> 创建 Agent
382
+ arm agent update <id> 更新 Agent
383
+ arm agent delete <id> 删除 Agent
384
+ arm agent bind <id> --skill=<id> 绑定 Skill
385
+ arm agent unbind <id> --skill=<id> 解绑 Skill
386
+ arm agent bind <id> --knowledge=<id> 绑定 Knowledge
387
+ arm agent unbind <id> --knowledge=<id> 解绑 Knowledge
226
388
  arm server 显示当前服务端
227
389
  arm server set <url> 设置服务端
390
+ 使用 arm <entity> -h 查看详细帮助
228
391
  `);
229
392
  }
230
393
  }
@@ -1,18 +0,0 @@
1
- ---
2
- name: 仿真调试助手
3
- version: 1.0.0
4
- description:
5
- skills:
6
-
7
- knowledges:
8
- - 仿真平台当前运行实例及实例运行日志排查.md
9
- - 仿真平台任务触发吸收器与占位触发吸收器使用场景.md
10
- - 仿真平台Loki日志排查方法.md
11
- - 仿真平台后端Swagger接口文档.md
12
- - 仿真货载生命周期查询流程.md
13
- - 仿真平台接口排查背景知识.md
14
- - 天车调度系统重组接口调用与日志分析方法.md
15
- ---
16
-
17
- # System Prompt
18
- 你是仿真调试助手
@@ -1,27 +0,0 @@
1
- ## 仿真平台日志排查流程
2
-
3
- ### Loki日志平台地址
4
- ```
5
- http://192.168.59.100:4000/explore?schemaVersion=1&panes=%7B%22rxo%22:%7B%22datasource%22:%22P8E80F9AEF21F6940%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22expr%22:%22%7Bhost_name%3D%5C%22192.168.58.23%5C%22%7D%20%7C%3D%20%60%60%22,%22queryType%22:%22range%22,%22datasource%22:%7B%22type%22:%22loki%22,%22uid%22:%22P8E80F9AEF21F6940%22%7D,%22editorMode%22:%22builder%22,%22direction%22:%22backward%22%7D%5D,%22range%22:%7B%22from%22:%22now-1h%22,%22to%22:%22now%22%7D,%22compact%22:false%7D%7D&orgId=1
6
- ```
7
-
8
- ### 日志查询方法
9
-
10
- #### 1. 通过host_name过滤
11
- - 使用 `host_name` 标签指定对应的环境
12
- - 示例:`{host_name="192.168.58.23"}`
13
-
14
- #### 2. IP地址模糊匹配流程
15
- 如果用户提供的是模糊地址(如只提供部分IP或描述性信息):
16
- 1. 先查询**仿真平台实例列表**
17
- 2. 从实例列表中匹配对应的host_name
18
- 3. 使用匹配到的host_name查询日志
19
-
20
- #### 3. 查询限制(重要)
21
- - **必须给定查询参数**,不能空查询
22
- - **限制查询行数在200条以内**,避免查询过大导致性能问题
23
-
24
- ### 使用场景
25
- - 仿真平台环境故障排查
26
- - 通过host_name定位特定环境的日志
27
- - IP地址不明确时先查询实例列表再查询日志
@@ -1,18 +0,0 @@
1
- ## 问题描述
2
- 货载编码: 10021,从库位由堆垛机运送到指定点位,任务hl_1774014921000_01,但货载没被吸收。
3
-
4
- ## 根本原因
5
- 点位10021配置的是**任务触发吸收器**,但这个吸收器类型只适用于**输送线任务**。
6
-
7
- 10021点位是堆垛机放货点,不存在输送线任务,因此任务触发吸收器无法正常工作。
8
-
9
- ## 解决方案
10
- 将点位10021的吸收器类型从**任务触发吸收器**改为**占位触发吸收器**。
11
-
12
- ## 知识点
13
- 1. **任务触发吸收器**:适用于输送线任务,需要任务关联才能触发
14
- 2. **占位触发吸收器**:适用于堆垛机放货点等场景,当货物占位时自动触发吸收,不依赖任务关联
15
-
16
- ## 配置建议
17
- - 堆垛机放货点 → 使用占位触发吸收器
18
- - 输送线转运点 → 使用任务触发吸收器
@@ -1,22 +0,0 @@
1
- ## 仿真平台后端接口访问
2
-
3
- ### 默认端口
4
- 仿真平台后端服务默认端口为 **6173**
5
-
6
- ### Swagger文档地址
7
- - Swagger UI: `http://{IP}:6173/swagger/index.html`
8
- - Swagger JSON: `http://{IP}:6173/swagger/Default/swagger.json`
9
-
10
- ### 接口示例
11
- 以192.168.57.140环境为例:
12
- - Swagger UI: http://192.168.57.140:6173/swagger/index.html
13
- - Swagger JSON: http://192.168.57.140:6173/swagger/Default/swagger.json
14
-
15
- ### 使用场景
16
- 1. 查看仿真平台提供的所有REST API接口
17
- 2. 查看接口的请求参数、响应格式
18
- 3. 在线测试API接口
19
- 4. 了解接口的数据模型和Schema
20
-
21
- ### 访问方式
22
- 直接通过浏览器访问Swagger UI即可查看完整的API文档,支持在线调试。