@lmnr-ai/claude-code-proxy 0.1.11 → 0.1.12

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/dist/index.d.ts CHANGED
@@ -67,8 +67,11 @@ export declare class ProxyServer {
67
67
  runServer(url: string): void;
68
68
  /**
69
69
  * Stop the proxy server and its health monitoring.
70
+ *
71
+ * @param timeout - Maximum time in seconds to wait for graceful shutdown (default: 4).
72
+ * The server will abort pending connections and background tasks after timeout/2.
70
73
  */
71
- stopServer(): void;
74
+ stopServer(timeout?: number): void;
72
75
  /**
73
76
  * Check if the server is currently running.
74
77
  */
@@ -96,8 +99,11 @@ export declare function runServer(url: string, port?: number): void;
96
99
  *
97
100
  * This is a backwards-compatible function that uses a global singleton instance.
98
101
  * For more control, consider creating your own ProxyServer instance.
102
+ *
103
+ * @param timeout - Maximum time in seconds to wait for graceful shutdown (default: 4).
104
+ * The server will abort pending connections and background tasks after timeout/2.
99
105
  */
100
- export declare function stopServer(): void;
106
+ export declare function stopServer(timeout?: number): void;
101
107
  /**
102
108
  * Set the current trace context by sending an HTTP request to the running proxy server.
103
109
  *
@@ -108,4 +114,4 @@ export declare function stopServer(): void;
108
114
  * @throws Error if the HTTP request fails
109
115
  */
110
116
  export declare function setCurrentTrace(context: SpanContext): Promise<void>;
111
- export declare const run: any, stop: any;
117
+ export declare const run: any, stop: any, stopWithTimeout: any;
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Laminar Claude Code Proxy - TypeScript/JavaScript bindings for HTTP proxy server
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.stop = exports.run = exports.ProxyServer = void 0;
6
+ exports.stopWithTimeout = exports.stop = exports.run = exports.ProxyServer = void 0;
7
7
  exports.runServer = runServer;
8
8
  exports.stopServer = stopServer;
9
9
  exports.setCurrentTrace = setCurrentTrace;
@@ -148,7 +148,7 @@ class ProxyServer {
148
148
  try {
149
149
  // Try to stop the existing server (it might be stuck)
150
150
  try {
151
- native.stop(this.port);
151
+ native.stopWithTimeout(this.port, 4);
152
152
  }
153
153
  catch {
154
154
  // Server might already be dead
@@ -201,8 +201,11 @@ class ProxyServer {
201
201
  }
202
202
  /**
203
203
  * Stop the proxy server and its health monitoring.
204
+ *
205
+ * @param timeout - Maximum time in seconds to wait for graceful shutdown (default: 4).
206
+ * The server will abort pending connections and background tasks after timeout/2.
204
207
  */
205
- stopServer() {
208
+ stopServer(timeout = 4) {
206
209
  // Stop the monitor
207
210
  if (this.monitorInterval !== null) {
208
211
  clearInterval(this.monitorInterval);
@@ -210,13 +213,11 @@ class ProxyServer {
210
213
  }
211
214
  // Reset the health check flag
212
215
  this.isHealthCheckRunning = false;
213
- // Stop the server
214
- try {
215
- native.stop(this.port);
216
- this._isRunning = false;
217
- }
218
- catch {
219
- }
216
+ // Once we stop monitoring, we've lost active management of the server,
217
+ // so we mark it as not running regardless of shutdown success
218
+ this._isRunning = false;
219
+ // Stop the server and re-throw any errors to inform caller
220
+ native.stopWithTimeout(this.port, timeout);
220
221
  }
221
222
  /**
222
223
  * Check if the server is currently running.
@@ -270,9 +271,12 @@ function runServer(url, port = 45667) {
270
271
  *
271
272
  * This is a backwards-compatible function that uses a global singleton instance.
272
273
  * For more control, consider creating your own ProxyServer instance.
274
+ *
275
+ * @param timeout - Maximum time in seconds to wait for graceful shutdown (default: 4).
276
+ * The server will abort pending connections and background tasks after timeout/2.
273
277
  */
274
- function stopServer() {
275
- getGlobalProxy().stopServer();
278
+ function stopServer(timeout = 4) {
279
+ getGlobalProxy().stopServer(timeout);
276
280
  }
277
281
  /**
278
282
  * Set the current trace context by sending an HTTP request to the running proxy server.
@@ -287,4 +291,4 @@ async function setCurrentTrace(context) {
287
291
  return getGlobalProxy().setCurrentTrace(context);
288
292
  }
289
293
  // Re-export native functions for direct access if needed
290
- exports.run = native.run, exports.stop = native.stop;
294
+ exports.run = native.run, exports.stop = native.stop, exports.stopWithTimeout = native.stopWithTimeout;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lmnr-ai/claude-code-proxy",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "HTTP proxy for Claude Desktop API requests with Laminar observability",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -23,13 +23,13 @@
23
23
  "dist"
24
24
  ],
25
25
  "optionalDependencies": {
26
- "@lmnr-ai/claude-code-proxy-darwin-arm64": "0.1.11",
27
- "@lmnr-ai/claude-code-proxy-darwin-x64": "0.1.11",
28
- "@lmnr-ai/claude-code-proxy-win32-x64-msvc": "0.1.11",
29
- "@lmnr-ai/claude-code-proxy-linux-x64-gnu": "0.1.11",
30
- "@lmnr-ai/claude-code-proxy-linux-arm64-gnu": "0.1.11",
31
- "@lmnr-ai/claude-code-proxy-linux-x64-musl": "0.1.11",
32
- "@lmnr-ai/claude-code-proxy-linux-arm64-musl": "0.1.11"
26
+ "@lmnr-ai/claude-code-proxy-darwin-arm64": "0.1.12",
27
+ "@lmnr-ai/claude-code-proxy-darwin-x64": "0.1.12",
28
+ "@lmnr-ai/claude-code-proxy-win32-x64-msvc": "0.1.12",
29
+ "@lmnr-ai/claude-code-proxy-linux-x64-gnu": "0.1.12",
30
+ "@lmnr-ai/claude-code-proxy-linux-arm64-gnu": "0.1.12",
31
+ "@lmnr-ai/claude-code-proxy-linux-x64-musl": "0.1.12",
32
+ "@lmnr-ai/claude-code-proxy-linux-arm64-musl": "0.1.12"
33
33
  },
34
34
  "keywords": [
35
35
  "claude",