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,243 @@
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
+ * Groups that this agent belongs to
100
+ *
101
+ * Defines organizational membership for discovery, coordination, and management.
102
+ * Groups can represent teams, projects, clusters, departments, or any arbitrary
103
+ * organizational structure. Supports both simple string IDs and rich objects
104
+ * with properties.
105
+ *
106
+ * @example
107
+ * // Simple string references
108
+ * ["team:backend", "project:api-v2", "cluster:production"]
109
+ *
110
+ * @example
111
+ * // Rich objects with properties
112
+ * [
113
+ * { id: "team:backend", properties: { role: "lead", tier: "senior" } },
114
+ * { id: "project:api-v2", properties: { status: "active", priority: 1 } }
115
+ * ]
116
+ */
117
+ groupIds: z
118
+ .array(z.union([z.string(), GroupSchema]))
119
+ .default([])
120
+ .describe("List of group ids that this agent belongs to"),
121
+ /**
122
+ * Agent IDs that this agent can call
123
+ *
124
+ * Explicitly defines which other agents this agent has permission to invoke.
125
+ * These could be local agent instances, remote agent servers, or any agent
126
+ * accessible in the runtime environment. This provides explicit access control
127
+ * separate from group membership.
128
+ *
129
+ * @example ["database-specialist", "security-auditor", "code-reviewer"]
130
+ * @example ["agent://team-lead", "https://agents.example.com/research"]
131
+ */
132
+ agentIds: z
133
+ .array(z.string())
134
+ .optional()
135
+ .describe("The agent ids that this agent can call"),
136
+ /**
137
+ * System instructions for the agent
138
+ *
139
+ * The core prompt that defines the agent's behavior, expertise, methodology,
140
+ * and output format. This is typically provided in the markdown body of an
141
+ * agent.md file and defines the agent's persona and capabilities.
142
+ *
143
+ * @example
144
+ * ```
145
+ * You are a backend system architect specializing in scalable API design.
146
+ *
147
+ * ## Focus Areas
148
+ * - RESTful API design with proper versioning
149
+ * - Microservice boundaries and communication patterns
150
+ * - Database schema design and optimization
151
+ *
152
+ * ## Methodology
153
+ * 1. Analyze requirements and constraints
154
+ * 2. Design contract-first APIs
155
+ * 3. Consider scalability from day one
156
+ * ```
157
+ */
158
+ instructions: z.string().describe("System prompt for the agent"),
159
+ });
160
+ /**
161
+ * Agent configuration schema
162
+ *
163
+ * Extends AgentDefinition with deployment-specific configuration including
164
+ * server connections and runtime metadata. This schema represents the full
165
+ * configuration needed to instantiate and run an agent in a specific environment.
166
+ *
167
+ * Use this when:
168
+ * - Deploying an agent to a runtime environment
169
+ * - Connecting to specific MCP or A2A servers
170
+ * - Adding environment-specific metadata
171
+ *
172
+ * @example
173
+ * ```typescript
174
+ * const config: AgentConfiguration = {
175
+ * // AgentDefinition fields
176
+ * id: "backend-architect",
177
+ * name: "Backend System Architect",
178
+ * description: "Design RESTful APIs and microservice architectures",
179
+ * model: "openai/gpt-4",
180
+ * toolIds: ["filesystem", "database-analyzer"],
181
+ * instructions: "You are a backend system architect...",
182
+ *
183
+ * // Configuration-specific fields
184
+ * servers: [
185
+ * {
186
+ * type: "mcp",
187
+ * id: "filesystem",
188
+ * url: "http://localhost:3000/mcp/filesystem"
189
+ * },
190
+ * {
191
+ * type: "a2a",
192
+ * id: "database-specialist",
193
+ * url: "https://agents.example.com/database-specialist"
194
+ * }
195
+ * ],
196
+ * metadata: {
197
+ * environment: "production",
198
+ * region: "us-east-1",
199
+ * version: "1.2.3"
200
+ * }
201
+ * }
202
+ * ```
203
+ */
204
+ export const AgentConfigurationSchema = AgentDefinitionSchema.extend({
205
+ /**
206
+ * Service connections for this agent
207
+ *
208
+ * Defines the actual service endpoints for MCP tool services and A2A agent services
209
+ * that this agent will connect to at runtime. Each service must have a type,
210
+ * unique ID, and connection URL.
211
+ *
212
+ * @example
213
+ * [
214
+ * { type: "mcp", id: "filesystem", url: "http://localhost:3000/mcp/fs" },
215
+ * { type: "a2a", id: "researcher", url: "https://agents.example.com/research" }
216
+ * { type: "a2a", uri: "local-agent-id", parameters: { name: "John Doe" } }
217
+ * ]
218
+ */
219
+ services: z
220
+ .array(ServiceSchema)
221
+ .default([])
222
+ .describe("List of MCP or A2A services"),
223
+ /**
224
+ * Runtime metadata for the agent
225
+ *
226
+ * Arbitrary key-value pairs for environment-specific configuration, tracking,
227
+ * or runtime behavior customization. Common uses include environment tags,
228
+ * version tracking, deployment information, or feature flags.
229
+ *
230
+ * @example
231
+ * {
232
+ * environment: "production",
233
+ * region: "us-east-1",
234
+ * deployedBy: "ci-pipeline",
235
+ * deployedAt: "2025-01-15T10:30:00Z",
236
+ * version: "1.2.3"
237
+ * }
238
+ */
239
+ metadata: z
240
+ .record(z.string(), z.string())
241
+ .optional()
242
+ .describe("Runtime metadata for environment-specific configuration"),
243
+ });