@demicodes/provider 0.4.0 → 0.4.2

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.
@@ -1,4 +1,4 @@
1
- import { d as ProviderCredentialInfo } from "./types-DO0VKCUa.mjs";
1
+ import { d as ProviderCredentialInfo } from "./types-DbFB3sp6.mjs";
2
2
  //#region src/credentials-pool.d.ts
3
3
  interface CredentialEntryMeta {
4
4
  id: string;
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as ProviderQuota, B as ProviderQuotaUnsupportedError, C as ProviderRuntimeFactory, D as ToolDefinition, E as ProviderServiceTier, F as ProviderQuotaProbeOptions, G as ensureQuota, H as ProviderQuotaWindowUnit, I as ProviderQuotaProbeResult, J as usedPercentFromRatio, K as severityFromUsedPercent, L as ProviderQuotaSeverity, M as ProviderQuotaObserveInput, N as ProviderQuotaPlan, O as CreateProviderQuotaOptions, P as ProviderQuotaProbeCost, R as ProviderQuotaSnapshot, S as ProviderRun, T as ProviderSelection, U as clampUsedPercent, V as ProviderQuotaWindow, W as createProviderQuota, _ as ProviderEvent, a as ModelPolicy, b as ProviderModelCost, c as ProviderAuthState, d as ProviderCredentialInfo, f as ProviderCredentialLoginOptions, g as ProviderCredentialsCapability, h as ProviderCredentials, i as InferenceSteer, j as ProviderQuotaCapability, k as EnsureQuotaOptions, l as ProviderCredentialActive, m as ProviderCredentialLoginResult, n as InferenceItem, o as Provider, p as ProviderCredentialLoginPending, q as unixSecondsToIso, r as InferenceRequest, s as ProviderAuth, t as AgentProvider, u as ProviderCredentialAddInput, v as ProviderFactoryDefinition, w as ProviderRuntimeState, x as ProviderModelList, y as ProviderModel, z as ProviderQuotaSource } from "./types-DO0VKCUa.mjs";
1
+ import { A as ProviderQuota, B as ProviderQuotaUnsupportedError, C as ProviderRuntimeFactory, D as ToolDefinition, E as ProviderServiceTier, F as ProviderQuotaProbeOptions, G as ensureQuota, H as ProviderQuotaWindowUnit, I as ProviderQuotaProbeResult, J as usedPercentFromRatio, K as severityFromUsedPercent, L as ProviderQuotaSeverity, M as ProviderQuotaObserveInput, N as ProviderQuotaPlan, O as CreateProviderQuotaOptions, P as ProviderQuotaProbeCost, R as ProviderQuotaSnapshot, S as ProviderRun, T as ProviderSelection, U as clampUsedPercent, V as ProviderQuotaWindow, W as createProviderQuota, _ as ProviderEvent, a as ModelPolicy, b as ProviderModelCost, c as ProviderAuthState, d as ProviderCredentialInfo, f as ProviderCredentialLoginOptions, g as ProviderCredentialsCapability, h as ProviderCredentials, i as InferenceSteer, j as ProviderQuotaCapability, k as EnsureQuotaOptions, l as ProviderCredentialActive, m as ProviderCredentialLoginResult, n as InferenceItem, o as Provider, p as ProviderCredentialLoginPending, q as unixSecondsToIso, r as InferenceRequest, s as ProviderAuth, t as AgentProvider, u as ProviderCredentialAddInput, v as ProviderFactoryDefinition, w as ProviderRuntimeState, x as ProviderModelList, y as ProviderModel, z as ProviderQuotaSource } from "./types-DbFB3sp6.mjs";
2
2
  import { FileExtension, ModelSelection, ThinkingCapability, ThinkingConfig, ToolResultContentBlock } from "@demicodes/core";
3
3
  //#region src/content.d.ts
4
4
  /**
package/dist/index.mjs CHANGED
@@ -139,9 +139,9 @@ function httpErrorCode(status, message) {
139
139
  function normalizeErrorCode(code, message) {
140
140
  const value = `${code ?? ""} ${message}`.toLowerCase();
141
141
  if (/context|too long|max.*token/.test(value)) return "context_length_exceeded";
142
- if (/rate|quota|billing|limit/.test(value)) return "rate_limit";
143
- if (/auth|unauth|invalid.*key|expired/.test(value)) return "auth_expired";
144
- if (/overload|unavailable|timeout/.test(value)) return "overloaded";
142
+ if (/rate|quota|usage|billing|balance|limit/.test(value)) return "rate_limit";
143
+ if (/auth|invalid.*(key|token)|expired/.test(value)) return "auth_expired";
144
+ if (/overload|unavailable|timed?\s?out|fetch failed|network|socket|econn/.test(value)) return "overloaded";
145
145
  return code;
146
146
  }
147
147
  /** Builds a provider `error` event from an unknown thrown value, redacting `secret`. */
@@ -1,4 +1,4 @@
1
- import { S as ProviderRun, _ as ProviderEvent, i as InferenceSteer, r as InferenceRequest, t as AgentProvider } from "./types-DO0VKCUa.mjs";
1
+ import { S as ProviderRun, _ as ProviderEvent, i as InferenceSteer, r as InferenceRequest, t as AgentProvider } from "./types-DbFB3sp6.mjs";
2
2
  //#region src/testing.d.ts
3
3
  /**
4
4
  * Scripted provider for testing. Each "turn" is a list of events to yield.
@@ -304,18 +304,15 @@ interface ProviderCredentialLoginOptions {
304
304
  onPending?: (pending: ProviderCredentialLoginPending) => void;
305
305
  /** Collects the code the user copied back from the vendor page (`requiresCodeInput` flows). */
306
306
  promptForCode?: () => Promise<string>;
307
- /** Prefer browser vs device/CLI when the vendor supports both; best-effort. */
308
- preferBrowser?: boolean;
309
307
  }
310
308
  /**
311
- * Login invoke result. Providers with a public device-code protocol (codex)
312
- * complete the flow natively, import the material into the pool, and return
313
- * the pool `credentialId`. CLI-spawning providers report vendor process status
314
- * only; the product should `importDefault` afterwards.
309
+ * Login invoke result. Every login flow runs the vendor's public protocol
310
+ * natively, imports the resulting material into the pool, and returns the
311
+ * pool `credentialId`.
315
312
  */
316
313
  type ProviderCredentialLoginResult = {
317
314
  status: 'completed';
318
- credentialId?: string;
315
+ credentialId: string;
319
316
  } | {
320
317
  status: 'cancelled';
321
318
  } | {
@@ -336,7 +333,7 @@ type ProviderCredentialsCapability = {
336
333
  mode: 'none';
337
334
  } | {
338
335
  mode: 'supported';
339
- /** Can spawn / open vendor login (`beginLogin`). */
336
+ /** Can run the vendor's native login flow (`beginLogin`). */
340
337
  canBeginLogin?: boolean;
341
338
  /** Can import from the vendor default location into the pool. */
342
339
  canImportDefault?: boolean;
@@ -359,8 +356,9 @@ interface ProviderCredentials {
359
356
  */
360
357
  setActive(credentialId: string): Promise<ProviderCredentialActive> | ProviderCredentialActive;
361
358
  /**
362
- * Invoke the vendors own login flow. Does not complete OAuth inside demi
363
- * and does not return a credential id.
359
+ * Run the vendor's public login protocol natively (device code or copy-back
360
+ * OAuth), surfacing user-facing material via `onPending`. On completion the
361
+ * material is imported into the pool and its `credentialId` is returned.
364
362
  */
365
363
  beginLogin?(options?: ProviderCredentialLoginOptions): Promise<ProviderCredentialLoginResult>;
366
364
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@demicodes/provider",
3
3
  "description": "Provider contract and shared building blocks for Demi inference adapters.",
4
- "version": "0.4.0",
4
+ "version": "0.4.2",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "exports": {