offrouter-core 0.0.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/package.json +21 -0
- package/src/audit.test.ts +302 -0
- package/src/audit.ts +553 -0
- package/src/auth/credential-chain.test.ts +202 -0
- package/src/auth/credential-chain.ts +181 -0
- package/src/auth/index.ts +32 -0
- package/src/auth/keychain.test.ts +75 -0
- package/src/auth/keychain.ts +39 -0
- package/src/auth/oauth-pkce.test.ts +184 -0
- package/src/auth/oauth-pkce.ts +409 -0
- package/src/config.test.ts +415 -0
- package/src/config.ts +484 -0
- package/src/delegation.test.ts +368 -0
- package/src/delegation.ts +605 -0
- package/src/index.ts +261 -0
- package/src/policy.test.ts +634 -0
- package/src/policy.ts +418 -0
- package/src/protocol.ts +7 -0
- package/src/providers/adapter.test.ts +293 -0
- package/src/providers/adapter.ts +324 -0
- package/src/providers/catalog-data.test.ts +258 -0
- package/src/providers/catalog-data.ts +498 -0
- package/src/providers/catalog.test.ts +84 -0
- package/src/providers/catalog.ts +483 -0
- package/src/providers/fake.ts +312 -0
- package/src/providers/openai-compatible.test.ts +366 -0
- package/src/providers/openai-compatible.ts +554 -0
- package/src/proxy/responses-mapper.test.ts +290 -0
- package/src/proxy/responses-mapper.ts +736 -0
- package/src/proxy/responses-server.test.ts +322 -0
- package/src/proxy/responses-server.ts +469 -0
- package/src/router.test.ts +562 -0
- package/src/router.ts +323 -0
- package/src/schemas.test.ts +240 -0
- package/src/schemas.ts +203 -0
- package/src/secrets.test.ts +271 -0
- package/src/secrets.ts +461 -0
- package/src/types.ts +167 -0
- package/src/usage.test.ts +283 -0
- package/src/usage.ts +669 -0
- package/tsconfig.json +9 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* offrouter-core public surface.
|
|
3
|
+
* Policy and router live here; provider adapters land in later milestones.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export { ROUTE_PROTOCOL_VERSION } from "./protocol.js";
|
|
7
|
+
export type { RouteProtocolVersion } from "./protocol.js";
|
|
8
|
+
|
|
9
|
+
export type {
|
|
10
|
+
AuthScope,
|
|
11
|
+
AuthTier,
|
|
12
|
+
FallbackChainEntry,
|
|
13
|
+
FallbackReason,
|
|
14
|
+
HarnessKind,
|
|
15
|
+
HarnessRef,
|
|
16
|
+
PolicyDecision,
|
|
17
|
+
PolicyDenial,
|
|
18
|
+
PolicyDenialCode,
|
|
19
|
+
PolicyDenialTarget,
|
|
20
|
+
ProviderCandidate,
|
|
21
|
+
ProviderHealth,
|
|
22
|
+
RiskLevel,
|
|
23
|
+
RouteConstraints,
|
|
24
|
+
RouteDecision,
|
|
25
|
+
RouteRequest,
|
|
26
|
+
RouteTask,
|
|
27
|
+
SelectedRoute,
|
|
28
|
+
SubscriptionStatus,
|
|
29
|
+
TaskKind,
|
|
30
|
+
WorkspaceRef,
|
|
31
|
+
} from "./types.js";
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
AuthScopeSchema,
|
|
35
|
+
AuthTierSchema,
|
|
36
|
+
FallbackChainEntrySchema,
|
|
37
|
+
FallbackReasonSchema,
|
|
38
|
+
HarnessKindSchema,
|
|
39
|
+
HarnessRefSchema,
|
|
40
|
+
PolicyDecisionSchema,
|
|
41
|
+
PolicyDenialCodeSchema,
|
|
42
|
+
PolicyDenialSchema,
|
|
43
|
+
PolicyDenialTargetSchema,
|
|
44
|
+
ProviderCandidateSchema,
|
|
45
|
+
ProviderHealthSchema,
|
|
46
|
+
RiskLevelSchema,
|
|
47
|
+
RouteConstraintsSchema,
|
|
48
|
+
RouteDecisionSchema,
|
|
49
|
+
RouteRequestSchema,
|
|
50
|
+
RouteTaskSchema,
|
|
51
|
+
SelectedRouteSchema,
|
|
52
|
+
SubscriptionStatusSchema,
|
|
53
|
+
TaskKindSchema,
|
|
54
|
+
WorkspaceRefSchema,
|
|
55
|
+
} from "./schemas.js";
|
|
56
|
+
|
|
57
|
+
export {
|
|
58
|
+
evaluatePolicy,
|
|
59
|
+
isHealthySubscriptionCapacity,
|
|
60
|
+
meetsCapabilities,
|
|
61
|
+
} from "./policy.js";
|
|
62
|
+
export type { PolicyConfig } from "./policy.js";
|
|
63
|
+
|
|
64
|
+
export { routeRequest } from "./router.js";
|
|
65
|
+
export type { RouteOptions } from "./router.js";
|
|
66
|
+
|
|
67
|
+
export { DelegationPolicyError, DelegationRuntime } from "./delegation.js";
|
|
68
|
+
export type {
|
|
69
|
+
DelegationEvent,
|
|
70
|
+
DelegationMode,
|
|
71
|
+
DelegationOutput,
|
|
72
|
+
DelegationRequest,
|
|
73
|
+
DelegationResult,
|
|
74
|
+
DelegationRuntimeOptions,
|
|
75
|
+
DelegationTask,
|
|
76
|
+
DelegationTaskStatus,
|
|
77
|
+
} from "./delegation.js";
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
ConfigError,
|
|
81
|
+
defaultConfig,
|
|
82
|
+
loadConfig,
|
|
83
|
+
resolveOffRouterHome,
|
|
84
|
+
} from "./config.js";
|
|
85
|
+
export type {
|
|
86
|
+
ConfiguredProfile,
|
|
87
|
+
ConfiguredProvider,
|
|
88
|
+
ConfigWarning,
|
|
89
|
+
LoadConfigOptions,
|
|
90
|
+
OffRouterConfig,
|
|
91
|
+
PolicyDefaults,
|
|
92
|
+
ResolveHomeOptions,
|
|
93
|
+
} from "./config.js";
|
|
94
|
+
|
|
95
|
+
export {
|
|
96
|
+
FileSecretStore,
|
|
97
|
+
KeychainSecretStore,
|
|
98
|
+
KeychainUnavailableError,
|
|
99
|
+
REDACTED,
|
|
100
|
+
redact,
|
|
101
|
+
} from "./secrets.js";
|
|
102
|
+
export type {
|
|
103
|
+
FileSecretStoreOptions,
|
|
104
|
+
KeychainSecretStoreOptions,
|
|
105
|
+
SecretStore,
|
|
106
|
+
} from "./secrets.js";
|
|
107
|
+
|
|
108
|
+
export { DEFAULT_PREVIEW_MAX_CHARS, InMemoryAuditStore } from "./audit.js";
|
|
109
|
+
export type {
|
|
110
|
+
AppendDecisionOptions,
|
|
111
|
+
AuditRecord,
|
|
112
|
+
AuditRecordKind,
|
|
113
|
+
AuditStore,
|
|
114
|
+
CancellationState,
|
|
115
|
+
InMemoryAuditStoreOptions,
|
|
116
|
+
ListAuditOptions,
|
|
117
|
+
MarkCancelledOptions,
|
|
118
|
+
} from "./audit.js";
|
|
119
|
+
|
|
120
|
+
export { InMemoryStateStore, InMemoryUsageStore } from "./usage.js";
|
|
121
|
+
export type {
|
|
122
|
+
InMemoryUsageStoreOptions,
|
|
123
|
+
PaidFallbackExplanation,
|
|
124
|
+
ProviderUsageSnapshot,
|
|
125
|
+
RecordUsageResult,
|
|
126
|
+
SlidingWindowOptions,
|
|
127
|
+
StateStore,
|
|
128
|
+
UsageEvent,
|
|
129
|
+
UsageEventKind,
|
|
130
|
+
UsageStore,
|
|
131
|
+
} from "./usage.js";
|
|
132
|
+
|
|
133
|
+
// Provider discovery + adapters
|
|
134
|
+
export {
|
|
135
|
+
PROVIDER_ADAPTER_METHODS,
|
|
136
|
+
ProviderError,
|
|
137
|
+
capabilityToCandidate,
|
|
138
|
+
isProviderError,
|
|
139
|
+
mapHttpToProviderError,
|
|
140
|
+
} from "./providers/adapter.js";
|
|
141
|
+
export type {
|
|
142
|
+
AuthStatus,
|
|
143
|
+
CostEstimate,
|
|
144
|
+
LimitSnapshot,
|
|
145
|
+
ModelCapability,
|
|
146
|
+
ProviderAdapter,
|
|
147
|
+
ProviderErrorCode,
|
|
148
|
+
ProviderErrorOptions,
|
|
149
|
+
ProviderEvent,
|
|
150
|
+
ProviderInvokeMessage,
|
|
151
|
+
ProviderInvokeRequest,
|
|
152
|
+
} from "./providers/adapter.js";
|
|
153
|
+
|
|
154
|
+
export {
|
|
155
|
+
MULTI_TIER_FAMILIES,
|
|
156
|
+
STATIC_CATALOG,
|
|
157
|
+
catalogToCandidates,
|
|
158
|
+
familyAuthTiers,
|
|
159
|
+
loadBuiltinCatalog,
|
|
160
|
+
loadStaticCatalog,
|
|
161
|
+
} from "./providers/catalog.js";
|
|
162
|
+
export type {
|
|
163
|
+
CatalogEntry,
|
|
164
|
+
LoadBuiltinCatalogOptions,
|
|
165
|
+
LoadCatalogOptions,
|
|
166
|
+
LogicalModelFamily,
|
|
167
|
+
} from "./providers/catalog.js";
|
|
168
|
+
|
|
169
|
+
export {
|
|
170
|
+
BUILTIN_PROVIDERS,
|
|
171
|
+
BUILTIN_PROVIDER_IDS,
|
|
172
|
+
getBuiltinProvider,
|
|
173
|
+
selectBuiltinProviders,
|
|
174
|
+
} from "./providers/catalog-data.js";
|
|
175
|
+
export type {
|
|
176
|
+
BuiltinCatalogConfig,
|
|
177
|
+
BuiltinModelFamily,
|
|
178
|
+
BuiltinProviderEntry,
|
|
179
|
+
PricingHint,
|
|
180
|
+
ProviderCatalogConfig,
|
|
181
|
+
} from "./providers/catalog-data.js";
|
|
182
|
+
|
|
183
|
+
export { FakeProviderAdapter, createFakeProvider } from "./providers/fake.js";
|
|
184
|
+
export type { FakeModelConfig, FakeProviderOptions } from "./providers/fake.js";
|
|
185
|
+
|
|
186
|
+
export {
|
|
187
|
+
OLLAMA_DUMMY_BEARER,
|
|
188
|
+
OpenAiCompatibleAdapter,
|
|
189
|
+
createOpenAiCompatibleAdapter,
|
|
190
|
+
} from "./providers/openai-compatible.js";
|
|
191
|
+
export type {
|
|
192
|
+
OpenAiCompatibleFlavor,
|
|
193
|
+
OpenAiCompatibleOptions,
|
|
194
|
+
} from "./providers/openai-compatible.js";
|
|
195
|
+
|
|
196
|
+
// Auth module (credential chain, OAuth PKCE, keychain helpers)
|
|
197
|
+
export {
|
|
198
|
+
Redacted,
|
|
199
|
+
exchangeCodeForTokens,
|
|
200
|
+
generateCodeChallenge,
|
|
201
|
+
generateCodeVerifier,
|
|
202
|
+
getProviderToken,
|
|
203
|
+
isOAuthProvider,
|
|
204
|
+
PKCE_CONFIGS,
|
|
205
|
+
refreshTokens,
|
|
206
|
+
resolveCredential,
|
|
207
|
+
setProviderToken,
|
|
208
|
+
startOAuthFlow,
|
|
209
|
+
} from "./auth/index.js";
|
|
210
|
+
export type {
|
|
211
|
+
CredentialResult,
|
|
212
|
+
CredentialSource,
|
|
213
|
+
OAuthFlowResult,
|
|
214
|
+
OAuthFlowState,
|
|
215
|
+
OAuthProviderConfig,
|
|
216
|
+
OAuthStartOptions,
|
|
217
|
+
OAuthTokenOptions,
|
|
218
|
+
OAuthTokenResponse,
|
|
219
|
+
ResolveCredentialOptions,
|
|
220
|
+
} from "./auth/index.js";
|
|
221
|
+
|
|
222
|
+
// OpenAI Responses-compatible local proxy
|
|
223
|
+
export {
|
|
224
|
+
CHAT_COMPLETIONS_DONE,
|
|
225
|
+
ChatCompletionsRequestSchema,
|
|
226
|
+
ChatCompletionsSseBuilder,
|
|
227
|
+
RESPONSES_PROMPT_PREVIEW_CHARS,
|
|
228
|
+
ResponsesRequestSchema,
|
|
229
|
+
ResponsesSseBuilder,
|
|
230
|
+
InvalidProxyRequestError,
|
|
231
|
+
buildDelegationRequest,
|
|
232
|
+
buildRouteRequest,
|
|
233
|
+
createResponsesProxyContext,
|
|
234
|
+
extractPromptFromChatCompletions,
|
|
235
|
+
extractPromptFromResponsesInput,
|
|
236
|
+
openAiErrorPayload,
|
|
237
|
+
policyDecisionToHttpStatus,
|
|
238
|
+
promptDigest,
|
|
239
|
+
promptPreview,
|
|
240
|
+
providerErrorCodeToHttpStatus,
|
|
241
|
+
responsesSseData,
|
|
242
|
+
} from "./proxy/responses-mapper.js";
|
|
243
|
+
export { startResponsesProxy } from "./proxy/responses-server.js";
|
|
244
|
+
export type {
|
|
245
|
+
BuildDelegationInput,
|
|
246
|
+
BuildRouteInput,
|
|
247
|
+
ChatCompletionDeltaEvent,
|
|
248
|
+
ChatCompletionObject,
|
|
249
|
+
ChatUsageInput,
|
|
250
|
+
OpenAiErrorPayload,
|
|
251
|
+
ParsedResponsesInput,
|
|
252
|
+
ResponsesMessageItem,
|
|
253
|
+
ResponsesObject,
|
|
254
|
+
ResponsesOutputTextPart,
|
|
255
|
+
ResponsesProxyContext,
|
|
256
|
+
ResponsesUsageInput,
|
|
257
|
+
} from "./proxy/responses-mapper.js";
|
|
258
|
+
export type {
|
|
259
|
+
ResponsesProxyHandle,
|
|
260
|
+
ResponsesProxyOptions,
|
|
261
|
+
} from "./proxy/responses-server.js";
|