@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/dist/agent.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Agent classes for Reminix Runtime.
|
|
3
3
|
*/
|
|
4
|
-
import type {
|
|
4
|
+
import type { AgentInvokeRequest, AgentInvokeResponse, JSONSchema, Capabilities } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Named agent templates with predefined input/output schemas.
|
|
7
|
+
* The default template is 'prompt'; use it when no template or input/output is provided.
|
|
8
|
+
*/
|
|
9
|
+
export type AgentTemplate = 'prompt' | 'chat' | 'task' | 'rag' | 'thread';
|
|
5
10
|
/**
|
|
6
11
|
* Web-standard fetch handler type.
|
|
7
12
|
*/
|
|
@@ -10,22 +15,22 @@ export type FetchHandler = (request: Request) => Promise<Response>;
|
|
|
10
15
|
* Metadata returned by agents for discovery.
|
|
11
16
|
*/
|
|
12
17
|
export interface AgentMetadata {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
|
|
18
|
+
description?: string;
|
|
19
|
+
capabilities: Capabilities;
|
|
20
|
+
input: JSONSchema;
|
|
21
|
+
output?: JSONSchema;
|
|
22
|
+
/** Named template (prompt, chat, task, rag, thread) when agent uses a template. */
|
|
23
|
+
template?: AgentTemplate;
|
|
19
24
|
[key: string]: unknown;
|
|
20
25
|
}
|
|
21
26
|
/**
|
|
22
|
-
* Handler type for
|
|
27
|
+
* Handler type for invoke requests.
|
|
23
28
|
*/
|
|
24
|
-
export type
|
|
29
|
+
export type InvokeHandler = (request: AgentInvokeRequest) => Promise<AgentInvokeResponse>;
|
|
25
30
|
/**
|
|
26
|
-
* Handler type for streaming
|
|
31
|
+
* Handler type for streaming invoke requests.
|
|
27
32
|
*/
|
|
28
|
-
export type
|
|
33
|
+
export type InvokeStreamHandler = (request: AgentInvokeRequest) => AsyncGenerator<string, void, unknown>;
|
|
29
34
|
/**
|
|
30
35
|
* Abstract base class defining the agent interface.
|
|
31
36
|
*
|
|
@@ -34,10 +39,6 @@ export type ExecuteStreamHandler = (request: ExecuteRequest) => AsyncGenerator<s
|
|
|
34
39
|
* `AgentAdapter` for framework adapters.
|
|
35
40
|
*/
|
|
36
41
|
export declare abstract class AgentBase {
|
|
37
|
-
/**
|
|
38
|
-
* Whether execute supports streaming. Override to enable.
|
|
39
|
-
*/
|
|
40
|
-
get streaming(): boolean;
|
|
41
42
|
/**
|
|
42
43
|
* Return the agent name.
|
|
43
44
|
*/
|
|
@@ -48,13 +49,13 @@ export declare abstract class AgentBase {
|
|
|
48
49
|
*/
|
|
49
50
|
get metadata(): AgentMetadata;
|
|
50
51
|
/**
|
|
51
|
-
* Handle an
|
|
52
|
+
* Handle an invoke request.
|
|
52
53
|
*/
|
|
53
|
-
abstract
|
|
54
|
+
abstract invoke(request: AgentInvokeRequest): Promise<AgentInvokeResponse>;
|
|
54
55
|
/**
|
|
55
|
-
* Handle a streaming
|
|
56
|
+
* Handle a streaming invoke request.
|
|
56
57
|
*/
|
|
57
|
-
|
|
58
|
+
invokeStream(_request: AgentInvokeRequest): AsyncGenerator<string, void, unknown>;
|
|
58
59
|
/**
|
|
59
60
|
* Create a web-standard fetch handler for this agent.
|
|
60
61
|
*
|
|
@@ -92,8 +93,8 @@ export declare abstract class AgentBase {
|
|
|
92
93
|
export declare class Agent extends AgentBase {
|
|
93
94
|
private readonly _name;
|
|
94
95
|
private readonly _metadata;
|
|
95
|
-
private
|
|
96
|
-
private
|
|
96
|
+
private _invokeHandler;
|
|
97
|
+
private _invokeStreamHandler;
|
|
97
98
|
/**
|
|
98
99
|
* Create a new agent.
|
|
99
100
|
*
|
|
@@ -101,7 +102,7 @@ export declare class Agent extends AgentBase {
|
|
|
101
102
|
* @param options - Optional configuration
|
|
102
103
|
*/
|
|
103
104
|
constructor(name: string, options?: {
|
|
104
|
-
metadata?:
|
|
105
|
+
metadata?: Partial<AgentMetadata>;
|
|
105
106
|
});
|
|
106
107
|
/**
|
|
107
108
|
* Return the agent name.
|
|
@@ -111,10 +112,6 @@ export declare class Agent extends AgentBase {
|
|
|
111
112
|
* Return agent metadata for discovery.
|
|
112
113
|
*/
|
|
113
114
|
get metadata(): AgentMetadata;
|
|
114
|
-
/**
|
|
115
|
-
* Whether execute supports streaming.
|
|
116
|
-
*/
|
|
117
|
-
get streaming(): boolean;
|
|
118
115
|
/**
|
|
119
116
|
* Register a handler.
|
|
120
117
|
*
|
|
@@ -123,25 +120,25 @@ export declare class Agent extends AgentBase {
|
|
|
123
120
|
* return { output: 'Hello!' };
|
|
124
121
|
* });
|
|
125
122
|
*/
|
|
126
|
-
handler(fn:
|
|
123
|
+
handler(fn: InvokeHandler): this;
|
|
127
124
|
/**
|
|
128
125
|
* Register a streaming handler.
|
|
129
126
|
*
|
|
130
127
|
* @example
|
|
131
128
|
* agent.streamHandler(async function* (request) {
|
|
132
|
-
* yield '
|
|
133
|
-
* yield '
|
|
129
|
+
* yield 'Hello';
|
|
130
|
+
* yield ' world!';
|
|
134
131
|
* });
|
|
135
132
|
*/
|
|
136
|
-
streamHandler(fn:
|
|
133
|
+
streamHandler(fn: InvokeStreamHandler): this;
|
|
137
134
|
/**
|
|
138
|
-
* Handle an
|
|
135
|
+
* Handle an invoke request.
|
|
139
136
|
*/
|
|
140
|
-
|
|
137
|
+
invoke(request: AgentInvokeRequest): Promise<AgentInvokeResponse>;
|
|
141
138
|
/**
|
|
142
|
-
* Handle a streaming
|
|
139
|
+
* Handle a streaming invoke request.
|
|
143
140
|
*/
|
|
144
|
-
|
|
141
|
+
invokeStream(request: AgentInvokeRequest): AsyncGenerator<string, void, unknown>;
|
|
145
142
|
}
|
|
146
143
|
/**
|
|
147
144
|
* Options for creating an agent with the agent() factory.
|
|
@@ -149,76 +146,58 @@ export declare class Agent extends AgentBase {
|
|
|
149
146
|
export interface AgentOptions {
|
|
150
147
|
/** Human-readable description of what the agent does */
|
|
151
148
|
description?: string;
|
|
152
|
-
/** Optional metadata for discovery */
|
|
153
|
-
metadata?: Record<string, unknown>;
|
|
154
149
|
/**
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
* Defaults to { prompt: string } if not provided.
|
|
150
|
+
* Named template (prompt, chat, task). When set, input/output default to the template's schemas
|
|
151
|
+
* unless overridden by explicit input/output.
|
|
158
152
|
*/
|
|
159
|
-
|
|
160
|
-
type: 'object';
|
|
161
|
-
properties: Record<string, unknown>;
|
|
162
|
-
required?: string[];
|
|
163
|
-
};
|
|
164
|
-
/** JSON Schema for output */
|
|
165
|
-
output?: Record<string, unknown>;
|
|
153
|
+
template?: AgentTemplate;
|
|
166
154
|
/**
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
* Regular function: Returns output directly
|
|
170
|
-
* Async generator: Yields string chunks (automatically collected for non-streaming requests)
|
|
155
|
+
* JSON Schema for input.
|
|
156
|
+
* Defaults to template schema if template is set, else { prompt: string }.
|
|
171
157
|
*/
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
* Options for creating a chat agent with the chatAgent() factory.
|
|
176
|
-
*/
|
|
177
|
-
export interface ChatAgentOptions {
|
|
178
|
-
/** Human-readable description of what the agent does */
|
|
179
|
-
description?: string;
|
|
180
|
-
/** Optional metadata for discovery */
|
|
181
|
-
metadata?: Record<string, unknown>;
|
|
158
|
+
input?: JSONSchema;
|
|
159
|
+
/** JSON Schema for output. Defaults to template schema if set, else string. */
|
|
160
|
+
output?: JSONSchema;
|
|
182
161
|
/**
|
|
183
162
|
* Handler function - can be a regular async function or an async generator for streaming.
|
|
184
163
|
*
|
|
185
|
-
* Regular function: Returns
|
|
164
|
+
* Regular function: Returns output directly
|
|
186
165
|
* Async generator: Yields string chunks (automatically collected for non-streaming requests)
|
|
187
166
|
*/
|
|
188
|
-
handler: ((
|
|
167
|
+
handler: ((input: Record<string, unknown>, context?: Record<string, unknown>) => Promise<unknown>) | ((input: Record<string, unknown>, context?: Record<string, unknown>) => AsyncGenerator<string, void, unknown>);
|
|
189
168
|
}
|
|
190
169
|
/**
|
|
191
170
|
* Create an agent from a configuration object.
|
|
192
171
|
*
|
|
193
|
-
* By default, agents expect `{ prompt: string }` in the request body and
|
|
194
|
-
* return `{ output:
|
|
172
|
+
* By default, agents expect `{ input: { prompt: string } }` in the request body and
|
|
173
|
+
* return `{ output: string }`. You can customize by providing `input` schema.
|
|
195
174
|
*
|
|
196
175
|
* @example
|
|
197
176
|
* ```typescript
|
|
198
|
-
* // Simple agent with default
|
|
199
|
-
* // Request: { prompt: 'Hello world' }
|
|
177
|
+
* // Simple agent with default input/output
|
|
178
|
+
* // Request: { input: { prompt: 'Hello world' } }
|
|
200
179
|
* // Response: { output: 'You said: Hello world' }
|
|
201
180
|
* const echo = agent('echo', {
|
|
202
181
|
* description: 'Echo the prompt',
|
|
203
182
|
* handler: async ({ prompt }) => `You said: ${prompt}`,
|
|
204
183
|
* });
|
|
205
184
|
*
|
|
206
|
-
* // Agent with custom
|
|
207
|
-
* // Request: { a: 1, b: 2 }
|
|
185
|
+
* // Agent with custom input schema
|
|
186
|
+
* // Request: { input: { a: 1, b: 2 } }
|
|
208
187
|
* // Response: { output: 3 }
|
|
209
188
|
* const calculator = agent('calculator', {
|
|
210
189
|
* description: 'Add two numbers',
|
|
211
|
-
*
|
|
190
|
+
* input: {
|
|
212
191
|
* type: 'object',
|
|
213
192
|
* properties: { a: { type: 'number' }, b: { type: 'number' } },
|
|
214
193
|
* required: ['a', 'b'],
|
|
215
194
|
* },
|
|
195
|
+
* output: { type: 'number' },
|
|
216
196
|
* handler: async ({ a, b }) => (a as number) + (b as number),
|
|
217
197
|
* });
|
|
218
198
|
*
|
|
219
199
|
* // Streaming agent (async generator)
|
|
220
|
-
* // Request: { prompt: 'hello world' }
|
|
221
|
-
* // Response: { output: 'hello world ' } (streamed)
|
|
200
|
+
* // Request: { input: { prompt: 'hello world' }, stream: true }
|
|
222
201
|
* const streamer = agent('streamer', {
|
|
223
202
|
* description: 'Stream text word by word',
|
|
224
203
|
* handler: async function* ({ prompt }) {
|
|
@@ -230,38 +209,4 @@ export interface ChatAgentOptions {
|
|
|
230
209
|
* ```
|
|
231
210
|
*/
|
|
232
211
|
export declare function agent(name: string, options: AgentOptions): Agent;
|
|
233
|
-
/**
|
|
234
|
-
* Create a chat agent from a configuration object.
|
|
235
|
-
*
|
|
236
|
-
* This is a convenience factory that creates an agent with a standard chat
|
|
237
|
-
* interface (messages in, messages out).
|
|
238
|
-
*
|
|
239
|
-
* Request: `{ messages: [...] }`
|
|
240
|
-
* Response: `{ messages: [{ role: 'assistant', content: '...' }, ...] }`
|
|
241
|
-
*
|
|
242
|
-
* @example
|
|
243
|
-
* ```typescript
|
|
244
|
-
* // Non-streaming chat agent
|
|
245
|
-
* // Request: { messages: [{ role: 'user', content: 'hello' }] }
|
|
246
|
-
* // Response: { messages: [{ role: 'assistant', content: 'You said: hello' }] }
|
|
247
|
-
* const bot = chatAgent('bot', {
|
|
248
|
-
* description: 'A simple chatbot',
|
|
249
|
-
* handler: async (messages) => {
|
|
250
|
-
* const lastMsg = messages.at(-1)?.content ?? '';
|
|
251
|
-
* return [{ role: 'assistant', content: `You said: ${lastMsg}` }];
|
|
252
|
-
* },
|
|
253
|
-
* });
|
|
254
|
-
*
|
|
255
|
-
* // Streaming chat agent (async generator)
|
|
256
|
-
* const streamingBot = chatAgent('streaming-bot', {
|
|
257
|
-
* description: 'A streaming chatbot',
|
|
258
|
-
* handler: async function* (messages) {
|
|
259
|
-
* yield 'Hello';
|
|
260
|
-
* yield ' ';
|
|
261
|
-
* yield 'world!';
|
|
262
|
-
* },
|
|
263
|
-
* });
|
|
264
|
-
* ```
|
|
265
|
-
*/
|
|
266
|
-
export declare function chatAgent(name: string, options: ChatAgentOptions): Agent;
|
|
267
212
|
//# sourceMappingURL=agent.d.ts.map
|
package/dist/agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGpG;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;AA+H1E;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,YAAY,CAAC;IAC3B,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,CAAC,EAAE,UA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