@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/bun.js CHANGED
@@ -1145,7 +1145,7 @@ class AiTask extends Task {
1145
1145
  if (modelTaskProperties.length > 0) {
1146
1146
  const modelRepo = registry.get(MODEL_REPOSITORY);
1147
1147
  const taskModels = await modelRepo.findModelsByTask(this.type) ?? [];
1148
- for (const [key, propSchema] of modelTaskProperties) {
1148
+ for (const [key] of modelTaskProperties) {
1149
1149
  const requestedModel = input[key];
1150
1150
  if (typeof requestedModel === "string") {
1151
1151
  const found = taskModels?.find((m) => m.model_id === requestedModel);
@@ -3206,6 +3206,8 @@ var inputSchema7 = {
3206
3206
  description: "The document ID"
3207
3207
  },
3208
3208
  documentTree: {
3209
+ type: "object",
3210
+ additionalProperties: true,
3209
3211
  title: "Document Tree",
3210
3212
  description: "The hierarchical document tree to enrich"
3211
3213
  },
@@ -3429,6 +3431,7 @@ Workflow14.prototype.documentEnricher = CreateWorkflow14(DocumentEnricherTask);
3429
3431
 
3430
3432
  // src/task/DocumentUpsertTask.ts
3431
3433
  import { Document, TypeKnowledgeBase as TypeKnowledgeBase5 } from "@workglow/knowledge-base";
3434
+ import { DocumentMetadataSchema } from "@workglow/knowledge-base";
3432
3435
  import { CreateWorkflow as CreateWorkflow15, Task as Task10, Workflow as Workflow15 } from "@workglow/task-graph";
3433
3436
  var inputSchema8 = {
3434
3437
  type: "object",
@@ -3449,10 +3452,16 @@ var inputSchema8 = {
3449
3452
  title: {
3450
3453
  type: "string",
3451
3454
  title: "Title",
3452
- description: "Human-readable title stored in the document metadata"
3455
+ description: "Optional human-readable title. If provided, overrides metadata.title. " + "Either this or metadata.title must be supplied."
3456
+ },
3457
+ metadata: {
3458
+ ...DocumentMetadataSchema,
3459
+ required: [],
3460
+ title: "Metadata",
3461
+ 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)."
3453
3462
  }
3454
3463
  },
3455
- required: ["knowledgeBase", "doc_id", "documentTree", "title"],
3464
+ required: ["knowledgeBase", "doc_id", "documentTree"],
3456
3465
  additionalProperties: false
3457
3466
  };
3458
3467
  var outputSchema8 = {
@@ -3481,10 +3490,17 @@ class DocumentUpsertTask extends Task10 {
3481
3490
  return outputSchema8;
3482
3491
  }
3483
3492
  async execute(input, context) {
3484
- const { knowledgeBase, doc_id, documentTree, title } = input;
3493
+ const { knowledgeBase, doc_id, documentTree, title, metadata } = input;
3485
3494
  const kb = knowledgeBase;
3495
+ const merged = {
3496
+ ...metadata ?? {},
3497
+ ...title !== undefined ? { title } : {}
3498
+ };
3499
+ if (!merged.title) {
3500
+ throw new Error("DocumentUpsertTask: title is required \u2014 provide it via the 'title' input or 'metadata.title'");
3501
+ }
3486
3502
  await context.updateProgress(1, "Upserting document");
3487
- const document = new Document(documentTree, { title }, [], doc_id);
3503
+ const document = new Document(documentTree, merged, [], doc_id);
3488
3504
  const stored = await kb.upsertDocument(document);
3489
3505
  return {
3490
3506
  doc_id: stored.doc_id ?? doc_id
@@ -4194,6 +4210,8 @@ var inputSchema9 = {
4194
4210
  description: "The ID of the document"
4195
4211
  },
4196
4212
  documentTree: {
4213
+ type: "object",
4214
+ additionalProperties: true,
4197
4215
  title: "Document Tree",
4198
4216
  description: "The hierarchical document tree to chunk"
4199
4217
  },
@@ -5635,7 +5653,6 @@ class RerankerTask extends Task15 {
5635
5653
  static title = "Reranker";
5636
5654
  static description = "Rerank retrieved chunks to improve relevance";
5637
5655
  static cacheable = true;
5638
- resolvedCrossEncoderModel;
5639
5656
  static inputSchema() {
5640
5657
  return inputSchema12;
5641
5658
  }
@@ -5807,8 +5824,10 @@ var outputSchema13 = {
5807
5824
  description: "Generated or provided document ID"
5808
5825
  },
5809
5826
  documentTree: {
5827
+ type: "object",
5810
5828
  title: "Document Tree",
5811
- description: "Parsed hierarchical document tree"
5829
+ description: "Parsed hierarchical document tree",
5830
+ additionalProperties: true
5812
5831
  },
5813
5832
  nodeCount: {
5814
5833
  type: "number",
@@ -5834,7 +5853,7 @@ class StructuralParserTask extends Task16 {
5834
5853
  }
5835
5854
  async execute(input, context) {
5836
5855
  const { text, title, format = "auto", sourceUri, doc_id: providedDocId } = input;
5837
- const doc_id = providedDocId || uuid42();
5856
+ const doc_id = providedDocId || sourceUri || uuid42();
5838
5857
  let documentTree;
5839
5858
  if (format === "markdown") {
5840
5859
  documentTree = await StructuralParser.parseMarkdown(doc_id, text, title);
@@ -7650,4 +7669,4 @@ export {
7650
7669
  AgentInputSchema
7651
7670
  };
7652
7671
 
7653
- //# debugId=A0AE35A82942CF9964756E2164756E21
7672
+ //# debugId=3A8ABD53CB039BD464756E2164756E21