@lmnr-ai/claude-code-proxy 0.1.10 → 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 +9 -3
- package/dist/index.js +17 -16
- package/package.json +8 -8
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.
|
|
151
|
+
native.stopWithTimeout(this.port, 4);
|
|
152
152
|
}
|
|
153
153
|
catch {
|
|
154
154
|
// Server might already be dead
|
|
@@ -198,12 +198,14 @@ class ProxyServer {
|
|
|
198
198
|
this.monitorInterval = setInterval(() => {
|
|
199
199
|
this.healthCheckMonitor().catch(() => { });
|
|
200
200
|
}, HEALTH_CHECK_INTERVAL);
|
|
201
|
-
console.info(`Started proxy server with health monitoring on port ${this.port}`);
|
|
202
201
|
}
|
|
203
202
|
/**
|
|
204
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.
|
|
205
207
|
*/
|
|
206
|
-
stopServer() {
|
|
208
|
+
stopServer(timeout = 4) {
|
|
207
209
|
// Stop the monitor
|
|
208
210
|
if (this.monitorInterval !== null) {
|
|
209
211
|
clearInterval(this.monitorInterval);
|
|
@@ -211,15 +213,11 @@ class ProxyServer {
|
|
|
211
213
|
}
|
|
212
214
|
// Reset the health check flag
|
|
213
215
|
this.isHealthCheckRunning = false;
|
|
214
|
-
//
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
catch (error) {
|
|
220
|
-
console.debug(`Error stopping the proxy server on port ${this.port}: ${error}`);
|
|
221
|
-
}
|
|
222
|
-
console.debug(`Stopped proxy server and health monitoring on port ${this.port}`);
|
|
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);
|
|
223
221
|
}
|
|
224
222
|
/**
|
|
225
223
|
* Check if the server is currently running.
|
|
@@ -273,9 +271,12 @@ function runServer(url, port = 45667) {
|
|
|
273
271
|
*
|
|
274
272
|
* This is a backwards-compatible function that uses a global singleton instance.
|
|
275
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.
|
|
276
277
|
*/
|
|
277
|
-
function stopServer() {
|
|
278
|
-
getGlobalProxy().stopServer();
|
|
278
|
+
function stopServer(timeout = 4) {
|
|
279
|
+
getGlobalProxy().stopServer(timeout);
|
|
279
280
|
}
|
|
280
281
|
/**
|
|
281
282
|
* Set the current trace context by sending an HTTP request to the running proxy server.
|
|
@@ -290,4 +291,4 @@ async function setCurrentTrace(context) {
|
|
|
290
291
|
return getGlobalProxy().setCurrentTrace(context);
|
|
291
292
|
}
|
|
292
293
|
// Re-export native functions for direct access if needed
|
|
293
|
-
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.
|
|
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.
|
|
27
|
-
"@lmnr-ai/claude-code-proxy-darwin-x64": "0.1.
|
|
28
|
-
"@lmnr-ai/claude-code-proxy-win32-x64-msvc": "0.1.
|
|
29
|
-
"@lmnr-ai/claude-code-proxy-linux-x64-gnu": "0.1.
|
|
30
|
-
"@lmnr-ai/claude-code-proxy-linux-arm64-gnu": "0.1.
|
|
31
|
-
"@lmnr-ai/claude-code-proxy-linux-x64-musl": "0.1.
|
|
32
|
-
"@lmnr-ai/claude-code-proxy-linux-arm64-musl": "0.1.
|
|
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",
|