@hilbras/sdk 3.4.2 → 3.4.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.
- package/README.md +2 -2
- package/dist/transport/fetch.d.ts +9 -0
- package/dist/transport/fetch.js +16 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="https://img.shields.io/badge/version-3.4.
|
|
2
|
+
<img src="https://img.shields.io/badge/version-3.4.3-blue" alt="version">
|
|
3
3
|
<img src="https://img.shields.io/badge/license-MIT-green" alt="license">
|
|
4
4
|
<img src="https://img.shields.io/badge/node-%3E%3D18-brightgreen" alt="node">
|
|
5
5
|
<img src="https://img.shields.io/badge/types-strict-blueviolet" alt="types">
|
|
6
|
-
<img src="https://img.shields.io/badge/tests-
|
|
6
|
+
<img src="https://img.shields.io/badge/tests-1809%20passing-brightgreen" alt="tests">
|
|
7
7
|
<img src="https://img.shields.io/badge/runtime%20deps-zero-brightgreen" alt="zero deps">
|
|
8
8
|
</p>
|
|
9
9
|
|
|
@@ -26,6 +26,15 @@ export declare class FetchTransport implements Transport {
|
|
|
26
26
|
private _coalesce;
|
|
27
27
|
private _cleanupTimer;
|
|
28
28
|
constructor(options?: FetchTransportOptions);
|
|
29
|
+
/**
|
|
30
|
+
* Start the idle-connection cleanup timer on first use.
|
|
31
|
+
*
|
|
32
|
+
* The timer is deliberately lazy. A client that never issues a request —
|
|
33
|
+
* including one whose constructor throws before the caller can dispose it —
|
|
34
|
+
* then holds no interval, so a failed construction cannot leave a repeating
|
|
35
|
+
* timer that pins the Node event loop open.
|
|
36
|
+
*/
|
|
37
|
+
private _ensureCleanupTimer;
|
|
29
38
|
private _getOrigin;
|
|
30
39
|
private _acquire;
|
|
31
40
|
private _release;
|
package/dist/transport/fetch.js
CHANGED
|
@@ -20,10 +20,21 @@ export class FetchTransport {
|
|
|
20
20
|
this._maxConnections = options.maxConnectionsPerOrigin ?? 6;
|
|
21
21
|
this._idleTimeout = options.idleTimeout ?? 30000;
|
|
22
22
|
this._coalesce = options.coalesceRequests ?? false;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Start the idle-connection cleanup timer on first use.
|
|
26
|
+
*
|
|
27
|
+
* The timer is deliberately lazy. A client that never issues a request —
|
|
28
|
+
* including one whose constructor throws before the caller can dispose it —
|
|
29
|
+
* then holds no interval, so a failed construction cannot leave a repeating
|
|
30
|
+
* timer that pins the Node event loop open.
|
|
31
|
+
*/
|
|
32
|
+
_ensureCleanupTimer() {
|
|
33
|
+
if (this._cleanupTimer !== null || typeof setInterval === "undefined")
|
|
34
|
+
return;
|
|
35
|
+
this._cleanupTimer = setInterval(() => this._cleanupPools(), this._idleTimeout);
|
|
36
|
+
// Never keep a process alive just to age out an idle connection pool.
|
|
37
|
+
this._cleanupTimer.unref?.();
|
|
27
38
|
}
|
|
28
39
|
_getOrigin(url) {
|
|
29
40
|
try {
|
|
@@ -76,6 +87,7 @@ export class FetchTransport {
|
|
|
76
87
|
return JSON.stringify([init.method || "GET", url, init.body ?? "", headers]);
|
|
77
88
|
}
|
|
78
89
|
async request(url, init) {
|
|
90
|
+
this._ensureCleanupTimer();
|
|
79
91
|
const origin = this._getOrigin(url);
|
|
80
92
|
const externalSignal = init.signal;
|
|
81
93
|
if (externalSignal?.aborted) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hilbras/sdk",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.3",
|
|
4
4
|
"description": "Provider-agnostic LLM client SDK — streaming, tool calling, embeddings, image generation, speech synthesis, transcription, reranking, circuit breaker, retry, reasoning normalization, cost enforcement, structured output with schema validation, type-safe tool builder, and SSRF-safe provider registration. Zero runtime dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|