@jacobbd/relay-ai 0.6.2 → 0.7.0
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/README.md +31 -4
- package/dist/{chunk-I3I5LKZI.js → chunk-IYYLLN5T.js} +62 -14
- package/dist/chunk-IYYLLN5T.js.map +1 -0
- package/dist/cli.js +320 -148
- package/dist/cli.js.map +1 -1
- package/dist/core/index.d.ts +91 -0
- package/dist/core/index.js +1854 -0
- package/dist/core/index.js.map +1 -0
- package/dist/{ui-command-GNCQS7F7.js → ui-command-3CWMSARO.js} +2 -2
- package/package.json +10 -2
- package/dist/chunk-I3I5LKZI.js.map +0 -1
- /package/dist/{ui-command-GNCQS7F7.js.map → ui-command-3CWMSARO.js.map} +0 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { LanguageModel } from 'ai';
|
|
2
|
+
|
|
3
|
+
/** Unconditionally-scoped route id: `${providerId}::${modelId}`. Never bare. */
|
|
4
|
+
type RelayRouteId = `${string}::${string}`;
|
|
5
|
+
type RelayCoreErrorCode = 'INVALID_ROUTE_ID' | 'ROUTE_NOT_FOUND' | 'PROVIDER_DISABLED' | 'CREDENTIAL_UNAVAILABLE' | 'OAUTH_REFRESH_FAILED' | 'UNSUPPORTED_MODEL' | 'UNSUPPORTED_REGISTRY_VERSION' | 'PROVIDER_LOAD_FAILED';
|
|
6
|
+
interface RelayModelDescriptor {
|
|
7
|
+
routeId: RelayRouteId;
|
|
8
|
+
providerId: string;
|
|
9
|
+
providerName: string;
|
|
10
|
+
modelId: string;
|
|
11
|
+
upstreamModelId: string;
|
|
12
|
+
displayName: string;
|
|
13
|
+
authType: 'api' | 'oauth' | 'none';
|
|
14
|
+
favorite: boolean;
|
|
15
|
+
contextWindow?: number;
|
|
16
|
+
pricing?: {
|
|
17
|
+
input: number;
|
|
18
|
+
output: number;
|
|
19
|
+
cacheRead?: number;
|
|
20
|
+
cacheWrite?: number;
|
|
21
|
+
};
|
|
22
|
+
capabilities: {
|
|
23
|
+
/**
|
|
24
|
+
* Always 'unknown' today — `CachedModel` carries no tools/vision metadata to
|
|
25
|
+
* report from, and this API deliberately never guesses from the model name.
|
|
26
|
+
* Will report a real boolean once that metadata exists upstream.
|
|
27
|
+
*/
|
|
28
|
+
tools: boolean | 'unknown';
|
|
29
|
+
/** See `tools` — same permanent-placeholder caveat. */
|
|
30
|
+
vision: boolean | 'unknown';
|
|
31
|
+
reasoning: 'none' | 'fixed' | 'adjustable' | 'unknown';
|
|
32
|
+
reasoningLevels?: string[];
|
|
33
|
+
defaultReasoningLevel?: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* List the credential-free model catalog: one descriptor per cached model of
|
|
39
|
+
* every enabled provider. Never resolves credentials, refreshes OAuth, hits a
|
|
40
|
+
* provider API, or writes to disk.
|
|
41
|
+
*/
|
|
42
|
+
declare function listRelayModels(registryPath?: string): RelayModelDescriptor[];
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Build a ready Vercel AI SDK `LanguageModel` for a `provider::model` route id.
|
|
46
|
+
*
|
|
47
|
+
* Re-reads the registry, credentials, and OAuth state on every call — nothing is
|
|
48
|
+
* cached across calls, so a provider disabled or re-authenticated after the last
|
|
49
|
+
* call takes effect without restarting the consumer process. Credentials are
|
|
50
|
+
* resolved (and OAuth tokens refreshed) by Relay's existing machinery; the
|
|
51
|
+
* credential and the intermediate spec never leave this function.
|
|
52
|
+
*/
|
|
53
|
+
declare function createRelayModel(routeId: RelayRouteId): Promise<LanguageModel>;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Build a route id from a provider id and a model id. The provider id must pass
|
|
57
|
+
* the registry's `PROVIDER_ID_PATTERN`; the model id may contain `/` and `:`.
|
|
58
|
+
*/
|
|
59
|
+
declare function toRelayRouteId(providerId: string, modelId: string): RelayRouteId;
|
|
60
|
+
/**
|
|
61
|
+
* Parse a route id back into its parts. Splits on the FIRST `::` only, so model
|
|
62
|
+
* ids containing `/` or `:` (e.g. `openrouter::vendor/model:free`) survive.
|
|
63
|
+
* A bare model id (no `::`) is rejected.
|
|
64
|
+
*/
|
|
65
|
+
declare function parseRelayRouteId(routeId: string): {
|
|
66
|
+
providerId: string;
|
|
67
|
+
modelId: string;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
interface RelayCoreErrorOptions {
|
|
71
|
+
retryable?: boolean;
|
|
72
|
+
providerId?: string;
|
|
73
|
+
routeId?: RelayRouteId;
|
|
74
|
+
cause?: unknown;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Error thrown by the embedded Core API. Carries only safe structured metadata —
|
|
78
|
+
* never credential material. `cause` is retained for internal debugging but is
|
|
79
|
+
* omitted from JSON serialization.
|
|
80
|
+
*/
|
|
81
|
+
declare class RelayCoreError extends Error {
|
|
82
|
+
readonly code: RelayCoreErrorCode;
|
|
83
|
+
readonly retryable: boolean;
|
|
84
|
+
readonly providerId?: string;
|
|
85
|
+
readonly routeId?: RelayRouteId;
|
|
86
|
+
constructor(code: RelayCoreErrorCode, message: string, options?: RelayCoreErrorOptions);
|
|
87
|
+
toJSON(): Record<string, unknown>;
|
|
88
|
+
}
|
|
89
|
+
declare function isRelayCoreError(err: unknown): err is RelayCoreError;
|
|
90
|
+
|
|
91
|
+
export { RelayCoreError, type RelayCoreErrorCode, type RelayModelDescriptor, type RelayRouteId, createRelayModel, isRelayCoreError, listRelayModels, parseRelayRouteId, toRelayRouteId };
|