@eum-agent/agent-management 0.0.0-stage → 1.0.0

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 (4) hide show
  1. package/dist/index.js +120 -0
  2. package/package.json +45 -3
  3. package/ui/ui.js +2961 -0
  4. package/README.md +0 -3
package/dist/index.js ADDED
@@ -0,0 +1,120 @@
1
+ import { existsSync } from "node:fs";
2
+ import { fileURLToPath } from "node:url";
3
+ import { z } from "zod";
4
+ //#region src/tool-names.ts
5
+ /** Canonical names shared by tool registration and browser presentation. */
6
+ const AGENT_TOOL_NAMES = [
7
+ "agent_read",
8
+ "agent_update",
9
+ "agent_create"
10
+ ];
11
+ //#endregion
12
+ //#region src/tools.ts
13
+ const ModelRef = z.strictObject({
14
+ providerId: z.string().min(1),
15
+ model: z.string().min(1)
16
+ });
17
+ const AgentCreateInput = z.strictObject({
18
+ name: z.string(),
19
+ description: z.string().optional(),
20
+ prompts: z.strictObject({
21
+ identity: z.string().optional(),
22
+ instructions: z.string().optional(),
23
+ style: z.string().optional(),
24
+ reminder: z.string().optional()
25
+ }).optional(),
26
+ defaultModel: ModelRef.nullable().optional(),
27
+ startsSessions: z.boolean().optional()
28
+ });
29
+ const Update = z.strictObject({
30
+ name: z.string().optional(),
31
+ description: z.string().optional(),
32
+ prompts: z.strictObject({
33
+ identity: z.string().optional(),
34
+ instructions: z.string().optional(),
35
+ style: z.string().optional(),
36
+ reminder: z.string().optional()
37
+ }).optional(),
38
+ defaultModel: ModelRef.nullable().optional(),
39
+ startsSessions: z.boolean().optional(),
40
+ expectedRevision: z.string().optional()
41
+ }).refine(({ name, description, prompts, defaultModel, startsSessions }) => name !== void 0 || description !== void 0 || Object.keys(prompts ?? {}).length > 0 || defaultModel !== void 0 || startsSessions !== void 0, "provide at least one field to change");
42
+ /** Registers owner-scoped tools and guidance over the ordinary tool source. */
43
+ function registerAgentTools(container, agent, create) {
44
+ const modelConfiguration = () => {
45
+ const service = container.services.find("agent-model-configuration");
46
+ if (!service) throw new Error("model configuration capability is unavailable");
47
+ return service;
48
+ };
49
+ container.tools.register({
50
+ name: "agent_create",
51
+ description: "Create a new agent after approval. This does not start a session.",
52
+ inputSchema: AgentCreateInput,
53
+ execute: ({ defaultModel, ...input }, exec) => create({
54
+ ...input,
55
+ ...defaultModel === void 0 ? {} : { extensionData: modelConfiguration().withDefault(defaultModel) }
56
+ }, exec)
57
+ });
58
+ container.tools.register({
59
+ name: "agent_read",
60
+ description: "Read your own agent definition, prompt slots and read-only tool restrictions. The revision can protect a later agent_update against concurrent edits.",
61
+ inputSchema: z.strictObject({}),
62
+ async execute(_input, exec) {
63
+ return { content: JSON.stringify(agent.read(exec)) };
64
+ }
65
+ });
66
+ container.tools.register({
67
+ name: "agent_update",
68
+ description: "Update your own name, description, prompt slots, default model or direct conversation settings after approval. Omitted fields remain unchanged. Tool permissions cannot be changed here.",
69
+ inputSchema: Update,
70
+ execute: ({ expectedRevision, defaultModel, ...patch }, exec) => agent.update(exec, {
71
+ ...patch,
72
+ ...defaultModel === void 0 ? {} : { extensionData: modelConfiguration().withDefault(defaultModel, agent.read(exec).extensionData) }
73
+ }, expectedRevision)
74
+ });
75
+ container.tools.guide({
76
+ title: "Your agent definition",
77
+ entries: [
78
+ {
79
+ tools: ["agent_create"],
80
+ text: "Create only the requested agent after approval. Report its id and actual configuration. Creation does not start a session."
81
+ },
82
+ {
83
+ tools: ["agent_read"],
84
+ text: "Read your current definition before editing. A rules-file read failure is not an empty rules file."
85
+ },
86
+ {
87
+ tools: ["agent_update"],
88
+ text: "Change only the requested fields. Approval mode governs persistence; tool permissions and credentials cannot be changed here. Report the actual result and when it takes effect."
89
+ }
90
+ ]
91
+ });
92
+ }
93
+ //#endregion
94
+ //#region src/index.ts
95
+ /** Concrete Agent tools and their guidance, withdrawn together with this extension. */
96
+ /** Each tool can be disabled independently without withdrawing Agent framework state. */
97
+ const AgentConfig = z.strictObject({ disabled: z.array(z.enum(AGENT_TOOL_NAMES)).default([]) }).default({ disabled: [] });
98
+ /** Agent sessions and configuration remain framework-owned after tool withdrawal. */
99
+ const agentPlugin = {
100
+ name: "@eum-agent/agent-management",
101
+ requires: ["agent-definition", "agent-creation"],
102
+ optionalServices: ["agent-model-configuration"],
103
+ configSchema: AgentConfig,
104
+ apply(ctx, config) {
105
+ const module = fileURLToPath(new URL("../ui/ui.js", import.meta.url));
106
+ if (existsSync(module)) ctx.client.registerUi({ module });
107
+ const disabled = new Set(config.disabled);
108
+ const definition = ctx.services.get("agent-definition");
109
+ const creation = ctx.services.get("agent-creation");
110
+ registerAgentTools({
111
+ ...ctx,
112
+ tools: {
113
+ ...ctx.tools,
114
+ register: (tool) => disabled.has(tool.name) ? () => {} : ctx.tools.register(tool)
115
+ }
116
+ }, definition, creation.create);
117
+ }
118
+ };
119
+ //#endregion
120
+ export { AGENT_TOOL_NAMES, AgentConfig, agentPlugin, agentPlugin as default, registerAgentTools };
package/package.json CHANGED
@@ -1,6 +1,48 @@
1
1
  {
2
2
  "name": "@eum-agent/agent-management",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "displayName": {
4
+ "en-US": "Agent Management",
5
+ "zh-CN": "智能体管理"
6
+ },
7
+ "version": "1.0.0",
8
+ "type": "module",
9
+ "description": "Agent definitions, workspaces, avatars and management tools",
10
+ "license": "MIT",
11
+ "exports": {
12
+ ".": {
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "ui"
19
+ ],
20
+ "dependencies": {
21
+ "zod": "^4.4.3"
22
+ },
23
+ "devDependencies": {
24
+ "@eum-agent/plugin": "1.0.0",
25
+ "@types/react": "^19.2.18",
26
+ "@types/react-dom": "^19.2.5",
27
+ "react": "^19.2.0",
28
+ "react-dom": "^19.2.0",
29
+ "vite": "^8.2.2",
30
+ "@eum-agent/protocol": "1.0.0",
31
+ "@eum-agent/kernel": "1.0.0",
32
+ "lucide-react": "^1.40.0",
33
+ "zustand": "^5.0.15"
34
+ },
35
+ "yaoguang": {
36
+ "description": {
37
+ "en-US": "Agent definitions, workspaces, avatars and management tools",
38
+ "zh-CN": "智能体定义、工作区、头像与管理工具"
39
+ },
40
+ "dependencies": {},
41
+ "kind": "extension"
42
+ },
43
+ "scripts": {
44
+ "build": "tsdown && vite build",
45
+ "test": "vitest run",
46
+ "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.ui.json"
47
+ }
6
48
  }