@reminix/runtime 0.0.13 → 0.0.16
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 +65 -166
- package/dist/agent-adapter.d.ts +3 -7
- package/dist/agent-adapter.d.ts.map +1 -1
- package/dist/agent-adapter.js +24 -11
- package/dist/agent-adapter.js.map +1 -1
- package/dist/agent.d.ts +50 -105
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +179 -328
- 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 +70 -23
- package/dist/server.js.map +1 -1
- package/dist/tool.d.ts +28 -22
- package/dist/tool.d.ts.map +1 -1
- package/dist/tool.js +25 -19
- package/dist/tool.js.map +1 -1
- package/dist/types.d.ts +41 -17
- 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/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The open source runtime for serving AI agents via REST APIs. Part of [Reminix](https://reminix.com) — the developer platform for AI agents.
|
|
4
4
|
|
|
5
|
-
Core runtime package for serving AI agents and tools via REST APIs. Provides the `agent()
|
|
5
|
+
Core runtime package for serving AI agents and tools via REST APIs. Provides the `agent()` and `tool()` factory functions, agent templates (prompt, chat, task, rag, thread), and types `Message` and `ToolCall` for OpenAI-style conversations.
|
|
6
6
|
|
|
7
7
|
Built on [Hono](https://hono.dev) for portability across Node.js, Deno, Bun, and edge runtimes.
|
|
8
8
|
|
|
@@ -17,12 +17,12 @@ npm install @reminix/runtime
|
|
|
17
17
|
## Quick Start
|
|
18
18
|
|
|
19
19
|
```typescript
|
|
20
|
-
import { agent,
|
|
20
|
+
import { agent, serve } from '@reminix/runtime';
|
|
21
21
|
|
|
22
22
|
// Create an agent for task-oriented operations
|
|
23
23
|
const calculator = agent('calculator', {
|
|
24
24
|
description: 'Add two numbers',
|
|
25
|
-
|
|
25
|
+
input: {
|
|
26
26
|
type: 'object',
|
|
27
27
|
properties: { a: { type: 'number' }, b: { type: 'number' } },
|
|
28
28
|
required: ['a', 'b'],
|
|
@@ -30,14 +30,8 @@ const calculator = agent('calculator', {
|
|
|
30
30
|
handler: async ({ a, b }) => (a as number) + (b as number),
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
description: 'A helpful assistant',
|
|
36
|
-
handler: async (messages) => `You said: ${messages.at(-1)?.content}`,
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
// Serve the agents
|
|
40
|
-
serve({ agents: [calculator, assistant], port: 8080 });
|
|
33
|
+
// Serve the agent
|
|
34
|
+
serve({ agents: [calculator], port: 8080 });
|
|
41
35
|
```
|
|
42
36
|
|
|
43
37
|
## How It Works
|
|
@@ -71,7 +65,7 @@ Returns runtime information, available agents, and tools:
|
|
|
71
65
|
{
|
|
72
66
|
"runtime": {
|
|
73
67
|
"name": "reminix-runtime",
|
|
74
|
-
"version": "0.0.
|
|
68
|
+
"version": "0.0.16",
|
|
75
69
|
"language": "typescript",
|
|
76
70
|
"framework": "hono"
|
|
77
71
|
},
|
|
@@ -80,7 +74,7 @@ Returns runtime information, available agents, and tools:
|
|
|
80
74
|
"name": "calculator",
|
|
81
75
|
"type": "agent",
|
|
82
76
|
"description": "Add two numbers",
|
|
83
|
-
"
|
|
77
|
+
"input": {
|
|
84
78
|
"type": "object",
|
|
85
79
|
"properties": { "a": { "type": "number" }, "b": { "type": "number" } },
|
|
86
80
|
"required": ["a", "b"]
|
|
@@ -93,41 +87,6 @@ Returns runtime information, available agents, and tools:
|
|
|
93
87
|
"requestKeys": ["a", "b"],
|
|
94
88
|
"responseKeys": ["content"],
|
|
95
89
|
"streaming": false
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
"name": "assistant",
|
|
99
|
-
"type": "chat_agent",
|
|
100
|
-
"description": "A helpful assistant",
|
|
101
|
-
"parameters": {
|
|
102
|
-
"type": "object",
|
|
103
|
-
"properties": {
|
|
104
|
-
"messages": {
|
|
105
|
-
"type": "array",
|
|
106
|
-
"items": { "type": "object", "properties": { "role": { "type": "string" }, "content": { "type": "string" } }, "required": ["role", "content"] }
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
"required": ["messages"]
|
|
110
|
-
},
|
|
111
|
-
"output": {
|
|
112
|
-
"type": "object",
|
|
113
|
-
"properties": {
|
|
114
|
-
"messages": {
|
|
115
|
-
"type": "array",
|
|
116
|
-
"items": {
|
|
117
|
-
"type": "object",
|
|
118
|
-
"properties": {
|
|
119
|
-
"role": { "type": "string" },
|
|
120
|
-
"content": { "type": "string" }
|
|
121
|
-
},
|
|
122
|
-
"required": ["role", "content"]
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
"required": ["messages"]
|
|
127
|
-
},
|
|
128
|
-
"requestKeys": ["messages"],
|
|
129
|
-
"responseKeys": ["messages"],
|
|
130
|
-
"streaming": false
|
|
131
90
|
}
|
|
132
91
|
],
|
|
133
92
|
"tools": [
|
|
@@ -135,7 +94,7 @@ Returns runtime information, available agents, and tools:
|
|
|
135
94
|
"name": "get_weather",
|
|
136
95
|
"type": "tool",
|
|
137
96
|
"description": "Get current weather for a location",
|
|
138
|
-
"
|
|
97
|
+
"input": { ... },
|
|
139
98
|
"output": { ... }
|
|
140
99
|
}
|
|
141
100
|
]
|
|
@@ -146,7 +105,7 @@ Returns runtime information, available agents, and tools:
|
|
|
146
105
|
|
|
147
106
|
`POST /agents/{name}/invoke` - Invoke an agent.
|
|
148
107
|
|
|
149
|
-
Request keys are defined by the agent's
|
|
108
|
+
Request keys are defined by the agent's input schema. For example, a calculator agent with input schema `{ properties: { a, b } }` expects `a` and `b` at the top level:
|
|
150
109
|
|
|
151
110
|
**Task-oriented agent:**
|
|
152
111
|
```bash
|
|
@@ -164,7 +123,7 @@ curl -X POST http://localhost:8080/agents/calculator/invoke \
|
|
|
164
123
|
|
|
165
124
|
**Chat agent:**
|
|
166
125
|
|
|
167
|
-
Chat agents expect `messages` at the top level and
|
|
126
|
+
Chat agents (template `chat` or `thread`) expect `messages` at the top level. Messages are OpenAI-style: `role` (`user` | `assistant` | `system` | `tool`), `content`, and optionally `tool_calls`, `tool_call_id`, and `name`. Use the `Message` and `ToolCall` types from `@reminix/runtime` in your handler. Chat returns a string; thread returns an array of messages.
|
|
168
127
|
|
|
169
128
|
```bash
|
|
170
129
|
curl -X POST http://localhost:8080/agents/assistant/invoke \
|
|
@@ -176,15 +135,10 @@ curl -X POST http://localhost:8080/agents/assistant/invoke \
|
|
|
176
135
|
}'
|
|
177
136
|
```
|
|
178
137
|
|
|
179
|
-
**Response:**
|
|
138
|
+
**Response (chat):**
|
|
180
139
|
```json
|
|
181
140
|
{
|
|
182
|
-
"
|
|
183
|
-
{
|
|
184
|
-
"role": "assistant",
|
|
185
|
-
"content": "You said: Hello!"
|
|
186
|
-
}
|
|
187
|
-
]
|
|
141
|
+
"content": "You said: Hello!"
|
|
188
142
|
}
|
|
189
143
|
```
|
|
190
144
|
|
|
@@ -209,16 +163,45 @@ curl -X POST http://localhost:8080/tools/get_weather/call \
|
|
|
209
163
|
|
|
210
164
|
Agents handle requests via the `/agents/{name}/invoke` endpoint.
|
|
211
165
|
|
|
166
|
+
### Agent templates
|
|
167
|
+
|
|
168
|
+
You can use a **template** to get standard input/output schemas without defining them yourself. Pass `template` when creating an agent:
|
|
169
|
+
|
|
170
|
+
| Template | Input | Output | Use case |
|
|
171
|
+
|----------|--------|--------|----------|
|
|
172
|
+
| `prompt` (default) | `{ prompt: string }` | `string` | Single prompt in, text out |
|
|
173
|
+
| `chat` | `{ messages: Message[] }` | `string` | Multi-turn chat, final reply as string |
|
|
174
|
+
| `task` | `{ task: string, ... }` | JSON | Task name + params, structured result |
|
|
175
|
+
| `rag` | `{ query: string, messages?: Message[], collectionIds?: string[] }` | `string` | RAG query, optional history and collections |
|
|
176
|
+
| `thread` | `{ messages: Message[] }` | `Message[]` | Multi-turn with tool calls; returns updated thread |
|
|
177
|
+
|
|
178
|
+
Messages are OpenAI-style: `role`, `content`, and optionally `tool_calls`, `tool_call_id`, and `name`. Use the exported types `Message` and `ToolCall` from `@reminix/runtime` for type-safe handlers.
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
import { agent, serve, type Message, type ToolCall } from '@reminix/runtime';
|
|
182
|
+
|
|
183
|
+
const assistant = agent('assistant', {
|
|
184
|
+
template: 'chat',
|
|
185
|
+
description: 'Helpful assistant',
|
|
186
|
+
handler: async ({ messages }) => {
|
|
187
|
+
const last = (messages as Message[]).slice(-1)[0];
|
|
188
|
+
return last?.role === 'user' ? `You said: ${last.content}` : 'Hello!';
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
serve({ agents: [assistant], port: 8080 });
|
|
193
|
+
```
|
|
194
|
+
|
|
212
195
|
### Task-Oriented Agent
|
|
213
196
|
|
|
214
|
-
Use `agent()` for task-oriented agents that take structured input and return output:
|
|
197
|
+
Use `agent()` for task-oriented agents that take structured input and return output (or omit `template` / use `template: 'prompt'` or `template: 'task'` for standard shapes):
|
|
215
198
|
|
|
216
199
|
```typescript
|
|
217
200
|
import { agent, serve } from '@reminix/runtime';
|
|
218
201
|
|
|
219
202
|
const calculator = agent('calculator', {
|
|
220
203
|
description: 'Add two numbers',
|
|
221
|
-
|
|
204
|
+
input: {
|
|
222
205
|
type: 'object',
|
|
223
206
|
properties: {
|
|
224
207
|
a: { type: 'number' },
|
|
@@ -231,7 +214,7 @@ const calculator = agent('calculator', {
|
|
|
231
214
|
|
|
232
215
|
const textProcessor = agent('text-processor', {
|
|
233
216
|
description: 'Process text in various ways',
|
|
234
|
-
|
|
217
|
+
input: {
|
|
235
218
|
type: 'object',
|
|
236
219
|
properties: {
|
|
237
220
|
text: { type: 'string' },
|
|
@@ -248,44 +231,16 @@ const textProcessor = agent('text-processor', {
|
|
|
248
231
|
serve({ agents: [calculator, textProcessor], port: 8080 });
|
|
249
232
|
```
|
|
250
233
|
|
|
251
|
-
### Chat Agent
|
|
252
|
-
|
|
253
|
-
Use `chatAgent()` for conversational agents that handle message history:
|
|
254
|
-
|
|
255
|
-
```typescript
|
|
256
|
-
import { chatAgent, serve } from '@reminix/runtime';
|
|
257
|
-
|
|
258
|
-
const assistant = chatAgent('assistant', {
|
|
259
|
-
description: 'A helpful assistant',
|
|
260
|
-
handler: async (messages) => {
|
|
261
|
-
const lastMsg = messages.at(-1)?.content ?? '';
|
|
262
|
-
return `You said: ${lastMsg}`;
|
|
263
|
-
},
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
// With context support
|
|
267
|
-
const contextualBot = chatAgent('contextual-bot', {
|
|
268
|
-
description: 'Bot with context awareness',
|
|
269
|
-
handler: async (messages, context) => {
|
|
270
|
-
const userId = context?.user_id ?? 'unknown';
|
|
271
|
-
return `Hello user ${userId}!`;
|
|
272
|
-
},
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
serve({ agents: [assistant, contextualBot], port: 8080 });
|
|
276
|
-
```
|
|
277
|
-
|
|
278
234
|
### Streaming
|
|
279
235
|
|
|
280
|
-
|
|
236
|
+
Agents support streaming via async generators. When you use an async generator function, the agent automatically supports streaming:
|
|
281
237
|
|
|
282
238
|
```typescript
|
|
283
|
-
import { agent,
|
|
239
|
+
import { agent, serve } from '@reminix/runtime';
|
|
284
240
|
|
|
285
|
-
// Streaming task agent
|
|
286
241
|
const streamer = agent('streamer', {
|
|
287
242
|
description: 'Stream text word by word',
|
|
288
|
-
|
|
243
|
+
input: {
|
|
289
244
|
type: 'object',
|
|
290
245
|
properties: { text: { type: 'string' } },
|
|
291
246
|
required: ['text'],
|
|
@@ -297,18 +252,7 @@ const streamer = agent('streamer', {
|
|
|
297
252
|
},
|
|
298
253
|
});
|
|
299
254
|
|
|
300
|
-
|
|
301
|
-
const streamingAssistant = chatAgent('streaming-assistant', {
|
|
302
|
-
description: 'Stream responses token by token',
|
|
303
|
-
handler: async function* (messages) {
|
|
304
|
-
const response = `You said: ${messages.at(-1)?.content}`;
|
|
305
|
-
for (const char of response) {
|
|
306
|
-
yield char;
|
|
307
|
-
}
|
|
308
|
-
},
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
serve({ agents: [streamer, streamingAssistant], port: 8080 });
|
|
255
|
+
serve({ agents: [streamer], port: 8080 });
|
|
312
256
|
```
|
|
313
257
|
|
|
314
258
|
For streaming agents:
|
|
@@ -328,7 +272,7 @@ import { tool, serve } from '@reminix/runtime';
|
|
|
328
272
|
|
|
329
273
|
const getWeather = tool('get_weather', {
|
|
330
274
|
description: 'Get current weather for a location',
|
|
331
|
-
|
|
275
|
+
input: {
|
|
332
276
|
type: 'object',
|
|
333
277
|
properties: {
|
|
334
278
|
location: { type: 'string', description: 'City name' },
|
|
@@ -361,7 +305,7 @@ import { agent, tool, serve } from '@reminix/runtime';
|
|
|
361
305
|
|
|
362
306
|
const summarizer = agent('summarizer', {
|
|
363
307
|
description: 'Summarize text',
|
|
364
|
-
|
|
308
|
+
input: {
|
|
365
309
|
type: 'object',
|
|
366
310
|
properties: { text: { type: 'string' } },
|
|
367
311
|
required: ['text'],
|
|
@@ -371,7 +315,7 @@ const summarizer = agent('summarizer', {
|
|
|
371
315
|
|
|
372
316
|
const calculator = tool('calculate', {
|
|
373
317
|
description: 'Perform basic math operations',
|
|
374
|
-
|
|
318
|
+
input: {
|
|
375
319
|
type: 'object',
|
|
376
320
|
properties: { expression: { type: 'string' } },
|
|
377
321
|
required: ['expression'],
|
|
@@ -422,14 +366,15 @@ const app = createApp({ agents: [myAgent], tools: [myTool] });
|
|
|
422
366
|
|
|
423
367
|
### `agent(name, options)`
|
|
424
368
|
|
|
425
|
-
Factory function to create
|
|
369
|
+
Factory function to create an agent. Use `template` for standard I/O shapes, or provide custom `input`/`output` schemas.
|
|
426
370
|
|
|
427
371
|
| Parameter | Type | Description |
|
|
428
372
|
|-----------|------|-------------|
|
|
429
373
|
| `name` | `string` | Unique identifier for the agent |
|
|
374
|
+
| `options.template` | `'prompt' \| 'chat' \| 'task' \| 'rag' \| 'thread'` | Optional. Standard input/output schema (default: `prompt` when no custom input/output). |
|
|
430
375
|
| `options.description` | `string` | Human-readable description |
|
|
431
|
-
| `options.
|
|
432
|
-
| `options.output` | `object` | Optional JSON Schema for output |
|
|
376
|
+
| `options.input` | `object` | JSON Schema for input (ignored if `template` is set) |
|
|
377
|
+
| `options.output` | `object` | Optional JSON Schema for output (ignored if `template` is set) |
|
|
433
378
|
| `options.handler` | `function` | Async function or async generator |
|
|
434
379
|
|
|
435
380
|
```typescript
|
|
@@ -438,7 +383,7 @@ import { agent } from '@reminix/runtime';
|
|
|
438
383
|
// Regular agent
|
|
439
384
|
const myAgent = agent('my-agent', {
|
|
440
385
|
description: 'Does something useful',
|
|
441
|
-
|
|
386
|
+
input: {
|
|
442
387
|
type: 'object',
|
|
443
388
|
properties: { input: { type: 'string' } },
|
|
444
389
|
required: ['input'],
|
|
@@ -449,7 +394,7 @@ const myAgent = agent('my-agent', {
|
|
|
449
394
|
// Streaming agent
|
|
450
395
|
const streamingAgent = agent('streaming-agent', {
|
|
451
396
|
description: 'Streams output',
|
|
452
|
-
|
|
397
|
+
input: { type: 'object', properties: { text: { type: 'string' } }, required: ['text'] },
|
|
453
398
|
handler: async function* ({ text }) {
|
|
454
399
|
for (const word of (text as string).split(' ')) {
|
|
455
400
|
yield word + ' ';
|
|
@@ -458,39 +403,6 @@ const streamingAgent = agent('streaming-agent', {
|
|
|
458
403
|
});
|
|
459
404
|
```
|
|
460
405
|
|
|
461
|
-
### `chatAgent(name, options)`
|
|
462
|
-
|
|
463
|
-
Factory function to create a chat agent.
|
|
464
|
-
|
|
465
|
-
| Parameter | Type | Description |
|
|
466
|
-
|-----------|------|-------------|
|
|
467
|
-
| `name` | `string` | Unique identifier for the agent |
|
|
468
|
-
| `options.description` | `string` | Human-readable description |
|
|
469
|
-
| `options.handler` | `function` | Async function or async generator receiving messages |
|
|
470
|
-
|
|
471
|
-
```typescript
|
|
472
|
-
import { chatAgent } from '@reminix/runtime';
|
|
473
|
-
|
|
474
|
-
// Regular chat agent
|
|
475
|
-
const bot = chatAgent('bot', {
|
|
476
|
-
description: 'A simple bot',
|
|
477
|
-
handler: async (messages) => `You said: ${messages.at(-1)?.content}`,
|
|
478
|
-
});
|
|
479
|
-
|
|
480
|
-
// With context
|
|
481
|
-
const contextBot = chatAgent('context-bot', {
|
|
482
|
-
handler: async (messages, context) => `Hello ${context?.user_id}!`,
|
|
483
|
-
});
|
|
484
|
-
|
|
485
|
-
// Streaming chat agent
|
|
486
|
-
const streamingBot = chatAgent('streaming-bot', {
|
|
487
|
-
handler: async function* (messages) {
|
|
488
|
-
yield 'Hello';
|
|
489
|
-
yield ' world!';
|
|
490
|
-
},
|
|
491
|
-
});
|
|
492
|
-
```
|
|
493
|
-
|
|
494
406
|
### `tool(name, options)`
|
|
495
407
|
|
|
496
408
|
Factory function to create a tool.
|
|
@@ -499,7 +411,7 @@ Factory function to create a tool.
|
|
|
499
411
|
|-----------|------|-------------|
|
|
500
412
|
| `name` | `string` | Unique identifier for the tool |
|
|
501
413
|
| `options.description` | `string` | Human-readable description |
|
|
502
|
-
| `options.
|
|
414
|
+
| `options.input` | `object` | JSON Schema for input |
|
|
503
415
|
| `options.output` | `object` | Optional JSON Schema for output |
|
|
504
416
|
| `options.handler` | `function` | Async function to call when invoked |
|
|
505
417
|
|
|
@@ -508,7 +420,7 @@ import { tool } from '@reminix/runtime';
|
|
|
508
420
|
|
|
509
421
|
const myTool = tool('my_tool', {
|
|
510
422
|
description: 'Does something useful',
|
|
511
|
-
|
|
423
|
+
input: {
|
|
512
424
|
type: 'object',
|
|
513
425
|
properties: { input: { type: 'string' } },
|
|
514
426
|
required: ['input'],
|
|
@@ -520,32 +432,19 @@ const myTool = tool('my_tool', {
|
|
|
520
432
|
### Request/Response Types
|
|
521
433
|
|
|
522
434
|
```typescript
|
|
523
|
-
// Request: top-level keys based on agent's
|
|
524
|
-
// For a calculator agent with
|
|
435
|
+
// Request: top-level keys based on agent's input schema
|
|
436
|
+
// For a calculator agent with input schema { a: number, b: number }:
|
|
525
437
|
interface CalculatorRequest {
|
|
526
|
-
a: number; // Top-level key from
|
|
527
|
-
b: number; // Top-level key from
|
|
438
|
+
a: number; // Top-level key from input schema
|
|
439
|
+
b: number; // Top-level key from input schema
|
|
528
440
|
stream?: boolean; // Whether to stream the response
|
|
529
441
|
context?: Record<string, unknown>; // Optional metadata
|
|
530
442
|
}
|
|
531
443
|
|
|
532
|
-
//
|
|
533
|
-
interface ChatRequest {
|
|
534
|
-
messages: Message[]; // Top-level key (requestKeys: ['messages'])
|
|
535
|
-
stream?: boolean;
|
|
536
|
-
context?: Record<string, unknown>;
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
// Response: keys based on agent's responseKeys
|
|
540
|
-
// Regular agent (responseKeys: ['content']):
|
|
444
|
+
// Response: keys based on agent's output schema
|
|
541
445
|
interface AgentResponse {
|
|
542
446
|
content: unknown;
|
|
543
447
|
}
|
|
544
|
-
|
|
545
|
-
// Chat agent (responseKeys: ['messages']):
|
|
546
|
-
interface ChatResponse {
|
|
547
|
-
messages: Array<{ role: string; content: string }>;
|
|
548
|
-
}
|
|
549
448
|
```
|
|
550
449
|
|
|
551
450
|
## Advanced
|
|
@@ -581,7 +480,7 @@ import { Tool, serve } from '@reminix/runtime';
|
|
|
581
480
|
|
|
582
481
|
const myTool = new Tool('get_weather', {
|
|
583
482
|
description: 'Get weather for a location',
|
|
584
|
-
|
|
483
|
+
input: {
|
|
585
484
|
type: 'object',
|
|
586
485
|
properties: { location: { type: 'string' } },
|
|
587
486
|
required: ['location'],
|
package/dist/agent-adapter.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Base agent adapter class for framework integrations.
|
|
3
3
|
*/
|
|
4
|
-
import type {
|
|
4
|
+
import type { AgentInvokeRequest } from './types.js';
|
|
5
5
|
import { AgentBase, type AgentMetadata } from './agent.js';
|
|
6
6
|
/**
|
|
7
7
|
* Base class for framework agent adapters.
|
|
@@ -14,18 +14,14 @@ export declare abstract class AgentAdapter extends AgentBase {
|
|
|
14
14
|
* The adapter name. Subclasses should override this.
|
|
15
15
|
*/
|
|
16
16
|
static adapterName: string;
|
|
17
|
-
/**
|
|
18
|
-
* All built-in adapters support streaming.
|
|
19
|
-
*/
|
|
20
|
-
get streaming(): boolean;
|
|
21
17
|
/**
|
|
22
18
|
* Return adapter metadata for discovery.
|
|
23
19
|
* Adapters accept both 'messages' (chat-style) and 'prompt' (simple) inputs.
|
|
24
20
|
*/
|
|
25
21
|
get metadata(): AgentMetadata;
|
|
26
22
|
/**
|
|
27
|
-
* Handle a streaming
|
|
23
|
+
* Handle a streaming invoke request.
|
|
28
24
|
*/
|
|
29
|
-
|
|
25
|
+
invokeStream(_request: AgentInvokeRequest): AsyncGenerator<string, void, unknown>;
|
|
30
26
|
}
|
|
31
27
|
//# sourceMappingURL=agent-adapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-adapter.d.ts","sourceRoot":"","sources":["../src/agent-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"agent-adapter.d.ts","sourceRoot":"","sources":["../src/agent-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAc,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAmB3D;;;;;GAKG;AACH,8BAAsB,YAAa,SAAQ,SAAS;IAClD;;OAEG;IACH,MAAM,CAAC,WAAW,EAAE,MAAM,CAAa;IAEvC;;;OAGG;IACH,IAAI,QAAQ,IAAI,aAAa,CAU5B;IAED;;OAEG;IAEI,YAAY,CAAC,QAAQ,EAAE,kBAAkB,GAAG,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC;CAGzF"}
|
package/dist/agent-adapter.js
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
* Base agent adapter class for framework integrations.
|
|
3
3
|
*/
|
|
4
4
|
import { AgentBase } from './agent.js';
|
|
5
|
+
/**
|
|
6
|
+
* Adapter input schema - accepts both messages and prompt.
|
|
7
|
+
*/
|
|
8
|
+
const ADAPTER_INPUT = {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
messages: {
|
|
12
|
+
type: 'array',
|
|
13
|
+
description: 'Chat-style messages input',
|
|
14
|
+
},
|
|
15
|
+
prompt: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
description: 'Simple prompt input',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
5
21
|
/**
|
|
6
22
|
* Base class for framework agent adapters.
|
|
7
23
|
*
|
|
@@ -13,29 +29,26 @@ export class AgentAdapter extends AgentBase {
|
|
|
13
29
|
* The adapter name. Subclasses should override this.
|
|
14
30
|
*/
|
|
15
31
|
static adapterName = 'unknown';
|
|
16
|
-
/**
|
|
17
|
-
* All built-in adapters support streaming.
|
|
18
|
-
*/
|
|
19
|
-
get streaming() {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
32
|
/**
|
|
23
33
|
* Return adapter metadata for discovery.
|
|
24
34
|
* Adapters accept both 'messages' (chat-style) and 'prompt' (simple) inputs.
|
|
25
35
|
*/
|
|
26
36
|
get metadata() {
|
|
27
37
|
return {
|
|
28
|
-
|
|
38
|
+
description: `${this.constructor.adapterName} adapter`,
|
|
39
|
+
capabilities: {
|
|
40
|
+
streaming: true,
|
|
41
|
+
},
|
|
42
|
+
input: ADAPTER_INPUT,
|
|
43
|
+
output: { type: 'string' },
|
|
29
44
|
adapter: this.constructor.adapterName,
|
|
30
|
-
requestKeys: ['messages', 'prompt'],
|
|
31
|
-
responseKeys: ['output'],
|
|
32
45
|
};
|
|
33
46
|
}
|
|
34
47
|
/**
|
|
35
|
-
* Handle a streaming
|
|
48
|
+
* Handle a streaming invoke request.
|
|
36
49
|
*/
|
|
37
50
|
// eslint-disable-next-line require-yield
|
|
38
|
-
async *
|
|
51
|
+
async *invokeStream(_request) {
|
|
39
52
|
throw new Error('Streaming not implemented for this adapter');
|
|
40
53
|
}
|
|
41
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-adapter.js","sourceRoot":"","sources":["../src/agent-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,SAAS,EAAsB,MAAM,YAAY,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,OAAgB,YAAa,SAAQ,SAAS;IAClD;;OAEG;IACH,MAAM,CAAC,WAAW,GAAW,SAAS,CAAC;IAEvC
|
|
1
|
+
{"version":3,"file":"agent-adapter.js","sourceRoot":"","sources":["../src/agent-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,SAAS,EAAsB,MAAM,YAAY,CAAC;AAE3D;;GAEG;AACH,MAAM,aAAa,GAAe;IAChC,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,QAAQ,EAAE;YACR,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,2BAA2B;SACzC;QACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,qBAAqB;SACnC;KACF;CACF,CAAC;AAEF;;;;;GAKG;AACH,MAAM,OAAgB,YAAa,SAAQ,SAAS;IAClD;;OAEG;IACH,MAAM,CAAC,WAAW,GAAW,SAAS,CAAC;IAEvC;;;OAGG;IACH,IAAI,QAAQ;QACV,OAAO;YACL,WAAW,EAAE,GAAI,IAAI,CAAC,WAAmC,CAAC,WAAW,UAAU;YAC/E,YAAY,EAAE;gBACZ,SAAS,EAAE,IAAI;aAChB;YACD,KAAK,EAAE,aAAa;YACpB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC1B,OAAO,EAAG,IAAI,CAAC,WAAmC,CAAC,WAAW;SAC/D,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,yCAAyC;IACzC,KAAK,CAAC,CAAC,YAAY,CAAC,QAA4B;QAC9C,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC"}
|