@node-llm/core 1.17.0 → 1.17.1
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/aliases.d.ts +561 -371
- package/dist/aliases.d.ts.map +1 -1
- package/dist/aliases.js +634 -444
- package/dist/chat/Chat.d.ts +1 -0
- package/dist/chat/Chat.d.ts.map +1 -1
- package/dist/chat/Chat.js +5 -1
- package/dist/chat/ChatOptions.d.ts +1 -0
- package/dist/chat/ChatOptions.d.ts.map +1 -1
- package/dist/chat/ToolHandler.d.ts.map +1 -1
- package/dist/chat/ToolHandler.js +15 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +3 -0
- package/dist/errors/index.d.ts +3 -1
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +4 -1
- package/dist/executor/Executor.d.ts +6 -0
- package/dist/executor/Executor.d.ts.map +1 -1
- package/dist/executor/Executor.js +19 -2
- package/dist/models/models.json +9274 -6310
- package/dist/providers/anthropic/Models.d.ts.map +1 -1
- package/dist/providers/anthropic/Models.js +4 -2
- package/dist/providers/deepseek/Models.d.ts.map +1 -1
- package/dist/providers/deepseek/Models.js +4 -2
- package/dist/providers/gemini/Embeddings.d.ts.map +1 -1
- package/dist/providers/gemini/Embeddings.js +4 -2
- package/dist/providers/gemini/Image.d.ts.map +1 -1
- package/dist/providers/gemini/Image.js +4 -2
- package/dist/providers/gemini/Models.d.ts.map +1 -1
- package/dist/providers/gemini/Models.js +4 -2
- package/dist/providers/gemini/Transcription.d.ts.map +1 -1
- package/dist/providers/gemini/Transcription.js +4 -2
- package/dist/providers/mistral/Embedding.d.ts.map +1 -1
- package/dist/providers/mistral/Embedding.js +4 -2
- package/dist/providers/mistral/Models.d.ts.map +1 -1
- package/dist/providers/mistral/Models.js +4 -2
- package/dist/providers/openai/Models.d.ts.map +1 -1
- package/dist/providers/openai/Models.js +4 -2
- package/dist/providers/openrouter/Models.d.ts.map +1 -1
- package/dist/providers/openrouter/Models.js +4 -2
- package/dist/utils/Binary.d.ts.map +1 -1
- package/dist/utils/Binary.js +11 -0
- package/dist/utils/FileLoader.d.ts.map +1 -1
- package/dist/utils/FileLoader.js +21 -2
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +8 -1
- package/package.json +10 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Models.d.ts","sourceRoot":"","sources":["../../../src/providers/anthropic/Models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Models.d.ts","sourceRoot":"","sources":["../../../src/providers/anthropic/Models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAM3C,qBAAa,eAAe;IAExB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM;IAG3B,OAAO,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAyDrC,IAAI,CAAC,OAAO,EAAE,MAAM;CAGrB"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { config } from "../../config.js";
|
|
2
|
+
import { fetchWithTimeout } from "../../utils/fetch.js";
|
|
1
3
|
import { Capabilities } from "./Capabilities.js";
|
|
2
4
|
import { ModelRegistry } from "../../models/ModelRegistry.js";
|
|
3
5
|
export class AnthropicModels {
|
|
@@ -9,14 +11,14 @@ export class AnthropicModels {
|
|
|
9
11
|
}
|
|
10
12
|
async execute() {
|
|
11
13
|
try {
|
|
12
|
-
const response = await
|
|
14
|
+
const response = await fetchWithTimeout(`${this.baseUrl}/models`, {
|
|
13
15
|
method: "GET",
|
|
14
16
|
headers: {
|
|
15
17
|
"x-api-key": this.apiKey,
|
|
16
18
|
"anthropic-version": "2023-06-01",
|
|
17
19
|
"content-type": "application/json"
|
|
18
20
|
}
|
|
19
|
-
});
|
|
21
|
+
}, config.requestTimeout);
|
|
20
22
|
if (response.ok) {
|
|
21
23
|
const { data } = (await response.json());
|
|
22
24
|
return data.map((m) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Models.d.ts","sourceRoot":"","sources":["../../../src/providers/deepseek/Models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Models.d.ts","sourceRoot":"","sources":["../../../src/providers/deepseek/Models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAiB3C,qBAAa,cAAc;IAEvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM;IAG3B,OAAO,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;CAmEtC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { config } from "../../config.js";
|
|
2
|
+
import { fetchWithTimeout } from "../../utils/fetch.js";
|
|
1
3
|
import { Capabilities } from "./Capabilities.js";
|
|
2
4
|
import { ModelRegistry } from "../../models/ModelRegistry.js";
|
|
3
5
|
export class DeepSeekModels {
|
|
@@ -8,12 +10,12 @@ export class DeepSeekModels {
|
|
|
8
10
|
this.apiKey = apiKey;
|
|
9
11
|
}
|
|
10
12
|
async execute() {
|
|
11
|
-
const response = await
|
|
13
|
+
const response = await fetchWithTimeout(`${this.baseUrl}/models`, {
|
|
12
14
|
method: "GET",
|
|
13
15
|
headers: {
|
|
14
16
|
Authorization: `Bearer ${this.apiKey}`
|
|
15
17
|
}
|
|
16
|
-
});
|
|
18
|
+
}, config.requestTimeout);
|
|
17
19
|
if (!response.ok) {
|
|
18
20
|
// Fallback to local registry
|
|
19
21
|
const localModels = ModelRegistry.all()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Embeddings.d.ts","sourceRoot":"","sources":["../../../src/providers/gemini/Embeddings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Embeddings.d.ts","sourceRoot":"","sources":["../../../src/providers/gemini/Embeddings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAOrE,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM;IAG3B,OAAO,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CA+CrE"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { config } from "../../config.js";
|
|
2
|
+
import { fetchWithTimeout } from "../../utils/fetch.js";
|
|
1
3
|
import { handleGeminiError } from "./Errors.js";
|
|
2
4
|
import { logger } from "../../utils/logger.js";
|
|
3
5
|
export class GeminiEmbeddings {
|
|
@@ -26,11 +28,11 @@ export class GeminiEmbeddings {
|
|
|
26
28
|
})
|
|
27
29
|
};
|
|
28
30
|
logger.logRequest("Gemini", "POST", url, payload);
|
|
29
|
-
const response = await
|
|
31
|
+
const response = await fetchWithTimeout(url, {
|
|
30
32
|
method: "POST",
|
|
31
33
|
headers: { "Content-Type": "application/json" },
|
|
32
34
|
body: JSON.stringify(payload)
|
|
33
|
-
});
|
|
35
|
+
}, config.requestTimeout);
|
|
34
36
|
if (!response.ok) {
|
|
35
37
|
await handleGeminiError(response, modelId);
|
|
36
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../../src/providers/gemini/Image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../../src/providers/gemini/Image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAO7D,qBAAa,WAAW;IAEpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM;IAG3B,OAAO,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;CAqE7D"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { config } from "../../config.js";
|
|
2
|
+
import { fetchWithTimeout } from "../../utils/fetch.js";
|
|
1
3
|
import { handleGeminiError } from "./Errors.js";
|
|
2
4
|
import { logger } from "../../utils/logger.js";
|
|
3
5
|
import { BinaryUtils } from "../../utils/Binary.js";
|
|
@@ -36,13 +38,13 @@ export class GeminiImage {
|
|
|
36
38
|
}
|
|
37
39
|
};
|
|
38
40
|
logger.logRequest("Gemini", "POST", url, body);
|
|
39
|
-
const response = await
|
|
41
|
+
const response = await fetchWithTimeout(url, {
|
|
40
42
|
method: "POST",
|
|
41
43
|
headers: {
|
|
42
44
|
"Content-Type": "application/json"
|
|
43
45
|
},
|
|
44
46
|
body: JSON.stringify(body)
|
|
45
|
-
});
|
|
47
|
+
}, config.requestTimeout);
|
|
46
48
|
if (!response.ok) {
|
|
47
49
|
await handleGeminiError(response, modelId);
|
|
48
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Models.d.ts","sourceRoot":"","sources":["../../../src/providers/gemini/Models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Models.d.ts","sourceRoot":"","sources":["../../../src/providers/gemini/Models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAO3C,qBAAa,YAAY;IAErB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM;IAG3B,OAAO,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAuDrC,IAAI,CAAC,OAAO,EAAE,MAAM;CAGrB"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { config } from "../../config.js";
|
|
2
|
+
import { fetchWithTimeout } from "../../utils/fetch.js";
|
|
1
3
|
import { Capabilities } from "./Capabilities.js";
|
|
2
4
|
import { ModelRegistry } from "../../models/ModelRegistry.js";
|
|
3
5
|
export class GeminiModels {
|
|
@@ -9,12 +11,12 @@ export class GeminiModels {
|
|
|
9
11
|
}
|
|
10
12
|
async execute() {
|
|
11
13
|
try {
|
|
12
|
-
const response = await
|
|
14
|
+
const response = await fetchWithTimeout(`${this.baseUrl}/models?key=${this.apiKey}`, {
|
|
13
15
|
method: "GET",
|
|
14
16
|
headers: {
|
|
15
17
|
"Content-Type": "application/json"
|
|
16
18
|
}
|
|
17
|
-
});
|
|
19
|
+
}, config.requestTimeout);
|
|
18
20
|
if (response.ok) {
|
|
19
21
|
const { models } = (await response.json());
|
|
20
22
|
return models.map((m) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transcription.d.ts","sourceRoot":"","sources":["../../../src/providers/gemini/Transcription.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Transcription.d.ts","sourceRoot":"","sources":["../../../src/providers/gemini/Transcription.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAQ7E,qBAAa,mBAAmB;IAK5B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;IALzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CACuC;gBAG1D,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM;IAG3B,OAAO,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAkE7E"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { config } from "../../config.js";
|
|
2
|
+
import { fetchWithTimeout } from "../../utils/fetch.js";
|
|
1
3
|
import { handleGeminiError } from "./Errors.js";
|
|
2
4
|
import { BinaryUtils } from "../../utils/Binary.js";
|
|
3
5
|
import { logger } from "../../utils/logger.js";
|
|
@@ -44,13 +46,13 @@ export class GeminiTranscription {
|
|
|
44
46
|
}
|
|
45
47
|
};
|
|
46
48
|
logger.logRequest("Gemini", "POST", url, payload);
|
|
47
|
-
const response = await
|
|
49
|
+
const response = await fetchWithTimeout(url, {
|
|
48
50
|
method: "POST",
|
|
49
51
|
headers: {
|
|
50
52
|
"Content-Type": "application/json"
|
|
51
53
|
},
|
|
52
54
|
body: JSON.stringify(payload)
|
|
53
|
-
});
|
|
55
|
+
}, config.requestTimeout);
|
|
54
56
|
if (!response.ok) {
|
|
55
57
|
await handleGeminiError(response, model);
|
|
56
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Embedding.d.ts","sourceRoot":"","sources":["../../../src/providers/mistral/Embedding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Embedding.d.ts","sourceRoot":"","sources":["../../../src/providers/mistral/Embedding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAsBrE,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM;IAG3B,OAAO,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CA4CrE"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { config } from "../../config.js";
|
|
2
|
+
import { fetchWithTimeout } from "../../utils/fetch.js";
|
|
1
3
|
import { logger } from "../../utils/logger.js";
|
|
2
4
|
import { handleMistralError } from "./Errors.js";
|
|
3
5
|
import { MistralCapabilities } from "./Capabilities.js";
|
|
@@ -20,7 +22,7 @@ export class MistralEmbedding {
|
|
|
20
22
|
};
|
|
21
23
|
const url = `${this.baseUrl}/embeddings`;
|
|
22
24
|
logger.logRequest("Mistral Embeddings", "POST", url, body);
|
|
23
|
-
const response = await
|
|
25
|
+
const response = await fetchWithTimeout(url, {
|
|
24
26
|
method: "POST",
|
|
25
27
|
headers: {
|
|
26
28
|
Authorization: `Bearer ${this.apiKey}`,
|
|
@@ -28,7 +30,7 @@ export class MistralEmbedding {
|
|
|
28
30
|
Accept: "application/json"
|
|
29
31
|
},
|
|
30
32
|
body: JSON.stringify(body)
|
|
31
|
-
});
|
|
33
|
+
}, config.requestTimeout);
|
|
32
34
|
if (!response.ok) {
|
|
33
35
|
await handleMistralError(response, model);
|
|
34
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Models.d.ts","sourceRoot":"","sources":["../../../src/providers/mistral/Models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Models.d.ts","sourceRoot":"","sources":["../../../src/providers/mistral/Models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAkB3C,qBAAa,aAAa;IAEtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM;IAG3B,OAAO,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;CAuEtC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { config } from "../../config.js";
|
|
2
|
+
import { fetchWithTimeout } from "../../utils/fetch.js";
|
|
1
3
|
import { MistralCapabilities } from "./Capabilities.js";
|
|
2
4
|
import { ModelRegistry } from "../../models/ModelRegistry.js";
|
|
3
5
|
export class MistralModels {
|
|
@@ -8,13 +10,13 @@ export class MistralModels {
|
|
|
8
10
|
this.apiKey = apiKey;
|
|
9
11
|
}
|
|
10
12
|
async execute() {
|
|
11
|
-
const response = await
|
|
13
|
+
const response = await fetchWithTimeout(`${this.baseUrl}/models`, {
|
|
12
14
|
method: "GET",
|
|
13
15
|
headers: {
|
|
14
16
|
Authorization: `Bearer ${this.apiKey}`,
|
|
15
17
|
Accept: "application/json"
|
|
16
18
|
}
|
|
17
|
-
});
|
|
19
|
+
}, config.requestTimeout);
|
|
18
20
|
if (!response.ok) {
|
|
19
21
|
// Fallback to local registry
|
|
20
22
|
const localModels = ModelRegistry.all()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Models.d.ts","sourceRoot":"","sources":["../../../src/providers/openai/Models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Models.d.ts","sourceRoot":"","sources":["../../../src/providers/openai/Models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAO3C,qBAAa,YAAY;IAErB,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM;IAClC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM;gBADd,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM;IAGnC,SAAS,CAAC,eAAe,IAAI,MAAM;IAInC,SAAS,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAMpD,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAQ1D,SAAS,CAAC,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAQ5D,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM;;;;IAKvC,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE;IAKpD,SAAS,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM;IAK9B,OAAO,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IA8DrC,IAAI,CAAC,OAAO,EAAE,MAAM;CAGrB"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { config } from "../../config.js";
|
|
2
|
+
import { fetchWithTimeout } from "../../utils/fetch.js";
|
|
1
3
|
import { Capabilities } from "./Capabilities.js";
|
|
2
4
|
import { ModelRegistry } from "../../models/ModelRegistry.js";
|
|
3
5
|
import { buildUrl } from "./utils.js";
|
|
@@ -42,13 +44,13 @@ export class OpenAIModels {
|
|
|
42
44
|
async execute() {
|
|
43
45
|
const provider = this.getProviderName();
|
|
44
46
|
try {
|
|
45
|
-
const response = await
|
|
47
|
+
const response = await fetchWithTimeout(buildUrl(this.baseUrl, "/models"), {
|
|
46
48
|
method: "GET",
|
|
47
49
|
headers: {
|
|
48
50
|
Authorization: `Bearer ${this.apiKey}`,
|
|
49
51
|
"Content-Type": "application/json"
|
|
50
52
|
}
|
|
51
|
-
});
|
|
53
|
+
}, config.requestTimeout);
|
|
52
54
|
if (response.ok) {
|
|
53
55
|
const { data } = (await response.json());
|
|
54
56
|
return data.map((m) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Models.d.ts","sourceRoot":"","sources":["../../../src/providers/openrouter/Models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Models.d.ts","sourceRoot":"","sources":["../../../src/providers/openrouter/Models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA0B3C,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM;IAG3B,OAAO,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAqBrC,OAAO,CAAC,UAAU;IA0BlB,OAAO,CAAC,iBAAiB;IA8BzB,OAAO,CAAC,YAAY;CAgCrB"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { config } from "../../config.js";
|
|
2
|
+
import { fetchWithTimeout } from "../../utils/fetch.js";
|
|
1
3
|
export class OpenRouterModels {
|
|
2
4
|
baseUrl;
|
|
3
5
|
apiKey;
|
|
@@ -6,12 +8,12 @@ export class OpenRouterModels {
|
|
|
6
8
|
this.apiKey = apiKey;
|
|
7
9
|
}
|
|
8
10
|
async execute() {
|
|
9
|
-
const response = await
|
|
11
|
+
const response = await fetchWithTimeout(`${this.baseUrl}/models`, {
|
|
10
12
|
headers: {
|
|
11
13
|
Authorization: `Bearer ${this.apiKey}`,
|
|
12
14
|
"Content-Type": "application/json"
|
|
13
15
|
}
|
|
14
|
-
});
|
|
16
|
+
}, config.requestTimeout);
|
|
15
17
|
if (!response.ok) {
|
|
16
18
|
throw new Error(`OpenRouter API error: ${response.status}`);
|
|
17
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Binary.d.ts","sourceRoot":"","sources":["../../src/utils/Binary.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Binary.d.ts","sourceRoot":"","sources":["../../src/utils/Binary.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,WAAW;IACtB;;OAEG;WACU,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAmD9D;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAI7C;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM;IAIjD,OAAO,CAAC,MAAM,CAAC,aAAa;CA0B7B"}
|
package/dist/utils/Binary.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { logger } from "./logger.js";
|
|
4
|
+
/** Max size (bytes) for a remotely-fetched binary, buffered fully into memory. */
|
|
5
|
+
const MAX_REMOTE_BYTES = 50 * 1024 * 1024;
|
|
4
6
|
export class BinaryUtils {
|
|
5
7
|
/**
|
|
6
8
|
* Converts a URL (data:, http:, or local path) to a base64 string and mime type.
|
|
@@ -20,7 +22,16 @@ export class BinaryUtils {
|
|
|
20
22
|
const response = await fetch(url);
|
|
21
23
|
if (!response.ok)
|
|
22
24
|
return null;
|
|
25
|
+
const declared = Number(response.headers.get("content-length"));
|
|
26
|
+
if (Number.isFinite(declared) && declared > MAX_REMOTE_BYTES) {
|
|
27
|
+
logger.error(`Remote file exceeds ${MAX_REMOTE_BYTES}-byte limit: ${url}`);
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
23
30
|
const buffer = await response.arrayBuffer();
|
|
31
|
+
if (buffer.byteLength > MAX_REMOTE_BYTES) {
|
|
32
|
+
logger.error(`Remote file exceeds ${MAX_REMOTE_BYTES}-byte limit: ${url}`);
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
24
35
|
const base64 = Buffer.from(buffer).toString("base64");
|
|
25
36
|
const mimeType = response.headers.get("content-type") || this.guessMimeType(url);
|
|
26
37
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileLoader.d.ts","sourceRoot":"","sources":["../../src/utils/FileLoader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"FileLoader.d.ts","sourceRoot":"","sources":["../../src/utils/FileLoader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAyFjD,qBAAa,UAAU;WACR,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAmF1D"}
|
package/dist/utils/FileLoader.js
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
import { promises as fs } from "fs";
|
|
2
2
|
import * as path from "path";
|
|
3
|
+
/**
|
|
4
|
+
* Maximum size (bytes) for a remotely-fetched attachment. Caps memory use and
|
|
5
|
+
* limits the blast radius if an untrusted URL is ever passed here (the fetched
|
|
6
|
+
* body is buffered fully into memory as base64). 50 MB comfortably covers
|
|
7
|
+
* images, audio, and PDFs sent to providers.
|
|
8
|
+
*/
|
|
9
|
+
const MAX_REMOTE_BYTES = 50 * 1024 * 1024;
|
|
10
|
+
async function readCapped(response, source) {
|
|
11
|
+
const declared = Number(response.headers.get("content-length"));
|
|
12
|
+
if (Number.isFinite(declared) && declared > MAX_REMOTE_BYTES) {
|
|
13
|
+
throw new Error(`Remote file ${source} is ${declared} bytes, exceeding the ${MAX_REMOTE_BYTES}-byte limit.`);
|
|
14
|
+
}
|
|
15
|
+
const buffer = await response.arrayBuffer();
|
|
16
|
+
if (buffer.byteLength > MAX_REMOTE_BYTES) {
|
|
17
|
+
throw new Error(`Remote file ${source} is ${buffer.byteLength} bytes, exceeding the ${MAX_REMOTE_BYTES}-byte limit.`);
|
|
18
|
+
}
|
|
19
|
+
return buffer;
|
|
20
|
+
}
|
|
3
21
|
const MIME_TYPES = {
|
|
4
22
|
".jpg": "image/jpeg",
|
|
5
23
|
".jpeg": "image/jpeg",
|
|
@@ -50,7 +68,8 @@ const TEXT_EXTENSIONS = new Set([
|
|
|
50
68
|
".xml",
|
|
51
69
|
".yml",
|
|
52
70
|
".yaml",
|
|
53
|
-
".env"
|
|
71
|
+
// ".env" intentionally excluded: silently inlining a dotenv file would leak
|
|
72
|
+
// secrets into the prompt sent to the provider.
|
|
54
73
|
".csv",
|
|
55
74
|
".go",
|
|
56
75
|
".java",
|
|
@@ -67,7 +86,7 @@ export class FileLoader {
|
|
|
67
86
|
const response = await fetch(filePath);
|
|
68
87
|
if (!response.ok)
|
|
69
88
|
throw new Error(`Failed to fetch file: ${response.statusText}`);
|
|
70
|
-
const buffer = await response
|
|
89
|
+
const buffer = await readCapped(response, filePath);
|
|
71
90
|
const contentTypeFull = response.headers.get("content-type") || "image/jpeg";
|
|
72
91
|
const contentType = (contentTypeFull.split(";")[0] ?? "image/jpeg").trim();
|
|
73
92
|
const base64 = Buffer.from(buffer).toString("base64");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAUA,cAAM,MAAM;IACV,OAAO,CAAC,cAAc;IAItB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI;IAO5C;;OAEG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI;IAS/E;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI;IASvF,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI3B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI;IAI3C,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAG5B;AAED,eAAO,MAAM,MAAM,QAAe,CAAC"}
|
package/dist/utils/logger.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { config } from "../config.js";
|
|
2
|
+
/**
|
|
3
|
+
* Masks credentials passed as URL query parameters (e.g. Gemini's `?key=...`)
|
|
4
|
+
* so they never reach stdout or a log aggregator when debug logging is on.
|
|
5
|
+
*/
|
|
6
|
+
function redactUrl(url) {
|
|
7
|
+
return url.replace(/([?&](?:key|api_key|apikey|access_token|token)=)[^&#]+/gi, "$1[REDACTED]");
|
|
8
|
+
}
|
|
2
9
|
class Logger {
|
|
3
10
|
isDebugEnabled() {
|
|
4
11
|
return config.debug === true;
|
|
@@ -14,7 +21,7 @@ class Logger {
|
|
|
14
21
|
*/
|
|
15
22
|
logRequest(provider, method, url, body) {
|
|
16
23
|
if (this.isDebugEnabled()) {
|
|
17
|
-
console.log(`[NodeLLM] [${provider}] Request: ${method} ${url}`);
|
|
24
|
+
console.log(`[NodeLLM] [${provider}] Request: ${method} ${redactUrl(url)}`);
|
|
18
25
|
if (body) {
|
|
19
26
|
console.log(JSON.stringify(body, null, 2));
|
|
20
27
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-llm/core",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -55,17 +55,6 @@
|
|
|
55
55
|
"README.md",
|
|
56
56
|
"LICENSE"
|
|
57
57
|
],
|
|
58
|
-
"scripts": {
|
|
59
|
-
"build": "tsc -p tsconfig.json",
|
|
60
|
-
"dev": "tsc -w",
|
|
61
|
-
"lint": "tsc --noEmit",
|
|
62
|
-
"test": "vitest run",
|
|
63
|
-
"test:docs": "vitest run test/docs",
|
|
64
|
-
"test:watch": "vitest",
|
|
65
|
-
"prepack": "npm run build && cp ../../CHANGELOG.md ./CHANGELOG.md",
|
|
66
|
-
"postpack": "rm ./CHANGELOG.md",
|
|
67
|
-
"prepublishOnly": "npm run build && npm run test:docs"
|
|
68
|
-
},
|
|
69
58
|
"dependencies": {
|
|
70
59
|
"zod": "^3.23.8",
|
|
71
60
|
"zod-to-json-schema": "^3.25.1"
|
|
@@ -75,5 +64,13 @@
|
|
|
75
64
|
"@pollyjs/adapter-node-http": "^6.0.6",
|
|
76
65
|
"@pollyjs/core": "^6.0.6",
|
|
77
66
|
"@pollyjs/persister-fs": "^6.0.6"
|
|
67
|
+
},
|
|
68
|
+
"scripts": {
|
|
69
|
+
"build": "tsc -p tsconfig.json",
|
|
70
|
+
"dev": "tsc -w",
|
|
71
|
+
"lint": "tsc --noEmit",
|
|
72
|
+
"test": "vitest run",
|
|
73
|
+
"test:docs": "vitest run test/docs",
|
|
74
|
+
"test:watch": "vitest"
|
|
78
75
|
}
|
|
79
|
-
}
|
|
76
|
+
}
|