@jambonz/llm 0.6.7 → 0.6.9

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-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';
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-C_yrWq_0.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 VendorCategory, q as VertexServiceAccountAuth } from './types-C_yrWq_0.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
- * List all registered vendor ids, sorted alphabetically.
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 adapters. Used by
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-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';
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-C_yrWq_0.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 VendorCategory, q as VertexServiceAccountAuth } from './types-C_yrWq_0.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
- * List all registered vendor ids, sorted alphabetically.
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 adapters. Used by
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 = Array.from(registry.values()).map((f) => f.manifest).sort((a, b) => a.vendor.localeCompare(b.vendor));
59
+ const vendors = [
60
+ ...Array.from(registry.values()).map((f) => f.manifest),
61
+ ...credentialVendors.values()
62
+ ].map((m) => ({ ...m, category: m.category ?? "llm" })).sort((a, b) => a.vendor.localeCompare(b.vendor));
37
63
  return { vendors };
38
64
  }
39
65
 
@@ -3725,6 +3751,92 @@ 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
+ category: "llm"
3786
+ };
3787
+
3788
+ // src/vendors/dialogflow-ces.ts
3789
+ var dialogflowCesManifest = {
3790
+ vendor: "dialogflow_ces",
3791
+ displayName: "Dialogflow CES",
3792
+ authKinds: [
3793
+ {
3794
+ kind: "googleServiceAccount",
3795
+ displayName: "Service Account JSON",
3796
+ fields: [
3797
+ {
3798
+ name: "credentials",
3799
+ label: "Service Account Key (JSON)",
3800
+ type: "json-file",
3801
+ required: true,
3802
+ help: "The key of a service account allowed to run your CES agents (Customer Engagement Suite)."
3803
+ }
3804
+ ]
3805
+ }
3806
+ ],
3807
+ knownModels: [],
3808
+ supportsModelListing: false,
3809
+ docsUrl: "https://cloud.google.com/customer-engagement-ai/conversational-agents/ps",
3810
+ credentialOnly: true,
3811
+ category: "hosted"
3812
+ };
3813
+
3814
+ // src/vendors/openai-s2s.ts
3815
+ var openaiS2sManifest = {
3816
+ vendor: "openai_s2s",
3817
+ displayName: "OpenAI Realtime",
3818
+ authKinds: [
3819
+ {
3820
+ kind: "apiKey",
3821
+ displayName: "API Key",
3822
+ fields: [
3823
+ {
3824
+ name: "apiKey",
3825
+ label: "API Key",
3826
+ type: "password",
3827
+ required: true,
3828
+ help: "An OpenAI API key with access to the Realtime API."
3829
+ }
3830
+ ]
3831
+ }
3832
+ ],
3833
+ knownModels: [],
3834
+ supportsModelListing: false,
3835
+ docsUrl: "https://platform.openai.com/docs/guides/realtime",
3836
+ credentialOnly: true,
3837
+ category: "s2s"
3838
+ };
3839
+
3728
3840
  // src/adapters/index.ts
3729
3841
  registerAdapter(openAIFactory);
3730
3842
  registerAdapter(deepseekFactory);
@@ -3742,6 +3854,9 @@ registerAdapter(azureOpenAIFactory);
3742
3854
  registerAdapter(groqFactory);
3743
3855
  registerAdapter(huggingfaceFactory);
3744
3856
  registerAdapter(openRouterFactory);
3857
+ registerCredentialVendor(harnessManifest);
3858
+ registerCredentialVendor(openaiS2sManifest);
3859
+ registerCredentialVendor(dialogflowCesManifest);
3745
3860
 
3746
3861
  // src/normalize-auth.ts
3747
3862
  function normalizeAuth(vendor, raw) {
@@ -3889,8 +4004,7 @@ function parseServiceKey(value) {
3889
4004
 
3890
4005
  // src/pick-auth-kind.ts
3891
4006
  function pickAuthKind(vendor, raw) {
3892
- const factory = getAdapterFactory(vendor);
3893
- const { authKinds } = factory.manifest;
4007
+ const { authKinds } = getVendorManifest(vendor);
3894
4008
  if (authKinds.length === 1) {
3895
4009
  return authKinds[0];
3896
4010
  }
@@ -3950,6 +4064,7 @@ export {
3950
4064
  createLlm,
3951
4065
  getAdapterFactory,
3952
4066
  getManifest,
4067
+ getVendorManifest,
3953
4068
  listVendors,
3954
4069
  normalizeAuth,
3955
4070
  pickAuthKind,