@jambonz/llm 0.6.7 → 0.6.8
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 +65 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -6
- package/dist/index.d.ts +15 -6
- package/dist/index.js +64 -4
- package/dist/index.js.map +1 -1
- package/dist/test-kit/index.cjs +51 -1
- package/dist/test-kit/index.cjs.map +1 -1
- package/dist/test-kit/index.d.cts +1 -1
- package/dist/test-kit/index.d.ts +1 -1
- package/dist/test-kit/index.js +51 -1
- package/dist/test-kit/index.js.map +1 -1
- package/dist/{types-dbgrfviJ.d.cts → types-4l2etrW-.d.cts} +7 -0
- package/dist/{types-dbgrfviJ.d.ts → types-4l2etrW-.d.ts} +7 -0
- 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-4l2etrW-.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-4l2etrW-.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The loose "DB-shape" input accepted by `normalizeAuth`.
|
|
@@ -101,12 +101,19 @@ declare function unregisterAdapter(vendor: string): void;
|
|
|
101
101
|
*/
|
|
102
102
|
declare function getAdapterFactory<A extends AuthSpec = AuthSpec>(vendor: string): AdapterFactory<A>;
|
|
103
103
|
/**
|
|
104
|
-
*
|
|
104
|
+
* Get the manifest for any registered vendor, adapter-backed or
|
|
105
|
+
* credential-only. Throws if unknown vendor. Use this (not
|
|
106
|
+
* `getAdapterFactory`) where only the credential shape matters.
|
|
107
|
+
*/
|
|
108
|
+
declare function getVendorManifest(vendor: string): AdapterManifest;
|
|
109
|
+
/**
|
|
110
|
+
* List all registered adapter vendor ids, sorted alphabetically.
|
|
111
|
+
* Credential-only vendors are not included: they cannot be passed to `createLlm`.
|
|
105
112
|
*/
|
|
106
113
|
declare function listVendors(): string[];
|
|
107
114
|
/**
|
|
108
|
-
* Return an aggregated manifest for all registered
|
|
109
|
-
* api-server's /llm-vendors/manifest endpoint.
|
|
115
|
+
* Return an aggregated manifest for all registered vendors, credential-only
|
|
116
|
+
* ones included. Used by api-server's /llm-vendors/manifest endpoint.
|
|
110
117
|
*/
|
|
111
118
|
declare function getManifest(): {
|
|
112
119
|
vendors: AdapterManifest[];
|
|
@@ -121,6 +128,8 @@ declare function getManifest(): {
|
|
|
121
128
|
* Consumers use:
|
|
122
129
|
* - `createLlm({vendor, auth, client?})` to get a ready-to-stream adapter instance.
|
|
123
130
|
* - `getManifest()` to enumerate registered vendors (used by api-server).
|
|
131
|
+
* - `getVendorManifest(vendor)` for one vendor's manifest, including
|
|
132
|
+
* credential-only vendors (e.g. `harness`) that have no adapter.
|
|
124
133
|
* - `normalizeAuth(vendor, rawCred)` to convert DB-shape creds to AuthSpec.
|
|
125
134
|
* - `pickAuthKind(vendor, rawCred)` to pick the right manifest authKind for
|
|
126
135
|
* a raw credential (used by api-server's `encryptCredential`).
|
|
@@ -129,4 +138,4 @@ declare function getManifest(): {
|
|
|
129
138
|
|
|
130
139
|
declare function createLlm<A extends AuthSpec = AuthSpec>(args: CreateLlmArgs<A>): Promise<LlmAdapter<A>>;
|
|
131
140
|
|
|
132
|
-
export { AdapterFactory, AdapterManifest, AuthKindSchema, AuthSpec, CreateLlmArgs, LlmAdapter, PromptRequest, type RawCredential, type RawCredentialLoose, ServiceAccountJson, assertValidRequest, createLlm, getAdapterFactory, getManifest, listVendors, normalizeAuth, pickAuthKind, registerAdapter, replaceAdapter, unregisterAdapter };
|
|
141
|
+
export { AdapterFactory, AdapterManifest, AuthKindSchema, AuthSpec, CreateLlmArgs, LlmAdapter, PromptRequest, type RawCredential, type RawCredentialLoose, ServiceAccountJson, assertValidRequest, createLlm, getAdapterFactory, getManifest, getVendorManifest, listVendors, normalizeAuth, pickAuthKind, registerAdapter, replaceAdapter, unregisterAdapter };
|
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-4l2etrW-.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-4l2etrW-.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The loose "DB-shape" input accepted by `normalizeAuth`.
|
|
@@ -101,12 +101,19 @@ declare function unregisterAdapter(vendor: string): void;
|
|
|
101
101
|
*/
|
|
102
102
|
declare function getAdapterFactory<A extends AuthSpec = AuthSpec>(vendor: string): AdapterFactory<A>;
|
|
103
103
|
/**
|
|
104
|
-
*
|
|
104
|
+
* Get the manifest for any registered vendor, adapter-backed or
|
|
105
|
+
* credential-only. Throws if unknown vendor. Use this (not
|
|
106
|
+
* `getAdapterFactory`) where only the credential shape matters.
|
|
107
|
+
*/
|
|
108
|
+
declare function getVendorManifest(vendor: string): AdapterManifest;
|
|
109
|
+
/**
|
|
110
|
+
* List all registered adapter vendor ids, sorted alphabetically.
|
|
111
|
+
* Credential-only vendors are not included: they cannot be passed to `createLlm`.
|
|
105
112
|
*/
|
|
106
113
|
declare function listVendors(): string[];
|
|
107
114
|
/**
|
|
108
|
-
* Return an aggregated manifest for all registered
|
|
109
|
-
* api-server's /llm-vendors/manifest endpoint.
|
|
115
|
+
* Return an aggregated manifest for all registered vendors, credential-only
|
|
116
|
+
* ones included. Used by api-server's /llm-vendors/manifest endpoint.
|
|
110
117
|
*/
|
|
111
118
|
declare function getManifest(): {
|
|
112
119
|
vendors: AdapterManifest[];
|
|
@@ -121,6 +128,8 @@ declare function getManifest(): {
|
|
|
121
128
|
* Consumers use:
|
|
122
129
|
* - `createLlm({vendor, auth, client?})` to get a ready-to-stream adapter instance.
|
|
123
130
|
* - `getManifest()` to enumerate registered vendors (used by api-server).
|
|
131
|
+
* - `getVendorManifest(vendor)` for one vendor's manifest, including
|
|
132
|
+
* credential-only vendors (e.g. `harness`) that have no adapter.
|
|
124
133
|
* - `normalizeAuth(vendor, rawCred)` to convert DB-shape creds to AuthSpec.
|
|
125
134
|
* - `pickAuthKind(vendor, rawCred)` to pick the right manifest authKind for
|
|
126
135
|
* a raw credential (used by api-server's `encryptCredential`).
|
|
@@ -129,4 +138,4 @@ declare function getManifest(): {
|
|
|
129
138
|
|
|
130
139
|
declare function createLlm<A extends AuthSpec = AuthSpec>(args: CreateLlmArgs<A>): Promise<LlmAdapter<A>>;
|
|
131
140
|
|
|
132
|
-
export { AdapterFactory, AdapterManifest, AuthKindSchema, AuthSpec, CreateLlmArgs, LlmAdapter, PromptRequest, type RawCredential, type RawCredentialLoose, ServiceAccountJson, assertValidRequest, createLlm, getAdapterFactory, getManifest, listVendors, normalizeAuth, pickAuthKind, registerAdapter, replaceAdapter, unregisterAdapter };
|
|
141
|
+
export { AdapterFactory, AdapterManifest, AuthKindSchema, AuthSpec, CreateLlmArgs, LlmAdapter, PromptRequest, type RawCredential, type RawCredentialLoose, ServiceAccountJson, assertValidRequest, createLlm, getAdapterFactory, getManifest, getVendorManifest, listVendors, normalizeAuth, pickAuthKind, registerAdapter, replaceAdapter, unregisterAdapter };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// src/registry.ts
|
|
2
2
|
var registry = /* @__PURE__ */ new Map();
|
|
3
|
+
var credentialVendors = /* @__PURE__ */ new Map();
|
|
3
4
|
function registerAdapter(factory) {
|
|
4
|
-
if (registry.has(factory.vendor)) {
|
|
5
|
+
if (registry.has(factory.vendor) || credentialVendors.has(factory.vendor)) {
|
|
5
6
|
throw new Error(
|
|
6
7
|
`Adapter already registered for vendor '${factory.vendor}'. Use replaceAdapter() if you intended to override.`
|
|
7
8
|
);
|
|
@@ -13,6 +14,15 @@ function registerAdapter(factory) {
|
|
|
13
14
|
}
|
|
14
15
|
registry.set(factory.vendor, factory);
|
|
15
16
|
}
|
|
17
|
+
function registerCredentialVendor(manifest) {
|
|
18
|
+
if (!manifest.credentialOnly) {
|
|
19
|
+
throw new Error(`Vendor '${manifest.vendor}' manifest is not marked credentialOnly.`);
|
|
20
|
+
}
|
|
21
|
+
if (registry.has(manifest.vendor) || credentialVendors.has(manifest.vendor)) {
|
|
22
|
+
throw new Error(`Vendor '${manifest.vendor}' is already registered.`);
|
|
23
|
+
}
|
|
24
|
+
credentialVendors.set(manifest.vendor, manifest);
|
|
25
|
+
}
|
|
16
26
|
function replaceAdapter(factory) {
|
|
17
27
|
registry.set(factory.vendor, factory);
|
|
18
28
|
}
|
|
@@ -22,6 +32,11 @@ function unregisterAdapter(vendor) {
|
|
|
22
32
|
function getAdapterFactory(vendor) {
|
|
23
33
|
const factory = registry.get(vendor);
|
|
24
34
|
if (!factory) {
|
|
35
|
+
if (credentialVendors.has(vendor)) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
`Vendor '${vendor}' is credential-only: @jambonz/llm has no adapter for it.`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
25
40
|
const known = Array.from(registry.keys()).sort().join(", ") || "(none)";
|
|
26
41
|
throw new Error(
|
|
27
42
|
`Unknown vendor '${vendor}'. Registered vendors: ${known}`
|
|
@@ -29,11 +44,22 @@ function getAdapterFactory(vendor) {
|
|
|
29
44
|
}
|
|
30
45
|
return factory;
|
|
31
46
|
}
|
|
47
|
+
function getVendorManifest(vendor) {
|
|
48
|
+
const manifest = registry.get(vendor)?.manifest ?? credentialVendors.get(vendor);
|
|
49
|
+
if (!manifest) {
|
|
50
|
+
const known = [...registry.keys(), ...credentialVendors.keys()].sort().join(", ") || "(none)";
|
|
51
|
+
throw new Error(`Unknown vendor '${vendor}'. Registered vendors: ${known}`);
|
|
52
|
+
}
|
|
53
|
+
return manifest;
|
|
54
|
+
}
|
|
32
55
|
function listVendors() {
|
|
33
56
|
return Array.from(registry.keys()).sort();
|
|
34
57
|
}
|
|
35
58
|
function getManifest() {
|
|
36
|
-
const vendors =
|
|
59
|
+
const vendors = [
|
|
60
|
+
...Array.from(registry.values()).map((f) => f.manifest),
|
|
61
|
+
...credentialVendors.values()
|
|
62
|
+
].sort((a, b) => a.vendor.localeCompare(b.vendor));
|
|
37
63
|
return { vendors };
|
|
38
64
|
}
|
|
39
65
|
|
|
@@ -3725,6 +3751,39 @@ var openRouterFactory = {
|
|
|
3725
3751
|
create: () => new OpenRouterAdapter()
|
|
3726
3752
|
};
|
|
3727
3753
|
|
|
3754
|
+
// src/vendors/harness.ts
|
|
3755
|
+
var harnessManifest = {
|
|
3756
|
+
vendor: "harness",
|
|
3757
|
+
displayName: "Harness",
|
|
3758
|
+
authKinds: [
|
|
3759
|
+
{
|
|
3760
|
+
// Only the form schema matters for a credential-only vendor; no
|
|
3761
|
+
// AuthSpec is ever built from it.
|
|
3762
|
+
kind: "apiKey",
|
|
3763
|
+
displayName: "API Key",
|
|
3764
|
+
fields: [
|
|
3765
|
+
{
|
|
3766
|
+
name: "url",
|
|
3767
|
+
label: "WebSocket URL",
|
|
3768
|
+
type: "url",
|
|
3769
|
+
required: true,
|
|
3770
|
+
help: "wss:// URL of your harness. ws:// is accepted only for a private or localhost address."
|
|
3771
|
+
},
|
|
3772
|
+
{
|
|
3773
|
+
name: "apiKey",
|
|
3774
|
+
label: "API Key",
|
|
3775
|
+
type: "password",
|
|
3776
|
+
required: true,
|
|
3777
|
+
help: 'Sent to the harness as "Authorization: Bearer <key>" when each call connects.'
|
|
3778
|
+
}
|
|
3779
|
+
]
|
|
3780
|
+
}
|
|
3781
|
+
],
|
|
3782
|
+
knownModels: [],
|
|
3783
|
+
supportsModelListing: false,
|
|
3784
|
+
credentialOnly: true
|
|
3785
|
+
};
|
|
3786
|
+
|
|
3728
3787
|
// src/adapters/index.ts
|
|
3729
3788
|
registerAdapter(openAIFactory);
|
|
3730
3789
|
registerAdapter(deepseekFactory);
|
|
@@ -3742,6 +3801,7 @@ registerAdapter(azureOpenAIFactory);
|
|
|
3742
3801
|
registerAdapter(groqFactory);
|
|
3743
3802
|
registerAdapter(huggingfaceFactory);
|
|
3744
3803
|
registerAdapter(openRouterFactory);
|
|
3804
|
+
registerCredentialVendor(harnessManifest);
|
|
3745
3805
|
|
|
3746
3806
|
// src/normalize-auth.ts
|
|
3747
3807
|
function normalizeAuth(vendor, raw) {
|
|
@@ -3889,8 +3949,7 @@ function parseServiceKey(value) {
|
|
|
3889
3949
|
|
|
3890
3950
|
// src/pick-auth-kind.ts
|
|
3891
3951
|
function pickAuthKind(vendor, raw) {
|
|
3892
|
-
const
|
|
3893
|
-
const { authKinds } = factory.manifest;
|
|
3952
|
+
const { authKinds } = getVendorManifest(vendor);
|
|
3894
3953
|
if (authKinds.length === 1) {
|
|
3895
3954
|
return authKinds[0];
|
|
3896
3955
|
}
|
|
@@ -3950,6 +4009,7 @@ export {
|
|
|
3950
4009
|
createLlm,
|
|
3951
4010
|
getAdapterFactory,
|
|
3952
4011
|
getManifest,
|
|
4012
|
+
getVendorManifest,
|
|
3953
4013
|
listVendors,
|
|
3954
4014
|
normalizeAuth,
|
|
3955
4015
|
pickAuthKind,
|