octaflow 0.22.0 → 0.23.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/dist/ai/index.d.ts +9 -2
- package/dist/ai/index.js +14 -2
- package/dist/ai/providers/index.d.ts +78 -1
- package/dist/ai/providers/index.js +84 -2
- package/dist/ai/registry.d.ts +2 -2
- package/dist/ai/registry.js +2 -2
- package/dist/{provider-registry-bXGOmyeh.d.ts → provider-registry-BDKSe_iO.d.ts} +51 -4
- package/dist/{provider-registry-DcRDsjtT.js → provider-registry-DHL-Ed-L.js} +58 -4
- package/package.json +6 -1
package/dist/ai/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { E as RetryPolicy, g as TypedWorkflow, h as TypedStepContext, m as TypedStep, nt as Result, tt as FlowErrorShape } from "../index-BURAYZui.js";
|
|
2
2
|
import { n as Logger } from "../logger-BCus3AOa.js";
|
|
3
3
|
import { i as BuildStepContextArgs, o as WorkflowHooks } from "../hooks-BdxIcc92.js";
|
|
4
|
-
import { a as
|
|
4
|
+
import { C as isSubprocessorResidency, S as embeddingDimensionsFor, _ as EmbeddingProviderMeta, a as AiProcessingRegion, b as OpenAiCompatibleProviderId, c as AiProviderModelOption, d as AiVendorResidency, f as DEFAULT_AI_PROVIDER, g as EmbeddingProviderId, h as EMBEDDING_PROVIDER_IDS, i as AiEndpointResidency, l as AiResidencyError, m as EMBEDDING_PROVIDERS, n as AI_PROVIDER_IDS, o as AiProviderId, p as DEFAULT_EMBEDDING_PROVIDER, r as AiEndpointRegion, s as AiProviderMeta, t as AI_PROVIDERS, u as AiResidencyResult, v as OPENAI_COMPATIBLE_PROVIDER, w as resolveEndpointResidency, x as OpenAiCompatibleProviderMeta, y as OPENAI_COMPATIBLE_PROVIDER_ID } from "../provider-registry-BDKSe_iO.js";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { EmbeddingModelV4, LanguageModelV4, SharedV4ProviderMetadata } from "@ai-sdk/provider";
|
|
7
7
|
//#region src/ai/instrumented-model.d.ts
|
|
@@ -82,6 +82,13 @@ export interface TokenUsage {
|
|
|
82
82
|
* pinned ids (`mistral-medium-2508`) fall to the fallback.
|
|
83
83
|
*/
|
|
84
84
|
export declare const DEFAULT_MODEL_PRICING: Record<string, ModelPricing>;
|
|
85
|
+
/**
|
|
86
|
+
* A zero row for a model that costs nothing per token, such as one on a server
|
|
87
|
+
* you run. Add it per model id: `{ ...DEFAULT_MODEL_PRICING, 'qwen3-32b': ZERO_MODEL_PRICING }`.
|
|
88
|
+
* An id missing from the table prices at the priciest row, which is safe for a
|
|
89
|
+
* vendor and makes quota refuse a free model long before it should.
|
|
90
|
+
*/
|
|
91
|
+
export declare const ZERO_MODEL_PRICING: ModelPricing;
|
|
85
92
|
export interface CostEstimatorOptions {
|
|
86
93
|
/** Pricing table keyed by model id. Defaults to `DEFAULT_MODEL_PRICING`. */
|
|
87
94
|
pricing?: Record<string, ModelPricing>;
|
|
@@ -543,4 +550,4 @@ export declare function thinkingSettingsFor(providerId: string, modelId: string,
|
|
|
543
550
|
budgetTokens: number;
|
|
544
551
|
}): ThinkingSettings;
|
|
545
552
|
//#endregion
|
|
546
|
-
export { AI_PROVIDERS, AI_PROVIDER_IDS, AiProcessingRegion, AiProviderId, AiProviderMeta, AiProviderModelOption, AiVendorResidency, DEFAULT_AI_PROVIDER, DEFAULT_EMBEDDING_PROVIDER, EMBEDDING_PROVIDERS, EMBEDDING_PROVIDER_IDS, EmbeddingProviderId, EmbeddingProviderMeta, embeddingDimensionsFor };
|
|
553
|
+
export { AI_PROVIDERS, AI_PROVIDER_IDS, AiEndpointRegion, AiEndpointResidency, AiProcessingRegion, AiProviderId, AiProviderMeta, AiProviderModelOption, AiResidencyError, AiResidencyResult, AiVendorResidency, DEFAULT_AI_PROVIDER, DEFAULT_EMBEDDING_PROVIDER, EMBEDDING_PROVIDERS, EMBEDDING_PROVIDER_IDS, EmbeddingProviderId, EmbeddingProviderMeta, OPENAI_COMPATIBLE_PROVIDER, OPENAI_COMPATIBLE_PROVIDER_ID, OpenAiCompatibleProviderId, OpenAiCompatibleProviderMeta, embeddingDimensionsFor, isSubprocessorResidency, resolveEndpointResidency };
|
package/dist/ai/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { S as ok, b as noopLogger, f as defineStep, l as buildWorkflow, x as err } from "../core-DNWPwFaE.js";
|
|
2
2
|
import { a as readRefusalDetails, i as isAiRefusalError, n as REFUSAL_FINISH_REASON, r as createRefusalAwareModel, t as AiRefusalError } from "../refusal-BsL2HPDb.js";
|
|
3
|
-
import { a as EMBEDDING_PROVIDERS, i as DEFAULT_EMBEDDING_PROVIDER, n as AI_PROVIDER_IDS, o as EMBEDDING_PROVIDER_IDS, r as DEFAULT_AI_PROVIDER, s as
|
|
3
|
+
import { a as EMBEDDING_PROVIDERS, c as OPENAI_COMPATIBLE_PROVIDER_ID, d as resolveEndpointResidency, i as DEFAULT_EMBEDDING_PROVIDER, l as embeddingDimensionsFor, n as AI_PROVIDER_IDS, o as EMBEDDING_PROVIDER_IDS, r as DEFAULT_AI_PROVIDER, s as OPENAI_COMPATIBLE_PROVIDER, t as AI_PROVIDERS, u as isSubprocessorResidency } from "../provider-registry-DHL-Ed-L.js";
|
|
4
4
|
import { wrapEmbeddingModel, wrapLanguageModel } from "ai";
|
|
5
5
|
//#region src/ai/instrumented-model.ts
|
|
6
6
|
function createUsageAccumulator() {
|
|
@@ -266,6 +266,18 @@ const DEFAULT_MODEL_PRICING = {
|
|
|
266
266
|
cacheWritePerMillion: 0
|
|
267
267
|
}
|
|
268
268
|
};
|
|
269
|
+
/**
|
|
270
|
+
* A zero row for a model that costs nothing per token, such as one on a server
|
|
271
|
+
* you run. Add it per model id: `{ ...DEFAULT_MODEL_PRICING, 'qwen3-32b': ZERO_MODEL_PRICING }`.
|
|
272
|
+
* An id missing from the table prices at the priciest row, which is safe for a
|
|
273
|
+
* vendor and makes quota refuse a free model long before it should.
|
|
274
|
+
*/
|
|
275
|
+
const ZERO_MODEL_PRICING = Object.freeze({
|
|
276
|
+
inputPerMillion: 0,
|
|
277
|
+
outputPerMillion: 0,
|
|
278
|
+
cacheReadPerMillion: 0,
|
|
279
|
+
cacheWritePerMillion: 0
|
|
280
|
+
});
|
|
269
281
|
function priciest(pricing) {
|
|
270
282
|
let best;
|
|
271
283
|
for (const p of Object.values(pricing)) if (!best || p.outputPerMillion > best.outputPerMillion) best = p;
|
|
@@ -650,4 +662,4 @@ function thinkingSettingsFor(providerId, modelId, opts) {
|
|
|
650
662
|
return { temperature: opts.temperature };
|
|
651
663
|
}
|
|
652
664
|
//#endregion
|
|
653
|
-
export { AI_PROVIDERS, AI_PROVIDER_IDS, AiRefusalError, DEFAULT_AI_PROVIDER, DEFAULT_AI_QUOTA, DEFAULT_EMBEDDING_PROVIDER, DEFAULT_MODEL_PRICING, EMBEDDING_PROVIDERS, EMBEDDING_PROVIDER_IDS, REFUSAL_FINISH_REASON, anthropicThinkingSettings, buildAiWorkflow, createAiQuotaService, createAiUsageAggregationService, createAiWorkflowHooks, createCostEstimator, createEmbeddingUsageAccumulator, createInstrumentedEmbeddingModel, createInstrumentedModel, createRefusalAwareModel, createUsageAccumulator, defineAiStep, embeddingDimensionsFor, estimateCostMicros, isAiRefusalError, readRefusalDetails, supportsAdaptiveThinking, supportsToolSearch, thinkingSettingsFor };
|
|
665
|
+
export { AI_PROVIDERS, AI_PROVIDER_IDS, AiRefusalError, DEFAULT_AI_PROVIDER, DEFAULT_AI_QUOTA, DEFAULT_EMBEDDING_PROVIDER, DEFAULT_MODEL_PRICING, EMBEDDING_PROVIDERS, EMBEDDING_PROVIDER_IDS, OPENAI_COMPATIBLE_PROVIDER, OPENAI_COMPATIBLE_PROVIDER_ID, REFUSAL_FINISH_REASON, ZERO_MODEL_PRICING, anthropicThinkingSettings, buildAiWorkflow, createAiQuotaService, createAiUsageAggregationService, createAiWorkflowHooks, createCostEstimator, createEmbeddingUsageAccumulator, createInstrumentedEmbeddingModel, createInstrumentedModel, createRefusalAwareModel, createUsageAccumulator, defineAiStep, embeddingDimensionsFor, estimateCostMicros, isAiRefusalError, isSubprocessorResidency, readRefusalDetails, resolveEndpointResidency, supportsAdaptiveThinking, supportsToolSearch, thinkingSettingsFor };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as OpenAiCompatibleProviderId, g as EmbeddingProviderId, i as AiEndpointResidency, o as AiProviderId } from "../../provider-registry-BDKSe_iO.js";
|
|
2
2
|
import { EmbeddingModelV4, LanguageModelV4 } from "@ai-sdk/provider";
|
|
3
3
|
//#region src/ai/providers/index.d.ts
|
|
4
4
|
export type LanguageModelFactory = (modelId: string) => LanguageModelV4;
|
|
@@ -66,4 +66,81 @@ export interface LazyEmbeddingModelMeta {
|
|
|
66
66
|
* next call rather than cached.
|
|
67
67
|
*/
|
|
68
68
|
export declare function createLazyEmbeddingModel(meta: LazyEmbeddingModelMeta, load: () => Promise<EmbeddingModelV4>): EmbeddingModelV4;
|
|
69
|
+
export type AiProviderConfigErrorKey = 'ai_residency_undeclared' | 'ai_residency_invalid' | 'ai_base_url_invalid' | 'ai_model_required' | 'ai_embedding_dimensions_invalid';
|
|
70
|
+
/**
|
|
71
|
+
* A provider configuration that cannot work. Thrown before any SDK is loaded
|
|
72
|
+
* or any request is made: it is a deployment mistake, found at wiring time.
|
|
73
|
+
*/
|
|
74
|
+
export declare class AiProviderConfigError extends Error {
|
|
75
|
+
readonly key: AiProviderConfigErrorKey;
|
|
76
|
+
constructor(key: AiProviderConfigErrorKey, message: string);
|
|
77
|
+
}
|
|
78
|
+
export interface OpenAiCompatibleEndpointConfig {
|
|
79
|
+
/** The API root including its version segment, e.g. `http://vllm.ai.svc:8000/v1`. Required: there is no default host. */
|
|
80
|
+
baseUrl: string;
|
|
81
|
+
/** Sent as `Authorization: Bearer …` when set. Most self-hosted servers need none. */
|
|
82
|
+
apiKey?: string;
|
|
83
|
+
/** Where the endpoint processes payloads. Required, validated by `resolveEndpointResidency`. */
|
|
84
|
+
residency: AiEndpointResidency;
|
|
85
|
+
/** Reported as the model's `provider`. Defaults to `openai-compatible`. */
|
|
86
|
+
name?: string;
|
|
87
|
+
headers?: Record<string, string>;
|
|
88
|
+
/** A fetch implementation, for middleware or tests. Defaults to the global `fetch`. */
|
|
89
|
+
fetch?: typeof globalThis.fetch;
|
|
90
|
+
}
|
|
91
|
+
export interface OpenAiCompatibleModelProviderConfig extends OpenAiCompatibleEndpointConfig {
|
|
92
|
+
/** The model a call without an id uses. Required: a server you run has no registry default. */
|
|
93
|
+
defaultModel: string;
|
|
94
|
+
/** Cheap model for classifier-style passes. Defaults to `defaultModel`. */
|
|
95
|
+
classifierModel?: string;
|
|
96
|
+
/** Set when the server enforces a JSON schema on output (vLLM does); otherwise `generateObject` uses JSON mode. */
|
|
97
|
+
structuredOutputs?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Ask for token usage on streamed responses. Defaults to `true`, because the
|
|
100
|
+
* instrumented model meters what the stream reports and a stream without it
|
|
101
|
+
* reports zero tokens. Turn it off only for a server that rejects the option.
|
|
102
|
+
*/
|
|
103
|
+
includeUsage?: boolean;
|
|
104
|
+
}
|
|
105
|
+
export interface OpenAiCompatibleModelProvider {
|
|
106
|
+
providerId: OpenAiCompatibleProviderId;
|
|
107
|
+
/** The declared residency, validated — what a badge or an audit record shows. */
|
|
108
|
+
residency: AiEndpointResidency;
|
|
109
|
+
classifierModelId: string;
|
|
110
|
+
/** A Chat Completions model, wrapped for refusal detection like the vendor ones. */
|
|
111
|
+
languageModel(modelId?: string): LanguageModelV4;
|
|
112
|
+
}
|
|
113
|
+
export interface OpenAiCompatibleEmbeddingProviderConfig extends OpenAiCompatibleEndpointConfig {
|
|
114
|
+
model: string;
|
|
115
|
+
/**
|
|
116
|
+
* The model's vector width, which must match your `vector(N)` column.
|
|
117
|
+
* Required: a guessed width, such as the registry's 1536 fallback, silently
|
|
118
|
+
* breaks a 1024-wide model like `bge-m3` at the first insert.
|
|
119
|
+
*/
|
|
120
|
+
dimensions: number;
|
|
121
|
+
}
|
|
122
|
+
export interface OpenAiCompatibleEmbeddingProvider {
|
|
123
|
+
providerId: OpenAiCompatibleProviderId;
|
|
124
|
+
residency: AiEndpointResidency;
|
|
125
|
+
modelId: string;
|
|
126
|
+
dimensions: number;
|
|
127
|
+
embeddingModel(): EmbeddingModelV4;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* A model server you run, or any host with the OpenAI-compatible API, as
|
|
131
|
+
* refusal-aware models. Language models go through **Chat Completions**, which
|
|
132
|
+
* is what vLLM, Ollama and llama.cpp speak — not the Responses API that
|
|
133
|
+
* `@ai-sdk/openai` defaults to.
|
|
134
|
+
*
|
|
135
|
+
* ```ts
|
|
136
|
+
* const models = await createOpenAiCompatibleModelProvider({
|
|
137
|
+
* baseUrl: 'http://vllm.ai.svc:8000/v1',
|
|
138
|
+
* residency: { region: 'self-hosted' },
|
|
139
|
+
* defaultModel: 'qwen3-32b',
|
|
140
|
+
* });
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
export declare function createOpenAiCompatibleModelProvider(config: OpenAiCompatibleModelProviderConfig): Promise<OpenAiCompatibleModelProvider>;
|
|
144
|
+
/** An embedding model on an OpenAI-compatible endpoint, with its declared width. */
|
|
145
|
+
export declare function createOpenAiCompatibleEmbeddingProvider(config: OpenAiCompatibleEmbeddingProviderConfig): Promise<OpenAiCompatibleEmbeddingProvider>;
|
|
69
146
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as createRefusalAwareModel } from "../../refusal-BsL2HPDb.js";
|
|
2
|
-
import { a as EMBEDDING_PROVIDERS, t as AI_PROVIDERS } from "../../provider-registry-
|
|
2
|
+
import { a as EMBEDDING_PROVIDERS, c as OPENAI_COMPATIBLE_PROVIDER_ID, d as resolveEndpointResidency, t as AI_PROVIDERS } from "../../provider-registry-DHL-Ed-L.js";
|
|
3
3
|
//#region src/ai/providers/index.ts
|
|
4
4
|
const LLM_LOADERS = {
|
|
5
5
|
anthropic: async (apiKey, baseURL) => {
|
|
@@ -103,5 +103,87 @@ function createLazyEmbeddingModel(meta, load) {
|
|
|
103
103
|
doEmbed: (options) => model().then((m) => m.doEmbed(options))
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* A provider configuration that cannot work. Thrown before any SDK is loaded
|
|
108
|
+
* or any request is made: it is a deployment mistake, found at wiring time.
|
|
109
|
+
*/
|
|
110
|
+
var AiProviderConfigError = class extends Error {
|
|
111
|
+
key;
|
|
112
|
+
constructor(key, message) {
|
|
113
|
+
super(message);
|
|
114
|
+
this.name = "AiProviderConfigError";
|
|
115
|
+
this.key = key;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
function checkEndpoint(config) {
|
|
119
|
+
const residency = resolveEndpointResidency(config.residency);
|
|
120
|
+
if (!residency.ok) throw new AiProviderConfigError(residency.error.key, residency.error.message);
|
|
121
|
+
let url;
|
|
122
|
+
try {
|
|
123
|
+
url = new URL(config.baseUrl);
|
|
124
|
+
} catch {
|
|
125
|
+
url = void 0;
|
|
126
|
+
}
|
|
127
|
+
if (url === void 0 || url.protocol !== "http:" && url.protocol !== "https:") throw new AiProviderConfigError("ai_base_url_invalid", `baseUrl must be an absolute http(s) URL, got ${JSON.stringify(config.baseUrl)}`);
|
|
128
|
+
return residency.value;
|
|
129
|
+
}
|
|
130
|
+
function requireModel(modelId, field) {
|
|
131
|
+
if (typeof modelId !== "string" || modelId.trim() === "") throw new AiProviderConfigError("ai_model_required", `${field} is required for an OpenAI-compatible endpoint`);
|
|
132
|
+
return modelId;
|
|
133
|
+
}
|
|
134
|
+
async function loadOpenAiCompatible(config, options = {}) {
|
|
135
|
+
const { createOpenAICompatible } = await import("@ai-sdk/openai-compatible");
|
|
136
|
+
return createOpenAICompatible({
|
|
137
|
+
name: config.name ?? "openai-compatible",
|
|
138
|
+
baseURL: config.baseUrl.replace(/\/+$/, ""),
|
|
139
|
+
apiKey: config.apiKey,
|
|
140
|
+
headers: config.headers,
|
|
141
|
+
fetch: config.fetch,
|
|
142
|
+
includeUsage: options.includeUsage ?? true,
|
|
143
|
+
supportsStructuredOutputs: options.structuredOutputs
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* A model server you run, or any host with the OpenAI-compatible API, as
|
|
148
|
+
* refusal-aware models. Language models go through **Chat Completions**, which
|
|
149
|
+
* is what vLLM, Ollama and llama.cpp speak — not the Responses API that
|
|
150
|
+
* `@ai-sdk/openai` defaults to.
|
|
151
|
+
*
|
|
152
|
+
* ```ts
|
|
153
|
+
* const models = await createOpenAiCompatibleModelProvider({
|
|
154
|
+
* baseUrl: 'http://vllm.ai.svc:8000/v1',
|
|
155
|
+
* residency: { region: 'self-hosted' },
|
|
156
|
+
* defaultModel: 'qwen3-32b',
|
|
157
|
+
* });
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
async function createOpenAiCompatibleModelProvider(config) {
|
|
161
|
+
const residency = checkEndpoint(config);
|
|
162
|
+
const defaultModel = requireModel(config.defaultModel, "defaultModel");
|
|
163
|
+
const provider = await loadOpenAiCompatible(config, {
|
|
164
|
+
structuredOutputs: config.structuredOutputs,
|
|
165
|
+
includeUsage: config.includeUsage
|
|
166
|
+
});
|
|
167
|
+
return {
|
|
168
|
+
providerId: OPENAI_COMPATIBLE_PROVIDER_ID,
|
|
169
|
+
residency,
|
|
170
|
+
classifierModelId: config.classifierModel ?? defaultModel,
|
|
171
|
+
languageModel: (modelId) => createRefusalAwareModel(provider.chatModel(modelId ?? defaultModel))
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/** An embedding model on an OpenAI-compatible endpoint, with its declared width. */
|
|
175
|
+
async function createOpenAiCompatibleEmbeddingProvider(config) {
|
|
176
|
+
const residency = checkEndpoint(config);
|
|
177
|
+
const modelId = requireModel(config.model, "model");
|
|
178
|
+
if (!Number.isInteger(config.dimensions) || config.dimensions <= 0) throw new AiProviderConfigError("ai_embedding_dimensions_invalid", `dimensions must be a positive integer matching your vector column, got ${JSON.stringify(config.dimensions)}`);
|
|
179
|
+
const provider = await loadOpenAiCompatible(config);
|
|
180
|
+
return {
|
|
181
|
+
providerId: OPENAI_COMPATIBLE_PROVIDER_ID,
|
|
182
|
+
residency,
|
|
183
|
+
modelId,
|
|
184
|
+
dimensions: config.dimensions,
|
|
185
|
+
embeddingModel: () => provider.embeddingModel(modelId)
|
|
186
|
+
};
|
|
187
|
+
}
|
|
106
188
|
//#endregion
|
|
107
|
-
export { createEmbeddingModelFactory, createEmbeddingModelProvider, createLanguageModelFactory, createLanguageModelProvider, createLazyEmbeddingModel };
|
|
189
|
+
export { AiProviderConfigError, createEmbeddingModelFactory, createEmbeddingModelProvider, createLanguageModelFactory, createLanguageModelProvider, createLazyEmbeddingModel, createOpenAiCompatibleEmbeddingProvider, createOpenAiCompatibleModelProvider };
|
package/dist/ai/registry.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { AI_PROVIDERS, AI_PROVIDER_IDS, AiProcessingRegion, AiProviderId, AiProviderMeta, AiProviderModelOption, AiVendorResidency, DEFAULT_AI_PROVIDER, DEFAULT_EMBEDDING_PROVIDER, EMBEDDING_PROVIDERS, EMBEDDING_PROVIDER_IDS, EmbeddingProviderId, EmbeddingProviderMeta, embeddingDimensionsFor };
|
|
1
|
+
import { C as isSubprocessorResidency, S as embeddingDimensionsFor, _ as EmbeddingProviderMeta, a as AiProcessingRegion, b as OpenAiCompatibleProviderId, c as AiProviderModelOption, d as AiVendorResidency, f as DEFAULT_AI_PROVIDER, g as EmbeddingProviderId, h as EMBEDDING_PROVIDER_IDS, i as AiEndpointResidency, l as AiResidencyError, m as EMBEDDING_PROVIDERS, n as AI_PROVIDER_IDS, o as AiProviderId, p as DEFAULT_EMBEDDING_PROVIDER, r as AiEndpointRegion, s as AiProviderMeta, t as AI_PROVIDERS, u as AiResidencyResult, v as OPENAI_COMPATIBLE_PROVIDER, w as resolveEndpointResidency, x as OpenAiCompatibleProviderMeta, y as OPENAI_COMPATIBLE_PROVIDER_ID } from "../provider-registry-BDKSe_iO.js";
|
|
2
|
+
export { AI_PROVIDERS, AI_PROVIDER_IDS, AiEndpointRegion, AiEndpointResidency, AiProcessingRegion, AiProviderId, AiProviderMeta, AiProviderModelOption, AiResidencyError, AiResidencyResult, AiVendorResidency, DEFAULT_AI_PROVIDER, DEFAULT_EMBEDDING_PROVIDER, EMBEDDING_PROVIDERS, EMBEDDING_PROVIDER_IDS, EmbeddingProviderId, EmbeddingProviderMeta, OPENAI_COMPATIBLE_PROVIDER, OPENAI_COMPATIBLE_PROVIDER_ID, OpenAiCompatibleProviderId, OpenAiCompatibleProviderMeta, embeddingDimensionsFor, isSubprocessorResidency, resolveEndpointResidency };
|
package/dist/ai/registry.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as EMBEDDING_PROVIDERS, i as DEFAULT_EMBEDDING_PROVIDER, n as AI_PROVIDER_IDS, o as EMBEDDING_PROVIDER_IDS, r as DEFAULT_AI_PROVIDER, s as
|
|
2
|
-
export { AI_PROVIDERS, AI_PROVIDER_IDS, DEFAULT_AI_PROVIDER, DEFAULT_EMBEDDING_PROVIDER, EMBEDDING_PROVIDERS, EMBEDDING_PROVIDER_IDS, embeddingDimensionsFor };
|
|
1
|
+
import { a as EMBEDDING_PROVIDERS, c as OPENAI_COMPATIBLE_PROVIDER_ID, d as resolveEndpointResidency, i as DEFAULT_EMBEDDING_PROVIDER, l as embeddingDimensionsFor, n as AI_PROVIDER_IDS, o as EMBEDDING_PROVIDER_IDS, r as DEFAULT_AI_PROVIDER, s as OPENAI_COMPATIBLE_PROVIDER, t as AI_PROVIDERS, u as isSubprocessorResidency } from "../provider-registry-DHL-Ed-L.js";
|
|
2
|
+
export { AI_PROVIDERS, AI_PROVIDER_IDS, DEFAULT_AI_PROVIDER, DEFAULT_EMBEDDING_PROVIDER, EMBEDDING_PROVIDERS, EMBEDDING_PROVIDER_IDS, OPENAI_COMPATIBLE_PROVIDER, OPENAI_COMPATIBLE_PROVIDER_ID, embeddingDimensionsFor, isSubprocessorResidency, resolveEndpointResidency };
|
|
@@ -72,10 +72,57 @@ interface EmbeddingProviderMeta {
|
|
|
72
72
|
}
|
|
73
73
|
declare const EMBEDDING_PROVIDERS: Record<EmbeddingProviderId, EmbeddingProviderMeta>;
|
|
74
74
|
/**
|
|
75
|
-
* Vector dimensions for an embedding model id
|
|
76
|
-
* `fallback` (default 1536
|
|
77
|
-
*
|
|
75
|
+
* Vector dimensions for an embedding model id in the vendor lists above.
|
|
76
|
+
* Unknown ids fall back to `fallback` (default 1536) so free-form vendor model
|
|
77
|
+
* ids keep a working column. A self-hosted model never goes through this
|
|
78
|
+
* guess: its width is declared (`createOpenAiCompatibleEmbeddingProvider`'s
|
|
79
|
+
* `dimensions`), because a wrong one fails at the first `vector(N)` insert.
|
|
78
80
|
*/
|
|
79
81
|
declare function embeddingDimensionsFor(modelId: string, fallback?: number): number;
|
|
82
|
+
/**
|
|
83
|
+
* Where a model endpoint the *deployment* names processes payloads. A vendor in
|
|
84
|
+
* the lists above has a fixed residency; an OpenAI-compatible endpoint does not:
|
|
85
|
+
* the same client talks to vLLM in your own cluster, to Ollama on a workstation,
|
|
86
|
+
* or to a hosted inference vendor. So whoever deploys it declares the residency,
|
|
87
|
+
* and `'self-hosted'` is the value that adds no subprocessor.
|
|
88
|
+
*
|
|
89
|
+
* Kept apart from {@link AiProcessingRegion} on purpose: that union describes the
|
|
90
|
+
* vendors above, and a picker that iterates `AI_PROVIDERS` keeps working unchanged.
|
|
91
|
+
*/
|
|
92
|
+
type AiEndpointRegion = AiProcessingRegion | 'self-hosted';
|
|
93
|
+
/** `{ region: 'self-hosted' }` for infrastructure you operate; a vendor's full residency otherwise. */
|
|
94
|
+
type AiEndpointResidency = {
|
|
95
|
+
region: 'self-hosted';
|
|
96
|
+
} | AiVendorResidency;
|
|
97
|
+
declare const OPENAI_COMPATIBLE_PROVIDER_ID = "openai-compatible";
|
|
98
|
+
type OpenAiCompatibleProviderId = typeof OPENAI_COMPATIBLE_PROVIDER_ID;
|
|
99
|
+
interface OpenAiCompatibleProviderMeta {
|
|
100
|
+
id: OpenAiCompatibleProviderId;
|
|
101
|
+
label: string;
|
|
102
|
+
/** Never fixed in the registry — see {@link resolveEndpointResidency}. */
|
|
103
|
+
residency: 'declared-by-deployment';
|
|
104
|
+
}
|
|
105
|
+
declare const OPENAI_COMPATIBLE_PROVIDER: OpenAiCompatibleProviderMeta;
|
|
106
|
+
interface AiResidencyError {
|
|
107
|
+
key: 'ai_residency_undeclared' | 'ai_residency_invalid';
|
|
108
|
+
message: string;
|
|
109
|
+
}
|
|
110
|
+
type AiResidencyResult = {
|
|
111
|
+
ok: true;
|
|
112
|
+
value: AiEndpointResidency;
|
|
113
|
+
} | {
|
|
114
|
+
ok: false;
|
|
115
|
+
error: AiResidencyError;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Validates a residency declared by a deployment — from config, an env file, a
|
|
119
|
+
* database row — before any call is made. A missing one is
|
|
120
|
+
* `ai_residency_undeclared`: an endpoint whose data location nobody stated is
|
|
121
|
+
* refused, never assumed to be local. A vendor region needs the legal name and
|
|
122
|
+
* the ISO country a subprocessor annex prints.
|
|
123
|
+
*/
|
|
124
|
+
declare function resolveEndpointResidency(declared: unknown): AiResidencyResult;
|
|
125
|
+
/** Whether calling an endpoint with this residency makes its operator a subprocessor. A self-hosted endpoint does not. */
|
|
126
|
+
declare function isSubprocessorResidency(residency: AiEndpointResidency): boolean;
|
|
80
127
|
//#endregion
|
|
81
|
-
export {
|
|
128
|
+
export { isSubprocessorResidency as C, embeddingDimensionsFor as S, EmbeddingProviderMeta as _, AiProcessingRegion as a, OpenAiCompatibleProviderId as b, AiProviderModelOption as c, AiVendorResidency as d, DEFAULT_AI_PROVIDER as f, EmbeddingProviderId as g, EMBEDDING_PROVIDER_IDS as h, AiEndpointResidency as i, AiResidencyError as l, EMBEDDING_PROVIDERS as m, AI_PROVIDER_IDS as n, AiProviderId as o, DEFAULT_EMBEDDING_PROVIDER as p, AiEndpointRegion as r, AiProviderMeta as s, AI_PROVIDERS as t, AiResidencyResult as u, OPENAI_COMPATIBLE_PROVIDER as v, resolveEndpointResidency as w, OpenAiCompatibleProviderMeta as x, OPENAI_COMPATIBLE_PROVIDER_ID as y };
|
|
@@ -106,9 +106,11 @@ const EMBEDDING_PROVIDERS = {
|
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
/**
|
|
109
|
-
* Vector dimensions for an embedding model id
|
|
110
|
-
* `fallback` (default 1536
|
|
111
|
-
*
|
|
109
|
+
* Vector dimensions for an embedding model id in the vendor lists above.
|
|
110
|
+
* Unknown ids fall back to `fallback` (default 1536) so free-form vendor model
|
|
111
|
+
* ids keep a working column. A self-hosted model never goes through this
|
|
112
|
+
* guess: its width is declared (`createOpenAiCompatibleEmbeddingProvider`'s
|
|
113
|
+
* `dimensions`), because a wrong one fails at the first `vector(N)` insert.
|
|
112
114
|
*/
|
|
113
115
|
function embeddingDimensionsFor(modelId, fallback = 1536) {
|
|
114
116
|
for (const meta of Object.values(EMBEDDING_PROVIDERS)) {
|
|
@@ -117,5 +119,57 @@ function embeddingDimensionsFor(modelId, fallback = 1536) {
|
|
|
117
119
|
}
|
|
118
120
|
return fallback;
|
|
119
121
|
}
|
|
122
|
+
const OPENAI_COMPATIBLE_PROVIDER_ID = "openai-compatible";
|
|
123
|
+
const OPENAI_COMPATIBLE_PROVIDER = {
|
|
124
|
+
id: OPENAI_COMPATIBLE_PROVIDER_ID,
|
|
125
|
+
label: "OpenAI-compatible endpoint",
|
|
126
|
+
residency: "declared-by-deployment"
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Validates a residency declared by a deployment — from config, an env file, a
|
|
130
|
+
* database row — before any call is made. A missing one is
|
|
131
|
+
* `ai_residency_undeclared`: an endpoint whose data location nobody stated is
|
|
132
|
+
* refused, never assumed to be local. A vendor region needs the legal name and
|
|
133
|
+
* the ISO country a subprocessor annex prints.
|
|
134
|
+
*/
|
|
135
|
+
function resolveEndpointResidency(declared) {
|
|
136
|
+
if (declared === void 0 || declared === null) return {
|
|
137
|
+
ok: false,
|
|
138
|
+
error: {
|
|
139
|
+
key: "ai_residency_undeclared",
|
|
140
|
+
message: "an OpenAI-compatible endpoint needs a declared residency: { region: \"self-hosted\" }, or a vendor region with its legalName and country"
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
if (typeof declared !== "object") return invalidResidency("residency must be an object");
|
|
144
|
+
const { region, legalName, country } = declared;
|
|
145
|
+
if (region === "self-hosted") return {
|
|
146
|
+
ok: true,
|
|
147
|
+
value: { region: "self-hosted" }
|
|
148
|
+
};
|
|
149
|
+
if (region !== "eu" && region !== "third-country") return invalidResidency(`unknown region ${JSON.stringify(region)}; expected "self-hosted", "eu" or "third-country"`);
|
|
150
|
+
if (typeof legalName !== "string" || legalName.trim() === "") return invalidResidency(`region "${region}" names a vendor, so legalName is required`);
|
|
151
|
+
if (typeof country !== "string" || !/^[A-Z]{2}$/.test(country)) return invalidResidency(`region "${region}" needs country as an ISO 3166-1 alpha-2 code`);
|
|
152
|
+
return {
|
|
153
|
+
ok: true,
|
|
154
|
+
value: {
|
|
155
|
+
region,
|
|
156
|
+
legalName,
|
|
157
|
+
country
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function invalidResidency(message) {
|
|
162
|
+
return {
|
|
163
|
+
ok: false,
|
|
164
|
+
error: {
|
|
165
|
+
key: "ai_residency_invalid",
|
|
166
|
+
message
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/** Whether calling an endpoint with this residency makes its operator a subprocessor. A self-hosted endpoint does not. */
|
|
171
|
+
function isSubprocessorResidency(residency) {
|
|
172
|
+
return residency.region !== "self-hosted";
|
|
173
|
+
}
|
|
120
174
|
//#endregion
|
|
121
|
-
export { EMBEDDING_PROVIDERS as a, DEFAULT_EMBEDDING_PROVIDER as i, AI_PROVIDER_IDS as n, EMBEDDING_PROVIDER_IDS as o, DEFAULT_AI_PROVIDER as r,
|
|
175
|
+
export { EMBEDDING_PROVIDERS as a, OPENAI_COMPATIBLE_PROVIDER_ID as c, resolveEndpointResidency as d, DEFAULT_EMBEDDING_PROVIDER as i, embeddingDimensionsFor as l, AI_PROVIDER_IDS as n, EMBEDDING_PROVIDER_IDS as o, DEFAULT_AI_PROVIDER as r, OPENAI_COMPATIBLE_PROVIDER as s, AI_PROVIDERS as t, isSubprocessorResidency as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "octaflow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "Durable DAG workflow engine: Zod-typed steps over Postgres + pg-boss, with an optional AI add-on (token/cost/quota). Layered single package.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
"@ai-sdk/anthropic": "^4.0.0",
|
|
72
72
|
"@ai-sdk/mistral": "^4.0.0",
|
|
73
73
|
"@ai-sdk/openai": "^4.0.0",
|
|
74
|
+
"@ai-sdk/openai-compatible": "^3.0.0",
|
|
74
75
|
"@ai-sdk/provider": "^4.0.0",
|
|
75
76
|
"ai": "^7.0.0",
|
|
76
77
|
"pg": "^8.0.0",
|
|
@@ -88,6 +89,9 @@
|
|
|
88
89
|
"@ai-sdk/openai": {
|
|
89
90
|
"optional": true
|
|
90
91
|
},
|
|
92
|
+
"@ai-sdk/openai-compatible": {
|
|
93
|
+
"optional": true
|
|
94
|
+
},
|
|
91
95
|
"@ai-sdk/provider": {
|
|
92
96
|
"optional": true
|
|
93
97
|
},
|
|
@@ -105,6 +109,7 @@
|
|
|
105
109
|
"@ai-sdk/anthropic": "^4.0.52",
|
|
106
110
|
"@ai-sdk/mistral": "^4.0.42",
|
|
107
111
|
"@ai-sdk/openai": "^4.0.65",
|
|
112
|
+
"@ai-sdk/openai-compatible": "^3.0.48",
|
|
108
113
|
"@ai-sdk/provider": "^4.0.13",
|
|
109
114
|
"@testcontainers/postgresql": "^12.1.0",
|
|
110
115
|
"@types/node": "^26.5.1",
|