@nuvin/nuvin-core 1.3.0 → 1.3.1

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/VERSION CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "1.3.0",
3
- "commit": "83fe0f5"
2
+ "version": "1.3.1",
3
+ "commit": "8fe7281"
4
4
  }
package/dist/index.d.ts CHANGED
@@ -1370,6 +1370,7 @@ interface CustomProviderDefinition {
1370
1370
  type?: 'openai-compat' | 'anthropic';
1371
1371
  baseUrl?: string;
1372
1372
  models?: ModelConfig;
1373
+ customHeaders?: Record<string, string>;
1373
1374
  }
1374
1375
  declare function createLLM(providerName: string, options?: LLMOptions, customProviders?: Record<string, CustomProviderDefinition>): LLMPort;
1375
1376
  declare function getAvailableProviders(customProviders?: Record<string, CustomProviderDefinition>): string[];
package/dist/index.js CHANGED
@@ -4711,11 +4711,13 @@ var BaseBearerAuthTransport = class {
4711
4711
  apiKey;
4712
4712
  baseUrl;
4713
4713
  version;
4714
- constructor(inner, apiKey, baseUrl, version) {
4714
+ customHeaders;
4715
+ constructor(inner, apiKey, baseUrl, version, customHeaders) {
4715
4716
  this.inner = inner;
4716
4717
  this.apiKey = apiKey;
4717
4718
  this.baseUrl = baseUrl ?? this.getDefaultBaseUrl();
4718
4719
  this.version = version;
4720
+ this.customHeaders = customHeaders;
4719
4721
  }
4720
4722
  buildFullUrl(path9) {
4721
4723
  if (path9.startsWith("/")) {
@@ -4724,14 +4726,16 @@ var BaseBearerAuthTransport = class {
4724
4726
  return path9;
4725
4727
  }
4726
4728
  makeAuthHeaders(headers) {
4727
- if (!this.apiKey || this.apiKey.trim() === "") {
4728
- throw new Error("API key missing");
4729
- }
4730
4729
  const base = headers ? { ...headers } : {};
4731
- base.Authorization = `Bearer ${this.apiKey}`;
4732
4730
  if (!base["User-Agent"] && this.version) {
4733
4731
  base["User-Agent"] = `nuvin-cli/${this.version}`;
4734
4732
  }
4733
+ if (this.apiKey && this.apiKey.trim() !== "" && !this.customHeaders?.Authorization) {
4734
+ base.Authorization = `Bearer ${this.apiKey}`;
4735
+ }
4736
+ if (this.customHeaders) {
4737
+ Object.assign(base, this.customHeaders);
4738
+ }
4735
4739
  return base;
4736
4740
  }
4737
4741
  async get(url, headers, signal) {
@@ -4751,8 +4755,8 @@ var BaseBearerAuthTransport = class {
4751
4755
  // transports/simple-bearer-transport.ts
4752
4756
  var SimpleBearerAuthTransport = class extends BaseBearerAuthTransport {
4753
4757
  defaultUrl;
4754
- constructor(inner, defaultBaseUrl, apiKey, baseUrl, version) {
4755
- super(inner, apiKey, baseUrl ?? defaultBaseUrl, version);
4758
+ constructor(inner, defaultBaseUrl, apiKey, baseUrl, version, customHeaders) {
4759
+ super(inner, apiKey, baseUrl ?? defaultBaseUrl, version, customHeaders);
4756
4760
  this.defaultUrl = defaultBaseUrl;
4757
4761
  }
4758
4762
  getDefaultBaseUrl() {
@@ -4761,8 +4765,8 @@ var SimpleBearerAuthTransport = class extends BaseBearerAuthTransport {
4761
4765
  };
4762
4766
 
4763
4767
  // transports/transport-factory.ts
4764
- function createTransport(inner, defaultBaseUrl, apiKey, baseUrl, version) {
4765
- return new SimpleBearerAuthTransport(inner, defaultBaseUrl, apiKey, baseUrl, version);
4768
+ function createTransport(inner, defaultBaseUrl, apiKey, baseUrl, version, customHeaders) {
4769
+ return new SimpleBearerAuthTransport(inner, defaultBaseUrl, apiKey, baseUrl, version, customHeaders);
4766
4770
  }
4767
4771
 
4768
4772
  // llm-providers/model-limits.ts
@@ -5417,6 +5421,19 @@ var llm_provider_config_default = {
5417
5421
  promptCaching: false,
5418
5422
  getModels: true
5419
5423
  }
5424
+ },
5425
+ {
5426
+ name: "kimi-for-coding",
5427
+ type: "openai-compat",
5428
+ baseUrl: "https://api.kimi.com/coding/v1",
5429
+ features: {
5430
+ promptCaching: true,
5431
+ getModels: true,
5432
+ includeUsage: true
5433
+ },
5434
+ customHeaders: {
5435
+ "User-Agent": "KimiCLI/0.59"
5436
+ }
5420
5437
  }
5421
5438
  ]
5422
5439
  };
@@ -5428,13 +5445,15 @@ var GenericLLM = class extends BaseLLM {
5428
5445
  includeUsage;
5429
5446
  modelConfig;
5430
5447
  providerName;
5431
- constructor(baseUrl, modelConfig, opts = {}) {
5448
+ customHeaders;
5449
+ constructor(baseUrl, modelConfig, opts = {}, customHeaders) {
5432
5450
  const { enablePromptCaching = false, includeUsage = false, providerName = "unknown", ...restOpts } = opts;
5433
5451
  super(opts.apiUrl || baseUrl, { enablePromptCaching });
5434
5452
  this.includeUsage = includeUsage;
5435
5453
  this.modelConfig = modelConfig;
5436
5454
  this.providerName = providerName;
5437
5455
  this.opts = restOpts;
5456
+ this.customHeaders = customHeaders;
5438
5457
  }
5439
5458
  createTransport() {
5440
5459
  const base = new FetchTransport({
@@ -5444,7 +5463,7 @@ var GenericLLM = class extends BaseLLM {
5444
5463
  maxFileSize: 5 * 1024 * 1024,
5445
5464
  captureResponseBody: true
5446
5465
  });
5447
- return createTransport(base, this.apiUrl, this.opts.apiKey, this.opts.apiUrl, this.opts.version);
5466
+ return createTransport(base, this.apiUrl, this.opts.apiKey, this.opts.apiUrl, this.opts.version, this.customHeaders);
5448
5467
  }
5449
5468
  async getModels(signal) {
5450
5469
  if (this.modelConfig === false) {
@@ -5512,6 +5531,7 @@ function mergeProviders(customProviders) {
5512
5531
  type: custom.type ?? "openai-compat",
5513
5532
  baseUrl: custom.baseUrl,
5514
5533
  models: custom.models ?? false,
5534
+ customHeaders: custom.customHeaders,
5515
5535
  features: existing?.features ?? {
5516
5536
  promptCaching: false,
5517
5537
  getModels: custom.models !== false,
@@ -5535,7 +5555,7 @@ function createLLM(providerName, options = {}, customProviders) {
5535
5555
  providerName: config.name,
5536
5556
  enablePromptCaching: options.enablePromptCaching ?? config.features.promptCaching,
5537
5557
  includeUsage: options.includeUsage ?? config.features.includeUsage
5538
- });
5558
+ }, config.customHeaders);
5539
5559
  }
5540
5560
  function getAvailableProviders(customProviders) {
5541
5561
  const allProviders = mergeProviders(customProviders);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuvin/nuvin-core",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "",
5
5
  "private": false,
6
6
  "main": "dist/index.js",