@juspay/neurolink 12.35.2 → 12.35.3

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.
@@ -28,8 +28,12 @@ export declare abstract class BaseServerAdapter extends EventEmitter {
28
28
  constructor(neurolink: NeuroLink, config?: ServerAdapterConfig);
29
29
  /**
30
30
  * Initialize the underlying server framework
31
+ * May be async: adapters that dynamically import their framework package
32
+ * (e.g. Hono) return a Promise; adapters with a synchronous no-op stub that
33
+ * defer real setup to their own overridden `initialize()` (Express/Fastify/
34
+ * Koa) still return void.
31
35
  */
32
- protected abstract initializeFramework(): void;
36
+ protected abstract initializeFramework(): void | Promise<void>;
33
37
  /**
34
38
  * Register a route with the framework
35
39
  */
@@ -145,7 +145,7 @@ export class BaseServerAdapter extends EventEmitter {
145
145
  const startTime = Date.now();
146
146
  try {
147
147
  // Initialize framework-specific setup
148
- this.initializeFramework();
148
+ await this.initializeFramework();
149
149
  // Register built-in middleware
150
150
  this.registerBuiltInMiddleware();
151
151
  // Register built-in routes
@@ -16,6 +16,8 @@ export declare class HonoServerAdapter extends BaseServerAdapter {
16
16
  private rateLimitStore;
17
17
  private rateLimitCleanupInterval?;
18
18
  private requestContextStore;
19
+ private HTTPExceptionCtor;
20
+ private streamSSEFn;
19
21
  constructor(neurolink: NeuroLink, config?: ServerAdapterConfig);
20
22
  /**
21
23
  * Create rate limiter middleware for Hono
@@ -27,8 +29,10 @@ export declare class HonoServerAdapter extends BaseServerAdapter {
27
29
  private cleanupRateLimitStore;
28
30
  /**
29
31
  * Initialize Hono framework
32
+ * Dynamically imports Hono and its middleware so requiring only another
33
+ * adapter (Express/Fastify/Koa) never pulls Hono's import graph in.
30
34
  */
31
- protected initializeFramework(): void;
35
+ protected initializeFramework(): Promise<void>;
32
36
  /**
33
37
  * Register route with Hono
34
38
  */
@@ -3,13 +3,6 @@
3
3
  * Primary server adapter implementation using Hono framework
4
4
  * Hono is chosen for its performance, TypeScript-first design, and edge compatibility
5
5
  */
6
- import { Hono } from "hono";
7
- import { cors } from "hono/cors";
8
- import { HTTPException } from "hono/http-exception";
9
- import { logger as honoLogger } from "hono/logger";
10
- import { secureHeaders } from "hono/secure-headers";
11
- import { streamSSE } from "hono/streaming";
12
- import { timeout } from "hono/timeout";
13
6
  import { logger } from "../../utils/logger.js";
14
7
  import { AlreadyRunningError, ServerStopError, wrapError } from "../errors.js";
15
8
  import { BaseServerAdapter } from "../abstract/baseServerAdapter.js";
@@ -25,6 +18,11 @@ export class HonoServerAdapter extends BaseServerAdapter {
25
18
  rateLimitCleanupInterval;
26
19
  // Store context by request ID for sharing between middleware and route handlers
27
20
  requestContextStore = new Map();
21
+ // Populated by initializeFramework's dynamic imports; used by methods that
22
+ // run after initialization (route registration, streaming) and so cannot
23
+ // rely on initializeFramework's own local closure variables.
24
+ HTTPExceptionCtor;
25
+ streamSSEFn;
28
26
  constructor(neurolink, config = {}) {
29
27
  super(neurolink, config);
30
28
  }
@@ -113,8 +111,21 @@ export class HonoServerAdapter extends BaseServerAdapter {
113
111
  }
114
112
  /**
115
113
  * Initialize Hono framework
114
+ * Dynamically imports Hono and its middleware so requiring only another
115
+ * adapter (Express/Fastify/Koa) never pulls Hono's import graph in.
116
116
  */
117
- initializeFramework() {
117
+ async initializeFramework() {
118
+ const [{ Hono }, { cors }, { HTTPException }, { logger: honoLogger }, { secureHeaders }, { streamSSE }, { timeout },] = await Promise.all([
119
+ this.importFrameworkDependency("hono", "hono"),
120
+ this.importFrameworkDependency("hono/cors", "hono"),
121
+ this.importFrameworkDependency("hono/http-exception", "hono"),
122
+ this.importFrameworkDependency("hono/logger", "hono"),
123
+ this.importFrameworkDependency("hono/secure-headers", "hono"),
124
+ this.importFrameworkDependency("hono/streaming", "hono"),
125
+ this.importFrameworkDependency("hono/timeout", "hono"),
126
+ ]);
127
+ this.HTTPExceptionCtor = HTTPException;
128
+ this.streamSSEFn = streamSSE;
118
129
  this.app = new Hono();
119
130
  // Add secure headers
120
131
  this.app.use("*", secureHeaders());
@@ -284,7 +295,7 @@ export class HonoServerAdapter extends BaseServerAdapter {
284
295
  route: route.path,
285
296
  error: errorMessage,
286
297
  });
287
- throw new HTTPException(500, { message: errorMessage });
298
+ throw new this.HTTPExceptionCtor(500, { message: errorMessage });
288
299
  }
289
300
  finally {
290
301
  // Untrack connection when request completes
@@ -304,7 +315,7 @@ export class HonoServerAdapter extends BaseServerAdapter {
304
315
  c.header(key, value);
305
316
  }
306
317
  }
307
- return streamSSE(c, async (stream) => {
318
+ return this.streamSSEFn(c, async (stream) => {
308
319
  try {
309
320
  // Get streaming result from handler
310
321
  const result = await route.handler(ctx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "12.35.2",
3
+ "version": "12.35.3",
4
4
  "packageManager": "pnpm@10.15.1",
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": {