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