@reminix/runtime 0.0.7 → 0.0.8
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.
- package/README.md +343 -167
- package/dist/agent-adapter.d.ts +4 -9
- package/dist/agent-adapter.d.ts.map +1 -1
- package/dist/agent-adapter.js +3 -13
- package/dist/agent-adapter.js.map +1 -1
- package/dist/agent.d.ts +149 -80
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +279 -150
- package/dist/agent.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +20 -40
- package/dist/server.js.map +1 -1
- package/dist/types.d.ts +8 -13
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/agent.js
CHANGED
|
@@ -2,24 +2,29 @@
|
|
|
2
2
|
* Agent classes for Reminix Runtime.
|
|
3
3
|
*/
|
|
4
4
|
import { VERSION } from './version.js';
|
|
5
|
+
/**
|
|
6
|
+
* Default parameters schema for agents.
|
|
7
|
+
* Request: { prompt: '...' }
|
|
8
|
+
*/
|
|
9
|
+
const DEFAULT_AGENT_PARAMETERS = {
|
|
10
|
+
type: 'object',
|
|
11
|
+
properties: {
|
|
12
|
+
prompt: { type: 'string', description: 'The prompt or task for the agent' },
|
|
13
|
+
},
|
|
14
|
+
required: ['prompt'],
|
|
15
|
+
};
|
|
5
16
|
/**
|
|
6
17
|
* Abstract base class defining the agent interface.
|
|
7
18
|
*
|
|
8
19
|
* This is the core contract that all agents must fulfill.
|
|
9
20
|
* Use `Agent` for callback-based registration or extend
|
|
10
|
-
* `
|
|
21
|
+
* `AgentAdapter` for framework adapters.
|
|
11
22
|
*/
|
|
12
23
|
export class AgentBase {
|
|
13
24
|
/**
|
|
14
|
-
* Whether
|
|
25
|
+
* Whether execute supports streaming. Override to enable.
|
|
15
26
|
*/
|
|
16
|
-
get
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Whether chat supports streaming. Override to enable.
|
|
21
|
-
*/
|
|
22
|
-
get chatStreaming() {
|
|
27
|
+
get streaming() {
|
|
23
28
|
return false;
|
|
24
29
|
}
|
|
25
30
|
/**
|
|
@@ -27,20 +32,18 @@ export class AgentBase {
|
|
|
27
32
|
* Override this to provide custom metadata.
|
|
28
33
|
*/
|
|
29
34
|
get metadata() {
|
|
30
|
-
return {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
async *invokeStream(_request) {
|
|
37
|
-
throw new Error('Streaming not implemented for this agent');
|
|
35
|
+
return {
|
|
36
|
+
type: 'agent',
|
|
37
|
+
parameters: DEFAULT_AGENT_PARAMETERS,
|
|
38
|
+
requestKeys: ['prompt'],
|
|
39
|
+
responseKeys: ['output'],
|
|
40
|
+
};
|
|
38
41
|
}
|
|
39
42
|
/**
|
|
40
|
-
* Handle a streaming
|
|
43
|
+
* Handle a streaming execute request.
|
|
41
44
|
*/
|
|
42
45
|
// eslint-disable-next-line require-yield
|
|
43
|
-
async *
|
|
46
|
+
async *executeStream(_request) {
|
|
44
47
|
throw new Error('Streaming not implemented for this agent');
|
|
45
48
|
}
|
|
46
49
|
/**
|
|
@@ -53,7 +56,7 @@ export class AgentBase {
|
|
|
53
56
|
* ```typescript
|
|
54
57
|
* // Vercel Edge Function
|
|
55
58
|
* const agent = new Agent('my-agent');
|
|
56
|
-
* agent.
|
|
59
|
+
* agent.onExecute(async (req) => ({ output: 'Hello!' }));
|
|
57
60
|
* export default agent.toHandler();
|
|
58
61
|
*
|
|
59
62
|
* // Cloudflare Worker
|
|
@@ -93,71 +96,41 @@ export class AgentBase {
|
|
|
93
96
|
{
|
|
94
97
|
name: this.name,
|
|
95
98
|
...this.metadata,
|
|
96
|
-
|
|
97
|
-
chat: { streaming: this.chatStreaming },
|
|
99
|
+
streaming: this.streaming,
|
|
98
100
|
},
|
|
99
101
|
],
|
|
100
102
|
}, { headers: corsHeaders });
|
|
101
103
|
}
|
|
102
|
-
// POST /agents/{name}/
|
|
103
|
-
const
|
|
104
|
-
if (method === 'POST' &&
|
|
105
|
-
const agentName =
|
|
106
|
-
if (agentName !== this.name) {
|
|
107
|
-
return Response.json({ error: `Agent '${agentName}' not found` }, { status: 404, headers: corsHeaders });
|
|
108
|
-
}
|
|
109
|
-
const body = (await request.json());
|
|
110
|
-
if (!body.input || Object.keys(body.input).length === 0) {
|
|
111
|
-
return Response.json({ error: 'input is required and must not be empty' }, { status: 400, headers: corsHeaders });
|
|
112
|
-
}
|
|
113
|
-
// Handle streaming
|
|
114
|
-
if (body.stream) {
|
|
115
|
-
const stream = new ReadableStream({
|
|
116
|
-
start: async (controller) => {
|
|
117
|
-
const encoder = new TextEncoder();
|
|
118
|
-
try {
|
|
119
|
-
for await (const chunk of this.invokeStream(body)) {
|
|
120
|
-
controller.enqueue(encoder.encode(`data: ${chunk}\n\n`));
|
|
121
|
-
}
|
|
122
|
-
controller.enqueue(encoder.encode('data: [DONE]\n\n'));
|
|
123
|
-
}
|
|
124
|
-
catch (error) {
|
|
125
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
126
|
-
controller.enqueue(encoder.encode(`data: ${JSON.stringify({ error: message })}\n\n`));
|
|
127
|
-
}
|
|
128
|
-
controller.close();
|
|
129
|
-
},
|
|
130
|
-
});
|
|
131
|
-
return new Response(stream, {
|
|
132
|
-
headers: {
|
|
133
|
-
...corsHeaders,
|
|
134
|
-
'Content-Type': 'text/event-stream',
|
|
135
|
-
'Cache-Control': 'no-cache',
|
|
136
|
-
Connection: 'keep-alive',
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
const response = await this.invoke(body);
|
|
141
|
-
return Response.json(response, { headers: corsHeaders });
|
|
142
|
-
}
|
|
143
|
-
// POST /agents/{name}/chat
|
|
144
|
-
const chatMatch = path.match(/^\/agents\/([^/]+)\/chat$/);
|
|
145
|
-
if (method === 'POST' && chatMatch) {
|
|
146
|
-
const agentName = chatMatch[1];
|
|
104
|
+
// POST /agents/{name}/execute
|
|
105
|
+
const executeMatch = path.match(/^\/agents\/([^/]+)\/execute$/);
|
|
106
|
+
if (method === 'POST' && executeMatch) {
|
|
107
|
+
const agentName = executeMatch[1];
|
|
147
108
|
if (agentName !== this.name) {
|
|
148
109
|
return Response.json({ error: `Agent '${agentName}' not found` }, { status: 404, headers: corsHeaders });
|
|
149
110
|
}
|
|
150
111
|
const body = (await request.json());
|
|
151
|
-
|
|
152
|
-
|
|
112
|
+
// Get requestKeys from agent metadata (all agents have defaults)
|
|
113
|
+
const requestKeys = this.metadata.requestKeys ?? [];
|
|
114
|
+
// Extract declared keys from body into input object
|
|
115
|
+
// e.g., requestKeys: ['prompt'] with body { prompt: '...' } -> input = { prompt: '...' }
|
|
116
|
+
const input = {};
|
|
117
|
+
for (const key of requestKeys) {
|
|
118
|
+
if (key in body) {
|
|
119
|
+
input[key] = body[key];
|
|
120
|
+
}
|
|
153
121
|
}
|
|
122
|
+
const executeRequest = {
|
|
123
|
+
input,
|
|
124
|
+
stream: body.stream === true,
|
|
125
|
+
context: body.context,
|
|
126
|
+
};
|
|
154
127
|
// Handle streaming
|
|
155
|
-
if (
|
|
128
|
+
if (executeRequest.stream) {
|
|
156
129
|
const stream = new ReadableStream({
|
|
157
130
|
start: async (controller) => {
|
|
158
131
|
const encoder = new TextEncoder();
|
|
159
132
|
try {
|
|
160
|
-
for await (const chunk of this.
|
|
133
|
+
for await (const chunk of this.executeStream(executeRequest)) {
|
|
161
134
|
controller.enqueue(encoder.encode(`data: ${chunk}\n\n`));
|
|
162
135
|
}
|
|
163
136
|
controller.enqueue(encoder.encode('data: [DONE]\n\n'));
|
|
@@ -178,7 +151,7 @@ export class AgentBase {
|
|
|
178
151
|
},
|
|
179
152
|
});
|
|
180
153
|
}
|
|
181
|
-
const response = await this.
|
|
154
|
+
const response = await this.execute(executeRequest);
|
|
182
155
|
return Response.json(response, { headers: corsHeaders });
|
|
183
156
|
}
|
|
184
157
|
// Not found
|
|
@@ -199,28 +172,22 @@ export class AgentBase {
|
|
|
199
172
|
* ```typescript
|
|
200
173
|
* const agent = new Agent('my-agent');
|
|
201
174
|
*
|
|
202
|
-
* agent.
|
|
175
|
+
* agent.onExecute(async (request) => {
|
|
203
176
|
* return { output: 'Hello!' };
|
|
204
177
|
* });
|
|
205
178
|
*
|
|
206
|
-
* agent.onChat(async (request) => {
|
|
207
|
-
* return { output: 'Hi!', messages: [...] };
|
|
208
|
-
* });
|
|
209
|
-
*
|
|
210
179
|
* serve({ agents: [agent], port: 8080 });
|
|
211
180
|
* ```
|
|
212
181
|
*/
|
|
213
182
|
export class Agent extends AgentBase {
|
|
214
183
|
_name;
|
|
215
184
|
_metadata;
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
_invokeStreamHandler = null;
|
|
219
|
-
_chatStreamHandler = null;
|
|
185
|
+
_executeHandler = null;
|
|
186
|
+
_executeStreamHandler = null;
|
|
220
187
|
/**
|
|
221
188
|
* Create a new agent.
|
|
222
189
|
*
|
|
223
|
-
* @param name - The agent name (used in URLs like /agents/{name}/
|
|
190
|
+
* @param name - The agent name (used in URLs like /agents/{name}/execute)
|
|
224
191
|
* @param options - Optional configuration
|
|
225
192
|
*/
|
|
226
193
|
constructor(name, options) {
|
|
@@ -238,104 +205,266 @@ export class Agent extends AgentBase {
|
|
|
238
205
|
* Return agent metadata for discovery.
|
|
239
206
|
*/
|
|
240
207
|
get metadata() {
|
|
241
|
-
return {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
208
|
+
return {
|
|
209
|
+
type: 'agent',
|
|
210
|
+
parameters: DEFAULT_AGENT_PARAMETERS,
|
|
211
|
+
requestKeys: ['prompt'],
|
|
212
|
+
responseKeys: ['output'],
|
|
213
|
+
...this._metadata,
|
|
214
|
+
};
|
|
248
215
|
}
|
|
249
216
|
/**
|
|
250
|
-
* Whether
|
|
217
|
+
* Whether execute supports streaming.
|
|
251
218
|
*/
|
|
252
|
-
get
|
|
253
|
-
return this.
|
|
219
|
+
get streaming() {
|
|
220
|
+
return this._executeStreamHandler !== null;
|
|
254
221
|
}
|
|
255
222
|
/**
|
|
256
|
-
* Register an
|
|
223
|
+
* Register an execute handler.
|
|
257
224
|
*
|
|
258
225
|
* @example
|
|
259
|
-
* agent.
|
|
226
|
+
* agent.onExecute(async (request) => {
|
|
260
227
|
* return { output: 'Hello!' };
|
|
261
228
|
* });
|
|
262
229
|
*/
|
|
263
|
-
|
|
264
|
-
this.
|
|
230
|
+
onExecute(handler) {
|
|
231
|
+
this._executeHandler = handler;
|
|
265
232
|
return this;
|
|
266
233
|
}
|
|
267
234
|
/**
|
|
268
|
-
* Register a
|
|
235
|
+
* Register a streaming execute handler.
|
|
269
236
|
*
|
|
270
237
|
* @example
|
|
271
|
-
* agent.
|
|
272
|
-
* return { output: 'Hi!', messages: [...] };
|
|
273
|
-
* });
|
|
274
|
-
*/
|
|
275
|
-
onChat(handler) {
|
|
276
|
-
this._chatHandler = handler;
|
|
277
|
-
return this;
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Register a streaming invoke handler.
|
|
281
|
-
*
|
|
282
|
-
* @example
|
|
283
|
-
* agent.onInvokeStream(async function* (request) {
|
|
238
|
+
* agent.onExecuteStream(async function* (request) {
|
|
284
239
|
* yield '{"chunk": "Hello"}';
|
|
285
240
|
* yield '{"chunk": " world!"}';
|
|
286
241
|
* });
|
|
287
242
|
*/
|
|
288
|
-
|
|
289
|
-
this.
|
|
243
|
+
onExecuteStream(handler) {
|
|
244
|
+
this._executeStreamHandler = handler;
|
|
290
245
|
return this;
|
|
291
246
|
}
|
|
292
247
|
/**
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
* @example
|
|
296
|
-
* agent.onChatStream(async function* (request) {
|
|
297
|
-
* yield '{"chunk": "Hi"}';
|
|
298
|
-
* });
|
|
248
|
+
* Handle an execute request.
|
|
299
249
|
*/
|
|
300
|
-
|
|
301
|
-
this.
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Handle an invoke request.
|
|
306
|
-
*/
|
|
307
|
-
async invoke(request) {
|
|
308
|
-
if (this._invokeHandler === null) {
|
|
309
|
-
throw new Error(`No invoke handler registered for agent '${this._name}'`);
|
|
250
|
+
async execute(request) {
|
|
251
|
+
if (this._executeHandler === null) {
|
|
252
|
+
throw new Error(`No execute handler registered for agent '${this._name}'`);
|
|
310
253
|
}
|
|
311
|
-
return this.
|
|
254
|
+
return this._executeHandler(request);
|
|
312
255
|
}
|
|
313
256
|
/**
|
|
314
|
-
* Handle a
|
|
257
|
+
* Handle a streaming execute request.
|
|
315
258
|
*/
|
|
316
|
-
async
|
|
317
|
-
if (this.
|
|
318
|
-
throw new Error(`No
|
|
259
|
+
async *executeStream(request) {
|
|
260
|
+
if (this._executeStreamHandler === null) {
|
|
261
|
+
throw new Error(`No streaming execute handler registered for agent '${this._name}'`);
|
|
319
262
|
}
|
|
320
|
-
|
|
263
|
+
yield* this._executeStreamHandler(request);
|
|
321
264
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Detect if a function is an async generator function.
|
|
268
|
+
*/
|
|
269
|
+
function isAsyncGeneratorFunction(fn) {
|
|
270
|
+
return fn?.constructor?.name === 'AsyncGeneratorFunction';
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Create an agent from a configuration object.
|
|
274
|
+
*
|
|
275
|
+
* By default, agents expect `{ prompt: string }` in the request body and
|
|
276
|
+
* return `{ output: ... }`. You can customize by providing `parameters`.
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```typescript
|
|
280
|
+
* // Simple agent with default parameters
|
|
281
|
+
* // Request: { prompt: 'Hello world' }
|
|
282
|
+
* // Response: { output: 'You said: Hello world' }
|
|
283
|
+
* const echo = agent('echo', {
|
|
284
|
+
* description: 'Echo the prompt',
|
|
285
|
+
* execute: async ({ prompt }) => `You said: ${prompt}`,
|
|
286
|
+
* });
|
|
287
|
+
*
|
|
288
|
+
* // Agent with custom parameters
|
|
289
|
+
* // Request: { a: 1, b: 2 }
|
|
290
|
+
* // Response: { output: 3 }
|
|
291
|
+
* const calculator = agent('calculator', {
|
|
292
|
+
* description: 'Add two numbers',
|
|
293
|
+
* parameters: {
|
|
294
|
+
* type: 'object',
|
|
295
|
+
* properties: { a: { type: 'number' }, b: { type: 'number' } },
|
|
296
|
+
* required: ['a', 'b'],
|
|
297
|
+
* },
|
|
298
|
+
* execute: async ({ a, b }) => (a as number) + (b as number),
|
|
299
|
+
* });
|
|
300
|
+
*
|
|
301
|
+
* // Streaming agent (async generator)
|
|
302
|
+
* // Request: { prompt: 'hello world' }
|
|
303
|
+
* // Response: { output: 'hello world ' } (streamed)
|
|
304
|
+
* const streamer = agent('streamer', {
|
|
305
|
+
* description: 'Stream text word by word',
|
|
306
|
+
* execute: async function* ({ prompt }) {
|
|
307
|
+
* for (const word of (prompt as string).split(' ')) {
|
|
308
|
+
* yield word + ' ';
|
|
309
|
+
* }
|
|
310
|
+
* },
|
|
311
|
+
* });
|
|
312
|
+
* ```
|
|
313
|
+
*/
|
|
314
|
+
export function agent(name, options) {
|
|
315
|
+
// Use provided parameters or default to { prompt: string }
|
|
316
|
+
const parameters = options.parameters ?? DEFAULT_AGENT_PARAMETERS;
|
|
317
|
+
// Derive requestKeys from parameters.properties
|
|
318
|
+
const requestKeys = Object.keys(parameters.properties);
|
|
319
|
+
const responseKeys = ['output'];
|
|
320
|
+
const agentInstance = new Agent(name, {
|
|
321
|
+
metadata: {
|
|
322
|
+
type: 'agent',
|
|
323
|
+
description: options.description,
|
|
324
|
+
parameters,
|
|
325
|
+
...(options.output !== undefined && { output: options.output }),
|
|
326
|
+
requestKeys,
|
|
327
|
+
responseKeys,
|
|
328
|
+
...options.metadata,
|
|
329
|
+
},
|
|
330
|
+
});
|
|
331
|
+
// Detect if execute is an async generator function
|
|
332
|
+
const isStreaming = isAsyncGeneratorFunction(options.execute);
|
|
333
|
+
// Get the response key from the agent's metadata (allows custom override)
|
|
334
|
+
const getResponseKey = () => {
|
|
335
|
+
const keys = agentInstance.metadata.responseKeys;
|
|
336
|
+
return keys?.[0] ?? 'output';
|
|
337
|
+
};
|
|
338
|
+
if (isStreaming) {
|
|
339
|
+
const streamExecute = options.execute;
|
|
340
|
+
// Register streaming execute handler
|
|
341
|
+
agentInstance.onExecuteStream(async function* (request) {
|
|
342
|
+
yield* streamExecute(request.input, request.context);
|
|
343
|
+
});
|
|
344
|
+
// Also register non-streaming handler that collects chunks
|
|
345
|
+
agentInstance.onExecute(async (request) => {
|
|
346
|
+
const chunks = [];
|
|
347
|
+
for await (const chunk of streamExecute(request.input, request.context)) {
|
|
348
|
+
chunks.push(chunk);
|
|
349
|
+
}
|
|
350
|
+
return { [getResponseKey()]: chunks.join('') };
|
|
351
|
+
});
|
|
330
352
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
353
|
+
else {
|
|
354
|
+
const regularExecute = options.execute;
|
|
355
|
+
agentInstance.onExecute(async (request) => {
|
|
356
|
+
const result = await regularExecute(request.input, request.context);
|
|
357
|
+
return { [getResponseKey()]: result };
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
return agentInstance;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Create a chat agent from a configuration object.
|
|
364
|
+
*
|
|
365
|
+
* This is a convenience factory that creates an agent with a standard chat
|
|
366
|
+
* interface (messages in, message out).
|
|
367
|
+
*
|
|
368
|
+
* Request: `{ messages: [...] }`
|
|
369
|
+
* Response: `{ message: { role: 'assistant', content: '...' } }`
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* ```typescript
|
|
373
|
+
* // Non-streaming chat agent
|
|
374
|
+
* // Request: { messages: [{ role: 'user', content: 'hello' }] }
|
|
375
|
+
* // Response: { message: { role: 'assistant', content: 'You said: hello' } }
|
|
376
|
+
* const bot = chatAgent('bot', {
|
|
377
|
+
* description: 'A simple chatbot',
|
|
378
|
+
* execute: async (messages) => {
|
|
379
|
+
* const lastMsg = messages.at(-1)?.content ?? '';
|
|
380
|
+
* return { role: 'assistant', content: `You said: ${lastMsg}` };
|
|
381
|
+
* },
|
|
382
|
+
* });
|
|
383
|
+
*
|
|
384
|
+
* // Streaming chat agent (async generator)
|
|
385
|
+
* const streamingBot = chatAgent('streaming-bot', {
|
|
386
|
+
* description: 'A streaming chatbot',
|
|
387
|
+
* execute: async function* (messages) {
|
|
388
|
+
* yield 'Hello';
|
|
389
|
+
* yield ' ';
|
|
390
|
+
* yield 'world!';
|
|
391
|
+
* },
|
|
392
|
+
* });
|
|
393
|
+
* ```
|
|
394
|
+
*/
|
|
395
|
+
export function chatAgent(name, options) {
|
|
396
|
+
// Chat agents have fixed request/response keys
|
|
397
|
+
const requestKeys = ['messages'];
|
|
398
|
+
const responseKeys = ['message'];
|
|
399
|
+
// Define standard chat agent schemas
|
|
400
|
+
const parametersSchema = {
|
|
401
|
+
type: 'object',
|
|
402
|
+
properties: {
|
|
403
|
+
messages: {
|
|
404
|
+
type: 'array',
|
|
405
|
+
items: {
|
|
406
|
+
type: 'object',
|
|
407
|
+
properties: {
|
|
408
|
+
role: { type: 'string' },
|
|
409
|
+
content: { type: 'string' },
|
|
410
|
+
},
|
|
411
|
+
required: ['role', 'content'],
|
|
412
|
+
},
|
|
413
|
+
},
|
|
414
|
+
},
|
|
415
|
+
required: ['messages'],
|
|
416
|
+
};
|
|
417
|
+
const outputSchema = {
|
|
418
|
+
type: 'object',
|
|
419
|
+
properties: {
|
|
420
|
+
role: { type: 'string' },
|
|
421
|
+
content: { type: 'string' },
|
|
422
|
+
},
|
|
423
|
+
required: ['role', 'content'],
|
|
424
|
+
};
|
|
425
|
+
const agentInstance = new Agent(name, {
|
|
426
|
+
metadata: {
|
|
427
|
+
type: 'chat_agent',
|
|
428
|
+
description: options.description,
|
|
429
|
+
parameters: parametersSchema,
|
|
430
|
+
output: outputSchema,
|
|
431
|
+
requestKeys,
|
|
432
|
+
responseKeys,
|
|
433
|
+
...options.metadata,
|
|
434
|
+
},
|
|
435
|
+
});
|
|
436
|
+
// Detect if execute is an async generator function
|
|
437
|
+
const isStreaming = isAsyncGeneratorFunction(options.execute);
|
|
438
|
+
// Get the response key from the agent's metadata (allows custom override)
|
|
439
|
+
const getResponseKey = () => {
|
|
440
|
+
const keys = agentInstance.metadata.responseKeys;
|
|
441
|
+
return keys?.[0] ?? 'message';
|
|
442
|
+
};
|
|
443
|
+
if (isStreaming) {
|
|
444
|
+
const streamExecute = options.execute;
|
|
445
|
+
// Register streaming execute handler
|
|
446
|
+
agentInstance.onExecuteStream(async function* (request) {
|
|
447
|
+
const rawMessages = (request.input.messages ?? []);
|
|
448
|
+
yield* streamExecute(rawMessages, request.context);
|
|
449
|
+
});
|
|
450
|
+
// Also register non-streaming handler that collects chunks
|
|
451
|
+
agentInstance.onExecute(async (request) => {
|
|
452
|
+
const rawMessages = (request.input.messages ?? []);
|
|
453
|
+
const chunks = [];
|
|
454
|
+
for await (const chunk of streamExecute(rawMessages, request.context)) {
|
|
455
|
+
chunks.push(chunk);
|
|
456
|
+
}
|
|
457
|
+
return { [getResponseKey()]: { role: 'assistant', content: chunks.join('') } };
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
const regularExecute = options.execute;
|
|
462
|
+
agentInstance.onExecute(async (request) => {
|
|
463
|
+
const rawMessages = (request.input.messages ?? []);
|
|
464
|
+
const message = await regularExecute(rawMessages, request.context);
|
|
465
|
+
return { [getResponseKey()]: message };
|
|
466
|
+
});
|
|
339
467
|
}
|
|
468
|
+
return agentInstance;
|
|
340
469
|
}
|
|
341
470
|
//# sourceMappingURL=agent.js.map
|
package/dist/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;;GAGG;AACH,MAAM,wBAAwB,GAAG;IAC/B,IAAI,EAAE,QAAiB;IACvB,UAAU,EAAE;QACV,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,kCAAkC,EAAE;KAC5E;IACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;CACrB,CAAC;AAgCF;;;;;;GAMG;AACH,MAAM,OAAgB,SAAS;IAC7B;;OAEG;IACH,IAAI,SAAS;QACX,OAAO,KAAK,CAAC;IACf,CAAC;IAOD;;;OAGG;IACH,IAAI,QAAQ;QACV,OAAO;YACL,IAAI,EAAE,OAAO;YACb,UAAU,EAAE,wBAAwB;YACpC,WAAW,EAAE,CAAC,QAAQ,CAAC;YACvB,YAAY,EAAE,CAAC,QAAQ,CAAC;SACzB,CAAC;IACJ,CAAC;IAOD;;OAEG;IACH,yCAAyC;IACzC,KAAK,CAAC,CAAC,aAAa,CAAC,QAAwB;QAC3C,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,SAAS;QACP,OAAO,KAAK,EAAE,OAAgB,EAAqB,EAAE;YACnD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,C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C,EAAE;YAC1F,MAAM,WAAW,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAc,CAAC;YAChE,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;YACnE,OAAO,EAAE,CAAC,cAAc,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { serve, createApp } from './server.js';
|
|
2
2
|
export type { ServeOptions, CreateAppOptions, FullServeOptions } from './server.js';
|
|
3
3
|
export { VERSION } from './version.js';
|
|
4
|
-
export type { Role,
|
|
5
|
-
export { AgentBase, Agent } from './agent.js';
|
|
6
|
-
export type { AgentMetadata,
|
|
4
|
+
export type { Role, ExecuteRequest, ExecuteResponse, Message, ToolSchema, ToolExecuteRequest, ToolExecuteResponse, } from './types.js';
|
|
5
|
+
export { AgentBase, Agent, agent, chatAgent } from './agent.js';
|
|
6
|
+
export type { AgentMetadata, ExecuteHandler, ExecuteStreamHandler, FetchHandler, AgentOptions, ChatAgentOptions, } from './agent.js';
|
|
7
7
|
export { AgentAdapter } from './agent-adapter.js';
|
|
8
8
|
export { ToolBase, Tool, tool } from './tool.js';
|
|
9
|
-
export type { ToolMetadata, ToolOptions, ExecuteHandler } from './tool.js';
|
|
9
|
+
export type { ToolMetadata, ToolOptions, ExecuteHandler as ToolExecuteHandler } from './tool.js';
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EACV,IAAI,EACJ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EACV,IAAI,EACJ,cAAc,EACd,eAAe,EACf,OAAO,EAEP,UAAU,EACV,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAChE,YAAY,EACV,aAAa,EACb,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,YAAY,EACZ,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjD,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { serve, createApp } from './server.js';
|
|
2
2
|
export { VERSION } from './version.js';
|
|
3
3
|
// Agent exports
|
|
4
|
-
export { AgentBase, Agent } from './agent.js';
|
|
4
|
+
export { AgentBase, Agent, agent, chatAgent } from './agent.js';
|
|
5
5
|
// Adapter exports
|
|
6
6
|
export { AgentAdapter } from './agent-adapter.js';
|
|
7
7
|
// Tool exports
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAWvC,gBAAgB;AAChB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAShE,kBAAkB;AAClB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,eAAe;AACf,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAI1C,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAI1C,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CA+GzD;AAED,MAAM,WAAW,gBAAiB,SAAQ,YAAY,EAAE,gBAAgB;CAAG;AAE3E;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,OAAO,GAAE,gBAAqB,GAAG,IAAI,CAgB1D"}
|