@workglow/ai 0.0.110 → 0.0.113

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/bun.js CHANGED
@@ -420,7 +420,7 @@ class AiProvider {
420
420
  }
421
421
  }
422
422
  // src/task/index.ts
423
- import { TaskRegistry as TaskRegistry2 } from "@workglow/task-graph";
423
+ import { TaskRegistry } from "@workglow/task-graph";
424
424
 
425
425
  // src/task/BackgroundRemovalTask.ts
426
426
  import { CreateWorkflow, Workflow } from "@workglow/task-graph";
@@ -780,7 +780,7 @@ var backgroundRemoval = (input, config) => {
780
780
  Workflow.prototype.backgroundRemoval = CreateWorkflow(BackgroundRemovalTask);
781
781
 
782
782
  // src/task/ChunkRetrievalTask.ts
783
- import { TypeDocumentChunkDataset } from "@workglow/dataset";
783
+ import { TypeKnowledgeBase } from "@workglow/dataset";
784
784
  import {
785
785
  CreateWorkflow as CreateWorkflow3,
786
786
  Task,
@@ -843,9 +843,9 @@ Workflow2.prototype.textEmbedding = CreateWorkflow2(TextEmbeddingTask);
843
843
  var inputSchema = {
844
844
  type: "object",
845
845
  properties: {
846
- dataset: TypeDocumentChunkDataset({
847
- title: "Document Chunk Vector Repository",
848
- description: "The document chunk vector repository instance to search in"
846
+ knowledgeBase: TypeKnowledgeBase({
847
+ title: "Knowledge Base",
848
+ description: "The knowledge base instance to search in"
849
849
  }),
850
850
  query: TypeSingleOrArray({
851
851
  oneOf: [
@@ -889,14 +889,14 @@ var inputSchema = {
889
889
  default: false
890
890
  }
891
891
  },
892
- required: ["dataset", "query"],
892
+ required: ["knowledgeBase", "query"],
893
893
  if: {
894
894
  properties: {
895
895
  query: { type: "string" }
896
896
  }
897
897
  },
898
898
  then: {
899
- required: ["dataset", "query", "model"]
899
+ required: ["knowledgeBase", "query", "model"]
900
900
  },
901
901
  else: {},
902
902
  additionalProperties: false
@@ -945,9 +945,20 @@ var outputSchema = {
945
945
  type: "number",
946
946
  title: "Count",
947
947
  description: "Number of results returned"
948
- }
948
+ },
949
+ query: TypeSingleOrArray({
950
+ oneOf: [
951
+ { type: "string" },
952
+ TypedArraySchema2({
953
+ title: "Query Vector",
954
+ description: "Pre-computed query vector"
955
+ })
956
+ ],
957
+ title: "Query",
958
+ description: "The query used for retrieval (pass-through)"
959
+ })
949
960
  },
950
- required: ["chunks", "chunk_ids", "metadata", "scores", "count"],
961
+ required: ["chunks", "chunk_ids", "metadata", "scores", "count", "query"],
951
962
  additionalProperties: false
952
963
  };
953
964
 
@@ -965,7 +976,7 @@ class ChunkRetrievalTask extends Task {
965
976
  }
966
977
  async execute(input, context) {
967
978
  const {
968
- dataset,
979
+ knowledgeBase,
969
980
  query,
970
981
  topK = 5,
971
982
  filter,
@@ -973,7 +984,7 @@ class ChunkRetrievalTask extends Task {
973
984
  scoreThreshold = 0,
974
985
  returnVectors = false
975
986
  } = input;
976
- const repo = dataset;
987
+ const kb = knowledgeBase;
977
988
  let queryVectors;
978
989
  if (typeof query === "string" || Array.isArray(query) && query.every((q) => typeof q === "string")) {
979
990
  if (!model) {
@@ -990,7 +1001,7 @@ class ChunkRetrievalTask extends Task {
990
1001
  const searchVectors = queryVectors.map((v) => v instanceof Float32Array ? v : new Float32Array(v));
991
1002
  const results = [];
992
1003
  for (const searchVector of searchVectors) {
993
- const res = await repo.similaritySearch(searchVector, {
1004
+ const res = await kb.similaritySearch(searchVector, {
994
1005
  topK,
995
1006
  filter,
996
1007
  scoreThreshold
@@ -999,14 +1010,15 @@ class ChunkRetrievalTask extends Task {
999
1010
  }
1000
1011
  const chunks = results.map((r) => {
1001
1012
  const meta = r.metadata;
1002
- return meta.text || meta.content || meta.chunk || JSON.stringify(meta);
1013
+ return meta.text || JSON.stringify(meta);
1003
1014
  });
1004
1015
  const output = {
1005
1016
  chunks,
1006
1017
  chunk_ids: results.map((r) => r.chunk_id),
1007
1018
  metadata: results.map((r) => r.metadata),
1008
1019
  scores: results.map((r) => r.score),
1009
- count: results.length
1020
+ count: results.length,
1021
+ query
1010
1022
  };
1011
1023
  if (returnVectors) {
1012
1024
  output.vectors = results.map((r) => r.vector);
@@ -1020,7 +1032,7 @@ var chunkRetrieval = (input, config) => {
1020
1032
  Workflow3.prototype.chunkRetrieval = CreateWorkflow3(ChunkRetrievalTask);
1021
1033
 
1022
1034
  // src/task/ChunkToVectorTask.ts
1023
- import { ChunkNodeSchema } from "@workglow/dataset";
1035
+ import { ChunkRecordSchema } from "@workglow/dataset";
1024
1036
  import {
1025
1037
  CreateWorkflow as CreateWorkflow4,
1026
1038
  Task as Task2,
@@ -1044,11 +1056,11 @@ var inputSchema2 = {
1044
1056
  },
1045
1057
  chunks: {
1046
1058
  type: "array",
1047
- items: ChunkNodeSchema(),
1059
+ items: ChunkRecordSchema(),
1048
1060
  title: "Chunks",
1049
- description: "Array of chunk nodes"
1061
+ description: "Array of chunk records"
1050
1062
  },
1051
- vectors: {
1063
+ vector: {
1052
1064
  type: "array",
1053
1065
  items: TypedArraySchema3({
1054
1066
  title: "Vector",
@@ -1058,7 +1070,7 @@ var inputSchema2 = {
1058
1070
  description: "Embeddings from TextEmbeddingTask"
1059
1071
  }
1060
1072
  },
1061
- required: ["chunks", "vectors"],
1073
+ required: ["chunks", "vector"],
1062
1074
  additionalProperties: false
1063
1075
  };
1064
1076
  var outputSchema2 = {
@@ -1113,13 +1125,13 @@ class ChunkToVectorTask extends Task2 {
1113
1125
  return outputSchema2;
1114
1126
  }
1115
1127
  async execute(input, context) {
1116
- const { chunks, vectors, doc_title } = input;
1128
+ const { chunks, vector, doc_title } = input;
1117
1129
  const chunkArray = chunks;
1118
- if (!chunkArray || !vectors) {
1130
+ if (!chunkArray || !vector) {
1119
1131
  throw new Error("Both chunks and vector are required");
1120
1132
  }
1121
- if (chunkArray.length !== vectors.length) {
1122
- throw new Error(`Mismatch: ${chunkArray.length} chunks but ${vectors.length} vectors`);
1133
+ if (chunkArray.length !== vector.length) {
1134
+ throw new Error(`Mismatch: ${chunkArray.length} chunks but ${vector.length} vectors`);
1123
1135
  }
1124
1136
  const ids = [];
1125
1137
  const metadata = [];
@@ -1136,12 +1148,13 @@ class ChunkToVectorTask extends Task2 {
1136
1148
  text: chunk.text,
1137
1149
  nodePath: chunk.nodePath,
1138
1150
  ...doc_title ? { doc_title } : {},
1139
- ...chunk.enrichment || {}
1151
+ ...chunk.summary ? { summary: chunk.summary } : {},
1152
+ ...chunk.entities ? { entities: chunk.entities } : {}
1140
1153
  });
1141
1154
  }
1142
1155
  return {
1143
1156
  ids,
1144
- vectors,
1157
+ vectors: vector,
1145
1158
  metadata,
1146
1159
  texts
1147
1160
  };
@@ -1153,7 +1166,7 @@ var chunkToVector = (input, config) => {
1153
1166
  Workflow4.prototype.chunkToVector = CreateWorkflow4(ChunkToVectorTask);
1154
1167
 
1155
1168
  // src/task/ChunkVectorHybridSearchTask.ts
1156
- import { TypeDocumentChunkDataset as TypeDocumentChunkDataset2 } from "@workglow/dataset";
1169
+ import { TypeKnowledgeBase as TypeKnowledgeBase2 } from "@workglow/dataset";
1157
1170
  import {
1158
1171
  CreateWorkflow as CreateWorkflow5,
1159
1172
  Task as Task3,
@@ -1165,9 +1178,9 @@ import {
1165
1178
  var inputSchema3 = {
1166
1179
  type: "object",
1167
1180
  properties: {
1168
- dataset: TypeDocumentChunkDataset2({
1169
- title: "Document Chunk Vector Repository",
1170
- description: "The document chunk vector repository instance to search in (must support hybridSearch)"
1181
+ knowledgeBase: TypeKnowledgeBase2({
1182
+ title: "Knowledge Base",
1183
+ description: "The knowledge base instance to search in (must support hybridSearch)"
1171
1184
  }),
1172
1185
  queryVector: TypedArraySchema4({
1173
1186
  title: "Query Vector",
@@ -1213,7 +1226,7 @@ var inputSchema3 = {
1213
1226
  default: false
1214
1227
  }
1215
1228
  },
1216
- required: ["dataset", "queryVector", "queryText"],
1229
+ required: ["knowledgeBase", "queryVector", "queryText"],
1217
1230
  additionalProperties: false
1218
1231
  };
1219
1232
  var outputSchema3 = {
@@ -1225,10 +1238,10 @@ var outputSchema3 = {
1225
1238
  title: "Text Chunks",
1226
1239
  description: "Retrieved text chunks"
1227
1240
  },
1228
- ids: {
1241
+ chunk_ids: {
1229
1242
  type: "array",
1230
1243
  items: { type: "string" },
1231
- title: "IDs",
1244
+ title: "Chunk IDs",
1232
1245
  description: "IDs of retrieved chunks"
1233
1246
  },
1234
1247
  metadata: {
@@ -1260,9 +1273,14 @@ var outputSchema3 = {
1260
1273
  type: "number",
1261
1274
  title: "Count",
1262
1275
  description: "Number of results returned"
1276
+ },
1277
+ query: {
1278
+ type: "string",
1279
+ title: "Query",
1280
+ description: "The text query used for search (pass-through)"
1263
1281
  }
1264
1282
  },
1265
- required: ["chunks", "ids", "metadata", "scores", "count"],
1283
+ required: ["chunks", "chunk_ids", "metadata", "scores", "count", "query"],
1266
1284
  additionalProperties: false
1267
1285
  };
1268
1286
 
@@ -1280,7 +1298,7 @@ class ChunkVectorHybridSearchTask extends Task3 {
1280
1298
  }
1281
1299
  async execute(input, context) {
1282
1300
  const {
1283
- dataset,
1301
+ knowledgeBase,
1284
1302
  queryVector,
1285
1303
  queryText,
1286
1304
  topK = 10,
@@ -1289,12 +1307,9 @@ class ChunkVectorHybridSearchTask extends Task3 {
1289
1307
  vectorWeight = 0.7,
1290
1308
  returnVectors = false
1291
1309
  } = input;
1292
- const repo = dataset;
1293
- if (!repo.hybridSearch) {
1294
- throw new Error("Dataset does not support hybrid search.");
1295
- }
1310
+ const kb = knowledgeBase;
1296
1311
  const searchVector = queryVector instanceof Float32Array ? queryVector : new Float32Array(queryVector);
1297
- const results = await repo.hybridSearch(searchVector, {
1312
+ const results = await kb.hybridSearch(searchVector, {
1298
1313
  textQuery: queryText,
1299
1314
  topK,
1300
1315
  filter,
@@ -1303,14 +1318,15 @@ class ChunkVectorHybridSearchTask extends Task3 {
1303
1318
  });
1304
1319
  const chunks = results.map((r) => {
1305
1320
  const meta = r.metadata;
1306
- return meta.text || meta.content || meta.chunk || JSON.stringify(meta);
1321
+ return meta.text || JSON.stringify(meta);
1307
1322
  });
1308
1323
  const output = {
1309
1324
  chunks,
1310
- ids: results.map((r) => r.chunk_id),
1325
+ chunk_ids: results.map((r) => r.chunk_id),
1311
1326
  metadata: results.map((r) => r.metadata),
1312
1327
  scores: results.map((r) => r.score),
1313
- count: results.length
1328
+ count: results.length,
1329
+ query: queryText
1314
1330
  };
1315
1331
  if (returnVectors) {
1316
1332
  output.vectors = results.map((r) => r.vector);
@@ -1324,7 +1340,7 @@ var hybridSearch = async (input, config) => {
1324
1340
  Workflow5.prototype.hybridSearch = CreateWorkflow5(ChunkVectorHybridSearchTask);
1325
1341
 
1326
1342
  // src/task/ChunkVectorSearchTask.ts
1327
- import { TypeDocumentChunkDataset as TypeDocumentChunkDataset3 } from "@workglow/dataset";
1343
+ import { TypeKnowledgeBase as TypeKnowledgeBase3 } from "@workglow/dataset";
1328
1344
  import {
1329
1345
  CreateWorkflow as CreateWorkflow6,
1330
1346
  Task as Task4,
@@ -1336,9 +1352,9 @@ import {
1336
1352
  var inputSchema4 = {
1337
1353
  type: "object",
1338
1354
  properties: {
1339
- dataset: TypeDocumentChunkDataset3({
1340
- title: "Vector Repository",
1341
- description: "The vector repository instance to search in"
1355
+ knowledgeBase: TypeKnowledgeBase3({
1356
+ title: "Knowledge Base",
1357
+ description: "The knowledge base instance to search in"
1342
1358
  }),
1343
1359
  query: TypedArraySchema5({
1344
1360
  title: "Query Vector",
@@ -1365,7 +1381,7 @@ var inputSchema4 = {
1365
1381
  default: 0
1366
1382
  }
1367
1383
  },
1368
- required: ["dataset", "query"],
1384
+ required: ["knowledgeBase", "query"],
1369
1385
  additionalProperties: false
1370
1386
  };
1371
1387
  var outputSchema4 = {
@@ -1416,7 +1432,7 @@ class ChunkVectorSearchTask extends Task4 {
1416
1432
  static type = "ChunkVectorSearchTask";
1417
1433
  static category = "Vector Store";
1418
1434
  static title = "Vector Store Search";
1419
- static description = "Search for similar vectors in a document chunk dataset";
1435
+ static description = "Search for similar vectors in a knowledge base";
1420
1436
  static cacheable = true;
1421
1437
  static inputSchema() {
1422
1438
  return inputSchema4;
@@ -1425,9 +1441,9 @@ class ChunkVectorSearchTask extends Task4 {
1425
1441
  return outputSchema4;
1426
1442
  }
1427
1443
  async execute(input, context) {
1428
- const { dataset, query, topK = 10, filter, scoreThreshold = 0 } = input;
1429
- const repo = dataset;
1430
- const results = await repo.similaritySearch(query, {
1444
+ const { knowledgeBase, query, topK = 10, filter, scoreThreshold = 0 } = input;
1445
+ const kb = knowledgeBase;
1446
+ const results = await kb.similaritySearch(query, {
1431
1447
  topK,
1432
1448
  filter,
1433
1449
  scoreThreshold
@@ -1447,7 +1463,7 @@ var vectorStoreSearch = (input, config) => {
1447
1463
  Workflow6.prototype.vectorStoreSearch = CreateWorkflow6(ChunkVectorSearchTask);
1448
1464
 
1449
1465
  // src/task/ChunkVectorUpsertTask.ts
1450
- import { TypeDocumentChunkDataset as TypeDocumentChunkDataset4 } from "@workglow/dataset";
1466
+ import { TypeKnowledgeBase as TypeKnowledgeBase4 } from "@workglow/dataset";
1451
1467
  import {
1452
1468
  CreateWorkflow as CreateWorkflow7,
1453
1469
  Task as Task5,
@@ -1459,9 +1475,9 @@ import {
1459
1475
  var inputSchema5 = {
1460
1476
  type: "object",
1461
1477
  properties: {
1462
- dataset: TypeDocumentChunkDataset4({
1463
- title: "Document Chunk Vector Repository",
1464
- description: "The document chunk vector repository instance to store vectors in"
1478
+ knowledgeBase: TypeKnowledgeBase4({
1479
+ title: "Knowledge Base",
1480
+ description: "The knowledge base instance to store vectors in"
1465
1481
  }),
1466
1482
  doc_id: {
1467
1483
  type: "string",
@@ -1479,7 +1495,7 @@ var inputSchema5 = {
1479
1495
  additionalProperties: true
1480
1496
  })
1481
1497
  },
1482
- required: ["dataset", "doc_id", "vectors", "metadata"],
1498
+ required: ["knowledgeBase", "doc_id", "vectors", "metadata"],
1483
1499
  additionalProperties: false
1484
1500
  };
1485
1501
  var outputSchema5 = {
@@ -1510,7 +1526,7 @@ class ChunkVectorUpsertTask extends Task5 {
1510
1526
  static type = "ChunkVectorUpsertTask";
1511
1527
  static category = "Vector Store";
1512
1528
  static title = "Add to Vector Store";
1513
- static description = "Store vector embeddings with metadata in a document chunk dataset";
1529
+ static description = "Store vector embeddings with metadata in a knowledge base";
1514
1530
  static cacheable = false;
1515
1531
  static inputSchema() {
1516
1532
  return inputSchema5;
@@ -1519,10 +1535,10 @@ class ChunkVectorUpsertTask extends Task5 {
1519
1535
  return outputSchema5;
1520
1536
  }
1521
1537
  async execute(input, context) {
1522
- const { dataset, doc_id, vectors, metadata } = input;
1538
+ const { knowledgeBase, doc_id, vectors, metadata } = input;
1523
1539
  const vectorArray = Array.isArray(vectors) ? vectors : [vectors];
1524
1540
  const metadataArray = Array.isArray(metadata) ? metadata : Array(vectorArray.length).fill(metadata);
1525
- const repo = dataset;
1541
+ const kb = knowledgeBase;
1526
1542
  await context.updateProgress(1, "Upserting vectors");
1527
1543
  if (vectorArray.length > 1) {
1528
1544
  if (vectorArray.length !== metadataArray.length) {
@@ -1536,7 +1552,7 @@ class ChunkVectorUpsertTask extends Task5 {
1536
1552
  metadata: metadataItem
1537
1553
  };
1538
1554
  });
1539
- const results = await repo.putBulk(entities);
1555
+ const results = await kb.upsertChunksBulk(entities);
1540
1556
  const chunk_ids = results.map((r) => r.chunk_id);
1541
1557
  return {
1542
1558
  doc_id,
@@ -1545,7 +1561,7 @@ class ChunkVectorUpsertTask extends Task5 {
1545
1561
  };
1546
1562
  } else if (vectorArray.length === 1) {
1547
1563
  const metadataItem = metadataArray[0];
1548
- const result = await repo.put({
1564
+ const result = await kb.upsertChunk({
1549
1565
  doc_id,
1550
1566
  vector: vectorArray[0],
1551
1567
  metadata: metadataItem
@@ -2990,7 +3006,7 @@ Workflow17.prototype.handLandmarker = CreateWorkflow17(HandLandmarkerTask);
2990
3006
 
2991
3007
  // src/task/HierarchicalChunkerTask.ts
2992
3008
  import {
2993
- ChunkNodeSchema as ChunkNodeSchema2,
3009
+ ChunkRecordSchema as ChunkRecordSchema2,
2994
3010
  estimateTokens as estimateTokens2,
2995
3011
  getChildren as getChildren2,
2996
3012
  hasChildren as hasChildren2
@@ -3060,9 +3076,9 @@ var outputSchema8 = {
3060
3076
  },
3061
3077
  chunks: {
3062
3078
  type: "array",
3063
- items: ChunkNodeSchema2(),
3079
+ items: ChunkRecordSchema2(),
3064
3080
  title: "Chunks",
3065
- description: "Array of chunk nodes"
3081
+ description: "Array of chunk records"
3066
3082
  },
3067
3083
  text: {
3068
3084
  type: "array",
@@ -3228,9 +3244,8 @@ Workflow18.prototype.hierarchicalChunker = CreateWorkflow18(HierarchicalChunkerT
3228
3244
 
3229
3245
  // src/task/HierarchyJoinTask.ts
3230
3246
  import {
3231
- ChunkMetadataArraySchema,
3232
- EnrichedChunkMetadataArraySchema,
3233
- TypeDocumentDataset
3247
+ ChunkRecordArraySchema,
3248
+ TypeKnowledgeBase as TypeKnowledgeBase5
3234
3249
  } from "@workglow/dataset";
3235
3250
  import {
3236
3251
  CreateWorkflow as CreateWorkflow19,
@@ -3240,9 +3255,9 @@ import {
3240
3255
  var inputSchema9 = {
3241
3256
  type: "object",
3242
3257
  properties: {
3243
- documents: TypeDocumentDataset({
3244
- title: "Documents",
3245
- description: "The documents dataset to query for hierarchy"
3258
+ knowledgeBase: TypeKnowledgeBase5({
3259
+ title: "Knowledge Base",
3260
+ description: "The knowledge base to query for hierarchy"
3246
3261
  }),
3247
3262
  chunks: {
3248
3263
  type: "array",
@@ -3256,7 +3271,7 @@ var inputSchema9 = {
3256
3271
  title: "Chunk IDs",
3257
3272
  description: "IDs of retrieved chunks"
3258
3273
  },
3259
- metadata: ChunkMetadataArraySchema,
3274
+ metadata: ChunkRecordArraySchema,
3260
3275
  scores: {
3261
3276
  type: "array",
3262
3277
  items: { type: "number" },
@@ -3276,7 +3291,7 @@ var inputSchema9 = {
3276
3291
  default: true
3277
3292
  }
3278
3293
  },
3279
- required: ["documents", "chunks", "chunk_ids", "metadata", "scores"],
3294
+ required: ["knowledgeBase", "chunks", "chunk_ids", "metadata", "scores"],
3280
3295
  additionalProperties: false
3281
3296
  };
3282
3297
  var outputSchema9 = {
@@ -3294,7 +3309,7 @@ var outputSchema9 = {
3294
3309
  title: "Chunk IDs",
3295
3310
  description: "IDs of retrieved chunks"
3296
3311
  },
3297
- metadata: EnrichedChunkMetadataArraySchema,
3312
+ metadata: ChunkRecordArraySchema,
3298
3313
  scores: {
3299
3314
  type: "array",
3300
3315
  items: { type: "number" },
@@ -3325,7 +3340,7 @@ class HierarchyJoinTask extends Task9 {
3325
3340
  }
3326
3341
  async execute(input, context) {
3327
3342
  const {
3328
- documents,
3343
+ knowledgeBase,
3329
3344
  chunks,
3330
3345
  chunk_ids,
3331
3346
  metadata,
@@ -3333,7 +3348,7 @@ class HierarchyJoinTask extends Task9 {
3333
3348
  includeParentSummaries = true,
3334
3349
  includeEntities = true
3335
3350
  } = input;
3336
- const repo = documents;
3351
+ const kb = knowledgeBase;
3337
3352
  const enrichedMetadata = [];
3338
3353
  for (let i = 0;i < chunk_ids.length; i++) {
3339
3354
  const chunkId = chunk_ids[i];
@@ -3349,7 +3364,7 @@ class HierarchyJoinTask extends Task9 {
3349
3364
  continue;
3350
3365
  }
3351
3366
  try {
3352
- const ancestors = await repo.getAncestors(doc_id, leafNodeId);
3367
+ const ancestors = await kb.getAncestors(doc_id, leafNodeId);
3353
3368
  const enriched = { ...originalMetadata };
3354
3369
  if (includeParentSummaries && ancestors.length > 0) {
3355
3370
  const parentSummaries = [];
@@ -3358,7 +3373,7 @@ class HierarchyJoinTask extends Task9 {
3358
3373
  if (ancestor.enrichment?.summary) {
3359
3374
  parentSummaries.push(ancestor.enrichment.summary);
3360
3375
  }
3361
- if (ancestor.kind === "section" && ancestor.title) {
3376
+ if (ancestor.kind === "section" && "title" in ancestor) {
3362
3377
  sectionTitles.push(ancestor.title);
3363
3378
  }
3364
3379
  }
@@ -4009,7 +4024,7 @@ var inputSchema10 = {
4009
4024
  var outputSchema10 = {
4010
4025
  type: "object",
4011
4026
  properties: {
4012
- queries: {
4027
+ query: {
4013
4028
  type: "array",
4014
4029
  items: { type: "string" },
4015
4030
  title: "Expanded Queries",
@@ -4031,7 +4046,7 @@ var outputSchema10 = {
4031
4046
  description: "Number of queries generated"
4032
4047
  }
4033
4048
  },
4034
- required: ["queries", "originalQuery", "method", "count"],
4049
+ required: ["query", "originalQuery", "method", "count"],
4035
4050
  additionalProperties: false
4036
4051
  };
4037
4052
 
@@ -4069,7 +4084,7 @@ class QueryExpanderTask extends Task10 {
4069
4084
  queries.unshift(query);
4070
4085
  }
4071
4086
  return {
4072
- queries,
4087
+ query: queries,
4073
4088
  originalQuery: query,
4074
4089
  method,
4075
4090
  count: queries.length
@@ -5261,8 +5276,78 @@ var textRewriter = (input, config) => {
5261
5276
  };
5262
5277
  Workflow37.prototype.textRewriter = CreateWorkflow37(TextRewriterTask);
5263
5278
 
5279
+ // src/task/TextTranslationTask.ts
5280
+ import { CreateWorkflow as CreateWorkflow38, Workflow as Workflow38 } from "@workglow/task-graph";
5281
+ var modelSchema27 = TypeModel("model:TextTranslationTask");
5282
+ var translationTextSchema = TypeSingleOrArray({
5283
+ type: "string",
5284
+ title: "Text",
5285
+ description: "The translated text",
5286
+ "x-stream": "replace"
5287
+ });
5288
+ var TextTranslationInputSchema = {
5289
+ type: "object",
5290
+ properties: {
5291
+ text: TypeSingleOrArray({
5292
+ type: "string",
5293
+ title: "Text",
5294
+ description: "The text to translate"
5295
+ }),
5296
+ source_lang: TypeLanguage({
5297
+ title: "Source Language",
5298
+ description: "The source language",
5299
+ minLength: 2,
5300
+ maxLength: 2
5301
+ }),
5302
+ target_lang: TypeLanguage({
5303
+ title: "Target Language",
5304
+ description: "The target language",
5305
+ minLength: 2,
5306
+ maxLength: 2
5307
+ }),
5308
+ model: modelSchema27
5309
+ },
5310
+ required: ["text", "source_lang", "target_lang", "model"],
5311
+ additionalProperties: false
5312
+ };
5313
+ var TextTranslationOutputSchema = {
5314
+ type: "object",
5315
+ properties: {
5316
+ text: translationTextSchema,
5317
+ target_lang: TypeLanguage({
5318
+ title: "Output Language",
5319
+ description: "The output language",
5320
+ minLength: 2,
5321
+ maxLength: 2
5322
+ })
5323
+ },
5324
+ required: ["text", "target_lang"],
5325
+ additionalProperties: false
5326
+ };
5327
+
5328
+ class TextTranslationTask extends StreamingAiTask {
5329
+ static type = "TextTranslationTask";
5330
+ static category = "AI Text Model";
5331
+ static title = "Text Translation";
5332
+ static description = "Translates text from one language to another using language models";
5333
+ static inputSchema() {
5334
+ return TextTranslationInputSchema;
5335
+ }
5336
+ static outputSchema() {
5337
+ return TextTranslationOutputSchema;
5338
+ }
5339
+ }
5340
+ var textTranslation = (input, config) => {
5341
+ return new TextTranslationTask({}, config).run(input);
5342
+ };
5343
+ Workflow38.prototype.textTranslation = CreateWorkflow38(TextTranslationTask);
5344
+
5264
5345
  // src/task/ToolCallingTask.ts
5265
- import { CreateWorkflow as CreateWorkflow38, TaskRegistry, Workflow as Workflow38 } from "@workglow/task-graph";
5346
+ import {
5347
+ CreateWorkflow as CreateWorkflow39,
5348
+ getTaskConstructors,
5349
+ Workflow as Workflow39
5350
+ } from "@workglow/task-graph";
5266
5351
  import { getLogger } from "@workglow/util";
5267
5352
  function buildToolDescription(tool) {
5268
5353
  let desc = tool.description;
@@ -5291,11 +5376,12 @@ function filterValidToolCalls(toolCalls, allowedTools) {
5291
5376
  }
5292
5377
  return filtered;
5293
5378
  }
5294
- function taskTypesToTools(taskNames) {
5379
+ function taskTypesToTools(taskNames, registry) {
5380
+ const constructors = getTaskConstructors(registry);
5295
5381
  return taskNames.map((name) => {
5296
- const ctor = TaskRegistry.all.get(name);
5382
+ const ctor = constructors.get(name);
5297
5383
  if (!ctor) {
5298
- throw new Error(`taskTypesToTools: Unknown task type "${name}" \u2014 not found in TaskRegistry`);
5384
+ throw new Error(`taskTypesToTools: Unknown task type "${name}" \u2014 not found in task constructors registry (ServiceRegistry: ${registry ? "custom" : "default"})`);
5299
5385
  }
5300
5386
  return {
5301
5387
  name: ctor.type,
@@ -5334,11 +5420,11 @@ var ToolDefinitionSchema = {
5334
5420
  required: ["name", "description", "inputSchema"],
5335
5421
  additionalProperties: false
5336
5422
  };
5337
- var modelSchema27 = TypeModel("model:ToolCallingTask");
5423
+ var modelSchema28 = TypeModel("model:ToolCallingTask");
5338
5424
  var ToolCallingInputSchema = {
5339
5425
  type: "object",
5340
5426
  properties: {
5341
- model: modelSchema27,
5427
+ model: modelSchema28,
5342
5428
  prompt: TypeSingleOrArray({
5343
5429
  type: "string",
5344
5430
  title: "Prompt",
@@ -5351,9 +5437,15 @@ var ToolCallingInputSchema = {
5351
5437
  },
5352
5438
  tools: {
5353
5439
  type: "array",
5440
+ format: "tasks",
5354
5441
  title: "Tools",
5355
5442
  description: "Tool definitions available for the model to call",
5356
- items: ToolDefinitionSchema
5443
+ items: {
5444
+ oneOf: [
5445
+ { type: "string", format: "tasks", description: "Task type name" },
5446
+ ToolDefinitionSchema
5447
+ ]
5448
+ }
5357
5449
  },
5358
5450
  toolChoice: {
5359
5451
  type: "string",
@@ -5416,73 +5508,7 @@ class ToolCallingTask extends StreamingAiTask {
5416
5508
  var toolCalling = (input, config) => {
5417
5509
  return new ToolCallingTask({}, config).run(input);
5418
5510
  };
5419
- Workflow38.prototype.toolCalling = CreateWorkflow38(ToolCallingTask);
5420
-
5421
- // src/task/TextTranslationTask.ts
5422
- import { CreateWorkflow as CreateWorkflow39, Workflow as Workflow39 } from "@workglow/task-graph";
5423
- var modelSchema28 = TypeModel("model:TextTranslationTask");
5424
- var translationTextSchema = TypeSingleOrArray({
5425
- type: "string",
5426
- title: "Text",
5427
- description: "The translated text",
5428
- "x-stream": "replace"
5429
- });
5430
- var TextTranslationInputSchema = {
5431
- type: "object",
5432
- properties: {
5433
- text: TypeSingleOrArray({
5434
- type: "string",
5435
- title: "Text",
5436
- description: "The text to translate"
5437
- }),
5438
- source_lang: TypeLanguage({
5439
- title: "Source Language",
5440
- description: "The source language",
5441
- minLength: 2,
5442
- maxLength: 2
5443
- }),
5444
- target_lang: TypeLanguage({
5445
- title: "Target Language",
5446
- description: "The target language",
5447
- minLength: 2,
5448
- maxLength: 2
5449
- }),
5450
- model: modelSchema28
5451
- },
5452
- required: ["text", "source_lang", "target_lang", "model"],
5453
- additionalProperties: false
5454
- };
5455
- var TextTranslationOutputSchema = {
5456
- type: "object",
5457
- properties: {
5458
- text: translationTextSchema,
5459
- target_lang: TypeLanguage({
5460
- title: "Output Language",
5461
- description: "The output language",
5462
- minLength: 2,
5463
- maxLength: 2
5464
- })
5465
- },
5466
- required: ["text", "target_lang"],
5467
- additionalProperties: false
5468
- };
5469
-
5470
- class TextTranslationTask extends StreamingAiTask {
5471
- static type = "TextTranslationTask";
5472
- static category = "AI Text Model";
5473
- static title = "Text Translation";
5474
- static description = "Translates text from one language to another using language models";
5475
- static inputSchema() {
5476
- return TextTranslationInputSchema;
5477
- }
5478
- static outputSchema() {
5479
- return TextTranslationOutputSchema;
5480
- }
5481
- }
5482
- var textTranslation = (input, config) => {
5483
- return new TextTranslationTask({}, config).run(input);
5484
- };
5485
- Workflow39.prototype.textTranslation = CreateWorkflow39(TextTranslationTask);
5511
+ Workflow39.prototype.toolCalling = CreateWorkflow39(ToolCallingTask);
5486
5512
 
5487
5513
  // src/task/TopicSegmenterTask.ts
5488
5514
  import {
@@ -6148,7 +6174,7 @@ var registerAiTasks = () => {
6148
6174
  VectorQuantizeTask,
6149
6175
  VectorSimilarityTask
6150
6176
  ];
6151
- tasks.map(TaskRegistry2.registerTask);
6177
+ tasks.map(TaskRegistry.registerTask);
6152
6178
  return tasks;
6153
6179
  };
6154
6180
  export {
@@ -6217,6 +6243,7 @@ export {
6217
6243
  TypeBoundingBox,
6218
6244
  TypeAudioInput,
6219
6245
  TopicSegmenterTask,
6246
+ ToolDefinitionSchema,
6220
6247
  ToolCallingTask,
6221
6248
  ToolCallingOutputSchema,
6222
6249
  ToolCallingInputSchema,
@@ -6322,4 +6349,4 @@ export {
6322
6349
  AiJob
6323
6350
  };
6324
6351
 
6325
- //# debugId=E73E8DF34D71240E64756E2164756E21
6352
+ //# debugId=8E8187274333361364756E2164756E21