@workglow/ai 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/node.js CHANGED
@@ -1144,7 +1144,7 @@ class AiTask extends Task {
1144
1144
  if (modelTaskProperties.length > 0) {
1145
1145
  const modelRepo = registry.get(MODEL_REPOSITORY);
1146
1146
  const taskModels = await modelRepo.findModelsByTask(this.type) ?? [];
1147
- for (const [key, propSchema] of modelTaskProperties) {
1147
+ for (const [key] of modelTaskProperties) {
1148
1148
  const requestedModel = input[key];
1149
1149
  if (typeof requestedModel === "string") {
1150
1150
  const found = taskModels?.find((m) => m.model_id === requestedModel);
@@ -3205,6 +3205,8 @@ var inputSchema7 = {
3205
3205
  description: "The document ID"
3206
3206
  },
3207
3207
  documentTree: {
3208
+ type: "object",
3209
+ additionalProperties: true,
3208
3210
  title: "Document Tree",
3209
3211
  description: "The hierarchical document tree to enrich"
3210
3212
  },
@@ -3428,6 +3430,7 @@ Workflow14.prototype.documentEnricher = CreateWorkflow14(DocumentEnricherTask);
3428
3430
 
3429
3431
  // src/task/DocumentUpsertTask.ts
3430
3432
  import { Document, TypeKnowledgeBase as TypeKnowledgeBase5 } from "@workglow/knowledge-base";
3433
+ import { DocumentMetadataSchema } from "@workglow/knowledge-base";
3431
3434
  import { CreateWorkflow as CreateWorkflow15, Task as Task10, Workflow as Workflow15 } from "@workglow/task-graph";
3432
3435
  var inputSchema8 = {
3433
3436
  type: "object",
@@ -3448,10 +3451,16 @@ var inputSchema8 = {
3448
3451
  title: {
3449
3452
  type: "string",
3450
3453
  title: "Title",
3451
- description: "Human-readable title stored in the document metadata"
3454
+ description: "Optional human-readable title. If provided, overrides metadata.title. " + "Either this or metadata.title must be supplied."
3455
+ },
3456
+ metadata: {
3457
+ ...DocumentMetadataSchema,
3458
+ required: [],
3459
+ title: "Metadata",
3460
+ description: "Optional document metadata. May contain `title` (unless the top-level " + "`title` input is also provided), `sourceUri`, `createdAt`, and any " + "additional caller-defined fields (the schema is open)."
3452
3461
  }
3453
3462
  },
3454
- required: ["knowledgeBase", "doc_id", "documentTree", "title"],
3463
+ required: ["knowledgeBase", "doc_id", "documentTree"],
3455
3464
  additionalProperties: false
3456
3465
  };
3457
3466
  var outputSchema8 = {
@@ -3480,10 +3489,17 @@ class DocumentUpsertTask extends Task10 {
3480
3489
  return outputSchema8;
3481
3490
  }
3482
3491
  async execute(input, context) {
3483
- const { knowledgeBase, doc_id, documentTree, title } = input;
3492
+ const { knowledgeBase, doc_id, documentTree, title, metadata } = input;
3484
3493
  const kb = knowledgeBase;
3494
+ const merged = {
3495
+ ...metadata ?? {},
3496
+ ...title !== undefined ? { title } : {}
3497
+ };
3498
+ if (!merged.title) {
3499
+ throw new Error("DocumentUpsertTask: title is required — provide it via the 'title' input or 'metadata.title'");
3500
+ }
3485
3501
  await context.updateProgress(1, "Upserting document");
3486
- const document = new Document(documentTree, { title }, [], doc_id);
3502
+ const document = new Document(documentTree, merged, [], doc_id);
3487
3503
  const stored = await kb.upsertDocument(document);
3488
3504
  return {
3489
3505
  doc_id: stored.doc_id ?? doc_id
@@ -4193,6 +4209,8 @@ var inputSchema9 = {
4193
4209
  description: "The ID of the document"
4194
4210
  },
4195
4211
  documentTree: {
4212
+ type: "object",
4213
+ additionalProperties: true,
4196
4214
  title: "Document Tree",
4197
4215
  description: "The hierarchical document tree to chunk"
4198
4216
  },
@@ -5634,7 +5652,6 @@ class RerankerTask extends Task15 {
5634
5652
  static title = "Reranker";
5635
5653
  static description = "Rerank retrieved chunks to improve relevance";
5636
5654
  static cacheable = true;
5637
- resolvedCrossEncoderModel;
5638
5655
  static inputSchema() {
5639
5656
  return inputSchema12;
5640
5657
  }
@@ -5806,8 +5823,10 @@ var outputSchema13 = {
5806
5823
  description: "Generated or provided document ID"
5807
5824
  },
5808
5825
  documentTree: {
5826
+ type: "object",
5809
5827
  title: "Document Tree",
5810
- description: "Parsed hierarchical document tree"
5828
+ description: "Parsed hierarchical document tree",
5829
+ additionalProperties: true
5811
5830
  },
5812
5831
  nodeCount: {
5813
5832
  type: "number",
@@ -5833,7 +5852,7 @@ class StructuralParserTask extends Task16 {
5833
5852
  }
5834
5853
  async execute(input, context) {
5835
5854
  const { text, title, format = "auto", sourceUri, doc_id: providedDocId } = input;
5836
- const doc_id = providedDocId || uuid42();
5855
+ const doc_id = providedDocId || sourceUri || uuid42();
5837
5856
  let documentTree;
5838
5857
  if (format === "markdown") {
5839
5858
  documentTree = await StructuralParser.parseMarkdown(doc_id, text, title);
@@ -7649,4 +7668,4 @@ export {
7649
7668
  AgentInputSchema
7650
7669
  };
7651
7670
 
7652
- //# debugId=EFF0B83E40197F3464756E2164756E21
7671
+ //# debugId=E87783958D33A7FE64756E2164756E21