@jambonz/llm 0.5.5 → 0.5.7

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.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-BEgQaQIb.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-BEgQaQIb.cjs';
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-rZZBXYhB.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-rZZBXYhB.cjs';
3
3
 
4
4
  /**
5
5
  * The loose "DB-shape" input accepted by `normalizeAuth`.
@@ -31,7 +31,7 @@ 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, anthropic, google,
34
+ * Supported vendors: openai, deepseek, baseten, moonshot, zai, xai, anthropic, google,
35
35
  * vertex (alias for vertex-gemini + vertex-openai — both accept the same auth shape),
36
36
  * vertex-gemini, vertex-openai, bedrock, azure-openai, groq, huggingface.
37
37
  *
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-BEgQaQIb.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-BEgQaQIb.js';
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-rZZBXYhB.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-rZZBXYhB.js';
3
3
 
4
4
  /**
5
5
  * The loose "DB-shape" input accepted by `normalizeAuth`.
@@ -31,7 +31,7 @@ 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, anthropic, google,
34
+ * Supported vendors: openai, deepseek, baseten, moonshot, zai, xai, anthropic, google,
35
35
  * vertex (alias for vertex-gemini + vertex-openai — both accept the same auth shape),
36
36
  * vertex-gemini, vertex-openai, bedrock, azure-openai, groq, huggingface.
37
37
  *
package/dist/index.js CHANGED
@@ -85,6 +85,12 @@ async function* streamFromOpenAI(client, req, options) {
85
85
  const param = options.tokensParam ?? (needsMaxCompletionTokens(req.model) ? "max_completion_tokens" : "max_tokens");
86
86
  body[param] = effectiveMaxTokens;
87
87
  }
88
+ if (req.providerParams) {
89
+ const bodyRecord = body;
90
+ for (const [key, value] of Object.entries(req.providerParams)) {
91
+ if (!(key in bodyRecord)) bodyRecord[key] = value;
92
+ }
93
+ }
88
94
  const t0 = process.hrtime.bigint();
89
95
  let t1;
90
96
  let t2;
@@ -944,6 +950,101 @@ var zaiFactory = {
944
950
  manifest: zaiManifest,
945
951
  create: () => new ZaiAdapter()
946
952
  };
953
+ var xaiManifest = {
954
+ vendor: "xai",
955
+ displayName: "xAI (Grok)",
956
+ authKinds: [
957
+ {
958
+ kind: "apiKey",
959
+ displayName: "API Key",
960
+ fields: [
961
+ {
962
+ name: "apiKey",
963
+ label: "API Key",
964
+ type: "password",
965
+ required: true,
966
+ help: "Get an API key from https://console.x.ai/team/default/api-keys"
967
+ },
968
+ {
969
+ name: "baseURL",
970
+ label: "Base URL",
971
+ type: "url",
972
+ required: false,
973
+ default: "https://api.x.ai/v1",
974
+ help: "Override for proxy endpoints. Defaults to xAI production."
975
+ }
976
+ ]
977
+ }
978
+ ],
979
+ knownModels: [
980
+ {
981
+ id: "grok-4.3",
982
+ displayName: "Grok 4.3",
983
+ capabilities: {
984
+ streaming: true,
985
+ tools: true,
986
+ vision: true,
987
+ systemPrompt: true,
988
+ maxContextTokens: 1e6
989
+ }
990
+ },
991
+ {
992
+ id: "grok-4.20-0309-reasoning",
993
+ displayName: "Grok 4.20 (Reasoning)",
994
+ capabilities: {
995
+ streaming: true,
996
+ tools: true,
997
+ vision: true,
998
+ systemPrompt: true,
999
+ maxContextTokens: 1e6
1000
+ }
1001
+ },
1002
+ {
1003
+ id: "grok-4.20-0309-non-reasoning",
1004
+ displayName: "Grok 4.20 (Non-Reasoning)",
1005
+ capabilities: {
1006
+ streaming: true,
1007
+ tools: true,
1008
+ vision: true,
1009
+ systemPrompt: true,
1010
+ maxContextTokens: 1e6
1011
+ }
1012
+ },
1013
+ {
1014
+ id: "grok-4.20-multi-agent-0309",
1015
+ displayName: "Grok 4.20 Multi-Agent",
1016
+ capabilities: {
1017
+ streaming: true,
1018
+ tools: true,
1019
+ vision: true,
1020
+ systemPrompt: true,
1021
+ maxContextTokens: 1e6
1022
+ }
1023
+ }
1024
+ ],
1025
+ supportsModelListing: true,
1026
+ docsUrl: "https://docs.x.ai/"
1027
+ };
1028
+ var XaiAdapter = class extends OpenAIAdapter {
1029
+ vendor = xaiManifest.vendor;
1030
+ init(auth, client) {
1031
+ super.init(
1032
+ {
1033
+ ...auth,
1034
+ baseURL: auth.baseURL ?? "https://api.x.ai/v1"
1035
+ },
1036
+ client
1037
+ );
1038
+ }
1039
+ knownModels() {
1040
+ return xaiManifest.knownModels;
1041
+ }
1042
+ };
1043
+ var xaiFactory = {
1044
+ vendor: xaiManifest.vendor,
1045
+ manifest: xaiManifest,
1046
+ create: () => new XaiAdapter()
1047
+ };
947
1048
 
948
1049
  // src/adapters/anthropic/adapter.ts
949
1050
  import Anthropic from "@anthropic-ai/sdk";
@@ -3125,6 +3226,7 @@ registerAdapter(deepseekFactory);
3125
3226
  registerAdapter(basetenFactory);
3126
3227
  registerAdapter(moonshotFactory);
3127
3228
  registerAdapter(zaiFactory);
3229
+ registerAdapter(xaiFactory);
3128
3230
  registerAdapter(anthropicFactory);
3129
3231
  registerAdapter(googleFactory);
3130
3232
  registerAdapter(vertexGeminiFactory);
@@ -3143,6 +3245,7 @@ function normalizeAuth(vendor, raw) {
3143
3245
  case "huggingface":
3144
3246
  case "moonshot":
3145
3247
  case "zai":
3248
+ case "xai":
3146
3249
  return requireApiKey(vendor, raw);
3147
3250
  case "deepseek":
3148
3251
  return {