@jambonz/llm 0.6.1 → 0.6.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/dist/index.cjs +163 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +163 -38
- package/dist/index.js.map +1 -1
- package/dist/test-kit/index.cjs +215 -40
- package/dist/test-kit/index.cjs.map +1 -1
- package/dist/test-kit/index.d.cts +2 -2
- package/dist/test-kit/index.d.ts +2 -2
- package/dist/test-kit/index.js +215 -40
- package/dist/test-kit/index.js.map +1 -1
- package/dist/{types-Y0o6rN3B.d.cts → types-dbgrfviJ.d.cts} +7 -1
- package/dist/{types-Y0o6rN3B.d.ts → types-dbgrfviJ.d.ts} +7 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as ServiceAccountJson, A as AuthSpec, a as AuthKindSchema, P as PromptRequest, b as AdapterFactory, c as AdapterManifest, C as CreateLlmArgs, L as LlmAdapter } from './types-
|
|
2
|
-
export { d as ApiKeyAuth, e as AuthKind, f as AzureOpenAIApiKeyAuth, B as BedrockApiKeyAuth, g as BedrockIamAuth, h as ClientOptions, i as ContentBlock, F as FinishReason, j as FormField, k as FormFieldType, G as GoogleApiKeyAuth, l as GoogleServiceAccountAuth, J as JsonSchema, m as LlmEvent, M as Message, n as ModelCapabilities, o as ModelInfo, R as Role, T as Tool, p as ToolCallEvent, U as Usage, V as VertexServiceAccountAuth } from './types-
|
|
1
|
+
import { S as ServiceAccountJson, A as AuthSpec, a as AuthKindSchema, P as PromptRequest, b as AdapterFactory, c as AdapterManifest, C as CreateLlmArgs, L as LlmAdapter } from './types-dbgrfviJ.cjs';
|
|
2
|
+
export { d as ApiKeyAuth, e as AuthKind, f as AzureOpenAIApiKeyAuth, B as BedrockApiKeyAuth, g as BedrockIamAuth, h as ClientOptions, i as ContentBlock, F as FinishReason, j as FormField, k as FormFieldType, G as GoogleApiKeyAuth, l as GoogleServiceAccountAuth, J as JsonSchema, m as LlmEvent, M as Message, n as ModelCapabilities, o as ModelInfo, R as Role, T as Tool, p as ToolCallEvent, U as Usage, V as VertexServiceAccountAuth } from './types-dbgrfviJ.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The loose "DB-shape" input accepted by `normalizeAuth`.
|
|
@@ -31,9 +31,10 @@ interface RawCredential {
|
|
|
31
31
|
/**
|
|
32
32
|
* Convert a vendor + raw credential into an `AuthSpec` discriminated union member.
|
|
33
33
|
*
|
|
34
|
-
* Supported vendors: openai, deepseek, baseten, moonshot, zai, xai,
|
|
35
|
-
* vertex (alias for vertex-gemini + vertex-openai — both accept
|
|
36
|
-
* vertex-gemini, vertex-openai, bedrock, azure-openai, groq,
|
|
34
|
+
* Supported vendors: openai, deepseek, baseten, moonshot, zai, xai, bedrock-mantle,
|
|
35
|
+
* anthropic, google, vertex (alias for vertex-gemini + vertex-openai — both accept
|
|
36
|
+
* the same auth shape), vertex-gemini, vertex-openai, bedrock, azure-openai, groq,
|
|
37
|
+
* huggingface.
|
|
37
38
|
*
|
|
38
39
|
* Throws with a clear message if the raw credential is missing required fields.
|
|
39
40
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as ServiceAccountJson, A as AuthSpec, a as AuthKindSchema, P as PromptRequest, b as AdapterFactory, c as AdapterManifest, C as CreateLlmArgs, L as LlmAdapter } from './types-
|
|
2
|
-
export { d as ApiKeyAuth, e as AuthKind, f as AzureOpenAIApiKeyAuth, B as BedrockApiKeyAuth, g as BedrockIamAuth, h as ClientOptions, i as ContentBlock, F as FinishReason, j as FormField, k as FormFieldType, G as GoogleApiKeyAuth, l as GoogleServiceAccountAuth, J as JsonSchema, m as LlmEvent, M as Message, n as ModelCapabilities, o as ModelInfo, R as Role, T as Tool, p as ToolCallEvent, U as Usage, V as VertexServiceAccountAuth } from './types-
|
|
1
|
+
import { S as ServiceAccountJson, A as AuthSpec, a as AuthKindSchema, P as PromptRequest, b as AdapterFactory, c as AdapterManifest, C as CreateLlmArgs, L as LlmAdapter } from './types-dbgrfviJ.js';
|
|
2
|
+
export { d as ApiKeyAuth, e as AuthKind, f as AzureOpenAIApiKeyAuth, B as BedrockApiKeyAuth, g as BedrockIamAuth, h as ClientOptions, i as ContentBlock, F as FinishReason, j as FormField, k as FormFieldType, G as GoogleApiKeyAuth, l as GoogleServiceAccountAuth, J as JsonSchema, m as LlmEvent, M as Message, n as ModelCapabilities, o as ModelInfo, R as Role, T as Tool, p as ToolCallEvent, U as Usage, V as VertexServiceAccountAuth } from './types-dbgrfviJ.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The loose "DB-shape" input accepted by `normalizeAuth`.
|
|
@@ -31,9 +31,10 @@ interface RawCredential {
|
|
|
31
31
|
/**
|
|
32
32
|
* Convert a vendor + raw credential into an `AuthSpec` discriminated union member.
|
|
33
33
|
*
|
|
34
|
-
* Supported vendors: openai, deepseek, baseten, moonshot, zai, xai,
|
|
35
|
-
* vertex (alias for vertex-gemini + vertex-openai — both accept
|
|
36
|
-
* vertex-gemini, vertex-openai, bedrock, azure-openai, groq,
|
|
34
|
+
* Supported vendors: openai, deepseek, baseten, moonshot, zai, xai, bedrock-mantle,
|
|
35
|
+
* anthropic, google, vertex (alias for vertex-gemini + vertex-openai — both accept
|
|
36
|
+
* the same auth shape), vertex-gemini, vertex-openai, bedrock, azure-openai, groq,
|
|
37
|
+
* huggingface.
|
|
37
38
|
*
|
|
38
39
|
* Throws with a clear message if the raw credential is missing required fields.
|
|
39
40
|
*/
|
package/dist/index.js
CHANGED
|
@@ -239,10 +239,11 @@ async function* streamFromOpenAI(client, req, options) {
|
|
|
239
239
|
}
|
|
240
240
|
yield endEvent;
|
|
241
241
|
}
|
|
242
|
-
function appendOpenAIAssistantToolCall(history, toolCalls) {
|
|
242
|
+
function appendOpenAIAssistantToolCall(history, toolCalls, assistantText) {
|
|
243
|
+
const text = assistantText?.trim() ? assistantText : null;
|
|
243
244
|
const wireMessage = {
|
|
244
245
|
role: "assistant",
|
|
245
|
-
content:
|
|
246
|
+
content: text,
|
|
246
247
|
tool_calls: toolCalls.map((tc) => ({
|
|
247
248
|
id: tc.id,
|
|
248
249
|
type: "function",
|
|
@@ -256,7 +257,7 @@ function appendOpenAIAssistantToolCall(history, toolCalls) {
|
|
|
256
257
|
...history,
|
|
257
258
|
{
|
|
258
259
|
role: "assistant",
|
|
259
|
-
content: "",
|
|
260
|
+
content: text ?? "",
|
|
260
261
|
vendorRaw: wireMessage
|
|
261
262
|
}
|
|
262
263
|
];
|
|
@@ -527,8 +528,8 @@ var OpenAIAdapter = class {
|
|
|
527
528
|
includeCacheKey: this.forwardCacheKey()
|
|
528
529
|
});
|
|
529
530
|
}
|
|
530
|
-
appendAssistantToolCall(history, toolCalls) {
|
|
531
|
-
return appendOpenAIAssistantToolCall(history, toolCalls);
|
|
531
|
+
appendAssistantToolCall(history, toolCalls, assistantText) {
|
|
532
|
+
return appendOpenAIAssistantToolCall(history, toolCalls, assistantText);
|
|
532
533
|
}
|
|
533
534
|
appendToolResult(history, toolCallId, result) {
|
|
534
535
|
return appendOpenAIToolResult(history, toolCallId, result);
|
|
@@ -1089,6 +1090,116 @@ var xaiFactory = {
|
|
|
1089
1090
|
manifest: xaiManifest,
|
|
1090
1091
|
create: () => new XaiAdapter()
|
|
1091
1092
|
};
|
|
1093
|
+
var BEDROCK_MANTLE_DEFAULT_BASE_URL = "https://bedrock-mantle.us-east-1.api.aws/v1";
|
|
1094
|
+
var bedrockMantleManifest = {
|
|
1095
|
+
vendor: "bedrock-mantle",
|
|
1096
|
+
displayName: "AWS Bedrock (OpenAI-compatible)",
|
|
1097
|
+
authKinds: [
|
|
1098
|
+
{
|
|
1099
|
+
kind: "apiKey",
|
|
1100
|
+
displayName: "API Key",
|
|
1101
|
+
fields: [
|
|
1102
|
+
{
|
|
1103
|
+
name: "apiKey",
|
|
1104
|
+
label: "Bedrock API Key",
|
|
1105
|
+
type: "password",
|
|
1106
|
+
required: true,
|
|
1107
|
+
help: "Generate a long-term Bedrock API key in the AWS console (Amazon Bedrock \u2192 API keys)."
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
name: "baseURL",
|
|
1111
|
+
label: "Base URL",
|
|
1112
|
+
type: "url",
|
|
1113
|
+
required: false,
|
|
1114
|
+
default: BEDROCK_MANTLE_DEFAULT_BASE_URL,
|
|
1115
|
+
help: "Change the region to match your key. xAI models are served only on the /openai/v1 path."
|
|
1116
|
+
}
|
|
1117
|
+
]
|
|
1118
|
+
}
|
|
1119
|
+
],
|
|
1120
|
+
/* A convenience seed, NOT the source of truth: the live `/v1/models`
|
|
1121
|
+
* endpoint is authoritative and grows continuously, which is why
|
|
1122
|
+
* `supportsModelListing` is true. Any model the endpoint lists can be used
|
|
1123
|
+
* by id without appearing here.
|
|
1124
|
+
*
|
|
1125
|
+
* AWS publishes no context-window metadata (neither `/v1/models` nor
|
|
1126
|
+
* `GetFoundationModel` returns it), so these limits are carried over from
|
|
1127
|
+
* the native-vendor manifests above for the same underlying models. Vision
|
|
1128
|
+
* follows Bedrock's `inputModalities`. */
|
|
1129
|
+
knownModels: [
|
|
1130
|
+
{
|
|
1131
|
+
id: "zai.glm-5",
|
|
1132
|
+
displayName: "GLM 5",
|
|
1133
|
+
capabilities: {
|
|
1134
|
+
streaming: true,
|
|
1135
|
+
tools: true,
|
|
1136
|
+
vision: false,
|
|
1137
|
+
systemPrompt: true,
|
|
1138
|
+
maxContextTokens: 202800
|
|
1139
|
+
}
|
|
1140
|
+
},
|
|
1141
|
+
{
|
|
1142
|
+
id: "zai.glm-4.7",
|
|
1143
|
+
displayName: "GLM 4.7",
|
|
1144
|
+
capabilities: {
|
|
1145
|
+
streaming: true,
|
|
1146
|
+
tools: true,
|
|
1147
|
+
vision: false,
|
|
1148
|
+
systemPrompt: true,
|
|
1149
|
+
maxContextTokens: 2e5
|
|
1150
|
+
}
|
|
1151
|
+
},
|
|
1152
|
+
{
|
|
1153
|
+
id: "moonshotai.kimi-k2.5",
|
|
1154
|
+
displayName: "Kimi K2.5",
|
|
1155
|
+
capabilities: {
|
|
1156
|
+
streaming: true,
|
|
1157
|
+
tools: true,
|
|
1158
|
+
vision: true,
|
|
1159
|
+
systemPrompt: true,
|
|
1160
|
+
maxContextTokens: 262144
|
|
1161
|
+
}
|
|
1162
|
+
},
|
|
1163
|
+
{
|
|
1164
|
+
id: "xai.grok-4.3",
|
|
1165
|
+
displayName: "Grok 4.3",
|
|
1166
|
+
capabilities: {
|
|
1167
|
+
streaming: true,
|
|
1168
|
+
tools: true,
|
|
1169
|
+
vision: true,
|
|
1170
|
+
systemPrompt: true,
|
|
1171
|
+
maxContextTokens: 1e6
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
],
|
|
1175
|
+
supportsModelListing: true,
|
|
1176
|
+
docsUrl: "https://docs.aws.amazon.com/bedrock/latest/userguide/inference-chat-completions.html"
|
|
1177
|
+
};
|
|
1178
|
+
var BedrockMantleAdapter = class extends OpenAIAdapter {
|
|
1179
|
+
vendor = bedrockMantleManifest.vendor;
|
|
1180
|
+
init(auth, client) {
|
|
1181
|
+
super.init(
|
|
1182
|
+
{
|
|
1183
|
+
...auth,
|
|
1184
|
+
baseURL: auth.baseURL ?? BEDROCK_MANTLE_DEFAULT_BASE_URL
|
|
1185
|
+
},
|
|
1186
|
+
client
|
|
1187
|
+
);
|
|
1188
|
+
}
|
|
1189
|
+
knownModels() {
|
|
1190
|
+
return bedrockMantleManifest.knownModels;
|
|
1191
|
+
}
|
|
1192
|
+
// Mantle fronts many third-party runtimes with differing param strictness,
|
|
1193
|
+
// and prompt_cache_key is unverified against all of them — do not forward.
|
|
1194
|
+
forwardCacheKey() {
|
|
1195
|
+
return false;
|
|
1196
|
+
}
|
|
1197
|
+
};
|
|
1198
|
+
var bedrockMantleFactory = {
|
|
1199
|
+
vendor: bedrockMantleManifest.vendor,
|
|
1200
|
+
manifest: bedrockMantleManifest,
|
|
1201
|
+
create: () => new BedrockMantleAdapter()
|
|
1202
|
+
};
|
|
1092
1203
|
|
|
1093
1204
|
// src/adapters/anthropic/adapter.ts
|
|
1094
1205
|
import Anthropic from "@anthropic-ai/sdk";
|
|
@@ -1384,21 +1495,25 @@ var AnthropicAdapter = class {
|
|
|
1384
1495
|
}
|
|
1385
1496
|
yield endEvent;
|
|
1386
1497
|
}
|
|
1387
|
-
appendAssistantToolCall(history, toolCalls) {
|
|
1498
|
+
appendAssistantToolCall(history, toolCalls, assistantText) {
|
|
1499
|
+
const text = assistantText?.trim() ? assistantText : null;
|
|
1388
1500
|
const wireMessage = {
|
|
1389
1501
|
role: "assistant",
|
|
1390
|
-
content:
|
|
1391
|
-
type: "
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1502
|
+
content: [
|
|
1503
|
+
...text ? [{ type: "text", text }] : [],
|
|
1504
|
+
...toolCalls.map((tc) => ({
|
|
1505
|
+
type: "tool_use",
|
|
1506
|
+
id: tc.id,
|
|
1507
|
+
name: tc.name,
|
|
1508
|
+
input: tc.arguments ?? {}
|
|
1509
|
+
}))
|
|
1510
|
+
]
|
|
1396
1511
|
};
|
|
1397
1512
|
return [
|
|
1398
1513
|
...history,
|
|
1399
1514
|
{
|
|
1400
1515
|
role: "assistant",
|
|
1401
|
-
content: "",
|
|
1516
|
+
content: text ?? "",
|
|
1402
1517
|
vendorRaw: wireMessage
|
|
1403
1518
|
}
|
|
1404
1519
|
];
|
|
@@ -1650,21 +1765,25 @@ async function* streamFromGemini(client, req) {
|
|
|
1650
1765
|
};
|
|
1651
1766
|
yield endEvent;
|
|
1652
1767
|
}
|
|
1653
|
-
function appendGeminiAssistantToolCall(history, toolCalls) {
|
|
1768
|
+
function appendGeminiAssistantToolCall(history, toolCalls, assistantText) {
|
|
1769
|
+
const text = assistantText?.trim() ? assistantText : null;
|
|
1654
1770
|
const wireMessage = {
|
|
1655
1771
|
role: "model",
|
|
1656
|
-
parts:
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1772
|
+
parts: [
|
|
1773
|
+
...text ? [{ text }] : [],
|
|
1774
|
+
...toolCalls.map((tc) => ({
|
|
1775
|
+
functionCall: {
|
|
1776
|
+
name: parseToolName(tc.id),
|
|
1777
|
+
args: tc.arguments ?? {}
|
|
1778
|
+
}
|
|
1779
|
+
}))
|
|
1780
|
+
]
|
|
1662
1781
|
};
|
|
1663
1782
|
return [
|
|
1664
1783
|
...history,
|
|
1665
1784
|
{
|
|
1666
1785
|
role: "assistant",
|
|
1667
|
-
content: "",
|
|
1786
|
+
content: text ?? "",
|
|
1668
1787
|
vendorRaw: wireMessage
|
|
1669
1788
|
}
|
|
1670
1789
|
];
|
|
@@ -1924,8 +2043,8 @@ var GoogleAdapter = class {
|
|
|
1924
2043
|
stream(req) {
|
|
1925
2044
|
return streamFromGemini(this.ensureClient(), req);
|
|
1926
2045
|
}
|
|
1927
|
-
appendAssistantToolCall(history, toolCalls) {
|
|
1928
|
-
return appendGeminiAssistantToolCall(history, toolCalls);
|
|
2046
|
+
appendAssistantToolCall(history, toolCalls, assistantText) {
|
|
2047
|
+
return appendGeminiAssistantToolCall(history, toolCalls, assistantText);
|
|
1929
2048
|
}
|
|
1930
2049
|
appendToolResult(history, toolCallId, result) {
|
|
1931
2050
|
return appendGeminiToolResult(history, toolCallId, result);
|
|
@@ -2130,8 +2249,8 @@ var VertexGeminiAdapter = class {
|
|
|
2130
2249
|
stream(req) {
|
|
2131
2250
|
return streamFromGemini(this.ensureClient(), req);
|
|
2132
2251
|
}
|
|
2133
|
-
appendAssistantToolCall(history, toolCalls) {
|
|
2134
|
-
return appendGeminiAssistantToolCall(history, toolCalls);
|
|
2252
|
+
appendAssistantToolCall(history, toolCalls, assistantText) {
|
|
2253
|
+
return appendGeminiAssistantToolCall(history, toolCalls, assistantText);
|
|
2135
2254
|
}
|
|
2136
2255
|
appendToolResult(history, toolCallId, result) {
|
|
2137
2256
|
return appendGeminiToolResult(history, toolCallId, result);
|
|
@@ -2328,8 +2447,8 @@ var VertexOpenAIAdapter = class {
|
|
|
2328
2447
|
vendorMetadataExtractor: VERTEX_OPENAI_METADATA_EXTRACTOR
|
|
2329
2448
|
});
|
|
2330
2449
|
}
|
|
2331
|
-
appendAssistantToolCall(history, toolCalls) {
|
|
2332
|
-
return appendOpenAIAssistantToolCall(history, toolCalls);
|
|
2450
|
+
appendAssistantToolCall(history, toolCalls, assistantText) {
|
|
2451
|
+
return appendOpenAIAssistantToolCall(history, toolCalls, assistantText);
|
|
2333
2452
|
}
|
|
2334
2453
|
appendToolResult(history, toolCallId, result) {
|
|
2335
2454
|
return appendOpenAIToolResult(history, toolCallId, result);
|
|
@@ -2821,22 +2940,26 @@ var BedrockAdapter = class {
|
|
|
2821
2940
|
}
|
|
2822
2941
|
yield endEvent;
|
|
2823
2942
|
}
|
|
2824
|
-
appendAssistantToolCall(history, toolCalls) {
|
|
2943
|
+
appendAssistantToolCall(history, toolCalls, assistantText) {
|
|
2944
|
+
const text = assistantText?.trim() ? assistantText : null;
|
|
2825
2945
|
const wireMessage = {
|
|
2826
2946
|
role: "assistant",
|
|
2827
|
-
content:
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2947
|
+
content: [
|
|
2948
|
+
...text ? [{ text }] : [],
|
|
2949
|
+
...toolCalls.map((tc) => ({
|
|
2950
|
+
toolUse: {
|
|
2951
|
+
toolUseId: tc.id,
|
|
2952
|
+
name: tc.name,
|
|
2953
|
+
input: tc.arguments ?? {}
|
|
2954
|
+
}
|
|
2955
|
+
}))
|
|
2956
|
+
]
|
|
2834
2957
|
};
|
|
2835
2958
|
return [
|
|
2836
2959
|
...history,
|
|
2837
2960
|
{
|
|
2838
2961
|
role: "assistant",
|
|
2839
|
-
content: "",
|
|
2962
|
+
content: text ?? "",
|
|
2840
2963
|
vendorRaw: wireMessage
|
|
2841
2964
|
}
|
|
2842
2965
|
];
|
|
@@ -3126,8 +3249,8 @@ var AzureOpenAIAdapter = class {
|
|
|
3126
3249
|
vendorMetadataExtractor: AZURE_OPENAI_METADATA_EXTRACTOR
|
|
3127
3250
|
});
|
|
3128
3251
|
}
|
|
3129
|
-
appendAssistantToolCall(history, toolCalls) {
|
|
3130
|
-
return appendOpenAIAssistantToolCall(history, toolCalls);
|
|
3252
|
+
appendAssistantToolCall(history, toolCalls, assistantText) {
|
|
3253
|
+
return appendOpenAIAssistantToolCall(history, toolCalls, assistantText);
|
|
3131
3254
|
}
|
|
3132
3255
|
appendToolResult(history, toolCallId, result) {
|
|
3133
3256
|
return appendOpenAIToolResult(history, toolCallId, result);
|
|
@@ -3415,6 +3538,7 @@ registerAdapter(basetenFactory);
|
|
|
3415
3538
|
registerAdapter(moonshotFactory);
|
|
3416
3539
|
registerAdapter(zaiFactory);
|
|
3417
3540
|
registerAdapter(xaiFactory);
|
|
3541
|
+
registerAdapter(bedrockMantleFactory);
|
|
3418
3542
|
registerAdapter(anthropicFactory);
|
|
3419
3543
|
registerAdapter(googleFactory);
|
|
3420
3544
|
registerAdapter(vertexGeminiFactory);
|
|
@@ -3434,6 +3558,7 @@ function normalizeAuth(vendor, raw) {
|
|
|
3434
3558
|
case "moonshot":
|
|
3435
3559
|
case "zai":
|
|
3436
3560
|
case "xai":
|
|
3561
|
+
case "bedrock-mantle":
|
|
3437
3562
|
return requireApiKey(vendor, raw);
|
|
3438
3563
|
case "deepseek":
|
|
3439
3564
|
return {
|