@workglow/ai 0.2.14 → 0.2.16

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 (37) hide show
  1. package/README.md +11 -15
  2. package/dist/browser.js +522 -1016
  3. package/dist/browser.js.map +14 -17
  4. package/dist/bun.js +522 -1016
  5. package/dist/bun.js.map +14 -17
  6. package/dist/node.js +522 -1016
  7. package/dist/node.js.map +14 -17
  8. package/dist/task/AiChatTask.d.ts +150 -231
  9. package/dist/task/AiChatTask.d.ts.map +1 -1
  10. package/dist/task/ChatMessage.d.ts +110 -155
  11. package/dist/task/ChatMessage.d.ts.map +1 -1
  12. package/dist/task/ChunkRetrievalTask.d.ts +32 -49
  13. package/dist/task/ChunkRetrievalTask.d.ts.map +1 -1
  14. package/dist/task/ChunkVectorUpsertTask.d.ts +107 -24
  15. package/dist/task/ChunkVectorUpsertTask.d.ts.map +1 -1
  16. package/dist/task/HierarchyJoinTask.d.ts +44 -42
  17. package/dist/task/HierarchyJoinTask.d.ts.map +1 -1
  18. package/dist/task/QueryExpanderTask.d.ts +5 -31
  19. package/dist/task/QueryExpanderTask.d.ts.map +1 -1
  20. package/dist/task/RerankerTask.d.ts +7 -89
  21. package/dist/task/RerankerTask.d.ts.map +1 -1
  22. package/dist/task/StructuredGenerationTask.d.ts +1 -1
  23. package/dist/task/StructuredGenerationTask.d.ts.map +1 -1
  24. package/dist/task/TextChunkerTask.d.ts +139 -37
  25. package/dist/task/TextChunkerTask.d.ts.map +1 -1
  26. package/dist/task/ToolCallingTask.d.ts +50 -77
  27. package/dist/task/ToolCallingTask.d.ts.map +1 -1
  28. package/dist/task/base/AiVisionTask.d.ts.map +1 -1
  29. package/dist/task/index.d.ts +1 -7
  30. package/dist/task/index.d.ts.map +1 -1
  31. package/package.json +11 -11
  32. package/dist/task/ChunkToVectorTask.d.ts +0 -210
  33. package/dist/task/ChunkToVectorTask.d.ts.map +0 -1
  34. package/dist/task/ChunkVectorHybridSearchTask.d.ts +0 -167
  35. package/dist/task/ChunkVectorHybridSearchTask.d.ts.map +0 -1
  36. package/dist/task/ChunkVectorSearchTask.d.ts +0 -139
  37. package/dist/task/ChunkVectorSearchTask.d.ts.map +0 -1
package/dist/bun.js CHANGED
@@ -1250,6 +1250,9 @@ var ContentBlockToolUseSchema = {
1250
1250
  required: ["type", "id", "name", "input"],
1251
1251
  additionalProperties: false
1252
1252
  };
1253
+ var ContentBlockInToolResultBodySchema = {
1254
+ oneOf: [ContentBlockTextSchema, ContentBlockImageSchema, ContentBlockToolUseSchema]
1255
+ };
1253
1256
  var ContentBlockToolResultSchema = {
1254
1257
  type: "object",
1255
1258
  properties: {
@@ -1257,7 +1260,7 @@ var ContentBlockToolResultSchema = {
1257
1260
  tool_use_id: { type: "string" },
1258
1261
  content: {
1259
1262
  type: "array",
1260
- items: { $ref: "#/definitions/ContentBlock" }
1263
+ items: ContentBlockInToolResultBodySchema
1261
1264
  },
1262
1265
  is_error: { type: "boolean" }
1263
1266
  },
@@ -1271,16 +1274,6 @@ var ContentBlockSchema = {
1271
1274
  ContentBlockToolUseSchema,
1272
1275
  ContentBlockToolResultSchema
1273
1276
  ],
1274
- definitions: {
1275
- ContentBlock: {
1276
- oneOf: [
1277
- ContentBlockTextSchema,
1278
- ContentBlockImageSchema,
1279
- ContentBlockToolUseSchema,
1280
- ContentBlockToolResultSchema
1281
- ]
1282
- }
1283
- },
1284
1277
  title: "ContentBlock",
1285
1278
  description: "A single content block within a chat message"
1286
1279
  };
@@ -1298,6 +1291,21 @@ var ChatMessageSchema = {
1298
1291
  title: "ChatMessage",
1299
1292
  description: "A single chat message with role and structured content blocks"
1300
1293
  };
1294
+ function isContentBlockInToolResultBody(value) {
1295
+ if (!value || typeof value !== "object")
1296
+ return false;
1297
+ const v = value;
1298
+ switch (v.type) {
1299
+ case "text":
1300
+ return typeof v.text === "string";
1301
+ case "image":
1302
+ return typeof v.mimeType === "string" && typeof v.data === "string";
1303
+ case "tool_use":
1304
+ return typeof v.id === "string" && typeof v.name === "string" && v.input !== null && typeof v.input === "object";
1305
+ default:
1306
+ return false;
1307
+ }
1308
+ }
1301
1309
  function isContentBlock(value) {
1302
1310
  if (!value || typeof value !== "object")
1303
1311
  return false;
@@ -1310,7 +1318,7 @@ function isContentBlock(value) {
1310
1318
  case "tool_use":
1311
1319
  return typeof v.id === "string" && typeof v.name === "string" && v.input !== null && typeof v.input === "object";
1312
1320
  case "tool_result":
1313
- return typeof v.tool_use_id === "string" && Array.isArray(v.content) && v.content.every(isContentBlock);
1321
+ return typeof v.tool_use_id === "string" && Array.isArray(v.content) && v.content.every(isContentBlockInToolResultBody);
1314
1322
  default:
1315
1323
  return false;
1316
1324
  }
@@ -1571,7 +1579,7 @@ class AiChatTask extends StreamingAiTask {
1571
1579
  import { CreateWorkflow, Workflow } from "@workglow/task-graph";
1572
1580
 
1573
1581
  // src/task/base/AiVisionTask.ts
1574
- import { convertImageDataToUseableForm } from "@workglow/util/media";
1582
+ import { Image } from "@workglow/util/media";
1575
1583
  class AiVisionTask extends AiTask {
1576
1584
  static type = "AiVisionTask";
1577
1585
  async getJobInput(input) {
@@ -1584,7 +1592,8 @@ class AiVisionTask extends AiTask {
1584
1592
  } else if (typeof providerName === "string" && providerName.startsWith("TENSORFLOW_MEDIAPIPE") && "VideoFrame" in globalThis) {
1585
1593
  supports.push("VideoFrame");
1586
1594
  }
1587
- const image = Array.isArray(input.image) ? await Promise.all(input.image.map((img) => convertImageDataToUseableForm(img, supports))) : await convertImageDataToUseableForm(input.image, supports);
1595
+ const toSupported = (img) => Image.from(img).toFirstSupported(supports);
1596
+ const image = Array.isArray(input.image) ? await Promise.all(input.image.map(toSupported)) : await toSupported(input.image);
1588
1597
  jobInput.taskInput.image = image;
1589
1598
  }
1590
1599
  return jobInput;
@@ -1699,7 +1708,7 @@ var inputSchema = {
1699
1708
  title: "Knowledge Base",
1700
1709
  description: "The knowledge base instance to search in"
1701
1710
  }),
1702
- query: TypeSingleOrArray({
1711
+ query: {
1703
1712
  oneOf: [
1704
1713
  { type: "string" },
1705
1714
  TypedArraySchema2({
@@ -1708,12 +1717,19 @@ var inputSchema = {
1708
1717
  })
1709
1718
  ],
1710
1719
  title: "Query",
1711
- description: "Query string or pre-computed query vector"
1712
- }),
1720
+ description: "Query string (requires `model`) or pre-computed query vector"
1721
+ },
1713
1722
  model: TypeModel("model:TextEmbeddingTask", {
1714
1723
  title: "Model",
1715
1724
  description: "Text embedding model to use for query embedding (required when query is a string)"
1716
1725
  }),
1726
+ method: {
1727
+ type: "string",
1728
+ enum: ["similarity", "hybrid"],
1729
+ title: "Retrieval Method",
1730
+ description: "Retrieval strategy: 'similarity' (vector only) or 'hybrid' (vector + full-text).",
1731
+ default: "similarity"
1732
+ },
1717
1733
  topK: {
1718
1734
  type: "number",
1719
1735
  title: "Top K",
@@ -1734,6 +1750,14 @@ var inputSchema = {
1734
1750
  maximum: 1,
1735
1751
  default: 0
1736
1752
  },
1753
+ vectorWeight: {
1754
+ type: "number",
1755
+ title: "Vector Weight",
1756
+ description: "For hybrid method: weight for vector similarity (0-1), remainder goes to text relevance",
1757
+ minimum: 0,
1758
+ maximum: 1,
1759
+ default: 0.7
1760
+ },
1737
1761
  returnVectors: {
1738
1762
  type: "boolean",
1739
1763
  title: "Return Vectors",
@@ -1798,7 +1822,7 @@ var outputSchema = {
1798
1822
  title: "Count",
1799
1823
  description: "Number of results returned"
1800
1824
  },
1801
- query: TypeSingleOrArray({
1825
+ query: {
1802
1826
  oneOf: [
1803
1827
  { type: "string" },
1804
1828
  TypedArraySchema2({
@@ -1808,7 +1832,7 @@ var outputSchema = {
1808
1832
  ],
1809
1833
  title: "Query",
1810
1834
  description: "The query used for retrieval (pass-through)"
1811
- })
1835
+ }
1812
1836
  },
1813
1837
  required: ["chunks", "chunk_ids", "metadata", "scores", "count", "query"],
1814
1838
  additionalProperties: false
@@ -1818,7 +1842,7 @@ class ChunkRetrievalTask extends Task2 {
1818
1842
  static type = "ChunkRetrievalTask";
1819
1843
  static category = "RAG";
1820
1844
  static title = "Chunk Retrieval";
1821
- static description = "End-to-end retrieval: embed query and search for similar chunks";
1845
+ static description = "End-to-end retrieval: embed query (if string) and search the knowledge base. Supports similarity and hybrid methods.";
1822
1846
  static cacheable = true;
1823
1847
  static inputSchema() {
1824
1848
  return inputSchema;
@@ -1833,332 +1857,46 @@ class ChunkRetrievalTask extends Task2 {
1833
1857
  topK = 5,
1834
1858
  filter,
1835
1859
  model,
1860
+ method = "similarity",
1861
+ vectorWeight = 0.7,
1836
1862
  scoreThreshold = 0,
1837
1863
  returnVectors = false
1838
1864
  } = input;
1839
1865
  const kb = knowledgeBase;
1840
- let queryVectors;
1841
- if (typeof query === "string" || Array.isArray(query) && query.every((q) => typeof q === "string")) {
1866
+ const queryIsString = typeof query === "string";
1867
+ if (method === "hybrid" && !queryIsString) {
1868
+ throw new Error("Hybrid retrieval requires a string query (it will be embedded and used for full-text search).");
1869
+ }
1870
+ if (method === "hybrid" && !kb.supportsHybridSearch()) {
1871
+ throw new Error("The provided knowledge base does not support hybrid search. Use method: 'similarity' or a backend with hybrid support (e.g., Postgres with pgvector).");
1872
+ }
1873
+ let queryVector;
1874
+ let queryText;
1875
+ if (queryIsString) {
1842
1876
  if (!model) {
1843
1877
  throw new Error("Model is required when query is a string. Please provide a model with format 'model:TextEmbeddingTask'.");
1844
1878
  }
1879
+ queryText = query;
1845
1880
  const embeddingTask = context.own(new TextEmbeddingTask);
1846
1881
  const embeddingResult = await embeddingTask.run({ text: query, model });
1847
- queryVectors = Array.isArray(embeddingResult.vector) ? embeddingResult.vector : [embeddingResult.vector];
1848
- } else if (isTypedArray(query) || Array.isArray(query) && query.every(isTypedArray)) {
1849
- queryVectors = Array.isArray(query) ? query : [query];
1882
+ const vec = embeddingResult.vector;
1883
+ queryVector = Array.isArray(vec) ? vec[0] : vec;
1884
+ } else if (isTypedArray(query)) {
1885
+ queryVector = query;
1850
1886
  } else {
1851
- throw new Error("Query must be a string, array of strings, or TypedArray");
1852
- }
1853
- const searchVectors = queryVectors.map((v) => v instanceof Float32Array ? v : new Float32Array(v));
1854
- const results = [];
1855
- for (const searchVector of searchVectors) {
1856
- const res = await kb.similaritySearch(searchVector, {
1857
- topK,
1858
- filter,
1859
- scoreThreshold
1860
- });
1861
- results.push(...res);
1887
+ throw new Error("Query must be a string or TypedArray");
1862
1888
  }
1863
- const chunks = results.map((r) => {
1864
- const meta = r.metadata;
1865
- return meta.text || JSON.stringify(meta);
1866
- });
1867
- const output = {
1868
- chunks,
1869
- chunk_ids: results.map((r) => r.chunk_id),
1870
- metadata: results.map((r) => r.metadata),
1871
- scores: results.map((r) => r.score),
1872
- count: results.length,
1873
- query
1874
- };
1875
- if (returnVectors) {
1876
- output.vectors = results.map((r) => r.vector);
1877
- }
1878
- return output;
1879
- }
1880
- }
1881
- var chunkRetrieval = (input, config) => {
1882
- return new ChunkRetrievalTask(config).run(input);
1883
- };
1884
- Workflow3.prototype.chunkRetrieval = CreateWorkflow3(ChunkRetrievalTask);
1885
-
1886
- // src/task/ChunkToVectorTask.ts
1887
- import { ChunkRecordSchema } from "@workglow/knowledge-base";
1888
- import { CreateWorkflow as CreateWorkflow4, Task as Task3, Workflow as Workflow4 } from "@workglow/task-graph";
1889
- import {
1890
- TypedArraySchema as TypedArraySchema3
1891
- } from "@workglow/util/schema";
1892
- var inputSchema2 = {
1893
- type: "object",
1894
- properties: {
1895
- doc_id: {
1896
- type: "string",
1897
- title: "Document ID",
1898
- description: "The document ID"
1899
- },
1900
- doc_title: {
1901
- type: "string",
1902
- title: "Document Title",
1903
- description: "Human-readable title for the source document"
1904
- },
1905
- chunks: {
1906
- type: "array",
1907
- items: ChunkRecordSchema(),
1908
- title: "Chunks",
1909
- description: "Array of chunk records"
1910
- },
1911
- vector: {
1912
- type: "array",
1913
- items: TypedArraySchema3({
1914
- title: "Vector",
1915
- description: "Vector embedding"
1916
- }),
1917
- title: "Vectors",
1918
- description: "Embeddings from TextEmbeddingTask"
1919
- }
1920
- },
1921
- required: ["chunks", "vector"],
1922
- additionalProperties: false
1923
- };
1924
- var outputSchema2 = {
1925
- type: "object",
1926
- properties: {
1927
- ids: {
1928
- type: "array",
1929
- items: { type: "string" },
1930
- title: "IDs",
1931
- description: "Chunk IDs for vector store"
1932
- },
1933
- vectors: {
1934
- type: "array",
1935
- items: TypedArraySchema3({
1936
- title: "Vector",
1937
- description: "Vector embedding"
1938
- }),
1939
- title: "Vectors",
1940
- description: "Vector embeddings"
1941
- },
1942
- metadata: {
1943
- type: "array",
1944
- items: {
1945
- type: "object",
1946
- title: "Metadata",
1947
- description: "Metadata for vector store"
1948
- },
1949
- title: "Metadata",
1950
- description: "Metadata for each vector"
1951
- },
1952
- texts: {
1953
- type: "array",
1954
- items: { type: "string" },
1955
- title: "Texts",
1956
- description: "Chunk texts (for reference)"
1957
- }
1958
- },
1959
- required: ["ids", "vectors", "metadata", "texts"],
1960
- additionalProperties: false
1961
- };
1962
-
1963
- class ChunkToVectorTask extends Task3 {
1964
- static type = "ChunkToVectorTask";
1965
- static category = "Document";
1966
- static title = "Chunk to Vector";
1967
- static description = "Transform chunks and embeddings to vector store format";
1968
- static cacheable = true;
1969
- static inputSchema() {
1970
- return inputSchema2;
1971
- }
1972
- static outputSchema() {
1973
- return outputSchema2;
1974
- }
1975
- async execute(input, context) {
1976
- const { chunks, vector, doc_title } = input;
1977
- const chunkArray = chunks;
1978
- if (!chunkArray || !vector) {
1979
- throw new Error("Both chunks and vector are required");
1980
- }
1981
- if (chunkArray.length !== vector.length) {
1982
- throw new Error(`Mismatch: ${chunkArray.length} chunks but ${vector.length} vectors`);
1983
- }
1984
- const ids = [];
1985
- const metadata = [];
1986
- const texts = [];
1987
- for (let i = 0;i < chunkArray.length; i++) {
1988
- const chunk = chunkArray[i];
1989
- ids.push(chunk.chunkId);
1990
- texts.push(chunk.text);
1991
- metadata.push({
1992
- doc_id: chunk.doc_id,
1993
- chunkId: chunk.chunkId,
1994
- leafNodeId: chunk.nodePath[chunk.nodePath.length - 1],
1995
- depth: chunk.depth,
1996
- text: chunk.text,
1997
- nodePath: chunk.nodePath,
1998
- ...doc_title ? { doc_title } : {},
1999
- ...chunk.summary ? { summary: chunk.summary } : {},
2000
- ...chunk.entities ? { entities: chunk.entities } : {}
2001
- });
2002
- }
2003
- return {
2004
- ids,
2005
- vectors: vector,
2006
- metadata,
2007
- texts
2008
- };
2009
- }
2010
- }
2011
- var chunkToVector = (input, config) => {
2012
- return new ChunkToVectorTask(config).run(input);
2013
- };
2014
- Workflow4.prototype.chunkToVector = CreateWorkflow4(ChunkToVectorTask);
2015
-
2016
- // src/task/ChunkVectorHybridSearchTask.ts
2017
- import { TypeKnowledgeBase as TypeKnowledgeBase2 } from "@workglow/knowledge-base";
2018
- import { CreateWorkflow as CreateWorkflow5, Task as Task4, Workflow as Workflow5 } from "@workglow/task-graph";
2019
- import {
2020
- TypedArraySchema as TypedArraySchema4
2021
- } from "@workglow/util/schema";
2022
- var inputSchema3 = {
2023
- type: "object",
2024
- properties: {
2025
- knowledgeBase: TypeKnowledgeBase2({
2026
- title: "Knowledge Base",
2027
- description: "The knowledge base instance to search in (must support hybridSearch)"
2028
- }),
2029
- queryVector: TypedArraySchema4({
2030
- title: "Query Vector",
2031
- description: "The query vector for semantic search"
2032
- }),
2033
- queryText: {
2034
- type: "string",
2035
- title: "Query Text",
2036
- description: "The query text for full-text search"
2037
- },
2038
- topK: {
2039
- type: "number",
2040
- title: "Top K",
2041
- description: "Number of top results to return",
2042
- minimum: 1,
2043
- default: 10
2044
- },
2045
- filter: {
2046
- type: "object",
2047
- title: "Metadata Filter",
2048
- description: "Filter results by metadata fields"
2049
- },
2050
- scoreThreshold: {
2051
- type: "number",
2052
- title: "Score Threshold",
2053
- description: "Minimum combined score threshold (0-1)",
2054
- minimum: 0,
2055
- maximum: 1,
2056
- default: 0
2057
- },
2058
- vectorWeight: {
2059
- type: "number",
2060
- title: "Vector Weight",
2061
- description: "Weight for vector similarity (0-1), remainder goes to text relevance",
2062
- minimum: 0,
2063
- maximum: 1,
2064
- default: 0.7
2065
- },
2066
- returnVectors: {
2067
- type: "boolean",
2068
- title: "Return Vectors",
2069
- description: "Whether to return vector embeddings in results",
2070
- default: false
2071
- }
2072
- },
2073
- required: ["knowledgeBase", "queryVector", "queryText"],
2074
- additionalProperties: false
2075
- };
2076
- var outputSchema3 = {
2077
- type: "object",
2078
- properties: {
2079
- chunks: {
2080
- type: "array",
2081
- items: { type: "string" },
2082
- title: "Text Chunks",
2083
- description: "Retrieved text chunks"
2084
- },
2085
- chunk_ids: {
2086
- type: "array",
2087
- items: { type: "string" },
2088
- title: "Chunk IDs",
2089
- description: "IDs of retrieved chunks"
2090
- },
2091
- metadata: {
2092
- type: "array",
2093
- items: {
2094
- type: "object",
2095
- title: "Metadata",
2096
- description: "Metadata of retrieved chunk"
2097
- },
2098
- title: "Metadata",
2099
- description: "Metadata of retrieved chunks"
2100
- },
2101
- scores: {
2102
- type: "array",
2103
- items: { type: "number" },
2104
- title: "Scores",
2105
- description: "Combined relevance scores for each result"
2106
- },
2107
- vectors: {
2108
- type: "array",
2109
- items: TypedArraySchema4({
2110
- title: "Vector",
2111
- description: "Vector embedding"
2112
- }),
2113
- title: "Vectors",
2114
- description: "Vector embeddings (if returnVectors is true)"
2115
- },
2116
- count: {
2117
- type: "number",
2118
- title: "Count",
2119
- description: "Number of results returned"
2120
- },
2121
- query: {
2122
- type: "string",
2123
- title: "Query",
2124
- description: "The text query used for search (pass-through)"
2125
- }
2126
- },
2127
- required: ["chunks", "chunk_ids", "metadata", "scores", "count", "query"],
2128
- additionalProperties: false
2129
- };
2130
-
2131
- class ChunkVectorHybridSearchTask extends Task4 {
2132
- static type = "ChunkVectorHybridSearchTask";
2133
- static category = "RAG";
2134
- static title = "Hybrid Search";
2135
- static description = "Combined vector + full-text search for improved retrieval";
2136
- static cacheable = true;
2137
- static inputSchema() {
2138
- return inputSchema3;
2139
- }
2140
- static outputSchema() {
2141
- return outputSchema3;
2142
- }
2143
- async execute(input, context) {
2144
- const {
2145
- knowledgeBase,
2146
- queryVector,
2147
- queryText,
2148
- topK = 10,
2149
- filter,
2150
- scoreThreshold = 0,
2151
- vectorWeight = 0.7,
2152
- returnVectors = false
2153
- } = input;
2154
- const kb = knowledgeBase;
2155
1889
  const searchVector = queryVector instanceof Float32Array ? queryVector : new Float32Array(queryVector);
2156
- const results = await kb.hybridSearch(searchVector, {
1890
+ const results = method === "hybrid" ? await kb.hybridSearch(searchVector, {
2157
1891
  textQuery: queryText,
2158
1892
  topK,
2159
1893
  filter,
2160
1894
  scoreThreshold,
2161
1895
  vectorWeight
1896
+ }) : await kb.similaritySearch(searchVector, {
1897
+ topK,
1898
+ filter,
1899
+ scoreThreshold
2162
1900
  });
2163
1901
  const chunks = results.map((r) => {
2164
1902
  const meta = r.metadata;
@@ -2170,7 +1908,7 @@ class ChunkVectorHybridSearchTask extends Task4 {
2170
1908
  metadata: results.map((r) => r.metadata),
2171
1909
  scores: results.map((r) => r.score),
2172
1910
  count: results.length,
2173
- query: queryText
1911
+ query
2174
1912
  };
2175
1913
  if (returnVectors) {
2176
1914
  output.vectors = results.map((r) => r.vector);
@@ -2178,163 +1916,39 @@ class ChunkVectorHybridSearchTask extends Task4 {
2178
1916
  return output;
2179
1917
  }
2180
1918
  }
2181
- var hybridSearch = async (input, config) => {
2182
- return new ChunkVectorHybridSearchTask(config).run(input);
2183
- };
2184
- Workflow5.prototype.hybridSearch = CreateWorkflow5(ChunkVectorHybridSearchTask);
2185
-
2186
- // src/task/ChunkVectorSearchTask.ts
2187
- import { TypeKnowledgeBase as TypeKnowledgeBase3 } from "@workglow/knowledge-base";
2188
- import { CreateWorkflow as CreateWorkflow6, Task as Task5, Workflow as Workflow6 } from "@workglow/task-graph";
2189
- import {
2190
- TypedArraySchema as TypedArraySchema5
2191
- } from "@workglow/util/schema";
2192
- var inputSchema4 = {
2193
- type: "object",
2194
- properties: {
2195
- knowledgeBase: TypeKnowledgeBase3({
2196
- title: "Knowledge Base",
2197
- description: "The knowledge base instance to search in"
2198
- }),
2199
- query: TypedArraySchema5({
2200
- title: "Query Vector",
2201
- description: "The query vector to search for similar vectors"
2202
- }),
2203
- topK: {
2204
- type: "number",
2205
- title: "Top K",
2206
- description: "Number of top results to return",
2207
- minimum: 1,
2208
- default: 10
2209
- },
2210
- filter: {
2211
- type: "object",
2212
- title: "Metadata Filter",
2213
- description: "Filter results by metadata fields"
2214
- },
2215
- scoreThreshold: {
2216
- type: "number",
2217
- title: "Score Threshold",
2218
- description: "Minimum similarity score threshold (0-1)",
2219
- minimum: 0,
2220
- maximum: 1,
2221
- default: 0
2222
- }
2223
- },
2224
- required: ["knowledgeBase", "query"],
2225
- additionalProperties: false
2226
- };
2227
- var outputSchema4 = {
2228
- type: "object",
2229
- properties: {
2230
- ids: {
2231
- type: "array",
2232
- items: { type: "string" },
2233
- title: "IDs",
2234
- description: "IDs of matching vectors"
2235
- },
2236
- vectors: {
2237
- type: "array",
2238
- items: TypedArraySchema5({
2239
- title: "Vector",
2240
- description: "Matching vector embedding"
2241
- }),
2242
- title: "Vectors",
2243
- description: "Matching vector embeddings"
2244
- },
2245
- metadata: {
2246
- type: "array",
2247
- items: {
2248
- type: "object",
2249
- title: "Metadata",
2250
- description: "Metadata of matching vector"
2251
- },
2252
- title: "Metadata",
2253
- description: "Metadata of matching vectors"
2254
- },
2255
- scores: {
2256
- type: "array",
2257
- items: { type: "number" },
2258
- title: "Scores",
2259
- description: "Similarity scores for each result"
2260
- },
2261
- count: {
2262
- type: "number",
2263
- title: "Count",
2264
- description: "Number of results returned"
2265
- }
2266
- },
2267
- required: ["ids", "vectors", "metadata", "scores", "count"],
2268
- additionalProperties: false
2269
- };
2270
-
2271
- class ChunkVectorSearchTask extends Task5 {
2272
- static type = "ChunkVectorSearchTask";
2273
- static category = "Vector Store";
2274
- static title = "Vector Store Search";
2275
- static description = "Search for similar vectors in a knowledge base";
2276
- static cacheable = true;
2277
- static inputSchema() {
2278
- return inputSchema4;
2279
- }
2280
- static outputSchema() {
2281
- return outputSchema4;
2282
- }
2283
- async execute(input, _context) {
2284
- const { knowledgeBase, query, topK = 10, filter, scoreThreshold = 0 } = input;
2285
- const kb = knowledgeBase;
2286
- const results = await kb.similaritySearch(query, {
2287
- topK,
2288
- filter,
2289
- scoreThreshold
2290
- });
2291
- return {
2292
- ids: results.map((r) => r.chunk_id),
2293
- vectors: results.map((r) => r.vector),
2294
- metadata: results.map((r) => r.metadata),
2295
- scores: results.map((r) => r.score),
2296
- count: results.length
2297
- };
2298
- }
2299
- }
2300
- var vectorStoreSearch = (input, config) => {
2301
- return new ChunkVectorSearchTask(config).run(input);
1919
+ var chunkRetrieval = (input, config) => {
1920
+ return new ChunkRetrievalTask(config).run(input);
2302
1921
  };
2303
- Workflow6.prototype.vectorStoreSearch = CreateWorkflow6(ChunkVectorSearchTask);
1922
+ Workflow3.prototype.chunkRetrieval = CreateWorkflow3(ChunkRetrievalTask);
2304
1923
 
2305
1924
  // src/task/ChunkVectorUpsertTask.ts
2306
- import { TypeKnowledgeBase as TypeKnowledgeBase4 } from "@workglow/knowledge-base";
2307
- import { CreateWorkflow as CreateWorkflow7, Task as Task6, Workflow as Workflow7 } from "@workglow/task-graph";
1925
+ import { ChunkRecordArraySchema, TypeKnowledgeBase as TypeKnowledgeBase2 } from "@workglow/knowledge-base";
1926
+ import { CreateWorkflow as CreateWorkflow4, Task as Task3, Workflow as Workflow4 } from "@workglow/task-graph";
2308
1927
  import {
2309
- TypedArraySchema as TypedArraySchema6
1928
+ TypedArraySchema as TypedArraySchema3
2310
1929
  } from "@workglow/util/schema";
2311
- var inputSchema5 = {
1930
+ var inputSchema2 = {
2312
1931
  type: "object",
2313
1932
  properties: {
2314
- knowledgeBase: TypeKnowledgeBase4({
1933
+ knowledgeBase: TypeKnowledgeBase2({
2315
1934
  title: "Knowledge Base",
2316
1935
  description: "The knowledge base instance to store vectors in"
2317
1936
  }),
2318
- doc_id: {
2319
- type: "string",
2320
- title: "Document ID",
2321
- description: "The document ID"
2322
- },
2323
- vectors: TypeSingleOrArray(TypedArraySchema6({
1937
+ chunks: ChunkRecordArraySchema,
1938
+ vector: TypeSingleOrArray(TypedArraySchema3({
2324
1939
  title: "Vectors",
2325
- description: "The vector embeddings"
1940
+ description: "The vector embeddings, aligned 1:1 with chunks"
2326
1941
  })),
2327
- metadata: TypeSingleOrArray({
2328
- type: "object",
2329
- title: "Metadata",
2330
- description: "Metadata associated with the vector",
2331
- additionalProperties: true
2332
- })
1942
+ doc_title: {
1943
+ type: "string",
1944
+ title: "Document Title",
1945
+ description: "Optional human-readable title stamped onto each chunk's metadata"
1946
+ }
2333
1947
  },
2334
- required: ["knowledgeBase", "doc_id", "vectors", "metadata"],
1948
+ required: ["knowledgeBase", "chunks", "vector"],
2335
1949
  additionalProperties: false
2336
1950
  };
2337
- var outputSchema5 = {
1951
+ var outputSchema2 = {
2338
1952
  type: "object",
2339
1953
  properties: {
2340
1954
  count: {
@@ -2345,7 +1959,7 @@ var outputSchema5 = {
2345
1959
  doc_id: {
2346
1960
  type: "string",
2347
1961
  title: "Document ID",
2348
- description: "The document ID"
1962
+ description: "The document ID (read from the first chunk)"
2349
1963
  },
2350
1964
  chunk_ids: {
2351
1965
  type: "array",
@@ -2358,74 +1972,69 @@ var outputSchema5 = {
2358
1972
  additionalProperties: false
2359
1973
  };
2360
1974
 
2361
- class ChunkVectorUpsertTask extends Task6 {
1975
+ class ChunkVectorUpsertTask extends Task3 {
2362
1976
  static type = "ChunkVectorUpsertTask";
2363
1977
  static category = "Vector Store";
2364
1978
  static title = "Add to Vector Store";
2365
- static description = "Store vector embeddings with metadata in a knowledge base";
1979
+ static description = "Store chunks + their embeddings in a knowledge base (1:1 aligned)";
2366
1980
  static cacheable = false;
2367
1981
  static inputSchema() {
2368
- return inputSchema5;
1982
+ return inputSchema2;
2369
1983
  }
2370
1984
  static outputSchema() {
2371
- return outputSchema5;
1985
+ return outputSchema2;
2372
1986
  }
2373
1987
  async execute(input, context) {
2374
- const { knowledgeBase, doc_id, vectors, metadata } = input;
2375
- const vectorArray = Array.isArray(vectors) ? vectors : [vectors];
2376
- const metadataArray = Array.isArray(metadata) ? metadata : Array(vectorArray.length).fill(metadata);
1988
+ const { knowledgeBase, chunks, vector, doc_title } = input;
1989
+ const chunkArray = chunks;
1990
+ const vectorArray = Array.isArray(vector) ? vector : [vector];
1991
+ if (chunkArray.length !== vectorArray.length) {
1992
+ throw new Error(`Mismatch: ${chunkArray.length} chunks but ${vectorArray.length} vectors \u2014 they must be 1:1 aligned`);
1993
+ }
1994
+ if (chunkArray.length === 0) {
1995
+ return { doc_id: "", chunk_ids: [], count: 0 };
1996
+ }
2377
1997
  const kb = knowledgeBase;
2378
- await context.updateProgress(1, "Upserting vectors");
2379
- if (vectorArray.length > 1) {
2380
- if (vectorArray.length !== metadataArray.length) {
2381
- throw new Error("Mismatch: vectors and metadata arrays must have the same length");
1998
+ const doc_id = chunkArray[0].doc_id;
1999
+ for (let i = 1;i < chunkArray.length; i++) {
2000
+ if (chunkArray[i].doc_id !== doc_id) {
2001
+ throw new Error(`ChunkVectorUpsertTask expects all chunks to share one doc_id, but chunk[${i}] has doc_id=${JSON.stringify(chunkArray[i].doc_id)} (expected ${JSON.stringify(doc_id)}).`);
2382
2002
  }
2383
- const entities = vectorArray.map((vector, i) => {
2384
- const metadataItem = metadataArray[i];
2385
- return {
2386
- doc_id,
2387
- vector,
2388
- metadata: metadataItem
2389
- };
2390
- });
2391
- const results = await kb.upsertChunksBulk(entities);
2392
- const chunk_ids = results.map((r) => r.chunk_id);
2393
- return {
2394
- doc_id,
2395
- chunk_ids,
2396
- count: chunk_ids.length
2003
+ }
2004
+ await context.updateProgress(1, "Upserting vectors");
2005
+ const entities = chunkArray.map((chunk, i) => {
2006
+ const leafNodeId = chunk.leafNodeId ?? chunk.nodePath[chunk.nodePath.length - 1] ?? undefined;
2007
+ const metadata = {
2008
+ ...chunk,
2009
+ ...leafNodeId !== undefined ? { leafNodeId } : {},
2010
+ ...doc_title ? { doc_title } : {}
2397
2011
  };
2398
- } else if (vectorArray.length === 1) {
2399
- const metadataItem = metadataArray[0];
2400
- const result = await kb.upsertChunk({
2401
- doc_id,
2402
- vector: vectorArray[0],
2403
- metadata: metadataItem
2404
- });
2405
2012
  return {
2406
- doc_id,
2407
- chunk_ids: [result.chunk_id],
2408
- count: 1
2013
+ doc_id: chunk.doc_id,
2014
+ vector: vectorArray[i],
2015
+ metadata
2409
2016
  };
2410
- }
2017
+ });
2018
+ const results = await kb.upsertChunksBulk(entities);
2019
+ const chunk_ids = results.map((r) => r.chunk_id);
2411
2020
  return {
2412
2021
  doc_id,
2413
- chunk_ids: [],
2414
- count: 0
2022
+ chunk_ids,
2023
+ count: chunk_ids.length
2415
2024
  };
2416
2025
  }
2417
2026
  }
2418
2027
  var chunkVectorUpsert = (input, config) => {
2419
2028
  return new ChunkVectorUpsertTask(config).run(input);
2420
2029
  };
2421
- Workflow7.prototype.chunkVectorUpsert = CreateWorkflow7(ChunkVectorUpsertTask);
2030
+ Workflow4.prototype.chunkVectorUpsert = CreateWorkflow4(ChunkVectorUpsertTask);
2422
2031
 
2423
2032
  // src/task/ContextBuilderTask.ts
2424
2033
  import { estimateTokens } from "@workglow/knowledge-base";
2425
- import { CreateWorkflow as CreateWorkflow9, Task as Task7, Workflow as Workflow9 } from "@workglow/task-graph";
2034
+ import { CreateWorkflow as CreateWorkflow6, Task as Task4, Workflow as Workflow6 } from "@workglow/task-graph";
2426
2035
 
2427
2036
  // src/task/CountTokensTask.ts
2428
- import { CreateWorkflow as CreateWorkflow8, Workflow as Workflow8 } from "@workglow/task-graph";
2037
+ import { CreateWorkflow as CreateWorkflow5, Workflow as Workflow5 } from "@workglow/task-graph";
2429
2038
  var modelSchema4 = TypeModel("model");
2430
2039
  var CountTokensInputSchema = {
2431
2040
  type: "object",
@@ -2469,7 +2078,7 @@ class CountTokensTask extends AiTask {
2469
2078
  var countTokens = async (input, config) => {
2470
2079
  return new CountTokensTask(config).run(input);
2471
2080
  };
2472
- Workflow8.prototype.countTokens = CreateWorkflow8(CountTokensTask);
2081
+ Workflow5.prototype.countTokens = CreateWorkflow5(CountTokensTask);
2473
2082
 
2474
2083
  // src/task/ContextBuilderTask.ts
2475
2084
  var ContextFormat = {
@@ -2483,7 +2092,7 @@ var modelSchema5 = TypeModel("model", {
2483
2092
  title: "Model",
2484
2093
  description: "Model to use for token counting (optional, falls back to estimation)"
2485
2094
  });
2486
- var inputSchema6 = {
2095
+ var inputSchema3 = {
2487
2096
  type: "object",
2488
2097
  properties: {
2489
2098
  chunks: {
@@ -2548,7 +2157,7 @@ var inputSchema6 = {
2548
2157
  required: ["chunks"],
2549
2158
  additionalProperties: false
2550
2159
  };
2551
- var outputSchema6 = {
2160
+ var outputSchema3 = {
2552
2161
  type: "object",
2553
2162
  properties: {
2554
2163
  context: {
@@ -2576,17 +2185,17 @@ var outputSchema6 = {
2576
2185
  additionalProperties: false
2577
2186
  };
2578
2187
 
2579
- class ContextBuilderTask extends Task7 {
2188
+ class ContextBuilderTask extends Task4 {
2580
2189
  static type = "ContextBuilderTask";
2581
2190
  static category = "RAG";
2582
2191
  static title = "Context Builder";
2583
2192
  static description = "Format retrieved chunks into context for LLM prompts";
2584
2193
  static cacheable = true;
2585
2194
  static inputSchema() {
2586
- return inputSchema6;
2195
+ return inputSchema3;
2587
2196
  }
2588
2197
  static outputSchema() {
2589
- return outputSchema6;
2198
+ return outputSchema3;
2590
2199
  }
2591
2200
  async executeReactive(input, _output, context) {
2592
2201
  const {
@@ -2769,14 +2378,14 @@ class ContextBuilderTask extends Task7 {
2769
2378
  var contextBuilder = (input, config) => {
2770
2379
  return new ContextBuilderTask(config).run(input);
2771
2380
  };
2772
- Workflow9.prototype.contextBuilder = CreateWorkflow9(ContextBuilderTask);
2381
+ Workflow6.prototype.contextBuilder = CreateWorkflow6(ContextBuilderTask);
2773
2382
 
2774
2383
  // src/task/DocumentEnricherTask.ts
2775
2384
  import { getChildren, hasChildren } from "@workglow/knowledge-base";
2776
- import { CreateWorkflow as CreateWorkflow12, Task as Task8, Workflow as Workflow12 } from "@workglow/task-graph";
2385
+ import { CreateWorkflow as CreateWorkflow9, Task as Task5, Workflow as Workflow9 } from "@workglow/task-graph";
2777
2386
 
2778
2387
  // src/task/TextNamedEntityRecognitionTask.ts
2779
- import { CreateWorkflow as CreateWorkflow10, Workflow as Workflow10 } from "@workglow/task-graph";
2388
+ import { CreateWorkflow as CreateWorkflow7, Workflow as Workflow7 } from "@workglow/task-graph";
2780
2389
  var modelSchema6 = TypeModel("model:TextNamedEntityRecognitionTask");
2781
2390
  var TextNamedEntityRecognitionInputSchema = {
2782
2391
  type: "object",
@@ -2851,10 +2460,10 @@ class TextNamedEntityRecognitionTask extends AiTask {
2851
2460
  var textNamedEntityRecognition = (input, config) => {
2852
2461
  return new TextNamedEntityRecognitionTask(config).run(input);
2853
2462
  };
2854
- Workflow10.prototype.textNamedEntityRecognition = CreateWorkflow10(TextNamedEntityRecognitionTask);
2463
+ Workflow7.prototype.textNamedEntityRecognition = CreateWorkflow7(TextNamedEntityRecognitionTask);
2855
2464
 
2856
2465
  // src/task/TextSummaryTask.ts
2857
- import { CreateWorkflow as CreateWorkflow11, Workflow as Workflow11 } from "@workglow/task-graph";
2466
+ import { CreateWorkflow as CreateWorkflow8, Workflow as Workflow8 } from "@workglow/task-graph";
2858
2467
  var modelSchema7 = TypeModel("model:TextSummaryTask");
2859
2468
  var TextSummaryInputSchema = {
2860
2469
  type: "object",
@@ -2898,10 +2507,10 @@ class TextSummaryTask extends StreamingAiTask {
2898
2507
  var textSummary = async (input, config) => {
2899
2508
  return new TextSummaryTask(config).run(input);
2900
2509
  };
2901
- Workflow11.prototype.textSummary = CreateWorkflow11(TextSummaryTask);
2510
+ Workflow8.prototype.textSummary = CreateWorkflow8(TextSummaryTask);
2902
2511
 
2903
2512
  // src/task/DocumentEnricherTask.ts
2904
- var inputSchema7 = {
2513
+ var inputSchema4 = {
2905
2514
  type: "object",
2906
2515
  properties: {
2907
2516
  doc_id: {
@@ -2945,7 +2554,7 @@ var inputSchema7 = {
2945
2554
  required: [],
2946
2555
  additionalProperties: false
2947
2556
  };
2948
- var outputSchema7 = {
2557
+ var outputSchema4 = {
2949
2558
  type: "object",
2950
2559
  properties: {
2951
2560
  doc_id: {
@@ -2972,17 +2581,17 @@ var outputSchema7 = {
2972
2581
  additionalProperties: false
2973
2582
  };
2974
2583
 
2975
- class DocumentEnricherTask extends Task8 {
2584
+ class DocumentEnricherTask extends Task5 {
2976
2585
  static type = "DocumentEnricherTask";
2977
2586
  static category = "Document";
2978
2587
  static title = "Document Enricher";
2979
2588
  static description = "Enrich document nodes with summaries and entities";
2980
2589
  static cacheable = true;
2981
2590
  static inputSchema() {
2982
- return inputSchema7;
2591
+ return inputSchema4;
2983
2592
  }
2984
2593
  static outputSchema() {
2985
- return outputSchema7;
2594
+ return outputSchema4;
2986
2595
  }
2987
2596
  async execute(input, context) {
2988
2597
  const {
@@ -3131,16 +2740,16 @@ class DocumentEnricherTask extends Task8 {
3131
2740
  var documentEnricher = (input, config) => {
3132
2741
  return new DocumentEnricherTask(config).run(input);
3133
2742
  };
3134
- Workflow12.prototype.documentEnricher = CreateWorkflow12(DocumentEnricherTask);
2743
+ Workflow9.prototype.documentEnricher = CreateWorkflow9(DocumentEnricherTask);
3135
2744
 
3136
2745
  // src/task/DocumentUpsertTask.ts
3137
- import { Document, TypeKnowledgeBase as TypeKnowledgeBase5 } from "@workglow/knowledge-base";
2746
+ import { Document, TypeKnowledgeBase as TypeKnowledgeBase3 } from "@workglow/knowledge-base";
3138
2747
  import { DocumentMetadataSchema } from "@workglow/knowledge-base";
3139
- import { CreateWorkflow as CreateWorkflow13, Task as Task9, Workflow as Workflow13 } from "@workglow/task-graph";
3140
- var inputSchema8 = {
2748
+ import { CreateWorkflow as CreateWorkflow10, Task as Task6, Workflow as Workflow10 } from "@workglow/task-graph";
2749
+ var inputSchema5 = {
3141
2750
  type: "object",
3142
2751
  properties: {
3143
- knowledgeBase: TypeKnowledgeBase5({
2752
+ knowledgeBase: TypeKnowledgeBase3({
3144
2753
  title: "Knowledge Base",
3145
2754
  description: "The knowledge base instance to store the document in"
3146
2755
  }),
@@ -3168,7 +2777,7 @@ var inputSchema8 = {
3168
2777
  required: ["knowledgeBase", "doc_id", "documentTree"],
3169
2778
  additionalProperties: false
3170
2779
  };
3171
- var outputSchema8 = {
2780
+ var outputSchema5 = {
3172
2781
  type: "object",
3173
2782
  properties: {
3174
2783
  doc_id: {
@@ -3181,17 +2790,17 @@ var outputSchema8 = {
3181
2790
  additionalProperties: false
3182
2791
  };
3183
2792
 
3184
- class DocumentUpsertTask extends Task9 {
2793
+ class DocumentUpsertTask extends Task6 {
3185
2794
  static type = "DocumentUpsertTask";
3186
2795
  static category = "Vector Store";
3187
2796
  static title = "Add Document";
3188
2797
  static description = "Persist a parsed document tree to a knowledge base";
3189
2798
  static cacheable = false;
3190
2799
  static inputSchema() {
3191
- return inputSchema8;
2800
+ return inputSchema5;
3192
2801
  }
3193
2802
  static outputSchema() {
3194
- return outputSchema8;
2803
+ return outputSchema5;
3195
2804
  }
3196
2805
  async execute(input, context) {
3197
2806
  const { knowledgeBase, doc_id, documentTree, title, metadata } = input;
@@ -3214,10 +2823,10 @@ class DocumentUpsertTask extends Task9 {
3214
2823
  var documentUpsert = (input, config) => {
3215
2824
  return new DocumentUpsertTask(config).run(input);
3216
2825
  };
3217
- Workflow13.prototype.documentUpsert = CreateWorkflow13(DocumentUpsertTask);
2826
+ Workflow10.prototype.documentUpsert = CreateWorkflow10(DocumentUpsertTask);
3218
2827
 
3219
2828
  // src/task/DownloadModelTask.ts
3220
- import { CreateWorkflow as CreateWorkflow14, Workflow as Workflow14 } from "@workglow/task-graph";
2829
+ import { CreateWorkflow as CreateWorkflow11, Workflow as Workflow11 } from "@workglow/task-graph";
3221
2830
  var modelSchema8 = TypeModel("model");
3222
2831
  var DownloadModelInputSchema = {
3223
2832
  type: "object",
@@ -3284,10 +2893,10 @@ class DownloadModelTask extends AiTask {
3284
2893
  var downloadModel = (input, config) => {
3285
2894
  return new DownloadModelTask(config).run(input);
3286
2895
  };
3287
- Workflow14.prototype.downloadModel = CreateWorkflow14(DownloadModelTask);
2896
+ Workflow11.prototype.downloadModel = CreateWorkflow11(DownloadModelTask);
3288
2897
 
3289
2898
  // src/task/FaceDetectorTask.ts
3290
- import { CreateWorkflow as CreateWorkflow15, Workflow as Workflow15 } from "@workglow/task-graph";
2899
+ import { CreateWorkflow as CreateWorkflow12, Workflow as Workflow12 } from "@workglow/task-graph";
3291
2900
  var modelSchema9 = TypeModel("model:FaceDetectorTask");
3292
2901
  var TypeBoundingBox2 = {
3293
2902
  type: "object",
@@ -3415,10 +3024,10 @@ class FaceDetectorTask extends AiVisionTask {
3415
3024
  var faceDetector = (input, config) => {
3416
3025
  return new FaceDetectorTask(config).run(input);
3417
3026
  };
3418
- Workflow15.prototype.faceDetector = CreateWorkflow15(FaceDetectorTask);
3027
+ Workflow12.prototype.faceDetector = CreateWorkflow12(FaceDetectorTask);
3419
3028
 
3420
3029
  // src/task/FaceLandmarkerTask.ts
3421
- import { CreateWorkflow as CreateWorkflow16, Workflow as Workflow16 } from "@workglow/task-graph";
3030
+ import { CreateWorkflow as CreateWorkflow13, Workflow as Workflow13 } from "@workglow/task-graph";
3422
3031
  var modelSchema10 = TypeModel("model:FaceLandmarkerTask");
3423
3032
  var TypeLandmark = {
3424
3033
  type: "object",
@@ -3577,10 +3186,10 @@ class FaceLandmarkerTask extends AiVisionTask {
3577
3186
  var faceLandmarker = (input, config) => {
3578
3187
  return new FaceLandmarkerTask(config).run(input);
3579
3188
  };
3580
- Workflow16.prototype.faceLandmarker = CreateWorkflow16(FaceLandmarkerTask);
3189
+ Workflow13.prototype.faceLandmarker = CreateWorkflow13(FaceLandmarkerTask);
3581
3190
 
3582
3191
  // src/task/GestureRecognizerTask.ts
3583
- import { CreateWorkflow as CreateWorkflow17, Workflow as Workflow17 } from "@workglow/task-graph";
3192
+ import { CreateWorkflow as CreateWorkflow14, Workflow as Workflow14 } from "@workglow/task-graph";
3584
3193
  var modelSchema11 = TypeModel("model:GestureRecognizerTask");
3585
3194
  var TypeLandmark2 = {
3586
3195
  type: "object",
@@ -3745,10 +3354,10 @@ class GestureRecognizerTask extends AiVisionTask {
3745
3354
  var gestureRecognizer = (input, config) => {
3746
3355
  return new GestureRecognizerTask(config).run(input);
3747
3356
  };
3748
- Workflow17.prototype.gestureRecognizer = CreateWorkflow17(GestureRecognizerTask);
3357
+ Workflow14.prototype.gestureRecognizer = CreateWorkflow14(GestureRecognizerTask);
3749
3358
 
3750
3359
  // src/task/HandLandmarkerTask.ts
3751
- import { CreateWorkflow as CreateWorkflow18, Workflow as Workflow18 } from "@workglow/task-graph";
3360
+ import { CreateWorkflow as CreateWorkflow15, Workflow as Workflow15 } from "@workglow/task-graph";
3752
3361
  var modelSchema12 = TypeModel("model:HandLandmarkerTask");
3753
3362
  var TypeLandmark3 = {
3754
3363
  type: "object",
@@ -3890,22 +3499,22 @@ class HandLandmarkerTask extends AiVisionTask {
3890
3499
  var handLandmarker = (input, config) => {
3891
3500
  return new HandLandmarkerTask(config).run(input);
3892
3501
  };
3893
- Workflow18.prototype.handLandmarker = CreateWorkflow18(HandLandmarkerTask);
3502
+ Workflow15.prototype.handLandmarker = CreateWorkflow15(HandLandmarkerTask);
3894
3503
 
3895
3504
  // src/task/HierarchicalChunkerTask.ts
3896
3505
  import {
3897
- ChunkRecordSchema as ChunkRecordSchema2,
3506
+ ChunkRecordSchema,
3898
3507
  estimateTokens as estimateTokens2,
3899
3508
  getChildren as getChildren2,
3900
3509
  hasChildren as hasChildren2
3901
3510
  } from "@workglow/knowledge-base";
3902
- import { CreateWorkflow as CreateWorkflow19, Task as Task10, Workflow as Workflow19 } from "@workglow/task-graph";
3511
+ import { CreateWorkflow as CreateWorkflow16, Task as Task7, Workflow as Workflow16 } from "@workglow/task-graph";
3903
3512
  import { uuid4 } from "@workglow/util";
3904
3513
  var modelSchema13 = TypeModel("model", {
3905
3514
  title: "Model",
3906
3515
  description: "Model to use for token counting"
3907
3516
  });
3908
- var inputSchema9 = {
3517
+ var inputSchema6 = {
3909
3518
  type: "object",
3910
3519
  properties: {
3911
3520
  doc_id: {
@@ -3952,7 +3561,7 @@ var inputSchema9 = {
3952
3561
  required: ["doc_id", "documentTree"],
3953
3562
  additionalProperties: false
3954
3563
  };
3955
- var outputSchema9 = {
3564
+ var outputSchema6 = {
3956
3565
  type: "object",
3957
3566
  properties: {
3958
3567
  doc_id: {
@@ -3962,7 +3571,7 @@ var outputSchema9 = {
3962
3571
  },
3963
3572
  chunks: {
3964
3573
  type: "array",
3965
- items: ChunkRecordSchema2(),
3574
+ items: ChunkRecordSchema(),
3966
3575
  title: "Chunks",
3967
3576
  description: "Array of chunk records"
3968
3577
  },
@@ -3982,17 +3591,17 @@ var outputSchema9 = {
3982
3591
  additionalProperties: false
3983
3592
  };
3984
3593
 
3985
- class HierarchicalChunkerTask extends Task10 {
3594
+ class HierarchicalChunkerTask extends Task7 {
3986
3595
  static type = "HierarchicalChunkerTask";
3987
3596
  static category = "Document";
3988
3597
  static title = "Hierarchical Chunker";
3989
3598
  static description = "Chunk documents hierarchically respecting token budgets";
3990
3599
  static cacheable = true;
3991
3600
  static inputSchema() {
3992
- return inputSchema9;
3601
+ return inputSchema6;
3993
3602
  }
3994
3603
  static outputSchema() {
3995
- return outputSchema9;
3604
+ return outputSchema6;
3996
3605
  }
3997
3606
  async execute(input, context) {
3998
3607
  const {
@@ -4126,36 +3735,36 @@ class HierarchicalChunkerTask extends Task10 {
4126
3735
  var hierarchicalChunker = (input, config) => {
4127
3736
  return new HierarchicalChunkerTask(config).run(input);
4128
3737
  };
4129
- Workflow19.prototype.hierarchicalChunker = CreateWorkflow19(HierarchicalChunkerTask);
3738
+ Workflow16.prototype.hierarchicalChunker = CreateWorkflow16(HierarchicalChunkerTask);
4130
3739
 
4131
3740
  // src/task/HierarchyJoinTask.ts
4132
- import { ChunkRecordArraySchema, TypeKnowledgeBase as TypeKnowledgeBase6 } from "@workglow/knowledge-base";
4133
- import { CreateWorkflow as CreateWorkflow20, Task as Task11, Workflow as Workflow20 } from "@workglow/task-graph";
4134
- var inputSchema10 = {
3741
+ import { ChunkRecordArraySchema as ChunkRecordArraySchema2, TypeKnowledgeBase as TypeKnowledgeBase4 } from "@workglow/knowledge-base";
3742
+ import { CreateWorkflow as CreateWorkflow17, Task as Task8, Workflow as Workflow17 } from "@workglow/task-graph";
3743
+ var inputSchema7 = {
4135
3744
  type: "object",
4136
3745
  properties: {
4137
- knowledgeBase: TypeKnowledgeBase6({
3746
+ knowledgeBase: TypeKnowledgeBase4({
4138
3747
  title: "Knowledge Base",
4139
3748
  description: "The knowledge base to query for hierarchy"
4140
3749
  }),
3750
+ metadata: ChunkRecordArraySchema2,
4141
3751
  chunks: {
4142
3752
  type: "array",
4143
3753
  items: { type: "string" },
4144
3754
  title: "Chunks",
4145
- description: "Retrieved text chunks"
3755
+ description: "Retrieved text chunks (pass-through)"
4146
3756
  },
4147
3757
  chunk_ids: {
4148
3758
  type: "array",
4149
3759
  items: { type: "string" },
4150
3760
  title: "Chunk IDs",
4151
- description: "IDs of retrieved chunks"
3761
+ description: "IDs of retrieved chunks (pass-through)"
4152
3762
  },
4153
- metadata: ChunkRecordArraySchema,
4154
3763
  scores: {
4155
3764
  type: "array",
4156
3765
  items: { type: "number" },
4157
3766
  title: "Scores",
4158
- description: "Similarity scores for each result"
3767
+ description: "Similarity scores (pass-through)"
4159
3768
  },
4160
3769
  includeParentSummaries: {
4161
3770
  type: "boolean",
@@ -4170,74 +3779,72 @@ var inputSchema10 = {
4170
3779
  default: true
4171
3780
  }
4172
3781
  },
4173
- required: ["knowledgeBase", "chunks", "chunk_ids", "metadata", "scores"],
3782
+ required: ["knowledgeBase", "metadata"],
4174
3783
  additionalProperties: false
4175
3784
  };
4176
- var outputSchema10 = {
3785
+ var outputSchema7 = {
4177
3786
  type: "object",
4178
3787
  properties: {
3788
+ metadata: ChunkRecordArraySchema2,
4179
3789
  chunks: {
4180
3790
  type: "array",
4181
3791
  items: { type: "string" },
4182
3792
  title: "Chunks",
4183
- description: "Retrieved text chunks"
3793
+ description: "Retrieved text chunks (pass-through)"
4184
3794
  },
4185
3795
  chunk_ids: {
4186
3796
  type: "array",
4187
3797
  items: { type: "string" },
4188
3798
  title: "Chunk IDs",
4189
- description: "IDs of retrieved chunks"
3799
+ description: "IDs of retrieved chunks (pass-through)"
4190
3800
  },
4191
- metadata: ChunkRecordArraySchema,
4192
3801
  scores: {
4193
3802
  type: "array",
4194
3803
  items: { type: "number" },
4195
3804
  title: "Scores",
4196
- description: "Similarity scores"
3805
+ description: "Similarity scores (pass-through)"
4197
3806
  },
4198
3807
  count: {
4199
3808
  type: "number",
4200
3809
  title: "Count",
4201
- description: "Number of results"
3810
+ description: "Number of enriched records"
4202
3811
  }
4203
3812
  },
4204
- required: ["chunks", "chunk_ids", "metadata", "scores", "count"],
3813
+ required: ["metadata", "count"],
4205
3814
  additionalProperties: false
4206
3815
  };
4207
3816
 
4208
- class HierarchyJoinTask extends Task11 {
3817
+ class HierarchyJoinTask extends Task8 {
4209
3818
  static type = "HierarchyJoinTask";
4210
3819
  static category = "RAG";
4211
3820
  static title = "Hierarchy Join";
4212
- static description = "Enrich search results with document hierarchy context";
3821
+ static description = "Enrich retrieval metadata with document hierarchy context";
4213
3822
  static cacheable = false;
4214
3823
  static inputSchema() {
4215
- return inputSchema10;
3824
+ return inputSchema7;
4216
3825
  }
4217
3826
  static outputSchema() {
4218
- return outputSchema10;
3827
+ return outputSchema7;
4219
3828
  }
4220
3829
  async execute(input, context) {
4221
3830
  const {
4222
3831
  knowledgeBase,
3832
+ metadata,
4223
3833
  chunks,
4224
3834
  chunk_ids,
4225
- metadata,
4226
3835
  scores,
4227
3836
  includeParentSummaries = true,
4228
3837
  includeEntities = true
4229
3838
  } = input;
4230
3839
  const kb = knowledgeBase;
4231
3840
  const enrichedMetadata = [];
4232
- for (let i = 0;i < chunk_ids.length; i++) {
4233
- const chunkId = chunk_ids[i];
4234
- const originalMetadata = metadata[i];
3841
+ for (const originalMetadata of metadata) {
4235
3842
  if (!originalMetadata) {
4236
3843
  enrichedMetadata.push({});
4237
3844
  continue;
4238
3845
  }
4239
3846
  const doc_id = originalMetadata.doc_id;
4240
- const leafNodeId = originalMetadata.leafNodeId;
3847
+ const leafNodeId = originalMetadata.leafNodeId ?? originalMetadata.nodePath?.[originalMetadata.nodePath.length - 1];
4241
3848
  if (!doc_id || !leafNodeId) {
4242
3849
  enrichedMetadata.push(originalMetadata);
4243
3850
  continue;
@@ -4283,31 +3890,35 @@ class HierarchyJoinTask extends Task11 {
4283
3890
  }
4284
3891
  enrichedMetadata.push(enriched);
4285
3892
  } catch (error) {
4286
- console.error(`Failed to join hierarchy for chunk ${chunkId}:`, error);
3893
+ console.error(`Failed to join hierarchy for chunk ${originalMetadata.chunkId}:`, error);
4287
3894
  enrichedMetadata.push(originalMetadata);
4288
3895
  }
4289
3896
  }
4290
- return {
4291
- chunks,
4292
- chunk_ids,
3897
+ const output = {
4293
3898
  metadata: enrichedMetadata,
4294
- scores,
4295
- count: chunks.length
3899
+ count: enrichedMetadata.length
4296
3900
  };
3901
+ if (chunks !== undefined)
3902
+ output.chunks = chunks;
3903
+ if (chunk_ids !== undefined)
3904
+ output.chunk_ids = chunk_ids;
3905
+ if (scores !== undefined)
3906
+ output.scores = scores;
3907
+ return output;
4297
3908
  }
4298
3909
  }
4299
3910
  var hierarchyJoin = (input, config) => {
4300
3911
  return new HierarchyJoinTask(config).run(input);
4301
3912
  };
4302
- Workflow20.prototype.hierarchyJoin = CreateWorkflow20(HierarchyJoinTask);
3913
+ Workflow17.prototype.hierarchyJoin = CreateWorkflow17(HierarchyJoinTask);
4303
3914
 
4304
3915
  // src/task/KbToDocumentsTask.ts
4305
- import { TypeKnowledgeBase as TypeKnowledgeBase7 } from "@workglow/knowledge-base";
4306
- import { CreateWorkflow as CreateWorkflow21, Task as Task12, Workflow as Workflow21 } from "@workglow/task-graph";
4307
- var inputSchema11 = {
3916
+ import { TypeKnowledgeBase as TypeKnowledgeBase5 } from "@workglow/knowledge-base";
3917
+ import { CreateWorkflow as CreateWorkflow18, Task as Task9, Workflow as Workflow18 } from "@workglow/task-graph";
3918
+ var inputSchema8 = {
4308
3919
  type: "object",
4309
3920
  properties: {
4310
- knowledgeBase: TypeKnowledgeBase7({
3921
+ knowledgeBase: TypeKnowledgeBase5({
4311
3922
  title: "Knowledge Base",
4312
3923
  description: "The knowledge base instance to list documents from"
4313
3924
  }),
@@ -4321,7 +3932,7 @@ var inputSchema11 = {
4321
3932
  required: ["knowledgeBase"],
4322
3933
  additionalProperties: false
4323
3934
  };
4324
- var outputSchema11 = {
3935
+ var outputSchema8 = {
4325
3936
  type: "object",
4326
3937
  properties: {
4327
3938
  doc_id: {
@@ -4347,17 +3958,17 @@ var outputSchema11 = {
4347
3958
  additionalProperties: false
4348
3959
  };
4349
3960
 
4350
- class KbToDocumentsTask extends Task12 {
3961
+ class KbToDocumentsTask extends Task9 {
4351
3962
  static type = "KbToDocumentsTask";
4352
3963
  static category = "Vector Store";
4353
3964
  static title = "Knowledge Base to Documents";
4354
3965
  static description = "List documents from a knowledge base, optionally filtering to only those that need embedding";
4355
3966
  static cacheable = false;
4356
3967
  static inputSchema() {
4357
- return inputSchema11;
3968
+ return inputSchema8;
4358
3969
  }
4359
3970
  static outputSchema() {
4360
- return outputSchema11;
3971
+ return outputSchema8;
4361
3972
  }
4362
3973
  async execute(input, context) {
4363
3974
  const { knowledgeBase, onlyStale = true } = input;
@@ -4388,10 +3999,10 @@ class KbToDocumentsTask extends Task12 {
4388
3999
  var kbToDocuments = (input, config) => {
4389
4000
  return new KbToDocumentsTask(config).run(input);
4390
4001
  };
4391
- Workflow21.prototype.kbToDocuments = CreateWorkflow21(KbToDocumentsTask);
4002
+ Workflow18.prototype.kbToDocuments = CreateWorkflow18(KbToDocumentsTask);
4392
4003
 
4393
4004
  // src/task/ImageClassificationTask.ts
4394
- import { CreateWorkflow as CreateWorkflow22, Workflow as Workflow22 } from "@workglow/task-graph";
4005
+ import { CreateWorkflow as CreateWorkflow19, Workflow as Workflow19 } from "@workglow/task-graph";
4395
4006
  var modelSchema14 = TypeModel("model:ImageClassificationTask");
4396
4007
  var ImageClassificationInputSchema = {
4397
4008
  type: "object",
@@ -4451,12 +4062,12 @@ class ImageClassificationTask extends AiVisionTask {
4451
4062
  var imageClassification = (input, config) => {
4452
4063
  return new ImageClassificationTask(config).run(input);
4453
4064
  };
4454
- Workflow22.prototype.imageClassification = CreateWorkflow22(ImageClassificationTask);
4065
+ Workflow19.prototype.imageClassification = CreateWorkflow19(ImageClassificationTask);
4455
4066
 
4456
4067
  // src/task/ImageEmbeddingTask.ts
4457
- import { CreateWorkflow as CreateWorkflow23, Workflow as Workflow23 } from "@workglow/task-graph";
4068
+ import { CreateWorkflow as CreateWorkflow20, Workflow as Workflow20 } from "@workglow/task-graph";
4458
4069
  import {
4459
- TypedArraySchema as TypedArraySchema7
4070
+ TypedArraySchema as TypedArraySchema4
4460
4071
  } from "@workglow/util/schema";
4461
4072
  var modelSchema15 = TypeModel("model:ImageEmbeddingTask");
4462
4073
  var ImageEmbeddingInputSchema = {
@@ -4471,7 +4082,7 @@ var ImageEmbeddingInputSchema = {
4471
4082
  var ImageEmbeddingOutputSchema = {
4472
4083
  type: "object",
4473
4084
  properties: {
4474
- vector: TypeSingleOrArray(TypedArraySchema7({
4085
+ vector: TypeSingleOrArray(TypedArraySchema4({
4475
4086
  title: "Embedding",
4476
4087
  description: "The image embedding vector"
4477
4088
  }))
@@ -4495,10 +4106,10 @@ class ImageEmbeddingTask extends AiVisionTask {
4495
4106
  var imageEmbedding = (input, config) => {
4496
4107
  return new ImageEmbeddingTask(config).run(input);
4497
4108
  };
4498
- Workflow23.prototype.imageEmbedding = CreateWorkflow23(ImageEmbeddingTask);
4109
+ Workflow20.prototype.imageEmbedding = CreateWorkflow20(ImageEmbeddingTask);
4499
4110
 
4500
4111
  // src/task/ImageSegmentationTask.ts
4501
- import { CreateWorkflow as CreateWorkflow24, Workflow as Workflow24 } from "@workglow/task-graph";
4112
+ import { CreateWorkflow as CreateWorkflow21, Workflow as Workflow21 } from "@workglow/task-graph";
4502
4113
  var modelSchema16 = TypeModel("model:ImageSegmentationTask");
4503
4114
  var ImageSegmentationInputSchema = {
4504
4115
  type: "object",
@@ -4583,10 +4194,10 @@ class ImageSegmentationTask extends AiVisionTask {
4583
4194
  var imageSegmentation = (input, config) => {
4584
4195
  return new ImageSegmentationTask(config).run(input);
4585
4196
  };
4586
- Workflow24.prototype.imageSegmentation = CreateWorkflow24(ImageSegmentationTask);
4197
+ Workflow21.prototype.imageSegmentation = CreateWorkflow21(ImageSegmentationTask);
4587
4198
 
4588
4199
  // src/task/ImageToTextTask.ts
4589
- import { CreateWorkflow as CreateWorkflow25, Workflow as Workflow25 } from "@workglow/task-graph";
4200
+ import { CreateWorkflow as CreateWorkflow22, Workflow as Workflow22 } from "@workglow/task-graph";
4590
4201
  var modelSchema17 = TypeModel("model:ImageToTextTask");
4591
4202
  var generatedTextSchema = {
4592
4203
  type: "string",
@@ -4638,10 +4249,10 @@ class ImageToTextTask extends AiVisionTask {
4638
4249
  var imageToText = (input, config) => {
4639
4250
  return new ImageToTextTask(config).run(input);
4640
4251
  };
4641
- Workflow25.prototype.imageToText = CreateWorkflow25(ImageToTextTask);
4252
+ Workflow22.prototype.imageToText = CreateWorkflow22(ImageToTextTask);
4642
4253
 
4643
4254
  // src/task/ModelInfoTask.ts
4644
- import { CreateWorkflow as CreateWorkflow26, Workflow as Workflow26 } from "@workglow/task-graph";
4255
+ import { CreateWorkflow as CreateWorkflow23, Workflow as Workflow23 } from "@workglow/task-graph";
4645
4256
  var modelSchema18 = TypeModel("model");
4646
4257
  var ModelInfoInputSchema = {
4647
4258
  type: "object",
@@ -4717,10 +4328,10 @@ class ModelInfoTask extends AiTask {
4717
4328
  var modelInfo = (input, config) => {
4718
4329
  return new ModelInfoTask(config).run(input);
4719
4330
  };
4720
- Workflow26.prototype.modelInfo = CreateWorkflow26(ModelInfoTask);
4331
+ Workflow23.prototype.modelInfo = CreateWorkflow23(ModelInfoTask);
4721
4332
 
4722
4333
  // src/task/ModelSearchTask.ts
4723
- import { CreateWorkflow as CreateWorkflow27, Task as Task13, Workflow as Workflow27 } from "@workglow/task-graph";
4334
+ import { CreateWorkflow as CreateWorkflow24, Task as Task10, Workflow as Workflow24 } from "@workglow/task-graph";
4724
4335
  var ModelSearchInputSchema = {
4725
4336
  type: "object",
4726
4337
  properties: {
@@ -4785,7 +4396,7 @@ var ModelSearchOutputSchema = {
4785
4396
  additionalProperties: false
4786
4397
  };
4787
4398
 
4788
- class ModelSearchTask extends Task13 {
4399
+ class ModelSearchTask extends Task10 {
4789
4400
  static type = "ModelSearchTask";
4790
4401
  static category = "AI Model";
4791
4402
  static title = "Model Search";
@@ -4811,10 +4422,10 @@ class ModelSearchTask extends Task13 {
4811
4422
  var modelSearch = (input, config) => {
4812
4423
  return new ModelSearchTask(config).run(input);
4813
4424
  };
4814
- Workflow27.prototype.modelSearch = CreateWorkflow27(ModelSearchTask);
4425
+ Workflow24.prototype.modelSearch = CreateWorkflow24(ModelSearchTask);
4815
4426
 
4816
4427
  // src/task/ObjectDetectionTask.ts
4817
- import { CreateWorkflow as CreateWorkflow28, Workflow as Workflow28 } from "@workglow/task-graph";
4428
+ import { CreateWorkflow as CreateWorkflow25, Workflow as Workflow25 } from "@workglow/task-graph";
4818
4429
  var modelSchema19 = TypeModel("model:ObjectDetectionTask");
4819
4430
  var detectionSchema = {
4820
4431
  type: "object",
@@ -4894,10 +4505,10 @@ class ObjectDetectionTask extends AiVisionTask {
4894
4505
  var objectDetection = (input, config) => {
4895
4506
  return new ObjectDetectionTask(config).run(input);
4896
4507
  };
4897
- Workflow28.prototype.objectDetection = CreateWorkflow28(ObjectDetectionTask);
4508
+ Workflow25.prototype.objectDetection = CreateWorkflow25(ObjectDetectionTask);
4898
4509
 
4899
4510
  // src/task/PoseLandmarkerTask.ts
4900
- import { CreateWorkflow as CreateWorkflow29, Workflow as Workflow29 } from "@workglow/task-graph";
4511
+ import { CreateWorkflow as CreateWorkflow26, Workflow as Workflow26 } from "@workglow/task-graph";
4901
4512
  var modelSchema20 = TypeModel("model:PoseLandmarkerTask");
4902
4513
  var TypePoseLandmark = {
4903
4514
  type: "object",
@@ -5056,17 +4667,15 @@ class PoseLandmarkerTask extends AiVisionTask {
5056
4667
  var poseLandmarker = (input, config) => {
5057
4668
  return new PoseLandmarkerTask(config).run(input);
5058
4669
  };
5059
- Workflow29.prototype.poseLandmarker = CreateWorkflow29(PoseLandmarkerTask);
4670
+ Workflow26.prototype.poseLandmarker = CreateWorkflow26(PoseLandmarkerTask);
5060
4671
 
5061
4672
  // src/task/QueryExpanderTask.ts
5062
- import { CreateWorkflow as CreateWorkflow30, Task as Task14, Workflow as Workflow30 } from "@workglow/task-graph";
4673
+ import { CreateWorkflow as CreateWorkflow27, Task as Task11, Workflow as Workflow27 } from "@workglow/task-graph";
5063
4674
  var QueryExpansionMethod = {
5064
4675
  MULTI_QUERY: "multi-query",
5065
- HYDE: "hyde",
5066
- SYNONYMS: "synonyms",
5067
- PARAPHRASE: "paraphrase"
4676
+ SYNONYMS: "synonyms"
5068
4677
  };
5069
- var inputSchema12 = {
4678
+ var inputSchema9 = {
5070
4679
  type: "object",
5071
4680
  properties: {
5072
4681
  query: {
@@ -5088,17 +4697,12 @@ var inputSchema12 = {
5088
4697
  minimum: 1,
5089
4698
  maximum: 10,
5090
4699
  default: 3
5091
- },
5092
- model: {
5093
- type: "string",
5094
- title: "Model",
5095
- description: "LLM model to use for expansion (for HyDE and paraphrase methods)"
5096
4700
  }
5097
4701
  },
5098
4702
  required: ["query"],
5099
4703
  additionalProperties: false
5100
4704
  };
5101
- var outputSchema12 = {
4705
+ var outputSchema9 = {
5102
4706
  type: "object",
5103
4707
  properties: {
5104
4708
  query: {
@@ -5127,31 +4731,25 @@ var outputSchema12 = {
5127
4731
  additionalProperties: false
5128
4732
  };
5129
4733
 
5130
- class QueryExpanderTask extends Task14 {
4734
+ class QueryExpanderTask extends Task11 {
5131
4735
  static type = "QueryExpanderTask";
5132
4736
  static category = "RAG";
5133
4737
  static title = "Query Expander";
5134
4738
  static description = "Expand queries to improve retrieval coverage";
5135
4739
  static cacheable = true;
5136
4740
  static inputSchema() {
5137
- return inputSchema12;
4741
+ return inputSchema9;
5138
4742
  }
5139
4743
  static outputSchema() {
5140
- return outputSchema12;
4744
+ return outputSchema9;
5141
4745
  }
5142
4746
  async execute(input, context) {
5143
4747
  const { query, method = QueryExpansionMethod.MULTI_QUERY, numVariations = 3 } = input;
5144
4748
  let queries;
5145
4749
  switch (method) {
5146
- case QueryExpansionMethod.HYDE:
5147
- queries = this.hydeExpansion(query, numVariations);
5148
- break;
5149
4750
  case QueryExpansionMethod.SYNONYMS:
5150
4751
  queries = this.synonymExpansion(query, numVariations);
5151
4752
  break;
5152
- case QueryExpansionMethod.PARAPHRASE:
5153
- queries = this.paraphraseExpansion(query, numVariations);
5154
- break;
5155
4753
  case QueryExpansionMethod.MULTI_QUERY:
5156
4754
  default:
5157
4755
  queries = this.multiQueryExpansion(query, numVariations);
@@ -5187,176 +4785,66 @@ class QueryExpanderTask extends Task14 {
5187
4785
  variations.push(`Tell me about ${query.toLowerCase()}`);
5188
4786
  }
5189
4787
  if (!query.toLowerCase().startsWith("explain")) {
5190
- variations.push(`Explain ${query.toLowerCase()}`);
5191
- }
5192
- for (let i = 0;i < Math.min(numVariations - 1, variations.length); i++) {
5193
- if (variations[i] && !queries.includes(variations[i])) {
5194
- queries.push(variations[i]);
5195
- }
5196
- }
5197
- return queries;
5198
- }
5199
- hydeExpansion(query, numVariations) {
5200
- const queries = [query];
5201
- const templates = [
5202
- `The answer to "${query}" is that`,
5203
- `Regarding ${query}, it is important to note that`,
5204
- `${query} can be explained by the fact that`,
5205
- `In response to ${query}, one should consider that`
5206
- ];
5207
- for (let i = 0;i < Math.min(numVariations - 1, templates.length); i++) {
5208
- queries.push(templates[i]);
5209
- }
5210
- return queries;
5211
- }
5212
- synonymExpansion(query, numVariations) {
5213
- const queries = [query];
5214
- const synonyms = {
5215
- find: ["locate", "discover", "search for"],
5216
- create: ["make", "build", "generate"],
5217
- delete: ["remove", "erase", "eliminate"],
5218
- update: ["modify", "change", "edit"],
5219
- show: ["display", "present", "reveal"],
5220
- explain: ["describe", "clarify", "elaborate"],
5221
- help: ["assist", "aid", "support"],
5222
- problem: ["issue", "challenge", "difficulty"],
5223
- solution: ["answer", "resolution", "fix"],
5224
- method: ["approach", "technique", "way"]
5225
- };
5226
- const words = query.toLowerCase().split(/\s+/);
5227
- let variationsGenerated = 0;
5228
- for (const [word, syns] of Object.entries(synonyms)) {
5229
- if (variationsGenerated >= numVariations - 1)
5230
- break;
5231
- const wordIndex = words.indexOf(word);
5232
- if (wordIndex !== -1) {
5233
- for (const syn of syns) {
5234
- if (variationsGenerated >= numVariations - 1)
5235
- break;
5236
- const newWords = [...words];
5237
- newWords[wordIndex] = syn;
5238
- const newQuery = newWords.join(" ");
5239
- const capitalizedQuery = this.preserveCapitalization(query, newQuery);
5240
- if (!queries.includes(capitalizedQuery)) {
5241
- queries.push(capitalizedQuery);
5242
- variationsGenerated++;
5243
- }
5244
- }
5245
- }
5246
- }
5247
- return queries;
5248
- }
5249
- paraphraseExpansion(query, numVariations) {
5250
- const queries = [query];
5251
- const paraphrases = [];
5252
- paraphrases.push(`I need information about ${query.toLowerCase()}`);
5253
- paraphrases.push(`Can you help me understand ${query.toLowerCase()}`);
5254
- paraphrases.push(`I'm looking for details on ${query.toLowerCase()}`);
5255
- for (let i = 0;i < Math.min(numVariations - 1, paraphrases.length); i++) {
5256
- if (!queries.includes(paraphrases[i])) {
5257
- queries.push(paraphrases[i]);
5258
- }
5259
- }
5260
- return queries;
5261
- }
5262
- preserveCapitalization(original, modified) {
5263
- if (original[0] === original[0].toUpperCase()) {
5264
- return modified.charAt(0).toUpperCase() + modified.slice(1);
5265
- }
5266
- return modified;
5267
- }
5268
- }
5269
- var queryExpander = (input, config) => {
5270
- return new QueryExpanderTask(config).run(input);
5271
- };
5272
- Workflow30.prototype.queryExpander = CreateWorkflow30(QueryExpanderTask);
5273
-
5274
- // src/task/RerankerTask.ts
5275
- import { CreateWorkflow as CreateWorkflow32, Task as Task15, Workflow as Workflow32 } from "@workglow/task-graph";
5276
-
5277
- // src/task/TextClassificationTask.ts
5278
- import { CreateWorkflow as CreateWorkflow31, Workflow as Workflow31 } from "@workglow/task-graph";
5279
- var modelSchema21 = TypeModel("model:TextClassificationTask");
5280
- var TextClassificationInputSchema = {
5281
- type: "object",
5282
- properties: {
5283
- text: {
5284
- type: "string",
5285
- title: "Text",
5286
- description: "The text to classify"
5287
- },
5288
- candidateLabels: {
5289
- type: "array",
5290
- items: {
5291
- type: "string"
5292
- },
5293
- title: "Candidate Labels",
5294
- description: "List of candidate labels (optional, if provided uses zero-shot classification)",
5295
- "x-ui-group": "Configuration"
5296
- },
5297
- maxCategories: {
5298
- type: "number",
5299
- minimum: 1,
5300
- maximum: 1000,
5301
- default: 5,
5302
- title: "Max Categories",
5303
- description: "The maximum number of categories to return",
5304
- "x-ui-group": "Configuration"
5305
- },
5306
- model: modelSchema21
5307
- },
5308
- required: ["text", "model"],
5309
- additionalProperties: false
5310
- };
5311
- var TextClassificationOutputSchema = {
5312
- type: "object",
5313
- properties: {
5314
- categories: {
5315
- type: "array",
5316
- items: {
5317
- type: "object",
5318
- properties: {
5319
- label: {
5320
- type: "string",
5321
- title: "Label",
5322
- description: "The name of the category"
5323
- },
5324
- score: {
5325
- type: "number",
5326
- title: "Score",
5327
- description: "The confidence score for this category"
4788
+ variations.push(`Explain ${query.toLowerCase()}`);
4789
+ }
4790
+ for (let i = 0;i < Math.min(numVariations - 1, variations.length); i++) {
4791
+ if (variations[i] && !queries.includes(variations[i])) {
4792
+ queries.push(variations[i]);
4793
+ }
4794
+ }
4795
+ return queries;
4796
+ }
4797
+ synonymExpansion(query, numVariations) {
4798
+ const queries = [query];
4799
+ const synonyms = {
4800
+ find: ["locate", "discover", "search for"],
4801
+ create: ["make", "build", "generate"],
4802
+ delete: ["remove", "erase", "eliminate"],
4803
+ update: ["modify", "change", "edit"],
4804
+ show: ["display", "present", "reveal"],
4805
+ explain: ["describe", "clarify", "elaborate"],
4806
+ help: ["assist", "aid", "support"],
4807
+ problem: ["issue", "challenge", "difficulty"],
4808
+ solution: ["answer", "resolution", "fix"],
4809
+ method: ["approach", "technique", "way"]
4810
+ };
4811
+ const words = query.toLowerCase().split(/\s+/);
4812
+ let variationsGenerated = 0;
4813
+ for (const [word, syns] of Object.entries(synonyms)) {
4814
+ if (variationsGenerated >= numVariations - 1)
4815
+ break;
4816
+ const wordIndex = words.indexOf(word);
4817
+ if (wordIndex !== -1) {
4818
+ for (const syn of syns) {
4819
+ if (variationsGenerated >= numVariations - 1)
4820
+ break;
4821
+ const newWords = [...words];
4822
+ newWords[wordIndex] = syn;
4823
+ const capitalizedQuery = this.preserveCapitalization(query, newWords.join(" "));
4824
+ if (!queries.includes(capitalizedQuery)) {
4825
+ queries.push(capitalizedQuery);
4826
+ variationsGenerated++;
5328
4827
  }
5329
- },
5330
- required: ["label", "score"],
5331
- additionalProperties: false
5332
- },
5333
- title: "Categories",
5334
- description: "The classification categories with their scores"
4828
+ }
4829
+ }
5335
4830
  }
5336
- },
5337
- required: ["categories"],
5338
- additionalProperties: false
5339
- };
5340
-
5341
- class TextClassificationTask extends AiTask {
5342
- static type = "TextClassificationTask";
5343
- static category = "AI Text Model";
5344
- static title = "Text Classifier";
5345
- static description = "Classifies text into categories using language models. Supports zero-shot classification when candidate labels are provided.";
5346
- static inputSchema() {
5347
- return TextClassificationInputSchema;
4831
+ return queries;
5348
4832
  }
5349
- static outputSchema() {
5350
- return TextClassificationOutputSchema;
4833
+ preserveCapitalization(original, modified) {
4834
+ if (original[0] === original[0].toUpperCase()) {
4835
+ return modified.charAt(0).toUpperCase() + modified.slice(1);
4836
+ }
4837
+ return modified;
5351
4838
  }
5352
4839
  }
5353
- var textClassification = (input, config) => {
5354
- return new TextClassificationTask(config).run(input);
4840
+ var queryExpander = (input, config) => {
4841
+ return new QueryExpanderTask(config).run(input);
5355
4842
  };
5356
- Workflow31.prototype.textClassification = CreateWorkflow31(TextClassificationTask);
4843
+ Workflow27.prototype.queryExpander = CreateWorkflow27(QueryExpanderTask);
5357
4844
 
5358
4845
  // src/task/RerankerTask.ts
5359
- var inputSchema13 = {
4846
+ import { CreateWorkflow as CreateWorkflow28, Task as Task12, Workflow as Workflow28 } from "@workglow/task-graph";
4847
+ var inputSchema10 = {
5360
4848
  type: "object",
5361
4849
  properties: {
5362
4850
  query: {
@@ -5394,20 +4882,16 @@ var inputSchema13 = {
5394
4882
  },
5395
4883
  method: {
5396
4884
  type: "string",
5397
- enum: ["cross-encoder", "reciprocal-rank-fusion", "simple"],
4885
+ enum: ["reciprocal-rank-fusion", "simple"],
5398
4886
  title: "Reranking Method",
5399
4887
  description: "Method to use for reranking",
5400
4888
  default: "simple"
5401
- },
5402
- model: TypeModel("model:RerankerTask", {
5403
- title: "Reranker Model",
5404
- description: "Cross-encoder model to use for reranking"
5405
- })
4889
+ }
5406
4890
  },
5407
4891
  required: ["query", "chunks"],
5408
4892
  additionalProperties: false
5409
4893
  };
5410
- var outputSchema13 = {
4894
+ var outputSchema10 = {
5411
4895
  type: "object",
5412
4896
  properties: {
5413
4897
  chunks: {
@@ -5448,28 +4932,22 @@ var outputSchema13 = {
5448
4932
  additionalProperties: false
5449
4933
  };
5450
4934
 
5451
- class RerankerTask extends Task15 {
4935
+ class RerankerTask extends Task12 {
5452
4936
  static type = "RerankerTask";
5453
4937
  static category = "RAG";
5454
4938
  static title = "Reranker";
5455
4939
  static description = "Rerank retrieved chunks to improve relevance";
5456
4940
  static cacheable = true;
5457
4941
  static inputSchema() {
5458
- return inputSchema13;
4942
+ return inputSchema10;
5459
4943
  }
5460
4944
  static outputSchema() {
5461
- return outputSchema13;
4945
+ return outputSchema10;
5462
4946
  }
5463
4947
  async execute(input, context) {
5464
- const { query, chunks, scores = [], metadata = [], topK, method = "simple", model } = input;
4948
+ const { query, chunks, scores = [], metadata = [], topK, method = "simple" } = input;
5465
4949
  let rankedItems;
5466
4950
  switch (method) {
5467
- case "cross-encoder":
5468
- if (!model) {
5469
- throw new Error("No cross-encoder model found. Please provide a model with format 'model:RerankerTask'.");
5470
- }
5471
- rankedItems = await this.crossEncoderRerank(query, chunks, scores, metadata, model, context);
5472
- break;
5473
4951
  case "reciprocal-rank-fusion":
5474
4952
  rankedItems = this.reciprocalRankFusion(chunks, scores, metadata);
5475
4953
  break;
@@ -5489,44 +4967,6 @@ class RerankerTask extends Task15 {
5489
4967
  count: rankedItems.length
5490
4968
  };
5491
4969
  }
5492
- async crossEncoderRerank(query, chunks, scores, metadata, model, context) {
5493
- if (chunks.length === 0) {
5494
- return [];
5495
- }
5496
- if (!model) {
5497
- throw new Error("No cross-encoder model found. Please provide a model or register a TextClassificationTask model.");
5498
- }
5499
- const items = await Promise.all(chunks.map(async (chunk, index) => {
5500
- const pairText = `${query} [SEP] ${chunk}`;
5501
- const task = context.own(new TextClassificationTask({ defaults: { model } }));
5502
- const result = await task.run({ text: pairText, maxCategories: 2 });
5503
- const crossScore = this.extractCrossEncoderScore(result.categories);
5504
- return {
5505
- chunk,
5506
- score: Number.isFinite(crossScore) ? crossScore : scores[index] || 0,
5507
- metadata: metadata[index],
5508
- originalIndex: index
5509
- };
5510
- }));
5511
- items.sort((a, b) => b.score - a.score);
5512
- return items;
5513
- }
5514
- extractCrossEncoderScore(categories) {
5515
- if (!categories || categories.length === 0) {
5516
- return 0;
5517
- }
5518
- const preferred = categories.find((category) => /^(label_1|positive|relevant|yes|true)$/i.test(category.label));
5519
- if (preferred) {
5520
- return preferred.score;
5521
- }
5522
- let best = categories[0].score;
5523
- for (let i = 1;i < categories.length; i++) {
5524
- if (categories[i].score > best) {
5525
- best = categories[i].score;
5526
- }
5527
- }
5528
- return best;
5529
- }
5530
4970
  simpleRerank(query, chunks, scores, metadata) {
5531
4971
  const queryLower = query.toLowerCase();
5532
4972
  const queryWords = queryLower.split(/\s+/).filter((w) => w.length > 0);
@@ -5534,7 +4974,6 @@ class RerankerTask extends Task15 {
5534
4974
  const chunkLower = chunk.toLowerCase();
5535
4975
  const initialScore = scores[index] || 0;
5536
4976
  let keywordScore = 0;
5537
- let exactMatchBonus = 0;
5538
4977
  for (const word of queryWords) {
5539
4978
  const regex = new RegExp(word, "gi");
5540
4979
  const matches = chunkLower.match(regex);
@@ -5542,33 +4981,23 @@ class RerankerTask extends Task15 {
5542
4981
  keywordScore += matches.length;
5543
4982
  }
5544
4983
  }
5545
- if (chunkLower.includes(queryLower)) {
5546
- exactMatchBonus = 0.5;
5547
- }
4984
+ const exactMatchBonus = chunkLower.includes(queryLower) ? 0.5 : 0;
5548
4985
  const normalizedKeywordScore = Math.min(keywordScore / (queryWords.length * 3), 1);
5549
4986
  const positionPenalty = Math.log(index + 1) / 10;
5550
4987
  const combinedScore = initialScore * 0.4 + normalizedKeywordScore * 0.4 + exactMatchBonus * 0.2 - positionPenalty;
5551
- return {
5552
- chunk,
5553
- score: combinedScore,
5554
- metadata: metadata[index],
5555
- originalIndex: index
5556
- };
4988
+ return { chunk, score: combinedScore, metadata: metadata[index], originalIndex: index };
5557
4989
  });
5558
4990
  items.sort((a, b) => b.score - a.score);
5559
4991
  return items;
5560
4992
  }
5561
4993
  reciprocalRankFusion(chunks, scores, metadata) {
5562
4994
  const k = 60;
5563
- const items = chunks.map((chunk, index) => {
5564
- const rrfScore = 1 / (k + index + 1);
5565
- return {
5566
- chunk,
5567
- score: rrfScore,
5568
- metadata: metadata[index],
5569
- originalIndex: index
5570
- };
5571
- });
4995
+ const items = chunks.map((chunk, index) => ({
4996
+ chunk,
4997
+ score: 1 / (k + index + 1),
4998
+ metadata: metadata[index],
4999
+ originalIndex: index
5000
+ }));
5572
5001
  items.sort((a, b) => b.score - a.score);
5573
5002
  return items;
5574
5003
  }
@@ -5576,13 +5005,13 @@ class RerankerTask extends Task15 {
5576
5005
  var reranker = (input, config) => {
5577
5006
  return new RerankerTask(config).run(input);
5578
5007
  };
5579
- Workflow32.prototype.reranker = CreateWorkflow32(RerankerTask);
5008
+ Workflow28.prototype.reranker = CreateWorkflow28(RerankerTask);
5580
5009
 
5581
5010
  // src/task/StructuralParserTask.ts
5582
5011
  import { StructuralParser } from "@workglow/knowledge-base";
5583
- import { CreateWorkflow as CreateWorkflow33, Task as Task16, Workflow as Workflow33 } from "@workglow/task-graph";
5012
+ import { CreateWorkflow as CreateWorkflow29, Task as Task13, Workflow as Workflow29 } from "@workglow/task-graph";
5584
5013
  import { uuid4 as uuid42 } from "@workglow/util";
5585
- var inputSchema14 = {
5014
+ var inputSchema11 = {
5586
5015
  type: "object",
5587
5016
  properties: {
5588
5017
  text: {
@@ -5616,7 +5045,7 @@ var inputSchema14 = {
5616
5045
  required: ["text", "title"],
5617
5046
  additionalProperties: false
5618
5047
  };
5619
- var outputSchema14 = {
5048
+ var outputSchema11 = {
5620
5049
  type: "object",
5621
5050
  properties: {
5622
5051
  doc_id: {
@@ -5640,17 +5069,17 @@ var outputSchema14 = {
5640
5069
  additionalProperties: false
5641
5070
  };
5642
5071
 
5643
- class StructuralParserTask extends Task16 {
5072
+ class StructuralParserTask extends Task13 {
5644
5073
  static type = "StructuralParserTask";
5645
5074
  static category = "Document";
5646
5075
  static title = "Structural Parser";
5647
5076
  static description = "Parse documents into hierarchical tree structure";
5648
5077
  static cacheable = true;
5649
5078
  static inputSchema() {
5650
- return inputSchema14;
5079
+ return inputSchema11;
5651
5080
  }
5652
5081
  static outputSchema() {
5653
- return outputSchema14;
5082
+ return outputSchema11;
5654
5083
  }
5655
5084
  async execute(input, context) {
5656
5085
  const { text, title, format = "auto", sourceUri, doc_id: providedDocId } = input;
@@ -5683,16 +5112,16 @@ class StructuralParserTask extends Task16 {
5683
5112
  var structuralParser = (input, config) => {
5684
5113
  return new StructuralParserTask(config).run(input);
5685
5114
  };
5686
- Workflow33.prototype.structuralParser = CreateWorkflow33(StructuralParserTask);
5115
+ Workflow29.prototype.structuralParser = CreateWorkflow29(StructuralParserTask);
5687
5116
 
5688
5117
  // src/task/StructuredGenerationTask.ts
5689
- import { CreateWorkflow as CreateWorkflow34, TaskConfigurationError as TaskConfigurationError4, TaskError, Workflow as Workflow34 } from "@workglow/task-graph";
5118
+ import { CreateWorkflow as CreateWorkflow30, TaskConfigurationError as TaskConfigurationError4, TaskError, Workflow as Workflow30 } from "@workglow/task-graph";
5690
5119
  import { compileSchema as compileSchema2 } from "@workglow/util/schema";
5691
- var modelSchema22 = TypeModel("model:StructuredGenerationTask");
5120
+ var modelSchema21 = TypeModel("model:StructuredGenerationTask");
5692
5121
  var StructuredGenerationInputSchema = {
5693
5122
  type: "object",
5694
5123
  properties: {
5695
- model: modelSchema22,
5124
+ model: modelSchema21,
5696
5125
  prompt: {
5697
5126
  type: "string",
5698
5127
  title: "Prompt",
@@ -5788,6 +5217,8 @@ class StructuredGenerationTask extends StreamingAiTask {
5788
5217
  let validator;
5789
5218
  try {
5790
5219
  validator = compileSchema2(input.outputSchema);
5220
+ if (!input.outputSchema)
5221
+ throw new Error("outputSchema is not a valid JSON Schema");
5791
5222
  } catch (err2) {
5792
5223
  const msg = err2 instanceof Error ? err2.message : String(err2);
5793
5224
  const configErr = new TaskConfigurationError4(`StructuredGenerationTask: invalid outputSchema \u2014 ${msg}`);
@@ -5858,17 +5289,18 @@ class StructuredGenerationTask extends StreamingAiTask {
5858
5289
  var structuredGeneration = (input, config) => {
5859
5290
  return new StructuredGenerationTask(config).run(input);
5860
5291
  };
5861
- Workflow34.prototype.structuredGeneration = CreateWorkflow34(StructuredGenerationTask);
5292
+ Workflow30.prototype.structuredGeneration = CreateWorkflow30(StructuredGenerationTask);
5862
5293
 
5863
5294
  // src/task/TextChunkerTask.ts
5864
- import { CreateWorkflow as CreateWorkflow35, Task as Task17, Workflow as Workflow35 } from "@workglow/task-graph";
5295
+ import { ChunkRecordArraySchema as ChunkRecordArraySchema3 } from "@workglow/knowledge-base";
5296
+ import { CreateWorkflow as CreateWorkflow31, Task as Task14, Workflow as Workflow31 } from "@workglow/task-graph";
5865
5297
  var ChunkingStrategy = {
5866
5298
  FIXED: "fixed",
5867
5299
  SENTENCE: "sentence",
5868
5300
  PARAGRAPH: "paragraph",
5869
5301
  SEMANTIC: "semantic"
5870
5302
  };
5871
- var inputSchema15 = {
5303
+ var inputSchema12 = {
5872
5304
  type: "object",
5873
5305
  properties: {
5874
5306
  text: {
@@ -5876,6 +5308,11 @@ var inputSchema15 = {
5876
5308
  title: "Text",
5877
5309
  description: "The text to chunk"
5878
5310
  },
5311
+ doc_id: {
5312
+ type: "string",
5313
+ title: "Document ID",
5314
+ description: "Optional document ID stamped onto each chunk. When omitted, chunks are emitted without a doc_id and the output also has no doc_id."
5315
+ },
5879
5316
  chunkSize: {
5880
5317
  type: "number",
5881
5318
  title: "Chunk Size",
@@ -5901,88 +5338,99 @@ var inputSchema15 = {
5901
5338
  required: ["text"],
5902
5339
  additionalProperties: false
5903
5340
  };
5904
- var outputSchema15 = {
5341
+ var outputSchema12 = {
5905
5342
  type: "object",
5906
5343
  properties: {
5907
- chunks: {
5344
+ doc_id: {
5345
+ type: "string",
5346
+ title: "Document ID",
5347
+ description: "The document ID (only emitted when provided in input)"
5348
+ },
5349
+ chunks: ChunkRecordArraySchema3,
5350
+ text: {
5908
5351
  type: "array",
5909
5352
  items: { type: "string" },
5910
- title: "Text Chunks",
5911
- description: "The chunked text segments"
5353
+ title: "Texts",
5354
+ description: "Chunk texts (for TextEmbeddingTask)"
5912
5355
  },
5913
- metadata: {
5914
- type: "array",
5915
- items: {
5916
- type: "object",
5917
- properties: {
5918
- index: { type: "number" },
5919
- startChar: { type: "number" },
5920
- endChar: { type: "number" },
5921
- length: { type: "number" }
5922
- },
5923
- additionalProperties: false
5924
- },
5925
- title: "Chunk Metadata",
5926
- description: "Metadata for each chunk"
5356
+ count: {
5357
+ type: "number",
5358
+ title: "Count",
5359
+ description: "Number of chunks generated"
5927
5360
  }
5928
5361
  },
5929
- required: ["chunks", "metadata"],
5362
+ required: ["chunks", "text", "count"],
5930
5363
  additionalProperties: false
5931
5364
  };
5932
5365
 
5933
- class TextChunkerTask extends Task17 {
5366
+ class TextChunkerTask extends Task14 {
5934
5367
  static type = "TextChunkerTask";
5935
5368
  static category = "Document";
5936
5369
  static title = "Text Chunker";
5937
5370
  static description = "Splits text into chunks using various strategies (fixed, sentence, paragraph)";
5938
5371
  static cacheable = true;
5939
5372
  static inputSchema() {
5940
- return inputSchema15;
5373
+ return inputSchema12;
5941
5374
  }
5942
5375
  static outputSchema() {
5943
- return outputSchema15;
5376
+ return outputSchema12;
5944
5377
  }
5945
5378
  async execute(input, context) {
5946
- const { text, chunkSize = 512, chunkOverlap = 50, strategy = ChunkingStrategy.FIXED } = input;
5947
- let chunks;
5948
- let metadata;
5379
+ const {
5380
+ text,
5381
+ doc_id,
5382
+ chunkSize = 512,
5383
+ chunkOverlap = 50,
5384
+ strategy = ChunkingStrategy.FIXED
5385
+ } = input;
5386
+ let rawChunks;
5949
5387
  switch (strategy) {
5950
5388
  case ChunkingStrategy.SENTENCE:
5951
- ({ chunks, metadata } = this.chunkBySentence(text, chunkSize, chunkOverlap));
5389
+ case ChunkingStrategy.SEMANTIC:
5390
+ rawChunks = this.chunkBySentence(text, chunkSize, chunkOverlap);
5952
5391
  break;
5953
5392
  case ChunkingStrategy.PARAGRAPH:
5954
- ({ chunks, metadata } = this.chunkByParagraph(text, chunkSize, chunkOverlap));
5955
- break;
5956
- case ChunkingStrategy.SEMANTIC:
5957
- ({ chunks, metadata } = this.chunkBySentence(text, chunkSize, chunkOverlap));
5393
+ rawChunks = this.chunkByParagraph(text, chunkSize, chunkOverlap);
5958
5394
  break;
5959
5395
  case ChunkingStrategy.FIXED:
5960
5396
  default:
5961
- ({ chunks, metadata } = this.chunkFixed(text, chunkSize, chunkOverlap));
5397
+ rawChunks = this.chunkFixed(text, chunkSize, chunkOverlap);
5962
5398
  break;
5963
5399
  }
5964
- return { chunks, metadata };
5400
+ const nodePath = doc_id ? [doc_id] : [];
5401
+ const chunks = rawChunks.map((raw, index) => ({
5402
+ chunkId: doc_id ? `${doc_id}:${index}` : `chunk:${index}:${raw.startChar}`,
5403
+ doc_id: doc_id ?? "",
5404
+ text: raw.text,
5405
+ nodePath,
5406
+ depth: nodePath.length,
5407
+ ...doc_id ? { leafNodeId: doc_id } : {},
5408
+ index,
5409
+ startChar: raw.startChar,
5410
+ endChar: raw.endChar
5411
+ }));
5412
+ const output = {
5413
+ chunks,
5414
+ text: chunks.map((c) => c.text),
5415
+ count: chunks.length
5416
+ };
5417
+ if (doc_id)
5418
+ output.doc_id = doc_id;
5419
+ return output;
5965
5420
  }
5966
5421
  chunkFixed(text, chunkSize, chunkOverlap) {
5967
5422
  const chunks = [];
5968
- const metadata = [];
5969
5423
  let startChar = 0;
5970
- let index = 0;
5971
5424
  while (startChar < text.length) {
5972
5425
  const endChar = Math.min(startChar + chunkSize, text.length);
5973
- const chunk = text.substring(startChar, endChar);
5974
- chunks.push(chunk);
5975
- metadata.push({
5976
- index,
5426
+ chunks.push({
5427
+ text: text.substring(startChar, endChar),
5977
5428
  startChar,
5978
- endChar,
5979
- length: chunk.length
5429
+ endChar
5980
5430
  });
5981
- const step = Math.max(1, chunkSize - chunkOverlap);
5982
- startChar += step;
5983
- index++;
5431
+ startChar += Math.max(1, chunkSize - chunkOverlap);
5984
5432
  }
5985
- return { chunks, metadata };
5433
+ return chunks;
5986
5434
  }
5987
5435
  chunkBySentence(text, chunkSize, chunkOverlap) {
5988
5436
  const sentenceRegex = /[.!?]+[\s\n]+/g;
@@ -5991,8 +5439,7 @@ class TextChunkerTask extends Task17 {
5991
5439
  let lastIndex = 0;
5992
5440
  let match;
5993
5441
  while ((match = sentenceRegex.exec(text)) !== null) {
5994
- const sentence = text.substring(lastIndex, match.index + match[0].length);
5995
- sentences.push(sentence);
5442
+ sentences.push(text.substring(lastIndex, match.index + match[0].length));
5996
5443
  sentenceStarts.push(lastIndex);
5997
5444
  lastIndex = match.index + match[0].length;
5998
5445
  }
@@ -6001,22 +5448,17 @@ class TextChunkerTask extends Task17 {
6001
5448
  sentenceStarts.push(lastIndex);
6002
5449
  }
6003
5450
  const chunks = [];
6004
- const metadata = [];
6005
5451
  let currentChunk = "";
6006
5452
  let currentStartChar = 0;
6007
- let index = 0;
6008
5453
  for (let i = 0;i < sentences.length; i++) {
6009
5454
  const sentence = sentences[i];
6010
5455
  const sentenceStart = sentenceStarts[i];
6011
5456
  if (currentChunk.length > 0 && currentChunk.length + sentence.length > chunkSize) {
6012
- chunks.push(currentChunk.trim());
6013
- metadata.push({
6014
- index,
5457
+ chunks.push({
5458
+ text: currentChunk.trim(),
6015
5459
  startChar: currentStartChar,
6016
- endChar: currentStartChar + currentChunk.length,
6017
- length: currentChunk.trim().length
5460
+ endChar: currentStartChar + currentChunk.length
6018
5461
  });
6019
- index++;
6020
5462
  if (chunkOverlap > 0) {
6021
5463
  let overlapText = "";
6022
5464
  let j = i - 1;
@@ -6038,37 +5480,30 @@ class TextChunkerTask extends Task17 {
6038
5480
  }
6039
5481
  }
6040
5482
  if (currentChunk.length > 0) {
6041
- chunks.push(currentChunk.trim());
6042
- metadata.push({
6043
- index,
5483
+ chunks.push({
5484
+ text: currentChunk.trim(),
6044
5485
  startChar: currentStartChar,
6045
- endChar: currentStartChar + currentChunk.length,
6046
- length: currentChunk.trim().length
5486
+ endChar: currentStartChar + currentChunk.length
6047
5487
  });
6048
5488
  }
6049
- return { chunks, metadata };
5489
+ return chunks;
6050
5490
  }
6051
5491
  chunkByParagraph(text, chunkSize, chunkOverlap) {
6052
5492
  const paragraphs = text.split(/\n\s*\n/).filter((p) => p.trim().length > 0);
6053
5493
  const chunks = [];
6054
- const metadata = [];
6055
5494
  let currentChunk = "";
6056
5495
  let currentStartChar = 0;
6057
- let index = 0;
6058
5496
  let charPosition = 0;
6059
5497
  for (let i = 0;i < paragraphs.length; i++) {
6060
5498
  const paragraph = paragraphs[i].trim();
6061
5499
  const paragraphStart = text.indexOf(paragraph, charPosition);
6062
5500
  charPosition = paragraphStart + paragraph.length;
6063
5501
  if (currentChunk.length > 0 && currentChunk.length + paragraph.length + 2 > chunkSize) {
6064
- chunks.push(currentChunk.trim());
6065
- metadata.push({
6066
- index,
5502
+ chunks.push({
5503
+ text: currentChunk.trim(),
6067
5504
  startChar: currentStartChar,
6068
- endChar: currentStartChar + currentChunk.length,
6069
- length: currentChunk.trim().length
5505
+ endChar: currentStartChar + currentChunk.length
6070
5506
  });
6071
- index++;
6072
5507
  if (chunkOverlap > 0 && i > 0) {
6073
5508
  let overlapText = "";
6074
5509
  let j = i - 1;
@@ -6096,24 +5531,103 @@ class TextChunkerTask extends Task17 {
6096
5531
  }
6097
5532
  }
6098
5533
  if (currentChunk.length > 0) {
6099
- chunks.push(currentChunk.trim());
6100
- metadata.push({
6101
- index,
5534
+ chunks.push({
5535
+ text: currentChunk.trim(),
6102
5536
  startChar: currentStartChar,
6103
- endChar: currentStartChar + currentChunk.length,
6104
- length: currentChunk.trim().length
5537
+ endChar: currentStartChar + currentChunk.length
6105
5538
  });
6106
5539
  }
6107
- return { chunks, metadata };
5540
+ return chunks;
6108
5541
  }
6109
5542
  }
6110
5543
  var textChunker = (input, config) => {
6111
5544
  return new TextChunkerTask(config).run(input);
6112
5545
  };
6113
- Workflow35.prototype.textChunker = CreateWorkflow35(TextChunkerTask);
5546
+ Workflow31.prototype.textChunker = CreateWorkflow31(TextChunkerTask);
5547
+
5548
+ // src/task/TextClassificationTask.ts
5549
+ import { CreateWorkflow as CreateWorkflow32, Workflow as Workflow32 } from "@workglow/task-graph";
5550
+ var modelSchema22 = TypeModel("model:TextClassificationTask");
5551
+ var TextClassificationInputSchema = {
5552
+ type: "object",
5553
+ properties: {
5554
+ text: {
5555
+ type: "string",
5556
+ title: "Text",
5557
+ description: "The text to classify"
5558
+ },
5559
+ candidateLabels: {
5560
+ type: "array",
5561
+ items: {
5562
+ type: "string"
5563
+ },
5564
+ title: "Candidate Labels",
5565
+ description: "List of candidate labels (optional, if provided uses zero-shot classification)",
5566
+ "x-ui-group": "Configuration"
5567
+ },
5568
+ maxCategories: {
5569
+ type: "number",
5570
+ minimum: 1,
5571
+ maximum: 1000,
5572
+ default: 5,
5573
+ title: "Max Categories",
5574
+ description: "The maximum number of categories to return",
5575
+ "x-ui-group": "Configuration"
5576
+ },
5577
+ model: modelSchema22
5578
+ },
5579
+ required: ["text", "model"],
5580
+ additionalProperties: false
5581
+ };
5582
+ var TextClassificationOutputSchema = {
5583
+ type: "object",
5584
+ properties: {
5585
+ categories: {
5586
+ type: "array",
5587
+ items: {
5588
+ type: "object",
5589
+ properties: {
5590
+ label: {
5591
+ type: "string",
5592
+ title: "Label",
5593
+ description: "The name of the category"
5594
+ },
5595
+ score: {
5596
+ type: "number",
5597
+ title: "Score",
5598
+ description: "The confidence score for this category"
5599
+ }
5600
+ },
5601
+ required: ["label", "score"],
5602
+ additionalProperties: false
5603
+ },
5604
+ title: "Categories",
5605
+ description: "The classification categories with their scores"
5606
+ }
5607
+ },
5608
+ required: ["categories"],
5609
+ additionalProperties: false
5610
+ };
5611
+
5612
+ class TextClassificationTask extends AiTask {
5613
+ static type = "TextClassificationTask";
5614
+ static category = "AI Text Model";
5615
+ static title = "Text Classifier";
5616
+ static description = "Classifies text into categories using language models. Supports zero-shot classification when candidate labels are provided.";
5617
+ static inputSchema() {
5618
+ return TextClassificationInputSchema;
5619
+ }
5620
+ static outputSchema() {
5621
+ return TextClassificationOutputSchema;
5622
+ }
5623
+ }
5624
+ var textClassification = (input, config) => {
5625
+ return new TextClassificationTask(config).run(input);
5626
+ };
5627
+ Workflow32.prototype.textClassification = CreateWorkflow32(TextClassificationTask);
6114
5628
 
6115
5629
  // src/task/TextFillMaskTask.ts
6116
- import { CreateWorkflow as CreateWorkflow36, Workflow as Workflow36 } from "@workglow/task-graph";
5630
+ import { CreateWorkflow as CreateWorkflow33, Workflow as Workflow33 } from "@workglow/task-graph";
6117
5631
  var modelSchema23 = TypeModel("model:TextFillMaskTask");
6118
5632
  var TextFillMaskInputSchema = {
6119
5633
  type: "object",
@@ -6178,10 +5692,10 @@ class TextFillMaskTask extends AiTask {
6178
5692
  var textFillMask = (input, config) => {
6179
5693
  return new TextFillMaskTask(config).run(input);
6180
5694
  };
6181
- Workflow36.prototype.textFillMask = CreateWorkflow36(TextFillMaskTask);
5695
+ Workflow33.prototype.textFillMask = CreateWorkflow33(TextFillMaskTask);
6182
5696
 
6183
5697
  // src/task/TextGenerationTask.ts
6184
- import { CreateWorkflow as CreateWorkflow37, Workflow as Workflow37 } from "@workglow/task-graph";
5698
+ import { CreateWorkflow as CreateWorkflow34, Workflow as Workflow34 } from "@workglow/task-graph";
6185
5699
  var generatedTextSchema2 = {
6186
5700
  type: "string",
6187
5701
  title: "Text",
@@ -6266,10 +5780,10 @@ class TextGenerationTask extends StreamingAiTask {
6266
5780
  var textGeneration = (input, config) => {
6267
5781
  return new TextGenerationTask(config).run(input);
6268
5782
  };
6269
- Workflow37.prototype.textGeneration = CreateWorkflow37(TextGenerationTask);
5783
+ Workflow34.prototype.textGeneration = CreateWorkflow34(TextGenerationTask);
6270
5784
 
6271
5785
  // src/task/TextLanguageDetectionTask.ts
6272
- import { CreateWorkflow as CreateWorkflow38, Workflow as Workflow38 } from "@workglow/task-graph";
5786
+ import { CreateWorkflow as CreateWorkflow35, Workflow as Workflow35 } from "@workglow/task-graph";
6273
5787
  var modelSchema25 = TypeModel("model:TextLanguageDetectionTask");
6274
5788
  var TextLanguageDetectionInputSchema = {
6275
5789
  type: "object",
@@ -6337,10 +5851,10 @@ class TextLanguageDetectionTask extends AiTask {
6337
5851
  var textLanguageDetection = (input, config) => {
6338
5852
  return new TextLanguageDetectionTask(config).run(input);
6339
5853
  };
6340
- Workflow38.prototype.textLanguageDetection = CreateWorkflow38(TextLanguageDetectionTask);
5854
+ Workflow35.prototype.textLanguageDetection = CreateWorkflow35(TextLanguageDetectionTask);
6341
5855
 
6342
5856
  // src/task/TextQuestionAnswerTask.ts
6343
- import { CreateWorkflow as CreateWorkflow39, Workflow as Workflow39 } from "@workglow/task-graph";
5857
+ import { CreateWorkflow as CreateWorkflow36, Workflow as Workflow36 } from "@workglow/task-graph";
6344
5858
  var contextSchema = {
6345
5859
  type: "string",
6346
5860
  title: "Context",
@@ -6392,10 +5906,10 @@ class TextQuestionAnswerTask extends StreamingAiTask {
6392
5906
  var textQuestionAnswer = (input, config) => {
6393
5907
  return new TextQuestionAnswerTask(config).run(input);
6394
5908
  };
6395
- Workflow39.prototype.textQuestionAnswer = CreateWorkflow39(TextQuestionAnswerTask);
5909
+ Workflow36.prototype.textQuestionAnswer = CreateWorkflow36(TextQuestionAnswerTask);
6396
5910
 
6397
5911
  // src/task/TextRewriterTask.ts
6398
- import { CreateWorkflow as CreateWorkflow40, Workflow as Workflow40 } from "@workglow/task-graph";
5912
+ import { CreateWorkflow as CreateWorkflow37, Workflow as Workflow37 } from "@workglow/task-graph";
6399
5913
  var modelSchema27 = TypeModel("model:TextRewriterTask");
6400
5914
  var TextRewriterInputSchema = {
6401
5915
  type: "object",
@@ -6444,10 +5958,10 @@ class TextRewriterTask extends StreamingAiTask {
6444
5958
  var textRewriter = (input, config) => {
6445
5959
  return new TextRewriterTask(config).run(input);
6446
5960
  };
6447
- Workflow40.prototype.textRewriter = CreateWorkflow40(TextRewriterTask);
5961
+ Workflow37.prototype.textRewriter = CreateWorkflow37(TextRewriterTask);
6448
5962
 
6449
5963
  // src/task/TextTranslationTask.ts
6450
- import { CreateWorkflow as CreateWorkflow41, Workflow as Workflow41 } from "@workglow/task-graph";
5964
+ import { CreateWorkflow as CreateWorkflow38, Workflow as Workflow38 } from "@workglow/task-graph";
6451
5965
  var modelSchema28 = TypeModel("model:TextTranslationTask");
6452
5966
  var translationTextSchema = {
6453
5967
  type: "string",
@@ -6510,10 +6024,10 @@ class TextTranslationTask extends StreamingAiTask {
6510
6024
  var textTranslation = (input, config) => {
6511
6025
  return new TextTranslationTask(config).run(input);
6512
6026
  };
6513
- Workflow41.prototype.textTranslation = CreateWorkflow41(TextTranslationTask);
6027
+ Workflow38.prototype.textTranslation = CreateWorkflow38(TextTranslationTask);
6514
6028
 
6515
6029
  // src/task/ToolCallingTask.ts
6516
- import { CreateWorkflow as CreateWorkflow42, getTaskConstructors, Workflow as Workflow42 } from "@workglow/task-graph";
6030
+ import { CreateWorkflow as CreateWorkflow39, getTaskConstructors, Workflow as Workflow39 } from "@workglow/task-graph";
6517
6031
  import { makeFingerprint } from "@workglow/util";
6518
6032
  function taskTypesToTools(taskNames, registry) {
6519
6033
  const constructors = getTaskConstructors(registry);
@@ -6745,16 +6259,16 @@ class ToolCallingTask extends StreamingAiTask {
6745
6259
  var toolCalling = (input, config) => {
6746
6260
  return new ToolCallingTask(config).run(input);
6747
6261
  };
6748
- Workflow42.prototype.toolCalling = CreateWorkflow42(ToolCallingTask);
6262
+ Workflow39.prototype.toolCalling = CreateWorkflow39(ToolCallingTask);
6749
6263
 
6750
6264
  // src/task/TopicSegmenterTask.ts
6751
- import { CreateWorkflow as CreateWorkflow43, Task as Task18, Workflow as Workflow43 } from "@workglow/task-graph";
6265
+ import { CreateWorkflow as CreateWorkflow40, Task as Task15, Workflow as Workflow40 } from "@workglow/task-graph";
6752
6266
  var SegmentationMethod = {
6753
6267
  HEURISTIC: "heuristic",
6754
6268
  EMBEDDING_SIMILARITY: "embedding-similarity",
6755
6269
  HYBRID: "hybrid"
6756
6270
  };
6757
- var inputSchema16 = {
6271
+ var inputSchema13 = {
6758
6272
  type: "object",
6759
6273
  properties: {
6760
6274
  text: {
@@ -6795,7 +6309,7 @@ var inputSchema16 = {
6795
6309
  required: ["text"],
6796
6310
  additionalProperties: false
6797
6311
  };
6798
- var outputSchema16 = {
6312
+ var outputSchema13 = {
6799
6313
  type: "object",
6800
6314
  properties: {
6801
6315
  segments: {
@@ -6823,7 +6337,7 @@ var outputSchema16 = {
6823
6337
  additionalProperties: false
6824
6338
  };
6825
6339
 
6826
- class TopicSegmenterTask extends Task18 {
6340
+ class TopicSegmenterTask extends Task15 {
6827
6341
  static type = "TopicSegmenterTask";
6828
6342
  static category = "Document";
6829
6343
  static title = "Topic Segmenter";
@@ -6831,10 +6345,10 @@ class TopicSegmenterTask extends Task18 {
6831
6345
  static cacheable = true;
6832
6346
  static EMBEDDING_DIMENSIONS = 256;
6833
6347
  static inputSchema() {
6834
- return inputSchema16;
6348
+ return inputSchema13;
6835
6349
  }
6836
6350
  static outputSchema() {
6837
- return outputSchema16;
6351
+ return outputSchema13;
6838
6352
  }
6839
6353
  async execute(input, context) {
6840
6354
  const {
@@ -7028,10 +6542,10 @@ class TopicSegmenterTask extends Task18 {
7028
6542
  var topicSegmenter = (input, config) => {
7029
6543
  return new TopicSegmenterTask(config).run(input);
7030
6544
  };
7031
- Workflow43.prototype.topicSegmenter = CreateWorkflow43(TopicSegmenterTask);
6545
+ Workflow40.prototype.topicSegmenter = CreateWorkflow40(TopicSegmenterTask);
7032
6546
 
7033
6547
  // src/task/UnloadModelTask.ts
7034
- import { CreateWorkflow as CreateWorkflow44, Workflow as Workflow44 } from "@workglow/task-graph";
6548
+ import { CreateWorkflow as CreateWorkflow41, Workflow as Workflow41 } from "@workglow/task-graph";
7035
6549
  var modelSchema30 = TypeModel("model");
7036
6550
  var UnloadModelInputSchema = {
7037
6551
  type: "object",
@@ -7066,27 +6580,27 @@ class UnloadModelTask extends AiTask {
7066
6580
  var unloadModel = (input, config) => {
7067
6581
  return new UnloadModelTask(config).run(input);
7068
6582
  };
7069
- Workflow44.prototype.unloadModel = CreateWorkflow44(UnloadModelTask);
6583
+ Workflow41.prototype.unloadModel = CreateWorkflow41(UnloadModelTask);
7070
6584
 
7071
6585
  // src/task/VectorQuantizeTask.ts
7072
- import { CreateWorkflow as CreateWorkflow45, Task as Task19, Workflow as Workflow45 } from "@workglow/task-graph";
6586
+ import { CreateWorkflow as CreateWorkflow42, Task as Task16, Workflow as Workflow42 } from "@workglow/task-graph";
7073
6587
  import {
7074
6588
  normalizeNumberArray,
7075
6589
  TensorType,
7076
- TypedArraySchema as TypedArraySchema8
6590
+ TypedArraySchema as TypedArraySchema5
7077
6591
  } from "@workglow/util/schema";
7078
- var inputSchema17 = {
6592
+ var inputSchema14 = {
7079
6593
  type: "object",
7080
6594
  properties: {
7081
6595
  vector: {
7082
6596
  anyOf: [
7083
- TypedArraySchema8({
6597
+ TypedArraySchema5({
7084
6598
  title: "Vector",
7085
6599
  description: "The vector to quantize"
7086
6600
  }),
7087
6601
  {
7088
6602
  type: "array",
7089
- items: TypedArraySchema8({
6603
+ items: TypedArraySchema5({
7090
6604
  title: "Vector",
7091
6605
  description: "Vector to quantize"
7092
6606
  })
@@ -7112,18 +6626,18 @@ var inputSchema17 = {
7112
6626
  required: ["vector", "targetType"],
7113
6627
  additionalProperties: false
7114
6628
  };
7115
- var outputSchema17 = {
6629
+ var outputSchema14 = {
7116
6630
  type: "object",
7117
6631
  properties: {
7118
6632
  vector: {
7119
6633
  anyOf: [
7120
- TypedArraySchema8({
6634
+ TypedArraySchema5({
7121
6635
  title: "Quantized Vector",
7122
6636
  description: "The quantized vector"
7123
6637
  }),
7124
6638
  {
7125
6639
  type: "array",
7126
- items: TypedArraySchema8({
6640
+ items: TypedArraySchema5({
7127
6641
  title: "Quantized Vector",
7128
6642
  description: "Quantized vector"
7129
6643
  })
@@ -7149,17 +6663,17 @@ var outputSchema17 = {
7149
6663
  additionalProperties: false
7150
6664
  };
7151
6665
 
7152
- class VectorQuantizeTask extends Task19 {
6666
+ class VectorQuantizeTask extends Task16 {
7153
6667
  static type = "VectorQuantizeTask";
7154
6668
  static category = "Vector";
7155
6669
  static title = "Quantize";
7156
6670
  static description = "Quantize vectors to reduce storage and improve performance";
7157
6671
  static cacheable = true;
7158
6672
  static inputSchema() {
7159
- return inputSchema17;
6673
+ return inputSchema14;
7160
6674
  }
7161
6675
  static outputSchema() {
7162
- return outputSchema17;
6676
+ return outputSchema14;
7163
6677
  }
7164
6678
  async executeReactive(input) {
7165
6679
  const { vector, targetType, normalize = true } = input;
@@ -7249,15 +6763,15 @@ class VectorQuantizeTask extends Task19 {
7249
6763
  var vectorQuantize = (input, config) => {
7250
6764
  return new VectorQuantizeTask(config).run(input);
7251
6765
  };
7252
- Workflow45.prototype.vectorQuantize = CreateWorkflow45(VectorQuantizeTask);
6766
+ Workflow42.prototype.vectorQuantize = CreateWorkflow42(VectorQuantizeTask);
7253
6767
 
7254
6768
  // src/task/VectorSimilarityTask.ts
7255
- import { CreateWorkflow as CreateWorkflow46, GraphAsTask, Workflow as Workflow46 } from "@workglow/task-graph";
6769
+ import { CreateWorkflow as CreateWorkflow43, GraphAsTask, Workflow as Workflow43 } from "@workglow/task-graph";
7256
6770
  import {
7257
6771
  cosineSimilarity,
7258
6772
  hammingSimilarity,
7259
6773
  jaccardSimilarity,
7260
- TypedArraySchema as TypedArraySchema9
6774
+ TypedArraySchema as TypedArraySchema6
7261
6775
  } from "@workglow/util/schema";
7262
6776
  var SimilarityFn = {
7263
6777
  COSINE: "cosine",
@@ -7272,13 +6786,13 @@ var similarityFunctions = {
7272
6786
  var SimilarityInputSchema = {
7273
6787
  type: "object",
7274
6788
  properties: {
7275
- query: TypedArraySchema9({
6789
+ query: TypedArraySchema6({
7276
6790
  title: "Query",
7277
6791
  description: "Query vector to compare against"
7278
6792
  }),
7279
6793
  vectors: {
7280
6794
  type: "array",
7281
- items: TypedArraySchema9({
6795
+ items: TypedArraySchema6({
7282
6796
  title: "Input",
7283
6797
  description: "Array of vectors to compare against the query"
7284
6798
  })
@@ -7306,7 +6820,7 @@ var SimilarityOutputSchema = {
7306
6820
  properties: {
7307
6821
  output: {
7308
6822
  type: "array",
7309
- items: TypedArraySchema9({
6823
+ items: TypedArraySchema6({
7310
6824
  title: "Output",
7311
6825
  description: "Ranked output vectors"
7312
6826
  })
@@ -7358,7 +6872,7 @@ class VectorSimilarityTask extends GraphAsTask {
7358
6872
  var similarity = (input, config) => {
7359
6873
  return new VectorSimilarityTask(config).run(input);
7360
6874
  };
7361
- Workflow46.prototype.similarity = CreateWorkflow46(VectorSimilarityTask);
6875
+ Workflow43.prototype.similarity = CreateWorkflow43(VectorSimilarityTask);
7362
6876
  // src/task/MessageConversion.ts
7363
6877
  function getInputMessages(input) {
7364
6878
  const messages = input.messages;
@@ -7512,14 +7026,11 @@ var registerAiTasks = () => {
7512
7026
  const tasks = [
7513
7027
  AiChatTask,
7514
7028
  BackgroundRemovalTask,
7515
- ChunkToVectorTask,
7516
7029
  CountTokensTask,
7517
7030
  ContextBuilderTask,
7518
7031
  DocumentEnricherTask,
7519
7032
  DocumentUpsertTask,
7520
7033
  ChunkRetrievalTask,
7521
- ChunkVectorHybridSearchTask,
7522
- ChunkVectorSearchTask,
7523
7034
  ChunkVectorUpsertTask,
7524
7035
  DownloadModelTask,
7525
7036
  FaceDetectorTask,
@@ -7562,7 +7073,6 @@ var registerAiTasks = () => {
7562
7073
  return tasks;
7563
7074
  };
7564
7075
  export {
7565
- vectorStoreSearch,
7566
7076
  vectorQuantize,
7567
7077
  unloadModel,
7568
7078
  topicSegmenter,
@@ -7596,6 +7106,7 @@ export {
7596
7106
  modelSearch,
7597
7107
  modelInfo,
7598
7108
  kbToDocuments,
7109
+ isContentBlockInToolResultBody,
7599
7110
  isContentBlock,
7600
7111
  isChatMessage,
7601
7112
  isAllowedToolName,
@@ -7603,7 +7114,6 @@ export {
7603
7114
  imageSegmentation,
7604
7115
  imageEmbedding,
7605
7116
  imageClassification,
7606
- hybridSearch,
7607
7117
  hierarchyJoin,
7608
7118
  hierarchicalChunker,
7609
7119
  handLandmarker,
@@ -7619,7 +7129,6 @@ export {
7619
7129
  countTokens,
7620
7130
  contextBuilder,
7621
7131
  chunkVectorUpsert,
7622
- chunkToVector,
7623
7132
  chunkRetrieval,
7624
7133
  buildToolDescription,
7625
7134
  backgroundRemoval,
@@ -7738,9 +7247,6 @@ export {
7738
7247
  ContentBlockSchema,
7739
7248
  ChunkingStrategy,
7740
7249
  ChunkVectorUpsertTask,
7741
- ChunkVectorSearchTask,
7742
- ChunkVectorHybridSearchTask,
7743
- ChunkToVectorTask,
7744
7250
  ChunkRetrievalTask,
7745
7251
  ChatMessageSchema,
7746
7252
  BackgroundRemovalTask,
@@ -7755,4 +7261,4 @@ export {
7755
7261
  AiChatInputSchema
7756
7262
  };
7757
7263
 
7758
- //# debugId=4A4F2C3AAA2FA8C064756E2164756E21
7264
+ //# debugId=D0BE66A575D71CC764756E2164756E21