@agentuity/server 0.0.4 → 0.0.5

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 (2) hide show
  1. package/README.md +27 -29
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -29,31 +29,25 @@ logger.info('Server running on http://localhost:3000');
29
29
  ### Defining an Agent
30
30
 
31
31
  ```typescript
32
- import { defineAgent } from '@agentuity/server';
32
+ import { type AgentContext, createAgent } from '@agentuity/server';
33
33
  import { z } from 'zod';
34
34
 
35
- const myAgent = defineAgent({
36
- metadata: {
37
- id: 'my-agent',
38
- identifier: 'my-agent',
39
- name: 'My Agent',
40
- description: 'Example agent',
41
- filename: 'src/agents/my-agent/agent.ts',
42
- version: '1.0.0'
35
+ const agent = createAgent({
36
+ schema: {
37
+ input: z.object({
38
+ message: z.string()
39
+ }),
40
+ output: z.object({
41
+ response: z.string()
42
+ }),
43
43
  },
44
- inputSchema: z.object({
45
- message: z.string()
46
- }),
47
- outputSchema: z.object({
48
- response: z.string()
49
- }),
50
- handler: async (ctx, input) => {
44
+ handler: async (ctx: AgentContext, input) => {
51
45
  ctx.logger.info('Processing message:', input.message);
52
46
  return { response: `You said: ${input.message}` };
53
- }
47
+ },
54
48
  });
55
49
 
56
- export default myAgent;
50
+ export default agent;
57
51
  ```
58
52
 
59
53
  ### Creating Custom Routes
@@ -133,16 +127,14 @@ Creates a new Agentuity application instance.
133
127
  - `server` - Server instance with `listen()` method
134
128
  - `logger` - Structured logger
135
129
 
136
- ### defineAgent(config)
130
+ ### createAgent(config)
137
131
 
138
- Defines a type-safe agent with input/output validation.
132
+ Creates a type-safe agent with input/output validation.
139
133
 
140
134
  **Config:**
141
- - `metadata` - Agent metadata (id, name, description, etc.)
142
- - `inputSchema?` - Schema for input validation (Zod, Valibot, etc.)
143
- - `outputSchema?` - Schema for output validation
144
- - `stream?` - Whether the agent returns a stream
145
- - `handler` - Agent handler function
135
+ - `schema.input?` - Schema for input validation (Zod, Valibot, etc.)
136
+ - `schema.output?` - Schema for output validation
137
+ - `handler` - Agent handler function `(ctx: AgentContext, input) => output`
146
138
 
147
139
  ### createRouter()
148
140
 
@@ -184,12 +176,15 @@ Agentuity provides built-in storage abstractions:
184
176
  Access these via the agent context:
185
177
 
186
178
  ```typescript
187
- const myAgent = defineAgent({
179
+ const agent = createAgent({
180
+ schema: {
181
+ output: z.object({ value: z.string().optional() }),
182
+ },
188
183
  handler: async (ctx, input) => {
189
184
  await ctx.kv.set('key', 'value');
190
185
  const value = await ctx.kv.get('key');
191
186
  return { value };
192
- }
187
+ },
193
188
  });
194
189
  ```
195
190
 
@@ -198,7 +193,10 @@ const myAgent = defineAgent({
198
193
  Built-in OpenTelemetry support for logging, tracing, and metrics:
199
194
 
200
195
  ```typescript
201
- const myAgent = defineAgent({
196
+ const agent = createAgent({
197
+ schema: {
198
+ output: z.object({ success: z.boolean() }),
199
+ },
202
200
  handler: async (ctx, input) => {
203
201
  ctx.logger.info('Processing request');
204
202
 
@@ -207,7 +205,7 @@ const myAgent = defineAgent({
207
205
  span.end();
208
206
 
209
207
  return { success: true };
210
- }
208
+ },
211
209
  });
212
210
  ```
213
211
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentuity/server",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./dist/index.d.ts",