@reminix/http-adapter 0.1.6 → 0.3.0

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
@@ -19,7 +19,7 @@ yarn add @reminix/http-adapter
19
19
  Create a file `my-handler.ts`:
20
20
 
21
21
  ```typescript
22
- import type { AgentHandler, Context, Request, Response } from '@reminix/sdk';
22
+ import type { AgentHandler, Context, Request, Response } from '@reminix/runtime';
23
23
 
24
24
  export const agents = {
25
25
  chatbot: async (context: Context, request: Request): Promise<Response> => {
@@ -196,7 +196,7 @@ Content-Type: application/json
196
196
  Handlers receive a `Context` and `Request`, and return a `Response`:
197
197
 
198
198
  ```typescript
199
- import type { AgentHandler, Context, Request, Response } from '@reminix/sdk';
199
+ import type { AgentHandler, Context, Request, Response } from '@reminix/runtime';
200
200
 
201
201
  const myAgent: AgentHandler = async (context: Context, request: Request): Promise<Response> => {
202
202
  // Access context
@@ -224,13 +224,6 @@ const myAgent: AgentHandler = async (context: Context, request: Request): Promis
224
224
  };
225
225
  ```
226
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
227
  ## API Reference
235
228
 
236
229
  ### `startServer(handlerPath, options?)`
@@ -300,4 +293,3 @@ MIT
300
293
 
301
294
  - [GitHub Repository](https://github.com/reminix-ai/reminix-typescript)
302
295
  - [Documentation](https://docs.reminix.com)
303
- - [Examples](./examples/)
package/dist/cli.js CHANGED
@@ -5,7 +5,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
5
5
  // src/server.ts
6
6
  import { createServer } from "http";
7
7
 
8
- // src/loader.ts
8
+ // ../runtime/dist/loader.js
9
9
  import { pathToFileURL } from "url";
10
10
  import { statSync } from "fs";
11
11
  async function loadHandler(handlerPath) {
@@ -23,9 +23,7 @@ async function loadHandler(handlerPath) {
23
23
  loaded.prompts = module.prompts;
24
24
  }
25
25
  if (!loaded.agents && !loaded.tools && !loaded.prompts) {
26
- throw new Error(
27
- `Handler file "${handlerPath}" must export at least one of: agents, tools, or prompts`
28
- );
26
+ throw new Error(`Handler file "${handlerPath}" must export at least one of: agents, tools, or prompts`);
29
27
  }
30
28
  return loaded;
31
29
  } catch (error) {
@@ -46,7 +44,7 @@ function isFile(path) {
46
44
  }
47
45
  __name(isFile, "isFile");
48
46
 
49
- // src/registry.ts
47
+ // ../runtime/dist/registry.js
50
48
  import { readdir, stat } from "fs/promises";
51
49
  import { join, extname, basename } from "path";
52
50
  import { pathToFileURL as pathToFileURL2 } from "url";
@@ -175,9 +173,7 @@ async function loadDirectory(dirPath) {
175
173
  if (exportedValue !== void 0) {
176
174
  handlers[key] = exportedValue;
177
175
  } else {
178
- const moduleKeys = Object.keys(module).filter(
179
- (k) => k !== "default" && !k.startsWith("__")
180
- );
176
+ const moduleKeys = Object.keys(module).filter((k) => k !== "default" && !k.startsWith("__"));
181
177
  if (moduleKeys.length > 0) {
182
178
  handlers[key] = module[moduleKeys[0]] || module;
183
179
  }
@@ -198,6 +194,12 @@ async function loadDirectory(dirPath) {
198
194
  }
199
195
  __name(loadDirectory, "loadDirectory");
200
196
 
197
+ // ../runtime/dist/executor.js
198
+ async function executeHandler(handler, context, request) {
199
+ return await handler(context, request);
200
+ }
201
+ __name(executeHandler, "executeHandler");
202
+
201
203
  // src/converter.ts
202
204
  async function convertHttpToRequest(httpReq) {
203
205
  try {
@@ -344,7 +346,7 @@ async function startServer(handlerPath, options = {}) {
344
346
  }
345
347
  const context = options.context ? await options.context(req) : createDefaultContext(req);
346
348
  const handlerReq = await convertHttpToRequest(req);
347
- const handlerRes = await agent(context, handlerReq);
349
+ const handlerRes = await executeHandler(agent, context, handlerReq);
348
350
  convertResponseToHttp(handlerRes, res);
349
351
  return;
350
352
  }
@@ -358,7 +360,7 @@ async function startServer(handlerPath, options = {}) {
358
360
  }
359
361
  const context = options.context ? await options.context(req) : createDefaultContext(req);
360
362
  const handlerReq = await convertHttpToRequest(req);
361
- const handlerRes = await tool(context, handlerReq);
363
+ const handlerRes = await executeHandler(tool, context, handlerReq);
362
364
  convertResponseToHttp(handlerRes, res);
363
365
  return;
364
366
  }
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server.ts","../src/loader.ts","../src/registry.ts","../src/converter.ts","../src/cli.ts"],"sourcesContent":["/**\n * HTTP server for Reminix handlers\n */\n\nimport { createServer, IncomingMessage, ServerResponse } from 'http';\nimport { loadHandler, isFile } from './loader';\nimport { discoverRegistry } from './registry';\nimport { convertHttpToRequest, convertResponseToHttp, convertErrorToHttp } from './converter';\nimport type { Context, AgentHandler, ToolHandler } from '@reminix/sdk';\n\nexport interface ServerOptions {\n port?: number;\n host?: string;\n context?: (req: IncomingMessage) => Promise<Context> | Context;\n}\n\n/**\n * Start HTTP server for handler\n */\nexport async function startServer(handlerPath: string, options: ServerOptions = {}): Promise<void> {\n const port = options.port || 3000;\n const host = options.host || 'localhost';\n\n // Load handler or discover registry\n let agents: Record<string, AgentHandler> = {};\n let tools: Record<string, ToolHandler> = {};\n let prompts: Record<string, unknown> = {};\n\n if (isFile(handlerPath)) {\n // Single file handler\n const loaded = await loadHandler(handlerPath);\n agents = loaded.agents || {};\n tools = loaded.tools || {};\n prompts = loaded.prompts || {};\n } else {\n // Directory - auto-discover\n const registry = await discoverRegistry(handlerPath);\n agents = registry.agents;\n tools = registry.tools;\n prompts = registry.prompts;\n }\n\n // Create HTTP server\n const server = createServer(async (req: IncomingMessage, res: ServerResponse) => {\n try {\n // Set CORS headers\n res.setHeader('Access-Control-Allow-Origin', '*');\n res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');\n res.setHeader('Access-Control-Allow-Headers', 'Content-Type');\n\n // Handle OPTIONS request\n if (req.method === 'OPTIONS') {\n res.writeHead(200);\n res.end();\n return;\n }\n\n // Parse URL to determine route\n const url = new URL(req.url || '/', `http://${req.headers.host || 'localhost'}`);\n const pathParts = url.pathname.split('/').filter(Boolean);\n\n // Route: /agents/:agentId/invoke\n if (pathParts[0] === 'agents' && pathParts[2] === 'invoke') {\n const agentId = pathParts[1];\n const agent = agents[agentId];\n\n if (!agent) {\n res.writeHead(404, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify({ error: `Agent not found: ${agentId}` }));\n return;\n }\n\n // Get context (provided by orchestrator or default)\n const context = options.context ? await options.context(req) : createDefaultContext(req);\n\n // Convert HTTP request to handler request\n const handlerReq = await convertHttpToRequest(req);\n\n // Call agent handler\n const handlerRes = await agent(context, handlerReq);\n\n // Convert handler response to HTTP response\n convertResponseToHttp(handlerRes, res);\n return;\n }\n\n // Route: /tools/:toolId/invoke\n if (pathParts[0] === 'tools' && pathParts[2] === 'invoke') {\n const toolId = pathParts[1];\n const tool = tools[toolId];\n\n if (!tool) {\n res.writeHead(404, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify({ error: `Tool not found: ${toolId}` }));\n return;\n }\n\n // Get context\n const context = options.context ? await options.context(req) : createDefaultContext(req);\n\n // Convert HTTP request to handler request\n const handlerReq = await convertHttpToRequest(req);\n\n // Call tool handler\n const handlerRes = await tool(context, handlerReq);\n\n // Convert handler response to HTTP response\n convertResponseToHttp(handlerRes, res);\n return;\n }\n\n // Route: /health (health check)\n if (pathParts[0] === 'health' || url.pathname === '/') {\n res.writeHead(200, { 'Content-Type': 'application/json' });\n res.end(\n JSON.stringify({\n status: 'ok',\n agents: Object.keys(agents),\n tools: Object.keys(tools),\n prompts: Object.keys(prompts),\n })\n );\n return;\n }\n\n // 404 for unknown routes\n res.writeHead(404, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify({ error: 'Not found' }));\n } catch (error) {\n convertErrorToHttp(error as Error, res);\n }\n });\n\n // Start server\n server.listen(port, host, () => {\n console.log(`Reminix HTTP adapter listening on http://${host}:${port}`);\n console.log(`Agents: ${Object.keys(agents).join(', ') || 'none'}`);\n console.log(`Tools: ${Object.keys(tools).join(', ') || 'none'}`);\n });\n\n // Handle server errors\n server.on('error', (error: Error) => {\n console.error('Server error:', error);\n });\n}\n\n/**\n * Create default context (for development)\n * In production, this would come from the orchestrator\n */\nfunction createDefaultContext(req: IncomingMessage): Context {\n // Extract chatId from headers or query params\n const chatId =\n req.headers['x-chat-id'] ||\n new URL(req.url || '/', `http://${req.headers.host || 'localhost'}`).searchParams.get(\n 'chatId'\n ) ||\n 'default-chat';\n\n // Return a minimal context (orchestrator will provide full context in production)\n return {\n chatId: chatId as string,\n memory: createMockMemoryStore(),\n knowledgeBase: createMockKnowledgeBase(),\n } as Context;\n}\n\n/**\n * Mock memory store for development\n */\nfunction createMockMemoryStore() {\n const store = new Map<string, unknown>();\n return {\n get: async (key: string) => store.get(key),\n set: async (key: string, value: unknown) => {\n store.set(key, value);\n },\n delete: async (key: string) => {\n store.delete(key);\n },\n clear: async () => {\n store.clear();\n },\n };\n}\n\n/**\n * Mock knowledge base for development\n */\nfunction createMockKnowledgeBase() {\n return {\n search: async (_query: string) => [],\n add: async (_content: string) => {},\n delete: async (_id: string) => {},\n };\n}\n","/**\n * Load handler from file\n */\n\nimport { pathToFileURL } from 'url';\nimport { statSync } from 'fs';\nimport type { AgentHandler, ToolHandler } from '@reminix/sdk';\n\nexport interface LoadedHandler {\n agents?: Record<string, AgentHandler>;\n tools?: Record<string, ToolHandler>;\n prompts?: Record<string, unknown>;\n}\n\n/**\n * Load handler from a file path\n * Supports both TypeScript (.ts) and JavaScript (.js) files\n */\nexport async function loadHandler(handlerPath: string): Promise<LoadedHandler> {\n try {\n // Convert file path to file URL for ES modules\n const fileUrl = pathToFileURL(handlerPath).href;\n\n // Dynamic import of the handler module\n const module = await import(fileUrl);\n\n // Extract agents, tools, and prompts\n const loaded: LoadedHandler = {};\n\n if (module.agents) {\n loaded.agents = module.agents;\n }\n\n if (module.tools) {\n loaded.tools = module.tools;\n }\n\n if (module.prompts) {\n loaded.prompts = module.prompts;\n }\n\n // Validate that at least one export exists\n if (!loaded.agents && !loaded.tools && !loaded.prompts) {\n throw new Error(\n `Handler file \"${handlerPath}\" must export at least one of: agents, tools, or prompts`\n );\n }\n\n return loaded;\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Failed to load handler from \"${handlerPath}\": ${error.message}`);\n }\n throw error;\n }\n}\n\n/**\n * Check if a path is a file (not a directory)\n */\nexport function isFile(path: string): boolean {\n try {\n const stats = statSync(path);\n return stats.isFile();\n } catch {\n return false;\n }\n}\n","/**\n * Registry for auto-discovering agents, tools, and prompts from directories\n */\n\nimport { readdir, stat } from 'fs/promises';\nimport { join, extname, basename } from 'path';\nimport { pathToFileURL } from 'url';\nimport { loadHandler } from './loader';\nimport type { AgentHandler, ToolHandler } from '@reminix/sdk';\n\nexport interface Registry {\n agents: Record<string, AgentHandler>;\n tools: Record<string, ToolHandler>;\n prompts: Record<string, unknown>;\n}\n\n/**\n * Auto-discover and load handlers from a directory structure\n *\n * Expected structure:\n * handler/\n * agents/\n * chatbot.ts\n * assistant.ts\n * tools/\n * search.ts\n * prompts/\n * system.ts\n */\nexport async function discoverRegistry(handlerPath: string): Promise<Registry> {\n const registry: Registry = {\n agents: {},\n tools: {},\n prompts: {},\n };\n\n try {\n // Check if path exists and is a directory\n const stats = await stat(handlerPath);\n if (!stats.isDirectory()) {\n throw new Error(`Handler path must be a directory: ${handlerPath}`);\n }\n\n // Discover agents\n const agentsPath = join(handlerPath, 'agents');\n try {\n const agentsStats = await stat(agentsPath);\n if (agentsStats.isDirectory()) {\n const agents = await loadDirectory(agentsPath);\n // Filter to only AgentHandler types\n for (const [key, value] of Object.entries(agents)) {\n if (typeof value === 'function') {\n registry.agents[key] = value as AgentHandler;\n }\n }\n }\n } catch {\n // agents/ directory doesn't exist, skip\n }\n\n // Discover tools\n const toolsPath = join(handlerPath, 'tools');\n try {\n const toolsStats = await stat(toolsPath);\n if (toolsStats.isDirectory()) {\n const tools = await loadDirectory(toolsPath);\n // Filter to only ToolHandler types\n for (const [key, value] of Object.entries(tools)) {\n if (typeof value === 'function') {\n registry.tools[key] = value as ToolHandler;\n }\n }\n }\n } catch {\n // tools/ directory doesn't exist, skip\n }\n\n // Discover prompts\n const promptsPath = join(handlerPath, 'prompts');\n try {\n const promptsStats = await stat(promptsPath);\n if (promptsStats.isDirectory()) {\n const prompts = await loadDirectory(promptsPath);\n registry.prompts = prompts;\n }\n } catch {\n // prompts/ directory doesn't exist, skip\n }\n\n // Validate that at least something was discovered\n if (\n Object.keys(registry.agents).length === 0 &&\n Object.keys(registry.tools).length === 0 &&\n Object.keys(registry.prompts).length === 0\n ) {\n throw new Error(`No agents, tools, or prompts found in directory: ${handlerPath}`);\n }\n\n return registry;\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Failed to discover registry from \"${handlerPath}\": ${error.message}`);\n }\n throw error;\n }\n}\n\n/**\n * Load all handler files from a directory\n * Filename (without extension) becomes the key in the registry\n */\nasync function loadDirectory(\n dirPath: string\n): Promise<Record<string, AgentHandler | ToolHandler | unknown>> {\n const handlers: Record<string, AgentHandler | ToolHandler | unknown> = {};\n\n try {\n const entries = await readdir(dirPath);\n\n for (const entry of entries) {\n const fullPath = join(dirPath, entry);\n const stats = await stat(fullPath);\n\n // Skip if not a file\n if (!stats.isFile()) {\n continue;\n }\n\n // Only process TypeScript/JavaScript files\n const ext = extname(entry);\n if (ext !== '.ts' && ext !== '.js' && ext !== '.mjs') {\n continue;\n }\n\n // Extract the key from filename (without extension)\n const key = entry.replace(ext, '');\n\n try {\n // Try loading as a handler file (expects agents/tools/prompts exports)\n const loaded = await loadHandler(fullPath);\n\n // Merge agents, tools, and prompts into the registry\n if (loaded.agents) {\n const agentKeys = Object.keys(loaded.agents);\n if (agentKeys.length === 1) {\n handlers[key] = loaded.agents[agentKeys[0]];\n } else {\n for (const agentKey of agentKeys) {\n handlers[`${key}.${agentKey}`] = loaded.agents[agentKey];\n }\n }\n }\n\n if (loaded.tools) {\n const toolKeys = Object.keys(loaded.tools);\n if (toolKeys.length === 1) {\n handlers[key] = loaded.tools[toolKeys[0]];\n } else {\n for (const toolKey of toolKeys) {\n handlers[`${key}.${toolKey}`] = loaded.tools[toolKey];\n }\n }\n }\n\n if (loaded.prompts) {\n const promptKeys = Object.keys(loaded.prompts);\n if (promptKeys.length === 1) {\n handlers[key] = loaded.prompts[promptKeys[0]];\n } else {\n for (const promptKey of promptKeys) {\n handlers[`${key}.${promptKey}`] = loaded.prompts[promptKey];\n }\n }\n }\n } catch {\n // If loadHandler fails, try loading as direct export\n // This handles files that export functions directly (e.g., export const chatbot)\n try {\n const fileUrl = pathToFileURL(fullPath).href;\n const module = await import(fileUrl);\n\n // Determine type based on directory name\n const dirName = basename(dirPath);\n\n // Check for direct exports matching the directory type\n if (dirName === 'agents') {\n // Look for exported function with same name as file, or any exported function\n const exportedFunction = module[key] || module.default;\n if (typeof exportedFunction === 'function') {\n handlers[key] = exportedFunction;\n }\n } else if (dirName === 'tools') {\n const exportedFunction = module[key] || module.default;\n if (typeof exportedFunction === 'function') {\n handlers[key] = exportedFunction;\n }\n } else if (dirName === 'prompts') {\n // For prompts, accept any export (function, object, string, etc.)\n // Try to get export with same name as file, or default, or any named export\n const exportedValue = module[key] || module.default;\n if (exportedValue !== undefined) {\n handlers[key] = exportedValue;\n } else {\n // Check if module has any exports (excluding default module properties)\n const moduleKeys = Object.keys(module).filter(\n (k) => k !== 'default' && !k.startsWith('__')\n );\n if (moduleKeys.length > 0) {\n // Use the first export, or the module itself if it's a simple object\n handlers[key] = module[moduleKeys[0]] || module;\n }\n }\n }\n } catch {\n // Skip this file if both methods fail\n continue;\n }\n }\n }\n\n return handlers;\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Failed to load directory \"${dirPath}\": ${error.message}`);\n }\n throw error;\n }\n}\n","/**\n * Convert between HTTP and Handler formats\n */\n\nimport type { IncomingMessage, ServerResponse } from 'http';\nimport type { Request as HandlerRequest, Response as HandlerResponse, Message } from '@reminix/sdk';\n\n/**\n * Convert HTTP request to Handler Request\n * Extracts messages from HTTP request body\n */\nexport async function convertHttpToRequest(httpReq: IncomingMessage): Promise<HandlerRequest> {\n try {\n // Read request body\n const body = await readRequestBody(httpReq);\n\n // Parse JSON body\n let parsedBody: Record<string, unknown> = {};\n if (body) {\n try {\n parsedBody = JSON.parse(body) as Record<string, unknown>;\n } catch {\n // If not JSON, treat as text\n parsedBody = { content: body };\n }\n }\n\n // Extract messages from body\n // Expected format: { messages: Message[] } or { message: Message } or just Message[]\n let messages: Message[] = [];\n\n if (Array.isArray(parsedBody)) {\n // Body is array of messages\n messages = parsedBody as Message[];\n } else if (parsedBody.messages && Array.isArray(parsedBody.messages)) {\n // Body has messages array\n messages = parsedBody.messages as Message[];\n } else if (parsedBody.message) {\n // Body has single message\n messages = [parsedBody.message as Message];\n } else if (parsedBody.content || parsedBody.role) {\n // Body is a single message object\n messages = [parsedBody as unknown as Message];\n }\n\n // Extract metadata from query params and headers\n const metadata: Record<string, unknown> = {\n method: httpReq.method,\n url: httpReq.url,\n headers: httpReq.headers,\n };\n\n // Add query params to metadata\n if (httpReq.url) {\n const url = new URL(httpReq.url, `http://${httpReq.headers.host || 'localhost'}`);\n const queryParams: Record<string, string> = {};\n url.searchParams.forEach((value, key) => {\n queryParams[key] = value;\n });\n if (Object.keys(queryParams).length > 0) {\n metadata.query = queryParams;\n }\n }\n\n // Merge any additional metadata from body\n if (parsedBody.metadata) {\n Object.assign(metadata, parsedBody.metadata);\n }\n\n return {\n messages,\n metadata,\n };\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Failed to convert HTTP request: ${error.message}`);\n }\n throw error;\n }\n}\n\n/**\n * Convert Handler Response to HTTP response\n */\nexport function convertResponseToHttp(handlerRes: HandlerResponse, httpRes: ServerResponse): void {\n try {\n // Set status code (default 200)\n const statusCode =\n typeof handlerRes.metadata?.statusCode === 'number' ? handlerRes.metadata.statusCode : 200;\n httpRes.statusCode = statusCode;\n\n // Set headers\n const headers =\n (handlerRes.metadata?.headers as Record<string, unknown> | undefined) ||\n ({} as Record<string, unknown>);\n headers['Content-Type'] =\n (typeof headers['Content-Type'] === 'string' ? headers['Content-Type'] : undefined) ||\n 'application/json';\n\n for (const [key, value] of Object.entries(headers)) {\n if (typeof value === 'string') {\n httpRes.setHeader(key, value);\n }\n }\n\n // Prepare response body\n const responseBody = {\n messages: handlerRes.messages,\n ...(handlerRes.metadata && { metadata: handlerRes.metadata }),\n ...(handlerRes.toolCalls && { toolCalls: handlerRes.toolCalls }),\n ...(handlerRes.stateUpdates && { stateUpdates: handlerRes.stateUpdates }),\n };\n\n // Send response\n httpRes.end(JSON.stringify(responseBody));\n } catch (error) {\n if (error instanceof Error) {\n httpRes.statusCode = 500;\n httpRes.setHeader('Content-Type', 'application/json');\n httpRes.end(JSON.stringify({ error: error.message }));\n }\n }\n}\n\n/**\n * Read request body from IncomingMessage\n */\nasync function readRequestBody(req: IncomingMessage): Promise<string> {\n return new Promise((resolve, reject) => {\n let body = '';\n\n req.on('data', (chunk) => {\n body += chunk.toString();\n });\n\n req.on('end', () => {\n resolve(body);\n });\n\n req.on('error', (error) => {\n reject(error);\n });\n });\n}\n\n/**\n * Convert error to HTTP error response\n */\nexport function convertErrorToHttp(error: Error, httpRes: ServerResponse): void {\n httpRes.statusCode = 500;\n httpRes.setHeader('Content-Type', 'application/json');\n httpRes.end(\n JSON.stringify({\n error: error.message,\n ...(process.env.NODE_ENV === 'development' && { stack: error.stack }),\n })\n );\n}\n","/**\n * CLI entry point for Reminix HTTP adapter\n *\n * Usage:\n * npx @reminix/http-adapter serve <handler-path> [options]\n * tsx src/cli.ts serve <handler-path> [options]\n */\n\nimport { startServer, type ServerOptions } from './server';\nimport { parseArgs } from 'util';\nimport { extname } from 'path';\n\n/**\n * Try to register tsx loader for TypeScript support\n * Uses dynamic import which respects Node's module resolution including global packages\n * Returns true if successful, false if tsx is not available\n */\nasync function tryRegisterTsx(): Promise<boolean> {\n try {\n // Use dynamic import to load tsx's ESM API which includes the register function\n // @ts-expect-error - tsx is a runtime dependency, not available at compile time\n const tsx = await import('tsx/esm/api');\n if (tsx && typeof tsx.register === 'function') {\n tsx.register();\n return true;\n }\n } catch {\n // tsx not available\n }\n return false;\n}\n\ninterface CliOptions {\n port?: number;\n host?: string;\n handlerPath: string;\n loader?: string;\n}\n\nfunction parseCliArgs(): CliOptions {\n const args = process.argv.slice(2);\n\n if (args.length === 0 || args[0] !== 'serve') {\n console.error('Usage: reminix-http-adapter serve <handler-path> [options]');\n console.error('');\n console.error('Options:');\n console.error(' --port <number> Port to listen on (default: 3000)');\n console.error(' --host <string> Host to listen on (default: localhost)');\n console.error(' --loader <name> Loader to use for TypeScript support (e.g., tsx)');\n console.error('');\n console.error('Examples:');\n console.error(' npx @reminix/http-adapter serve ./my-handler.ts');\n console.error(' npx @reminix/http-adapter serve ./my-handler.ts --loader tsx');\n console.error(' npx @reminix/http-adapter serve ./my-handler --port 8080');\n process.exit(1);\n }\n\n const handlerPath = args[1];\n if (!handlerPath) {\n console.error('Error: handler-path is required');\n process.exit(1);\n }\n\n const { values } = parseArgs({\n args: args.slice(2),\n options: {\n port: { type: 'string' },\n host: { type: 'string' },\n loader: { type: 'string' },\n },\n });\n\n const options: CliOptions = {\n handlerPath,\n port: values.port ? parseInt(values.port, 10) : undefined,\n host: values.host,\n loader: values.loader,\n };\n\n return options;\n}\n\nasync function main() {\n try {\n const options = parseCliArgs();\n\n // Check if TypeScript support is needed\n const ext = extname(options.handlerPath).toLowerCase();\n const isTypeScript = ext === '.ts' || ext === '.tsx';\n // For directories, we'll check later if they contain .ts files, but register tsx preemptively\n const isDirectory = !ext || ext === '';\n const needsTsx = options.loader === 'tsx' || isTypeScript || (isDirectory && !options.loader);\n\n // Register tsx loader if needed\n if (needsTsx) {\n const registered = await tryRegisterTsx();\n if (!registered) {\n console.error('Error: TypeScript support requires \"tsx\" to be installed.');\n console.error('');\n console.error('To install tsx:');\n console.error(' npm install -g tsx');\n console.error(' # or locally:');\n console.error(' npm install tsx');\n console.error('');\n console.error('Then run:');\n console.error(` npx @reminix/http-adapter serve ${options.handlerPath} --loader tsx`);\n console.error('');\n console.error('Alternatively, use Node.js with --import flag (Node 20.6+):');\n console.error(\n ` node --import tsx node_modules/@reminix/http-adapter/dist/cli.js serve ${options.handlerPath}`\n );\n process.exit(1);\n }\n }\n\n const serverOptions: ServerOptions = {\n port: options.port,\n host: options.host,\n };\n\n await startServer(options.handlerPath, serverOptions);\n } catch (error) {\n console.error('Error starting server:', error);\n process.exit(1);\n }\n}\n\n// Run if called directly\nmain();\n"],"mappings":";;;;;AAIA,SAAS,oBAAqD;;;ACA9D,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AAazB,eAAsB,YAAY,aAA6C;AAC7E,MAAI;AAEF,UAAM,UAAU,cAAc,WAAW,EAAE;AAG3C,UAAM,SAAS,MAAM,OAAO;AAG5B,UAAM,SAAwB,CAAC;AAE/B,QAAI,OAAO,QAAQ;AACjB,aAAO,SAAS,OAAO;AAAA,IACzB;AAEA,QAAI,OAAO,OAAO;AAChB,aAAO,QAAQ,OAAO;AAAA,IACxB;AAEA,QAAI,OAAO,SAAS;AAClB,aAAO,UAAU,OAAO;AAAA,IAC1B;AAGA,QAAI,CAAC,OAAO,UAAU,CAAC,OAAO,SAAS,CAAC,OAAO,SAAS;AACtD,YAAM,IAAI;AAAA,QACR,iBAAiB,WAAW;AAAA,MAC9B;AAAA,IACF;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,QAAI,iBAAiB,OAAO;AAC1B,YAAM,IAAI,MAAM,gCAAgC,WAAW,MAAM,MAAM,OAAO,EAAE;AAAA,IAClF;AACA,UAAM;AAAA,EACR;AACF;AArCsB;AA0Cf,SAAS,OAAO,MAAuB;AAC5C,MAAI;AACF,UAAM,QAAQ,SAAS,IAAI;AAC3B,WAAO,MAAM,OAAO;AAAA,EACtB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAPgB;;;ACxDhB,SAAS,SAAS,YAAY;AAC9B,S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,gBAA+B;AAAA,MACnC,MAAM,QAAQ;AAAA,MACd,MAAM,QAAQ;AAAA,IAChB;AAEA,UAAM,YAAY,QAAQ,aAAa,aAAa;AAAA,EACtD,SAAS,OAAO;AACd,YAAQ,MAAM,0BAA0B,KAAK;AAC7C,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AA3Ce;AA8Cf,KAAK;","names":["pathToFileURL","pathToFileURL","extname","extname"]}
1
+ {"version":3,"sources":["../src/server.ts","../../runtime/src/loader.ts","../../runtime/src/registry.ts","../../runtime/src/executor.ts","../src/converter.ts","../src/cli.ts"],"sourcesContent":["/**\n * HTTP server for Reminix handlers\n */\n\nimport { createServer, IncomingMessage, ServerResponse } from 'http';\nimport { loadHandler, isFile, discoverRegistry, executeHandler } from '@reminix/runtime';\nimport { convertHttpToRequest, convertResponseToHttp, convertErrorToHttp } from './converter';\nimport type { Context, AgentHandler, ToolHandler } from '@reminix/runtime';\n\nexport interface ServerOptions {\n port?: number;\n host?: string;\n context?: (req: IncomingMessage) => Promise<Context> | Context;\n}\n\n/**\n * Start HTTP server for handler\n */\nexport async function startServer(handlerPath: string, options: ServerOptions = {}): Promise<void> {\n const port = options.port || 3000;\n const host = options.host || 'localhost';\n\n // Load handler or discover registry\n let agents: Record<string, AgentHandler> = {};\n let tools: Record<string, ToolHandler> = {};\n let prompts: Record<string, unknown> = {};\n\n if (isFile(handlerPath)) {\n // Single file handler\n const loaded = await loadHandler(handlerPath);\n agents = loaded.agents || {};\n tools = loaded.tools || {};\n prompts = loaded.prompts || {};\n } else {\n // Directory - auto-discover\n const registry = await discoverRegistry(handlerPath);\n agents = registry.agents;\n tools = registry.tools;\n prompts = registry.prompts;\n }\n\n // Create HTTP server\n const server = createServer(async (req: IncomingMessage, res: ServerResponse) => {\n try {\n // Set CORS headers\n res.setHeader('Access-Control-Allow-Origin', '*');\n res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');\n res.setHeader('Access-Control-Allow-Headers', 'Content-Type');\n\n // Handle OPTIONS request\n if (req.method === 'OPTIONS') {\n res.writeHead(200);\n res.end();\n return;\n }\n\n // Parse URL to determine route\n const url = new URL(req.url || '/', `http://${req.headers.host || 'localhost'}`);\n const pathParts = url.pathname.split('/').filter(Boolean);\n\n // Route: /agents/:agentId/invoke\n if (pathParts[0] === 'agents' && pathParts[2] === 'invoke') {\n const agentId = pathParts[1];\n const agent = agents[agentId];\n\n if (!agent) {\n res.writeHead(404, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify({ error: `Agent not found: ${agentId}` }));\n return;\n }\n\n // Get context (provided by orchestrator or default)\n const context = options.context ? await options.context(req) : createDefaultContext(req);\n\n // Convert HTTP request to handler request\n const handlerReq = await convertHttpToRequest(req);\n\n // Execute agent handler\n const handlerRes = await executeHandler(agent, context, handlerReq);\n\n // Convert handler response to HTTP response\n convertResponseToHttp(handlerRes, res);\n return;\n }\n\n // Route: /tools/:toolId/invoke\n if (pathParts[0] === 'tools' && pathParts[2] === 'invoke') {\n const toolId = pathParts[1];\n const tool = tools[toolId];\n\n if (!tool) {\n res.writeHead(404, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify({ error: `Tool not found: ${toolId}` }));\n return;\n }\n\n // Get context\n const context = options.context ? await options.context(req) : createDefaultContext(req);\n\n // Convert HTTP request to handler request\n const handlerReq = await convertHttpToRequest(req);\n\n // Execute tool handler\n const handlerRes = await executeHandler(tool, context, handlerReq);\n\n // Convert handler response to HTTP response\n convertResponseToHttp(handlerRes, res);\n return;\n }\n\n // Route: /health (health check)\n if (pathParts[0] === 'health' || url.pathname === '/') {\n res.writeHead(200, { 'Content-Type': 'application/json' });\n res.end(\n JSON.stringify({\n status: 'ok',\n agents: Object.keys(agents),\n tools: Object.keys(tools),\n prompts: Object.keys(prompts),\n })\n );\n return;\n }\n\n // 404 for unknown routes\n res.writeHead(404, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify({ error: 'Not found' }));\n } catch (error) {\n convertErrorToHttp(error as Error, res);\n }\n });\n\n // Start server\n server.listen(port, host, () => {\n console.log(`Reminix HTTP adapter listening on http://${host}:${port}`);\n console.log(`Agents: ${Object.keys(agents).join(', ') || 'none'}`);\n console.log(`Tools: ${Object.keys(tools).join(', ') || 'none'}`);\n });\n\n // Handle server errors\n server.on('error', (error: Error) => {\n console.error('Server error:', error);\n });\n}\n\n/**\n * Create default context (for development)\n * In production, this would come from the orchestrator\n */\nfunction createDefaultContext(req: IncomingMessage): Context {\n // Extract chatId from headers or query params\n const chatId =\n req.headers['x-chat-id'] ||\n new URL(req.url || '/', `http://${req.headers.host || 'localhost'}`).searchParams.get(\n 'chatId'\n ) ||\n 'default-chat';\n\n // Return a minimal context (orchestrator will provide full context in production)\n return {\n chatId: chatId as string,\n memory: createMockMemoryStore(),\n knowledgeBase: createMockKnowledgeBase(),\n } as Context;\n}\n\n/**\n * Mock memory store for development\n */\nfunction createMockMemoryStore() {\n const store = new Map<string, unknown>();\n return {\n get: async (key: string) => store.get(key),\n set: async (key: string, value: unknown) => {\n store.set(key, value);\n },\n delete: async (key: string) => {\n store.delete(key);\n },\n clear: async () => {\n store.clear();\n },\n };\n}\n\n/**\n * Mock knowledge base for development\n */\nfunction createMockKnowledgeBase() {\n return {\n search: async (_query: string) => [],\n add: async (_content: string) => {},\n delete: async (_id: string) => {},\n };\n}\n","/**\n * Load handler from file\n */\n\nimport { pathToFileURL } from 'url';\nimport { statSync } from 'fs';\nimport type { AgentHandler, ToolHandler } from './types';\n\nexport interface LoadedHandler {\n agents?: Record<string, AgentHandler>;\n tools?: Record<string, ToolHandler>;\n prompts?: Record<string, unknown>;\n}\n\n/**\n * Load handler from a file path\n * Supports both TypeScript (.ts) and JavaScript (.js) files\n */\nexport async function loadHandler(handlerPath: string): Promise<LoadedHandler> {\n try {\n // Convert file path to file URL for ES modules\n const fileUrl = pathToFileURL(handlerPath).href;\n\n // Dynamic import of the handler module\n const module = await import(fileUrl);\n\n // Extract agents, tools, and prompts\n const loaded: LoadedHandler = {};\n\n if (module.agents) {\n loaded.agents = module.agents;\n }\n\n if (module.tools) {\n loaded.tools = module.tools;\n }\n\n if (module.prompts) {\n loaded.prompts = module.prompts;\n }\n\n // Validate that at least one export exists\n if (!loaded.agents && !loaded.tools && !loaded.prompts) {\n throw new Error(\n `Handler file \"${handlerPath}\" must export at least one of: agents, tools, or prompts`\n );\n }\n\n return loaded;\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Failed to load handler from \"${handlerPath}\": ${error.message}`);\n }\n throw error;\n }\n}\n\n/**\n * Check if a path is a file (not a directory)\n */\nexport function isFile(path: string): boolean {\n try {\n const stats = statSync(path);\n return stats.isFile();\n } catch {\n return false;\n }\n}\n","/**\n * Registry for auto-discovering agents, tools, and prompts from directories\n */\n\nimport { readdir, stat } from 'fs/promises';\nimport { join, extname, basename } from 'path';\nimport { pathToFileURL } from 'url';\nimport { loadHandler } from './loader';\nimport type { AgentHandler, ToolHandler } from './types';\n\nexport interface Registry {\n agents: Record<string, AgentHandler>;\n tools: Record<string, ToolHandler>;\n prompts: Record<string, unknown>;\n}\n\n/**\n * Auto-discover and load handlers from a directory structure\n *\n * Expected structure:\n * handler/\n * agents/\n * chatbot.ts\n * assistant.ts\n * tools/\n * search.ts\n * prompts/\n * system.ts\n */\nexport async function discoverRegistry(handlerPath: string): Promise<Registry> {\n const registry: Registry = {\n agents: {},\n tools: {},\n prompts: {},\n };\n\n try {\n // Check if path exists and is a directory\n const stats = await stat(handlerPath);\n if (!stats.isDirectory()) {\n throw new Error(`Handler path must be a directory: ${handlerPath}`);\n }\n\n // Discover agents\n const agentsPath = join(handlerPath, 'agents');\n try {\n const agentsStats = await stat(agentsPath);\n if (agentsStats.isDirectory()) {\n const agents = await loadDirectory(agentsPath);\n // Filter to only AgentHandler types\n for (const [key, value] of Object.entries(agents)) {\n if (typeof value === 'function') {\n registry.agents[key] = value as AgentHandler;\n }\n }\n }\n } catch {\n // agents/ directory doesn't exist, skip\n }\n\n // Discover tools\n const toolsPath = join(handlerPath, 'tools');\n try {\n const toolsStats = await stat(toolsPath);\n if (toolsStats.isDirectory()) {\n const tools = await loadDirectory(toolsPath);\n // Filter to only ToolHandler types\n for (const [key, value] of Object.entries(tools)) {\n if (typeof value === 'function') {\n registry.tools[key] = value as ToolHandler;\n }\n }\n }\n } catch {\n // tools/ directory doesn't exist, skip\n }\n\n // Discover prompts\n const promptsPath = join(handlerPath, 'prompts');\n try {\n const promptsStats = await stat(promptsPath);\n if (promptsStats.isDirectory()) {\n const prompts = await loadDirectory(promptsPath);\n registry.prompts = prompts;\n }\n } catch {\n // prompts/ directory doesn't exist, skip\n }\n\n // Validate that at least something was discovered\n if (\n Object.keys(registry.agents).length === 0 &&\n Object.keys(registry.tools).length === 0 &&\n Object.keys(registry.prompts).length === 0\n ) {\n throw new Error(`No agents, tools, or prompts found in directory: ${handlerPath}`);\n }\n\n return registry;\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Failed to discover registry from \"${handlerPath}\": ${error.message}`);\n }\n throw error;\n }\n}\n\n/**\n * Load all handler files from a directory\n * Filename (without extension) becomes the key in the registry\n */\nasync function loadDirectory(\n dirPath: string\n): Promise<Record<string, AgentHandler | ToolHandler | unknown>> {\n const handlers: Record<string, AgentHandler | ToolHandler | unknown> = {};\n\n try {\n const entries = await readdir(dirPath);\n\n for (const entry of entries) {\n const fullPath = join(dirPath, entry);\n const stats = await stat(fullPath);\n\n // Skip if not a file\n if (!stats.isFile()) {\n continue;\n }\n\n // Only process TypeScript/JavaScript files\n const ext = extname(entry);\n if (ext !== '.ts' && ext !== '.js' && ext !== '.mjs') {\n continue;\n }\n\n // Extract the key from filename (without extension)\n const key = entry.replace(ext, '');\n\n try {\n // Try loading as a handler file (expects agents/tools/prompts exports)\n const loaded = await loadHandler(fullPath);\n\n // Merge agents, tools, and prompts into the registry\n if (loaded.agents) {\n const agentKeys = Object.keys(loaded.agents);\n if (agentKeys.length === 1) {\n handlers[key] = loaded.agents[agentKeys[0]];\n } else {\n for (const agentKey of agentKeys) {\n handlers[`${key}.${agentKey}`] = loaded.agents[agentKey];\n }\n }\n }\n\n if (loaded.tools) {\n const toolKeys = Object.keys(loaded.tools);\n if (toolKeys.length === 1) {\n handlers[key] = loaded.tools[toolKeys[0]];\n } else {\n for (const toolKey of toolKeys) {\n handlers[`${key}.${toolKey}`] = loaded.tools[toolKey];\n }\n }\n }\n\n if (loaded.prompts) {\n const promptKeys = Object.keys(loaded.prompts);\n if (promptKeys.length === 1) {\n handlers[key] = loaded.prompts[promptKeys[0]];\n } else {\n for (const promptKey of promptKeys) {\n handlers[`${key}.${promptKey}`] = loaded.prompts[promptKey];\n }\n }\n }\n } catch {\n // If loadHandler fails, try loading as direct export\n // This handles files that export functions directly (e.g., export const chatbot)\n try {\n const fileUrl = pathToFileURL(fullPath).href;\n const module = await import(fileUrl);\n\n // Determine type based on directory name\n const dirName = basename(dirPath);\n\n // Check for direct exports matching the directory type\n if (dirName === 'agents') {\n // Look for exported function with same name as file, or any exported function\n const exportedFunction = module[key] || module.default;\n if (typeof exportedFunction === 'function') {\n handlers[key] = exportedFunction;\n }\n } else if (dirName === 'tools') {\n const exportedFunction = module[key] || module.default;\n if (typeof exportedFunction === 'function') {\n handlers[key] = exportedFunction;\n }\n } else if (dirName === 'prompts') {\n // For prompts, accept any export (function, object, string, etc.)\n // Try to get export with same name as file, or default, or any named export\n const exportedValue = module[key] || module.default;\n if (exportedValue !== undefined) {\n handlers[key] = exportedValue;\n } else {\n // Check if module has any exports (excluding default module properties)\n const moduleKeys = Object.keys(module).filter(\n (k) => k !== 'default' && !k.startsWith('__')\n );\n if (moduleKeys.length > 0) {\n // Use the first export, or the module itself if it's a simple object\n handlers[key] = module[moduleKeys[0]] || module;\n }\n }\n }\n } catch {\n // Skip this file if both methods fail\n continue;\n }\n }\n }\n\n return handlers;\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Failed to load directory \"${dirPath}\": ${error.message}`);\n }\n throw error;\n }\n}\n","/**\n * Core handler execution logic\n */\n\nimport type { AgentHandler, ToolHandler, Context, Request, Response } from './types';\n\n/**\n * Execute an agent handler\n */\nexport async function executeAgent(\n handler: AgentHandler,\n context: Context,\n request: Request\n): Promise<Response> {\n return await handler(context, request);\n}\n\n/**\n * Execute a tool handler\n */\nexport async function executeTool(\n handler: ToolHandler,\n context: Context,\n request: Request\n): Promise<Response> {\n return await handler(context, request);\n}\n\n/**\n * Execute a handler (agent or tool)\n */\nexport async function executeHandler(\n handler: AgentHandler | ToolHandler,\n context: Context,\n request: Request\n): Promise<Response> {\n return await handler(context, request);\n}\n","/**\n * Convert between HTTP and Handler formats\n */\n\nimport type { IncomingMessage, ServerResponse } from 'http';\nimport type {\n Request as HandlerRequest,\n Response as HandlerResponse,\n Message,\n} from '@reminix/runtime';\n\n/**\n * Convert HTTP request to Handler Request\n * Extracts messages from HTTP request body\n */\nexport async function convertHttpToRequest(httpReq: IncomingMessage): Promise<HandlerRequest> {\n try {\n // Read request body\n const body = await readRequestBody(httpReq);\n\n // Parse JSON body\n let parsedBody: Record<string, unknown> = {};\n if (body) {\n try {\n parsedBody = JSON.parse(body) as Record<string, unknown>;\n } catch {\n // If not JSON, treat as text\n parsedBody = { content: body };\n }\n }\n\n // Extract messages from body\n // Expected format: { messages: Message[] } or { message: Message } or just Message[]\n let messages: Message[] = [];\n\n if (Array.isArray(parsedBody)) {\n // Body is array of messages\n messages = parsedBody as Message[];\n } else if (parsedBody.messages && Array.isArray(parsedBody.messages)) {\n // Body has messages array\n messages = parsedBody.messages as Message[];\n } else if (parsedBody.message) {\n // Body has single message\n messages = [parsedBody.message as Message];\n } else if (parsedBody.content || parsedBody.role) {\n // Body is a single message object\n messages = [parsedBody as unknown as Message];\n }\n\n // Extract metadata from query params and headers\n const metadata: Record<string, unknown> = {\n method: httpReq.method,\n url: httpReq.url,\n headers: httpReq.headers,\n };\n\n // Add query params to metadata\n if (httpReq.url) {\n const url = new URL(httpReq.url, `http://${httpReq.headers.host || 'localhost'}`);\n const queryParams: Record<string, string> = {};\n url.searchParams.forEach((value, key) => {\n queryParams[key] = value;\n });\n if (Object.keys(queryParams).length > 0) {\n metadata.query = queryParams;\n }\n }\n\n // Merge any additional metadata from body\n if (parsedBody.metadata) {\n Object.assign(metadata, parsedBody.metadata);\n }\n\n return {\n messages,\n metadata,\n };\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Failed to convert HTTP request: ${error.message}`);\n }\n throw error;\n }\n}\n\n/**\n * Convert Handler Response to HTTP response\n */\nexport function convertResponseToHttp(handlerRes: HandlerResponse, httpRes: ServerResponse): void {\n try {\n // Set status code (default 200)\n const statusCode =\n typeof handlerRes.metadata?.statusCode === 'number' ? handlerRes.metadata.statusCode : 200;\n httpRes.statusCode = statusCode;\n\n // Set headers\n const headers =\n (handlerRes.metadata?.headers as Record<string, unknown> | undefined) ||\n ({} as Record<string, unknown>);\n headers['Content-Type'] =\n (typeof headers['Content-Type'] === 'string' ? headers['Content-Type'] : undefined) ||\n 'application/json';\n\n for (const [key, value] of Object.entries(headers)) {\n if (typeof value === 'string') {\n httpRes.setHeader(key, value);\n }\n }\n\n // Prepare response body\n const responseBody = {\n messages: handlerRes.messages,\n ...(handlerRes.metadata && { metadata: handlerRes.metadata }),\n ...(handlerRes.toolCalls && { toolCalls: handlerRes.toolCalls }),\n ...(handlerRes.stateUpdates && { stateUpdates: handlerRes.stateUpdates }),\n };\n\n // Send response\n httpRes.end(JSON.stringify(responseBody));\n } catch (error) {\n if (error instanceof Error) {\n httpRes.statusCode = 500;\n httpRes.setHeader('Content-Type', 'application/json');\n httpRes.end(JSON.stringify({ error: error.message }));\n }\n }\n}\n\n/**\n * Read request body from IncomingMessage\n */\nasync function readRequestBody(req: IncomingMessage): Promise<string> {\n return new Promise((resolve, reject) => {\n let body = '';\n\n req.on('data', (chunk) => {\n body += chunk.toString();\n });\n\n req.on('end', () => {\n resolve(body);\n });\n\n req.on('error', (error) => {\n reject(error);\n });\n });\n}\n\n/**\n * Convert error to HTTP error response\n */\nexport function convertErrorToHttp(error: Error, httpRes: ServerResponse): void {\n httpRes.statusCode = 500;\n httpRes.setHeader('Content-Type', 'application/json');\n httpRes.end(\n JSON.stringify({\n error: error.message,\n ...(process.env.NODE_ENV === 'development' && { stack: error.stack }),\n })\n );\n}\n","/**\n * CLI entry point for Reminix HTTP adapter\n *\n * Usage:\n * npx @reminix/http-adapter serve <handler-path> [options]\n * tsx src/cli.ts serve <handler-path> [options]\n */\n\nimport { startServer, type ServerOptions } from './server';\nimport { parseArgs } from 'util';\nimport { extname } from 'path';\n\n/**\n * Try to register tsx loader for TypeScript support\n * Uses dynamic import which respects Node's module resolution including global packages\n * Returns true if successful, false if tsx is not available\n */\nasync function tryRegisterTsx(): Promise<boolean> {\n try {\n // Use dynamic import to load tsx's ESM API which includes the register function\n // @ts-expect-error - tsx is a runtime dependency, not available at compile time\n const tsx = await import('tsx/esm/api');\n if (tsx && typeof tsx.register === 'function') {\n tsx.register();\n return true;\n }\n } catch {\n // tsx not available\n }\n return false;\n}\n\ninterface CliOptions {\n port?: number;\n host?: string;\n handlerPath: string;\n loader?: string;\n}\n\nfunction parseCliArgs(): CliOptions {\n const args = process.argv.slice(2);\n\n if (args.length === 0 || args[0] !== 'serve') {\n console.error('Usage: reminix-http-adapter serve <handler-path> [options]');\n console.error('');\n console.error('Options:');\n console.error(' --port <number> Port to listen on (default: 3000)');\n console.error(' --host <string> Host to listen on (default: localhost)');\n console.error(' --loader <name> Loader to use for TypeScript support (e.g., tsx)');\n console.error('');\n console.error('Examples:');\n console.error(' npx @reminix/http-adapter serve ./my-handler.ts');\n console.error(' npx @reminix/http-adapter serve ./my-handler.ts --loader tsx');\n console.error(' npx @reminix/http-adapter serve ./my-handler --port 8080');\n process.exit(1);\n }\n\n const handlerPath = args[1];\n if (!handlerPath) {\n console.error('Error: handler-path is required');\n process.exit(1);\n }\n\n const { values } = parseArgs({\n args: args.slice(2),\n options: {\n port: { type: 'string' },\n host: { type: 'string' },\n loader: { type: 'string' },\n },\n });\n\n const options: CliOptions = {\n handlerPath,\n port: values.port ? parseInt(values.port, 10) : undefined,\n host: values.host,\n loader: values.loader,\n };\n\n return options;\n}\n\nasync function main() {\n try {\n const options = parseCliArgs();\n\n // Check if TypeScript support is needed\n const ext = extname(options.handlerPath).toLowerCase();\n const isTypeScript = ext === '.ts' || ext === '.tsx';\n // For directories, we'll check later if they contain .ts files, but register tsx preemptively\n const isDirectory = !ext || ext === '';\n const needsTsx = options.loader === 'tsx' || isTypeScript || (isDirectory && !options.loader);\n\n // Register tsx loader if needed\n if (needsTsx) {\n const registered = await tryRegisterTsx();\n if (!registered) {\n console.error('Error: TypeScript support requires \"tsx\" to be installed.');\n console.error('');\n console.error('To install tsx:');\n console.error(' npm install -g tsx');\n console.error(' # or locally:');\n console.error(' npm install tsx');\n console.error('');\n console.error('Then run:');\n console.error(` npx @reminix/http-adapter serve ${options.handlerPath} --loader tsx`);\n console.error('');\n console.error('Alternatively, use Node.js with --import flag (Node 20.6+):');\n console.error(\n ` node --import tsx node_modules/@reminix/http-adapter/dist/cli.js serve ${options.handlerPath}`\n );\n process.exit(1);\n }\n }\n\n const serverOptions: ServerOptions = {\n port: options.port,\n host: options.host,\n };\n\n await startServer(options.handlerPath, serverOptions);\n } catch (error) {\n console.error('Error starting server:', error);\n process.exit(1);\n }\n}\n\n// Run if called directly\nmain();\n"],"mappings":";;;;;AAIA,SAAS,oBAAqD;;;ACA9D,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AAazB,eAAsB,YAAY,aAAmB;AACnD,MAAI;AAEF,UAAM,UAAU,cAAc,WAAW,EAAE;AAG3C,UAAM,SAAS,MAAM,OAAO;AAG5B,UAAM,SAAwB,CAAA;AAE9B,QAAI,OAAO,QAAQ;AACjB,aAAO,SAAS,OAAO;IACzB;AAEA,QAAI,OAAO,OAAO;AAChB,aAAO,QAAQ,OAAO;IACxB;AAEA,QAAI,OAAO,SAAS;AAClB,aAAO,UAAU,OAAO;IAC1B;AAGA,QAAI,CAAC,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QAAQ,WAAW,eAAe;AACrF,gBAAQ,MAAM,EAAE;AAChB,gBAAQ,MAAM,6DAA6D;AAC3E,gBAAQ;AAAA,UACN,4EAA4E,QAAQ,WAAW;AAAA,QACjG;AACA,gBAAQ,KAAK,CAAC;AAAA,MAChB;AAAA,IACF;AAEA,UAAM,gBAA+B;AAAA,MACnC,MAAM,QAAQ;AAAA,MACd,MAAM,QAAQ;AAAA,IAChB;AAEA,UAAM,YAAY,QAAQ,aAAa,aAAa;AAAA,EACtD,SAAS,OAAO;AACd,YAAQ,MAAM,0BAA0B,KAAK;AAC7C,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AA3Ce;AA8Cf,KAAK;","names":["pathToFileURL","pathToFileURL","extname","extname"]}
@@ -2,7 +2,7 @@
2
2
  * Convert between HTTP and Handler formats
3
3
  */
4
4
  import type { IncomingMessage, ServerResponse } from 'http';
5
- import type { Request as HandlerRequest, Response as HandlerResponse } from '@reminix/sdk';
5
+ import type { Request as HandlerRequest, Response as HandlerResponse } from '@reminix/runtime';
6
6
  /**
7
7
  * Convert HTTP request to Handler Request
8
8
  * Extracts messages from HTTP request body
@@ -1 +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"}
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,EACV,OAAO,IAAI,cAAc,EACzB,QAAQ,IAAI,eAAe,EAE5B,MAAM,kBAAkB,CAAC;AAE1B;;;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"}
@@ -1 +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,UAAU,CAAC,EA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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 CHANGED
@@ -2,8 +2,7 @@
2
2
  * @reminix/http-adapter
3
3
  * HTTP adapter for Reminix handlers
4
4
  */
5
- export { loadHandler, isFile, type LoadedHandler } from './loader';
6
- export { discoverRegistry, type Registry } from './registry';
5
+ export { loadHandler, isFile, discoverRegistry, type LoadedHandler, type Registry, } from '@reminix/runtime';
7
6
  export { convertHttpToRequest, convertResponseToHttp, convertErrorToHttp } from './converter';
8
7
  export { startServer, type ServerOptions } from './server';
9
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,WAAW,EACX,MAAM,EACN,gBAAgB,EAChB,KAAK,aAAa,EAClB,KAAK,QAAQ,GACd,MAAM,kBAAkB,CAAC;AAG1B,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 CHANGED
@@ -2,8 +2,9 @@
2
2
  * @reminix/http-adapter
3
3
  * HTTP adapter for Reminix handlers
4
4
  */
5
- export { loadHandler, isFile } from './loader';
6
- export { discoverRegistry } from './registry';
5
+ // Re-export runtime utilities for convenience
6
+ export { loadHandler, isFile, discoverRegistry, } from '@reminix/runtime';
7
+ // HTTP-specific exports
7
8
  export { convertHttpToRequest, convertResponseToHttp, convertErrorToHttp } from './converter';
8
9
  export { startServer } from './server';
9
10
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +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"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,8CAA8C;AAC9C,OAAO,EACL,WAAW,EACX,MAAM,EACN,gBAAgB,GAGjB,MAAM,kBAAkB,CAAC;AAE1B,wBAAwB;AACxB,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAsB,MAAM,UAAU,CAAC"}
package/dist/server.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * HTTP server for Reminix handlers
3
3
  */
4
4
  import { IncomingMessage } from 'http';
5
- import type { Context } from '@reminix/sdk';
5
+ import type { Context } from '@reminix/runtime';
6
6
  export interface ServerOptions {
7
7
  port?: number;
8
8
  host?: string;
@@ -1 +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"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAgB,eAAe,EAAkB,MAAM,MAAM,CAAC;AAGrE,OAAO,KAAK,EAAE,OAAO,EAA6B,MAAM,kBAAkB,CAAC;AAE3E,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 CHANGED
@@ -2,8 +2,7 @@
2
2
  * HTTP server for Reminix handlers
3
3
  */
4
4
  import { createServer } from 'http';
5
- import { loadHandler, isFile } from './loader';
6
- import { discoverRegistry } from './registry';
5
+ import { loadHandler, isFile, discoverRegistry, executeHandler } from '@reminix/runtime';
7
6
  import { convertHttpToRequest, convertResponseToHttp, convertErrorToHttp } from './converter';
8
7
  /**
9
8
  * Start HTTP server for handler
@@ -58,8 +57,8 @@ export async function startServer(handlerPath, options = {}) {
58
57
  const context = options.context ? await options.context(req) : createDefaultContext(req);
59
58
  // Convert HTTP request to handler request
60
59
  const handlerReq = await convertHttpToRequest(req);
61
- // Call agent handler
62
- const handlerRes = await agent(context, handlerReq);
60
+ // Execute agent handler
61
+ const handlerRes = await executeHandler(agent, context, handlerReq);
63
62
  // Convert handler response to HTTP response
64
63
  convertResponseToHttp(handlerRes, res);
65
64
  return;
@@ -77,8 +76,8 @@ export async function startServer(handlerPath, options = {}) {
77
76
  const context = options.context ? await options.context(req) : createDefaultContext(req);
78
77
  // Convert HTTP request to handler request
79
78
  const handlerReq = await convertHttpToRequest(req);
80
- // Call tool handler
81
- const handlerRes = await tool(context, handlerReq);
79
+ // Execute tool handler
80
+ const handlerRes = await executeHandler(tool, context, handlerReq);
82
81
  // Convert handler response to HTTP response
83
82
  convertResponseToHttp(handlerRes, res);
84
83
  return;
@@ -1 +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,CA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9B,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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reminix/http-adapter",
3
- "version": "0.1.6",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "description": "Reminix HTTP adapter for running handlers",
6
6
  "main": "./dist/index.js",
@@ -34,7 +34,7 @@
34
34
  "homepage": "https://github.com/reminix-ai/reminix-typescript",
35
35
  "dependencies": {
36
36
  "tsx": "^4.21.0",
37
- "@reminix/sdk": "0.1.6"
37
+ "@reminix/runtime": "0.3.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/node": "^25.0.3",
package/dist/loader.d.ts DELETED
@@ -1,19 +0,0 @@
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
@@ -1 +0,0 @@
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 DELETED
@@ -1,52 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"A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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"}
@@ -1,24 +0,0 @@
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
@@ -1 +0,0 @@
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 DELETED
@@ -1,208 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,WAA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