@juspay/neurolink 13.8.15 โ†’ 13.8.17

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.
@@ -2,6 +2,8 @@
2
2
  * Server Adapter Types
3
3
  * Comprehensive type system for NeuroLink server adapters
4
4
  */
5
+ import type { IncomingHttpHeaders, IncomingMessage, ServerResponse as NodeServerResponse } from "node:http";
6
+ import type { Readable } from "node:stream";
5
7
  import type { ExternalServerManager } from "../mcp/externalServerManager.js";
6
8
  import type { MCPToolRegistry } from "../mcp/toolRegistry.js";
7
9
  import type { NeuroLink } from "../neurolink.js";
@@ -185,6 +187,53 @@ export type RequiredBodyParserConfig = {
185
187
  rawMaxSize: string;
186
188
  urlEncoded: boolean;
187
189
  };
190
+ /**
191
+ * The request a body-parser middleware is handed in place of the real one: a
192
+ * stream of bytes that were already read, with the headers the parser decides
193
+ * from. `body` is where the parser leaves its result, as on a real request.
194
+ */
195
+ export type ServerBufferedRequest = Readable & {
196
+ headers: IncomingHttpHeaders;
197
+ body: unknown;
198
+ };
199
+ /**
200
+ * A body read as far as its limit: the bytes, and whether the connection is to
201
+ * be closed after the answer. That is the case when a compressed body was
202
+ * complete but the request kept sending past the cap on raw bytes, which are
203
+ * then left unread.
204
+ */
205
+ export type ServerBoundedBodyRead = {
206
+ bytes: Buffer;
207
+ closeConnection: boolean;
208
+ };
209
+ /** A Node request as a body-parser middleware sees it: `body` is where it leaves what it parsed. */
210
+ export type ServerParsedNodeRequest = IncomingMessage & {
211
+ body?: unknown;
212
+ };
213
+ /**
214
+ * A body-parser middleware (`express.json()`, `express.urlencoded()`) as
215
+ * body-parser types it: Node's request and response, and a `next` that takes
216
+ * an error. Typed without Express, which is an optional peer, so the published
217
+ * declarations do not import it.
218
+ */
219
+ export type ServerNodeMiddleware = (req: ServerParsedNodeRequest, res: NodeServerResponse, next: (error?: unknown) => void) => void;
220
+ /**
221
+ * What a body-parser middleware decides about a request, asked before any of
222
+ * its body is read: leave it alone, parse it, or refuse it. A refusal made
223
+ * before the parser would read anything has `beforeRead` set; one the parser
224
+ * only reaches once it starts to read (a charset the decoder cannot handle)
225
+ * has not.
226
+ */
227
+ export type ServerBodyParserVerdict = {
228
+ kind: "skip";
229
+ body: unknown;
230
+ } | {
231
+ kind: "parse";
232
+ } | {
233
+ kind: "reject";
234
+ error: unknown;
235
+ beforeRead: boolean;
236
+ };
188
237
  /**
189
238
  * Logging configuration
190
239
  */
@@ -7811,7 +7811,7 @@
7811
7811
  {"objectID":"dee68d2efd01a80eb4a442ec7f72d40d414182b8ee8036638126c7e48f9a745c","title":"4. Respect Retry-After Headers","url":"/docs/guides/server-adapters/errors#4-respect-retry-after-headers","content":"When handling RateLimitError, honor the retryAfterMs:","hierarchy":{"lvl0":"Guides","lvl1":"Error Handling","lvl2":"4. Respect Retry-After Headers","lvl3":""}},
7812
7812
  {"objectID":"af5a0269b91a605247991a222cba64afe694b0045fa4a74aa70a7aba01040a9c","title":"5. Log Appropriately by Severity","url":"/docs/guides/server-adapters/errors#5-log-appropriately-by-severity","content":"5. Log Appropriately by Severity","hierarchy":{"lvl0":"Guides","lvl1":"Error Handling","lvl2":"5. Log Appropriately by Severity","lvl3":""}},
7813
7813
  {"objectID":"6de13080daf8a055a6de3bee97117d3618cbc7b3f61be0c48f17e957ff0b4a88","title":"Related Documentation","url":"/docs/guides/server-adapters/errors#related-documentation","content":"Server Adapters Overview - Getting started with server adapters\nSecurity Best Practices - Authentication and authorization\nConfiguration Reference - Full configuration options\nDeployment Guide - Production deployment strategies","hierarchy":{"lvl0":"Guides","lvl1":"Error Handling","lvl2":"Related Documentation","lvl3":""}},
7814
- {"objectID":"d86a2f773105827bac17ead4d527ff7188a4489c218c4208152663b89b14565c","title":"Express Adapter","url":"/docs/guides/server-adapters/express","content":"Express Adapter\n\nThe most popular Node.js web framework\n\nExpress is a minimal and flexible Node.js web framework that provides a robust set of features for building web applications and APIs. It has the largest ecosystem of middleware and is widely used in production.\n\nWhy Express?\n\n| Feature | Benefit |\n| --------------------- | ----------------------------------------------- |\n| Mature ecosystem | Thousands of middleware packages available |\n| Well-documented | Extensive documentation and community resources |\n| Familiar API | Most Node.js developers already know Express |\n| Flexible | Unopinionated, adapt to any architecture |\n| Production-proven | Powers millions of applications worldwide |\n| Easy migration | Integrate NeuroLink into existing Express apps |\n\nExpress is ideal when you have an existing Express application or prefer its familiar middleware patterns.\n\nCLI Usage\n\nStart an Express server via CLI:\n\nQuick Start\n\nInstallation\n\nExpress must be installed separately alongside NeuroLink:\n\nBasic Usage\n\nTest the Server\n\nAccessing the Express App\n\nFor advanced customization, you can access the underlying Express application:\n\nConfiguration Options\n\nFull Configuration Example\n\nMiddleware Integration\n\nUsing NeuroLink Middleware\n\nUsing Express-Native Middleware\n\nStreaming Responses\n\nExpress supports streaming through Server-Sent Events (SSE):\n\nCustom Streaming Route\n\nAbort Signal Handling\n\nThe abort signal middleware allows detecting when clients disconnect during long-running requests. NeuroLink provides both a universal middleware and an Express-specific implementation.\n\nUsing Abort Signal Middleware\n\nUse Cases\n\nThe abort signal middleware is useful for:\nLong-running AI generation - Cancel generation when client disconnects\nStreaming responses - Stop producing chunks when client leaves\nDatabase queries - Cancel queries that support abort signals\nExternal API calls - Pass signal to fetch/axios for cancellation\n\nNative Express Approach\n\nFor simpler cases, you can use Express's native socket events:\n\nFor streaming requests, the adapter automatically detects client disconnection and stops the stream to avoid unnecessary processing.\n\nError Handling\n\nCustom Error Handler\n\nIntegrating with Existing Express Apps\n\nIf you already have an Express application, you can integrate NeuroLink routes:\n\nTesting\n\nUnit Testing with Supertest\n\nProduction Checklist\n[ ] Configure environment variables securely\n[ ] Set appropriate CORS origins (not *)\n[ ] Enable rate limiting with reasonable limits\n[ ] Add authentication middleware\n[ ] Configure request timeouts\n[ ] Set body size limits\n[ ] Enable compression (gzip/brotli)\n[ ] Add security headers (helmet)\n[ ] Configure logging with appropriate level\n[ ] Set up health check monitoring\n[ ] Configure error tracking (Sentry, etc.)\n[ ] Use a process manager (PM2, systemd)\n\nRelated Documentation\nServer Adapters Overview - Getting started with server adapters\nConfiguration Reference - Full configuration options\nHono Adapter - Compare with Hono adapter\nFastify Adapter - Compare with Fastify adapter\nSecurity Best Practices - Authentication patterns\n\nAdditional Resources\nExpress Documentation - Official Express documentation\nExpress Middleware - Popular middleware packages\nExpress Security Best Practices - Security guidelines\n\nNeed Help? Join our GitHub Discussions or open an issue.","hierarchy":{"lvl0":"Guides","lvl1":"Express Adapter","lvl2":"","lvl3":""}},
7814
+ {"objectID":"d86a2f773105827bac17ead4d527ff7188a4489c218c4208152663b89b14565c","title":"Express Adapter","url":"/docs/guides/server-adapters/express","content":"Express Adapter\n\nThe most popular Node.js web framework\n\nExpress is a minimal and flexible Node.js web framework that provides a robust set of features for building web applications and APIs. It has the largest ecosystem of middleware and is widely used in production.\n\nWhy Express?\n\n| Feature | Benefit |\n| --------------------- | ----------------------------------------------- |\n| Mature ecosystem | Thousands of middleware packages available |\n| Well-documented | Extensive documentation and community resources |\n| Familiar API | Most Node.js developers already know Express |\n| Flexible | Unopinionated, adapt to any architecture |\n| Production-proven | Powers millions of applications worldwide |\n| Easy migration | Integrate NeuroLink into existing Express apps |\n\nExpress is ideal when you have an existing Express application or prefer its familiar middleware patterns.\n\nCLI Usage\n\nStart an Express server via CLI:\n\nQuick Start\n\nInstallation\n\nExpress must be installed separately alongside NeuroLink:\n\nBasic Usage\n\nTest the Server\n\nAccessing the Express App\n\nFor advanced customization, you can access the underlying Express application:\n\nConfiguration Options\n\nFull Configuration Example\n\nRequest body limits\n\nbodyParser.jsonLimit bounds JSON bodies and bodyParser.maxSize bounds url-encoded forms. Both default to 10mb, and raising either one is honoured. Uploads (multipart/form-data, application/octet-stream, audio/*) are bounded by bodyParser.rawMaxSize, which defaults to maxSize when that is set and to 64mb otherwise.\n\nA JSON or url-encoded form body over its limit is answered 413 with error.code set to PAYLOAD_TOO_LARGE and error.message set to request entity too large, before any middleware or route runs, and the connection is closed so the client stops sending. The body is not read past the limit: a declared Content-Length over the limit is refused without reading the body, and a body sent without one (chunked) is read only as far as the limit. For a compressed body (Content-Encoding: gzip, deflate, br or zstd) the limit applies to the inflated size, and reading stops once the body has inflated past it.\n\nThe bytes are still parsed by express.json() and express.urlencoded() (body-parser), so which requests are parsed, how charsets are decoded, strict JSON, and the qs parsing of forms are unchanged. Anything body-parser refuses other than a body that is too large (a malformed or scalar JSON body, an unsupported charset or Content-Encoding, too many form parameters) is answered 500 with error.code set to INTERNAL_ERROR, as before.\n\nMiddleware Integration\n\nUsing NeuroLink Middleware\n\nUsing Express-Native Middleware\n\nStreaming Responses\n\nExpress supports streaming through Server-Sent Events (SSE):\n\nCustom Streaming Route\n\nAbort Signal Handling\n\nThe abort signal middleware allows detecting when clients disconnect during long-running requests. NeuroLink provides both a universal middleware and an Express-specific implementation.\n\nUsing Abort Signal Middleware\n\nUse Cases\n\nThe abort signal middleware is useful for:\nLong-running AI generation - Cancel generation when client disconnects\nStreaming responses - Stop producing chunks when client leaves\nDatabase queries - Cancel queries that support abort signals\nExternal API calls - Pass signal to fetch/axios for cancellation\n\nNative Express Approach\n\nFor simpler cases, you can use Express's native socket events:\n\nFor streaming requests, the adapter automatically detects client disconnection and stops the stream to avoid unnecessary processing.\n\nError Handling\n\nCustom Error Handler\n\nIntegrating with Existing Express Apps\n\nIf you already have an Express application, you can integrate NeuroLink routes:\n\nTesting\n\nUnit Testing with Supertest\n\nProduction Checklist\n[ ] Configure environment variables securely\n[ ] Set appropriate CORS origins (not *)\n[ ] Enable rate limiting with reasonable limits\n[ ] Add authentication middleware\n[ ] Configure request timeouts\n[ ] Set body size limits\n[ ] Enable compression (gzip/brotli)\n[ ] Add security headers (helmet)\n[ ] Configure logging with appropriate level\n[ ] Set up health check monitoring\n[ ] Configure error tracking (Sentry, etc.)\n[ ] Use a process manager (PM2, systemd)\n\nRelated Documentation\nServer Adapters Overview - Getting started with server adapters\nConfiguration Reference - Full configuration options\nHono Adapter - Compare with Hono adapter\nFastify Adapter - Compare with Fastify adapter\nSecurity Best Practices - Authentication patterns\n\nAdditional Resources\nExpress Documentation - Official Express documentation\nExpress Middleware - Popular middleware packages\nExpress Security Best Practices - Security guidelines\n\nNeed Help? Join our GitHub Discussions or open an issue.","hierarchy":{"lvl0":"Guides","lvl1":"Express Adapter","lvl2":"","lvl3":""}},
7815
7815
  {"objectID":"3a0b46a625e8077c402e2fae808252ee0b790e25915b781aab36e0043e0c95ff","title":"Express Adapter","url":"/docs/guides/server-adapters/express#express-adapter","content":"The most popular Node.js web framework\n\nExpress is a minimal and flexible Node.js web framework that provides a robust set of features for building web applications and APIs. It has the largest ecosystem of middleware and is widely used in production.","hierarchy":{"lvl0":"Guides","lvl1":"Express Adapter","lvl2":"Express Adapter","lvl3":""}},
7816
7816
  {"objectID":"05122ccefbae0eefb95cc5da06fccfdf4d33b0d5afa177ae7b75f9745d2a23cf","title":"Why Express?","url":"/docs/guides/server-adapters/express#why-express","content":"| Feature | Benefit |\n| --------------------- | ----------------------------------------------- |\n| Mature ecosystem | Thousands of middleware packages available |\n| Well-documented | Extensive documentation and community resources |\n| Familiar API | Most Node.js developers already know Express |\n| Flexible | Unopinionated, adapt to any architecture |\n| Production-proven | Powers millions of applications worldwide |\n| Easy migration | Integrate NeuroLink into existing Express apps |\n\nExpress is ideal when you have an existing Express application or prefer its familiar middleware patterns.","hierarchy":{"lvl0":"Guides","lvl1":"Express Adapter","lvl2":"Why Express?","lvl3":""}},
7817
7817
  {"objectID":"a509b1b55a5ad6b22c14631c5be63ad50e2d0c1fd7895d7fc7ed3e89c96b31de","title":"CLI Usage","url":"/docs/guides/server-adapters/express#cli-usage","content":"Start an Express server via CLI:","hierarchy":{"lvl0":"Guides","lvl1":"Express Adapter","lvl2":"CLI Usage","lvl3":""}},
@@ -7820,6 +7820,7 @@
7820
7820
  {"objectID":"c8665ba8299a709bf777f2fea4a5c30034f120434206161f412de05e70046f83","title":"Test the Server","url":"/docs/guides/server-adapters/express#test-the-server","content":"Test the Server","hierarchy":{"lvl0":"Guides","lvl1":"Express Adapter","lvl2":"Test the Server","lvl3":""}},
7821
7821
  {"objectID":"43d29d1695eb139f97358faa91162964159fb4687d5ab7d49a961cec1a6c257e","title":"Accessing the Express App","url":"/docs/guides/server-adapters/express#accessing-the-express-app","content":"For advanced customization, you can access the underlying Express application:","hierarchy":{"lvl0":"Guides","lvl1":"Express Adapter","lvl2":"Accessing the Express App","lvl3":""}},
7822
7822
  {"objectID":"e287cd8271a5e9e82a98ba6038721c91c3d49b8a7c6fd588f9b5309953f1c489","title":"Full Configuration Example","url":"/docs/guides/server-adapters/express#full-configuration-example","content":"Full Configuration Example","hierarchy":{"lvl0":"Guides","lvl1":"Express Adapter","lvl2":"Full Configuration Example","lvl3":""}},
7823
+ {"objectID":"27bf2e9da638509164e8ac21d64b5e36f101deaa75f464fcadcb3e4f4057ced2","title":"Request body limits","url":"/docs/guides/server-adapters/express#request-body-limits","content":"bodyParser.jsonLimit bounds JSON bodies and bodyParser.maxSize bounds url-encoded forms. Both default to 10mb, and raising either one is honoured. Uploads (multipart/form-data, application/octet-stream, audio/*) are bounded by bodyParser.rawMaxSize, which defaults to maxSize when that is set and to 64mb otherwise.\n\nA JSON or url-encoded form body over its limit is answered 413 with error.code set to PAYLOAD_TOO_LARGE and error.message set to request entity too large, before any middleware or route runs, and the connection is closed so the client stops sending. The body is not read past the limit: a declared Content-Length over the limit is refused without reading the body, and a body sent without one (chunked) is read only as far as the limit. For a compressed body (Content-Encoding: gzip, deflate, br or zstd) the limit applies to the inflated size, and reading stops once the body has inflated past it.\n\nThe bytes are still parsed by express.json() and express.urlencoded() (body-parser), so which requests are parsed, how charsets are decoded, strict JSON, and the qs parsing of forms are unchanged. Anything body-parser refuses other than a body that is too large (a malformed or scalar JSON body, an unsupported charset or Content-Encoding, too many form parameters) is answered 500 with error.code set to INTERNAL_ERROR, as before.","hierarchy":{"lvl0":"Guides","lvl1":"Express Adapter","lvl2":"Request body limits","lvl3":""}},
7823
7824
  {"objectID":"05db65d092e325a4ae7bbd23890cc3f6ca3e61561a196d00f3199c158851cc4e","title":"Using NeuroLink Middleware","url":"/docs/guides/server-adapters/express#using-neurolink-middleware","content":"Using NeuroLink Middleware","hierarchy":{"lvl0":"Guides","lvl1":"Express Adapter","lvl2":"Using NeuroLink Middleware","lvl3":""}},
7824
7825
  {"objectID":"b4c7f350e63e32f17c10ecaade63856d9baac07c72d93a07083e10c1cac4fc01","title":"Using Express-Native Middleware","url":"/docs/guides/server-adapters/express#using-express-native-middleware","content":"Using Express-Native Middleware","hierarchy":{"lvl0":"Guides","lvl1":"Express Adapter","lvl2":"Using Express-Native Middleware","lvl3":""}},
7825
7826
  {"objectID":"3ef5b221323ada6a9627c762b6f84cad3c88454030f6b5496da6a84dba4801a0","title":"Streaming Responses","url":"/docs/guides/server-adapters/express#streaming-responses","content":"Express supports streaming through Server-Sent Events (SSE):","hierarchy":{"lvl0":"Guides","lvl1":"Express Adapter","lvl2":"Streaming Responses","lvl3":""}},
@@ -7859,7 +7860,7 @@
7859
7860
  {"objectID":"ce64f640074b8e60ee4bd472c5c1e5a246d0c373e06b5c046eae0db635733ba5","title":"Production Checklist","url":"/docs/guides/server-adapters/fastify#production-checklist","content":"[ ] Configure environment variables securely\n[ ] Set appropriate CORS origins (not *)\n[ ] Enable rate limiting with reasonable limits\n[ ] Add authentication middleware\n[ ] Configure request timeouts\n[ ] Set body size limits\n[ ] Enable compression (@fastify/compress)\n[ ] Add security headers (@fastify/helmet)\n[ ] Configure logging with appropriate level\n[ ] Set up health check monitoring\n[ ] Configure error tracking (Sentry, etc.)\n[ ] Use schema validation for all routes\n[ ] Enable JSON schema compilation caching","hierarchy":{"lvl0":"Guides","lvl1":"Fastify Adapter","lvl2":"Production Checklist","lvl3":""}},
7860
7861
  {"objectID":"96060a0ae3f9dfb112daf783ff1f49d405316b318d40fdb38c9e9b3a3f4dc377","title":"Related Documentation","url":"/docs/guides/server-adapters/fastify#related-documentation","content":"Server Adapters Overview - Getting started with server adapters\nConfiguration Reference - Full configuration options\nHono Adapter - Compare with Hono adapter\nExpress Adapter - Compare with Express adapter\nSecurity Best Practices - Authentication patterns","hierarchy":{"lvl0":"Guides","lvl1":"Fastify Adapter","lvl2":"Related Documentation","lvl3":""}},
7861
7862
  {"objectID":"84a68aab0ea6da1d4500a0e89cffad25af13dfb8f7c11c0466d2a5cc2160f2c2","title":"Additional Resources","url":"/docs/guides/server-adapters/fastify#additional-resources","content":"Fastify Documentation - Official Fastify documentation\nFastify Plugins - Official and community plugins\nFastify Performance - Performance tuning\n\nNeed Help? Join our GitHub Discussions or open an issue.","hierarchy":{"lvl0":"Guides","lvl1":"Fastify Adapter","lvl2":"Additional Resources","lvl3":""}},
7862
- {"objectID":"cd85d95041216458a7ff86a558a33685239f0e7c062584b10c910a1071c70385","title":"Hono Adapter","url":"/docs/guides/server-adapters/hono","content":"Hono Adapter\n\nThe recommended framework for NeuroLink server adapters\n\nHono is a lightweight, ultrafast web framework designed for the edge. It runs on virtually any JavaScript runtime including Node.js, Deno, Bun, Cloudflare Workers, and more.\n\nWhy Hono?\n\n| Feature | Benefit |\n| ----------------------- | ------------------------------------------------------------------------- |\n| Multi-runtime | Deploy to Node.js, Deno, Bun, Cloudflare Workers, Vercel Edge, AWS Lambda |\n| Ultrafast | Minimal overhead, optimized router with RegExpRouter |\n| TypeScript-first | Full type safety out of the box |\n| Tiny footprint | ~14KB minified, no dependencies |\n| Built-in middleware | CORS, compression, ETag, secure headers included |\n| Web Standards | Uses Fetch API, Request/Response objects |\n\nHono is the default and recommended framework for NeuroLink server adapters.\n\nCLI Usage\n\nStart a Hono server via CLI:\n\nQuick Start\n\nInstallation\n\nHono is included with NeuroLink - no additional installation required.\n\nBasic Usage\n\nTest the Server\n\nAccessing the Hono App\n\nFor advanced customization, you can access the underlying Hono instance:\n\nConfiguration Options\n\nFull Configuration Example\n\nRequest body limits\n\nbodyParser.jsonLimit bounds JSON bodies and bodyParser.maxSize bounds url-encoded forms. Both default to 10mb, as on the Express, Fastify and Koa adapters, and raising either one is honoured. Uploads (multipart/form-data, application/octet-stream, audio/*) are bounded by bodyParser.rawMaxSize, which defaults to maxSize when that is set and to 64mb otherwise.\n\nA JSON or url-encoded form body over its limit is answered 413 with error.code set to PAYLOAD_TOO_LARGE, before any middleware or route runs. A declared Content-Length over the limit is refused without reading the body, and a body sent without one is read only as far as the limit. An upload over the limit still reaches its route, which answers in its own wire format.\n\nMiddleware Integration\n\nUsing NeuroLink Middleware\n\nUsing Hono Built-in Middleware\n\nStreaming Responses\n\nHono has excellent streaming support, which NeuroLink leverages for real-time AI responses:\n\nCustom Streaming Route\n\nError Handling\n\nCustom Error Handler\n\nPerformance Tips\nUse the RegExpRouter (Default)\n\nHono uses RegExpRouter by default, which is the fastest router. No configuration needed.\nEnable Compression\nUse ETag for Caching\nMinimize Middleware Chain\n\nOnly use middleware where needed:\nUse Streaming for Long Responses\n\nAlways use the streaming endpoint for AI generation to avoid timeouts:\n\nEdge Runtime Deployment\n\nCloudflare Workers\n\nVercel Edge Functions\n\nDeno Deploy\n\nTesting\n\nUnit Testing with Hono Test Client\n\nProduction Checklist\n[ ] Configure environment variables securely\n[ ] Set appropriate CORS origins (not *)\n[ ] Enable rate limiting with reasonable limits\n[ ] Add authentication middleware\n[ ] Configure request timeouts\n[ ] Set body size limits\n[ ] Enable compression\n[ ] Add security headers\n[ ] Configure logging with appropriate level\n[ ] Set up health check monitoring\n[ ] Configure error tracking (Sentry, etc.)\n\nRelated Documentation\nServer Adapters Overview - Getting started with server adapters\nConfiguration Reference - Full configuration options\nExpress Adapter - Compare with Express adapter\nSecurity Best Practices - Authentication patterns\nStreaming Guide - Real-time streaming with SSE and NDJSON\n\nAdditional Resources\nHono Documentation - Official Hono documentation\nHono Middleware - Built-in middleware\nHono Examples - Example applications\n\nNeed Help? Join our GitHub Discussions or open an issue.","hierarchy":{"lvl0":"Guides","lvl1":"Hono Adapter","lvl2":"","lvl3":""}},
7863
+ {"objectID":"cd85d95041216458a7ff86a558a33685239f0e7c062584b10c910a1071c70385","title":"Hono Adapter","url":"/docs/guides/server-adapters/hono","content":"Hono Adapter\n\nThe recommended framework for NeuroLink server adapters\n\nHono is a lightweight, ultrafast web framework designed for the edge. It runs on virtually any JavaScript runtime including Node.js, Deno, Bun, Cloudflare Workers, and more.\n\nWhy Hono?\n\n| Feature | Benefit |\n| ----------------------- | ------------------------------------------------------------------------- |\n| Multi-runtime | Deploy to Node.js, Deno, Bun, Cloudflare Workers, Vercel Edge, AWS Lambda |\n| Ultrafast | Minimal overhead, optimized router with RegExpRouter |\n| TypeScript-first | Full type safety out of the box |\n| Tiny footprint | ~14KB minified, no dependencies |\n| Built-in middleware | CORS, compression, ETag, secure headers included |\n| Web Standards | Uses Fetch API, Request/Response objects |\n\nHono is the default and recommended framework for NeuroLink server adapters.\n\nCLI Usage\n\nStart a Hono server via CLI:\n\nQuick Start\n\nInstallation\n\nHono is included with NeuroLink - no additional installation required.\n\nBasic Usage\n\nTest the Server\n\nAccessing the Hono App\n\nFor advanced customization, you can access the underlying Hono instance:\n\nConfiguration Options\n\nFull Configuration Example\n\nRequest body limits\n\nbodyParser.jsonLimit bounds JSON bodies and bodyParser.maxSize bounds url-encoded forms. Both default to 10mb, as on the Express, Fastify and Koa adapters, and raising either one is honoured. Uploads (multipart/form-data, application/octet-stream, audio/*) are bounded by bodyParser.rawMaxSize, which defaults to maxSize when that is set and to 64mb otherwise.\n\nA JSON or url-encoded form body over its limit is answered 413 with error.code set to PAYLOAD_TOO_LARGE, before any middleware or route runs. A declared Content-Length over the limit is refused without reading the body, and a body sent without one is read only as far as the limit. An upload over the limit still reaches its route, which answers in its own wire format.\n\nThe Express adapter stops at the limit the same way (see \"Request body limits\" in its guide). Its 413 carries the message request entity too large, where Hono's names the limit in bytes.\n\nMiddleware Integration\n\nUsing NeuroLink Middleware\n\nUsing Hono Built-in Middleware\n\nStreaming Responses\n\nHono has excellent streaming support, which NeuroLink leverages for real-time AI responses:\n\nCustom Streaming Route\n\nError Handling\n\nCustom Error Handler\n\nPerformance Tips\nUse the RegExpRouter (Default)\n\nHono uses RegExpRouter by default, which is the fastest router. No configuration needed.\nEnable Compression\nUse ETag for Caching\nMinimize Middleware Chain\n\nOnly use middleware where needed:\nUse Streaming for Long Responses\n\nAlways use the streaming endpoint for AI generation to avoid timeouts:\n\nEdge Runtime Deployment\n\nCloudflare Workers\n\nVercel Edge Functions\n\nDeno Deploy\n\nTesting\n\nUnit Testing with Hono Test Client\n\nProduction Checklist\n[ ] Configure environment variables securely\n[ ] Set appropriate CORS origins (not *)\n[ ] Enable rate limiting with reasonable limits\n[ ] Add authentication middleware\n[ ] Configure request timeouts\n[ ] Set body size limits\n[ ] Enable compression\n[ ] Add security headers\n[ ] Configure logging with appropriate level\n[ ] Set up health check monitoring\n[ ] Configure error tracking (Sentry, etc.)\n\nRelated Documentation\nServer Adapters Overview - Getting started with server adapters\nConfiguration Reference - Full configuration options\nExpress Adapter - Compare with Express adapter\nSecurity Best Practices - Authentication patterns\nStreaming Guide - Real-time streaming with SSE and NDJSON\n\nAdditional Resources\nHono Documentation - Official Hono documentation\nHono Middleware - Built-in middleware\nHono Examples - Example applications\n\nNeed Help? Join our GitHub Discussions or open an issue.","hierarchy":{"lvl0":"Guides","lvl1":"Hono Adapter","lvl2":"","lvl3":""}},
7863
7864
  {"objectID":"4f52a63fa59e73e486b75c6e70853fb82c660686cdf13261394fc63c32c40a66","title":"Hono Adapter","url":"/docs/guides/server-adapters/hono#hono-adapter","content":"The recommended framework for NeuroLink server adapters\n\nHono is a lightweight, ultrafast web framework designed for the edge. It runs on virtually any JavaScript runtime including Node.js, Deno, Bun, Cloudflare Workers, and more.","hierarchy":{"lvl0":"Guides","lvl1":"Hono Adapter","lvl2":"Hono Adapter","lvl3":""}},
7864
7865
  {"objectID":"c53bb661bf4d428d1292350b9eae21f7c2d881f171414cc705135e3e360d3521","title":"Why Hono?","url":"/docs/guides/server-adapters/hono#why-hono","content":"| Feature | Benefit |\n| ----------------------- | ------------------------------------------------------------------------- |\n| Multi-runtime | Deploy to Node.js, Deno, Bun, Cloudflare Workers, Vercel Edge, AWS Lambda |\n| Ultrafast | Minimal overhead, optimized router with RegExpRouter |\n| TypeScript-first | Full type safety out of the box |\n| Tiny footprint | ~14KB minified, no dependencies |\n| Built-in middleware | CORS, compression, ETag, secure headers included |\n| Web Standards | Uses Fetch API, Request/Response objects |\n\nHono is the default and recommended framework for NeuroLink server adapters.","hierarchy":{"lvl0":"Guides","lvl1":"Hono Adapter","lvl2":"Why Hono?","lvl3":""}},
7865
7866
  {"objectID":"4a6a19f4b89aa1306c9c1c381201916f7a706160c87f5e8dbf11e7f2cc60764f","title":"CLI Usage","url":"/docs/guides/server-adapters/hono#cli-usage","content":"Start a Hono server via CLI:","hierarchy":{"lvl0":"Guides","lvl1":"Hono Adapter","lvl2":"CLI Usage","lvl3":""}},
@@ -7868,7 +7869,7 @@
7868
7869
  {"objectID":"ac05717bef2259e66cdf32c6288f05234f2bcfdb7368a47650ed142a0a388a55","title":"Test the Server","url":"/docs/guides/server-adapters/hono#test-the-server","content":"Test the Server","hierarchy":{"lvl0":"Guides","lvl1":"Hono Adapter","lvl2":"Test the Server","lvl3":""}},
7869
7870
  {"objectID":"65a842ab7e90d7989760c8a34c85e7567c556472b5b3d94a0c62ccc93a613156","title":"Accessing the Hono App","url":"/docs/guides/server-adapters/hono#accessing-the-hono-app","content":"For advanced customization, you can access the underlying Hono instance:","hierarchy":{"lvl0":"Guides","lvl1":"Hono Adapter","lvl2":"Accessing the Hono App","lvl3":""}},
7870
7871
  {"objectID":"0f064fccc3e1e74bc76e8e15f3bf58fc0a6fb19c5287de8d9477a3c660a1b562","title":"Full Configuration Example","url":"/docs/guides/server-adapters/hono#full-configuration-example","content":"Full Configuration Example","hierarchy":{"lvl0":"Guides","lvl1":"Hono Adapter","lvl2":"Full Configuration Example","lvl3":""}},
7871
- {"objectID":"f2750d8ff58dea504fb6e6d82dd41be7772022260c0badf9be197729e5921f1c","title":"Request body limits","url":"/docs/guides/server-adapters/hono#request-body-limits","content":"bodyParser.jsonLimit bounds JSON bodies and bodyParser.maxSize bounds url-encoded forms. Both default to 10mb, as on the Express, Fastify and Koa adapters, and raising either one is honoured. Uploads (multipart/form-data, application/octet-stream, audio/*) are bounded by bodyParser.rawMaxSize, which defaults to maxSize when that is set and to 64mb otherwise.\n\nA JSON or url-encoded form body over its limit is answered 413 with error.code set to PAYLOAD_TOO_LARGE, before any middleware or route runs. A declared Content-Length over the limit is refused without reading the body, and a body sent without one is read only as far as the limit. An upload over the limit still reaches its route, which answers in its own wire format.","hierarchy":{"lvl0":"Guides","lvl1":"Hono Adapter","lvl2":"Request body limits","lvl3":""}},
7872
+ {"objectID":"f2750d8ff58dea504fb6e6d82dd41be7772022260c0badf9be197729e5921f1c","title":"Request body limits","url":"/docs/guides/server-adapters/hono#request-body-limits","content":"bodyParser.jsonLimit bounds JSON bodies and bodyParser.maxSize bounds url-encoded forms. Both default to 10mb, as on the Express, Fastify and Koa adapters, and raising either one is honoured. Uploads (multipart/form-data, application/octet-stream, audio/*) are bounded by bodyParser.rawMaxSize, which defaults to maxSize when that is set and to 64mb otherwise.\n\nA JSON or url-encoded form body over its limit is answered 413 with error.code set to PAYLOAD_TOO_LARGE, before any middleware or route runs. A declared Content-Length over the limit is refused without reading the body, and a body sent without one is read only as far as the limit. An upload over the limit still reaches its route, which answers in its own wire format.\n\nThe Express adapter stops at the limit the same way (see \"Request body limits\" in its guide). Its 413 carries the message request entity too large, where Hono's names the limit in bytes.","hierarchy":{"lvl0":"Guides","lvl1":"Hono Adapter","lvl2":"Request body limits","lvl3":""}},
7872
7873
  {"objectID":"821ac3bdd68d125a2aef04f014beab93f8b62f2148bcece2ccc375cd2d09925b","title":"Using NeuroLink Middleware","url":"/docs/guides/server-adapters/hono#using-neurolink-middleware","content":"Using NeuroLink Middleware","hierarchy":{"lvl0":"Guides","lvl1":"Hono Adapter","lvl2":"Using NeuroLink Middleware","lvl3":""}},
7873
7874
  {"objectID":"354e2b56d0fe0720a8dadeb912ee44e5412ff034874daf270f8c96ce6a011b54","title":"Using Hono Built-in Middleware","url":"/docs/guides/server-adapters/hono#using-hono-built-in-middleware","content":"Using Hono Built-in Middleware","hierarchy":{"lvl0":"Guides","lvl1":"Hono Adapter","lvl2":"Using Hono Built-in Middleware","lvl3":""}},
7874
7875
  {"objectID":"87222251107cdbe1386180da56d88d17b161d2b7b2aafc76f031006fa81fc0dd","title":"Streaming Responses","url":"/docs/guides/server-adapters/hono#streaming-responses","content":"Hono has excellent streaming support, which NeuroLink leverages for real-time AI responses:","hierarchy":{"lvl0":"Guides","lvl1":"Hono Adapter","lvl2":"Streaming Responses","lvl3":""}},
@@ -8466,15 +8467,16 @@
8466
8467
  {"objectID":"156003cd4819e4dbb7f346be7120ea605e8ad136ca867e2f736327744c48c281","title":"2. Best Practices","url":"/docs/mcp/testing#2-best-practices","content":"Use TypeScript for full type safety\nValidate inputs with Zod schemas\nHandle errors gracefully in tools\nLog execution for debugging\nTest thoroughly before deployment","hierarchy":{"lvl0":"Mcp","lvl1":"๐Ÿงช MCP Foundation Testing Guide","lvl2":"2. Best Practices","lvl3":""}},
8467
8468
  {"objectID":"e772b5dca6bea98f96f9043b173ee610272e201d08879869318c2d8070425ffc","title":"3. Performance Monitoring","url":"/docs/mcp/testing#3-performance-monitoring","content":"3. Performance Monitoring","hierarchy":{"lvl0":"Mcp","lvl1":"๐Ÿงช MCP Foundation Testing Guide","lvl2":"3. Performance Monitoring","lvl3":""}},
8468
8469
  {"objectID":"82c7cc03c75290cac4197443132e907f9796ad297a7a81df29ac6e5ae9c42734","title":"๐Ÿš€ Next Steps","url":"/docs/mcp/testing#-next-steps","content":"โœ… Test Current Implementation - Use programmatic testing examples\n๐Ÿ”ง Add CLI Integration - Implement MCP CLI commands\n๐Ÿ—๏ธ Create Custom Servers - Build domain-specific tool servers\n๐Ÿ“Š Monitor Performance - Track tool execution and usage\n๐Ÿ”„ Iterate and Improve - Enhance based on real usage\n\nMCP Foundation is production-ready and waiting for your custom tools! ๐ŸŽ‰","hierarchy":{"lvl0":"Mcp","lvl1":"๐Ÿงช MCP Foundation Testing Guide","lvl2":"๐Ÿš€ Next Steps","lvl3":""}},
8469
- {"objectID":"d287e2ebab877225d0b71aafb45118dd2b1d04914f8cf4cd8b2c82b12aba80b8","title":"Conversation Memory","url":"/docs/memory/conversation","content":"Conversation Memory\n\nNeuroLink's Conversation Memory feature enables AI models to maintain context across multiple turns within a session, creating more natural and coherent conversations.\n\n๐Ÿง  Overview\n\nThe conversation memory system provides:\nSession-based memory: Each conversation session maintains its own context\nTurn-by-turn persistence: AI remembers previous messages within a session\nAutomatic cleanup: Configurable limits to prevent memory bloat\nSession isolation: Different sessions don't interfere with each other\nIn-memory storage: Fast, lightweight storage for conversation history\nUniversal Method Support: Works seamlessly with both generate() and stream() methods\nStream Integration: Full conversation memory support for streaming responses\n\nโš™๏ธ Configuration\n\nEnvironment Variables\n\nProgrammatic Configuration\n\n๐Ÿš€ Usage Examples\n\nBasic Usage with Session ID\n\nStreaming Support\n\nThe conversation memory system now fully supports streaming responses with the same memory persistence:\n\nMixed Generate/Stream Conversations\n\nYou can seamlessly mix generate() and stream() calls within the same conversation:\n\nSession Isolation Example\n\n๐Ÿ“Š Memory Management\n\nTurn Limits\n\nWhen the number of conversation turns exceeds maxTurnsPerSession, older messages are automatically removed:\n\nSession Limits\n\nWhen the number of active sessions exceeds maxSessions, the least recently used sessions are removed:\n\n๐Ÿ”Œ API Reference\n\nMemory Statistics\n\nSession Management\n\n๐Ÿงช Test Results\n\nThe conversation memory system has been thoroughly tested and validated:\n\nโœ… Test Suite Results\n\n| Test Case | Status | Description |\n| --------------------- | ------- | ----------------------------------------------- |\n| Basic Memory | โœ… PASS | AI correctly remembers information across turns |\n| Session Isolation | โœ… PASS | Sessions remain completely separate |\n| Turn Limits | โœ… PASS | Automatic cleanup when limits exceeded |\n| Session Limits | โœ… PASS | LRU eviction of old sessions |\n| API Functions | โœ… PASS | Clear operations work correctly |\n\nExample Test Output\n\n๐Ÿ’ก Best Practices\nSession ID Strategy\nMemory Limits\nError Handling\n\n๐Ÿ”ง Technical Implementation\n\nArchitecture\n\nMessage Format\n\n๐Ÿ” Troubleshooting\n\nCommon Issues\n\nMemory not persisting between calls\nEnsure sessionId is consistent across calls\nVerify conversationMemory.enabled is true\nCheck that sessionId is a valid string\n\nPerformance issues with large conversations\nReduce maxTurnsPerSession limit\nImplement session cleanup strategies\nMonitor memory usage statistics\n\nSession isolation not working\nVerify different sessionId values are being used\nCheck for session ID conflicts or duplicates\n\nDebug Logging\n\n๐Ÿ”— Related Documentation\nRedis Conversation Export - Export session history as JSON for analytics\nAPI Reference - Complete SDK documentation\nConfiguration - Environment setup guide\nExamples - More usage examples\nTesting Guide - How to test conversation memory\n\n๐Ÿ“ˆ Performance Characteristics\nMemory Usage: ~1KB per conversation turn\nLookup Time: O(1) for session retrieval\nCleanup Time: O(n) for session limit enforcement\nConcurrency: Thread-safe in-memory operations\n\nThe conversation memory system is designed for production use with efficient memory management and robust error handling.","hierarchy":{"lvl0":"Memory","lvl1":"Conversation Memory","lvl2":"","lvl3":""}},
8470
+ {"objectID":"d287e2ebab877225d0b71aafb45118dd2b1d04914f8cf4cd8b2c82b12aba80b8","title":"Conversation Memory","url":"/docs/memory/conversation","content":"Conversation Memory\n\nNeuroLink's Conversation Memory feature enables AI models to maintain context across multiple turns within a session, creating more natural and coherent conversations.\n\n๐Ÿง  Overview\n\nThe conversation memory system provides:\nSession-based memory: Each conversation session maintains its own context\nTurn-by-turn persistence: AI remembers previous messages within a session\nAutomatic cleanup: Configurable limits to prevent memory bloat\nSession isolation: Different sessions don't interfere with each other\nIn-memory storage: Fast, lightweight storage for conversation history\nUniversal Method Support: Works seamlessly with both generate() and stream() methods\nStream Integration: Full conversation memory support for streaming responses\nTitle Generation Events: Redis-backed conversations get an AI-generated title, announced with a conversation:titleGenerated event\n\nโš™๏ธ Configuration\n\nEnvironment Variables\n\nProgrammatic Configuration\n\n๐Ÿš€ Usage Examples\n\nBasic Usage with Session ID\n\nStreaming Support\n\nThe conversation memory system now fully supports streaming responses with the same memory persistence:\n\nMixed Generate/Stream Conversations\n\nYou can seamlessly mix generate() and stream() calls within the same conversation:\n\nSession Isolation Example\n\n๐Ÿท๏ธ Title Generation Events {#title-generation-events}\n\nWhen a Redis-backed conversation stores its first turn, NeuroLink generates a title for it in the background and saves it on the session (listSessions() reports it). Once the title is stored, the SDK's event emitter fires conversation:titleGenerated.\n\nPayload (ConversationTitleGeneratedEvent):\n\n| Property | Type | Description |\n| ----------- | -------- | ---------------------------------------------------- |\n| sessionId | string | Session the title belongs to |\n| userId | string | User that owns the session (randomUser when unset) |\n| title | string | The title that was stored |\n| timestamp | number | Unix epoch milliseconds when the title was stored |\n\nNotes:\nThe event fires once per conversation, on the first turn, not on later turns.\nOnly Redis-backed memory generates titles; in-memory storage lists sessions by session ID.\nIf the summarization provider cannot answer, the stored title falls back to the first 30 characters of the message plus ..., and the event carries that fallback.\nSet NEUROLINK_TITLE_PROMPT to customize the title prompt. ${userMessage} is replaced with the user's message.\n\n๐Ÿ“Š Memory Management\n\nTurn Limits\n\nWhen the number of conversation turns exceeds maxTurnsPerSession, older messages are automatically removed:\n\nSession Limits\n\nWhen the number of active sessions exceeds maxSessions, the least recently used sessions are removed:\n\n๐Ÿ”Œ API Reference\n\nMemory Statistics\n\nSession Management\n\n๐Ÿงช Test Results\n\nThe conversation memory system has been thoroughly tested and validated:\n\nโœ… Test Suite Results\n\n| Test Case | Status | Description |\n| --------------------- | ------- | ----------------------------------------------- |\n| Basic Memory | โœ… PASS | AI correctly remembers information across turns |\n| Session Isolation | โœ… PASS | Sessions remain completely separate |\n| Turn Limits | โœ… PASS | Automatic cleanup when limits exceeded |\n| Session Limits | โœ… PASS | LRU eviction of old sessions |\n| API Functions | โœ… PASS | Clear operations work correctly |\n\nExample Test Output\n\n๐Ÿ’ก Best Practices\nSession ID Strategy\nMemory Limits\nError Handling\n\n๐Ÿ”ง Technical Implementation\n\nArchitecture\n\nMessage Format\n\n๐Ÿ” Troubleshooting\n\nCommon Issues\n\nMemory not persisting between calls\nEnsure sessionId is consistent across calls\nVerify conversationMemory.enabled is true\nCheck that sessionId is a valid string\n\nPerformance issues with large conversations\nReduce maxTurnsPerSession limit\nImplement session cleanup strategies\nMonitor memory usage statistics\n\nSession isolation not working\nVerify different sessionId values are being used\nCheck for session ID conflicts or duplicates\n\nDebug Logging\n\n๐Ÿ”— Related Documentation\nRedis Conversation Export - Export session history as JSON for analytics\nAPI Reference - Complete SDK documentation\nConfiguration - Environment setup guide\nExamples - More usage examples\nTesting Guide - How to test conversation memory\n\n๐Ÿ“ˆ Performance Characteristics\nMemory Usage: ~1KB per conversation turn\nLookup Time: O(1) for session retrieval\nCleanup Time: O(n) for session limit enforcement\nConcurrency: Thread-safe in-memory operations\n\nThe conversation memory system is designed for production use with efficient memory management and robust error handling.","hierarchy":{"lvl0":"Memory","lvl1":"Conversation Memory","lvl2":"","lvl3":""}},
8470
8471
  {"objectID":"c5ecb284a686db95e36732c07ddc3b49949d9113b826193e1f6feabf1ae48784","title":"Conversation Memory","url":"/docs/memory/conversation#conversation-memory","content":"NeuroLink's Conversation Memory feature enables AI models to maintain context across multiple turns within a session, creating more natural and coherent conversations.","hierarchy":{"lvl0":"Memory","lvl1":"Conversation Memory","lvl2":"Conversation Memory","lvl3":""}},
8471
- {"objectID":"5eb7e9215a286dcd5f45287f758f7c7aa08263f946d3b58182bd9ae2ea029d98","title":"๐Ÿง  Overview","url":"/docs/memory/conversation#-overview","content":"The conversation memory system provides:\nSession-based memory: Each conversation session maintains its own context\nTurn-by-turn persistence: AI remembers previous messages within a session\nAutomatic cleanup: Configurable limits to prevent memory bloat\nSession isolation: Different sessions don't interfere with each other\nIn-memory storage: Fast, lightweight storage for conversation history\nUniversal Method Support: Works seamlessly with both generate() and stream() methods\nStream Integration: Full conversation memory support for streaming responses","hierarchy":{"lvl0":"Memory","lvl1":"Conversation Memory","lvl2":"๐Ÿง  Overview","lvl3":""}},
8472
+ {"objectID":"5eb7e9215a286dcd5f45287f758f7c7aa08263f946d3b58182bd9ae2ea029d98","title":"๐Ÿง  Overview","url":"/docs/memory/conversation#-overview","content":"The conversation memory system provides:\nSession-based memory: Each conversation session maintains its own context\nTurn-by-turn persistence: AI remembers previous messages within a session\nAutomatic cleanup: Configurable limits to prevent memory bloat\nSession isolation: Different sessions don't interfere with each other\nIn-memory storage: Fast, lightweight storage for conversation history\nUniversal Method Support: Works seamlessly with both generate() and stream() methods\nStream Integration: Full conversation memory support for streaming responses\nTitle Generation Events: Redis-backed conversations get an AI-generated title, announced with a conversation:titleGenerated event","hierarchy":{"lvl0":"Memory","lvl1":"Conversation Memory","lvl2":"๐Ÿง  Overview","lvl3":""}},
8472
8473
  {"objectID":"d2eb5a1a0caa1a4c9a75e15f0cf37e5cd1f37e00d9ef168bac48c0db9cb40ffd","title":"Environment Variables","url":"/docs/memory/conversation#environment-variables","content":"Environment Variables","hierarchy":{"lvl0":"Memory","lvl1":"Conversation Memory","lvl2":"Environment Variables","lvl3":""}},
8473
8474
  {"objectID":"520e090e02894dc26d3732e6e5710332a0c681ebd3f9648f421d48e01c991d65","title":"Programmatic Configuration","url":"/docs/memory/conversation#programmatic-configuration","content":"Programmatic Configuration","hierarchy":{"lvl0":"Memory","lvl1":"Conversation Memory","lvl2":"Programmatic Configuration","lvl3":""}},
8474
8475
  {"objectID":"75f91f33db6fd6704adb0d78885dafb7f3d33a0e36ac5edd543ed070cacd2329","title":"Basic Usage with Session ID","url":"/docs/memory/conversation#basic-usage-with-session-id","content":"Basic Usage with Session ID","hierarchy":{"lvl0":"Memory","lvl1":"Conversation Memory","lvl2":"Basic Usage with Session ID","lvl3":""}},
8475
8476
  {"objectID":"5d65f1e509ac96cb91a4a3027345c19b33198f0e3dd51442e5f3ef4d5e6bf8ba","title":"Streaming Support","url":"/docs/memory/conversation#streaming-support","content":"The conversation memory system now fully supports streaming responses with the same memory persistence:","hierarchy":{"lvl0":"Memory","lvl1":"Conversation Memory","lvl2":"Streaming Support","lvl3":""}},
8476
8477
  {"objectID":"b104538f38fc8e518c4b440d352a6888ccbc0e3fe334446b317e81ef2815ef69","title":"Mixed Generate/Stream Conversations","url":"/docs/memory/conversation#mixed-generatestream-conversations","content":"You can seamlessly mix generate() and stream() calls within the same conversation:","hierarchy":{"lvl0":"Memory","lvl1":"Conversation Memory","lvl2":"Mixed Generate/Stream Conversations","lvl3":""}},
8477
8478
  {"objectID":"3d44a6a1ef6c03c6f48aabb0c9516e1f05d660eac1d51829bfaf2e8506bd9c2e","title":"Session Isolation Example","url":"/docs/memory/conversation#session-isolation-example","content":"Session Isolation Example","hierarchy":{"lvl0":"Memory","lvl1":"Conversation Memory","lvl2":"Session Isolation Example","lvl3":""}},
8479
+ {"objectID":"778e79ba226a658a91d70c69514a873920f93d560c695eb75e1d9b6a735567a8","title":"๐Ÿท๏ธ Title Generation Events","url":"/docs/memory/conversation#title-generation-events","content":"When a Redis-backed conversation stores its first turn, NeuroLink generates a title for it in the background and saves it on the session (listSessions() reports it). Once the title is stored, the SDK's event emitter fires conversation:titleGenerated.\n\nPayload (ConversationTitleGeneratedEvent):\n\n| Property | Type | Description |\n| ----------- | -------- | ---------------------------------------------------- |\n| sessionId | string | Session the title belongs to |\n| userId | string | User that owns the session (randomUser when unset) |\n| title | string | The title that was stored |\n| timestamp | number | Unix epoch milliseconds when the title was stored |\n\nNotes:\nThe event fires once per conversation, on the first turn, not on later turns.\nOnly Redis-backed memory generates titles; in-memory storage lists sessions by session ID.\nIf the summarization provider cannot answer, the stored title falls back to the first 30 characters of the message plus ..., and the event carries that fallback.\nSet NEUROLINK_TITLE_PROMPT to customize the title prompt. ${userMessage} is replaced with the user's message.","hierarchy":{"lvl0":"Memory","lvl1":"Conversation Memory","lvl2":"๐Ÿท๏ธ Title Generation Events","lvl3":""}},
8478
8480
  {"objectID":"63f2feb8c208abf16abfab0606af7eb1d9d51bcbc584182610a3d692a41ef777","title":"Turn Limits","url":"/docs/memory/conversation#turn-limits","content":"When the number of conversation turns exceeds maxTurnsPerSession, older messages are automatically removed:","hierarchy":{"lvl0":"Memory","lvl1":"Conversation Memory","lvl2":"Turn Limits","lvl3":""}},
8479
8481
  {"objectID":"211814691635003dcae6fae6c3c3e7cb5b400ba93b6f4ad45fdec9423659ec0c","title":"Session Limits","url":"/docs/memory/conversation#session-limits","content":"When the number of active sessions exceeds maxSessions, the least recently used sessions are removed:","hierarchy":{"lvl0":"Memory","lvl1":"Conversation Memory","lvl2":"Session Limits","lvl3":""}},
8480
8482
  {"objectID":"11e00a73bb57324fcdab4d4130bf0f98bb4cb3b754b4e558e2feb4474e73a1d3","title":"Memory Statistics","url":"/docs/memory/conversation#memory-statistics","content":"Memory Statistics","hierarchy":{"lvl0":"Memory","lvl1":"Conversation Memory","lvl2":"Memory Statistics","lvl3":""}},
@@ -10349,6 +10351,7 @@
10349
10351
  {"objectID":"d79631a303031924a7185daa0471458026c9d9ef6bee4a13e49d9ce0610262b9","title":"Event System","url":"/docs/sdk/api-reference#event-system","content":"NeuroLink emits events throughout the generation and streaming lifecycle through a TypedEventEmitter. NeuroLink does not extend EventEmitter itself, so there is no neurolink.on(): get the emitter with getEventEmitter(), subscribe with on() and unsubscribe with off().","hierarchy":{"lvl0":"Sdk","lvl1":"API Reference","lvl2":"Event System","lvl3":""}},
10350
10352
  {"objectID":"357bbb718f458d764e00524826a1d42a64da83167df93a52c04d9ddec3651764","title":"Core Events","url":"/docs/sdk/api-reference#core-events","content":"| Event | Emitted When |\n| ------------------ | ------------------------------------ |\n| generation:start | A generate() call begins |\n| generation:end | A generate() call completes |\n| stream:start | A stream() call begins |\n| stream:chunk | A new chunk arrives during streaming |\n| stream:end | Streaming completes normally |\n| stream:complete | Stream fully consumed |\n| stream:error | An error occurs during streaming |\n| tool:start | A tool execution begins |\n| tool:end | A tool execution completes |\n| response:start | A provider response begins |\n| response:end | A provider response completes |","hierarchy":{"lvl0":"Sdk","lvl1":"API Reference","lvl2":"Core Events","lvl3":""}},
10351
10353
  {"objectID":"efcf19aa651c13dbc72ef4b3d0f83986ee180008a076c0db030509880e4d4b1a","title":"MCP Server Events","url":"/docs/sdk/api-reference#mcp-server-events","content":"| Event | Emitted When |\n| -------------------------------- | ----------------------------------------- |\n| externalMCP:serverConnected | An external MCP server connects |\n| externalMCP:serverDisconnected | An external MCP server disconnects |\n| externalMCP:serverFailed | An external MCP server connection fails |\n| externalMCP:toolDiscovered | A new tool is discovered on an MCP server |\n| externalMCP:toolRemoved | A tool is removed from an MCP server |\n| externalMCP:serverAdded | A new MCP server registration is added |\n| externalMCP:serverRemoved | An MCP server registration is removed |","hierarchy":{"lvl0":"Sdk","lvl1":"API Reference","lvl2":"MCP Server Events","lvl3":""}},
10354
+ {"objectID":"e6691df9653e15f2a7a988af6dbe15f86784234b7aa7030fa74880e053d1e262","title":"Conversation Memory Events","url":"/docs/sdk/api-reference#conversation-memory-events","content":"| Event | Emitted When |\n| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |\n| conversation:titleGenerated | A new Redis-backed conversation's title is stored (see Conversation Memory) |","hierarchy":{"lvl0":"Sdk","lvl1":"API Reference","lvl2":"Conversation Memory Events","lvl3":""}},
10352
10355
  {"objectID":"c4d157804d0d96f1d8571e6aabeff4305aca0c07c151894dee3804d611331de6","title":"Other Events","url":"/docs/sdk/api-reference#other-events","content":"| Event | Emitted When |\n| ---------------------- | ----------------------------------- |\n| tools-register:start | Tool registration process begins |\n| tools-register:end | Tool registration process completes |\n| connected | Connection established |\n| message | General message event |\n| error | An error occurs |\n| log | A log message is emitted |\n| log-event | A structured log event is emitted |\n\nTypedEventEmitter Interface:","hierarchy":{"lvl0":"Sdk","lvl1":"API Reference","lvl2":"Other Events","lvl3":""}},
10353
10356
  {"objectID":"7ff1b31f163c4928ce88a79da3c279d1c1c6351ccf3cc5ad2464d2a03174f308","title":"Related Features","url":"/docs/sdk/api-reference#related-features","content":"Human-in-the-Loop (HITL) - Mark tools with requiresConfirmation: true\nGuardrails Middleware - Set middleware per call, in new NeuroLink({ middleware }) or with configureGlobalMiddleware(); add badWords or modelFilter to filter\nConversation History - Use getConversationHistory() method\nMultimodal Chat - Use images array in generate() options\nAuto Evaluation - Enable with enableEvaluation: true\nCLI Loop Sessions - Interactive mode with persistent state\nProvider Orchestration - Set enableOrchestration: true\nRegional Streaming - Use region parameter in generate()\nOffice Documents - Use the files array (or --file) for DOCX, PPTX, XLSX\nPDF Support - Use pdfFiles array for PDF documents\nCSV Support - Use csvFiles array for spreadsheet data\nCLI Commands Reference - CLI equivalents for all SDK methods\nConfiguration Guide - Environment variables and config files\nTroubleshooting - Common SDK issues and solutions\n\nBack to Main README | Next: Visual Demos","hierarchy":{"lvl0":"Sdk","lvl1":"API Reference","lvl2":"Related Features","lvl3":""}},
10354
10357
  {"objectID":"72ff7213f71cd3e590c196c5a1a39a7ab2af152776936e1a647f228cae34de6e","title":"๐Ÿ”ง SDK Custom Tools Guide","url":"/docs/sdk/custom-tools-guide","content":"๐Ÿ”ง SDK Custom Tools Guide\n\nBuild powerful AI applications by extending NeuroLink with your own custom tools.\n\n๐Ÿ“‹ Overview\n\nNeuroLink's SDK allows you to register custom tools programmatically, giving your AI assistants access to any functionality you need. All registered tools work seamlessly with the built-in tool system across all supported providers.\n\nKey Features\nโœ… Type-Safe: Full TypeScript support with Zod schema validation\nโœ… Provider Agnostic: Works with all providers that support tools\nโœ… Easy Integration: Simple API for tool registration\nโœ… Async Support: All tools run asynchronously\nโœ… Error Handling: Graceful error handling built-in\n\n๐Ÿš€ Quick Start\n\nBasic Tool Registration\n\nโš ๏ธ Common Mistakes\n\nโŒ Using schema instead of parameters\n\nโŒ Using plain JSON schema as parameters\n\nโœ… Correct Zod Schema Format\n\n๐Ÿ“– SimpleTool Interface\n\nAll custom tools implement the SimpleTool interface:\n\nInterface Components\ndescription: Clear, actionable description that helps the AI understand when to use the tool\nparameters: Optional Zod schema for validating inputs (highly recommended)\nexecute: Async function that implements the tool's logic\n\n๐Ÿ› ๏ธ Registration Methods\n\nRegister Single Tool\n\nRegister Multiple Tools\n\nGet Custom Tools\n\n๐Ÿ’ก Common Use Cases\nAPI Integration\nDatabase Operations\nData Processing\nFile Operations\nExternal Service Integration\n\n๐ŸŽฏ Best Practices\nClear Descriptions\n\nMake tool descriptions specific and actionable:\nParameter Validation\n\nAlways use Zod schemas for type safety:\nError Handling\n\nHandle errors gracefully:\n\nA returned error is classified as a failure everywhere the SDK reports one,\nexactly as a thrown error is. A result is error-shaped when it carries\nisError: true (the MCP convention), a non-null error field ({ error:\n\"User not found\" }), or a status of \"error\" / \"failed\" / \"failure\" /\n\"fail\". Such a call emits tool:end with success: false and the error\ntext, is stored in session memory as success: false, replays on later turns\nas [called <tool> โ†’ error], and is reported with isError: true in\nresult.toolExecutions. The model still receives the full object you\nreturned โ€” classification only affects telemetry and memory, never what the\nmodel sees.\nAsync Operations\n\nAll execute functions must return promises:\nTool Naming\n\nUse clear, consistent naming:\n\n๐Ÿงช Testing Your Tools\n\nUnit Testing\n\nIntegration Testing\n\n๐Ÿ” Debugging Tools\n\nEnable Debug Mode\n\nLog Tool Execution\n\n๐Ÿš€ Advanced Patterns\n\nTool Composition\n\nTool Middleware\n\nDynamic Tool Registration\n\nForcing a Tool Call\n\ntoolChoice tells the model whether it must call a tool on a step:\n\n| Value | Effect |\n| --------------------------------- | ------------------------------------------------ |\n| \"auto\" (default) | The model decides whether and which tool to call |\n| \"none\" | No tool calls on any step |\n| \"required\" | The model must call at least one tool |\n| { type: \"tool\", toolName: \"x\" } | The model must call the named tool |\n\nA forced choice (\"required\" or a named tool) is applied only to the first\ntoolChoiceSteps steps of the tool loop โ€” default 1 โ€” after which the\nmodel is free to answer. Holding a forced choice on every step would compel\na tool call on every step, and the turn could only end when maxSteps ran\nout. \"auto\" and \"none\" are applied unchanged on every step.\n\nFor anything finer, prepareStep runs before every step and may return a\ntoolChoice for that step, which takes precedence over toolChoiceSteps:\n\nprepareStep receives { stepNumber, steps, maxSteps, model }, where steps\nholds one record per completed step (its text, tool calls โ€” with input\nalready parsed into an object โ€” tool results, finish reason and usage,\nincluding prompt-cache tokens where the provider reports them). Only the\nreturned toolChoice is honoured; the legacy model and\nexperimental_activeTools / activeTools fields are accepted for source\ncompatibility but ignored, and their presence is logged once as a warning โ€”\nuse toolFilter / excludeTools to scope tools. A hook that throws is\nlogged and that step falls back to the toolChoice / toolChoiceSteps rule;\na hook still pending when the turn is aborted or times out is released with\nthe abort. Both toolChoice and prepareStep apply to stream() as well.\n\nVertex, Google AI Studio and Bedrock do not honour toolChoice at all today.\nSageMaker honours tools, toolChoice and prepareStep on generate()\nonly: its stream() sends the prompt without tools.\n\n๐Ÿ“Š Performance Considerations\nTimeout Handling\nCaching\nBatch Operations\n\n๐Ÿ”’ Security Considerations\n\nInput Sanitization\n\nPermission Checking\n\nRate Limiting\n\n๐ŸŽ‰ Complete Example\n\nHere's a complete example combining multiple concepts:\n\n๐ŸŒ MCP Server Integration\n\nBeyond simple tool registration, NeuroLink SDK supports adding complete MCP (Model Context Protocol) servers for more complex tool ecosystems.\n\nAdding I","hierarchy":{"lvl0":"Sdk","lvl1":"๐Ÿ”ง SDK Custom Tools Guide","lvl2":"","lvl3":""}},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "13.8.15",
3
+ "version": "13.8.17",
4
4
  "packageManager": "pnpm@10.28.2",
5
5
  "description": "The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types โ€” generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002/call) for routing, tool selection and context budgeting. MCP-native (4 transports), voice TTS/STT/realtime, RAG, agents, memory, compaction, 9 observability exporters. OpenAI ยท Anthropic ยท Gemini ยท Bedrock ยท Azure ยท Ollama ยท TypeSafe Jev and more.",
6
6
  "author": {