@reminix/runtime 0.5.0 → 0.6.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @reminix/runtime
2
2
 
3
- Reminix runtime for building handlers that run on Reminix.
3
+ Agent runtime for building AI agents that integrate with the Reminix API.
4
4
 
5
5
  ## Installation
6
6
 
@@ -8,48 +8,227 @@ Reminix runtime for building handlers that run on Reminix.
8
8
  npm install @reminix/runtime
9
9
  # or
10
10
  pnpm add @reminix/runtime
11
- # or
12
- yarn add @reminix/runtime
13
11
  ```
14
12
 
15
- ## Usage
13
+ ## Quick Start
14
+
15
+ ```typescript
16
+ import { Agent, serve } from '@reminix/runtime';
17
+
18
+ // Create an agent with optional metadata for dashboard display
19
+ const agent = new Agent('my-agent', {
20
+ metadata: {
21
+ framework: 'custom',
22
+ model: 'gpt-4',
23
+ description: 'My first agent',
24
+ },
25
+ });
26
+
27
+ agent.onInvoke(async (input) => {
28
+ return { output: `Processed: ${input.message}` };
29
+ });
30
+
31
+ agent.onChat(async (messages) => {
32
+ const lastMessage = messages[messages.length - 1];
33
+ return {
34
+ message: { role: 'assistant', content: `Reply: ${lastMessage.content}` },
35
+ };
36
+ });
37
+
38
+ serve(agent, { port: 8080 });
39
+ ```
40
+
41
+ ## API Reference
42
+
43
+ ### Agent Class
44
+
45
+ Create an agent with a unique name and optional metadata:
46
+
47
+ ```typescript
48
+ import { Agent } from '@reminix/runtime';
49
+
50
+ const agent = new Agent('my-agent');
51
+
52
+ // With metadata (optional)
53
+ const agentWithMeta = new Agent('my-agent', {
54
+ metadata: {
55
+ framework: 'langchain',
56
+ model: 'gpt-4',
57
+ description: 'Customer support agent',
58
+ },
59
+ });
60
+ ```
61
+
62
+ The `metadata` is available via the `/_discover` endpoint and displayed in the Reminix dashboard.
63
+
64
+ #### `agent.onInvoke(handler)`
65
+
66
+ Register an invoke handler:
16
67
 
17
68
  ```typescript
18
- import type { AgentHandler, Context, Request, Response } from '@reminix/runtime';
69
+ agent.onInvoke(async (input, ctx) => {
70
+ // input is Record<string, unknown>
71
+ // ctx has: conversationId, userId, custom
72
+ return { output: 'result' };
73
+ });
74
+ ```
75
+
76
+ #### `agent.onChat(handler)`
19
77
 
20
- const myAgent: AgentHandler = async (context: Context, request: Request): Promise<Response> => {
21
- // Your handler logic here
78
+ Register a chat handler:
79
+
80
+ ```typescript
81
+ agent.onChat(async (messages, ctx) => {
82
+ // messages is ChatMessage[]
83
+ // ctx has: conversationId, userId, custom
22
84
  return {
23
- messages: [
24
- {
25
- role: 'assistant',
26
- content: 'Hello from my handler!',
27
- },
28
- ],
85
+ message: { role: 'assistant', content: `Hello, user ${ctx?.userId}!` },
86
+ };
87
+ });
88
+ ```
89
+
90
+ The `ctx` parameter is optional and contains request context:
91
+
92
+ - `conversationId`: Track multi-turn conversations
93
+ - `userId`: Identify the user
94
+ - `custom`: Any additional custom fields
95
+
96
+ ### Streaming Responses
97
+
98
+ Return an async generator to stream responses:
99
+
100
+ ```typescript
101
+ agent.onInvoke(async function* (input) {
102
+ yield { chunk: 'Hello ' };
103
+ yield { chunk: 'World!' };
104
+ });
105
+
106
+ agent.onChat(async function* (messages) {
107
+ yield { chunk: 'Streaming ' };
108
+ yield { chunk: 'response...' };
109
+ });
110
+ ```
111
+
112
+ ### Serve Function
113
+
114
+ Start a server hosting your agents:
115
+
116
+ ```typescript
117
+ import { serve } from '@reminix/runtime';
118
+
119
+ // Single agent
120
+ serve(agent, { host: '0.0.0.0', port: 8080 });
121
+
122
+ // Multiple agents
123
+ serve([agent1, agent2], { port: 8080 });
124
+ ```
125
+
126
+ ### Endpoints
127
+
128
+ | Method | Path | Description |
129
+ | ------ | ---------------------- | --------------------------- |
130
+ | GET | `/health` | Runtime health status |
131
+ | GET | `/_discover` | Runtime and agent discovery |
132
+ | GET | `/agent/{name}/health` | Agent capabilities |
133
+ | POST | `/agent/{name}/invoke` | Invoke agent |
134
+ | POST | `/agent/{name}/chat` | Chat with agent |
135
+
136
+ ### Discovery Endpoint
137
+
138
+ The `/_discover` endpoint returns runtime and agent information:
139
+
140
+ ```bash
141
+ curl http://localhost:8080/_discover
142
+ ```
143
+
144
+ ```json
145
+ {
146
+ "runtime": {
147
+ "version": "0.6.0",
148
+ "language": "typescript",
149
+ "framework": "hono"
150
+ },
151
+ "agents": [
152
+ {
153
+ "name": "my-agent",
154
+ "invoke": true,
155
+ "chat": true,
156
+ "metadata": {
157
+ "framework": "langchain",
158
+ "model": "gpt-4"
159
+ }
160
+ }
161
+ ]
162
+ }
163
+ ```
164
+
165
+ ### Request/Response Types
166
+
167
+ #### Invoke Request
168
+
169
+ ```typescript
170
+ {
171
+ input: Record<string, unknown>;
172
+ stream?: boolean; // default: false
173
+ }
174
+ ```
175
+
176
+ #### Invoke Response
177
+
178
+ ```typescript
179
+ {
180
+ output: unknown;
181
+ }
182
+ ```
183
+
184
+ #### Chat Request
185
+
186
+ ```typescript
187
+ {
188
+ messages: Array<{
189
+ role: 'system' | 'user' | 'assistant' | 'tool';
190
+ content: string | unknown[] | null;
191
+ name?: string;
192
+ tool_calls?: ToolCall[];
193
+ tool_call_id?: string;
194
+ }>;
195
+ stream?: boolean; // default: false
196
+ }
197
+ ```
198
+
199
+ #### Chat Response
200
+
201
+ ```typescript
202
+ {
203
+ message: {
204
+ role: 'assistant';
205
+ content: string | unknown[] | null;
206
+ tool_calls?: ToolCall[];
29
207
  };
30
- };
208
+ }
31
209
  ```
32
210
 
33
- ## Components
211
+ #### Streaming Response (SSE)
212
+
213
+ When `stream: true`, responses are Server-Sent Events:
34
214
 
35
- ### Types
215
+ ```
216
+ data: {"chunk": "Hello "}
217
+
218
+ data: {"chunk": "World!"}
219
+
220
+ data: [DONE]
221
+ ```
36
222
 
37
- - `Message` - Conversation message
38
- - `ToolCall` - Tool call made by an agent
39
- - `Context` - Persistent resources provided to handlers
40
- - `Request` - Current invocation request
41
- - `Response` - Handler response
42
- - `MemoryStore` - Memory store interface
43
- - `KnowledgeBase` - Knowledge base interface
44
- - `ToolRegistry` - Tool registry interface
45
- - `AgentHandler` - Agent handler function type
46
- - `ToolHandler` - Tool handler function type
223
+ ## Error Handling
47
224
 
48
- ### Utilities
225
+ The runtime handles errors appropriately:
49
226
 
50
- - `load_handler(handlerPath)` - Load a handler from a file
51
- - `discover_registry(handlerPath)` - Auto-discover handlers from a directory structure
52
- - `execute_handler(handler, context, request)` - Execute a handler with context and request
227
+ - `404` - Agent not found
228
+ - `400` - Invalid request (missing input/messages, validation errors)
229
+ - `501` - Handler not implemented
230
+ - `502` - Agent handler returned invalid response
231
+ - `500` - Internal server error
53
232
 
54
233
  ## License
55
234
 
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Agent class for building AI agents that integrate with Reminix.
3
+ */
4
+ import type { AgentInfo, ChatHandler, ChatMessage, ChatResponse, Context, InvokeHandler, InvokeInput, InvokeResponse, StreamChunk } from './types';
5
+ /**
6
+ * Options for creating an Agent.
7
+ */
8
+ export interface AgentOptions {
9
+ /**
10
+ * Optional metadata for the agent (e.g., framework, model, description).
11
+ */
12
+ metadata?: Record<string, unknown>;
13
+ }
14
+ /**
15
+ * Agent class for defining invoke and chat handlers.
16
+ *
17
+ * Handlers can optionally receive a context parameter with conversation
18
+ * and user information.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const agent = new Agent('my-agent');
23
+ *
24
+ * agent.onInvoke(async (input, ctx) => {
25
+ * // ctx has: conversationId, userId, custom
26
+ * return { output: `Processed: ${input.message}` };
27
+ * });
28
+ *
29
+ * agent.onChat(async (messages, ctx) => {
30
+ * return {
31
+ * message: { role: 'assistant', content: `Hello, user ${ctx?.userId}!` }
32
+ * };
33
+ * });
34
+ * ```
35
+ */
36
+ export declare class Agent {
37
+ readonly name: string;
38
+ private readonly _metadata;
39
+ private invokeHandler;
40
+ private chatHandler;
41
+ /**
42
+ * Create a new Agent.
43
+ *
44
+ * @param name - Unique identifier for the agent (lowercase letters, numbers, hyphens, underscores)
45
+ * @param options - Optional configuration including metadata
46
+ * @throws {Error} If name is empty or contains invalid characters
47
+ */
48
+ constructor(name: string, options?: AgentOptions);
49
+ /**
50
+ * Get the agent's metadata.
51
+ */
52
+ get metadata(): Record<string, unknown>;
53
+ /**
54
+ * Get agent information for discovery.
55
+ */
56
+ toInfo(): AgentInfo;
57
+ /**
58
+ * Whether an invoke handler is registered.
59
+ */
60
+ get hasInvoke(): boolean;
61
+ /**
62
+ * Whether a chat handler is registered.
63
+ */
64
+ get hasChat(): boolean;
65
+ /**
66
+ * Register an invoke handler.
67
+ *
68
+ * @param handler - Function that processes invoke requests
69
+ * @returns The agent instance for chaining
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * agent.onInvoke(async (input) => {
74
+ * return { output: processData(input) };
75
+ * });
76
+ * ```
77
+ */
78
+ onInvoke(handler: InvokeHandler): this;
79
+ /**
80
+ * Register a chat handler.
81
+ *
82
+ * @param handler - Function that processes chat requests
83
+ * @returns The agent instance for chaining
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * agent.onChat(async (messages) => {
88
+ * return {
89
+ * message: { role: 'assistant', content: 'Hello!' }
90
+ * };
91
+ * });
92
+ * ```
93
+ */
94
+ onChat(handler: ChatHandler): this;
95
+ /**
96
+ * Handle an invoke request.
97
+ *
98
+ * @param input - The input data from the request
99
+ * @param ctx - Optional request context
100
+ * @returns The response or an async generator for streaming
101
+ * @throws {Error} If no invoke handler is registered
102
+ * @throws {Error} If the response is invalid
103
+ */
104
+ handleInvoke(input: InvokeInput, ctx?: Context): Promise<InvokeResponse | AsyncGenerator<StreamChunk, void, unknown>>;
105
+ /**
106
+ * Handle a chat request.
107
+ *
108
+ * @param messages - The conversation messages
109
+ * @param ctx - Optional request context
110
+ * @returns The response or an async generator for streaming
111
+ * @throws {Error} If no chat handler is registered
112
+ * @throws {Error} If the response is invalid
113
+ */
114
+ handleChat(messages: ChatMessage[], ctx?: Context): Promise<ChatResponse | AsyncGenerator<StreamChunk, void, unknown>>;
115
+ /**
116
+ * String representation for debugging.
117
+ */
118
+ toString(): string;
119
+ }
120
+ /**
121
+ * Error thrown when a handler is not implemented.
122
+ */
123
+ export declare class NotImplementedError extends Error {
124
+ constructor(message: string);
125
+ }
126
+ /**
127
+ * Error thrown when an agent handler returns invalid data.
128
+ */
129
+ export declare class AgentError extends Error {
130
+ constructor(message: string);
131
+ }
132
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,WAAW,EACX,YAAY,EAEZ,OAAO,EACP,aAAa,EACb,WAAW,EACX,cAAc,EAEd,WAAW,EACZ,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAmBD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,KAAK;IAChB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA0B;IACpD,OAAO,CAAC,aAAa,CAA8B;IACnD,OAAO,CAAC,WAAW,CAA4B;IAE/C;;;;;;OAMG;gBACS,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;IAgBhD;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEtC;IAED;;OAEG;IACH,MAAM,IAAI,SAAS;IASnB;;OAEG;IACH,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAKtC;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAKlC;;;;;;;;OAQG;IACG,YAAY,CAChB,KAAK,EAAE,WAAW,EAClB,GAAG,CAAC,EAAE,OAAO,GACZ,OAAO,CAAC,cAAc,GAAG,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAoBvE;;;;;;;;OAQG;IACG,UAAU,CACd,QAAQ,EAAE,WAAW,EAAE,EACvB,GAAG,CAAC,EAAE,OAAO,GACZ,OAAO,CAAC,YAAY,GAAG,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAyBrE;;OAEG;IACH,QAAQ,IAAI,MAAM;CAMnB;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,KAAK;gBACvB,OAAO,EAAE,MAAM;CAI5B"}
package/dist/agent.js ADDED
@@ -0,0 +1,207 @@
1
+ /**
2
+ * Agent class for building AI agents that integrate with Reminix.
3
+ */
4
+ /**
5
+ * Pattern for valid agent names: lowercase letters, numbers, hyphens, underscores.
6
+ */
7
+ const VALID_NAME_PATTERN = /^[a-z0-9_-]+$/;
8
+ /**
9
+ * Check if a value is an async generator.
10
+ */
11
+ function isAsyncGenerator(value) {
12
+ return (value !== null &&
13
+ typeof value === 'object' &&
14
+ Symbol.asyncIterator in value &&
15
+ typeof value.next === 'function');
16
+ }
17
+ /**
18
+ * Agent class for defining invoke and chat handlers.
19
+ *
20
+ * Handlers can optionally receive a context parameter with conversation
21
+ * and user information.
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * const agent = new Agent('my-agent');
26
+ *
27
+ * agent.onInvoke(async (input, ctx) => {
28
+ * // ctx has: conversationId, userId, custom
29
+ * return { output: `Processed: ${input.message}` };
30
+ * });
31
+ *
32
+ * agent.onChat(async (messages, ctx) => {
33
+ * return {
34
+ * message: { role: 'assistant', content: `Hello, user ${ctx?.userId}!` }
35
+ * };
36
+ * });
37
+ * ```
38
+ */
39
+ export class Agent {
40
+ /**
41
+ * Create a new Agent.
42
+ *
43
+ * @param name - Unique identifier for the agent (lowercase letters, numbers, hyphens, underscores)
44
+ * @param options - Optional configuration including metadata
45
+ * @throws {Error} If name is empty or contains invalid characters
46
+ */
47
+ constructor(name, options) {
48
+ this.invokeHandler = null;
49
+ this.chatHandler = null;
50
+ if (!name || name.trim() === '') {
51
+ throw new Error('Agent name cannot be empty');
52
+ }
53
+ if (!VALID_NAME_PATTERN.test(name)) {
54
+ throw new Error(`Agent name "${name}" contains invalid characters. ` +
55
+ 'Use only lowercase letters, numbers, hyphens, and underscores.');
56
+ }
57
+ this.name = name;
58
+ this._metadata = options?.metadata ?? {};
59
+ }
60
+ /**
61
+ * Get the agent's metadata.
62
+ */
63
+ get metadata() {
64
+ return this._metadata;
65
+ }
66
+ /**
67
+ * Get agent information for discovery.
68
+ */
69
+ toInfo() {
70
+ return {
71
+ name: this.name,
72
+ invoke: this.hasInvoke,
73
+ chat: this.hasChat,
74
+ metadata: this._metadata,
75
+ };
76
+ }
77
+ /**
78
+ * Whether an invoke handler is registered.
79
+ */
80
+ get hasInvoke() {
81
+ return this.invokeHandler !== null;
82
+ }
83
+ /**
84
+ * Whether a chat handler is registered.
85
+ */
86
+ get hasChat() {
87
+ return this.chatHandler !== null;
88
+ }
89
+ /**
90
+ * Register an invoke handler.
91
+ *
92
+ * @param handler - Function that processes invoke requests
93
+ * @returns The agent instance for chaining
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * agent.onInvoke(async (input) => {
98
+ * return { output: processData(input) };
99
+ * });
100
+ * ```
101
+ */
102
+ onInvoke(handler) {
103
+ this.invokeHandler = handler;
104
+ return this;
105
+ }
106
+ /**
107
+ * Register a chat handler.
108
+ *
109
+ * @param handler - Function that processes chat requests
110
+ * @returns The agent instance for chaining
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * agent.onChat(async (messages) => {
115
+ * return {
116
+ * message: { role: 'assistant', content: 'Hello!' }
117
+ * };
118
+ * });
119
+ * ```
120
+ */
121
+ onChat(handler) {
122
+ this.chatHandler = handler;
123
+ return this;
124
+ }
125
+ /**
126
+ * Handle an invoke request.
127
+ *
128
+ * @param input - The input data from the request
129
+ * @param ctx - Optional request context
130
+ * @returns The response or an async generator for streaming
131
+ * @throws {Error} If no invoke handler is registered
132
+ * @throws {Error} If the response is invalid
133
+ */
134
+ async handleInvoke(input, ctx) {
135
+ if (!this.invokeHandler) {
136
+ throw new NotImplementedError('Invoke handler not implemented');
137
+ }
138
+ const result = await this.invokeHandler(input, ctx ?? {});
139
+ // If it's a generator, return it for streaming
140
+ if (isAsyncGenerator(result)) {
141
+ return result;
142
+ }
143
+ // Validate non-streaming response
144
+ if (!('output' in result)) {
145
+ throw new AgentError('Invoke handler must return an object with "output" field');
146
+ }
147
+ return result;
148
+ }
149
+ /**
150
+ * Handle a chat request.
151
+ *
152
+ * @param messages - The conversation messages
153
+ * @param ctx - Optional request context
154
+ * @returns The response or an async generator for streaming
155
+ * @throws {Error} If no chat handler is registered
156
+ * @throws {Error} If the response is invalid
157
+ */
158
+ async handleChat(messages, ctx) {
159
+ if (!this.chatHandler) {
160
+ throw new NotImplementedError('Chat handler not implemented');
161
+ }
162
+ const result = await this.chatHandler(messages, ctx ?? {});
163
+ // If it's a generator, return it for streaming
164
+ if (isAsyncGenerator(result)) {
165
+ return result;
166
+ }
167
+ // Validate non-streaming response
168
+ if (!('message' in result)) {
169
+ throw new AgentError('Chat handler must return an object with "message" field');
170
+ }
171
+ const message = result.message;
172
+ if (!message || message.role !== 'assistant') {
173
+ throw new AgentError('Chat handler must return a message with role "assistant"');
174
+ }
175
+ return result;
176
+ }
177
+ /**
178
+ * String representation for debugging.
179
+ */
180
+ toString() {
181
+ const capabilities = [];
182
+ if (this.hasInvoke)
183
+ capabilities.push('invoke');
184
+ if (this.hasChat)
185
+ capabilities.push('chat');
186
+ return `Agent(${this.name}, ${capabilities.length > 0 ? capabilities.join(', ') : 'no handlers'})`;
187
+ }
188
+ }
189
+ /**
190
+ * Error thrown when a handler is not implemented.
191
+ */
192
+ export class NotImplementedError extends Error {
193
+ constructor(message) {
194
+ super(message);
195
+ this.name = 'NotImplementedError';
196
+ }
197
+ }
198
+ /**
199
+ * Error thrown when an agent handler returns invalid data.
200
+ */
201
+ export class AgentError extends Error {
202
+ constructor(message) {
203
+ super(message);
204
+ this.name = 'AgentError';
205
+ }
206
+ }
207
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA;;GAEG;AA0BH;;GAEG;AACH,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAE3C;;GAEG;AACH,SAAS,gBAAgB,CAAC,KAAc;IACtC,OAAO,CACL,KAAK,KAAK,IAAI;QACd,OAAO,KAAK,KAAK,QAAQ;QACzB,MAAM,CAAC,aAAa,IAAI,KAAK;QAC7B,OAAQ,KAAwB,CAAC,IAAI,KAAK,UAAU,CACrD,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,KAAK;IAMhB;;;;;;OAMG;IACH,YAAY,IAAY,EAAE,OAAsB;QAVxC,kBAAa,GAAyB,IAAI,CAAC;QAC3C,gBAAW,GAAuB,IAAI,CAAC;QAU7C,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,CAAC;QAED,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CACb,eAAe,IAAI,iCAAiC;gBAClD,gEAAgE,CACnE,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC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;AAED;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF"}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,31 @@
1
1
  /**
2
- * Reminix Runtime Types
3
- * @packageDocumentation
2
+ * Reminix Agent Runtime
3
+ *
4
+ * Build AI agents that integrate seamlessly with the Reminix API.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { Agent, serve } from '@reminix/runtime';
9
+ *
10
+ * const agent = new Agent('my-agent');
11
+ *
12
+ * agent.onInvoke(async (input) => {
13
+ * return { output: `Processed: ${input.message}` };
14
+ * });
15
+ *
16
+ * agent.onChat(async (messages) => {
17
+ * const lastMessage = messages[messages.length - 1];
18
+ * return {
19
+ * message: { role: 'assistant', content: `Reply to: ${lastMessage.content}` }
20
+ * };
21
+ * });
22
+ *
23
+ * serve(agent, { port: 8080 });
24
+ * ```
4
25
  */
5
- export type { Message, ToolCall, Context, Request, Response, MemoryStore, KnowledgeBase, ToolRegistry, ToolHandler, AgentHandler, } from './types';
6
- export { loadHandler, isFile, type LoadedHandler } from './loader';
7
- export { discoverRegistry, type Registry } from './registry';
8
- export { executeAgent, executeTool, executeHandler } from './executor';
26
+ export type { ToolCallFunction, ToolCall, MessageRole, ChatMessage, AssistantMessage, InvokeRequest, ChatRequest, InvokeResponse, ChatResponse, StreamChunk, Context, InvokeInput, InvokeResult, ChatResult, InvokeHandler, ChatHandler, AgentHealth, HealthResponse, AgentMetadata, AgentInfo, RuntimeInfo, DiscoverResponse, } from './types';
27
+ export { ToolCallFunctionSchema, ToolCallSchema, MessageRoleSchema, ChatMessageSchema, AssistantMessageSchema, InvokeRequestSchema, ChatRequestSchema, InvokeResponseSchema, ChatResponseSchema, StreamChunkSchema, } from './types';
28
+ export { Agent, NotImplementedError, AgentError, type AgentOptions } from './agent';
29
+ export { serve, createApp, type ServeOptions } from './server';
30
+ export { formatSseEvent, formatSseDone, streamToSse } from './streaming';
9
31
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EACV,OAAO,EACP,QAAQ,EACR,OAAO,EACP,OAAO,EACP,QAAQ,EACR,WAAW,EACX,aAAa,EACb,YAAY,EACZ,WAAW,EACX,YAAY,GACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,YAAY,EAEV,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,WAAW,EACX,gBAAgB,EAEhB,aAAa,EACb,WAAW,EAEX,cAAc,EACd,YAAY,EACZ,WAAW,EAEX,OAAO,EAEP,WAAW,EACX,YAAY,EACZ,UAAU,EACV,aAAa,EACb,WAAW,EAEX,WAAW,EACX,cAAc,EAEd,aAAa,EACb,SAAS,EACT,WAAW,EACX,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,iBAA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