agent-def 0.0.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.
@@ -0,0 +1,248 @@
1
+ /**
2
+ * Copyright 2025 The Artinet Project
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { z } from "zod";
6
+ import { AgentCardSchema } from "@artinet/sdk";
7
+ import { ServiceSchema } from "@artinet/types";
8
+ /**
9
+ * Group definition
10
+ *
11
+ * Represents a flexible organizational unit that an agent can belong to.
12
+ * Groups can represent teams, projects, clusters, departments, or any arbitrary
13
+ * organizational structure.
14
+ *
15
+ * @example
16
+ * // Simple team group
17
+ * { id: "team:backend", properties: { role: "lead", tier: "senior" } }
18
+ *
19
+ * @example
20
+ * // Project group
21
+ * { id: "project:api-v2", properties: { status: "active", priority: 1 } }
22
+ *
23
+ * @example
24
+ * // Cluster group
25
+ * { id: "cluster:production-us-east", properties: { region: "us-east-1" } }
26
+ */
27
+ export const GroupSchema = z.object({
28
+ id: z
29
+ .string()
30
+ .describe("Group identifier (e.g., 'team:backend', 'project:api-v2')"),
31
+ properties: z
32
+ .record(z.string(), z.unknown())
33
+ .optional()
34
+ .describe("Optional properties of the group (e.g., role, priority, status)"),
35
+ });
36
+ /**
37
+ * Agent definition schema
38
+ *
39
+ * The core specification for an Artinet agent, defining its identity, capabilities,
40
+ * organizational membership, and behavior. This schema is designed to be portable
41
+ * and can be serialized in agent.md files with YAML frontmatter.
42
+ *
43
+ * @example
44
+ * ```yaml
45
+ * ---
46
+ * id: backend-architect
47
+ * name: Backend System Architect
48
+ * description: Design RESTful APIs and microservice architectures
49
+ * model: openai/gpt-4
50
+ * version: "1.0.0"
51
+ * toolIds:
52
+ * - filesystem
53
+ * - database-analyzer
54
+ * groupIds:
55
+ * - team:backend
56
+ * - project:api-v2
57
+ * agentIds:
58
+ * - database-specialist
59
+ * - security-auditor
60
+ * instructions: |
61
+ * You are a backend system architect specializing in scalable API design...
62
+ * ---
63
+ * ```
64
+ */
65
+ export const AgentDefinitionSchema = AgentCardSchema.partial({
66
+ protocolVersion: true,
67
+ url: true,
68
+ capabilities: true,
69
+ defaultInputModes: true,
70
+ defaultOutputModes: true,
71
+ }).extend({
72
+ /**
73
+ * Optional agent ID - will be generated if not provided
74
+ *
75
+ * Use kebab-case for consistency (e.g., 'backend-architect', 'code-reviewer')
76
+ */
77
+ id: z.string().optional().describe("Unique agent identifier"),
78
+ /**
79
+ * Optional model specification
80
+ *
81
+ * Specifies the LLM model to use for this agent.
82
+ *
83
+ * @example "openai/gpt-4o-mini"
84
+ * @example "anthropic/claude-3-opus-20241022"
85
+ * @example "deepseek-ai/DeepSeek-R1"
86
+ */
87
+ modelId: z.string().optional().describe("Model identifier"),
88
+ /**
89
+ * Tool IDs that this agent can use
90
+ *
91
+ * A flexible list of tool identifiers that reference MCP servers, in-memory
92
+ * functions, or any other tool providers available in the runtime environment.
93
+ * Tools are resolved by the agent runtime based on these IDs.
94
+ *
95
+ * @example ["filesystem", "web-search", "code-analyzer"]
96
+ * @example ["mcp-server-git", "mcp-server-postgres", "custom-api-client"]
97
+ */
98
+ toolIds: z
99
+ .array(z.string())
100
+ .default([])
101
+ .describe("List of tool ids that this agent can use"),
102
+ /**
103
+ * Agent IDs that this agent can call
104
+ *
105
+ * Explicitly defines which other agents this agent has permission to invoke.
106
+ * These could be local agent instances, remote agent servers, or any agent
107
+ * accessible in the runtime environment. This provides explicit access control
108
+ * separate from group membership.
109
+ *
110
+ * @example ["database-specialist", "security-auditor", "code-reviewer"]
111
+ * @example ["agent://team-lead", "https://agents.example.com/research"]
112
+ */
113
+ agentIds: z
114
+ .array(z.string())
115
+ .optional()
116
+ .describe("The agent ids that this agent can call"),
117
+ /**
118
+ * Groups that this agent belongs to
119
+ *
120
+ * Defines organizational membership for discovery, coordination, and management.
121
+ * Groups can represent teams, projects, clusters, departments, or any arbitrary
122
+ * organizational structure. Supports both simple string IDs and rich objects
123
+ * with properties.
124
+ *
125
+ * @example
126
+ * // Simple string references
127
+ * ["team:backend", "project:api-v2", "cluster:production"]
128
+ *
129
+ * @example
130
+ * // Rich objects with properties
131
+ * [
132
+ * { id: "team:backend", properties: { role: "lead", tier: "senior" } },
133
+ * { id: "project:api-v2", properties: { status: "active", priority: 1 } }
134
+ * ]
135
+ */
136
+ groupIds: z
137
+ .array(z.union([z.string(), GroupSchema]))
138
+ .optional()
139
+ .default([])
140
+ .describe("List of group ids that this agent belongs to"),
141
+ /**
142
+ * System instructions for the agent
143
+ *
144
+ * The core prompt that defines the agent's behavior, expertise, methodology,
145
+ * and output format. This is typically provided in the markdown body of an
146
+ * agent.md file and defines the agent's persona and capabilities.
147
+ *
148
+ * @example
149
+ * ```
150
+ * You are a backend system architect specializing in scalable API design.
151
+ *
152
+ * ## Focus Areas
153
+ * - RESTful API design with proper versioning
154
+ * - Microservice boundaries and communication patterns
155
+ * - Database schema design and optimization
156
+ *
157
+ * ## Methodology
158
+ * 1. Analyze requirements and constraints
159
+ * 2. Design contract-first APIs
160
+ * 3. Consider scalability from day one
161
+ * ```
162
+ */
163
+ instructions: z.string().describe("System prompt for the agent"),
164
+ });
165
+ /**
166
+ * Agent configuration schema
167
+ *
168
+ * Extends AgentDefinition with deployment-specific configuration including
169
+ * server connections and runtime metadata. This schema represents the full
170
+ * configuration needed to instantiate and run an agent in a specific environment.
171
+ *
172
+ * Use this when:
173
+ * - Deploying an agent to a runtime environment
174
+ * - Connecting to specific MCP or A2A servers
175
+ * - Adding environment-specific metadata
176
+ *
177
+ * @example
178
+ * ```typescript
179
+ * const config: AgentConfiguration = {
180
+ * // AgentDefinition fields
181
+ * id: "backend-architect",
182
+ * name: "Backend System Architect",
183
+ * description: "Design RESTful APIs and microservice architectures",
184
+ * model: "openai/gpt-4",
185
+ * toolIds: ["filesystem", "database-analyzer"],
186
+ * instructions: "You are a backend system architect...",
187
+ *
188
+ * // Configuration-specific fields
189
+ * servers: [
190
+ * {
191
+ * type: "mcp",
192
+ * id: "filesystem",
193
+ * url: "http://localhost:3000/mcp/filesystem"
194
+ * },
195
+ * {
196
+ * type: "a2a",
197
+ * id: "database-specialist",
198
+ * url: "https://agents.example.com/database-specialist"
199
+ * }
200
+ * ],
201
+ * metadata: {
202
+ * environment: "production",
203
+ * region: "us-east-1",
204
+ * version: "1.2.3"
205
+ * }
206
+ * }
207
+ * ```
208
+ */
209
+ export const AgentConfigurationSchema = AgentDefinitionSchema.extend({
210
+ /**
211
+ * Service connections for this agent
212
+ *
213
+ * Defines the actual service endpoints for MCP tool services and A2A agent services
214
+ * that this agent will connect to at runtime. Each service must have a type,
215
+ * unique ID, and connection URL.
216
+ *
217
+ * @example
218
+ * [
219
+ * { type: "mcp", id: "filesystem", url: "http://localhost:3000/mcp/fs" },
220
+ * { type: "a2a", id: "researcher", url: "https://agents.example.com/research" }
221
+ * { type: "a2a", uri: "local-agent-id", parameters: { name: "John Doe" } }
222
+ * ]
223
+ */
224
+ services: z
225
+ .array(ServiceSchema)
226
+ .default([])
227
+ .describe("List of MCP or A2A services"),
228
+ /**
229
+ * Runtime metadata for the agent
230
+ *
231
+ * Arbitrary key-value pairs for environment-specific configuration, tracking,
232
+ * or runtime behavior customization. Common uses include environment tags,
233
+ * version tracking, deployment information, or feature flags.
234
+ *
235
+ * @example
236
+ * {
237
+ * environment: "production",
238
+ * region: "us-east-1",
239
+ * deployedBy: "ci-pipeline",
240
+ * deployedAt: "2025-01-15T10:30:00Z",
241
+ * version: "1.2.3"
242
+ * }
243
+ */
244
+ metadata: z
245
+ .record(z.string(), z.string())
246
+ .optional()
247
+ .describe("Runtime metadata for environment-specific configuration"),
248
+ });
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "agent-def",
3
+ "version": "0.0.1",
4
+ "description": "A standardized definition for collaborative agents.",
5
+ "main": "dist/src/definition.js",
6
+ "module": "dist/src/definition.js",
7
+ "types": "dist/src/definition.d.ts",
8
+ "type": "module",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/src/definition.d.ts",
12
+ "import": "./dist/src/definition.js",
13
+ "default": "./dist/src/definition.js"
14
+ }
15
+ },
16
+ "scripts": {
17
+ "build": "tsc --project tsconfig.json",
18
+ "generate:schema": "tsx ./scripts/generate-schema.ts",
19
+ "lint": "eslint .",
20
+ "clean": "rimraf dist",
21
+ "prepublishOnly": "npm run build"
22
+ },
23
+ "keywords": [
24
+ "artinet",
25
+ "agent",
26
+ "definition",
27
+ "configuration",
28
+ "ai",
29
+ "artificial intelligence"
30
+ ],
31
+ "author": "artinet",
32
+ "license": "Apache-2.0",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/the-artinet-project/agent-def.git"
36
+ },
37
+ "bugs": {
38
+ "url": "https://github.com/the-artinet-project/agent-def/issues"
39
+ },
40
+ "homepage": "https://github.com/the-artinet-project/agent-def#readme",
41
+ "files": [
42
+ "./dist/**/*",
43
+ "./package.json",
44
+ "./README.md"
45
+ ],
46
+ "engines": {
47
+ "node": ">=18.9.1"
48
+ },
49
+ "rootDir": ".",
50
+ "devDependencies": {
51
+ "@eslint/js": "^9.25.1",
52
+ "@types/node": "^22.15.3",
53
+ "eslint": "^9.25.1",
54
+ "globals": "^16.0.0",
55
+ "jest": "^29.7.0",
56
+ "rimraf": "^5.0.5",
57
+ "ts-jest": "^29.3.2",
58
+ "ts-node": "^10.9.2",
59
+ "typescript": "^5.8.3",
60
+ "typescript-eslint": "^8.31.1",
61
+ "zod-to-json-schema": "^3.25.0"
62
+ },
63
+ "dependencies": {
64
+ "@artinet/sdk": "^0.5.18",
65
+ "@artinet/types": "^0.0.8",
66
+ "zod": "^3.23.8"
67
+ }
68
+ }