@bratsos/workflow-engine 0.2.1 → 0.3.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/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { ModelKey } from './chunk-P4KMGCT3.js';
2
- 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 } from './chunk-P4KMGCT3.js';
1
+ import { ModelKey } from './chunk-QBYB2PJJ.js';
2
+ 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 } from './chunk-QBYB2PJJ.js';
3
3
  import './chunk-D7RVRRM2.js';
4
4
  export { PrismaAICallLogger, PrismaJobQueue, PrismaWorkflowPersistence, createPrismaAICallLogger, createPrismaJobQueue, createPrismaWorkflowPersistence } from './chunk-NYKMT46J.js';
5
5
  import './chunk-MUWP5SF2.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bratsos/workflow-engine",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Type-safe, distributed workflow engine for AI-orchestrated processes with suspend/resume, parallel execution, and cost tracking",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -76,12 +76,6 @@
76
76
  "README.md",
77
77
  "LICENSE"
78
78
  ],
79
- "scripts": {
80
- "typecheck": "tsc --noEmit",
81
- "build": "tsup",
82
- "test": "vitest run",
83
- "sync-models": "tsx src/cli/sync-models.ts"
84
- },
85
79
  "dependencies": {
86
80
  "@ai-sdk/google": "^3.0.1",
87
81
  "@openrouter/ai-sdk-provider": "^2.1.1",
@@ -118,5 +112,11 @@
118
112
  },
119
113
  "engines": {
120
114
  "node": ">=22.11.0"
115
+ },
116
+ "scripts": {
117
+ "typecheck": "tsc --noEmit",
118
+ "build": "tsup",
119
+ "test": "vitest run",
120
+ "sync-models": "tsx src/cli/sync-models.ts"
121
121
  }
122
- }
122
+ }
@@ -337,6 +337,8 @@ const ai = createAIHelper(
337
337
  const { text, cost } = await ai.generateText("gemini-2.5-flash", prompt);
338
338
  const { object } = await ai.generateObject("gemini-2.5-flash", prompt, schema);
339
339
  const { embedding } = await ai.embed("text-embedding-004", ["text1"], { dimensions: 768 });
340
+ // OpenRouter embedding models (OpenAI, Cohere, etc.)
341
+ const { embedding } = await ai.embed("openai/text-embedding-3-small", ["text1"]);
340
342
  ```
341
343
 
342
344
  ## Persistence Setup
@@ -248,16 +248,16 @@ const result = await ai.generateObject(
248
248
 
249
249
  ## embed
250
250
 
251
- Generate embeddings for text.
251
+ Generate embeddings for text. Supports Google and OpenRouter embedding providers.
252
252
 
253
253
  ```typescript
254
- // Single text
254
+ // Google embedding model (with Google-specific options)
255
255
  const result = await ai.embed(
256
256
  "text-embedding-004",
257
257
  "The quick brown fox",
258
258
  {
259
259
  dimensions: 768, // Output dimensions (default: 768)
260
- taskType: "RETRIEVAL_DOCUMENT", // or "RETRIEVAL_QUERY", "SEMANTIC_SIMILARITY"
260
+ taskType: "RETRIEVAL_DOCUMENT", // Google-only: "RETRIEVAL_QUERY", "SEMANTIC_SIMILARITY"
261
261
  }
262
262
  );
263
263
 
@@ -266,6 +266,12 @@ console.log(result.dimensions); // 768
266
266
  console.log(result.inputTokens);
267
267
  console.log(result.cost);
268
268
 
269
+ // OpenRouter embedding model (OpenAI, Cohere, etc.)
270
+ const result = await ai.embed(
271
+ "openai/text-embedding-3-small",
272
+ "The quick brown fox",
273
+ );
274
+
269
275
  // Multiple texts (batch)
270
276
  const result = await ai.embed("text-embedding-004", [
271
277
  "First document",
@@ -277,6 +283,10 @@ console.log(result.embeddings); // number[][] (3 embeddings)
277
283
  console.log(result.embedding); // First embedding (convenience)
278
284
  ```
279
285
 
286
+ > **Note:** `taskType` and `outputDimensionality` options only apply to Google embedding models.
287
+ > OpenRouter embedding models work without provider-specific options. The provider is determined
288
+ > by the `provider` field in the model's `ModelConfig`.
289
+
280
290
  ## streamText
281
291
 
282
292
  Stream text generation.
@@ -465,6 +475,26 @@ registerModels({
465
475
  const result = await ai.generateText("my-custom-model", prompt);
466
476
  ```
467
477
 
478
+ ### Register Custom Embedding Models
479
+
480
+ ```typescript
481
+ import { registerModels } from "@bratsos/workflow-engine";
482
+
483
+ registerModels({
484
+ "openai/text-embedding-3-small": {
485
+ id: "openai/text-embedding-3-small",
486
+ name: "OpenAI text-embedding-3-small",
487
+ provider: "openrouter",
488
+ inputCostPerMillion: 0.02,
489
+ outputCostPerMillion: 0,
490
+ isEmbeddingModel: true,
491
+ },
492
+ });
493
+
494
+ // Now usable
495
+ const { embedding } = await ai.embed("openai/text-embedding-3-small", "text");
496
+ ```
497
+
468
498
  ### Cost Calculation
469
499
 
470
500
  ```typescript