@bratsos/workflow-engine 0.2.1 → 0.4.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/LICENSE +21 -0
- package/dist/{chunk-P4KMGCT3.js → chunk-XS3ZX4KW.js} +33 -9
- package/dist/chunk-XS3ZX4KW.js.map +1 -0
- package/dist/{client-D4PoxADF.d.ts → client-DxNS_NoL.d.ts} +19 -2
- package/dist/client.d.ts +2 -1
- package/dist/client.js +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -2
- package/package.json +9 -8
- package/skills/workflow-engine/SKILL.md +9 -0
- package/skills/workflow-engine/references/04-ai-integration.md +66 -3
- package/dist/chunk-P4KMGCT3.js.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Alex Bratsos
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1355,6 +1355,10 @@ var OpenAIBatchProvider = class {
|
|
|
1355
1355
|
};
|
|
1356
1356
|
var logger = createLogger("AIHelper");
|
|
1357
1357
|
var DEFAULT_EMBEDDING_DIMENSIONS = 768;
|
|
1358
|
+
var embeddingProviderRegistry = /* @__PURE__ */ new Map();
|
|
1359
|
+
function registerEmbeddingProvider(providerName, factory) {
|
|
1360
|
+
embeddingProviderRegistry.set(providerName, factory);
|
|
1361
|
+
}
|
|
1358
1362
|
function getModelProvider(modelConfig) {
|
|
1359
1363
|
if (modelConfig.provider === "openrouter") {
|
|
1360
1364
|
return openrouter(modelConfig.id, {
|
|
@@ -1372,6 +1376,22 @@ function getModelProvider(modelConfig) {
|
|
|
1372
1376
|
}
|
|
1373
1377
|
return google(modelConfig.id);
|
|
1374
1378
|
}
|
|
1379
|
+
function getEmbeddingModelProvider(modelConfig) {
|
|
1380
|
+
const customFactory = embeddingProviderRegistry.get(modelConfig.provider);
|
|
1381
|
+
if (customFactory) {
|
|
1382
|
+
return customFactory(modelConfig.id);
|
|
1383
|
+
}
|
|
1384
|
+
if (modelConfig.provider === "openrouter") {
|
|
1385
|
+
return openrouter.textEmbeddingModel(modelConfig.id);
|
|
1386
|
+
}
|
|
1387
|
+
if (modelConfig.provider === "google") {
|
|
1388
|
+
const googleModelId = modelConfig.id.replace(/^google\//, "");
|
|
1389
|
+
return google.embeddingModel(googleModelId);
|
|
1390
|
+
}
|
|
1391
|
+
throw new Error(
|
|
1392
|
+
`Unsupported embedding provider "${modelConfig.provider}" for model "${modelConfig.id}". Register it with registerEmbeddingProvider() or use a built-in provider ("openrouter", "google").`
|
|
1393
|
+
);
|
|
1394
|
+
}
|
|
1375
1395
|
function calculateCostWithDiscount(modelKey, inputTokens, outputTokens, isBatch = false) {
|
|
1376
1396
|
const model = getModel(modelKey);
|
|
1377
1397
|
const baseCost = calculateCost(modelKey, inputTokens, outputTokens);
|
|
@@ -1718,6 +1738,7 @@ var AIHelperImpl = class _AIHelperImpl {
|
|
|
1718
1738
|
logger.debug(`embed request`, {
|
|
1719
1739
|
model: modelKey,
|
|
1720
1740
|
modelId: modelConfig.id,
|
|
1741
|
+
provider: modelConfig.provider,
|
|
1721
1742
|
textCount: texts.length,
|
|
1722
1743
|
textPreview,
|
|
1723
1744
|
dimensions,
|
|
@@ -1727,14 +1748,16 @@ var AIHelperImpl = class _AIHelperImpl {
|
|
|
1727
1748
|
const embeddings = [];
|
|
1728
1749
|
let totalInputTokens = 0;
|
|
1729
1750
|
for (const t of texts) {
|
|
1730
|
-
const
|
|
1751
|
+
const embeddingModel = getEmbeddingModelProvider(modelConfig);
|
|
1731
1752
|
const result = await embed({
|
|
1732
|
-
model:
|
|
1753
|
+
model: embeddingModel,
|
|
1733
1754
|
value: t,
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1755
|
+
...modelConfig.provider === "google" && {
|
|
1756
|
+
providerOptions: {
|
|
1757
|
+
google: {
|
|
1758
|
+
outputDimensionality: dimensions,
|
|
1759
|
+
taskType: options.taskType ?? "RETRIEVAL_DOCUMENT"
|
|
1760
|
+
}
|
|
1738
1761
|
}
|
|
1739
1762
|
}
|
|
1740
1763
|
});
|
|
@@ -1767,6 +1790,7 @@ var AIHelperImpl = class _AIHelperImpl {
|
|
|
1767
1790
|
});
|
|
1768
1791
|
logger.debug(`embed response`, {
|
|
1769
1792
|
model: modelKey,
|
|
1793
|
+
provider: modelConfig.provider,
|
|
1770
1794
|
embeddingsCount: embeddings.length,
|
|
1771
1795
|
dimensions,
|
|
1772
1796
|
inputTokens: totalInputTokens,
|
|
@@ -2287,6 +2311,6 @@ function createAIHelper(topic, logger2, logContext) {
|
|
|
2287
2311
|
return new AIHelperImpl(topic, logger2, logContext);
|
|
2288
2312
|
}
|
|
2289
2313
|
|
|
2290
|
-
export { AVAILABLE_MODELS, AnthropicBatchProvider, DEFAULT_MODEL_KEY, GoogleBatchProvider, ModelKey, ModelStatsTracker, NoInputSchema, OpenAIBatchProvider, calculateCost, createAIHelper, defineAsyncBatchStage, defineStage, getBestProviderForModel, getDefaultModel, getModel, getModelById, getRegisteredModel, listModels, listRegisteredModels, modelSupportsBatch, printAvailableModels, registerModels, requireStageOutput, resolveModelForProvider };
|
|
2291
|
-
//# sourceMappingURL=chunk-
|
|
2292
|
-
//# sourceMappingURL=chunk-
|
|
2314
|
+
export { AVAILABLE_MODELS, AnthropicBatchProvider, DEFAULT_MODEL_KEY, GoogleBatchProvider, ModelKey, ModelStatsTracker, NoInputSchema, OpenAIBatchProvider, calculateCost, createAIHelper, defineAsyncBatchStage, defineStage, getBestProviderForModel, getDefaultModel, getModel, getModelById, getRegisteredModel, listModels, listRegisteredModels, modelSupportsBatch, printAvailableModels, registerEmbeddingProvider, registerModels, requireStageOutput, resolveModelForProvider };
|
|
2315
|
+
//# sourceMappingURL=chunk-XS3ZX4KW.js.map
|
|
2316
|
+
//# sourceMappingURL=chunk-XS3ZX4KW.js.map
|