@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 CHANGED
@@ -34,6 +34,7 @@ __export(src_exports, {
34
34
  createLlm: () => createLlm,
35
35
  getAdapterFactory: () => getAdapterFactory,
36
36
  getManifest: () => getManifest,
37
+ getVendorManifest: () => getVendorManifest,
37
38
  listVendors: () => listVendors,
38
39
  normalizeAuth: () => normalizeAuth,
39
40
  pickAuthKind: () => pickAuthKind,
@@ -45,8 +46,9 @@ module.exports = __toCommonJS(src_exports);
45
46
 
46
47
  // src/registry.ts
47
48
  var registry = /* @__PURE__ */ new Map();
49
+ var credentialVendors = /* @__PURE__ */ new Map();
48
50
  function registerAdapter(factory) {
49
- if (registry.has(factory.vendor)) {
51
+ if (registry.has(factory.vendor) || credentialVendors.has(factory.vendor)) {
50
52
  throw new Error(
51
53
  `Adapter already registered for vendor '${factory.vendor}'. Use replaceAdapter() if you intended to override.`
52
54
  );
@@ -58,6 +60,15 @@ function registerAdapter(factory) {
58
60
  }
59
61
  registry.set(factory.vendor, factory);
60
62
  }
63
+ function registerCredentialVendor(manifest) {
64
+ if (!manifest.credentialOnly) {
65
+ throw new Error(`Vendor '${manifest.vendor}' manifest is not marked credentialOnly.`);
66
+ }
67
+ if (registry.has(manifest.vendor) || credentialVendors.has(manifest.vendor)) {
68
+ throw new Error(`Vendor '${manifest.vendor}' is already registered.`);
69
+ }
70
+ credentialVendors.set(manifest.vendor, manifest);
71
+ }
61
72
  function replaceAdapter(factory) {
62
73
  registry.set(factory.vendor, factory);
63
74
  }
@@ -67,6 +78,11 @@ function unregisterAdapter(vendor) {
67
78
  function getAdapterFactory(vendor) {
68
79
  const factory = registry.get(vendor);
69
80
  if (!factory) {
81
+ if (credentialVendors.has(vendor)) {
82
+ throw new Error(
83
+ `Vendor '${vendor}' is credential-only: @jambonz/llm has no adapter for it.`
84
+ );
85
+ }
70
86
  const known = Array.from(registry.keys()).sort().join(", ") || "(none)";
71
87
  throw new Error(
72
88
  `Unknown vendor '${vendor}'. Registered vendors: ${known}`
@@ -74,11 +90,22 @@ function getAdapterFactory(vendor) {
74
90
  }
75
91
  return factory;
76
92
  }
93
+ function getVendorManifest(vendor) {
94
+ const manifest = registry.get(vendor)?.manifest ?? credentialVendors.get(vendor);
95
+ if (!manifest) {
96
+ const known = [...registry.keys(), ...credentialVendors.keys()].sort().join(", ") || "(none)";
97
+ throw new Error(`Unknown vendor '${vendor}'. Registered vendors: ${known}`);
98
+ }
99
+ return manifest;
100
+ }
77
101
  function listVendors() {
78
102
  return Array.from(registry.keys()).sort();
79
103
  }
80
104
  function getManifest() {
81
- const vendors = Array.from(registry.values()).map((f) => f.manifest).sort((a, b) => a.vendor.localeCompare(b.vendor));
105
+ const vendors = [
106
+ ...Array.from(registry.values()).map((f) => f.manifest),
107
+ ...credentialVendors.values()
108
+ ].sort((a, b) => a.vendor.localeCompare(b.vendor));
82
109
  return { vendors };
83
110
  }
84
111
 
@@ -3764,6 +3791,39 @@ var openRouterFactory = {
3764
3791
  create: () => new OpenRouterAdapter()
3765
3792
  };
3766
3793
 
3794
+ // src/vendors/harness.ts
3795
+ var harnessManifest = {
3796
+ vendor: "harness",
3797
+ displayName: "Harness",
3798
+ authKinds: [
3799
+ {
3800
+ // Only the form schema matters for a credential-only vendor; no
3801
+ // AuthSpec is ever built from it.
3802
+ kind: "apiKey",
3803
+ displayName: "API Key",
3804
+ fields: [
3805
+ {
3806
+ name: "url",
3807
+ label: "WebSocket URL",
3808
+ type: "url",
3809
+ required: true,
3810
+ help: "wss:// URL of your harness. ws:// is accepted only for a private or localhost address."
3811
+ },
3812
+ {
3813
+ name: "apiKey",
3814
+ label: "API Key",
3815
+ type: "password",
3816
+ required: true,
3817
+ help: 'Sent to the harness as "Authorization: Bearer <key>" when each call connects.'
3818
+ }
3819
+ ]
3820
+ }
3821
+ ],
3822
+ knownModels: [],
3823
+ supportsModelListing: false,
3824
+ credentialOnly: true
3825
+ };
3826
+
3767
3827
  // src/adapters/index.ts
3768
3828
  registerAdapter(openAIFactory);
3769
3829
  registerAdapter(deepseekFactory);
@@ -3781,6 +3841,7 @@ registerAdapter(azureOpenAIFactory);
3781
3841
  registerAdapter(groqFactory);
3782
3842
  registerAdapter(huggingfaceFactory);
3783
3843
  registerAdapter(openRouterFactory);
3844
+ registerCredentialVendor(harnessManifest);
3784
3845
 
3785
3846
  // src/normalize-auth.ts
3786
3847
  function normalizeAuth(vendor, raw) {
@@ -3928,8 +3989,7 @@ function parseServiceKey(value) {
3928
3989
 
3929
3990
  // src/pick-auth-kind.ts
3930
3991
  function pickAuthKind(vendor, raw) {
3931
- const factory = getAdapterFactory(vendor);
3932
- const { authKinds } = factory.manifest;
3992
+ const { authKinds } = getVendorManifest(vendor);
3933
3993
  if (authKinds.length === 1) {
3934
3994
  return authKinds[0];
3935
3995
  }
@@ -3990,6 +4050,7 @@ async function createLlm(args) {
3990
4050
  createLlm,
3991
4051
  getAdapterFactory,
3992
4052
  getManifest,
4053
+ getVendorManifest,
3993
4054
  listVendors,
3994
4055
  normalizeAuth,
3995
4056
  pickAuthKind,