@workglow/ai 0.2.6 → 0.2.7

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.
Files changed (90) hide show
  1. package/dist/browser.js +211 -83
  2. package/dist/browser.js.map +9 -8
  3. package/dist/bun.js +211 -83
  4. package/dist/bun.js.map +9 -8
  5. package/dist/model/ModelRepository.d.ts +2 -0
  6. package/dist/model/ModelRepository.d.ts.map +1 -1
  7. package/dist/model/ModelSchema.d.ts +16 -0
  8. package/dist/model/ModelSchema.d.ts.map +1 -1
  9. package/dist/node.js +211 -83
  10. package/dist/node.js.map +9 -8
  11. package/dist/provider/AiProvider.d.ts +6 -0
  12. package/dist/provider/AiProvider.d.ts.map +1 -1
  13. package/dist/provider/AiProviderRegistry.d.ts +2 -0
  14. package/dist/provider/AiProviderRegistry.d.ts.map +1 -1
  15. package/dist/task/AgentTask.d.ts +16 -0
  16. package/dist/task/AgentTask.d.ts.map +1 -1
  17. package/dist/task/BackgroundRemovalTask.d.ts +8 -0
  18. package/dist/task/BackgroundRemovalTask.d.ts.map +1 -1
  19. package/dist/task/ChunkRetrievalTask.d.ts +8 -0
  20. package/dist/task/ChunkRetrievalTask.d.ts.map +1 -1
  21. package/dist/task/ContextBuilderTask.d.ts +8 -0
  22. package/dist/task/ContextBuilderTask.d.ts.map +1 -1
  23. package/dist/task/CountTokensTask.d.ts +8 -0
  24. package/dist/task/CountTokensTask.d.ts.map +1 -1
  25. package/dist/task/DocumentEnricherTask.d.ts +16 -0
  26. package/dist/task/DocumentEnricherTask.d.ts.map +1 -1
  27. package/dist/task/DownloadModelTask.d.ts +18 -0
  28. package/dist/task/DownloadModelTask.d.ts.map +1 -1
  29. package/dist/task/FaceDetectorTask.d.ts +8 -0
  30. package/dist/task/FaceDetectorTask.d.ts.map +1 -1
  31. package/dist/task/FaceLandmarkerTask.d.ts +8 -0
  32. package/dist/task/FaceLandmarkerTask.d.ts.map +1 -1
  33. package/dist/task/GestureRecognizerTask.d.ts +8 -0
  34. package/dist/task/GestureRecognizerTask.d.ts.map +1 -1
  35. package/dist/task/HandLandmarkerTask.d.ts +8 -0
  36. package/dist/task/HandLandmarkerTask.d.ts.map +1 -1
  37. package/dist/task/HierarchicalChunkerTask.d.ts +8 -0
  38. package/dist/task/HierarchicalChunkerTask.d.ts.map +1 -1
  39. package/dist/task/ImageClassificationTask.d.ts +8 -0
  40. package/dist/task/ImageClassificationTask.d.ts.map +1 -1
  41. package/dist/task/ImageEmbeddingTask.d.ts +8 -0
  42. package/dist/task/ImageEmbeddingTask.d.ts.map +1 -1
  43. package/dist/task/ImageSegmentationTask.d.ts +8 -0
  44. package/dist/task/ImageSegmentationTask.d.ts.map +1 -1
  45. package/dist/task/ImageToTextTask.d.ts +8 -0
  46. package/dist/task/ImageToTextTask.d.ts.map +1 -1
  47. package/dist/task/KbToDocumentsTask.d.ts +98 -0
  48. package/dist/task/KbToDocumentsTask.d.ts.map +1 -0
  49. package/dist/task/ModelInfoTask.d.ts +29 -1
  50. package/dist/task/ModelInfoTask.d.ts.map +1 -1
  51. package/dist/task/ObjectDetectionTask.d.ts +8 -0
  52. package/dist/task/ObjectDetectionTask.d.ts.map +1 -1
  53. package/dist/task/PoseLandmarkerTask.d.ts +8 -0
  54. package/dist/task/PoseLandmarkerTask.d.ts.map +1 -1
  55. package/dist/task/RerankerTask.d.ts +8 -0
  56. package/dist/task/RerankerTask.d.ts.map +1 -1
  57. package/dist/task/StructuredGenerationTask.d.ts +8 -0
  58. package/dist/task/StructuredGenerationTask.d.ts.map +1 -1
  59. package/dist/task/TextClassificationTask.d.ts +8 -0
  60. package/dist/task/TextClassificationTask.d.ts.map +1 -1
  61. package/dist/task/TextEmbeddingTask.d.ts +8 -0
  62. package/dist/task/TextEmbeddingTask.d.ts.map +1 -1
  63. package/dist/task/TextFillMaskTask.d.ts +8 -0
  64. package/dist/task/TextFillMaskTask.d.ts.map +1 -1
  65. package/dist/task/TextGenerationTask.d.ts +8 -0
  66. package/dist/task/TextGenerationTask.d.ts.map +1 -1
  67. package/dist/task/TextLanguageDetectionTask.d.ts +8 -0
  68. package/dist/task/TextLanguageDetectionTask.d.ts.map +1 -1
  69. package/dist/task/TextNamedEntityRecognitionTask.d.ts +8 -0
  70. package/dist/task/TextNamedEntityRecognitionTask.d.ts.map +1 -1
  71. package/dist/task/TextQuestionAnswerTask.d.ts +8 -0
  72. package/dist/task/TextQuestionAnswerTask.d.ts.map +1 -1
  73. package/dist/task/TextRewriterTask.d.ts +8 -0
  74. package/dist/task/TextRewriterTask.d.ts.map +1 -1
  75. package/dist/task/TextSummaryTask.d.ts +8 -0
  76. package/dist/task/TextSummaryTask.d.ts.map +1 -1
  77. package/dist/task/TextTranslationTask.d.ts +8 -0
  78. package/dist/task/TextTranslationTask.d.ts.map +1 -1
  79. package/dist/task/ToolCallingTask.d.ts +8 -0
  80. package/dist/task/ToolCallingTask.d.ts.map +1 -1
  81. package/dist/task/UnloadModelTask.d.ts +18 -0
  82. package/dist/task/UnloadModelTask.d.ts.map +1 -1
  83. package/dist/task/base/AiTask.d.ts.map +1 -1
  84. package/dist/task/base/AiTaskSchemas.d.ts +16 -0
  85. package/dist/task/base/AiTaskSchemas.d.ts.map +1 -1
  86. package/dist/task/index.d.ts +3 -1
  87. package/dist/task/index.d.ts.map +1 -1
  88. package/dist/worker.js +19 -3
  89. package/dist/worker.js.map +4 -4
  90. package/package.json +11 -11
package/dist/browser.js CHANGED
@@ -454,7 +454,15 @@ var ModelConfigSchema = {
454
454
  provider_config: {
455
455
  type: "object",
456
456
  properties: {
457
- credential_key: { type: "string", format: "credential", "x-ui-hidden": true }
457
+ credential_key: { type: "string", format: "credential", "x-ui-hidden": true },
458
+ native_dimensions: {
459
+ type: "integer",
460
+ description: "Native output vector dimensions for embedding models"
461
+ },
462
+ mrl: {
463
+ type: "boolean",
464
+ description: "Whether the model supports Matryoshka Representation Learning"
465
+ }
458
466
  },
459
467
  additionalProperties: true,
460
468
  default: {}
@@ -648,6 +656,7 @@ registerInputCompactor("model", async (value, _format, registry) => {
648
656
 
649
657
  // src/provider/AiProvider.ts
650
658
  import { globalServiceRegistry as globalServiceRegistry3, WORKER_MANAGER as WORKER_MANAGER2 } from "@workglow/util/worker";
659
+ var DEFAULT_AI_PROVIDER_WORKER_IDLE_TIMEOUT_MS = 15 * 60 * 1000;
651
660
  function resolveAiProviderGpuQueueConcurrency(concurrency) {
652
661
  if (concurrency === undefined) {
653
662
  return 1;
@@ -695,7 +704,13 @@ class AiProvider {
695
704
  const registry = getAiProviderRegistry();
696
705
  if (!isInline && options.worker) {
697
706
  const workerManager = globalServiceRegistry3.get(WORKER_MANAGER2);
698
- workerManager.registerWorker(this.name, options.worker);
707
+ if (typeof options.worker === "function") {
708
+ workerManager.registerWorker(this.name, options.worker, {
709
+ idleTimeoutMs: options.workerIdleTimeoutMs ?? DEFAULT_AI_PROVIDER_WORKER_IDLE_TIMEOUT_MS
710
+ });
711
+ } else {
712
+ workerManager.registerWorker(this.name, options.worker);
713
+ }
699
714
  for (const taskType of this.taskTypes) {
700
715
  registry.registerAsWorkerRunFn(this.name, taskType);
701
716
  registry.registerAsWorkerStreamFn(this.name, taskType);
@@ -1049,6 +1064,18 @@ class AiTask extends Task {
1049
1064
  const jobInput = await this.getJobInput(input);
1050
1065
  const strategy = getAiProviderRegistry().getStrategy(model);
1051
1066
  const output = await strategy.execute(jobInput, executeContext, this.runConfig.runnerId);
1067
+ if (executeContext.resourceScope) {
1068
+ const registry = getAiProviderRegistry();
1069
+ const provider = registry.getProvider(model.provider);
1070
+ const unloadFn = provider?.getRunFn("UnloadModelTask");
1071
+ if (unloadFn) {
1072
+ const modelPath = model.provider_config?.model_path ?? model.model;
1073
+ const resourceKey = `ai:${model.provider}:${modelPath}`;
1074
+ executeContext.resourceScope.register(resourceKey, async () => {
1075
+ await unloadFn({ model }, model, () => {}, AbortSignal.timeout(30000));
1076
+ });
1077
+ }
1078
+ }
1052
1079
  return output;
1053
1080
  }
1054
1081
  async getJobInput(input) {
@@ -4596,8 +4623,97 @@ var hierarchyJoin = (input, config) => {
4596
4623
  };
4597
4624
  Workflow22.prototype.hierarchyJoin = CreateWorkflow22(HierarchyJoinTask);
4598
4625
 
4626
+ // src/task/KbToDocumentsTask.ts
4627
+ import { TypeKnowledgeBase as TypeKnowledgeBase7 } from "@workglow/knowledge-base";
4628
+ import { CreateWorkflow as CreateWorkflow23, Task as Task13, Workflow as Workflow23 } from "@workglow/task-graph";
4629
+ var inputSchema11 = {
4630
+ type: "object",
4631
+ properties: {
4632
+ knowledgeBase: TypeKnowledgeBase7({
4633
+ title: "Knowledge Base",
4634
+ description: "The knowledge base instance to list documents from"
4635
+ }),
4636
+ onlyStale: {
4637
+ type: "boolean",
4638
+ title: "Only Stale",
4639
+ description: "If true, only return documents that have no chunks (need embedding)",
4640
+ default: true
4641
+ }
4642
+ },
4643
+ required: ["knowledgeBase"],
4644
+ additionalProperties: false
4645
+ };
4646
+ var outputSchema11 = {
4647
+ type: "object",
4648
+ properties: {
4649
+ doc_id: {
4650
+ type: "array",
4651
+ items: { type: "string" },
4652
+ title: "Document IDs",
4653
+ description: "Array of document IDs"
4654
+ },
4655
+ documentTree: {
4656
+ type: "array",
4657
+ items: { type: "object", additionalProperties: true },
4658
+ title: "Document Trees",
4659
+ description: "Array of document root nodes (parallel to doc_id)"
4660
+ },
4661
+ title: {
4662
+ type: "array",
4663
+ items: { type: "string" },
4664
+ title: "Titles",
4665
+ description: "Array of document titles (parallel to doc_id)"
4666
+ }
4667
+ },
4668
+ required: ["doc_id", "documentTree", "title"],
4669
+ additionalProperties: false
4670
+ };
4671
+
4672
+ class KbToDocumentsTask extends Task13 {
4673
+ static type = "KbToDocumentsTask";
4674
+ static category = "Vector Store";
4675
+ static title = "Knowledge Base to Documents";
4676
+ static description = "List documents from a knowledge base, optionally filtering to only those that need embedding";
4677
+ static cacheable = false;
4678
+ static inputSchema() {
4679
+ return inputSchema11;
4680
+ }
4681
+ static outputSchema() {
4682
+ return outputSchema11;
4683
+ }
4684
+ async execute(input, context) {
4685
+ const { knowledgeBase, onlyStale = true } = input;
4686
+ const kb = knowledgeBase;
4687
+ await context.updateProgress(1, "Listing documents");
4688
+ const allDocIds = await kb.listDocuments();
4689
+ const doc_id = [];
4690
+ const documentTree = [];
4691
+ const title = [];
4692
+ for (const id of allDocIds) {
4693
+ if (onlyStale) {
4694
+ const chunks = await kb.getChunksForDocument(id);
4695
+ if (chunks.length > 0) {
4696
+ continue;
4697
+ }
4698
+ }
4699
+ const doc = await kb.getDocument(id);
4700
+ if (!doc) {
4701
+ continue;
4702
+ }
4703
+ doc_id.push(id);
4704
+ documentTree.push(doc.root);
4705
+ title.push(doc.metadata.title);
4706
+ }
4707
+ return { doc_id, documentTree, title };
4708
+ }
4709
+ }
4710
+ var kbToDocuments = (input, config) => {
4711
+ return new KbToDocumentsTask(config).run(input);
4712
+ };
4713
+ Workflow23.prototype.kbToDocuments = CreateWorkflow23(KbToDocumentsTask);
4714
+
4599
4715
  // src/task/ImageClassificationTask.ts
4600
- import { CreateWorkflow as CreateWorkflow23, Workflow as Workflow23 } from "@workglow/task-graph";
4716
+ import { CreateWorkflow as CreateWorkflow24, Workflow as Workflow24 } from "@workglow/task-graph";
4601
4717
  var modelSchema15 = TypeModel("model:ImageClassificationTask");
4602
4718
  var ImageClassificationInputSchema = {
4603
4719
  type: "object",
@@ -4657,10 +4773,10 @@ class ImageClassificationTask extends AiVisionTask {
4657
4773
  var imageClassification = (input, config) => {
4658
4774
  return new ImageClassificationTask(config).run(input);
4659
4775
  };
4660
- Workflow23.prototype.imageClassification = CreateWorkflow23(ImageClassificationTask);
4776
+ Workflow24.prototype.imageClassification = CreateWorkflow24(ImageClassificationTask);
4661
4777
 
4662
4778
  // src/task/ImageEmbeddingTask.ts
4663
- import { CreateWorkflow as CreateWorkflow24, Workflow as Workflow24 } from "@workglow/task-graph";
4779
+ import { CreateWorkflow as CreateWorkflow25, Workflow as Workflow25 } from "@workglow/task-graph";
4664
4780
  import {
4665
4781
  TypedArraySchema as TypedArraySchema7
4666
4782
  } from "@workglow/util/schema";
@@ -4701,10 +4817,10 @@ class ImageEmbeddingTask extends AiVisionTask {
4701
4817
  var imageEmbedding = (input, config) => {
4702
4818
  return new ImageEmbeddingTask(config).run(input);
4703
4819
  };
4704
- Workflow24.prototype.imageEmbedding = CreateWorkflow24(ImageEmbeddingTask);
4820
+ Workflow25.prototype.imageEmbedding = CreateWorkflow25(ImageEmbeddingTask);
4705
4821
 
4706
4822
  // src/task/ImageSegmentationTask.ts
4707
- import { CreateWorkflow as CreateWorkflow25, Workflow as Workflow25 } from "@workglow/task-graph";
4823
+ import { CreateWorkflow as CreateWorkflow26, Workflow as Workflow26 } from "@workglow/task-graph";
4708
4824
  var modelSchema17 = TypeModel("model:ImageSegmentationTask");
4709
4825
  var ImageSegmentationInputSchema = {
4710
4826
  type: "object",
@@ -4789,10 +4905,10 @@ class ImageSegmentationTask extends AiVisionTask {
4789
4905
  var imageSegmentation = (input, config) => {
4790
4906
  return new ImageSegmentationTask(config).run(input);
4791
4907
  };
4792
- Workflow25.prototype.imageSegmentation = CreateWorkflow25(ImageSegmentationTask);
4908
+ Workflow26.prototype.imageSegmentation = CreateWorkflow26(ImageSegmentationTask);
4793
4909
 
4794
4910
  // src/task/ImageToTextTask.ts
4795
- import { CreateWorkflow as CreateWorkflow26, Workflow as Workflow26 } from "@workglow/task-graph";
4911
+ import { CreateWorkflow as CreateWorkflow27, Workflow as Workflow27 } from "@workglow/task-graph";
4796
4912
  var modelSchema18 = TypeModel("model:ImageToTextTask");
4797
4913
  var generatedTextSchema = {
4798
4914
  type: "string",
@@ -4844,10 +4960,10 @@ class ImageToTextTask extends AiVisionTask {
4844
4960
  var imageToText = (input, config) => {
4845
4961
  return new ImageToTextTask(config).run(input);
4846
4962
  };
4847
- Workflow26.prototype.imageToText = CreateWorkflow26(ImageToTextTask);
4963
+ Workflow27.prototype.imageToText = CreateWorkflow27(ImageToTextTask);
4848
4964
 
4849
4965
  // src/task/ModelInfoTask.ts
4850
- import { CreateWorkflow as CreateWorkflow27, Workflow as Workflow27 } from "@workglow/task-graph";
4966
+ import { CreateWorkflow as CreateWorkflow28, Workflow as Workflow28 } from "@workglow/task-graph";
4851
4967
  var modelSchema19 = TypeModel("model");
4852
4968
  var ModelInfoInputSchema = {
4853
4969
  type: "object",
@@ -4855,7 +4971,7 @@ var ModelInfoInputSchema = {
4855
4971
  model: modelSchema19,
4856
4972
  detail: {
4857
4973
  type: "string",
4858
- enum: ["cached_status", "files", "files_with_metadata"],
4974
+ enum: ["cached_status", "files", "files_with_metadata", "dimensions"],
4859
4975
  default: "files_with_metadata"
4860
4976
  }
4861
4977
  },
@@ -4877,6 +4993,14 @@ var ModelInfoOutputSchema = {
4877
4993
  type: "array",
4878
4994
  items: { type: "string" },
4879
4995
  description: "Available quantization variants (e.g. fp32, fp16, q8). Only present for models with quantization options."
4996
+ },
4997
+ native_dimensions: {
4998
+ type: "integer",
4999
+ description: "Native output vector dimensions. Only present when detail is 'dimensions' and the provider can determine them."
5000
+ },
5001
+ mrl: {
5002
+ type: "boolean",
5003
+ description: "Whether the model supports Matryoshka Representation Learning. Only present when detail is 'dimensions'."
4880
5004
  }
4881
5005
  },
4882
5006
  required: [
@@ -4915,10 +5039,10 @@ class ModelInfoTask extends AiTask {
4915
5039
  var modelInfo = (input, config) => {
4916
5040
  return new ModelInfoTask(config).run(input);
4917
5041
  };
4918
- Workflow27.prototype.modelInfo = CreateWorkflow27(ModelInfoTask);
5042
+ Workflow28.prototype.modelInfo = CreateWorkflow28(ModelInfoTask);
4919
5043
 
4920
5044
  // src/task/ModelSearchTask.ts
4921
- import { CreateWorkflow as CreateWorkflow28, Task as Task13, Workflow as Workflow28 } from "@workglow/task-graph";
5045
+ import { CreateWorkflow as CreateWorkflow29, Task as Task14, Workflow as Workflow29 } from "@workglow/task-graph";
4922
5046
  var ModelSearchInputSchema = {
4923
5047
  type: "object",
4924
5048
  properties: {
@@ -4983,7 +5107,7 @@ var ModelSearchOutputSchema = {
4983
5107
  additionalProperties: false
4984
5108
  };
4985
5109
 
4986
- class ModelSearchTask extends Task13 {
5110
+ class ModelSearchTask extends Task14 {
4987
5111
  static type = "ModelSearchTask";
4988
5112
  static category = "AI Model";
4989
5113
  static title = "Model Search";
@@ -5009,10 +5133,10 @@ class ModelSearchTask extends Task13 {
5009
5133
  var modelSearch = (input, config) => {
5010
5134
  return new ModelSearchTask(config).run(input);
5011
5135
  };
5012
- Workflow28.prototype.modelSearch = CreateWorkflow28(ModelSearchTask);
5136
+ Workflow29.prototype.modelSearch = CreateWorkflow29(ModelSearchTask);
5013
5137
 
5014
5138
  // src/task/ObjectDetectionTask.ts
5015
- import { CreateWorkflow as CreateWorkflow29, Workflow as Workflow29 } from "@workglow/task-graph";
5139
+ import { CreateWorkflow as CreateWorkflow30, Workflow as Workflow30 } from "@workglow/task-graph";
5016
5140
  var modelSchema20 = TypeModel("model:ObjectDetectionTask");
5017
5141
  var detectionSchema = {
5018
5142
  type: "object",
@@ -5092,10 +5216,10 @@ class ObjectDetectionTask extends AiVisionTask {
5092
5216
  var objectDetection = (input, config) => {
5093
5217
  return new ObjectDetectionTask(config).run(input);
5094
5218
  };
5095
- Workflow29.prototype.objectDetection = CreateWorkflow29(ObjectDetectionTask);
5219
+ Workflow30.prototype.objectDetection = CreateWorkflow30(ObjectDetectionTask);
5096
5220
 
5097
5221
  // src/task/PoseLandmarkerTask.ts
5098
- import { CreateWorkflow as CreateWorkflow30, Workflow as Workflow30 } from "@workglow/task-graph";
5222
+ import { CreateWorkflow as CreateWorkflow31, Workflow as Workflow31 } from "@workglow/task-graph";
5099
5223
  var modelSchema21 = TypeModel("model:PoseLandmarkerTask");
5100
5224
  var TypePoseLandmark = {
5101
5225
  type: "object",
@@ -5254,17 +5378,17 @@ class PoseLandmarkerTask extends AiVisionTask {
5254
5378
  var poseLandmarker = (input, config) => {
5255
5379
  return new PoseLandmarkerTask(config).run(input);
5256
5380
  };
5257
- Workflow30.prototype.poseLandmarker = CreateWorkflow30(PoseLandmarkerTask);
5381
+ Workflow31.prototype.poseLandmarker = CreateWorkflow31(PoseLandmarkerTask);
5258
5382
 
5259
5383
  // src/task/QueryExpanderTask.ts
5260
- import { CreateWorkflow as CreateWorkflow31, Task as Task14, Workflow as Workflow31 } from "@workglow/task-graph";
5384
+ import { CreateWorkflow as CreateWorkflow32, Task as Task15, Workflow as Workflow32 } from "@workglow/task-graph";
5261
5385
  var QueryExpansionMethod = {
5262
5386
  MULTI_QUERY: "multi-query",
5263
5387
  HYDE: "hyde",
5264
5388
  SYNONYMS: "synonyms",
5265
5389
  PARAPHRASE: "paraphrase"
5266
5390
  };
5267
- var inputSchema11 = {
5391
+ var inputSchema12 = {
5268
5392
  type: "object",
5269
5393
  properties: {
5270
5394
  query: {
@@ -5296,7 +5420,7 @@ var inputSchema11 = {
5296
5420
  required: ["query"],
5297
5421
  additionalProperties: false
5298
5422
  };
5299
- var outputSchema11 = {
5423
+ var outputSchema12 = {
5300
5424
  type: "object",
5301
5425
  properties: {
5302
5426
  query: {
@@ -5325,17 +5449,17 @@ var outputSchema11 = {
5325
5449
  additionalProperties: false
5326
5450
  };
5327
5451
 
5328
- class QueryExpanderTask extends Task14 {
5452
+ class QueryExpanderTask extends Task15 {
5329
5453
  static type = "QueryExpanderTask";
5330
5454
  static category = "RAG";
5331
5455
  static title = "Query Expander";
5332
5456
  static description = "Expand queries to improve retrieval coverage";
5333
5457
  static cacheable = true;
5334
5458
  static inputSchema() {
5335
- return inputSchema11;
5459
+ return inputSchema12;
5336
5460
  }
5337
5461
  static outputSchema() {
5338
- return outputSchema11;
5462
+ return outputSchema12;
5339
5463
  }
5340
5464
  async execute(input, context) {
5341
5465
  const { query, method = QueryExpansionMethod.MULTI_QUERY, numVariations = 3 } = input;
@@ -5467,13 +5591,13 @@ class QueryExpanderTask extends Task14 {
5467
5591
  var queryExpander = (input, config) => {
5468
5592
  return new QueryExpanderTask(config).run(input);
5469
5593
  };
5470
- Workflow31.prototype.queryExpander = CreateWorkflow31(QueryExpanderTask);
5594
+ Workflow32.prototype.queryExpander = CreateWorkflow32(QueryExpanderTask);
5471
5595
 
5472
5596
  // src/task/RerankerTask.ts
5473
- import { CreateWorkflow as CreateWorkflow33, Task as Task15, Workflow as Workflow33 } from "@workglow/task-graph";
5597
+ import { CreateWorkflow as CreateWorkflow34, Task as Task16, Workflow as Workflow34 } from "@workglow/task-graph";
5474
5598
 
5475
5599
  // src/task/TextClassificationTask.ts
5476
- import { CreateWorkflow as CreateWorkflow32, Workflow as Workflow32 } from "@workglow/task-graph";
5600
+ import { CreateWorkflow as CreateWorkflow33, Workflow as Workflow33 } from "@workglow/task-graph";
5477
5601
  var modelSchema22 = TypeModel("model:TextClassificationTask");
5478
5602
  var TextClassificationInputSchema = {
5479
5603
  type: "object",
@@ -5551,10 +5675,10 @@ class TextClassificationTask extends AiTask {
5551
5675
  var textClassification = (input, config) => {
5552
5676
  return new TextClassificationTask(config).run(input);
5553
5677
  };
5554
- Workflow32.prototype.textClassification = CreateWorkflow32(TextClassificationTask);
5678
+ Workflow33.prototype.textClassification = CreateWorkflow33(TextClassificationTask);
5555
5679
 
5556
5680
  // src/task/RerankerTask.ts
5557
- var inputSchema12 = {
5681
+ var inputSchema13 = {
5558
5682
  type: "object",
5559
5683
  properties: {
5560
5684
  query: {
@@ -5605,7 +5729,7 @@ var inputSchema12 = {
5605
5729
  required: ["query", "chunks"],
5606
5730
  additionalProperties: false
5607
5731
  };
5608
- var outputSchema12 = {
5732
+ var outputSchema13 = {
5609
5733
  type: "object",
5610
5734
  properties: {
5611
5735
  chunks: {
@@ -5646,17 +5770,17 @@ var outputSchema12 = {
5646
5770
  additionalProperties: false
5647
5771
  };
5648
5772
 
5649
- class RerankerTask extends Task15 {
5773
+ class RerankerTask extends Task16 {
5650
5774
  static type = "RerankerTask";
5651
5775
  static category = "RAG";
5652
5776
  static title = "Reranker";
5653
5777
  static description = "Rerank retrieved chunks to improve relevance";
5654
5778
  static cacheable = true;
5655
5779
  static inputSchema() {
5656
- return inputSchema12;
5780
+ return inputSchema13;
5657
5781
  }
5658
5782
  static outputSchema() {
5659
- return outputSchema12;
5783
+ return outputSchema13;
5660
5784
  }
5661
5785
  async execute(input, context) {
5662
5786
  const { query, chunks, scores = [], metadata = [], topK, method = "simple", model } = input;
@@ -5774,13 +5898,13 @@ class RerankerTask extends Task15 {
5774
5898
  var reranker = (input, config) => {
5775
5899
  return new RerankerTask(config).run(input);
5776
5900
  };
5777
- Workflow33.prototype.reranker = CreateWorkflow33(RerankerTask);
5901
+ Workflow34.prototype.reranker = CreateWorkflow34(RerankerTask);
5778
5902
 
5779
5903
  // src/task/StructuralParserTask.ts
5780
5904
  import { StructuralParser } from "@workglow/knowledge-base";
5781
- import { CreateWorkflow as CreateWorkflow34, Task as Task16, Workflow as Workflow34 } from "@workglow/task-graph";
5905
+ import { CreateWorkflow as CreateWorkflow35, Task as Task17, Workflow as Workflow35 } from "@workglow/task-graph";
5782
5906
  import { uuid4 as uuid42 } from "@workglow/util";
5783
- var inputSchema13 = {
5907
+ var inputSchema14 = {
5784
5908
  type: "object",
5785
5909
  properties: {
5786
5910
  text: {
@@ -5814,7 +5938,7 @@ var inputSchema13 = {
5814
5938
  required: ["text", "title"],
5815
5939
  additionalProperties: false
5816
5940
  };
5817
- var outputSchema13 = {
5941
+ var outputSchema14 = {
5818
5942
  type: "object",
5819
5943
  properties: {
5820
5944
  doc_id: {
@@ -5838,17 +5962,17 @@ var outputSchema13 = {
5838
5962
  additionalProperties: false
5839
5963
  };
5840
5964
 
5841
- class StructuralParserTask extends Task16 {
5965
+ class StructuralParserTask extends Task17 {
5842
5966
  static type = "StructuralParserTask";
5843
5967
  static category = "Document";
5844
5968
  static title = "Structural Parser";
5845
5969
  static description = "Parse documents into hierarchical tree structure";
5846
5970
  static cacheable = true;
5847
5971
  static inputSchema() {
5848
- return inputSchema13;
5972
+ return inputSchema14;
5849
5973
  }
5850
5974
  static outputSchema() {
5851
- return outputSchema13;
5975
+ return outputSchema14;
5852
5976
  }
5853
5977
  async execute(input, context) {
5854
5978
  const { text, title, format = "auto", sourceUri, doc_id: providedDocId } = input;
@@ -5881,10 +6005,10 @@ class StructuralParserTask extends Task16 {
5881
6005
  var structuralParser = (input, config) => {
5882
6006
  return new StructuralParserTask(config).run(input);
5883
6007
  };
5884
- Workflow34.prototype.structuralParser = CreateWorkflow34(StructuralParserTask);
6008
+ Workflow35.prototype.structuralParser = CreateWorkflow35(StructuralParserTask);
5885
6009
 
5886
6010
  // src/task/StructuredGenerationTask.ts
5887
- import { CreateWorkflow as CreateWorkflow35, Workflow as Workflow35 } from "@workglow/task-graph";
6011
+ import { CreateWorkflow as CreateWorkflow36, Workflow as Workflow36 } from "@workglow/task-graph";
5888
6012
  var modelSchema23 = TypeModel("model:StructuredGenerationTask");
5889
6013
  var StructuredGenerationInputSchema = {
5890
6014
  type: "object",
@@ -5952,17 +6076,17 @@ class StructuredGenerationTask extends StreamingAiTask {
5952
6076
  var structuredGeneration = (input, config) => {
5953
6077
  return new StructuredGenerationTask(config).run(input);
5954
6078
  };
5955
- Workflow35.prototype.structuredGeneration = CreateWorkflow35(StructuredGenerationTask);
6079
+ Workflow36.prototype.structuredGeneration = CreateWorkflow36(StructuredGenerationTask);
5956
6080
 
5957
6081
  // src/task/TextChunkerTask.ts
5958
- import { CreateWorkflow as CreateWorkflow36, Task as Task17, Workflow as Workflow36 } from "@workglow/task-graph";
6082
+ import { CreateWorkflow as CreateWorkflow37, Task as Task18, Workflow as Workflow37 } from "@workglow/task-graph";
5959
6083
  var ChunkingStrategy = {
5960
6084
  FIXED: "fixed",
5961
6085
  SENTENCE: "sentence",
5962
6086
  PARAGRAPH: "paragraph",
5963
6087
  SEMANTIC: "semantic"
5964
6088
  };
5965
- var inputSchema14 = {
6089
+ var inputSchema15 = {
5966
6090
  type: "object",
5967
6091
  properties: {
5968
6092
  text: {
@@ -5995,7 +6119,7 @@ var inputSchema14 = {
5995
6119
  required: ["text"],
5996
6120
  additionalProperties: false
5997
6121
  };
5998
- var outputSchema14 = {
6122
+ var outputSchema15 = {
5999
6123
  type: "object",
6000
6124
  properties: {
6001
6125
  chunks: {
@@ -6024,17 +6148,17 @@ var outputSchema14 = {
6024
6148
  additionalProperties: false
6025
6149
  };
6026
6150
 
6027
- class TextChunkerTask extends Task17 {
6151
+ class TextChunkerTask extends Task18 {
6028
6152
  static type = "TextChunkerTask";
6029
6153
  static category = "Document";
6030
6154
  static title = "Text Chunker";
6031
6155
  static description = "Splits text into chunks using various strategies (fixed, sentence, paragraph)";
6032
6156
  static cacheable = true;
6033
6157
  static inputSchema() {
6034
- return inputSchema14;
6158
+ return inputSchema15;
6035
6159
  }
6036
6160
  static outputSchema() {
6037
- return outputSchema14;
6161
+ return outputSchema15;
6038
6162
  }
6039
6163
  async execute(input, context) {
6040
6164
  const { text, chunkSize = 512, chunkOverlap = 50, strategy = ChunkingStrategy.FIXED } = input;
@@ -6204,10 +6328,10 @@ class TextChunkerTask extends Task17 {
6204
6328
  var textChunker = (input, config) => {
6205
6329
  return new TextChunkerTask(config).run(input);
6206
6330
  };
6207
- Workflow36.prototype.textChunker = CreateWorkflow36(TextChunkerTask);
6331
+ Workflow37.prototype.textChunker = CreateWorkflow37(TextChunkerTask);
6208
6332
 
6209
6333
  // src/task/TextFillMaskTask.ts
6210
- import { CreateWorkflow as CreateWorkflow37, Workflow as Workflow37 } from "@workglow/task-graph";
6334
+ import { CreateWorkflow as CreateWorkflow38, Workflow as Workflow38 } from "@workglow/task-graph";
6211
6335
  var modelSchema24 = TypeModel("model:TextFillMaskTask");
6212
6336
  var TextFillMaskInputSchema = {
6213
6337
  type: "object",
@@ -6272,10 +6396,10 @@ class TextFillMaskTask extends AiTask {
6272
6396
  var textFillMask = (input, config) => {
6273
6397
  return new TextFillMaskTask(config).run(input);
6274
6398
  };
6275
- Workflow37.prototype.textFillMask = CreateWorkflow37(TextFillMaskTask);
6399
+ Workflow38.prototype.textFillMask = CreateWorkflow38(TextFillMaskTask);
6276
6400
 
6277
6401
  // src/task/TextGenerationTask.ts
6278
- import { CreateWorkflow as CreateWorkflow38, Workflow as Workflow38 } from "@workglow/task-graph";
6402
+ import { CreateWorkflow as CreateWorkflow39, Workflow as Workflow39 } from "@workglow/task-graph";
6279
6403
  var generatedTextSchema2 = {
6280
6404
  type: "string",
6281
6405
  title: "Text",
@@ -6360,10 +6484,10 @@ class TextGenerationTask extends StreamingAiTask {
6360
6484
  var textGeneration = (input, config) => {
6361
6485
  return new TextGenerationTask(config).run(input);
6362
6486
  };
6363
- Workflow38.prototype.textGeneration = CreateWorkflow38(TextGenerationTask);
6487
+ Workflow39.prototype.textGeneration = CreateWorkflow39(TextGenerationTask);
6364
6488
 
6365
6489
  // src/task/TextLanguageDetectionTask.ts
6366
- import { CreateWorkflow as CreateWorkflow39, Workflow as Workflow39 } from "@workglow/task-graph";
6490
+ import { CreateWorkflow as CreateWorkflow40, Workflow as Workflow40 } from "@workglow/task-graph";
6367
6491
  var modelSchema26 = TypeModel("model:TextLanguageDetectionTask");
6368
6492
  var TextLanguageDetectionInputSchema = {
6369
6493
  type: "object",
@@ -6431,10 +6555,10 @@ class TextLanguageDetectionTask extends AiTask {
6431
6555
  var textLanguageDetection = (input, config) => {
6432
6556
  return new TextLanguageDetectionTask(config).run(input);
6433
6557
  };
6434
- Workflow39.prototype.textLanguageDetection = CreateWorkflow39(TextLanguageDetectionTask);
6558
+ Workflow40.prototype.textLanguageDetection = CreateWorkflow40(TextLanguageDetectionTask);
6435
6559
 
6436
6560
  // src/task/TextQuestionAnswerTask.ts
6437
- import { CreateWorkflow as CreateWorkflow40, Workflow as Workflow40 } from "@workglow/task-graph";
6561
+ import { CreateWorkflow as CreateWorkflow41, Workflow as Workflow41 } from "@workglow/task-graph";
6438
6562
  var contextSchema = {
6439
6563
  type: "string",
6440
6564
  title: "Context",
@@ -6486,10 +6610,10 @@ class TextQuestionAnswerTask extends StreamingAiTask {
6486
6610
  var textQuestionAnswer = (input, config) => {
6487
6611
  return new TextQuestionAnswerTask(config).run(input);
6488
6612
  };
6489
- Workflow40.prototype.textQuestionAnswer = CreateWorkflow40(TextQuestionAnswerTask);
6613
+ Workflow41.prototype.textQuestionAnswer = CreateWorkflow41(TextQuestionAnswerTask);
6490
6614
 
6491
6615
  // src/task/TextRewriterTask.ts
6492
- import { CreateWorkflow as CreateWorkflow41, Workflow as Workflow41 } from "@workglow/task-graph";
6616
+ import { CreateWorkflow as CreateWorkflow42, Workflow as Workflow42 } from "@workglow/task-graph";
6493
6617
  var modelSchema28 = TypeModel("model:TextRewriterTask");
6494
6618
  var TextRewriterInputSchema = {
6495
6619
  type: "object",
@@ -6538,10 +6662,10 @@ class TextRewriterTask extends StreamingAiTask {
6538
6662
  var textRewriter = (input, config) => {
6539
6663
  return new TextRewriterTask(config).run(input);
6540
6664
  };
6541
- Workflow41.prototype.textRewriter = CreateWorkflow41(TextRewriterTask);
6665
+ Workflow42.prototype.textRewriter = CreateWorkflow42(TextRewriterTask);
6542
6666
 
6543
6667
  // src/task/TextTranslationTask.ts
6544
- import { CreateWorkflow as CreateWorkflow42, Workflow as Workflow42 } from "@workglow/task-graph";
6668
+ import { CreateWorkflow as CreateWorkflow43, Workflow as Workflow43 } from "@workglow/task-graph";
6545
6669
  var modelSchema29 = TypeModel("model:TextTranslationTask");
6546
6670
  var translationTextSchema = {
6547
6671
  type: "string",
@@ -6604,16 +6728,16 @@ class TextTranslationTask extends StreamingAiTask {
6604
6728
  var textTranslation = (input, config) => {
6605
6729
  return new TextTranslationTask(config).run(input);
6606
6730
  };
6607
- Workflow42.prototype.textTranslation = CreateWorkflow42(TextTranslationTask);
6731
+ Workflow43.prototype.textTranslation = CreateWorkflow43(TextTranslationTask);
6608
6732
 
6609
6733
  // src/task/TopicSegmenterTask.ts
6610
- import { CreateWorkflow as CreateWorkflow43, Task as Task18, Workflow as Workflow43 } from "@workglow/task-graph";
6734
+ import { CreateWorkflow as CreateWorkflow44, Task as Task19, Workflow as Workflow44 } from "@workglow/task-graph";
6611
6735
  var SegmentationMethod = {
6612
6736
  HEURISTIC: "heuristic",
6613
6737
  EMBEDDING_SIMILARITY: "embedding-similarity",
6614
6738
  HYBRID: "hybrid"
6615
6739
  };
6616
- var inputSchema15 = {
6740
+ var inputSchema16 = {
6617
6741
  type: "object",
6618
6742
  properties: {
6619
6743
  text: {
@@ -6654,7 +6778,7 @@ var inputSchema15 = {
6654
6778
  required: ["text"],
6655
6779
  additionalProperties: false
6656
6780
  };
6657
- var outputSchema15 = {
6781
+ var outputSchema16 = {
6658
6782
  type: "object",
6659
6783
  properties: {
6660
6784
  segments: {
@@ -6682,7 +6806,7 @@ var outputSchema15 = {
6682
6806
  additionalProperties: false
6683
6807
  };
6684
6808
 
6685
- class TopicSegmenterTask extends Task18 {
6809
+ class TopicSegmenterTask extends Task19 {
6686
6810
  static type = "TopicSegmenterTask";
6687
6811
  static category = "Document";
6688
6812
  static title = "Topic Segmenter";
@@ -6690,10 +6814,10 @@ class TopicSegmenterTask extends Task18 {
6690
6814
  static cacheable = true;
6691
6815
  static EMBEDDING_DIMENSIONS = 256;
6692
6816
  static inputSchema() {
6693
- return inputSchema15;
6817
+ return inputSchema16;
6694
6818
  }
6695
6819
  static outputSchema() {
6696
- return outputSchema15;
6820
+ return outputSchema16;
6697
6821
  }
6698
6822
  async execute(input, context) {
6699
6823
  const {
@@ -6887,10 +7011,10 @@ class TopicSegmenterTask extends Task18 {
6887
7011
  var topicSegmenter = (input, config) => {
6888
7012
  return new TopicSegmenterTask(config).run(input);
6889
7013
  };
6890
- Workflow43.prototype.topicSegmenter = CreateWorkflow43(TopicSegmenterTask);
7014
+ Workflow44.prototype.topicSegmenter = CreateWorkflow44(TopicSegmenterTask);
6891
7015
 
6892
7016
  // src/task/UnloadModelTask.ts
6893
- import { CreateWorkflow as CreateWorkflow44, Workflow as Workflow44 } from "@workglow/task-graph";
7017
+ import { CreateWorkflow as CreateWorkflow45, Workflow as Workflow45 } from "@workglow/task-graph";
6894
7018
  var modelSchema30 = TypeModel("model");
6895
7019
  var UnloadModelInputSchema = {
6896
7020
  type: "object",
@@ -6925,16 +7049,16 @@ class UnloadModelTask extends AiTask {
6925
7049
  var unloadModel = (input, config) => {
6926
7050
  return new UnloadModelTask(config).run(input);
6927
7051
  };
6928
- Workflow44.prototype.unloadModel = CreateWorkflow44(UnloadModelTask);
7052
+ Workflow45.prototype.unloadModel = CreateWorkflow45(UnloadModelTask);
6929
7053
 
6930
7054
  // src/task/VectorQuantizeTask.ts
6931
- import { CreateWorkflow as CreateWorkflow45, Task as Task19, Workflow as Workflow45 } from "@workglow/task-graph";
7055
+ import { CreateWorkflow as CreateWorkflow46, Task as Task20, Workflow as Workflow46 } from "@workglow/task-graph";
6932
7056
  import {
6933
7057
  normalizeNumberArray,
6934
7058
  TensorType,
6935
7059
  TypedArraySchema as TypedArraySchema8
6936
7060
  } from "@workglow/util/schema";
6937
- var inputSchema16 = {
7061
+ var inputSchema17 = {
6938
7062
  type: "object",
6939
7063
  properties: {
6940
7064
  vector: {
@@ -6971,7 +7095,7 @@ var inputSchema16 = {
6971
7095
  required: ["vector", "targetType"],
6972
7096
  additionalProperties: false
6973
7097
  };
6974
- var outputSchema16 = {
7098
+ var outputSchema17 = {
6975
7099
  type: "object",
6976
7100
  properties: {
6977
7101
  vector: {
@@ -7008,17 +7132,17 @@ var outputSchema16 = {
7008
7132
  additionalProperties: false
7009
7133
  };
7010
7134
 
7011
- class VectorQuantizeTask extends Task19 {
7135
+ class VectorQuantizeTask extends Task20 {
7012
7136
  static type = "VectorQuantizeTask";
7013
7137
  static category = "Vector";
7014
7138
  static title = "Quantize";
7015
7139
  static description = "Quantize vectors to reduce storage and improve performance";
7016
7140
  static cacheable = true;
7017
7141
  static inputSchema() {
7018
- return inputSchema16;
7142
+ return inputSchema17;
7019
7143
  }
7020
7144
  static outputSchema() {
7021
- return outputSchema16;
7145
+ return outputSchema17;
7022
7146
  }
7023
7147
  async executeReactive(input) {
7024
7148
  const { vector, targetType, normalize = true } = input;
@@ -7108,10 +7232,10 @@ class VectorQuantizeTask extends Task19 {
7108
7232
  var vectorQuantize = (input, config) => {
7109
7233
  return new VectorQuantizeTask(config).run(input);
7110
7234
  };
7111
- Workflow45.prototype.vectorQuantize = CreateWorkflow45(VectorQuantizeTask);
7235
+ Workflow46.prototype.vectorQuantize = CreateWorkflow46(VectorQuantizeTask);
7112
7236
 
7113
7237
  // src/task/VectorSimilarityTask.ts
7114
- import { CreateWorkflow as CreateWorkflow46, GraphAsTask, Workflow as Workflow46 } from "@workglow/task-graph";
7238
+ import { CreateWorkflow as CreateWorkflow47, GraphAsTask, Workflow as Workflow47 } from "@workglow/task-graph";
7115
7239
  import {
7116
7240
  cosineSimilarity,
7117
7241
  hammingSimilarity,
@@ -7217,7 +7341,7 @@ class VectorSimilarityTask extends GraphAsTask {
7217
7341
  var similarity = (input, config) => {
7218
7342
  return new VectorSimilarityTask(config).run(input);
7219
7343
  };
7220
- Workflow46.prototype.similarity = CreateWorkflow46(VectorSimilarityTask);
7344
+ Workflow47.prototype.similarity = CreateWorkflow47(VectorSimilarityTask);
7221
7345
  // src/task/MessageConversion.ts
7222
7346
  function getInputMessages(input) {
7223
7347
  const messages = input.messages;
@@ -7436,6 +7560,7 @@ var registerAiTasks = () => {
7436
7560
  HandLandmarkerTask,
7437
7561
  HierarchicalChunkerTask,
7438
7562
  HierarchyJoinTask,
7563
+ KbToDocumentsTask,
7439
7564
  ImageClassificationTask,
7440
7565
  ImageEmbeddingTask,
7441
7566
  ImageSegmentationTask,
@@ -7504,6 +7629,7 @@ export {
7504
7629
  objectDetection,
7505
7630
  modelSearch,
7506
7631
  modelInfo,
7632
+ kbToDocuments,
7507
7633
  isAllowedToolName,
7508
7634
  imageToText,
7509
7635
  imageSegmentation,
@@ -7614,6 +7740,7 @@ export {
7614
7740
  ModelInfoTask,
7615
7741
  ModelConfigSchema,
7616
7742
  MODEL_REPOSITORY,
7743
+ KbToDocumentsTask,
7617
7744
  InMemoryModelRepository,
7618
7745
  ImageToTextTask,
7619
7746
  ImageToTextOutputSchema,
@@ -7645,6 +7772,7 @@ export {
7645
7772
  DocumentUpsertTask,
7646
7773
  DocumentEnricherTask,
7647
7774
  DirectExecutionStrategy,
7775
+ DEFAULT_AI_PROVIDER_WORKER_IDLE_TIMEOUT_MS,
7648
7776
  CountTokensTask,
7649
7777
  CountTokensOutputSchema,
7650
7778
  CountTokensInputSchema,
@@ -7668,4 +7796,4 @@ export {
7668
7796
  AgentInputSchema
7669
7797
  };
7670
7798
 
7671
- //# debugId=D3865241A90A4BFE64756E2164756E21
7799
+ //# debugId=E5D2CAC1AFB89B5564756E2164756E21