@reminix/http-adapter 0.1.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/LICENSE +21 -0
- package/README.md +303 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +60 -0
- package/dist/cli.js.map +1 -0
- package/dist/converter.d.ts +19 -0
- package/dist/converter.d.ts.map +1 -0
- package/dist/converter.js +140 -0
- package/dist/converter.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/loader.d.ts +19 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +52 -0
- package/dist/loader.js.map +1 -0
- package/dist/registry.d.ts +24 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +208 -0
- package/dist/registry.js.map +1 -0
- package/dist/server.d.ts +15 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +160 -0
- package/dist/server.js.map +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Reminix
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
# @reminix/http-adapter
|
|
2
|
+
|
|
3
|
+
HTTP adapter for running Reminix handlers locally. This package provides an HTTP server that can load and execute TypeScript/JavaScript handlers, making them accessible via REST API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @reminix/http-adapter
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @reminix/http-adapter
|
|
11
|
+
# or
|
|
12
|
+
yarn add @reminix/http-adapter
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
### 1. Create a Handler
|
|
18
|
+
|
|
19
|
+
Create a file `my-handler.ts`:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import type { AgentHandler, Context, Request, Response } from '@reminix/sdk';
|
|
23
|
+
|
|
24
|
+
export const agents = {
|
|
25
|
+
chatbot: async (context: Context, request: Request): Promise<Response> => {
|
|
26
|
+
const lastMessage = request.messages[request.messages.length - 1];
|
|
27
|
+
return {
|
|
28
|
+
messages: [
|
|
29
|
+
{
|
|
30
|
+
role: 'assistant',
|
|
31
|
+
content: `You said: ${lastMessage?.content || 'Hello!'}`,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
metadata: {},
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 2. Start the Server
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Using npx
|
|
44
|
+
npx @reminix/http-adapter serve my-handler.ts
|
|
45
|
+
|
|
46
|
+
# Or using tsx (development)
|
|
47
|
+
tsx node_modules/@reminix/http-adapter/dist/cli.js serve my-handler.ts
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 3. Test the Handler
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Health check
|
|
54
|
+
curl http://localhost:3000/health
|
|
55
|
+
|
|
56
|
+
# Invoke the agent
|
|
57
|
+
curl -X POST http://localhost:3000/agents/chatbot/invoke \
|
|
58
|
+
-H "Content-Type: application/json" \
|
|
59
|
+
-d '{"messages": [{"role": "user", "content": "Hello!"}]}'
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Usage
|
|
63
|
+
|
|
64
|
+
### Command Line
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Basic usage
|
|
68
|
+
npx @reminix/http-adapter serve <handler-path> [options]
|
|
69
|
+
|
|
70
|
+
# Options
|
|
71
|
+
--port <number> Port to listen on (default: 3000)
|
|
72
|
+
--host <string> Host to listen on (default: localhost)
|
|
73
|
+
|
|
74
|
+
# Examples
|
|
75
|
+
npx @reminix/http-adapter serve ./my-handler.ts
|
|
76
|
+
npx @reminix/http-adapter serve ./my-handler.ts --port 8080
|
|
77
|
+
npx @reminix/http-adapter serve ./my-handler --host 0.0.0.0
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Programmatic API
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { startServer } from '@reminix/http-adapter';
|
|
84
|
+
|
|
85
|
+
// Start server with default options
|
|
86
|
+
await startServer('./my-handler.ts');
|
|
87
|
+
|
|
88
|
+
// Start server with custom options
|
|
89
|
+
await startServer('./my-handler.ts', {
|
|
90
|
+
port: 8080,
|
|
91
|
+
host: '0.0.0.0',
|
|
92
|
+
context: async (req) => {
|
|
93
|
+
// Provide custom context from request
|
|
94
|
+
return {
|
|
95
|
+
chatId: req.headers['x-chat-id'] || 'default',
|
|
96
|
+
// ... other context properties
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Handler Formats
|
|
103
|
+
|
|
104
|
+
### Single File Handler
|
|
105
|
+
|
|
106
|
+
Export `agents`, `tools`, and/or `prompts`:
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
export const agents = {
|
|
110
|
+
chatbot: async (context, request) => ({ messages: [] }),
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const tools = {
|
|
114
|
+
calculator: async (context, request) => ({ messages: [] }),
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export const prompts = {
|
|
118
|
+
system: 'You are a helpful assistant.',
|
|
119
|
+
};
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Directory-Based Handler (Auto-Discovery)
|
|
123
|
+
|
|
124
|
+
Organize handlers in a directory structure:
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
my-handler/
|
|
128
|
+
agents/
|
|
129
|
+
chatbot.ts # export const chatbot = async (...) => {...}
|
|
130
|
+
assistant.ts # export const assistant = async (...) => {...}
|
|
131
|
+
tools/
|
|
132
|
+
search.ts # export const search = async (...) => {...}
|
|
133
|
+
weather.ts # export const weather = async (...) => {...}
|
|
134
|
+
prompts/
|
|
135
|
+
system.ts # export const system = {...}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
The adapter will automatically discover and load all handlers from this structure.
|
|
139
|
+
|
|
140
|
+
## API Endpoints
|
|
141
|
+
|
|
142
|
+
### Health Check
|
|
143
|
+
|
|
144
|
+
```http
|
|
145
|
+
GET /health
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Returns:
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"status": "ok",
|
|
153
|
+
"agents": ["chatbot", "assistant"],
|
|
154
|
+
"tools": ["search", "weather"],
|
|
155
|
+
"prompts": ["system"]
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Invoke Agent
|
|
160
|
+
|
|
161
|
+
```http
|
|
162
|
+
POST /agents/:agentId/invoke
|
|
163
|
+
Content-Type: application/json
|
|
164
|
+
|
|
165
|
+
{
|
|
166
|
+
"messages": [
|
|
167
|
+
{
|
|
168
|
+
"role": "user",
|
|
169
|
+
"content": "Hello!"
|
|
170
|
+
}
|
|
171
|
+
],
|
|
172
|
+
"metadata": {
|
|
173
|
+
"chatId": "chat-123"
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Invoke Tool
|
|
179
|
+
|
|
180
|
+
```http
|
|
181
|
+
POST /tools/:toolId/invoke
|
|
182
|
+
Content-Type: application/json
|
|
183
|
+
|
|
184
|
+
{
|
|
185
|
+
"messages": [
|
|
186
|
+
{
|
|
187
|
+
"role": "user",
|
|
188
|
+
"content": "5 + 3"
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Handler Interface
|
|
195
|
+
|
|
196
|
+
Handlers receive a `Context` and `Request`, and return a `Response`:
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
import type { AgentHandler, Context, Request, Response } from '@reminix/sdk';
|
|
200
|
+
|
|
201
|
+
const myAgent: AgentHandler = async (context: Context, request: Request): Promise<Response> => {
|
|
202
|
+
// Access context
|
|
203
|
+
const chatId = context.chatId;
|
|
204
|
+
const memory = context.memory;
|
|
205
|
+
|
|
206
|
+
// Access request
|
|
207
|
+
const messages = request.messages;
|
|
208
|
+
const metadata = request.metadata;
|
|
209
|
+
|
|
210
|
+
// Return response
|
|
211
|
+
return {
|
|
212
|
+
messages: [
|
|
213
|
+
{
|
|
214
|
+
role: 'assistant',
|
|
215
|
+
content: 'Response here',
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
metadata: {
|
|
219
|
+
tokensUsed: 100,
|
|
220
|
+
},
|
|
221
|
+
toolCalls: [], // Optional
|
|
222
|
+
stateUpdates: {}, // Optional
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Examples
|
|
228
|
+
|
|
229
|
+
See the [examples directory](./examples/) for complete working examples:
|
|
230
|
+
|
|
231
|
+
- **Basic Handler**: Single-file handler with agents and tools
|
|
232
|
+
- **Multi Handler**: Directory-based handler with auto-discovery
|
|
233
|
+
|
|
234
|
+
## API Reference
|
|
235
|
+
|
|
236
|
+
### `startServer(handlerPath, options?)`
|
|
237
|
+
|
|
238
|
+
Start an HTTP server for the given handler.
|
|
239
|
+
|
|
240
|
+
**Parameters:**
|
|
241
|
+
|
|
242
|
+
- `handlerPath` (string): Path to handler file or directory
|
|
243
|
+
- `options` (ServerOptions, optional):
|
|
244
|
+
- `port` (number): Port to listen on (default: 3000)
|
|
245
|
+
- `host` (string): Host to listen on (default: 'localhost')
|
|
246
|
+
- `context` (function): Custom context provider
|
|
247
|
+
|
|
248
|
+
**Returns:** `Promise<void>`
|
|
249
|
+
|
|
250
|
+
### `loadHandler(handlerPath)`
|
|
251
|
+
|
|
252
|
+
Load a handler from a file.
|
|
253
|
+
|
|
254
|
+
**Parameters:**
|
|
255
|
+
|
|
256
|
+
- `handlerPath` (string): Path to handler file
|
|
257
|
+
|
|
258
|
+
**Returns:** `Promise<LoadedHandler>`
|
|
259
|
+
|
|
260
|
+
### `discoverRegistry(handlerPath)`
|
|
261
|
+
|
|
262
|
+
Auto-discover handlers from a directory structure.
|
|
263
|
+
|
|
264
|
+
**Parameters:**
|
|
265
|
+
|
|
266
|
+
- `handlerPath` (string): Path to handler directory
|
|
267
|
+
|
|
268
|
+
**Returns:** `Promise<Registry>`
|
|
269
|
+
|
|
270
|
+
### `convertHttpToRequest(httpReq)`
|
|
271
|
+
|
|
272
|
+
Convert HTTP request to handler Request format.
|
|
273
|
+
|
|
274
|
+
**Parameters:**
|
|
275
|
+
|
|
276
|
+
- `httpReq` (IncomingMessage): Node.js HTTP request
|
|
277
|
+
|
|
278
|
+
**Returns:** `Promise<Request>`
|
|
279
|
+
|
|
280
|
+
### `convertResponseToHttp(handlerRes, httpRes)`
|
|
281
|
+
|
|
282
|
+
Convert handler Response to HTTP response.
|
|
283
|
+
|
|
284
|
+
**Parameters:**
|
|
285
|
+
|
|
286
|
+
- `handlerRes` (Response): Handler response
|
|
287
|
+
- `httpRes` (ServerResponse): Node.js HTTP response
|
|
288
|
+
|
|
289
|
+
**Returns:** `void`
|
|
290
|
+
|
|
291
|
+
## TypeScript Support
|
|
292
|
+
|
|
293
|
+
This package is written in TypeScript and includes full type definitions. No additional `@types` package needed.
|
|
294
|
+
|
|
295
|
+
## License
|
|
296
|
+
|
|
297
|
+
MIT
|
|
298
|
+
|
|
299
|
+
## Links
|
|
300
|
+
|
|
301
|
+
- [GitHub Repository](https://github.com/reminix-ai/reminix-typescript)
|
|
302
|
+
- [Documentation](https://docs.reminix.com)
|
|
303
|
+
- [Examples](./examples/)
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;GAMG"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* CLI entry point for Reminix HTTP adapter
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* npx @reminix/http-adapter serve <handler-path> [options]
|
|
7
|
+
* tsx src/cli.ts serve <handler-path> [options]
|
|
8
|
+
*/
|
|
9
|
+
import { startServer } from './server';
|
|
10
|
+
import { parseArgs } from 'util';
|
|
11
|
+
function parseCliArgs() {
|
|
12
|
+
const args = process.argv.slice(2);
|
|
13
|
+
if (args.length === 0 || args[0] !== 'serve') {
|
|
14
|
+
console.error('Usage: reminix-http-adapter serve <handler-path> [options]');
|
|
15
|
+
console.error('');
|
|
16
|
+
console.error('Options:');
|
|
17
|
+
console.error(' --port <number> Port to listen on (default: 3000)');
|
|
18
|
+
console.error(' --host <string> Host to listen on (default: localhost)');
|
|
19
|
+
console.error('');
|
|
20
|
+
console.error('Examples:');
|
|
21
|
+
console.error(' npx @reminix/http-adapter serve ./my-handler.ts');
|
|
22
|
+
console.error(' npx @reminix/http-adapter serve ./my-handler --port 8080');
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
const handlerPath = args[1];
|
|
26
|
+
if (!handlerPath) {
|
|
27
|
+
console.error('Error: handler-path is required');
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
const { values } = parseArgs({
|
|
31
|
+
args: args.slice(2),
|
|
32
|
+
options: {
|
|
33
|
+
port: { type: 'string' },
|
|
34
|
+
host: { type: 'string' },
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
const options = {
|
|
38
|
+
handlerPath,
|
|
39
|
+
port: values.port ? parseInt(values.port, 10) : undefined,
|
|
40
|
+
host: values.host,
|
|
41
|
+
};
|
|
42
|
+
return options;
|
|
43
|
+
}
|
|
44
|
+
async function main() {
|
|
45
|
+
try {
|
|
46
|
+
const options = parseCliArgs();
|
|
47
|
+
const serverOptions = {
|
|
48
|
+
port: options.port,
|
|
49
|
+
host: options.host,
|
|
50
|
+
};
|
|
51
|
+
await startServer(options.handlerPath, serverOptions);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
console.error('Error starting server:', error);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Run if called directly
|
|
59
|
+
main();
|
|
60
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","source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xB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SACzB;KACF,CAAC,CAAC;IAEH,MAAM,OAAO,GAAe;QAC1B,WAAW;QACX,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS;QACzD,IAAI,EAAE,MAAM,CAAC,IAAI;KAClB,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,YAAY,EAAE,CAAC;QAE/B,MAAM,aAAa,GAAkB;YACnC,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,IAAI,EAAE,OAAO,CAAC,IAAI;SACnB,CAAC;QAEF,MAAM,WAAW,CAAC,OAAO,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IACxD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,yBAAyB;AACzB,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert between HTTP and Handler formats
|
|
3
|
+
*/
|
|
4
|
+
import type { IncomingMessage, ServerResponse } from 'http';
|
|
5
|
+
import type { Request as HandlerRequest, Response as HandlerResponse } from '@reminix/sdk';
|
|
6
|
+
/**
|
|
7
|
+
* Convert HTTP request to Handler Request
|
|
8
|
+
* Extracts messages from HTTP request body
|
|
9
|
+
*/
|
|
10
|
+
export declare function convertHttpToRequest(httpReq: IncomingMessage): Promise<HandlerRequest>;
|
|
11
|
+
/**
|
|
12
|
+
* Convert Handler Response to HTTP response
|
|
13
|
+
*/
|
|
14
|
+
export declare function convertResponseToHttp(handlerRes: HandlerResponse, httpRes: ServerResponse): void;
|
|
15
|
+
/**
|
|
16
|
+
* Convert error to HTTP error response
|
|
17
|
+
*/
|
|
18
|
+
export declare function convertErrorToHttp(error: Error, httpRes: ServerResponse): void;
|
|
19
|
+
//# sourceMappingURL=converter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converter.d.ts","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,IAAI,cAAc,EAAE,QAAQ,IAAI,eAAe,EAAW,MAAM,cAAc,CAAC;AAEpG;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAoE5F;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAsChG;AAuBD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAS9E"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert between HTTP and Handler formats
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Convert HTTP request to Handler Request
|
|
6
|
+
* Extracts messages from HTTP request body
|
|
7
|
+
*/
|
|
8
|
+
export async function convertHttpToRequest(httpReq) {
|
|
9
|
+
try {
|
|
10
|
+
// Read request body
|
|
11
|
+
const body = await readRequestBody(httpReq);
|
|
12
|
+
// Parse JSON body
|
|
13
|
+
let parsedBody = {};
|
|
14
|
+
if (body) {
|
|
15
|
+
try {
|
|
16
|
+
parsedBody = JSON.parse(body);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
// If not JSON, treat as text
|
|
20
|
+
parsedBody = { content: body };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// Extract messages from body
|
|
24
|
+
// Expected format: { messages: Message[] } or { message: Message } or just Message[]
|
|
25
|
+
let messages = [];
|
|
26
|
+
if (Array.isArray(parsedBody)) {
|
|
27
|
+
// Body is array of messages
|
|
28
|
+
messages = parsedBody;
|
|
29
|
+
}
|
|
30
|
+
else if (parsedBody.messages && Array.isArray(parsedBody.messages)) {
|
|
31
|
+
// Body has messages array
|
|
32
|
+
messages = parsedBody.messages;
|
|
33
|
+
}
|
|
34
|
+
else if (parsedBody.message) {
|
|
35
|
+
// Body has single message
|
|
36
|
+
messages = [parsedBody.message];
|
|
37
|
+
}
|
|
38
|
+
else if (parsedBody.content || parsedBody.role) {
|
|
39
|
+
// Body is a single message object
|
|
40
|
+
messages = [parsedBody];
|
|
41
|
+
}
|
|
42
|
+
// Extract metadata from query params and headers
|
|
43
|
+
const metadata = {
|
|
44
|
+
method: httpReq.method,
|
|
45
|
+
url: httpReq.url,
|
|
46
|
+
headers: httpReq.headers,
|
|
47
|
+
};
|
|
48
|
+
// Add query params to metadata
|
|
49
|
+
if (httpReq.url) {
|
|
50
|
+
const url = new URL(httpReq.url, `http://${httpReq.headers.host || 'localhost'}`);
|
|
51
|
+
const queryParams = {};
|
|
52
|
+
url.searchParams.forEach((value, key) => {
|
|
53
|
+
queryParams[key] = value;
|
|
54
|
+
});
|
|
55
|
+
if (Object.keys(queryParams).length > 0) {
|
|
56
|
+
metadata.query = queryParams;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Merge any additional metadata from body
|
|
60
|
+
if (parsedBody.metadata) {
|
|
61
|
+
Object.assign(metadata, parsedBody.metadata);
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
messages,
|
|
65
|
+
metadata,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
if (error instanceof Error) {
|
|
70
|
+
throw new Error(`Failed to convert HTTP request: ${error.message}`);
|
|
71
|
+
}
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Convert Handler Response to HTTP response
|
|
77
|
+
*/
|
|
78
|
+
export function convertResponseToHttp(handlerRes, httpRes) {
|
|
79
|
+
try {
|
|
80
|
+
// Set status code (default 200)
|
|
81
|
+
const statusCode = typeof handlerRes.metadata?.statusCode === 'number' ? handlerRes.metadata.statusCode : 200;
|
|
82
|
+
httpRes.statusCode = statusCode;
|
|
83
|
+
// Set headers
|
|
84
|
+
const headers = handlerRes.metadata?.headers ||
|
|
85
|
+
{};
|
|
86
|
+
headers['Content-Type'] =
|
|
87
|
+
(typeof headers['Content-Type'] === 'string' ? headers['Content-Type'] : undefined) ||
|
|
88
|
+
'application/json';
|
|
89
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
90
|
+
if (typeof value === 'string') {
|
|
91
|
+
httpRes.setHeader(key, value);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Prepare response body
|
|
95
|
+
const responseBody = {
|
|
96
|
+
messages: handlerRes.messages,
|
|
97
|
+
...(handlerRes.metadata && { metadata: handlerRes.metadata }),
|
|
98
|
+
...(handlerRes.toolCalls && { toolCalls: handlerRes.toolCalls }),
|
|
99
|
+
...(handlerRes.stateUpdates && { stateUpdates: handlerRes.stateUpdates }),
|
|
100
|
+
};
|
|
101
|
+
// Send response
|
|
102
|
+
httpRes.end(JSON.stringify(responseBody));
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
if (error instanceof Error) {
|
|
106
|
+
httpRes.statusCode = 500;
|
|
107
|
+
httpRes.setHeader('Content-Type', 'application/json');
|
|
108
|
+
httpRes.end(JSON.stringify({ error: error.message }));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Read request body from IncomingMessage
|
|
114
|
+
*/
|
|
115
|
+
async function readRequestBody(req) {
|
|
116
|
+
return new Promise((resolve, reject) => {
|
|
117
|
+
let body = '';
|
|
118
|
+
req.on('data', (chunk) => {
|
|
119
|
+
body += chunk.toString();
|
|
120
|
+
});
|
|
121
|
+
req.on('end', () => {
|
|
122
|
+
resolve(body);
|
|
123
|
+
});
|
|
124
|
+
req.on('error', (error) => {
|
|
125
|
+
reject(error);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Convert error to HTTP error response
|
|
131
|
+
*/
|
|
132
|
+
export function convertErrorToHttp(error, httpRes) {
|
|
133
|
+
httpRes.statusCode = 500;
|
|
134
|
+
httpRes.setHeader('Content-Type', 'application/json');
|
|
135
|
+
httpRes.end(JSON.stringify({
|
|
136
|
+
error: error.message,
|
|
137
|
+
...(process.env.NODE_ENV === 'development' && { stack: error.stack }),
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=converter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAAwB;IACjE,IAAI,CAAC;QACH,oBAAoB;QACpB,MAAM,IAAI,GAAG,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC;QAE5C,kBAAkB;QAClB,IAAI,UAAU,GAA4B,EAAE,CAAC;QAC7C,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC;gBACH,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAA4B,CAAC;YAC3D,CAAC;YAAC,MAAM,CAAC;gBACP,6BAA6B;gBAC7B,UAAU,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YACjC,CAAC;QACH,CAAC;QAED,6BAA6B;QAC7B,qFAAqF;QACrF,IAAI,QAAQ,GAAc,EAAE,CAAC;QAE7B,IAAI,KAAK,CAAC,OAAO,CAAC,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,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAY,EAAE,OAAuB;IACtE,OAAO,CAAC,UAAU,GAAG,GAAG,CAAC;IACzB,OAAO,CAAC,SAAS,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;IACtD,OAAO,CAAC,GAAG,CACT,IAAI,CAAC,SAAS,CAAC;QACb,KAAK,EAAE,KAAK,CAAC,OAAO;QACpB,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;KACtE,CAAC,CACH,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @reminix/http-adapter
|
|
3
|
+
* HTTP adapter for Reminix handlers
|
|
4
|
+
*/
|
|
5
|
+
export { loadHandler, isFile, type LoadedHandler } from './loader';
|
|
6
|
+
export { discoverRegistry, type Registry } from './registry';
|
|
7
|
+
export { convertHttpToRequest, convertResponseToHttp, convertErrorToHttp } from './converter';
|
|
8
|
+
export { startServer, type ServerOptions } from './server';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,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,oBAAoB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @reminix/http-adapter
|
|
3
|
+
* HTTP adapter for Reminix handlers
|
|
4
|
+
*/
|
|
5
|
+
export { loadHandler, isFile } from './loader';
|
|
6
|
+
export { discoverRegistry } from './registry';
|
|
7
|
+
export { convertHttpToRequest, convertResponseToHttp, convertErrorToHttp } from './converter';
|
|
8
|
+
export { startServer } from './server';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,EAAsB,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAiB,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAsB,MAAM,UAAU,CAAC"}
|
package/dist/loader.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load handler from file
|
|
3
|
+
*/
|
|
4
|
+
import type { AgentHandler, ToolHandler } from '@reminix/sdk';
|
|
5
|
+
export interface LoadedHandler {
|
|
6
|
+
agents?: Record<string, AgentHandler>;
|
|
7
|
+
tools?: Record<string, ToolHandler>;
|
|
8
|
+
prompts?: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Load handler from a file path
|
|
12
|
+
* Supports both TypeScript (.ts) and JavaScript (.js) files
|
|
13
|
+
*/
|
|
14
|
+
export declare function loadHandler(handlerPath: string): Promise<LoadedHandler>;
|
|
15
|
+
/**
|
|
16
|
+
* Check if a path is a file (not a directory)
|
|
17
|
+
*/
|
|
18
|
+
export declare function isFile(path: string): boolean;
|
|
19
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE9D,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAqC7E;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAO5C"}
|
package/dist/loader.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load handler from file
|
|
3
|
+
*/
|
|
4
|
+
import { pathToFileURL } from 'url';
|
|
5
|
+
import { statSync } from 'fs';
|
|
6
|
+
/**
|
|
7
|
+
* Load handler from a file path
|
|
8
|
+
* Supports both TypeScript (.ts) and JavaScript (.js) files
|
|
9
|
+
*/
|
|
10
|
+
export async function loadHandler(handlerPath) {
|
|
11
|
+
try {
|
|
12
|
+
// Convert file path to file URL for ES modules
|
|
13
|
+
const fileUrl = pathToFileURL(handlerPath).href;
|
|
14
|
+
// Dynamic import of the handler module
|
|
15
|
+
const module = await import(fileUrl);
|
|
16
|
+
// Extract agents, tools, and prompts
|
|
17
|
+
const loaded = {};
|
|
18
|
+
if (module.agents) {
|
|
19
|
+
loaded.agents = module.agents;
|
|
20
|
+
}
|
|
21
|
+
if (module.tools) {
|
|
22
|
+
loaded.tools = module.tools;
|
|
23
|
+
}
|
|
24
|
+
if (module.prompts) {
|
|
25
|
+
loaded.prompts = module.prompts;
|
|
26
|
+
}
|
|
27
|
+
// Validate that at least one export exists
|
|
28
|
+
if (!loaded.agents && !loaded.tools && !loaded.prompts) {
|
|
29
|
+
throw new Error(`Handler file "${handlerPath}" must export at least one of: agents, tools, or prompts`);
|
|
30
|
+
}
|
|
31
|
+
return loaded;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (error instanceof Error) {
|
|
35
|
+
throw new Error(`Failed to load handler from "${handlerPath}": ${error.message}`);
|
|
36
|
+
}
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Check if a path is a file (not a directory)
|
|
42
|
+
*/
|
|
43
|
+
export function isFile(path) {
|
|
44
|
+
try {
|
|
45
|
+
const stats = statSync(path);
|
|
46
|
+
return stats.isFile();
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAS9B;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,WAAmB;IACnD,IAAI,CAAC;QACH,+CAA+C;QAC/C,MAAM,OAAO,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC;QAEhD,uCAAuC;QACvC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;QAErC,qCAAqC;QACrC,MAAM,MAAM,GAAkB,EAAE,CAAC;QAEjC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAChC,CAAC;QAED,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC9B,CAAC;QAED,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAClC,CAAC;QAED,2CAA2C;QAC3C,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACvD,MAAM,IAAI,KAAK,CACb,iBAAiB,WAAW,0DAA0D,CACvF,CAAC;QACJ,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,gCAAgC,WAAW,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACpF,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,IAAY;IACjC,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC7B,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;IACxB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry for auto-discovering agents, tools, and prompts from directories
|
|
3
|
+
*/
|
|
4
|
+
import type { AgentHandler, ToolHandler } from '@reminix/sdk';
|
|
5
|
+
export interface Registry {
|
|
6
|
+
agents: Record<string, AgentHandler>;
|
|
7
|
+
tools: Record<string, ToolHandler>;
|
|
8
|
+
prompts: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Auto-discover and load handlers from a directory structure
|
|
12
|
+
*
|
|
13
|
+
* Expected structure:
|
|
14
|
+
* handler/
|
|
15
|
+
* agents/
|
|
16
|
+
* chatbot.ts
|
|
17
|
+
* assistant.ts
|
|
18
|
+
* tools/
|
|
19
|
+
* search.ts
|
|
20
|
+
* prompts/
|
|
21
|
+
* system.ts
|
|
22
|
+
*/
|
|
23
|
+
export declare function discoverRegistry(handlerPath: string): Promise<Registry>;
|
|
24
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE9D,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACrC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CA4E7E"}
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry for auto-discovering agents, tools, and prompts from directories
|
|
3
|
+
*/
|
|
4
|
+
import { readdir, stat } from 'fs/promises';
|
|
5
|
+
import { join, extname, basename } from 'path';
|
|
6
|
+
import { pathToFileURL } from 'url';
|
|
7
|
+
import { loadHandler } from './loader';
|
|
8
|
+
/**
|
|
9
|
+
* Auto-discover and load handlers from a directory structure
|
|
10
|
+
*
|
|
11
|
+
* Expected structure:
|
|
12
|
+
* handler/
|
|
13
|
+
* agents/
|
|
14
|
+
* chatbot.ts
|
|
15
|
+
* assistant.ts
|
|
16
|
+
* tools/
|
|
17
|
+
* search.ts
|
|
18
|
+
* prompts/
|
|
19
|
+
* system.ts
|
|
20
|
+
*/
|
|
21
|
+
export async function discoverRegistry(handlerPath) {
|
|
22
|
+
const registry = {
|
|
23
|
+
agents: {},
|
|
24
|
+
tools: {},
|
|
25
|
+
prompts: {},
|
|
26
|
+
};
|
|
27
|
+
try {
|
|
28
|
+
// Check if path exists and is a directory
|
|
29
|
+
const stats = await stat(handlerPath);
|
|
30
|
+
if (!stats.isDirectory()) {
|
|
31
|
+
throw new Error(`Handler path must be a directory: ${handlerPath}`);
|
|
32
|
+
}
|
|
33
|
+
// Discover agents
|
|
34
|
+
const agentsPath = join(handlerPath, 'agents');
|
|
35
|
+
try {
|
|
36
|
+
const agentsStats = await stat(agentsPath);
|
|
37
|
+
if (agentsStats.isDirectory()) {
|
|
38
|
+
const agents = await loadDirectory(agentsPath);
|
|
39
|
+
// Filter to only AgentHandler types
|
|
40
|
+
for (const [key, value] of Object.entries(agents)) {
|
|
41
|
+
if (typeof value === 'function') {
|
|
42
|
+
registry.agents[key] = value;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// agents/ directory doesn't exist, skip
|
|
49
|
+
}
|
|
50
|
+
// Discover tools
|
|
51
|
+
const toolsPath = join(handlerPath, 'tools');
|
|
52
|
+
try {
|
|
53
|
+
const toolsStats = await stat(toolsPath);
|
|
54
|
+
if (toolsStats.isDirectory()) {
|
|
55
|
+
const tools = await loadDirectory(toolsPath);
|
|
56
|
+
// Filter to only ToolHandler types
|
|
57
|
+
for (const [key, value] of Object.entries(tools)) {
|
|
58
|
+
if (typeof value === 'function') {
|
|
59
|
+
registry.tools[key] = value;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
// tools/ directory doesn't exist, skip
|
|
66
|
+
}
|
|
67
|
+
// Discover prompts
|
|
68
|
+
const promptsPath = join(handlerPath, 'prompts');
|
|
69
|
+
try {
|
|
70
|
+
const promptsStats = await stat(promptsPath);
|
|
71
|
+
if (promptsStats.isDirectory()) {
|
|
72
|
+
const prompts = await loadDirectory(promptsPath);
|
|
73
|
+
registry.prompts = prompts;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
// prompts/ directory doesn't exist, skip
|
|
78
|
+
}
|
|
79
|
+
// Validate that at least something was discovered
|
|
80
|
+
if (Object.keys(registry.agents).length === 0 &&
|
|
81
|
+
Object.keys(registry.tools).length === 0 &&
|
|
82
|
+
Object.keys(registry.prompts).length === 0) {
|
|
83
|
+
throw new Error(`No agents, tools, or prompts found in directory: ${handlerPath}`);
|
|
84
|
+
}
|
|
85
|
+
return registry;
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
if (error instanceof Error) {
|
|
89
|
+
throw new Error(`Failed to discover registry from "${handlerPath}": ${error.message}`);
|
|
90
|
+
}
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Load all handler files from a directory
|
|
96
|
+
* Filename (without extension) becomes the key in the registry
|
|
97
|
+
*/
|
|
98
|
+
async function loadDirectory(dirPath) {
|
|
99
|
+
const handlers = {};
|
|
100
|
+
try {
|
|
101
|
+
const entries = await readdir(dirPath);
|
|
102
|
+
for (const entry of entries) {
|
|
103
|
+
const fullPath = join(dirPath, entry);
|
|
104
|
+
const stats = await stat(fullPath);
|
|
105
|
+
// Skip if not a file
|
|
106
|
+
if (!stats.isFile()) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
// Only process TypeScript/JavaScript files
|
|
110
|
+
const ext = extname(entry);
|
|
111
|
+
if (ext !== '.ts' && ext !== '.js' && ext !== '.mjs') {
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
// Extract the key from filename (without extension)
|
|
115
|
+
const key = entry.replace(ext, '');
|
|
116
|
+
try {
|
|
117
|
+
// Try loading as a handler file (expects agents/tools/prompts exports)
|
|
118
|
+
const loaded = await loadHandler(fullPath);
|
|
119
|
+
// Merge agents, tools, and prompts into the registry
|
|
120
|
+
if (loaded.agents) {
|
|
121
|
+
const agentKeys = Object.keys(loaded.agents);
|
|
122
|
+
if (agentKeys.length === 1) {
|
|
123
|
+
handlers[key] = loaded.agents[agentKeys[0]];
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
for (const agentKey of agentKeys) {
|
|
127
|
+
handlers[`${key}.${agentKey}`] = loaded.agents[agentKey];
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (loaded.tools) {
|
|
132
|
+
const toolKeys = Object.keys(loaded.tools);
|
|
133
|
+
if (toolKeys.length === 1) {
|
|
134
|
+
handlers[key] = loaded.tools[toolKeys[0]];
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
for (const toolKey of toolKeys) {
|
|
138
|
+
handlers[`${key}.${toolKey}`] = loaded.tools[toolKey];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (loaded.prompts) {
|
|
143
|
+
const promptKeys = Object.keys(loaded.prompts);
|
|
144
|
+
if (promptKeys.length === 1) {
|
|
145
|
+
handlers[key] = loaded.prompts[promptKeys[0]];
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
for (const promptKey of promptKeys) {
|
|
149
|
+
handlers[`${key}.${promptKey}`] = loaded.prompts[promptKey];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
// If loadHandler fails, try loading as direct export
|
|
156
|
+
// This handles files that export functions directly (e.g., export const chatbot)
|
|
157
|
+
try {
|
|
158
|
+
const fileUrl = pathToFileURL(fullPath).href;
|
|
159
|
+
const module = await import(fileUrl);
|
|
160
|
+
// Determine type based on directory name
|
|
161
|
+
const dirName = basename(dirPath);
|
|
162
|
+
// Check for direct exports matching the directory type
|
|
163
|
+
if (dirName === 'agents') {
|
|
164
|
+
// Look for exported function with same name as file, or any exported function
|
|
165
|
+
const exportedFunction = module[key] || module.default;
|
|
166
|
+
if (typeof exportedFunction === 'function') {
|
|
167
|
+
handlers[key] = exportedFunction;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
else if (dirName === 'tools') {
|
|
171
|
+
const exportedFunction = module[key] || module.default;
|
|
172
|
+
if (typeof exportedFunction === 'function') {
|
|
173
|
+
handlers[key] = exportedFunction;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
else if (dirName === 'prompts') {
|
|
177
|
+
// For prompts, accept any export (function, object, string, etc.)
|
|
178
|
+
// Try to get export with same name as file, or default, or any named export
|
|
179
|
+
const exportedValue = module[key] || module.default;
|
|
180
|
+
if (exportedValue !== undefined) {
|
|
181
|
+
handlers[key] = exportedValue;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
// Check if module has any exports (excluding default module properties)
|
|
185
|
+
const moduleKeys = Object.keys(module).filter((k) => k !== 'default' && !k.startsWith('__'));
|
|
186
|
+
if (moduleKeys.length > 0) {
|
|
187
|
+
// Use the first export, or the module itself if it's a simple object
|
|
188
|
+
handlers[key] = module[moduleKeys[0]] || module;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
// Skip this file if both methods fail
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return handlers;
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
if (error instanceof Error) {
|
|
203
|
+
throw new Error(`Failed to load directory "${dirPath}": ${error.message}`);
|
|
204
|
+
}
|
|
205
|
+
throw error;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @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AAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC;wBACpD,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;4BAChC,QAAQ,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC;wBAChC,CAAC;6BAAM,CAAC;4BACN,wEAAwE;4BACxE,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAC3C,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAC9C,CAAC;4BACF,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gCAC1B,qEAAqE;gCACrE,QAAQ,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC;4BAClD,CAAC;wBACH,CAAC;oBACH,CAAC;gBACH,CAAC;gBAAC,MAAM,CAAC;oBACP,sCAAsC;oBACtC,SAAS;gBACX,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,6BAA6B,OAAO,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC7E,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP server for Reminix handlers
|
|
3
|
+
*/
|
|
4
|
+
import { IncomingMessage } from 'http';
|
|
5
|
+
import type { Context } from '@reminix/sdk';
|
|
6
|
+
export interface ServerOptions {
|
|
7
|
+
port?: number;
|
|
8
|
+
host?: string;
|
|
9
|
+
context?: (req: IncomingMessage) => Promise<Context> | Context;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Start HTTP server for handler
|
|
13
|
+
*/
|
|
14
|
+
export declare function startServer(handlerPath: string, options?: ServerOptions): Promise<void>;
|
|
15
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAgB,eAAe,EAAkB,MAAM,MAAM,CAAC;AAIrE,OAAO,KAAK,EAAE,OAAO,EAA6B,MAAM,cAAc,CAAC;AAEvE,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CAChE;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CA6HjG"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP server for Reminix handlers
|
|
3
|
+
*/
|
|
4
|
+
import { createServer } from 'http';
|
|
5
|
+
import { loadHandler, isFile } from './loader';
|
|
6
|
+
import { discoverRegistry } from './registry';
|
|
7
|
+
import { convertHttpToRequest, convertResponseToHttp, convertErrorToHttp } from './converter';
|
|
8
|
+
/**
|
|
9
|
+
* Start HTTP server for handler
|
|
10
|
+
*/
|
|
11
|
+
export async function startServer(handlerPath, options = {}) {
|
|
12
|
+
const port = options.port || 3000;
|
|
13
|
+
const host = options.host || 'localhost';
|
|
14
|
+
// Load handler or discover registry
|
|
15
|
+
let agents = {};
|
|
16
|
+
let tools = {};
|
|
17
|
+
let prompts = {};
|
|
18
|
+
if (isFile(handlerPath)) {
|
|
19
|
+
// Single file handler
|
|
20
|
+
const loaded = await loadHandler(handlerPath);
|
|
21
|
+
agents = loaded.agents || {};
|
|
22
|
+
tools = loaded.tools || {};
|
|
23
|
+
prompts = loaded.prompts || {};
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
// Directory - auto-discover
|
|
27
|
+
const registry = await discoverRegistry(handlerPath);
|
|
28
|
+
agents = registry.agents;
|
|
29
|
+
tools = registry.tools;
|
|
30
|
+
prompts = registry.prompts;
|
|
31
|
+
}
|
|
32
|
+
// Create HTTP server
|
|
33
|
+
const server = createServer(async (req, res) => {
|
|
34
|
+
try {
|
|
35
|
+
// Set CORS headers
|
|
36
|
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
37
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
|
38
|
+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
|
|
39
|
+
// Handle OPTIONS request
|
|
40
|
+
if (req.method === 'OPTIONS') {
|
|
41
|
+
res.writeHead(200);
|
|
42
|
+
res.end();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
// Parse URL to determine route
|
|
46
|
+
const url = new URL(req.url || '/', `http://${req.headers.host || 'localhost'}`);
|
|
47
|
+
const pathParts = url.pathname.split('/').filter(Boolean);
|
|
48
|
+
// Route: /agents/:agentId/invoke
|
|
49
|
+
if (pathParts[0] === 'agents' && pathParts[2] === 'invoke') {
|
|
50
|
+
const agentId = pathParts[1];
|
|
51
|
+
const agent = agents[agentId];
|
|
52
|
+
if (!agent) {
|
|
53
|
+
res.writeHead(404, { 'Content-Type': 'application/json' });
|
|
54
|
+
res.end(JSON.stringify({ error: `Agent not found: ${agentId}` }));
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
// Get context (provided by orchestrator or default)
|
|
58
|
+
const context = options.context ? await options.context(req) : createDefaultContext(req);
|
|
59
|
+
// Convert HTTP request to handler request
|
|
60
|
+
const handlerReq = await convertHttpToRequest(req);
|
|
61
|
+
// Call agent handler
|
|
62
|
+
const handlerRes = await agent(context, handlerReq);
|
|
63
|
+
// Convert handler response to HTTP response
|
|
64
|
+
convertResponseToHttp(handlerRes, res);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
// Route: /tools/:toolId/invoke
|
|
68
|
+
if (pathParts[0] === 'tools' && pathParts[2] === 'invoke') {
|
|
69
|
+
const toolId = pathParts[1];
|
|
70
|
+
const tool = tools[toolId];
|
|
71
|
+
if (!tool) {
|
|
72
|
+
res.writeHead(404, { 'Content-Type': 'application/json' });
|
|
73
|
+
res.end(JSON.stringify({ error: `Tool not found: ${toolId}` }));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
// Get context
|
|
77
|
+
const context = options.context ? await options.context(req) : createDefaultContext(req);
|
|
78
|
+
// Convert HTTP request to handler request
|
|
79
|
+
const handlerReq = await convertHttpToRequest(req);
|
|
80
|
+
// Call tool handler
|
|
81
|
+
const handlerRes = await tool(context, handlerReq);
|
|
82
|
+
// Convert handler response to HTTP response
|
|
83
|
+
convertResponseToHttp(handlerRes, res);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
// Route: /health (health check)
|
|
87
|
+
if (pathParts[0] === 'health' || url.pathname === '/') {
|
|
88
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
89
|
+
res.end(JSON.stringify({
|
|
90
|
+
status: 'ok',
|
|
91
|
+
agents: Object.keys(agents),
|
|
92
|
+
tools: Object.keys(tools),
|
|
93
|
+
prompts: Object.keys(prompts),
|
|
94
|
+
}));
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// 404 for unknown routes
|
|
98
|
+
res.writeHead(404, { 'Content-Type': 'application/json' });
|
|
99
|
+
res.end(JSON.stringify({ error: 'Not found' }));
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
convertErrorToHttp(error, res);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
// Start server
|
|
106
|
+
server.listen(port, host, () => {
|
|
107
|
+
console.log(`Reminix HTTP adapter listening on http://${host}:${port}`);
|
|
108
|
+
console.log(`Agents: ${Object.keys(agents).join(', ') || 'none'}`);
|
|
109
|
+
console.log(`Tools: ${Object.keys(tools).join(', ') || 'none'}`);
|
|
110
|
+
});
|
|
111
|
+
// Handle server errors
|
|
112
|
+
server.on('error', (error) => {
|
|
113
|
+
console.error('Server error:', error);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Create default context (for development)
|
|
118
|
+
* In production, this would come from the orchestrator
|
|
119
|
+
*/
|
|
120
|
+
function createDefaultContext(req) {
|
|
121
|
+
// Extract chatId from headers or query params
|
|
122
|
+
const chatId = req.headers['x-chat-id'] ||
|
|
123
|
+
new URL(req.url || '/', `http://${req.headers.host || 'localhost'}`).searchParams.get('chatId') ||
|
|
124
|
+
'default-chat';
|
|
125
|
+
// Return a minimal context (orchestrator will provide full context in production)
|
|
126
|
+
return {
|
|
127
|
+
chatId: chatId,
|
|
128
|
+
memory: createMockMemoryStore(),
|
|
129
|
+
knowledgeBase: createMockKnowledgeBase(),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Mock memory store for development
|
|
134
|
+
*/
|
|
135
|
+
function createMockMemoryStore() {
|
|
136
|
+
const store = new Map();
|
|
137
|
+
return {
|
|
138
|
+
get: async (key) => store.get(key),
|
|
139
|
+
set: async (key, value) => {
|
|
140
|
+
store.set(key, value);
|
|
141
|
+
},
|
|
142
|
+
delete: async (key) => {
|
|
143
|
+
store.delete(key);
|
|
144
|
+
},
|
|
145
|
+
clear: async () => {
|
|
146
|
+
store.clear();
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Mock knowledge base for development
|
|
152
|
+
*/
|
|
153
|
+
function createMockKnowledgeBase() {
|
|
154
|
+
return {
|
|
155
|
+
search: async (_query) => [],
|
|
156
|
+
add: async (_content) => { },
|
|
157
|
+
delete: async (_id) => { },
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAmC,MAAM,MAAM,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAS9F;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,WAAmB,EAAE,UAAyB,EAAE;IAChF,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC;IAClC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,WAAW,CAAC;IAEzC,oCAAoC;IACpC,IAAI,MAAM,GAAiC,EAAE,CAAC;IAC9C,IAAI,KAAK,GAAgC,EAAE,CAAC;IAC5C,IAAI,OAAO,GAA4B,EAAE,CAAC;IAE1C,IAAI,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;QACxB,sBAAsB;QACtB,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,WAAW,CAAC,CAAC;QAC9C,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC;QAC7B,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC;QAC3B,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;IACjC,CAAC;SAAM,CAAC;QACN,4BAA4B;QAC5B,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC,WAAW,CAAC,CAAC;QACrD,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;QACzB,KAAK,GAAG,QAAQ,CAAC,KAAK,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AW,EAAE,EAAE;YAC5B,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACpB,CAAC;QACD,KAAK,EAAE,KAAK,IAAI,EAAE;YAChB,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,uBAAuB;IAC9B,OAAO;QACL,MAAM,EAAE,KAAK,EAAE,MAAc,EAAE,EAAE,CAAC,EAAE;QACpC,GAAG,EAAE,KAAK,EAAE,QAAgB,EAAE,EAAE,GAAE,CAAC;QACnC,MAAM,EAAE,KAAK,EAAE,GAAW,EAAE,EAAE,GAAE,CAAC;KAClC,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@reminix/http-adapter",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Reminix HTTP adapter for running handlers",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"reminix-http-adapter": "./dist/cli.js"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"keywords": [
|
|
22
|
+
"reminix",
|
|
23
|
+
"adapter",
|
|
24
|
+
"http",
|
|
25
|
+
"handler"
|
|
26
|
+
],
|
|
27
|
+
"author": "Reminix <support@reminix.com>",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/reminix-ai/reminix-typescript.git",
|
|
32
|
+
"directory": "packages/http-adapter"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/reminix-ai/reminix-typescript",
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@reminix/sdk": "0.1.1"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/node": "^25.0.3",
|
|
40
|
+
"vitest": "^4.0.16",
|
|
41
|
+
"tsd": "^0.33.0"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsc",
|
|
48
|
+
"clean": "rm -rf dist",
|
|
49
|
+
"test": "vitest run",
|
|
50
|
+
"test:watch": "vitest",
|
|
51
|
+
"lint": "eslint src"
|
|
52
|
+
}
|
|
53
|
+
}
|