@happyvertical/smrt-inference 0.0.0-stage → 0.60.16
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/AGENTS.md +206 -0
- package/CLAUDE.md +1 -0
- package/LICENSE +7 -0
- package/README.md +73 -2
- package/agents/fusions.md +105 -0
- package/agents/hosted.md +161 -0
- package/agents/resolver.md +65 -0
- package/agents/settings.md +107 -0
- package/dist/__smrt-register__.d.ts +2 -0
- package/dist/__smrt-register__.d.ts.map +1 -0
- package/dist/chunks/InferenceOverrideCollection-Dat4TrK5.js +423 -0
- package/dist/chunks/InferenceOverrideCollection-Dat4TrK5.js.map +1 -0
- package/dist/chunks/provider-config-BSpIQRVM.js +1873 -0
- package/dist/chunks/provider-config-BSpIQRVM.js.map +1 -0
- package/dist/classify.d.ts +32 -0
- package/dist/classify.d.ts.map +1 -0
- package/dist/config.d.ts +89 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/errors.d.ts +51 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/executor.d.ts +45 -0
- package/dist/executor.d.ts.map +1 -0
- package/dist/fusion-store.d.ts +16 -0
- package/dist/fusion-store.d.ts.map +1 -0
- package/dist/fusion.d.ts +155 -0
- package/dist/fusion.d.ts.map +1 -0
- package/dist/gate.d.ts +143 -0
- package/dist/gate.d.ts.map +1 -0
- package/dist/gate.js +94 -0
- package/dist/gate.js.map +1 -0
- package/dist/hosted.d.ts +461 -0
- package/dist/hosted.d.ts.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.json +453 -0
- package/dist/models/InferenceOverride.d.ts +38 -0
- package/dist/models/InferenceOverride.d.ts.map +1 -0
- package/dist/models/InferenceOverrideCollection.d.ts +35 -0
- package/dist/models/InferenceOverrideCollection.d.ts.map +1 -0
- package/dist/models.d.ts +11 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +2 -0
- package/dist/node.d.ts +110 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +1414 -0
- package/dist/node.js.map +1 -0
- package/dist/provider-config.d.ts +113 -0
- package/dist/provider-config.d.ts.map +1 -0
- package/dist/register.d.ts +30 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/resolver.d.ts +166 -0
- package/dist/resolver.d.ts.map +1 -0
- package/dist/resolver.js +291 -0
- package/dist/resolver.js.map +1 -0
- package/dist/server.d.ts +25 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +1138 -0
- package/dist/server.js.map +1 -0
- package/dist/settings/cache.d.ts +5 -0
- package/dist/settings/cache.d.ts.map +1 -0
- package/dist/settings/keys.d.ts +70 -0
- package/dist/settings/keys.d.ts.map +1 -0
- package/dist/settings/layers.d.ts +68 -0
- package/dist/settings/layers.d.ts.map +1 -0
- package/dist/settings/override-service.d.ts +119 -0
- package/dist/settings/override-service.d.ts.map +1 -0
- package/dist/settings/preferences.d.ts +137 -0
- package/dist/settings/preferences.d.ts.map +1 -0
- package/dist/settings/resolver.d.ts +41 -0
- package/dist/settings/resolver.d.ts.map +1 -0
- package/dist/settings/settings-service.d.ts +355 -0
- package/dist/settings/settings-service.d.ts.map +1 -0
- package/dist/settings/targets.d.ts +112 -0
- package/dist/settings/targets.d.ts.map +1 -0
- package/dist/settings/transcripts.d.ts +33 -0
- package/dist/settings/transcripts.d.ts.map +1 -0
- package/dist/smrt-knowledge.json +341 -0
- package/dist/smrt-knowledge.okf.md +80 -0
- package/dist/svelte/components/InferenceAliasEditor.svelte +210 -0
- package/dist/svelte/components/InferenceAliasEditor.svelte.d.ts +13 -0
- package/dist/svelte/components/InferenceAliasEditor.svelte.d.ts.map +1 -0
- package/dist/svelte/components/InferenceDefaultView.svelte +330 -0
- package/dist/svelte/components/InferenceDefaultView.svelte.d.ts +15 -0
- package/dist/svelte/components/InferenceDefaultView.svelte.d.ts.map +1 -0
- package/dist/svelte/components/InferenceFusionList.svelte +141 -0
- package/dist/svelte/components/InferenceFusionList.svelte.d.ts +16 -0
- package/dist/svelte/components/InferenceFusionList.svelte.d.ts.map +1 -0
- package/dist/svelte/components/InferenceSettingsPanel.svelte +392 -0
- package/dist/svelte/components/InferenceSettingsPanel.svelte.d.ts +84 -0
- package/dist/svelte/components/InferenceSettingsPanel.svelte.d.ts.map +1 -0
- package/dist/svelte/components/InferenceTierRow.svelte +199 -0
- package/dist/svelte/components/InferenceTierRow.svelte.d.ts +14 -0
- package/dist/svelte/components/InferenceTierRow.svelte.d.ts.map +1 -0
- package/dist/svelte/components/InferenceTranscriptSettings.svelte +165 -0
- package/dist/svelte/components/InferenceTranscriptSettings.svelte.d.ts +18 -0
- package/dist/svelte/components/InferenceTranscriptSettings.svelte.d.ts.map +1 -0
- package/dist/svelte/components/InferenceUsageTable.svelte +177 -0
- package/dist/svelte/components/InferenceUsageTable.svelte.d.ts +21 -0
- package/dist/svelte/components/InferenceUsageTable.svelte.d.ts.map +1 -0
- package/dist/svelte/index.d.ts +17 -0
- package/dist/svelte/index.d.ts.map +1 -0
- package/dist/svelte/index.js +14 -0
- package/dist/svelte/types.d.ts +262 -0
- package/dist/svelte/types.d.ts.map +1 -0
- package/dist/svelte/types.js +124 -0
- package/dist/types.d.ts +47 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/package.json +105 -3
package/dist/hosted.d.ts
ADDED
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hosted inference provisioning (#4759), Node-only (`./node`).
|
|
3
|
+
*
|
|
4
|
+
* When a member gains `inference.hosted`, SMRT mints them a per-user virtual
|
|
5
|
+
* key on the operator's AI gateway (`bifrost` or `litellm`, through the
|
|
6
|
+
* `ai.admin` surface of `@happyvertical/ai`; SMRT never talks to a gateway's
|
|
7
|
+
* admin API itself) and stores it where the BYO path already looks: the
|
|
8
|
+
* user's `inference.provider-config` secret (#4756) with `source: 'hosted'`
|
|
9
|
+
* and `mode: 'hosted'` (#4757). Switching to hosted therefore changes only
|
|
10
|
+
* the stored provider config.
|
|
11
|
+
*
|
|
12
|
+
* Storage (all smrt-secrets rows under `context = tenantId`, every write and
|
|
13
|
+
* delete audited through `SecretAuditLog` with an `operation` detail):
|
|
14
|
+
* - `inference.provider-config:user:<userId>`: the hosted binding (holds the
|
|
15
|
+
* virtual key; the only place it lives).
|
|
16
|
+
* - `inference.hosted:user:<userId>`: provisioning state: status, lifecycle
|
|
17
|
+
* generation, the key's non-secret id and alias, the budget, and the
|
|
18
|
+
* user's prior provider config (restored on revoke).
|
|
19
|
+
* - `inference.hosted:project`: the tenant's gateway project id.
|
|
20
|
+
*
|
|
21
|
+
* Idempotency: provisioning runs under `runOnce()` per `(tenantId, userId,
|
|
22
|
+
* generation)`, so concurrent deliveries create one key; the generation
|
|
23
|
+
* advances on every revoke, so a later re-provision runs again. The tenant
|
|
24
|
+
* project is looked up on the gateway (`listProjects`) before one is
|
|
25
|
+
* created, so a crash between create and persist never makes a second. Lifecycle
|
|
26
|
+
* operations run one at a time per process and, on PostgreSQL, under a
|
|
27
|
+
* per-tenant advisory lock across processes. A revoke ends local
|
|
28
|
+
* use of the key whatever the gateway answers; deletions the gateway could
|
|
29
|
+
* not perform are kept as `pendingGatewayRevocations` and retried by
|
|
30
|
+
* `revoke()` / `reconcileTenant()`.
|
|
31
|
+
*
|
|
32
|
+
* The key never appears in returned objects, errors, logs, usage tags,
|
|
33
|
+
* audit details or `runOnce()` results: usage rows carry `source: hosted`
|
|
34
|
+
* and the key's alias (`gatewayKeyAlias`) only.
|
|
35
|
+
*/
|
|
36
|
+
import type { AIAdminBudget, AIAdminInterface } from '@happyvertical/ai';
|
|
37
|
+
import { type InferenceTier } from '@happyvertical/smrt-core';
|
|
38
|
+
import { SmrtError } from '@happyvertical/smrt-core/smrt-error';
|
|
39
|
+
import type { DatabaseInterface } from '@happyvertical/sql';
|
|
40
|
+
import { type InferenceProviderConfig } from './provider-config.js';
|
|
41
|
+
/** The feature key that entitles hosted inference (`smrt-features`' `FEATURE_INFERENCE_HOSTED`). */
|
|
42
|
+
export declare const HOSTED_INFERENCE_FEATURE_KEY = "inference.hosted";
|
|
43
|
+
/** smrt-secrets category of the hosted state and project rows. */
|
|
44
|
+
export declare const HOSTED_INFERENCE_SECRET_CATEGORY = "inference.hosted";
|
|
45
|
+
/** Gateway providers of `@happyvertical/ai` that expose `ai.admin`. */
|
|
46
|
+
export declare const HOSTED_GATEWAY_PROVIDERS: readonly ["bifrost", "litellm"];
|
|
47
|
+
export type HostedGatewayProvider = (typeof HOSTED_GATEWAY_PROVIDERS)[number];
|
|
48
|
+
/** Budget reset windows; mapped to the gateway's reset duration. */
|
|
49
|
+
export declare const HOSTED_BUDGET_WINDOWS: readonly ["day", "week", "month", "year"];
|
|
50
|
+
export type HostedBudgetWindow = (typeof HOSTED_BUDGET_WINDOWS)[number];
|
|
51
|
+
/**
|
|
52
|
+
* A hosted user's spend cap. Money is an integer: micro-dollars (USD ×
|
|
53
|
+
* 1,000,000), the unit #4760's spend gate meters. Converted to the gateway's
|
|
54
|
+
* USD `maxLimit` only at the admin call.
|
|
55
|
+
*/
|
|
56
|
+
export interface HostedInferenceBudget {
|
|
57
|
+
limitMicros: number;
|
|
58
|
+
/** Reset window. Default `month`. */
|
|
59
|
+
window?: HostedBudgetWindow;
|
|
60
|
+
}
|
|
61
|
+
/** Error codes of {@link HostedInferenceError}. */
|
|
62
|
+
export type HostedInferenceErrorCode = 'HOSTED_INFERENCE_INVALID' | 'HOSTED_GATEWAY_NOT_CONFIGURED' | 'HOSTED_GATEWAY_UNSUPPORTED' | 'HOSTED_GATEWAY_FAILED' | 'HOSTED_STATE_INVALID' | 'HOSTED_NOT_ENTITLED';
|
|
63
|
+
/**
|
|
64
|
+
* A provisioning failure. Messages name fields and operations, never a key,
|
|
65
|
+
* an admin credential or a gateway response body.
|
|
66
|
+
*/
|
|
67
|
+
export declare class HostedInferenceError extends SmrtError {
|
|
68
|
+
constructor(message: string, code: HostedInferenceErrorCode, details?: Record<string, unknown>);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The operator's gateway. Admin credentials stay in this object (built once
|
|
72
|
+
* from the host environment) and are only handed to `@happyvertical/ai`.
|
|
73
|
+
*/
|
|
74
|
+
export interface HostedGatewayConfig {
|
|
75
|
+
provider: HostedGatewayProvider;
|
|
76
|
+
/** OpenAI-compatible inference endpoint the virtual keys are used against. */
|
|
77
|
+
baseUrl: string;
|
|
78
|
+
/** Admin API root, when it differs from `baseUrl`. */
|
|
79
|
+
adminUrl?: string;
|
|
80
|
+
/** LiteLLM master key, or a Bifrost admin virtual key. */
|
|
81
|
+
adminApiKey?: string;
|
|
82
|
+
/** Bifrost governance Basic-auth user. */
|
|
83
|
+
adminUser?: string;
|
|
84
|
+
/** Bifrost governance Basic-auth password. */
|
|
85
|
+
adminPassword?: string;
|
|
86
|
+
/** Default model of the stored binding. */
|
|
87
|
+
model?: string;
|
|
88
|
+
/** Per-tier models of the stored binding. */
|
|
89
|
+
tiers?: Partial<Record<InferenceTier, string>>;
|
|
90
|
+
/** Models the virtual key may use. Default: `model` plus the tier models. */
|
|
91
|
+
models?: string[];
|
|
92
|
+
/** Key lifetime (`30d`, `permanent`, ...), where the gateway supports it. */
|
|
93
|
+
keyDuration?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Deadline for each admin call in ms (default
|
|
96
|
+
* {@link HOSTED_GATEWAY_ADMIN_TIMEOUT_MS}). A call past it counts as
|
|
97
|
+
* failed, so a stalled gateway never holds the lifecycle lock.
|
|
98
|
+
*/
|
|
99
|
+
adminTimeoutMs?: number;
|
|
100
|
+
}
|
|
101
|
+
/** Default deadline of one gateway admin call. */
|
|
102
|
+
export declare const HOSTED_GATEWAY_ADMIN_TIMEOUT_MS = 30000;
|
|
103
|
+
/** The `AIAdminInterface` calls provisioning uses. */
|
|
104
|
+
export declare const HOSTED_GATEWAY_ADMIN_METHODS: readonly ["createProject", "createVirtualKey", "updateVirtualKey", "deleteVirtualKey", "listProjects"];
|
|
105
|
+
/**
|
|
106
|
+
* The admin surface provisioning uses (`@happyvertical/ai` >= 0.111.7,
|
|
107
|
+
* happyvertical/sdk#1494). Plan changes send only `budget` to
|
|
108
|
+
* `updateVirtualKey` (Bifrost refuses `models` / `metadata`, LiteLLM
|
|
109
|
+
* `providerConfigs`, with `ADMIN_UNSUPPORTED_FIELD`); `deleteVirtualKey`
|
|
110
|
+
* resolving `false` means the key is already gone.
|
|
111
|
+
*/
|
|
112
|
+
export type HostedGatewayAdmin = Pick<AIAdminInterface, (typeof HOSTED_GATEWAY_ADMIN_METHODS)[number]>;
|
|
113
|
+
/** Environment variables {@link hostedGatewayConfigFromEnv} reads. */
|
|
114
|
+
export declare const HOSTED_GATEWAY_ENV: {
|
|
115
|
+
readonly provider: "SMRT_INFERENCE_HOSTED_PROVIDER";
|
|
116
|
+
readonly baseUrl: "SMRT_INFERENCE_HOSTED_BASE_URL";
|
|
117
|
+
readonly adminUrl: "SMRT_INFERENCE_HOSTED_ADMIN_URL";
|
|
118
|
+
readonly adminApiKey: "SMRT_INFERENCE_HOSTED_ADMIN_KEY";
|
|
119
|
+
readonly adminUser: "SMRT_INFERENCE_HOSTED_ADMIN_USER";
|
|
120
|
+
readonly adminPassword: "SMRT_INFERENCE_HOSTED_ADMIN_PASSWORD";
|
|
121
|
+
readonly model: "SMRT_INFERENCE_HOSTED_MODEL";
|
|
122
|
+
readonly models: "SMRT_INFERENCE_HOSTED_MODELS";
|
|
123
|
+
readonly keyDuration: "SMRT_INFERENCE_HOSTED_KEY_DURATION";
|
|
124
|
+
readonly adminTimeoutMs: "SMRT_INFERENCE_HOSTED_ADMIN_TIMEOUT_MS";
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Validate a gateway config. Throws `HOSTED_GATEWAY_NOT_CONFIGURED` naming
|
|
128
|
+
* the missing or invalid fields (never their values).
|
|
129
|
+
*/
|
|
130
|
+
export declare function parseHostedGatewayConfig(value: Partial<HostedGatewayConfig>): HostedGatewayConfig;
|
|
131
|
+
/**
|
|
132
|
+
* Build the gateway config from environment variables
|
|
133
|
+
* ({@link HOSTED_GATEWAY_ENV}, plus `SMRT_INFERENCE_HOSTED_<TIER>_MODEL`).
|
|
134
|
+
* `undefined` when `SMRT_INFERENCE_HOSTED_PROVIDER` is unset (hosted
|
|
135
|
+
* inference off); throws when it is set but incomplete.
|
|
136
|
+
*/
|
|
137
|
+
export declare function hostedGatewayConfigFromEnv(env?: Record<string, string | undefined>): HostedGatewayConfig | undefined;
|
|
138
|
+
/**
|
|
139
|
+
* The process gateway config, read from the environment once and cached.
|
|
140
|
+
* Throws `HOSTED_GATEWAY_NOT_CONFIGURED` when hosted inference is not set up.
|
|
141
|
+
*/
|
|
142
|
+
export declare function getHostedGatewayConfig(): HostedGatewayConfig;
|
|
143
|
+
/** Forget the cached environment config (tests). */
|
|
144
|
+
export declare function resetHostedGatewayConfig(): void;
|
|
145
|
+
/**
|
|
146
|
+
* The `ai.admin` surface of the configured gateway provider, built through
|
|
147
|
+
* `getAI()` of `@happyvertical/ai`. Throws `HOSTED_GATEWAY_UNSUPPORTED` when
|
|
148
|
+
* the installed SDK's provider lacks any of {@link HOSTED_GATEWAY_ADMIN_METHODS}.
|
|
149
|
+
*/
|
|
150
|
+
export declare function createHostedGatewayAdmin(config: HostedGatewayConfig): Promise<HostedGatewayAdmin>;
|
|
151
|
+
/** A gateway key SMRT no longer uses but could not delete yet. */
|
|
152
|
+
export interface HostedPendingGatewayRevocation {
|
|
153
|
+
/** The key's non-secret handle; `null` when the gateway returned none. */
|
|
154
|
+
keyId: string | null;
|
|
155
|
+
keyAlias: string;
|
|
156
|
+
/**
|
|
157
|
+
* Why it is pending: `failed` the delete call failed; `orphaned` a failed
|
|
158
|
+
* provision may have left it; `unsupported` no admin client was usable or
|
|
159
|
+
* the key has no id (entries recorded before `@happyvertical/ai` 0.111.7
|
|
160
|
+
* also carry it). Entries with a `keyId` are retried; without one only an
|
|
161
|
+
* operator can revoke the key (by alias) and acknowledge it.
|
|
162
|
+
*/
|
|
163
|
+
reason: 'unsupported' | 'failed' | 'orphaned';
|
|
164
|
+
since: string;
|
|
165
|
+
}
|
|
166
|
+
/** A user's provisioning state (`inference.hosted:user:<userId>`). */
|
|
167
|
+
export interface HostedInferenceState {
|
|
168
|
+
version: 1;
|
|
169
|
+
status: 'active' | 'revoked';
|
|
170
|
+
/** Lifecycle generation; advances on every revoke. */
|
|
171
|
+
generation: number;
|
|
172
|
+
provider?: HostedGatewayProvider;
|
|
173
|
+
projectId?: string;
|
|
174
|
+
/** The gateway's non-secret key id (update/delete handle), when returned. */
|
|
175
|
+
keyId: string | null;
|
|
176
|
+
/** Empty when no key was ever stored (only pending cleanups). */
|
|
177
|
+
keyAlias: string;
|
|
178
|
+
budget?: Required<HostedInferenceBudget>;
|
|
179
|
+
provisionedAt?: string;
|
|
180
|
+
revokedAt?: string;
|
|
181
|
+
/** The user's provider config before provisioning; dropped on revoke. */
|
|
182
|
+
prior: InferenceProviderConfig | null;
|
|
183
|
+
/**
|
|
184
|
+
* Keys SMRT stopped using whose gateway deletion is still owed (a failed
|
|
185
|
+
* delete, no usable admin or key id, or a key left by a failed provision).
|
|
186
|
+
* Retried by `revoke()` and `reconcileTenant()`; never holds a key value.
|
|
187
|
+
*/
|
|
188
|
+
pendingGatewayRevocations?: HostedPendingGatewayRevocation[];
|
|
189
|
+
/**
|
|
190
|
+
* The member replaced the hosted binding with their own config: reconcile
|
|
191
|
+
* leaves them alone; only an explicit `provision()` re-provisions.
|
|
192
|
+
*/
|
|
193
|
+
optedOut?: boolean;
|
|
194
|
+
/**
|
|
195
|
+
* Set when a budget update failed or timed out (it may still land on the
|
|
196
|
+
* gateway); budget syncs re-apply the stored budget while it is set.
|
|
197
|
+
*/
|
|
198
|
+
budgetSyncUncertainAt?: string;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* How long after an uncertain budget update a confirmed one must come
|
|
202
|
+
* before the uncertainty is cleared (a late landing is overwritten by the
|
|
203
|
+
* re-applies in between).
|
|
204
|
+
*/
|
|
205
|
+
export declare const HOSTED_BUDGET_UNCERTAIN_WINDOW_MS: number;
|
|
206
|
+
/** What provisioning and revocation return: never the key. */
|
|
207
|
+
export interface HostedInferenceDescriptor {
|
|
208
|
+
tenantId: string;
|
|
209
|
+
userId: string;
|
|
210
|
+
status: 'active' | 'revoked' | 'none';
|
|
211
|
+
generation: number;
|
|
212
|
+
provider?: HostedGatewayProvider;
|
|
213
|
+
projectId?: string;
|
|
214
|
+
keyId?: string | null;
|
|
215
|
+
keyAlias?: string;
|
|
216
|
+
budget?: Required<HostedInferenceBudget>;
|
|
217
|
+
/** Non-secret handles of keys whose gateway deletion is still owed. */
|
|
218
|
+
pendingGatewayRevocations?: HostedPendingGatewayRevocation[];
|
|
219
|
+
}
|
|
220
|
+
/** Result of {@link HostedInferenceProvisioner.provision}. */
|
|
221
|
+
export interface ProvisionHostedInferenceResult extends HostedInferenceDescriptor {
|
|
222
|
+
/** True when this call created the key; false for an existing grant. */
|
|
223
|
+
created: boolean;
|
|
224
|
+
/** Budget sync outcome when an existing grant's budget differed. */
|
|
225
|
+
budgetSync?: HostedBudgetSyncStatus;
|
|
226
|
+
}
|
|
227
|
+
/** How a gateway key revocation went. */
|
|
228
|
+
export type HostedGatewayRevokeStatus = 'revoked' | 'missing' | 'unsupported' | 'failed' | 'none';
|
|
229
|
+
/** Result of {@link HostedInferenceProvisioner.revoke}. */
|
|
230
|
+
export interface RevokeHostedInferenceResult extends HostedInferenceDescriptor {
|
|
231
|
+
revoked: boolean;
|
|
232
|
+
/**
|
|
233
|
+
* `revoked`: the gateway deleted the key; `missing`: it no longer existed
|
|
234
|
+
* (already revoked); `unsupported`: no admin client is configured or the
|
|
235
|
+
* gateway returned no key id; `failed`: the delete call failed. For
|
|
236
|
+
* `unsupported` and `failed` SMRT has already stopped using the key and
|
|
237
|
+
* records it in `pendingGatewayRevocations` (and the audit log) for a
|
|
238
|
+
* later retry or a manual revocation on the gateway; `none`: nothing to
|
|
239
|
+
* revoke.
|
|
240
|
+
*/
|
|
241
|
+
gateway: HostedGatewayRevokeStatus;
|
|
242
|
+
/** What the user's provider config became. */
|
|
243
|
+
restored?: 'prior' | 'off' | 'kept';
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Budget sync outcome. `unsupported`: the grant has no gateway key id to
|
|
247
|
+
* update (the stored budget stays, so a later sync retries).
|
|
248
|
+
*/
|
|
249
|
+
export type HostedBudgetSyncStatus = 'updated' | 'unchanged' | 'unsupported';
|
|
250
|
+
/** Result of {@link HostedInferenceProvisioner.syncBudget}. */
|
|
251
|
+
export interface SyncHostedBudgetResult extends HostedInferenceDescriptor {
|
|
252
|
+
sync: HostedBudgetSyncStatus | 'none';
|
|
253
|
+
}
|
|
254
|
+
/** What {@link HostedInferenceProvisioner.reconcileTenant} should converge to. */
|
|
255
|
+
export interface HostedReconcileTarget {
|
|
256
|
+
/** Whether the tenant's plan grants `inference.hosted` now. */
|
|
257
|
+
entitled: boolean;
|
|
258
|
+
/** The plan's budget (required to provision; syncs active grants). */
|
|
259
|
+
budget?: HostedInferenceBudget;
|
|
260
|
+
/** Users to hold an active grant while entitled (idempotent). */
|
|
261
|
+
users?: readonly string[];
|
|
262
|
+
}
|
|
263
|
+
/** Per-user outcome of a reconcile. */
|
|
264
|
+
export interface HostedReconcileResult {
|
|
265
|
+
tenantId: string;
|
|
266
|
+
provisioned: ProvisionHostedInferenceResult[];
|
|
267
|
+
revoked: RevokeHostedInferenceResult[];
|
|
268
|
+
synced: SyncHostedBudgetResult[];
|
|
269
|
+
/** Pending gateway deletions retried, and what is still pending. */
|
|
270
|
+
pending: Array<{
|
|
271
|
+
userId: string;
|
|
272
|
+
remaining: number;
|
|
273
|
+
}>;
|
|
274
|
+
failures: Array<{
|
|
275
|
+
userId: string;
|
|
276
|
+
error: unknown;
|
|
277
|
+
}>;
|
|
278
|
+
}
|
|
279
|
+
/** The secret store calls provisioning uses (`SecretService` satisfies it). */
|
|
280
|
+
export interface HostedSecretStore {
|
|
281
|
+
retrieve(name: string): Promise<{
|
|
282
|
+
value: string;
|
|
283
|
+
}>;
|
|
284
|
+
store(name: string, value: string, options?: {
|
|
285
|
+
category?: string;
|
|
286
|
+
description?: string;
|
|
287
|
+
auditDetails?: Record<string, unknown>;
|
|
288
|
+
}): Promise<unknown>;
|
|
289
|
+
delete(name: string, options?: {
|
|
290
|
+
auditDetails?: Record<string, unknown>;
|
|
291
|
+
}): Promise<boolean>;
|
|
292
|
+
list(options?: {
|
|
293
|
+
category?: string;
|
|
294
|
+
}): Promise<Array<{
|
|
295
|
+
name: string;
|
|
296
|
+
}>>;
|
|
297
|
+
}
|
|
298
|
+
/** Options for {@link createHostedInferenceProvisioner}. */
|
|
299
|
+
export interface HostedInferenceProvisionerOptions {
|
|
300
|
+
/** Database for `runOnce()` claims, the lifecycle lock and, without `secrets`, the secrets. */
|
|
301
|
+
db: DatabaseInterface;
|
|
302
|
+
/** Secret store; default `SecretService.create({ db })`. */
|
|
303
|
+
secrets?: HostedSecretStore;
|
|
304
|
+
/** Gateway config; default {@link getHostedGatewayConfig} (environment). */
|
|
305
|
+
gateway?: HostedGatewayConfig;
|
|
306
|
+
/** Admin client; default {@link createHostedGatewayAdmin}. Tests inject a fake. */
|
|
307
|
+
admin?: HostedGatewayAdmin;
|
|
308
|
+
/** Who acts, recorded as the audit user (default `system`). */
|
|
309
|
+
actor?: string;
|
|
310
|
+
/** Clock seam. */
|
|
311
|
+
now?: () => Date;
|
|
312
|
+
/** Alias/project nonce seam (tests). Default: random. */
|
|
313
|
+
nonce?: () => string;
|
|
314
|
+
/**
|
|
315
|
+
* Current entitlement check, run inside the tenant lock before a new key
|
|
316
|
+
* is minted (e.g. the host's `checkFeature('inference.hosted')`). With it,
|
|
317
|
+
* a provision that arrives after a downgrade (a stale event, a late
|
|
318
|
+
* retry) refuses with `HOSTED_NOT_ENTITLED` instead of activating.
|
|
319
|
+
*/
|
|
320
|
+
entitled?: (tenantId: string) => Promise<boolean>;
|
|
321
|
+
}
|
|
322
|
+
/** Hosted provisioning bound to one database, store and gateway. */
|
|
323
|
+
export interface HostedInferenceProvisioner {
|
|
324
|
+
provision(options: {
|
|
325
|
+
tenantId: string;
|
|
326
|
+
userId: string;
|
|
327
|
+
budget: HostedInferenceBudget;
|
|
328
|
+
}): Promise<ProvisionHostedInferenceResult>;
|
|
329
|
+
/**
|
|
330
|
+
* Revoke the user's active grant; with none active, retry any pending
|
|
331
|
+
* gateway deletions. Idempotent.
|
|
332
|
+
*/
|
|
333
|
+
revoke(options: {
|
|
334
|
+
tenantId: string;
|
|
335
|
+
userId: string;
|
|
336
|
+
reason?: string;
|
|
337
|
+
}): Promise<RevokeHostedInferenceResult>;
|
|
338
|
+
syncBudget(options: {
|
|
339
|
+
tenantId: string;
|
|
340
|
+
userId: string;
|
|
341
|
+
budget: HostedInferenceBudget;
|
|
342
|
+
}): Promise<SyncHostedBudgetResult>;
|
|
343
|
+
status(options: {
|
|
344
|
+
tenantId: string;
|
|
345
|
+
userId: string;
|
|
346
|
+
}): Promise<HostedInferenceDescriptor>;
|
|
347
|
+
/** Users of the tenant with an active hosted grant. */
|
|
348
|
+
listActive(tenantId: string): Promise<string[]>;
|
|
349
|
+
/** Users of the tenant with any hosted state (active, revoked, pending). */
|
|
350
|
+
listKnown(tenantId: string): Promise<string[]>;
|
|
351
|
+
revokeTenant(tenantId: string, options?: {
|
|
352
|
+
reason?: string;
|
|
353
|
+
}): Promise<RevokeHostedInferenceResult[]>;
|
|
354
|
+
syncTenantBudget(tenantId: string, budget: HostedInferenceBudget): Promise<SyncHostedBudgetResult[]>;
|
|
355
|
+
/**
|
|
356
|
+
* Converge the tenant to `target` (idempotent): not entitled revokes every
|
|
357
|
+
* active grant; entitled provisions `users` and syncs active budgets; both
|
|
358
|
+
* retry pending gateway deletions. Run it on webhook redelivery or on a
|
|
359
|
+
* schedule so a lost entitlement reaction is repaired.
|
|
360
|
+
*/
|
|
361
|
+
reconcileTenant(tenantId: string, target: HostedReconcileTarget): Promise<HostedReconcileResult>;
|
|
362
|
+
/**
|
|
363
|
+
* Drop an owed gateway deletion after an operator revoked that key on the
|
|
364
|
+
* gateway by hand (audited). Returns whether an entry was removed.
|
|
365
|
+
*/
|
|
366
|
+
acknowledgeGatewayRevocation(options: {
|
|
367
|
+
tenantId: string;
|
|
368
|
+
userId: string;
|
|
369
|
+
keyAlias: string;
|
|
370
|
+
}): Promise<boolean>;
|
|
371
|
+
}
|
|
372
|
+
/** Secret name of a user's hosted state. */
|
|
373
|
+
export declare function hostedInferenceStateSecretName(userId: string): string;
|
|
374
|
+
/** Validate a budget; fills the default window. */
|
|
375
|
+
export declare function normalizeHostedBudget(budget: HostedInferenceBudget | undefined): Required<HostedInferenceBudget>;
|
|
376
|
+
/** The gateway's budget shape for a hosted budget (USD at the boundary). */
|
|
377
|
+
export declare function toGatewayBudget(budget: Required<HostedInferenceBudget>): AIAdminBudget;
|
|
378
|
+
/**
|
|
379
|
+
* Create a provisioner. One per process (or per request) is fine: lifecycle
|
|
380
|
+
* operations run one at a time per process and, on PostgreSQL, hold a
|
|
381
|
+
* per-tenant transaction-scoped advisory lock (cross-process), so a
|
|
382
|
+
* tenant-wide revoke never misses an in-flight provision.
|
|
383
|
+
*/
|
|
384
|
+
export declare function createHostedInferenceProvisioner(options: HostedInferenceProvisionerOptions): HostedInferenceProvisioner;
|
|
385
|
+
/**
|
|
386
|
+
* Provision hosted inference for one user (#4759): create the tenant's
|
|
387
|
+
* gateway project on first use, mint a per-user virtual key with `budget`,
|
|
388
|
+
* store it as the user's `inference.provider-config` (`source: 'hosted'`,
|
|
389
|
+
* `mode: 'hosted'`), keeping the prior config for revoke. Idempotent per
|
|
390
|
+
* `(tenantId, userId)`: an active grant is returned (its budget synced when
|
|
391
|
+
* it differs) and concurrent calls create one key.
|
|
392
|
+
*/
|
|
393
|
+
export declare function provisionHostedInference(options: HostedInferenceProvisionerOptions & {
|
|
394
|
+
tenantId: string;
|
|
395
|
+
userId: string;
|
|
396
|
+
budget: HostedInferenceBudget;
|
|
397
|
+
}): Promise<ProvisionHostedInferenceResult>;
|
|
398
|
+
/**
|
|
399
|
+
* Revoke a user's hosted inference (downgrade, deletion): stop using the key
|
|
400
|
+
* (restore the user's prior provider config, or mode `off`), retire the
|
|
401
|
+
* state, and delete the gateway key (a failed delete is kept as an owed
|
|
402
|
+
* deletion, audited, and retried by revoke or reconcile). Idempotent.
|
|
403
|
+
*/
|
|
404
|
+
export declare function revokeHostedInference(options: HostedInferenceProvisionerOptions & {
|
|
405
|
+
tenantId: string;
|
|
406
|
+
userId: string;
|
|
407
|
+
reason?: string;
|
|
408
|
+
}): Promise<RevokeHostedInferenceResult>;
|
|
409
|
+
/** Read a hosted budget from an `inference.hosted` grant's `metadata.budget`. */
|
|
410
|
+
export declare function hostedBudgetFromGrantMetadata(metadata: Record<string, unknown> | undefined): HostedInferenceBudget | undefined;
|
|
411
|
+
/** Structural mirror of smrt-subscriptions' `EntitlementSnapshot` (grants). */
|
|
412
|
+
export interface HostedEntitlementSnapshot {
|
|
413
|
+
grants: ReadonlyArray<{
|
|
414
|
+
featureKey: string;
|
|
415
|
+
enabled?: boolean;
|
|
416
|
+
metadata?: Record<string, unknown>;
|
|
417
|
+
}>;
|
|
418
|
+
}
|
|
419
|
+
/** Structural mirror of smrt-subscriptions' `EntitlementChange`. */
|
|
420
|
+
export interface HostedEntitlementChange {
|
|
421
|
+
tenantId: string;
|
|
422
|
+
gained: readonly string[];
|
|
423
|
+
lost: readonly string[];
|
|
424
|
+
changed: readonly string[];
|
|
425
|
+
after: HostedEntitlementSnapshot;
|
|
426
|
+
}
|
|
427
|
+
/** Options for the entitlement listener and reconciler. */
|
|
428
|
+
export interface HostedInferenceEntitlementListenerOptions {
|
|
429
|
+
provisioner: HostedInferenceProvisioner;
|
|
430
|
+
/**
|
|
431
|
+
* Users who should hold a grant while the tenant is entitled (the
|
|
432
|
+
* tenant's members; membership is the host's). Users joining later are
|
|
433
|
+
* provisioned by the host calling `provision()` directly.
|
|
434
|
+
*/
|
|
435
|
+
users(tenantId: string): Promise<readonly string[]>;
|
|
436
|
+
/**
|
|
437
|
+
* The budget for the tenant's plan. Default: the `inference.hosted`
|
|
438
|
+
* grant's `metadata.budget` ({@link hostedBudgetFromGrantMetadata}), else
|
|
439
|
+
* `defaultBudget`.
|
|
440
|
+
*/
|
|
441
|
+
budgetFor?(tenantId: string, snapshot: HostedEntitlementSnapshot): HostedInferenceBudget | undefined;
|
|
442
|
+
defaultBudget?: HostedInferenceBudget;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Reconcile a tenant's hosted grants with its current entitlement snapshot
|
|
446
|
+
* (smrt-subscriptions' `snapshotEntitlements()`): entitled provisions
|
|
447
|
+
* `users()` and syncs budgets, not entitled revokes every grant, both retry
|
|
448
|
+
* owed gateway deletions. Idempotent: run it on webhook redelivery (a
|
|
449
|
+
* replayed write diffs to "no change") and on a schedule, so a reaction
|
|
450
|
+
* lost to a crash or a failed listener is repaired. Throws one error naming
|
|
451
|
+
* the users that failed, after trying all of them.
|
|
452
|
+
*/
|
|
453
|
+
export declare function createHostedInferenceReconciler(options: HostedInferenceEntitlementListenerOptions): (tenantId: string, snapshot: HostedEntitlementSnapshot) => Promise<HostedReconcileResult>;
|
|
454
|
+
/**
|
|
455
|
+
* The smrt-subscriptions entitlement-change listener for hosted inference:
|
|
456
|
+
* register it with `registerEntitlementChangeListener()`. A change that
|
|
457
|
+
* gains, loses or changes `inference.hosted` reconciles the tenant to the
|
|
458
|
+
* change's `after` snapshot ({@link createHostedInferenceReconciler}).
|
|
459
|
+
*/
|
|
460
|
+
export declare function createHostedInferenceEntitlementListener(options: HostedInferenceEntitlementListenerOptions): (change: HostedEntitlementChange) => Promise<void>;
|
|
461
|
+
//# sourceMappingURL=hosted.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted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,EAAE,qBAAqB,CAAC;CACvC;AA6BD;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,yCAAyC,GACjD,CACD,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,yBAAyB,KAChC,OAAO,CAAC,qBAAqB,CAAC,CA6BlC;AAED;;;;;GAKG;AACH,wBAAgB,wCAAwC,CACtD,OAAO,EAAE,yCAAyC,GACjD,CAAC,MAAM,EAAE,uBAAuB,KAAK,OAAO,CAAC,IAAI,CAAC,CASpD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { classifyInferenceFailure, isInferenceAbort, } from './classify.js';
|
|
2
|
+
export { CHAIN_KINDS, type ChainStep, candidateLabel, candidateToStep, EXECUTOR_KINDS, expandTarget, FUSION_GATE_CONTINUE, FUSION_SEAT_COUNTS, findFusionDefinitionIssues, findFusionPromptIssues, findInferenceConfigIssues, hasInferenceChains, validateInferenceConfig, } from './config.js';
|
|
3
|
+
export { InferenceConfigError, InferenceExhaustedError, InferenceFusionError, } from './errors.js';
|
|
4
|
+
export { type ChainExecutorOptions, createChainClient, } from './executor.js';
|
|
5
|
+
export { clearFusions, createChainExecutor, createFusionClient, type DefineFusionInput, defineFusion, type FusionCallOptions, type FusionGateResult, type FusionPromptResolver, type FusionRunResult, type FusionSeatPrompt, type FusionSeatResult, type FusionSeatStatus, type FusionSeatUsage, getFusion, listFusions, runFusion, setFusionPromptResolver, } from './fusion.js';
|
|
6
|
+
export { INFERENCE_PROVIDER_CONFIG_SECRET_TYPE, INFERENCE_PROVIDER_CONFIG_SOURCES, INFERENCE_PROVIDER_PARAM_KEYS, type InferenceProviderBinding, type InferenceProviderConfig, InferenceProviderConfigError, type InferenceProviderConfigSource, inferenceProviderBindingFor, inferenceProviderConfigSecretName, inferenceProviderSource, inferenceProviderTargets, parseInferenceProviderConfig, type RedactedInferenceProviderBinding, type RedactedInferenceProviderConfig, redactInferenceProviderConfig, redactInferenceTarget, } from './provider-config.js';
|
|
7
|
+
export { createInferenceResolver, isInferenceRegistered, type RegisterInferenceOptions, registerInference, } from './register.js';
|
|
8
|
+
export { INFERENCE_FAILURE_CLASSES, type InferenceConfigIssue, type InferenceFailureClass, type InferenceSubstitution, type InferenceSubstitutionReason, } from './types.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,WAAW,EACX,KAAK,SAAS,EACd,cAAc,EACd,eAAe,EACf,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,EAClB,0BAA0B,EAC1B,sBAAsB,EACtB,yBAAyB,EACzB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,oBAAoB,EACzB,iBAAiB,GAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,KAAK,iBAAiB,EACtB,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,SAAS,EACT,WAAW,EACX,SAAS,EACT,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,qCAAqC,EACrC,iCAAiC,EACjC,6BAA6B,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,4BAA4B,EAC5B,KAAK,6BAA6B,EAClC,2BAA2B,EAC3B,iCAAiC,EACjC,uBAAuB,EACvB,wBAAwB,EACxB,4BAA4B,EAC5B,KAAK,gCAAgC,EACrC,KAAK,+BAA+B,EACpC,6BAA6B,EAC7B,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,KAAK,wBAAwB,EAC7B,iBAAiB,GAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,yBAAyB,EACzB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,GACjC,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { A as candidateLabel, B as InferenceConfigError, C as createChainClient, D as EXECUTOR_KINDS, E as CHAIN_KINDS, F as findFusionPromptIssues, H as InferenceFusionError, I as findInferenceConfigIssues, L as hasInferenceChains, M as expandTarget, N as findFusionDefinitionIssues, O as FUSION_GATE_CONTINUE, R as validateInferenceConfig, S as setFusionPromptResolver, T as isInferenceAbort, V as InferenceExhaustedError, _ as createFusionClient, a as inferenceProviderBindingFor, b as listFusions, c as inferenceProviderTargets, d as redactInferenceTarget, f as createInferenceResolver, g as createChainExecutor, h as clearFusions, i as InferenceProviderConfigError, j as candidateToStep, k as FUSION_SEAT_COUNTS, l as parseInferenceProviderConfig, m as registerInference, n as INFERENCE_PROVIDER_CONFIG_SOURCES, o as inferenceProviderConfigSecretName, p as isInferenceRegistered, r as INFERENCE_PROVIDER_PARAM_KEYS, s as inferenceProviderSource, t as INFERENCE_PROVIDER_CONFIG_SECRET_TYPE, u as redactInferenceProviderConfig, v as defineFusion, w as classifyInferenceFailure, x as runFusion, y as getFusion } from "./chunks/provider-config-BSpIQRVM.js";
|
|
2
|
+
import { INFERENCE_FAILURE_CLASSES } from "./types.js";
|
|
3
|
+
//#region src/index.ts
|
|
4
|
+
registerInference();
|
|
5
|
+
//#endregion
|
|
6
|
+
export { CHAIN_KINDS, EXECUTOR_KINDS, FUSION_GATE_CONTINUE, FUSION_SEAT_COUNTS, INFERENCE_FAILURE_CLASSES, INFERENCE_PROVIDER_CONFIG_SECRET_TYPE, INFERENCE_PROVIDER_CONFIG_SOURCES, INFERENCE_PROVIDER_PARAM_KEYS, InferenceConfigError, InferenceExhaustedError, InferenceFusionError, InferenceProviderConfigError, candidateLabel, candidateToStep, classifyInferenceFailure, clearFusions, createChainClient, createChainExecutor, createFusionClient, createInferenceResolver, defineFusion, expandTarget, findFusionDefinitionIssues, findFusionPromptIssues, findInferenceConfigIssues, getFusion, hasInferenceChains, inferenceProviderBindingFor, inferenceProviderConfigSecretName, inferenceProviderSource, inferenceProviderTargets, isInferenceAbort, isInferenceRegistered, listFusions, parseInferenceProviderConfig, redactInferenceProviderConfig, redactInferenceTarget, registerInference, runFusion, setFusionPromptResolver, validateInferenceConfig };
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @happyvertical/smrt-inference — inference binding behavior for SMRT tiers\n * (#4749). This entry is browser-safe; `./node` holds the doctor and\n * `./resolver` the per-user / per-tenant resolver over smrt-secrets (#4756).\n *\n * Importing it registers the executor (alias chains and fusions) and the\n * validating resolver into core's seam (`setInferenceExecutor()` /\n * `setInferenceResolver()`).\n */\nimport { registerInference } from './register.js';\n\nexport {\n classifyInferenceFailure,\n isInferenceAbort,\n} from './classify.js';\nexport {\n CHAIN_KINDS,\n type ChainStep,\n candidateLabel,\n candidateToStep,\n EXECUTOR_KINDS,\n expandTarget,\n FUSION_GATE_CONTINUE,\n FUSION_SEAT_COUNTS,\n findFusionDefinitionIssues,\n findFusionPromptIssues,\n findInferenceConfigIssues,\n hasInferenceChains,\n validateInferenceConfig,\n} from './config.js';\nexport {\n InferenceConfigError,\n InferenceExhaustedError,\n InferenceFusionError,\n} from './errors.js';\nexport {\n type ChainExecutorOptions,\n createChainClient,\n} from './executor.js';\nexport {\n clearFusions,\n createChainExecutor,\n createFusionClient,\n type DefineFusionInput,\n defineFusion,\n type FusionCallOptions,\n type FusionGateResult,\n type FusionPromptResolver,\n type FusionRunResult,\n type FusionSeatPrompt,\n type FusionSeatResult,\n type FusionSeatStatus,\n type FusionSeatUsage,\n getFusion,\n listFusions,\n runFusion,\n setFusionPromptResolver,\n} from './fusion.js';\nexport {\n INFERENCE_PROVIDER_CONFIG_SECRET_TYPE,\n INFERENCE_PROVIDER_CONFIG_SOURCES,\n INFERENCE_PROVIDER_PARAM_KEYS,\n type InferenceProviderBinding,\n type InferenceProviderConfig,\n InferenceProviderConfigError,\n type InferenceProviderConfigSource,\n inferenceProviderBindingFor,\n inferenceProviderConfigSecretName,\n inferenceProviderSource,\n inferenceProviderTargets,\n parseInferenceProviderConfig,\n type RedactedInferenceProviderBinding,\n type RedactedInferenceProviderConfig,\n redactInferenceProviderConfig,\n redactInferenceTarget,\n} from './provider-config.js';\nexport {\n createInferenceResolver,\n isInferenceRegistered,\n type RegisterInferenceOptions,\n registerInference,\n} from './register.js';\nexport {\n INFERENCE_FAILURE_CLASSES,\n type InferenceConfigIssue,\n type InferenceFailureClass,\n type InferenceSubstitution,\n type InferenceSubstitutionReason,\n} from './types.js';\n\nregisterInference();\n"],"mappings":";;;AA0FA,kBAAkB"}
|