@demicodes/provider 0.3.2 → 0.4.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as ProviderCredentialInfo } from "./types-
|
|
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;
|
|
@@ -56,11 +56,5 @@ declare class CredentialPoolError extends Error {
|
|
|
56
56
|
readonly code: 'credential_not_found' | 'credential_invalid';
|
|
57
57
|
constructor(code: 'credential_not_found' | 'credential_invalid', message: string);
|
|
58
58
|
}
|
|
59
|
-
declare function runVendorLoginCommand(command: string, args: string[], options?: {
|
|
60
|
-
signal?: AbortSignal;
|
|
61
|
-
}): Promise<{
|
|
62
|
-
status: 'completed' | 'cancelled' | 'failed' | 'unavailable';
|
|
63
|
-
message?: string;
|
|
64
|
-
}>;
|
|
65
59
|
//#endregion
|
|
66
|
-
export { CredentialEntryMeta, CredentialPoolError, FileCredentialPool, FileCredentialPoolOptions, credentialIdFromIdentity, newCredentialId, resolveDemiHome
|
|
60
|
+
export { CredentialEntryMeta, CredentialPoolError, FileCredentialPool, FileCredentialPoolOptions, credentialIdFromIdentity, newCredentialId, resolveDemiHome };
|
|
@@ -201,62 +201,5 @@ var CredentialPoolError = class extends Error {
|
|
|
201
201
|
this.name = "CredentialPoolError";
|
|
202
202
|
}
|
|
203
203
|
};
|
|
204
|
-
async function runVendorLoginCommand(command, args, options = {}) {
|
|
205
|
-
const { spawn } = await import("node:child_process");
|
|
206
|
-
return new Promise((resolvePromise) => {
|
|
207
|
-
let child;
|
|
208
|
-
try {
|
|
209
|
-
child = spawn(command, args, {
|
|
210
|
-
stdio: "inherit",
|
|
211
|
-
env: process.env,
|
|
212
|
-
shell: false
|
|
213
|
-
});
|
|
214
|
-
} catch (error) {
|
|
215
|
-
resolvePromise({
|
|
216
|
-
status: "unavailable",
|
|
217
|
-
message: error instanceof Error ? error.message : String(error)
|
|
218
|
-
});
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
const onAbort = () => {
|
|
222
|
-
child.kill("SIGTERM");
|
|
223
|
-
};
|
|
224
|
-
if (options.signal) {
|
|
225
|
-
if (options.signal.aborted) {
|
|
226
|
-
child.kill("SIGTERM");
|
|
227
|
-
resolvePromise({ status: "cancelled" });
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
options.signal.addEventListener("abort", onAbort, { once: true });
|
|
231
|
-
}
|
|
232
|
-
child.on("error", (error) => {
|
|
233
|
-
options.signal?.removeEventListener("abort", onAbort);
|
|
234
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
235
|
-
if (errorCode(error) === "ENOENT") {
|
|
236
|
-
resolvePromise({
|
|
237
|
-
status: "unavailable",
|
|
238
|
-
message: `Command not found: ${command}`
|
|
239
|
-
});
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
resolvePromise({
|
|
243
|
-
status: "failed",
|
|
244
|
-
message: msg
|
|
245
|
-
});
|
|
246
|
-
});
|
|
247
|
-
child.on("exit", (code, signal) => {
|
|
248
|
-
options.signal?.removeEventListener("abort", onAbort);
|
|
249
|
-
if (options.signal?.aborted || signal === "SIGTERM" || signal === "SIGINT") {
|
|
250
|
-
resolvePromise({ status: "cancelled" });
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
if (code === 0) resolvePromise({ status: "completed" });
|
|
254
|
-
else resolvePromise({
|
|
255
|
-
status: "failed",
|
|
256
|
-
message: `${command} exited with code ${code ?? "null"}`
|
|
257
|
-
});
|
|
258
|
-
});
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
204
|
//#endregion
|
|
262
|
-
export { CredentialPoolError, FileCredentialPool, credentialIdFromIdentity, newCredentialId, resolveDemiHome
|
|
205
|
+
export { CredentialPoolError, FileCredentialPool, credentialIdFromIdentity, newCredentialId, resolveDemiHome };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
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
|
/**
|
|
@@ -64,4 +64,4 @@ declare function numberHeader(headers: Headers, name: string): number | null;
|
|
|
64
64
|
/** Builds a redacted provider `error` event from a failed HTTP response. */
|
|
65
65
|
declare function httpRequestFailedEvent(response: Response, secret: string | null | undefined, providerLabel: string): Promise<ProviderEvent>;
|
|
66
66
|
//#endregion
|
|
67
|
-
export { AgentProvider, type CreateProviderQuotaOptions, DEFAULT_ATTACHMENT_EXTENSIONS, type EnsureQuotaOptions, InferenceItem, InferenceRequest, InferenceSteer, ModelPolicy, type ModelSelectionFromCatalogOptions, Provider, ProviderAuth, ProviderAuthState, ProviderCredentialActive, ProviderCredentialAddInput, ProviderCredentialInfo, ProviderCredentialLoginOptions, ProviderCredentialLoginResult, ProviderCredentials, ProviderCredentialsCapability, ProviderEvent, ProviderFactoryDefinition, ProviderModel, ProviderModelCost, ProviderModelList, type ProviderQuota, type ProviderQuotaCapability, type ProviderQuotaObserveInput, type ProviderQuotaPlan, type ProviderQuotaProbeCost, type ProviderQuotaProbeOptions, type ProviderQuotaProbeResult, type ProviderQuotaSeverity, type ProviderQuotaSnapshot, type ProviderQuotaSource, ProviderQuotaUnsupportedError, type ProviderQuotaWindow, type ProviderQuotaWindowUnit, ProviderRun, ProviderRuntimeFactory, ProviderRuntimeState, ProviderSelection, ProviderServiceTier, ToolDefinition, applyModelPolicy, authStatusFromKey, clampPromptCacheKey, clampUsedPercent, createProviderQuota, defineProvider, ensureQuota, httpErrorCode, httpRequestFailedEvent, modelSelectionFromCatalog, normalizeErrorCode, numberHeader, providerErrorFromUnknown, providerRuntime, redactCredentialText, redactSecretText, retryAfterMsFromHeader, severityFromUsedPercent, thinkingCapabilitiesFromProviderModel, toolResultContentToText, unixSecondsToIso, usedPercentFromRatio, withProviderId };
|
|
67
|
+
export { AgentProvider, type CreateProviderQuotaOptions, DEFAULT_ATTACHMENT_EXTENSIONS, type EnsureQuotaOptions, InferenceItem, InferenceRequest, InferenceSteer, ModelPolicy, type ModelSelectionFromCatalogOptions, Provider, ProviderAuth, ProviderAuthState, ProviderCredentialActive, ProviderCredentialAddInput, ProviderCredentialInfo, ProviderCredentialLoginOptions, ProviderCredentialLoginPending, ProviderCredentialLoginResult, ProviderCredentials, ProviderCredentialsCapability, ProviderEvent, ProviderFactoryDefinition, ProviderModel, ProviderModelCost, ProviderModelList, type ProviderQuota, type ProviderQuotaCapability, type ProviderQuotaObserveInput, type ProviderQuotaPlan, type ProviderQuotaProbeCost, type ProviderQuotaProbeOptions, type ProviderQuotaProbeResult, type ProviderQuotaSeverity, type ProviderQuotaSnapshot, type ProviderQuotaSource, ProviderQuotaUnsupportedError, type ProviderQuotaWindow, type ProviderQuotaWindowUnit, ProviderRun, ProviderRuntimeFactory, ProviderRuntimeState, ProviderSelection, ProviderServiceTier, ToolDefinition, applyModelPolicy, authStatusFromKey, clampPromptCacheKey, clampUsedPercent, createProviderQuota, defineProvider, ensureQuota, httpErrorCode, httpRequestFailedEvent, modelSelectionFromCatalog, normalizeErrorCode, numberHeader, providerErrorFromUnknown, providerRuntime, redactCredentialText, redactSecretText, retryAfterMsFromHeader, severityFromUsedPercent, thinkingCapabilitiesFromProviderModel, toolResultContentToText, unixSecondsToIso, usedPercentFromRatio, withProviderId };
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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.
|
|
@@ -280,18 +280,39 @@ interface ProviderCredentialActive {
|
|
|
280
280
|
/** Same shape as auth status, for the active credential. */
|
|
281
281
|
status: ProviderAuthState;
|
|
282
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* User-facing material issued mid-flow by a device-code login: the product
|
|
285
|
+
* relays it to the user, who completes login from any browser on any device.
|
|
286
|
+
*/
|
|
287
|
+
interface ProviderCredentialLoginPending {
|
|
288
|
+
/** URL the user opens to confirm the login. */
|
|
289
|
+
verificationUrl: string;
|
|
290
|
+
/** One-time code the user enters at the verification URL (device-code flows). */
|
|
291
|
+
userCode?: string | null;
|
|
292
|
+
/** ISO-8601 expiry of the code, when the vendor exposes one. */
|
|
293
|
+
expiresAt?: string | null;
|
|
294
|
+
/**
|
|
295
|
+
* True when the vendor displays a code AFTER approval that the user must
|
|
296
|
+
* bring back; the product collects it via `promptForCode`.
|
|
297
|
+
*/
|
|
298
|
+
requiresCodeInput?: boolean;
|
|
299
|
+
}
|
|
283
300
|
interface ProviderCredentialLoginOptions {
|
|
284
|
-
/** Abort the
|
|
301
|
+
/** Abort the login flow. */
|
|
285
302
|
signal?: AbortSignal;
|
|
286
|
-
/**
|
|
287
|
-
|
|
303
|
+
/** Fires once when the flow issues user-facing material (device-code login). */
|
|
304
|
+
onPending?: (pending: ProviderCredentialLoginPending) => void;
|
|
305
|
+
/** Collects the code the user copied back from the vendor page (`requiresCodeInput` flows). */
|
|
306
|
+
promptForCode?: () => Promise<string>;
|
|
288
307
|
}
|
|
289
308
|
/**
|
|
290
|
-
* Login invoke result
|
|
291
|
-
*
|
|
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`.
|
|
292
312
|
*/
|
|
293
313
|
type ProviderCredentialLoginResult = {
|
|
294
314
|
status: 'completed';
|
|
315
|
+
credentialId: string;
|
|
295
316
|
} | {
|
|
296
317
|
status: 'cancelled';
|
|
297
318
|
} | {
|
|
@@ -312,7 +333,7 @@ type ProviderCredentialsCapability = {
|
|
|
312
333
|
mode: 'none';
|
|
313
334
|
} | {
|
|
314
335
|
mode: 'supported';
|
|
315
|
-
/** Can
|
|
336
|
+
/** Can run the vendor's native login flow (`beginLogin`). */
|
|
316
337
|
canBeginLogin?: boolean;
|
|
317
338
|
/** Can import from the vendor default location into the pool. */
|
|
318
339
|
canImportDefault?: boolean;
|
|
@@ -335,8 +356,9 @@ interface ProviderCredentials {
|
|
|
335
356
|
*/
|
|
336
357
|
setActive(credentialId: string): Promise<ProviderCredentialActive> | ProviderCredentialActive;
|
|
337
358
|
/**
|
|
338
|
-
*
|
|
339
|
-
*
|
|
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.
|
|
340
362
|
*/
|
|
341
363
|
beginLogin?(options?: ProviderCredentialLoginOptions): Promise<ProviderCredentialLoginResult>;
|
|
342
364
|
/**
|
|
@@ -430,4 +452,4 @@ type ModelPolicy = {
|
|
|
430
452
|
default?: string;
|
|
431
453
|
};
|
|
432
454
|
//#endregion
|
|
433
|
-
export {
|
|
455
|
+
export { ProviderQuota as A, ProviderQuotaUnsupportedError as B, ProviderRuntimeFactory as C, ToolDefinition as D, ProviderServiceTier as E, ProviderQuotaProbeOptions as F, ensureQuota as G, ProviderQuotaWindowUnit as H, ProviderQuotaProbeResult as I, usedPercentFromRatio as J, severityFromUsedPercent as K, ProviderQuotaSeverity as L, ProviderQuotaObserveInput as M, ProviderQuotaPlan as N, CreateProviderQuotaOptions as O, ProviderQuotaProbeCost as P, ProviderQuotaSnapshot as R, ProviderRun as S, ProviderSelection as T, clampUsedPercent as U, ProviderQuotaWindow as V, createProviderQuota as W, ProviderEvent as _, ModelPolicy as a, ProviderModelCost as b, ProviderAuthState as c, ProviderCredentialInfo as d, ProviderCredentialLoginOptions as f, ProviderCredentialsCapability as g, ProviderCredentials as h, InferenceSteer as i, ProviderQuotaCapability as j, EnsureQuotaOptions as k, ProviderCredentialActive as l, ProviderCredentialLoginResult as m, InferenceItem as n, Provider as o, ProviderCredentialLoginPending as p, unixSecondsToIso as q, InferenceRequest as r, ProviderAuth as s, AgentProvider as t, ProviderCredentialAddInput as u, ProviderFactoryDefinition as v, ProviderRuntimeState as w, ProviderModelList as x, ProviderModel as y, ProviderQuotaSource as z };
|