@reminix/lambda-adapter
v0.5.0
Published
Reminix Lambda adapter for running handlers on AWS Lambda
Downloads
344
Maintainers
Readme
@reminix/lambda-adapter
Reminix Lambda adapter for running handlers on AWS Lambda.
Installation
npm install @reminix/lambda-adapter
# or
pnpm add @reminix/lambda-adapter
# or
yarn add @reminix/lambda-adapterUsage
1. Create a Handler
You can either create your own handler or use the examples from @reminix/runtime:
Option A: Use Example Handler
// Use the basic handler example
// Set HANDLER_PATH=/var/task/examples/basic-handler.tsOption B: Create Your Own Handler
Create a file handler.ts:
import type { AgentHandler, Context, Request, Response } from '@reminix/runtime';
export const agents = {
chatbot: async (context: Context, request: Request): Promise<Response> => {
const lastMessage = request.messages[request.messages.length - 1];
return {
messages: [
{
role: 'assistant',
content: `You said: ${lastMessage?.content || 'Hello!'}`,
},
],
metadata: {},
};
},
};See the examples in the repository root for more complete examples.
2. Deploy to Lambda
Package your handler with the Lambda adapter:
// lambda.ts
import { lambdaHandler } from '@reminix/lambda-adapter';
import type {
APIGatewayProxyEvent,
APIGatewayProxyResult,
LambdaContext,
} from '@reminix/lambda-adapter';
export const handler = lambdaHandler;3. Configure Lambda
Set the HANDLER_PATH environment variable to point to your handler file:
HANDLER_PATH=/var/task/handler.tsOr use the default path /var/task/handler.
4. API Gateway Integration
The adapter expects API Gateway proxy integration. Routes:
GET /health- Health checkPOST /agents/:agentId/invoke- Invoke an agentPOST /tools/:toolId/invoke- Invoke a tool
Example Request
curl -X POST https://your-api.execute-api.us-east-1.amazonaws.com/prod/agents/chatbot/invoke \
-H "Content-Type: application/json" \
-d '{
"messages": [
{
"role": "user",
"content": "Hello!"
}
]
}'Environment Variables
HANDLER_PATH- Path to handler file or directory (default:/var/task/handler)NODE_ENV- Set todevelopmentto include stack traces in errors
Context
The adapter automatically creates a handler context with:
chatId- Extracted fromx-chat-idheader, path parameter, or Lambda request IDmemory- Mock memory store (in production, configure your own)knowledgeBase- Mock knowledge base (in production, configure your own)metadata- Lambda context information (requestId, functionName, etc.)
License
MIT
