@workglow/ai 0.1.1 → 0.2.0

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 (137) hide show
  1. package/README.md +8 -7
  2. package/dist/browser.js +1436 -397
  3. package/dist/browser.js.map +64 -58
  4. package/dist/bun.js +1436 -397
  5. package/dist/bun.js.map +64 -58
  6. package/dist/common.d.ts +1 -0
  7. package/dist/common.d.ts.map +1 -1
  8. package/dist/execution/DirectExecutionStrategy.d.ts +1 -1
  9. package/dist/execution/DirectExecutionStrategy.d.ts.map +1 -1
  10. package/dist/execution/QueuedExecutionStrategy.d.ts +2 -2
  11. package/dist/execution/QueuedExecutionStrategy.d.ts.map +1 -1
  12. package/dist/job/AiJob.d.ts +2 -1
  13. package/dist/job/AiJob.d.ts.map +1 -1
  14. package/dist/model/ModelRegistry.d.ts.map +1 -1
  15. package/dist/model/ModelRepository.d.ts +11 -15
  16. package/dist/model/ModelRepository.d.ts.map +1 -1
  17. package/dist/model/ModelSchema.d.ts.map +1 -1
  18. package/dist/node.js +1436 -397
  19. package/dist/node.js.map +64 -58
  20. package/dist/provider/AiProvider.d.ts +2 -2
  21. package/dist/provider/AiProvider.d.ts.map +1 -1
  22. package/dist/provider/AiProviderRegistry.d.ts +3 -2
  23. package/dist/provider/AiProviderRegistry.d.ts.map +1 -1
  24. package/dist/provider/QueuedAiProvider.d.ts +2 -1
  25. package/dist/provider/QueuedAiProvider.d.ts.map +1 -1
  26. package/dist/task/AgentTask.d.ts +525 -0
  27. package/dist/task/AgentTask.d.ts.map +1 -0
  28. package/dist/task/AgentTypes.d.ts +183 -0
  29. package/dist/task/AgentTypes.d.ts.map +1 -0
  30. package/dist/task/AgentUtils.d.ts +55 -0
  31. package/dist/task/AgentUtils.d.ts.map +1 -0
  32. package/dist/task/BackgroundRemovalTask.d.ts +6 -34
  33. package/dist/task/BackgroundRemovalTask.d.ts.map +1 -1
  34. package/dist/task/ChunkRetrievalTask.d.ts +6 -4
  35. package/dist/task/ChunkRetrievalTask.d.ts.map +1 -1
  36. package/dist/task/ChunkToVectorTask.d.ts +6 -26
  37. package/dist/task/ChunkToVectorTask.d.ts.map +1 -1
  38. package/dist/task/ChunkVectorHybridSearchTask.d.ts +6 -25
  39. package/dist/task/ChunkVectorHybridSearchTask.d.ts.map +1 -1
  40. package/dist/task/ChunkVectorSearchTask.d.ts +6 -12
  41. package/dist/task/ChunkVectorSearchTask.d.ts.map +1 -1
  42. package/dist/task/ChunkVectorUpsertTask.d.ts +6 -13
  43. package/dist/task/ChunkVectorUpsertTask.d.ts.map +1 -1
  44. package/dist/task/ContextBuilderTask.d.ts +6 -30
  45. package/dist/task/ContextBuilderTask.d.ts.map +1 -1
  46. package/dist/task/CountTokensTask.d.ts +6 -21
  47. package/dist/task/CountTokensTask.d.ts.map +1 -1
  48. package/dist/task/DocumentEnricherTask.d.ts +6 -40
  49. package/dist/task/DocumentEnricherTask.d.ts.map +1 -1
  50. package/dist/task/DownloadModelTask.d.ts +7 -21
  51. package/dist/task/DownloadModelTask.d.ts.map +1 -1
  52. package/dist/task/FaceDetectorTask.d.ts +6 -36
  53. package/dist/task/FaceDetectorTask.d.ts.map +1 -1
  54. package/dist/task/FaceLandmarkerTask.d.ts +6 -40
  55. package/dist/task/FaceLandmarkerTask.d.ts.map +1 -1
  56. package/dist/task/GestureRecognizerTask.d.ts +6 -38
  57. package/dist/task/GestureRecognizerTask.d.ts.map +1 -1
  58. package/dist/task/HandLandmarkerTask.d.ts +6 -38
  59. package/dist/task/HandLandmarkerTask.d.ts.map +1 -1
  60. package/dist/task/HierarchicalChunkerTask.d.ts +6 -26
  61. package/dist/task/HierarchicalChunkerTask.d.ts.map +1 -1
  62. package/dist/task/HierarchyJoinTask.d.ts +6 -29
  63. package/dist/task/HierarchyJoinTask.d.ts.map +1 -1
  64. package/dist/task/ImageClassificationTask.d.ts +6 -36
  65. package/dist/task/ImageClassificationTask.d.ts.map +1 -1
  66. package/dist/task/ImageEmbeddingTask.d.ts +6 -47
  67. package/dist/task/ImageEmbeddingTask.d.ts.map +1 -1
  68. package/dist/task/ImageSegmentationTask.d.ts +6 -36
  69. package/dist/task/ImageSegmentationTask.d.ts.map +1 -1
  70. package/dist/task/ImageToTextTask.d.ts +6 -35
  71. package/dist/task/ImageToTextTask.d.ts.map +1 -1
  72. package/dist/task/MessageConversion.d.ts +52 -0
  73. package/dist/task/MessageConversion.d.ts.map +1 -0
  74. package/dist/task/ModelInfoTask.d.ts +7 -22
  75. package/dist/task/ModelInfoTask.d.ts.map +1 -1
  76. package/dist/task/ModelSearchTask.d.ts +6 -7
  77. package/dist/task/ModelSearchTask.d.ts.map +1 -1
  78. package/dist/task/ObjectDetectionTask.d.ts +6 -36
  79. package/dist/task/ObjectDetectionTask.d.ts.map +1 -1
  80. package/dist/task/PoseLandmarkerTask.d.ts +6 -39
  81. package/dist/task/PoseLandmarkerTask.d.ts.map +1 -1
  82. package/dist/task/QueryExpanderTask.d.ts +6 -9
  83. package/dist/task/QueryExpanderTask.d.ts.map +1 -1
  84. package/dist/task/RerankerTask.d.ts +6 -28
  85. package/dist/task/RerankerTask.d.ts.map +1 -1
  86. package/dist/task/StructuralParserTask.d.ts +6 -10
  87. package/dist/task/StructuralParserTask.d.ts.map +1 -1
  88. package/dist/task/StructuredGenerationTask.d.ts +6 -26
  89. package/dist/task/StructuredGenerationTask.d.ts.map +1 -1
  90. package/dist/task/TextChunkerTask.d.ts +6 -9
  91. package/dist/task/TextChunkerTask.d.ts.map +1 -1
  92. package/dist/task/TextClassificationTask.d.ts +6 -23
  93. package/dist/task/TextClassificationTask.d.ts.map +1 -1
  94. package/dist/task/TextEmbeddingTask.d.ts +6 -21
  95. package/dist/task/TextEmbeddingTask.d.ts.map +1 -1
  96. package/dist/task/TextFillMaskTask.d.ts +6 -21
  97. package/dist/task/TextFillMaskTask.d.ts.map +1 -1
  98. package/dist/task/TextGenerationTask.d.ts +6 -26
  99. package/dist/task/TextGenerationTask.d.ts.map +1 -1
  100. package/dist/task/TextLanguageDetectionTask.d.ts +6 -22
  101. package/dist/task/TextLanguageDetectionTask.d.ts.map +1 -1
  102. package/dist/task/TextNamedEntityRecognitionTask.d.ts +6 -22
  103. package/dist/task/TextNamedEntityRecognitionTask.d.ts.map +1 -1
  104. package/dist/task/TextQuestionAnswerTask.d.ts +6 -22
  105. package/dist/task/TextQuestionAnswerTask.d.ts.map +1 -1
  106. package/dist/task/TextRewriterTask.d.ts +6 -22
  107. package/dist/task/TextRewriterTask.d.ts.map +1 -1
  108. package/dist/task/TextSummaryTask.d.ts +6 -21
  109. package/dist/task/TextSummaryTask.d.ts.map +1 -1
  110. package/dist/task/TextTranslationTask.d.ts +6 -23
  111. package/dist/task/TextTranslationTask.d.ts.map +1 -1
  112. package/dist/task/ToolCallingTask.d.ts +348 -0
  113. package/dist/task/ToolCallingTask.d.ts.map +1 -0
  114. package/dist/task/ToolCallingUtils.d.ts +75 -0
  115. package/dist/task/ToolCallingUtils.d.ts.map +1 -0
  116. package/dist/task/TopicSegmenterTask.d.ts +6 -10
  117. package/dist/task/TopicSegmenterTask.d.ts.map +1 -1
  118. package/dist/task/UnloadModelTask.d.ts +6 -20
  119. package/dist/task/UnloadModelTask.d.ts.map +1 -1
  120. package/dist/task/VectorQuantizeTask.d.ts +6 -8
  121. package/dist/task/VectorQuantizeTask.d.ts.map +1 -1
  122. package/dist/task/VectorSimilarityTask.d.ts +7 -10
  123. package/dist/task/VectorSimilarityTask.d.ts.map +1 -1
  124. package/dist/task/base/AiTask.d.ts +8 -5
  125. package/dist/task/base/AiTask.d.ts.map +1 -1
  126. package/dist/task/base/AiTaskSchemas.d.ts.map +1 -1
  127. package/dist/task/base/AiVisionTask.d.ts +3 -7
  128. package/dist/task/base/AiVisionTask.d.ts.map +1 -1
  129. package/dist/task/base/StreamingAiTask.d.ts +4 -7
  130. package/dist/task/base/StreamingAiTask.d.ts.map +1 -1
  131. package/dist/task/index.d.ts +9 -1
  132. package/dist/task/index.d.ts.map +1 -1
  133. package/dist/worker.d.ts +2 -0
  134. package/dist/worker.d.ts.map +1 -1
  135. package/dist/worker.js +247 -25
  136. package/dist/worker.js.map +9 -7
  137. package/package.json +16 -11
package/dist/bun.js CHANGED
@@ -5,7 +5,8 @@ import {
5
5
  Job,
6
6
  JobStatus,
7
7
  PermanentJobError,
8
- RetryableJobError
8
+ RetryableJobError,
9
+ withJobErrorDiagnostics
9
10
  } from "@workglow/job-queue";
10
11
  import { getLogger } from "@workglow/util/worker";
11
12
 
@@ -138,16 +139,13 @@ function setAiProviderRegistry(pr) {
138
139
 
139
140
  // src/job/AiJob.ts
140
141
  var DEFAULT_AI_TIMEOUT_MS = 120000;
141
- var LOCAL_MODEL_DEFAULT_TIMEOUT_MS = 600000;
142
+ var LOCAL_INFERENCE_DEFAULT_TIMEOUT_MS = 300000;
142
143
  function resolveAiJobTimeoutMs(aiProvider, explicitMs) {
143
144
  if (explicitMs !== undefined) {
144
145
  return explicitMs;
145
146
  }
146
- if (aiProvider === "LOCAL_LLAMACPP") {
147
- return LOCAL_MODEL_DEFAULT_TIMEOUT_MS;
148
- }
149
- if (aiProvider === "HF_TRANSFORMERS_ONNX" || aiProvider.startsWith("HF_TRANSFORMERS_ONNX")) {
150
- return LOCAL_MODEL_DEFAULT_TIMEOUT_MS;
147
+ if (aiProvider === "LOCAL_LLAMACPP" || aiProvider === "HF_TRANSFORMERS_ONNX") {
148
+ return LOCAL_INFERENCE_DEFAULT_TIMEOUT_MS;
151
149
  }
152
150
  return DEFAULT_AI_TIMEOUT_MS;
153
151
  }
@@ -160,39 +158,39 @@ function classifyProviderError(err, taskType, provider) {
160
158
  const m = message.match(/\b([45]\d{2})\b/);
161
159
  return m ? parseInt(m[1], 10) : undefined;
162
160
  })();
163
- if (err instanceof DOMException && err.name === "AbortError") {
164
- return new AbortSignalJobError(`Provider call aborted for ${taskType} (${provider})`);
161
+ if (err instanceof Error && err.name === "AbortError") {
162
+ return new AbortSignalJobError(withJobErrorDiagnostics(`Provider call aborted for ${taskType} (${provider})`, err));
165
163
  }
166
- if (err instanceof DOMException && err.name === "TimeoutError") {
167
- return new AbortSignalJobError(`Provider call timed out for ${taskType} (${provider})`);
164
+ if (err instanceof Error && err.name === "TimeoutError") {
165
+ return new AbortSignalJobError(withJobErrorDiagnostics(`Provider call timed out for ${taskType} (${provider})`, err));
168
166
  }
169
167
  if (message.includes("Pipeline download aborted") || message.includes("Operation aborted") || message.includes("operation was aborted") || message.includes("The operation was aborted")) {
170
- return new AbortSignalJobError(`Provider call aborted for ${taskType} (${provider}): ${message}`);
168
+ return new AbortSignalJobError(withJobErrorDiagnostics(`Provider call aborted for ${taskType} (${provider}): ${message}`, err));
171
169
  }
172
170
  if (message.startsWith("HFT_NULL_PROCESSOR:")) {
173
- return new RetryableJobError(message);
171
+ return new RetryableJobError(withJobErrorDiagnostics(message, err));
174
172
  }
175
173
  if (status === 429) {
176
174
  const retryAfterMatch = message.match(/retry.after[:\s]*(\d+)/i);
177
175
  const retryMs = retryAfterMatch ? parseInt(retryAfterMatch[1], 10) * 1000 : 30000;
178
- return new RetryableJobError(`Rate limited by ${provider} for ${taskType}: ${message}`, new Date(Date.now() + retryMs));
176
+ return new RetryableJobError(withJobErrorDiagnostics(`Rate limited by ${provider} for ${taskType}: ${message}`, err), new Date(Date.now() + retryMs));
179
177
  }
180
178
  if (status === 401 || status === 403) {
181
- return new PermanentJobError(`Authentication failed for ${provider} (${taskType}): ${message}`);
179
+ return new PermanentJobError(withJobErrorDiagnostics(`Authentication failed for ${provider} (${taskType}): ${message}`, err));
182
180
  }
183
181
  if (status === 400 || status === 404) {
184
- return new PermanentJobError(`Invalid request to ${provider} for ${taskType}: ${message}`);
182
+ return new PermanentJobError(withJobErrorDiagnostics(`Invalid request to ${provider} for ${taskType}: ${message}`, err));
185
183
  }
186
184
  if (status && status >= 500) {
187
- return new RetryableJobError(`Server error from ${provider} for ${taskType} (HTTP ${status}): ${message}`);
185
+ return new RetryableJobError(withJobErrorDiagnostics(`Server error from ${provider} for ${taskType} (HTTP ${status}): ${message}`, err));
188
186
  }
189
187
  if (message.includes("ECONNREFUSED") || message.includes("ECONNRESET") || message.includes("ETIMEDOUT") || message.includes("fetch failed") || message.includes("network") || err instanceof TypeError && message.includes("fetch")) {
190
- return new RetryableJobError(`Network error calling ${provider} for ${taskType}: ${message}`);
188
+ return new RetryableJobError(withJobErrorDiagnostics(`Network error calling ${provider} for ${taskType}: ${message}`, err));
191
189
  }
192
190
  if (message.includes("timed out") || message.includes("timeout")) {
193
- return new RetryableJobError(`Timeout calling ${provider} for ${taskType}: ${message}`);
191
+ return new RetryableJobError(withJobErrorDiagnostics(`Timeout calling ${provider} for ${taskType}: ${message}`, err));
194
192
  }
195
- return new PermanentJobError(`Provider ${provider} failed for ${taskType}: ${message}`);
193
+ return new PermanentJobError(withJobErrorDiagnostics(`Provider ${provider} failed for ${taskType}: ${message}`, err));
196
194
  }
197
195
 
198
196
  class AiJob extends Job {
@@ -298,12 +296,14 @@ class DirectExecutionStrategy {
298
296
  }
299
297
 
300
298
  // src/execution/QueuedExecutionStrategy.ts
301
- import { ConcurrencyLimiter, JobQueueClient, JobQueueServer } from "@workglow/job-queue";
302
- import { InMemoryQueueStorage } from "@workglow/storage";
303
299
  import {
304
- getTaskQueueRegistry,
305
- TaskConfigurationError
306
- } from "@workglow/task-graph";
300
+ AbortSignalJobError as AbortSignalJobError2,
301
+ ConcurrencyLimiter,
302
+ JobQueueClient,
303
+ JobQueueServer
304
+ } from "@workglow/job-queue";
305
+ import { InMemoryQueueStorage } from "@workglow/storage";
306
+ import { getTaskQueueRegistry, TaskConfigurationError } from "@workglow/task-graph";
307
307
  class QueuedExecutionStrategy {
308
308
  queueName;
309
309
  concurrency;
@@ -316,7 +316,7 @@ class QueuedExecutionStrategy {
316
316
  }
317
317
  async execute(jobInput, context, runnerId) {
318
318
  if (context.signal.aborted) {
319
- throw context.signal.reason ?? new DOMException("The operation was aborted", "AbortError");
319
+ throw context.signal.reason ?? new AbortSignalJobError2("The operation was aborted");
320
320
  }
321
321
  const registeredQueue = await this.ensureQueue();
322
322
  const { client } = registeredQueue;
@@ -335,7 +335,7 @@ class QueuedExecutionStrategy {
335
335
  });
336
336
  try {
337
337
  if (context.signal.aborted) {
338
- throw context.signal.reason ?? new DOMException("The operation was aborted", "AbortError");
338
+ throw context.signal.reason ?? new AbortSignalJobError2("The operation was aborted");
339
339
  }
340
340
  const output = await handle.waitFor();
341
341
  return output;
@@ -409,11 +409,101 @@ class QueuedExecutionStrategy {
409
409
  }
410
410
  }
411
411
 
412
+ // src/task/ToolCallingUtils.ts
413
+ import { getLogger as getLogger2 } from "@workglow/util/worker";
414
+ function buildToolDescription(tool) {
415
+ let desc = tool.description;
416
+ if (tool.outputSchema && typeof tool.outputSchema === "object") {
417
+ desc += `
418
+
419
+ Returns: ${JSON.stringify(tool.outputSchema)}`;
420
+ }
421
+ return desc;
422
+ }
423
+ function isAllowedToolName(name, allowedTools) {
424
+ return allowedTools.some((t) => t.name === name);
425
+ }
426
+ function filterValidToolCalls(toolCalls, allowedTools) {
427
+ return toolCalls.filter((tc) => {
428
+ if (tc.name && isAllowedToolName(tc.name, allowedTools)) {
429
+ return true;
430
+ }
431
+ getLogger2().warn(`Filtered out tool call with unknown name "${tc.name ?? "(missing)"}"`, {
432
+ callId: tc.id,
433
+ toolName: tc.name
434
+ });
435
+ return false;
436
+ });
437
+ }
438
+
412
439
  // src/model/InMemoryModelRepository.ts
413
440
  import { InMemoryTabularStorage } from "@workglow/storage";
414
441
 
415
442
  // src/model/ModelRepository.ts
416
443
  import { EventEmitter } from "@workglow/util";
444
+ import { compileSchema } from "@workglow/util/schema";
445
+
446
+ // src/model/ModelSchema.ts
447
+ var ModelConfigSchema = {
448
+ type: "object",
449
+ properties: {
450
+ model_id: { type: "string" },
451
+ tasks: { type: "array", items: { type: "string" }, "x-ui-editor": "multiselect" },
452
+ title: { type: "string" },
453
+ description: { type: "string", "x-ui-editor": "textarea" },
454
+ provider: { type: "string" },
455
+ provider_config: {
456
+ type: "object",
457
+ properties: {
458
+ credential_key: { type: "string", format: "credential", "x-ui-hidden": true }
459
+ },
460
+ additionalProperties: true,
461
+ default: {}
462
+ },
463
+ metadata: { type: "object", default: {}, "x-ui-hidden": true }
464
+ },
465
+ required: ["provider", "provider_config"],
466
+ format: "model",
467
+ additionalProperties: true
468
+ };
469
+ var ModelRecordSchema = {
470
+ type: "object",
471
+ properties: {
472
+ ...ModelConfigSchema.properties
473
+ },
474
+ required: [
475
+ "model_id",
476
+ "tasks",
477
+ "provider",
478
+ "title",
479
+ "description",
480
+ "provider_config",
481
+ "metadata"
482
+ ],
483
+ format: "model",
484
+ additionalProperties: false
485
+ };
486
+ var ModelPrimaryKeyNames = ["model_id"];
487
+
488
+ // src/model/ModelRepository.ts
489
+ var compiledModelRecordSchema;
490
+ function getModelRecordSchemaNode() {
491
+ if (!compiledModelRecordSchema) {
492
+ compiledModelRecordSchema = compileSchema(ModelRecordSchema);
493
+ }
494
+ return compiledModelRecordSchema;
495
+ }
496
+ function validateModelRecord(model) {
497
+ const schemaNode = getModelRecordSchemaNode();
498
+ const result = schemaNode.validate(model);
499
+ if (!result.valid) {
500
+ const errorMessages = result.errors.map((e) => {
501
+ const path = e.data?.pointer || "";
502
+ return `${e.message}${path ? ` (${path})` : ""}`;
503
+ });
504
+ throw new Error(`Invalid model record: ${errorMessages.join(", ")}`);
505
+ }
506
+ }
417
507
 
418
508
  class ModelRepository {
419
509
  modelTabularRepository;
@@ -437,10 +527,25 @@ class ModelRepository {
437
527
  return this.events.waitOn(name);
438
528
  }
439
529
  async addModel(model) {
530
+ validateModelRecord(model);
531
+ const existing = await this.modelTabularRepository.get({ model_id: model.model_id });
532
+ if (existing) {
533
+ throw new Error(`Model with id "${model.model_id}" already exists`);
534
+ }
440
535
  await this.modelTabularRepository.put(model);
441
536
  this.events.emit("model_added", model);
442
537
  return model;
443
538
  }
539
+ async updateModel(model) {
540
+ validateModelRecord(model);
541
+ const existing = await this.modelTabularRepository.get({ model_id: model.model_id });
542
+ if (!existing) {
543
+ throw new Error(`Model with id "${model.model_id}" not found`);
544
+ }
545
+ await this.modelTabularRepository.put(model);
546
+ this.events.emit("model_updated", model);
547
+ return model;
548
+ }
444
549
  async removeModel(model_id) {
445
550
  const model = await this.modelTabularRepository.get({ model_id });
446
551
  if (!model) {
@@ -499,48 +604,6 @@ class ModelRepository {
499
604
  }
500
605
  }
501
606
 
502
- // src/model/ModelSchema.ts
503
- var ModelConfigSchema = {
504
- type: "object",
505
- properties: {
506
- model_id: { type: "string" },
507
- tasks: { type: "array", items: { type: "string" }, "x-ui-editor": "multiselect" },
508
- title: { type: "string" },
509
- description: { type: "string", "x-ui-editor": "textarea" },
510
- provider: { type: "string" },
511
- provider_config: {
512
- type: "object",
513
- properties: {
514
- credential_key: { type: "string", format: "credential", "x-ui-hidden": true }
515
- },
516
- additionalProperties: true,
517
- default: {}
518
- },
519
- metadata: { type: "object", default: {}, "x-ui-hidden": true }
520
- },
521
- required: ["provider", "provider_config"],
522
- format: "model",
523
- additionalProperties: true
524
- };
525
- var ModelRecordSchema = {
526
- type: "object",
527
- properties: {
528
- ...ModelConfigSchema.properties
529
- },
530
- required: [
531
- "model_id",
532
- "tasks",
533
- "provider",
534
- "title",
535
- "description",
536
- "provider_config",
537
- "metadata"
538
- ],
539
- format: "model",
540
- additionalProperties: false
541
- };
542
- var ModelPrimaryKeyNames = ["model_id"];
543
-
544
607
  // src/model/InMemoryModelRepository.ts
545
608
  class InMemoryModelRepository extends ModelRepository {
546
609
  constructor() {
@@ -552,12 +615,11 @@ class InMemoryModelRepository extends ModelRepository {
552
615
  import {
553
616
  createServiceToken,
554
617
  globalServiceRegistry as globalServiceRegistry2,
618
+ registerInputCompactor,
555
619
  registerInputResolver
556
620
  } from "@workglow/util";
557
621
  var MODEL_REPOSITORY = createServiceToken("model.repository");
558
- if (!globalServiceRegistry2.has(MODEL_REPOSITORY)) {
559
- globalServiceRegistry2.register(MODEL_REPOSITORY, () => new InMemoryModelRepository, true);
560
- }
622
+ globalServiceRegistry2.registerIfAbsent(MODEL_REPOSITORY, () => new InMemoryModelRepository, true);
561
623
  function getGlobalModelRepository() {
562
624
  return globalServiceRegistry2.get(MODEL_REPOSITORY);
563
625
  }
@@ -573,12 +635,22 @@ async function resolveModelFromRegistry(id, format, registry) {
573
635
  return model;
574
636
  }
575
637
  registerInputResolver("model", resolveModelFromRegistry);
638
+ registerInputCompactor("model", async (value, _format, registry) => {
639
+ if (typeof value === "object" && value !== null && "model_id" in value) {
640
+ const id = value.model_id;
641
+ if (typeof id !== "string")
642
+ return;
643
+ const modelRepo = registry.has(MODEL_REPOSITORY) ? registry.get(MODEL_REPOSITORY) : getGlobalModelRepository();
644
+ const model = await modelRepo.findByName(id);
645
+ if (!model)
646
+ return;
647
+ return id;
648
+ }
649
+ return;
650
+ });
576
651
 
577
652
  // src/provider/AiProvider.ts
578
- import {
579
- globalServiceRegistry as globalServiceRegistry3,
580
- WORKER_MANAGER as WORKER_MANAGER2
581
- } from "@workglow/util/worker";
653
+ import { globalServiceRegistry as globalServiceRegistry3, WORKER_MANAGER as WORKER_MANAGER2 } from "@workglow/util/worker";
582
654
  function resolveAiProviderGpuQueueConcurrency(concurrency) {
583
655
  if (concurrency === undefined) {
584
656
  return 1;
@@ -698,8 +770,74 @@ class QueuedAiProvider extends AiProvider {
698
770
  // src/task/index.ts
699
771
  import { TaskRegistry } from "@workglow/task-graph";
700
772
 
701
- // src/task/BackgroundRemovalTask.ts
702
- import { CreateWorkflow, Workflow } from "@workglow/task-graph";
773
+ // src/task/AgentTask.ts
774
+ import { CreateWorkflow as CreateWorkflow2, Task as Task2, Workflow as Workflow2 } from "@workglow/task-graph";
775
+ import { getLogger as getLogger4 } from "@workglow/util";
776
+
777
+ // src/task/AgentTypes.ts
778
+ import { parseDataUri } from "@workglow/util/media";
779
+ function imageBlock(mimeType, data) {
780
+ return { type: "image", mimeType, data };
781
+ }
782
+ function audioBlock(mimeType, data) {
783
+ return { type: "audio", mimeType, data };
784
+ }
785
+ function imageBlockFromDataUri(dataUri) {
786
+ const { mimeType, base64 } = parseDataUri(dataUri);
787
+ return { type: "image", mimeType, data: base64 };
788
+ }
789
+ function audioBlockFromDataUri(dataUri) {
790
+ const { mimeType, base64 } = parseDataUri(dataUri);
791
+ return { type: "audio", mimeType, data: base64 };
792
+ }
793
+ function userMessage(prompt) {
794
+ return { role: "user", content: prompt };
795
+ }
796
+ function assistantMessage(text, toolCalls) {
797
+ const content = [];
798
+ if (text) {
799
+ content.push({ type: "text", text });
800
+ }
801
+ if (toolCalls) {
802
+ for (const tc of toolCalls) {
803
+ content.push({
804
+ type: "tool_use",
805
+ id: tc.id,
806
+ name: tc.name,
807
+ input: tc.input
808
+ });
809
+ }
810
+ }
811
+ return { role: "assistant", content };
812
+ }
813
+ function toolMessage(results) {
814
+ return {
815
+ role: "tool",
816
+ content: results.map((r) => {
817
+ const jsonText = JSON.stringify(r.output);
818
+ const content = r.mediaContent && r.mediaContent.length > 0 ? [{ type: "text", text: jsonText }, ...r.mediaContent] : jsonText;
819
+ return {
820
+ type: "tool_result",
821
+ tool_use_id: r.toolCallId,
822
+ content,
823
+ is_error: r.isError || undefined
824
+ };
825
+ })
826
+ };
827
+ }
828
+ function toolSourceDefinitions(sources) {
829
+ return sources.map((s) => s.definition);
830
+ }
831
+ function findToolSource(sources, name) {
832
+ return sources.find((s) => s.definition.name === name);
833
+ }
834
+
835
+ // src/task/AgentUtils.ts
836
+ import { getTaskConstructors as getTaskConstructors2, TaskAbortedError } from "@workglow/task-graph";
837
+ import { getLogger as getLogger3 } from "@workglow/util";
838
+
839
+ // src/task/ToolCallingTask.ts
840
+ import { CreateWorkflow, getTaskConstructors, Workflow } from "@workglow/task-graph";
703
841
 
704
842
  // src/task/base/AiTaskSchemas.ts
705
843
  var TypeLanguage = (annotations = {}) => ({
@@ -858,11 +996,12 @@ var TypeCategory = {
858
996
  description: "Classification category with label and score"
859
997
  };
860
998
 
861
- // src/task/base/AiVisionTask.ts
862
- import { convertImageDataToUseableForm } from "@workglow/util/media";
999
+ // src/task/base/StreamingAiTask.ts
1000
+ import { getStreamingPorts, TaskConfigurationError as TaskConfigurationError3 } from "@workglow/task-graph";
863
1001
 
864
1002
  // src/task/base/AiTask.ts
865
1003
  import {
1004
+ Entitlements,
866
1005
  Task,
867
1006
  TaskConfigSchema,
868
1007
  TaskConfigurationError as TaskConfigurationError2,
@@ -881,6 +1020,27 @@ var aiTaskConfigSchema = {
881
1020
 
882
1021
  class AiTask extends Task {
883
1022
  static type = "AiTask";
1023
+ static hasDynamicEntitlements = true;
1024
+ static entitlements() {
1025
+ return {
1026
+ entitlements: [{ id: Entitlements.AI_INFERENCE, reason: "Runs AI model inference" }]
1027
+ };
1028
+ }
1029
+ entitlements() {
1030
+ const base = [
1031
+ { id: Entitlements.AI_INFERENCE, reason: "Runs AI model inference" }
1032
+ ];
1033
+ const runModel = this.runInputData?.model;
1034
+ const modelId = typeof runModel === "string" ? runModel : typeof this.defaults.model === "string" ? this.defaults.model : undefined;
1035
+ if (modelId) {
1036
+ base.push({
1037
+ id: Entitlements.AI_MODEL,
1038
+ reason: `Uses model ${modelId}`,
1039
+ resources: [modelId]
1040
+ });
1041
+ }
1042
+ return { entitlements: base };
1043
+ }
884
1044
  static configSchema() {
885
1045
  return aiTaskConfigSchema;
886
1046
  }
@@ -943,71 +1103,773 @@ class AiTask extends Task {
943
1103
  return reactiveFn(input, output, model);
944
1104
  }
945
1105
  }
946
- return super.executeReactive(input, output, context);
1106
+ return super.executeReactive(input, output, context);
1107
+ }
1108
+ async validateInput(input) {
1109
+ const inputSchema = this.inputSchema();
1110
+ if (typeof inputSchema === "boolean") {
1111
+ if (inputSchema === false) {
1112
+ throw new TaskConfigurationError2(`AiTask: Input schema is 'false' and accepts no inputs`);
1113
+ }
1114
+ return true;
1115
+ }
1116
+ const modelTaskProperties = Object.entries(inputSchema.properties || {}).filter(([key, schema]) => schemaFormat(schema)?.startsWith("model:"));
1117
+ for (const [key] of modelTaskProperties) {
1118
+ const model = input[key];
1119
+ if (typeof model === "object" && model !== null) {
1120
+ const tasks = model.tasks;
1121
+ if (Array.isArray(tasks) && tasks.length > 0 && !tasks.includes(this.type)) {
1122
+ const modelId = model.model_id ?? "(inline config)";
1123
+ throw new TaskConfigurationError2(`AiTask: Model "${modelId}" for '${key}' is not compatible with task '${this.type}'. ` + `Model supports: [${tasks.join(", ")}]`);
1124
+ }
1125
+ } else if (model !== undefined && model !== null) {
1126
+ throw new TaskConfigurationError2(`AiTask: Invalid model for '${key}' - expected ModelConfig object but got ${typeof model}. ` + `Ensure the model ID was registered in the ModelRepository before running the task.`);
1127
+ }
1128
+ }
1129
+ const modelPlainProperties = Object.entries(inputSchema.properties || {}).filter(([key, schema]) => schemaFormat(schema) === "model");
1130
+ for (const [key] of modelPlainProperties) {
1131
+ const model = input[key];
1132
+ if (model !== undefined && model !== null && typeof model !== "object") {
1133
+ throw new TaskConfigurationError2(`AiTask: Invalid model for '${key}' - expected ModelConfig object but got ${typeof model}. ` + `Ensure the model ID was registered in the ModelRepository before running the task.`);
1134
+ }
1135
+ }
1136
+ return super.validateInput(input);
1137
+ }
1138
+ async narrowInput(input, registry) {
1139
+ const inputSchema = this.inputSchema();
1140
+ if (typeof inputSchema === "boolean") {
1141
+ if (inputSchema === false) {
1142
+ throw new TaskConfigurationError2(`AiTask: Input schema is 'false' and accepts no inputs`);
1143
+ }
1144
+ return input;
1145
+ }
1146
+ const modelTaskProperties = Object.entries(inputSchema.properties || {}).filter(([key, schema]) => schemaFormat(schema)?.startsWith("model:"));
1147
+ if (modelTaskProperties.length > 0) {
1148
+ const modelRepo = registry.get(MODEL_REPOSITORY);
1149
+ const taskModels = await modelRepo.findModelsByTask(this.type) ?? [];
1150
+ for (const [key, propSchema] of modelTaskProperties) {
1151
+ const requestedModel = input[key];
1152
+ if (typeof requestedModel === "string") {
1153
+ const found = taskModels?.find((m) => m.model_id === requestedModel);
1154
+ if (!found) {
1155
+ input[key] = undefined;
1156
+ }
1157
+ } else if (typeof requestedModel === "object" && requestedModel !== null) {
1158
+ const model = requestedModel;
1159
+ const tasks = model.tasks;
1160
+ if (Array.isArray(tasks) && tasks.length > 0 && !tasks.includes(this.type)) {
1161
+ input[key] = undefined;
1162
+ }
1163
+ }
1164
+ }
1165
+ }
1166
+ return input;
1167
+ }
1168
+ }
1169
+
1170
+ // src/task/base/StreamingAiTask.ts
1171
+ class StreamingAiTask extends AiTask {
1172
+ static type = "StreamingAiTask";
1173
+ async* executeStream(input, context) {
1174
+ const model = input.model;
1175
+ if (!model || typeof model !== "object") {
1176
+ throw new TaskConfigurationError3("StreamingAiTask: Model was not resolved to ModelConfig - this indicates a bug in the resolution system");
1177
+ }
1178
+ const jobInput = await this.getJobInput(input);
1179
+ const strategy = getAiProviderRegistry().getStrategy(model);
1180
+ const outSchema = this.outputSchema();
1181
+ const ports = getStreamingPorts(outSchema);
1182
+ let defaultPort = "text";
1183
+ if (ports.length > 0) {
1184
+ defaultPort = ports[0].port;
1185
+ } else {
1186
+ if (typeof outSchema === "object" && outSchema.properties) {
1187
+ const firstProp = Object.keys(outSchema.properties)[0];
1188
+ if (firstProp)
1189
+ defaultPort = firstProp;
1190
+ }
1191
+ }
1192
+ for await (const event of strategy.executeStream(jobInput, context, this.runConfig.runnerId)) {
1193
+ if (event.type === "text-delta") {
1194
+ yield { ...event, port: event.port ?? defaultPort };
1195
+ } else if (event.type === "object-delta") {
1196
+ yield { ...event, port: event.port ?? defaultPort };
1197
+ } else {
1198
+ yield event;
1199
+ }
1200
+ }
1201
+ }
1202
+ }
1203
+
1204
+ // src/task/ToolCallingTask.ts
1205
+ function taskTypesToTools(taskNames, registry) {
1206
+ const constructors = getTaskConstructors(registry);
1207
+ return taskNames.map((name) => {
1208
+ const ctor = constructors.get(name);
1209
+ if (!ctor) {
1210
+ throw new Error(`taskTypesToTools: Unknown task type "${name}" \u2014 not found in task constructors registry (ServiceRegistry: ${registry ? "custom" : "default"})`);
1211
+ }
1212
+ const configSchema = "configSchema" in ctor && typeof ctor.configSchema === "function" ? ctor.configSchema() : undefined;
1213
+ return {
1214
+ name: ctor.type,
1215
+ description: ctor.description ?? "",
1216
+ inputSchema: ctor.inputSchema(),
1217
+ outputSchema: ctor.outputSchema(),
1218
+ ...configSchema ? { configSchema } : {},
1219
+ taskType: name
1220
+ };
1221
+ });
1222
+ }
1223
+ var ToolDefinitionSchema = {
1224
+ type: "object",
1225
+ properties: {
1226
+ name: {
1227
+ type: "string",
1228
+ title: "Name",
1229
+ description: "The tool name"
1230
+ },
1231
+ description: {
1232
+ type: "string",
1233
+ title: "Description",
1234
+ description: "A description of what the tool does"
1235
+ },
1236
+ inputSchema: {
1237
+ type: "object",
1238
+ title: "Input Schema",
1239
+ description: "JSON Schema describing the tool's input parameters",
1240
+ additionalProperties: true
1241
+ },
1242
+ outputSchema: {
1243
+ type: "object",
1244
+ title: "Output Schema",
1245
+ description: "JSON Schema describing what the tool returns",
1246
+ additionalProperties: true
1247
+ },
1248
+ configSchema: {
1249
+ type: "object",
1250
+ title: "Config Schema",
1251
+ description: "JSON Schema describing the task's configuration options (not sent to the LLM)",
1252
+ additionalProperties: true
1253
+ },
1254
+ config: {
1255
+ type: "object",
1256
+ title: "Config",
1257
+ description: "Concrete configuration values for the backing task (not sent to the LLM)",
1258
+ additionalProperties: true
1259
+ }
1260
+ },
1261
+ required: ["name", "description", "inputSchema"],
1262
+ additionalProperties: true
1263
+ };
1264
+ var ToolCallSchema = {
1265
+ type: "object",
1266
+ properties: {
1267
+ id: {
1268
+ type: "string",
1269
+ title: "ID",
1270
+ description: "Unique identifier for this tool call"
1271
+ },
1272
+ name: {
1273
+ type: "string",
1274
+ title: "Name",
1275
+ description: "The name of the tool to invoke"
1276
+ },
1277
+ input: {
1278
+ type: "object",
1279
+ title: "Input",
1280
+ description: "The input arguments for the tool call",
1281
+ additionalProperties: true
1282
+ }
1283
+ },
1284
+ required: ["id", "name", "input"],
1285
+ additionalProperties: false
1286
+ };
1287
+ var modelSchema = TypeModel("model:ToolCallingTask");
1288
+ var ToolCallingInputSchema = {
1289
+ type: "object",
1290
+ properties: {
1291
+ model: modelSchema,
1292
+ prompt: {
1293
+ oneOf: [
1294
+ { type: "string", title: "Prompt", description: "The prompt to send to the model" },
1295
+ {
1296
+ type: "array",
1297
+ title: "Prompt",
1298
+ description: "The prompt as an array of strings or content blocks",
1299
+ items: {
1300
+ oneOf: [
1301
+ { type: "string" },
1302
+ {
1303
+ type: "object",
1304
+ properties: {
1305
+ type: { type: "string", enum: ["text", "image", "audio"] }
1306
+ },
1307
+ required: ["type"],
1308
+ additionalProperties: true
1309
+ }
1310
+ ]
1311
+ }
1312
+ }
1313
+ ],
1314
+ title: "Prompt",
1315
+ description: "The prompt to send to the model"
1316
+ },
1317
+ systemPrompt: {
1318
+ type: "string",
1319
+ title: "System Prompt",
1320
+ description: "Optional system instructions for the model"
1321
+ },
1322
+ messages: {
1323
+ type: "array",
1324
+ title: "Messages",
1325
+ description: "Full conversation history for multi-turn interactions. When provided, used instead of prompt to construct the messages array sent to the provider.",
1326
+ items: {
1327
+ type: "object",
1328
+ properties: {
1329
+ role: { type: "string", enum: ["user", "assistant", "tool"] },
1330
+ content: {}
1331
+ },
1332
+ required: ["role", "content"],
1333
+ additionalProperties: true
1334
+ }
1335
+ },
1336
+ tools: {
1337
+ type: "array",
1338
+ format: "tasks",
1339
+ title: "Tools",
1340
+ description: "Tool definitions available for the model to call",
1341
+ items: {
1342
+ oneOf: [
1343
+ { type: "string", format: "tasks", description: "Task type name" },
1344
+ ToolDefinitionSchema
1345
+ ]
1346
+ }
1347
+ },
1348
+ toolChoice: {
1349
+ type: "string",
1350
+ title: "Tool Choice",
1351
+ description: 'Controls tool selection: "auto" (model decides), "none" (no tools), "required" (must call a tool), or a specific tool name',
1352
+ "x-ui-group": "Configuration"
1353
+ },
1354
+ maxTokens: {
1355
+ type: "number",
1356
+ title: "Max Tokens",
1357
+ description: "The maximum number of tokens to generate",
1358
+ minimum: 1,
1359
+ "x-ui-group": "Configuration"
1360
+ },
1361
+ temperature: {
1362
+ type: "number",
1363
+ title: "Temperature",
1364
+ description: "The temperature to use for sampling",
1365
+ minimum: 0,
1366
+ maximum: 2,
1367
+ "x-ui-group": "Configuration"
1368
+ }
1369
+ },
1370
+ required: ["model", "prompt", "tools"],
1371
+ additionalProperties: false
1372
+ };
1373
+ var ToolCallingOutputSchema = {
1374
+ type: "object",
1375
+ properties: {
1376
+ text: {
1377
+ type: "string",
1378
+ title: "Text",
1379
+ description: "Any text content generated by the model",
1380
+ "x-stream": "append"
1381
+ },
1382
+ toolCalls: {
1383
+ type: "array",
1384
+ items: ToolCallSchema,
1385
+ title: "Tool Calls",
1386
+ description: "Tool calls requested by the model",
1387
+ "x-stream": "object"
1388
+ }
1389
+ },
1390
+ required: ["text", "toolCalls"],
1391
+ additionalProperties: false
1392
+ };
1393
+
1394
+ class ToolCallingTask extends StreamingAiTask {
1395
+ static type = "ToolCallingTask";
1396
+ static category = "AI Text Model";
1397
+ static title = "Tool Calling";
1398
+ static description = "Sends a prompt with tool definitions to a language model and returns text along with any tool calls the model requests";
1399
+ static inputSchema() {
1400
+ return ToolCallingInputSchema;
1401
+ }
1402
+ static outputSchema() {
1403
+ return ToolCallingOutputSchema;
1404
+ }
1405
+ }
1406
+ var toolCalling = (input, config) => {
1407
+ return new ToolCallingTask(config).run(input);
1408
+ };
1409
+ Workflow.prototype.toolCalling = CreateWorkflow(ToolCallingTask);
1410
+
1411
+ // src/task/AgentUtils.ts
1412
+ function resolveToolConfig(toolName, config, taskConfigSchema) {
1413
+ if (config && !taskConfigSchema) {
1414
+ getLogger3().warn(`AgentTask: Tool "${toolName}" provided config but task has no configSchema \u2014 config ignored`);
1415
+ return {};
1416
+ }
1417
+ return config;
1418
+ }
1419
+ function buildToolSources(tools, registry) {
1420
+ if (!tools || tools.length === 0)
1421
+ return [];
1422
+ const stringNames = tools.filter((t) => typeof t === "string");
1423
+ const resolvedDefs = new Map(taskTypesToTools(stringNames, registry).map((d) => [d.taskType, d]));
1424
+ const constructors = getTaskConstructors2(registry);
1425
+ const sources = [];
1426
+ for (const tool of tools) {
1427
+ if (typeof tool === "string") {
1428
+ const def = resolvedDefs.get(tool);
1429
+ if (def) {
1430
+ const { taskType, ...definition } = def;
1431
+ sources.push({
1432
+ type: "registry",
1433
+ definition,
1434
+ taskType
1435
+ });
1436
+ }
1437
+ } else if (tool.type === "function" || !tool.type && tool.execute) {
1438
+ if (!tool.execute) {
1439
+ getLogger3().warn(`AgentTask: Tool "${tool.name}" has type "function" but no execute function \u2014 will throw on invocation`);
1440
+ }
1441
+ const { execute, configSchema: _cs, config: _c, type: _t, ...definition } = tool;
1442
+ sources.push({
1443
+ type: "function",
1444
+ definition,
1445
+ run: execute ?? (async () => {
1446
+ throw new Error(`No execute function for tool "${tool.name}"`);
1447
+ })
1448
+ });
1449
+ } else if (tool.type === "task") {
1450
+ const ctor = constructors.get(tool.name);
1451
+ if (!ctor) {
1452
+ getLogger3().warn(`AgentTask: Tool "${tool.name}" has type "task" but is not in TaskRegistry \u2014 will throw on invocation`);
1453
+ const { execute: _e, configSchema: _cs, config: _c, type: _t, ...definition } = tool;
1454
+ sources.push({
1455
+ type: "function",
1456
+ definition,
1457
+ run: async () => {
1458
+ throw new Error(`Task "${tool.name}" not found in TaskRegistry`);
1459
+ }
1460
+ });
1461
+ } else {
1462
+ const safeConfig = resolveToolConfig(tool.name, tool.config, ctor.configSchema?.());
1463
+ const { execute: _e, configSchema: _cs, config: _c, type: _t, ...definition } = tool;
1464
+ sources.push({
1465
+ type: "registry",
1466
+ definition,
1467
+ taskType: tool.name,
1468
+ config: safeConfig
1469
+ });
1470
+ }
1471
+ } else {
1472
+ const ctor = constructors.get(tool.name);
1473
+ if (ctor) {
1474
+ const safeConfig = resolveToolConfig(tool.name, tool.config, ctor.configSchema?.());
1475
+ const { execute: _e, configSchema: _cs, config: _c, type: _t, ...definition } = tool;
1476
+ sources.push({
1477
+ type: "registry",
1478
+ definition,
1479
+ taskType: tool.name,
1480
+ config: safeConfig
1481
+ });
1482
+ } else {
1483
+ const { execute: _e, configSchema: _cs, config: _c, type: _t, ...definition } = tool;
1484
+ sources.push({
1485
+ type: "function",
1486
+ definition,
1487
+ run: async () => {
1488
+ throw new Error(`No executor registered for tool "${tool.name}"`);
1489
+ }
1490
+ });
1491
+ }
1492
+ }
1493
+ }
1494
+ return sources;
1495
+ }
1496
+ async function executeToolCall(toolCall, sources, context, hooks) {
1497
+ const source = findToolSource(sources, toolCall.name);
1498
+ if (!source) {
1499
+ getLogger3().warn(`AgentTask: Unknown tool "${toolCall.name}" \u2014 not found in tool sources`);
1500
+ return {
1501
+ toolCallId: toolCall.id,
1502
+ toolName: toolCall.name,
1503
+ output: { error: `Unknown tool: ${toolCall.name}` },
1504
+ isError: true
1505
+ };
1506
+ }
1507
+ let effectiveCall = toolCall;
1508
+ if (hooks?.beforeToolCall) {
1509
+ const decision = await hooks.beforeToolCall(toolCall, source);
1510
+ if (decision.action === "deny") {
1511
+ return {
1512
+ toolCallId: toolCall.id,
1513
+ toolName: toolCall.name,
1514
+ output: { error: decision.reason ?? "Tool call denied by hook" },
1515
+ isError: true
1516
+ };
1517
+ }
1518
+ if (decision.action === "modify") {
1519
+ effectiveCall = { ...toolCall, input: decision.input };
1520
+ }
1521
+ }
1522
+ try {
1523
+ let output;
1524
+ switch (source.type) {
1525
+ case "registry": {
1526
+ const ctor = getTaskConstructors2(context.registry).get(source.taskType);
1527
+ if (!ctor) {
1528
+ throw new Error(`Task type "${source.taskType}" not found in TaskRegistry`);
1529
+ }
1530
+ const taskConfig = source.config ?? {};
1531
+ const task = context.own(new ctor({}, taskConfig));
1532
+ output = await task.run(effectiveCall.input) ?? {};
1533
+ break;
1534
+ }
1535
+ case "function": {
1536
+ output = await source.run(effectiveCall.input);
1537
+ break;
1538
+ }
1539
+ }
1540
+ let result = {
1541
+ toolCallId: toolCall.id,
1542
+ toolName: toolCall.name,
1543
+ output,
1544
+ isError: false
1545
+ };
1546
+ if (hooks?.afterToolCall) {
1547
+ result = await hooks.afterToolCall(toolCall, result);
1548
+ }
1549
+ return result;
1550
+ } catch (err) {
1551
+ const error = err instanceof Error ? err : new Error(String(err));
1552
+ if (hooks?.onToolError) {
1553
+ const action = await hooks.onToolError(toolCall, error);
1554
+ if (action.action === "result") {
1555
+ return {
1556
+ toolCallId: toolCall.id,
1557
+ toolName: toolCall.name,
1558
+ output: action.output,
1559
+ isError: false
1560
+ };
1561
+ }
1562
+ }
1563
+ getLogger3().warn(`AgentTask: Tool "${toolCall.name}" failed: ${error.message}`);
1564
+ return {
1565
+ toolCallId: toolCall.id,
1566
+ toolName: toolCall.name,
1567
+ output: { error: error.message },
1568
+ isError: true
1569
+ };
1570
+ }
1571
+ }
1572
+ async function executeToolCalls(toolCalls, sources, context, hooks, maxConcurrency = 5) {
1573
+ const calls = toolCalls;
1574
+ if (calls.length === 0)
1575
+ return [];
1576
+ const concurrency = Math.max(1, Math.min(maxConcurrency, calls.length));
1577
+ const results = new Array(calls.length);
1578
+ let cursor = 0;
1579
+ const workers = Array.from({ length: concurrency }, async () => {
1580
+ while (true) {
1581
+ if (context.signal.aborted) {
1582
+ throw context.signal.reason ?? new TaskAbortedError("The operation was aborted");
1583
+ }
1584
+ const position = cursor;
1585
+ cursor += 1;
1586
+ if (position >= calls.length)
1587
+ return;
1588
+ results[position] = await executeToolCall(calls[position], sources, context, hooks);
1589
+ }
1590
+ });
1591
+ await Promise.all(workers);
1592
+ return results;
1593
+ }
1594
+ function hasToolCalls(toolCalls) {
1595
+ return toolCalls !== undefined && toolCalls.length > 0;
1596
+ }
1597
+ function countAssistantToolUses(messages) {
1598
+ let n = 0;
1599
+ for (const m of messages) {
1600
+ if (m.role !== "assistant")
1601
+ continue;
1602
+ for (const block of m.content) {
1603
+ if (block.type === "tool_use")
1604
+ n += 1;
1605
+ }
1606
+ }
1607
+ return n;
1608
+ }
1609
+
1610
+ // src/task/AgentTask.ts
1611
+ var MAX_CONTEXT_MESSAGES = 1000;
1612
+ var modelSchema2 = TypeModel("model:ToolCallingTask");
1613
+ var AgentInputSchema = {
1614
+ type: "object",
1615
+ properties: {
1616
+ model: modelSchema2,
1617
+ prompt: {
1618
+ oneOf: [
1619
+ { type: "string" },
1620
+ {
1621
+ type: "array",
1622
+ items: {
1623
+ type: "object",
1624
+ properties: {
1625
+ type: { type: "string", enum: ["text", "image", "audio"] }
1626
+ },
1627
+ required: ["type"],
1628
+ additionalProperties: true
1629
+ }
1630
+ }
1631
+ ],
1632
+ title: "Prompt",
1633
+ description: "The user prompt to start the agent loop. Can be a string or an array of content blocks (text, image, audio)."
1634
+ },
1635
+ systemPrompt: {
1636
+ type: "string",
1637
+ title: "System Prompt",
1638
+ description: "Optional system instructions for the agent"
1639
+ },
1640
+ tools: {
1641
+ type: "array",
1642
+ format: "tasks",
1643
+ title: "Tools",
1644
+ description: "Tools available to the agent. Each entry is a task type name (string, resolved from TaskRegistry) or a full ToolDefinition object with optional config for configurable tasks.",
1645
+ items: {
1646
+ oneOf: [
1647
+ { type: "string", format: "tasks", description: "Task type name" },
1648
+ ToolDefinitionSchema
1649
+ ]
1650
+ }
1651
+ },
1652
+ stopTool: {
1653
+ type: "string",
1654
+ title: "Stop Tool",
1655
+ description: "Name of a tool that signals agent completion. When called, the loop ends and the tool input becomes structuredOutput.",
1656
+ "x-ui-group": "Configuration"
1657
+ },
1658
+ maxIterations: {
1659
+ type: "number",
1660
+ title: "Max Iterations",
1661
+ description: "Maximum number of agent loop iterations (default: 10)",
1662
+ minimum: 1,
1663
+ "x-ui-group": "Configuration"
1664
+ },
1665
+ maxContextMessages: {
1666
+ type: "number",
1667
+ title: "Max Context Messages",
1668
+ description: "Maximum messages in conversation history. Older messages are trimmed to prevent context overflow.",
1669
+ minimum: 3,
1670
+ "x-ui-group": "Configuration"
1671
+ },
1672
+ maxTokens: {
1673
+ type: "number",
1674
+ title: "Max Tokens",
1675
+ description: "Maximum tokens per LLM call",
1676
+ minimum: 1,
1677
+ "x-ui-group": "Configuration"
1678
+ },
1679
+ temperature: {
1680
+ type: "number",
1681
+ title: "Temperature",
1682
+ description: "Sampling temperature for LLM calls",
1683
+ minimum: 0,
1684
+ maximum: 2,
1685
+ "x-ui-group": "Configuration"
1686
+ }
1687
+ },
1688
+ required: ["model", "prompt"],
1689
+ additionalProperties: false
1690
+ };
1691
+ var AgentOutputSchema = {
1692
+ type: "object",
1693
+ properties: {
1694
+ text: {
1695
+ type: "string",
1696
+ title: "Text",
1697
+ description: "The final text response from the agent",
1698
+ "x-stream": "append"
1699
+ },
1700
+ messages: {
1701
+ type: "array",
1702
+ title: "Messages",
1703
+ description: "Full conversation history including all tool calls and results",
1704
+ items: {
1705
+ type: "object",
1706
+ additionalProperties: true
1707
+ }
1708
+ },
1709
+ iterations: {
1710
+ type: "number",
1711
+ title: "Iterations",
1712
+ description: "Number of LLM calls made during the agent loop"
1713
+ },
1714
+ toolCallCount: {
1715
+ type: "number",
1716
+ title: "Tool Call Count",
1717
+ description: "Total number of tool calls the assistant requested (tool_use blocks in assistant messages)"
1718
+ },
1719
+ structuredOutput: {
1720
+ type: "object",
1721
+ title: "Structured Output",
1722
+ description: "Present when the agent terminated via a stop tool",
1723
+ additionalProperties: true
1724
+ }
1725
+ },
1726
+ required: ["text", "messages", "iterations", "toolCallCount"],
1727
+ additionalProperties: false
1728
+ };
1729
+
1730
+ class AgentTask extends Task2 {
1731
+ static type = "AgentTask";
1732
+ static category = "AI Agent";
1733
+ static title = "Agent";
1734
+ static description = "Multi-turn agentic loop that calls an LLM with tools, executes tool calls, and iterates until done";
1735
+ static cacheable = false;
1736
+ static inputSchema() {
1737
+ return AgentInputSchema;
947
1738
  }
948
- async validateInput(input) {
949
- const inputSchema = this.inputSchema();
950
- if (typeof inputSchema === "boolean") {
951
- if (inputSchema === false) {
952
- throw new TaskConfigurationError2(`AiTask: Input schema is 'false' and accepts no inputs`);
953
- }
954
- return true;
955
- }
956
- const modelTaskProperties = Object.entries(inputSchema.properties || {}).filter(([key, schema]) => schemaFormat(schema)?.startsWith("model:"));
957
- for (const [key] of modelTaskProperties) {
958
- const model = input[key];
959
- if (typeof model === "object" && model !== null) {
960
- const tasks = model.tasks;
961
- if (Array.isArray(tasks) && tasks.length > 0 && !tasks.includes(this.type)) {
962
- const modelId = model.model_id ?? "(inline config)";
963
- throw new TaskConfigurationError2(`AiTask: Model "${modelId}" for '${key}' is not compatible with task '${this.type}'. ` + `Model supports: [${tasks.join(", ")}]`);
964
- }
965
- } else if (model !== undefined && model !== null) {
966
- throw new TaskConfigurationError2(`AiTask: Invalid model for '${key}' - expected ModelConfig object but got ${typeof model}. ` + `Ensure the model ID was registered in the ModelRepository before running the task.`);
1739
+ static outputSchema() {
1740
+ return AgentOutputSchema;
1741
+ }
1742
+ async execute(input, context) {
1743
+ let result;
1744
+ for await (const event of this.agentLoop(input, context)) {
1745
+ if (event.type === "finish") {
1746
+ result = event.data;
967
1747
  }
968
1748
  }
969
- const modelPlainProperties = Object.entries(inputSchema.properties || {}).filter(([key, schema]) => schemaFormat(schema) === "model");
970
- for (const [key] of modelPlainProperties) {
971
- const model = input[key];
972
- if (model !== undefined && model !== null && typeof model !== "object") {
973
- throw new TaskConfigurationError2(`AiTask: Invalid model for '${key}' - expected ModelConfig object but got ${typeof model}. ` + `Ensure the model ID was registered in the ModelRepository before running the task.`);
974
- }
1749
+ if (!result) {
1750
+ throw new Error("AgentTask: loop ended without producing output");
975
1751
  }
976
- return super.validateInput(input);
1752
+ return result;
977
1753
  }
978
- async narrowInput(input, registry) {
979
- const inputSchema = this.inputSchema();
980
- if (typeof inputSchema === "boolean") {
981
- if (inputSchema === false) {
982
- throw new TaskConfigurationError2(`AiTask: Input schema is 'false' and accepts no inputs`);
1754
+ async* executeStream(input, context) {
1755
+ yield* this.agentLoop(input, context);
1756
+ }
1757
+ async* agentLoop(input, context) {
1758
+ const maxIterations = input.maxIterations ?? 10;
1759
+ const hooks = this.config.hooks;
1760
+ const maxConcurrency = this.config.maxConcurrency ?? 5;
1761
+ const toolSources = this.resolveToolSources(input, context);
1762
+ const toolDefs = this.resolveToolDefs(toolSources, input.stopTool);
1763
+ const messages = [userMessage(input.prompt)];
1764
+ let finalText = "";
1765
+ let structuredOutput;
1766
+ for (let iteration = 0;iteration < maxIterations; iteration++) {
1767
+ if (context.signal.aborted)
1768
+ break;
1769
+ if (hooks?.onIteration) {
1770
+ const action = await hooks.onIteration(iteration, messages, {
1771
+ totalToolCalls: countAssistantToolUses(messages)
1772
+ });
1773
+ if (action.action === "stop")
1774
+ break;
983
1775
  }
984
- return input;
985
- }
986
- const modelTaskProperties = Object.entries(inputSchema.properties || {}).filter(([key, schema]) => schemaFormat(schema)?.startsWith("model:"));
987
- if (modelTaskProperties.length > 0) {
988
- const modelRepo = registry.get(MODEL_REPOSITORY);
989
- const taskModels = await modelRepo.findModelsByTask(this.type) ?? [];
990
- for (const [key, propSchema] of modelTaskProperties) {
991
- const requestedModel = input[key];
992
- if (typeof requestedModel === "string") {
993
- const found = taskModels?.find((m) => m.model_id === requestedModel);
994
- if (!found) {
995
- input[key] = undefined;
1776
+ await context.updateProgress(Math.round(iteration / maxIterations * 100), `Agent iteration ${iteration + 1}`);
1777
+ const contextMessages = this.trimMessages(messages, input.maxContextMessages ?? MAX_CONTEXT_MESSAGES);
1778
+ const llmTask = context.own(new ToolCallingTask);
1779
+ let iterationText = "";
1780
+ let toolCalls = [];
1781
+ for await (const event of llmTask.executeStream({
1782
+ model: input.model,
1783
+ prompt: input.prompt,
1784
+ systemPrompt: input.systemPrompt,
1785
+ tools: toolDefs,
1786
+ messages: contextMessages,
1787
+ maxTokens: input.maxTokens,
1788
+ temperature: input.temperature
1789
+ }, context)) {
1790
+ if (event.type === "text-delta") {
1791
+ yield { type: "text-delta", port: "text", textDelta: event.textDelta };
1792
+ iterationText += event.textDelta;
1793
+ } else if (event.type === "object-delta" && event.port === "toolCalls") {
1794
+ const items = event.objectDelta;
1795
+ for (const item of items) {
1796
+ const idx = toolCalls.findIndex((tc) => tc.id === item.id);
1797
+ if (idx >= 0)
1798
+ toolCalls[idx] = item;
1799
+ else
1800
+ toolCalls.push(item);
996
1801
  }
997
- } else if (typeof requestedModel === "object" && requestedModel !== null) {
998
- const model = requestedModel;
999
- const tasks = model.tasks;
1000
- if (Array.isArray(tasks) && tasks.length > 0 && !tasks.includes(this.type)) {
1001
- input[key] = undefined;
1802
+ } else if (event.type === "finish") {
1803
+ const data = event.data;
1804
+ iterationText = data?.text ?? iterationText;
1805
+ if (data?.toolCalls && data.toolCalls.length > 0) {
1806
+ toolCalls = data.toolCalls;
1002
1807
  }
1003
1808
  }
1004
1809
  }
1810
+ finalText = iterationText;
1811
+ messages.push(assistantMessage(iterationText, toolCalls));
1812
+ if (input.stopTool) {
1813
+ const stopCall = toolCalls.find((tc) => tc.name === input.stopTool);
1814
+ if (stopCall) {
1815
+ structuredOutput = stopCall.input;
1816
+ break;
1817
+ }
1818
+ }
1819
+ if (!hasToolCalls(toolCalls)) {
1820
+ break;
1821
+ }
1822
+ const results = await executeToolCalls(toolCalls, toolSources, context, hooks, maxConcurrency);
1823
+ messages.push(toolMessage(results));
1005
1824
  }
1006
- return input;
1825
+ const output = {
1826
+ text: finalText,
1827
+ messages,
1828
+ iterations: messages.filter((m) => m.role === "assistant").length,
1829
+ toolCallCount: countAssistantToolUses(messages),
1830
+ ...structuredOutput !== undefined ? { structuredOutput } : {}
1831
+ };
1832
+ yield { type: "finish", data: output };
1833
+ }
1834
+ resolveToolSources(input, context) {
1835
+ return buildToolSources(input.tools, context.registry);
1836
+ }
1837
+ resolveToolDefs(toolSources, stopTool) {
1838
+ const defs = toolSourceDefinitions(toolSources);
1839
+ if (stopTool && !defs.some((d) => d.name === stopTool)) {
1840
+ defs.push({
1841
+ name: stopTool,
1842
+ description: "Call this tool when you have completed the task. Pass your final structured result as the input.",
1843
+ inputSchema: { type: "object", additionalProperties: true }
1844
+ });
1845
+ }
1846
+ return defs;
1847
+ }
1848
+ trimMessages(messages, maxContextMessages) {
1849
+ if (!maxContextMessages || messages.length <= maxContextMessages) {
1850
+ return messages;
1851
+ }
1852
+ getLogger4().debug(`AgentTask: Trimming context from ${messages.length} to ${maxContextMessages} messages`);
1853
+ const tail = messages.slice(1);
1854
+ let startIdx = tail.length - (maxContextMessages - 1);
1855
+ if (startIdx < 0)
1856
+ startIdx = 0;
1857
+ while (startIdx > 0 && startIdx < tail.length && tail[startIdx].role === "tool") {
1858
+ startIdx -= 1;
1859
+ }
1860
+ return [messages[0], ...tail.slice(startIdx)];
1007
1861
  }
1008
1862
  }
1863
+ var agent = (input, config) => {
1864
+ return new AgentTask(config).run(input);
1865
+ };
1866
+ Workflow2.prototype.agent = CreateWorkflow2(AgentTask);
1867
+
1868
+ // src/task/BackgroundRemovalTask.ts
1869
+ import { CreateWorkflow as CreateWorkflow3, Workflow as Workflow3 } from "@workglow/task-graph";
1009
1870
 
1010
1871
  // src/task/base/AiVisionTask.ts
1872
+ import { convertImageDataToUseableForm } from "@workglow/util/media";
1011
1873
  class AiVisionTask extends AiTask {
1012
1874
  static type = "AiVisionTask";
1013
1875
  async getJobInput(input) {
@@ -1028,7 +1890,7 @@ class AiVisionTask extends AiTask {
1028
1890
  }
1029
1891
 
1030
1892
  // src/task/BackgroundRemovalTask.ts
1031
- var modelSchema = TypeModel("model:BackgroundRemovalTask");
1893
+ var modelSchema3 = TypeModel("model:BackgroundRemovalTask");
1032
1894
  var processedImageSchema = {
1033
1895
  type: "string",
1034
1896
  contentEncoding: "base64",
@@ -1040,7 +1902,7 @@ var BackgroundRemovalInputSchema = {
1040
1902
  type: "object",
1041
1903
  properties: {
1042
1904
  image: TypeImageInput,
1043
- model: modelSchema
1905
+ model: modelSchema3
1044
1906
  },
1045
1907
  required: ["image", "model"],
1046
1908
  additionalProperties: false
@@ -1067,24 +1929,24 @@ class BackgroundRemovalTask extends AiVisionTask {
1067
1929
  }
1068
1930
  }
1069
1931
  var backgroundRemoval = (input, config) => {
1070
- return new BackgroundRemovalTask({}, config).run(input);
1932
+ return new BackgroundRemovalTask(config).run(input);
1071
1933
  };
1072
- Workflow.prototype.backgroundRemoval = CreateWorkflow(BackgroundRemovalTask);
1934
+ Workflow3.prototype.backgroundRemoval = CreateWorkflow3(BackgroundRemovalTask);
1073
1935
 
1074
1936
  // src/task/ChunkRetrievalTask.ts
1075
1937
  import { TypeKnowledgeBase } from "@workglow/knowledge-base";
1076
- import { CreateWorkflow as CreateWorkflow3, Task as Task2, Workflow as Workflow3 } from "@workglow/task-graph";
1938
+ import { CreateWorkflow as CreateWorkflow5, Task as Task3, Workflow as Workflow5 } from "@workglow/task-graph";
1077
1939
  import {
1078
1940
  isTypedArray,
1079
1941
  TypedArraySchema as TypedArraySchema2
1080
1942
  } from "@workglow/util/schema";
1081
1943
 
1082
1944
  // src/task/TextEmbeddingTask.ts
1083
- import { CreateWorkflow as CreateWorkflow2, Workflow as Workflow2 } from "@workglow/task-graph";
1945
+ import { CreateWorkflow as CreateWorkflow4, Workflow as Workflow4 } from "@workglow/task-graph";
1084
1946
  import {
1085
1947
  TypedArraySchema
1086
1948
  } from "@workglow/util/schema";
1087
- var modelSchema2 = TypeModel("model:TextEmbeddingTask");
1949
+ var modelSchema4 = TypeModel("model:TextEmbeddingTask");
1088
1950
  var TextEmbeddingInputSchema = {
1089
1951
  type: "object",
1090
1952
  properties: {
@@ -1093,7 +1955,7 @@ var TextEmbeddingInputSchema = {
1093
1955
  title: "Text",
1094
1956
  description: "The text to embed"
1095
1957
  }),
1096
- model: modelSchema2
1958
+ model: modelSchema4
1097
1959
  },
1098
1960
  required: ["text", "model"],
1099
1961
  additionalProperties: false
@@ -1123,9 +1985,9 @@ class TextEmbeddingTask extends AiTask {
1123
1985
  }
1124
1986
  }
1125
1987
  var textEmbedding = async (input, config) => {
1126
- return new TextEmbeddingTask({}, config).run(input);
1988
+ return new TextEmbeddingTask(config).run(input);
1127
1989
  };
1128
- Workflow2.prototype.textEmbedding = CreateWorkflow2(TextEmbeddingTask);
1990
+ Workflow4.prototype.textEmbedding = CreateWorkflow4(TextEmbeddingTask);
1129
1991
 
1130
1992
  // src/task/ChunkRetrievalTask.ts
1131
1993
  var inputSchema = {
@@ -1250,7 +2112,7 @@ var outputSchema = {
1250
2112
  additionalProperties: false
1251
2113
  };
1252
2114
 
1253
- class ChunkRetrievalTask extends Task2 {
2115
+ class ChunkRetrievalTask extends Task3 {
1254
2116
  static type = "ChunkRetrievalTask";
1255
2117
  static category = "RAG";
1256
2118
  static title = "Chunk Retrieval";
@@ -1278,8 +2140,8 @@ class ChunkRetrievalTask extends Task2 {
1278
2140
  if (!model) {
1279
2141
  throw new Error("Model is required when query is a string. Please provide a model with format 'model:TextEmbeddingTask'.");
1280
2142
  }
1281
- const embeddingTask = context.own(new TextEmbeddingTask({ text: query, model }));
1282
- const embeddingResult = await embeddingTask.run();
2143
+ const embeddingTask = context.own(new TextEmbeddingTask);
2144
+ const embeddingResult = await embeddingTask.run({ text: query, model });
1283
2145
  queryVectors = Array.isArray(embeddingResult.vector) ? embeddingResult.vector : [embeddingResult.vector];
1284
2146
  } else if (isTypedArray(query) || Array.isArray(query) && query.every(isTypedArray)) {
1285
2147
  queryVectors = Array.isArray(query) ? query : [query];
@@ -1315,13 +2177,13 @@ class ChunkRetrievalTask extends Task2 {
1315
2177
  }
1316
2178
  }
1317
2179
  var chunkRetrieval = (input, config) => {
1318
- return new ChunkRetrievalTask({}, config).run(input);
2180
+ return new ChunkRetrievalTask(config).run(input);
1319
2181
  };
1320
- Workflow3.prototype.chunkRetrieval = CreateWorkflow3(ChunkRetrievalTask);
2182
+ Workflow5.prototype.chunkRetrieval = CreateWorkflow5(ChunkRetrievalTask);
1321
2183
 
1322
2184
  // src/task/ChunkToVectorTask.ts
1323
2185
  import { ChunkRecordSchema } from "@workglow/knowledge-base";
1324
- import { CreateWorkflow as CreateWorkflow4, Task as Task3, Workflow as Workflow4 } from "@workglow/task-graph";
2186
+ import { CreateWorkflow as CreateWorkflow6, Task as Task4, Workflow as Workflow6 } from "@workglow/task-graph";
1325
2187
  import {
1326
2188
  TypedArraySchema as TypedArraySchema3
1327
2189
  } from "@workglow/util/schema";
@@ -1396,7 +2258,7 @@ var outputSchema2 = {
1396
2258
  additionalProperties: false
1397
2259
  };
1398
2260
 
1399
- class ChunkToVectorTask extends Task3 {
2261
+ class ChunkToVectorTask extends Task4 {
1400
2262
  static type = "ChunkToVectorTask";
1401
2263
  static category = "Document";
1402
2264
  static title = "Chunk to Vector";
@@ -1445,13 +2307,13 @@ class ChunkToVectorTask extends Task3 {
1445
2307
  }
1446
2308
  }
1447
2309
  var chunkToVector = (input, config) => {
1448
- return new ChunkToVectorTask({}, config).run(input);
2310
+ return new ChunkToVectorTask(config).run(input);
1449
2311
  };
1450
- Workflow4.prototype.chunkToVector = CreateWorkflow4(ChunkToVectorTask);
2312
+ Workflow6.prototype.chunkToVector = CreateWorkflow6(ChunkToVectorTask);
1451
2313
 
1452
2314
  // src/task/ChunkVectorHybridSearchTask.ts
1453
2315
  import { TypeKnowledgeBase as TypeKnowledgeBase2 } from "@workglow/knowledge-base";
1454
- import { CreateWorkflow as CreateWorkflow5, Task as Task4, Workflow as Workflow5 } from "@workglow/task-graph";
2316
+ import { CreateWorkflow as CreateWorkflow7, Task as Task5, Workflow as Workflow7 } from "@workglow/task-graph";
1455
2317
  import {
1456
2318
  TypedArraySchema as TypedArraySchema4
1457
2319
  } from "@workglow/util/schema";
@@ -1564,7 +2426,7 @@ var outputSchema3 = {
1564
2426
  additionalProperties: false
1565
2427
  };
1566
2428
 
1567
- class ChunkVectorHybridSearchTask extends Task4 {
2429
+ class ChunkVectorHybridSearchTask extends Task5 {
1568
2430
  static type = "ChunkVectorHybridSearchTask";
1569
2431
  static category = "RAG";
1570
2432
  static title = "Hybrid Search";
@@ -1615,13 +2477,13 @@ class ChunkVectorHybridSearchTask extends Task4 {
1615
2477
  }
1616
2478
  }
1617
2479
  var hybridSearch = async (input, config) => {
1618
- return new ChunkVectorHybridSearchTask({}, config).run(input);
2480
+ return new ChunkVectorHybridSearchTask(config).run(input);
1619
2481
  };
1620
- Workflow5.prototype.hybridSearch = CreateWorkflow5(ChunkVectorHybridSearchTask);
2482
+ Workflow7.prototype.hybridSearch = CreateWorkflow7(ChunkVectorHybridSearchTask);
1621
2483
 
1622
2484
  // src/task/ChunkVectorSearchTask.ts
1623
2485
  import { TypeKnowledgeBase as TypeKnowledgeBase3 } from "@workglow/knowledge-base";
1624
- import { CreateWorkflow as CreateWorkflow6, Task as Task5, Workflow as Workflow6 } from "@workglow/task-graph";
2486
+ import { CreateWorkflow as CreateWorkflow8, Task as Task6, Workflow as Workflow8 } from "@workglow/task-graph";
1625
2487
  import {
1626
2488
  TypedArraySchema as TypedArraySchema5
1627
2489
  } from "@workglow/util/schema";
@@ -1704,7 +2566,7 @@ var outputSchema4 = {
1704
2566
  additionalProperties: false
1705
2567
  };
1706
2568
 
1707
- class ChunkVectorSearchTask extends Task5 {
2569
+ class ChunkVectorSearchTask extends Task6 {
1708
2570
  static type = "ChunkVectorSearchTask";
1709
2571
  static category = "Vector Store";
1710
2572
  static title = "Vector Store Search";
@@ -1734,13 +2596,13 @@ class ChunkVectorSearchTask extends Task5 {
1734
2596
  }
1735
2597
  }
1736
2598
  var vectorStoreSearch = (input, config) => {
1737
- return new ChunkVectorSearchTask({}, config).run(input);
2599
+ return new ChunkVectorSearchTask(config).run(input);
1738
2600
  };
1739
- Workflow6.prototype.vectorStoreSearch = CreateWorkflow6(ChunkVectorSearchTask);
2601
+ Workflow8.prototype.vectorStoreSearch = CreateWorkflow8(ChunkVectorSearchTask);
1740
2602
 
1741
2603
  // src/task/ChunkVectorUpsertTask.ts
1742
2604
  import { TypeKnowledgeBase as TypeKnowledgeBase4 } from "@workglow/knowledge-base";
1743
- import { CreateWorkflow as CreateWorkflow7, Task as Task6, Workflow as Workflow7 } from "@workglow/task-graph";
2605
+ import { CreateWorkflow as CreateWorkflow9, Task as Task7, Workflow as Workflow9 } from "@workglow/task-graph";
1744
2606
  import {
1745
2607
  TypedArraySchema as TypedArraySchema6
1746
2608
  } from "@workglow/util/schema";
@@ -1794,7 +2656,7 @@ var outputSchema5 = {
1794
2656
  additionalProperties: false
1795
2657
  };
1796
2658
 
1797
- class ChunkVectorUpsertTask extends Task6 {
2659
+ class ChunkVectorUpsertTask extends Task7 {
1798
2660
  static type = "ChunkVectorUpsertTask";
1799
2661
  static category = "Vector Store";
1800
2662
  static title = "Add to Vector Store";
@@ -1852,21 +2714,17 @@ class ChunkVectorUpsertTask extends Task6 {
1852
2714
  }
1853
2715
  }
1854
2716
  var chunkVectorUpsert = (input, config) => {
1855
- return new ChunkVectorUpsertTask({}, config).run(input);
2717
+ return new ChunkVectorUpsertTask(config).run(input);
1856
2718
  };
1857
- Workflow7.prototype.chunkVectorUpsert = CreateWorkflow7(ChunkVectorUpsertTask);
2719
+ Workflow9.prototype.chunkVectorUpsert = CreateWorkflow9(ChunkVectorUpsertTask);
1858
2720
 
1859
2721
  // src/task/ContextBuilderTask.ts
1860
2722
  import { estimateTokens } from "@workglow/knowledge-base";
1861
- import {
1862
- CreateWorkflow as CreateWorkflow9,
1863
- Task as Task7,
1864
- Workflow as Workflow9
1865
- } from "@workglow/task-graph";
2723
+ import { CreateWorkflow as CreateWorkflow11, Task as Task8, Workflow as Workflow11 } from "@workglow/task-graph";
1866
2724
 
1867
2725
  // src/task/CountTokensTask.ts
1868
- import { CreateWorkflow as CreateWorkflow8, Workflow as Workflow8 } from "@workglow/task-graph";
1869
- var modelSchema3 = TypeModel("model");
2726
+ import { CreateWorkflow as CreateWorkflow10, Workflow as Workflow10 } from "@workglow/task-graph";
2727
+ var modelSchema5 = TypeModel("model");
1870
2728
  var CountTokensInputSchema = {
1871
2729
  type: "object",
1872
2730
  properties: {
@@ -1875,7 +2733,7 @@ var CountTokensInputSchema = {
1875
2733
  title: "Text",
1876
2734
  description: "The text to count tokens for"
1877
2735
  },
1878
- model: modelSchema3
2736
+ model: modelSchema5
1879
2737
  },
1880
2738
  required: ["text", "model"],
1881
2739
  additionalProperties: false
@@ -1907,9 +2765,9 @@ class CountTokensTask extends AiTask {
1907
2765
  }
1908
2766
  }
1909
2767
  var countTokens = async (input, config) => {
1910
- return new CountTokensTask({}, config).run(input);
2768
+ return new CountTokensTask(config).run(input);
1911
2769
  };
1912
- Workflow8.prototype.countTokens = CreateWorkflow8(CountTokensTask);
2770
+ Workflow10.prototype.countTokens = CreateWorkflow10(CountTokensTask);
1913
2771
 
1914
2772
  // src/task/ContextBuilderTask.ts
1915
2773
  var ContextFormat = {
@@ -1919,7 +2777,7 @@ var ContextFormat = {
1919
2777
  MARKDOWN: "markdown",
1920
2778
  JSON: "json"
1921
2779
  };
1922
- var modelSchema4 = TypeModel("model", {
2780
+ var modelSchema6 = TypeModel("model", {
1923
2781
  title: "Model",
1924
2782
  description: "Model to use for token counting (optional, falls back to estimation)"
1925
2783
  });
@@ -1983,7 +2841,7 @@ var inputSchema6 = {
1983
2841
 
1984
2842
  `
1985
2843
  },
1986
- model: modelSchema4
2844
+ model: modelSchema6
1987
2845
  },
1988
2846
  required: ["chunks"],
1989
2847
  additionalProperties: false
@@ -2016,7 +2874,7 @@ var outputSchema6 = {
2016
2874
  additionalProperties: false
2017
2875
  };
2018
2876
 
2019
- class ContextBuilderTask extends Task7 {
2877
+ class ContextBuilderTask extends Task8 {
2020
2878
  static type = "ContextBuilderTask";
2021
2879
  static category = "RAG";
2022
2880
  static title = "Context Builder";
@@ -2043,7 +2901,7 @@ class ContextBuilderTask extends Task7 {
2043
2901
  } = input;
2044
2902
  let countFn = async (text) => estimateTokens(text);
2045
2903
  if (input.model) {
2046
- const countTask = context.own(new CountTokensTask({ model: input.model }));
2904
+ const countTask = context.own(new CountTokensTask({ defaults: { model: input.model } }));
2047
2905
  countFn = async (text) => {
2048
2906
  try {
2049
2907
  const result = await countTask.run({ text });
@@ -2207,20 +3065,17 @@ class ContextBuilderTask extends Task7 {
2207
3065
  }
2208
3066
  }
2209
3067
  var contextBuilder = (input, config) => {
2210
- return new ContextBuilderTask({}, config).run(input);
3068
+ return new ContextBuilderTask(config).run(input);
2211
3069
  };
2212
- Workflow9.prototype.contextBuilder = CreateWorkflow9(ContextBuilderTask);
3070
+ Workflow11.prototype.contextBuilder = CreateWorkflow11(ContextBuilderTask);
2213
3071
 
2214
3072
  // src/task/DocumentEnricherTask.ts
2215
- import {
2216
- getChildren,
2217
- hasChildren
2218
- } from "@workglow/knowledge-base";
2219
- import { CreateWorkflow as CreateWorkflow12, Task as Task8, Workflow as Workflow12 } from "@workglow/task-graph";
3073
+ import { getChildren, hasChildren } from "@workglow/knowledge-base";
3074
+ import { CreateWorkflow as CreateWorkflow14, Task as Task9, Workflow as Workflow14 } from "@workglow/task-graph";
2220
3075
 
2221
3076
  // src/task/TextNamedEntityRecognitionTask.ts
2222
- import { CreateWorkflow as CreateWorkflow10, Workflow as Workflow10 } from "@workglow/task-graph";
2223
- var modelSchema5 = TypeModel("model:TextNamedEntityRecognitionTask");
3077
+ import { CreateWorkflow as CreateWorkflow12, Workflow as Workflow12 } from "@workglow/task-graph";
3078
+ var modelSchema7 = TypeModel("model:TextNamedEntityRecognitionTask");
2224
3079
  var TextNamedEntityRecognitionInputSchema = {
2225
3080
  type: "object",
2226
3081
  properties: {
@@ -2239,7 +3094,7 @@ var TextNamedEntityRecognitionInputSchema = {
2239
3094
  "x-ui-group": "Configuration",
2240
3095
  "x-ui-group-open": false
2241
3096
  },
2242
- model: modelSchema5
3097
+ model: modelSchema7
2243
3098
  },
2244
3099
  required: ["text", "model"],
2245
3100
  additionalProperties: false
@@ -2292,53 +3147,13 @@ class TextNamedEntityRecognitionTask extends AiTask {
2292
3147
  }
2293
3148
  }
2294
3149
  var textNamedEntityRecognition = (input, config) => {
2295
- return new TextNamedEntityRecognitionTask({}, config).run(input);
3150
+ return new TextNamedEntityRecognitionTask(config).run(input);
2296
3151
  };
2297
- Workflow10.prototype.textNamedEntityRecognition = CreateWorkflow10(TextNamedEntityRecognitionTask);
2298
-
2299
- // src/task/TextSummaryTask.ts
2300
- import { CreateWorkflow as CreateWorkflow11, Workflow as Workflow11 } from "@workglow/task-graph";
2301
-
2302
- // src/task/base/StreamingAiTask.ts
2303
- import {
2304
- getStreamingPorts,
2305
- TaskConfigurationError as TaskConfigurationError3
2306
- } from "@workglow/task-graph";
2307
- class StreamingAiTask extends AiTask {
2308
- static type = "StreamingAiTask";
2309
- async* executeStream(input, context) {
2310
- const model = input.model;
2311
- if (!model || typeof model !== "object") {
2312
- throw new TaskConfigurationError3("StreamingAiTask: Model was not resolved to ModelConfig - this indicates a bug in the resolution system");
2313
- }
2314
- const jobInput = await this.getJobInput(input);
2315
- const strategy = getAiProviderRegistry().getStrategy(model);
2316
- const outSchema = this.outputSchema();
2317
- const ports = getStreamingPorts(outSchema);
2318
- let defaultPort = "text";
2319
- if (ports.length > 0) {
2320
- defaultPort = ports[0].port;
2321
- } else {
2322
- if (typeof outSchema === "object" && outSchema.properties) {
2323
- const firstProp = Object.keys(outSchema.properties)[0];
2324
- if (firstProp)
2325
- defaultPort = firstProp;
2326
- }
2327
- }
2328
- for await (const event of strategy.executeStream(jobInput, context, this.runConfig.runnerId)) {
2329
- if (event.type === "text-delta") {
2330
- yield { ...event, port: event.port ?? defaultPort };
2331
- } else if (event.type === "object-delta") {
2332
- yield { ...event, port: event.port ?? defaultPort };
2333
- } else {
2334
- yield event;
2335
- }
2336
- }
2337
- }
2338
- }
3152
+ Workflow12.prototype.textNamedEntityRecognition = CreateWorkflow12(TextNamedEntityRecognitionTask);
2339
3153
 
2340
3154
  // src/task/TextSummaryTask.ts
2341
- var modelSchema6 = TypeModel("model:TextSummaryTask");
3155
+ import { CreateWorkflow as CreateWorkflow13, Workflow as Workflow13 } from "@workglow/task-graph";
3156
+ var modelSchema8 = TypeModel("model:TextSummaryTask");
2342
3157
  var TextSummaryInputSchema = {
2343
3158
  type: "object",
2344
3159
  properties: {
@@ -2347,7 +3162,7 @@ var TextSummaryInputSchema = {
2347
3162
  title: "Text",
2348
3163
  description: "The text to summarize"
2349
3164
  },
2350
- model: modelSchema6
3165
+ model: modelSchema8
2351
3166
  },
2352
3167
  required: ["text", "model"],
2353
3168
  additionalProperties: false
@@ -2379,9 +3194,9 @@ class TextSummaryTask extends StreamingAiTask {
2379
3194
  }
2380
3195
  }
2381
3196
  var textSummary = async (input, config) => {
2382
- return new TextSummaryTask({}, config).run(input);
3197
+ return new TextSummaryTask(config).run(input);
2383
3198
  };
2384
- Workflow11.prototype.textSummary = CreateWorkflow11(TextSummaryTask);
3199
+ Workflow13.prototype.textSummary = CreateWorkflow13(TextSummaryTask);
2385
3200
 
2386
3201
  // src/task/DocumentEnricherTask.ts
2387
3202
  var inputSchema7 = {
@@ -2453,7 +3268,7 @@ var outputSchema7 = {
2453
3268
  additionalProperties: false
2454
3269
  };
2455
3270
 
2456
- class DocumentEnricherTask extends Task8 {
3271
+ class DocumentEnricherTask extends Task9 {
2457
3272
  static type = "DocumentEnricherTask";
2458
3273
  static category = "Document";
2459
3274
  static title = "Document Enricher";
@@ -2481,7 +3296,7 @@ class DocumentEnricherTask extends Task8 {
2481
3296
  let summaryCount = 0;
2482
3297
  let entityCount = 0;
2483
3298
  const extract = extractEntities && nerModel ? async (text) => {
2484
- const result = await context.own(new TextNamedEntityRecognitionTask({ text, model: nerModel })).run();
3299
+ const result = await context.own(new TextNamedEntityRecognitionTask).run({ text, model: nerModel });
2485
3300
  return result.entities.map((e) => ({
2486
3301
  type: e.entity,
2487
3302
  text: e.word,
@@ -2610,17 +3425,17 @@ class DocumentEnricherTask extends Task8 {
2610
3425
  }
2611
3426
  }
2612
3427
  var documentEnricher = (input, config) => {
2613
- return new DocumentEnricherTask({}, config).run(input);
3428
+ return new DocumentEnricherTask(config).run(input);
2614
3429
  };
2615
- Workflow12.prototype.documentEnricher = CreateWorkflow12(DocumentEnricherTask);
3430
+ Workflow14.prototype.documentEnricher = CreateWorkflow14(DocumentEnricherTask);
2616
3431
 
2617
3432
  // src/task/DownloadModelTask.ts
2618
- import { CreateWorkflow as CreateWorkflow13, Workflow as Workflow13 } from "@workglow/task-graph";
2619
- var modelSchema7 = TypeModel("model");
3433
+ import { CreateWorkflow as CreateWorkflow15, Workflow as Workflow15 } from "@workglow/task-graph";
3434
+ var modelSchema9 = TypeModel("model");
2620
3435
  var DownloadModelInputSchema = {
2621
3436
  type: "object",
2622
3437
  properties: {
2623
- model: modelSchema7
3438
+ model: modelSchema9
2624
3439
  },
2625
3440
  required: ["model"],
2626
3441
  additionalProperties: false
@@ -2628,7 +3443,7 @@ var DownloadModelInputSchema = {
2628
3443
  var DownloadModelOutputSchema = {
2629
3444
  type: "object",
2630
3445
  properties: {
2631
- model: modelSchema7
3446
+ model: modelSchema9
2632
3447
  },
2633
3448
  required: ["model"],
2634
3449
  additionalProperties: false
@@ -2647,8 +3462,8 @@ class DownloadModelTask extends AiTask {
2647
3462
  }
2648
3463
  static cacheable = false;
2649
3464
  files = [];
2650
- constructor(input, config = {}) {
2651
- super(input, config);
3465
+ constructor(config = {}) {
3466
+ super(config);
2652
3467
  this.on("progress", this.processProgress.bind(this));
2653
3468
  this.on("start", () => {
2654
3469
  this.files = [];
@@ -2680,13 +3495,13 @@ class DownloadModelTask extends AiTask {
2680
3495
  }
2681
3496
  }
2682
3497
  var downloadModel = (input, config) => {
2683
- return new DownloadModelTask({}, config).run(input);
3498
+ return new DownloadModelTask(config).run(input);
2684
3499
  };
2685
- Workflow13.prototype.downloadModel = CreateWorkflow13(DownloadModelTask);
3500
+ Workflow15.prototype.downloadModel = CreateWorkflow15(DownloadModelTask);
2686
3501
 
2687
3502
  // src/task/FaceDetectorTask.ts
2688
- import { CreateWorkflow as CreateWorkflow14, Workflow as Workflow14 } from "@workglow/task-graph";
2689
- var modelSchema8 = TypeModel("model:FaceDetectorTask");
3503
+ import { CreateWorkflow as CreateWorkflow16, Workflow as Workflow16 } from "@workglow/task-graph";
3504
+ var modelSchema10 = TypeModel("model:FaceDetectorTask");
2690
3505
  var TypeBoundingBox2 = {
2691
3506
  type: "object",
2692
3507
  properties: {
@@ -2759,7 +3574,7 @@ var FaceDetectorInputSchema = {
2759
3574
  type: "object",
2760
3575
  properties: {
2761
3576
  image: TypeImageInput,
2762
- model: modelSchema8,
3577
+ model: modelSchema10,
2763
3578
  minDetectionConfidence: {
2764
3579
  type: "number",
2765
3580
  minimum: 0,
@@ -2811,13 +3626,13 @@ class FaceDetectorTask extends AiVisionTask {
2811
3626
  }
2812
3627
  }
2813
3628
  var faceDetector = (input, config) => {
2814
- return new FaceDetectorTask({}, config).run(input);
3629
+ return new FaceDetectorTask(config).run(input);
2815
3630
  };
2816
- Workflow14.prototype.faceDetector = CreateWorkflow14(FaceDetectorTask);
3631
+ Workflow16.prototype.faceDetector = CreateWorkflow16(FaceDetectorTask);
2817
3632
 
2818
3633
  // src/task/FaceLandmarkerTask.ts
2819
- import { CreateWorkflow as CreateWorkflow15, Workflow as Workflow15 } from "@workglow/task-graph";
2820
- var modelSchema9 = TypeModel("model:FaceLandmarkerTask");
3634
+ import { CreateWorkflow as CreateWorkflow17, Workflow as Workflow17 } from "@workglow/task-graph";
3635
+ var modelSchema11 = TypeModel("model:FaceLandmarkerTask");
2821
3636
  var TypeLandmark = {
2822
3637
  type: "object",
2823
3638
  properties: {
@@ -2889,7 +3704,7 @@ var FaceLandmarkerInputSchema = {
2889
3704
  type: "object",
2890
3705
  properties: {
2891
3706
  image: TypeImageInput,
2892
- model: modelSchema9,
3707
+ model: modelSchema11,
2893
3708
  numFaces: {
2894
3709
  type: "number",
2895
3710
  minimum: 1,
@@ -2973,13 +3788,13 @@ class FaceLandmarkerTask extends AiVisionTask {
2973
3788
  }
2974
3789
  }
2975
3790
  var faceLandmarker = (input, config) => {
2976
- return new FaceLandmarkerTask({}, config).run(input);
3791
+ return new FaceLandmarkerTask(config).run(input);
2977
3792
  };
2978
- Workflow15.prototype.faceLandmarker = CreateWorkflow15(FaceLandmarkerTask);
3793
+ Workflow17.prototype.faceLandmarker = CreateWorkflow17(FaceLandmarkerTask);
2979
3794
 
2980
3795
  // src/task/GestureRecognizerTask.ts
2981
- import { CreateWorkflow as CreateWorkflow16, Workflow as Workflow16 } from "@workglow/task-graph";
2982
- var modelSchema10 = TypeModel("model:GestureRecognizerTask");
3796
+ import { CreateWorkflow as CreateWorkflow18, Workflow as Workflow18 } from "@workglow/task-graph";
3797
+ var modelSchema12 = TypeModel("model:GestureRecognizerTask");
2983
3798
  var TypeLandmark2 = {
2984
3799
  type: "object",
2985
3800
  properties: {
@@ -3071,7 +3886,7 @@ var GestureRecognizerInputSchema = {
3071
3886
  type: "object",
3072
3887
  properties: {
3073
3888
  image: TypeImageInput,
3074
- model: modelSchema10,
3889
+ model: modelSchema12,
3075
3890
  numHands: {
3076
3891
  type: "number",
3077
3892
  minimum: 1,
@@ -3141,13 +3956,13 @@ class GestureRecognizerTask extends AiVisionTask {
3141
3956
  }
3142
3957
  }
3143
3958
  var gestureRecognizer = (input, config) => {
3144
- return new GestureRecognizerTask({}, config).run(input);
3959
+ return new GestureRecognizerTask(config).run(input);
3145
3960
  };
3146
- Workflow16.prototype.gestureRecognizer = CreateWorkflow16(GestureRecognizerTask);
3961
+ Workflow18.prototype.gestureRecognizer = CreateWorkflow18(GestureRecognizerTask);
3147
3962
 
3148
3963
  // src/task/HandLandmarkerTask.ts
3149
- import { CreateWorkflow as CreateWorkflow17, Workflow as Workflow17 } from "@workglow/task-graph";
3150
- var modelSchema11 = TypeModel("model:HandLandmarkerTask");
3964
+ import { CreateWorkflow as CreateWorkflow19, Workflow as Workflow19 } from "@workglow/task-graph";
3965
+ var modelSchema13 = TypeModel("model:HandLandmarkerTask");
3151
3966
  var TypeLandmark3 = {
3152
3967
  type: "object",
3153
3968
  properties: {
@@ -3216,7 +4031,7 @@ var HandLandmarkerInputSchema = {
3216
4031
  type: "object",
3217
4032
  properties: {
3218
4033
  image: TypeImageInput,
3219
- model: modelSchema11,
4034
+ model: modelSchema13,
3220
4035
  numHands: {
3221
4036
  type: "number",
3222
4037
  minimum: 1,
@@ -3286,9 +4101,9 @@ class HandLandmarkerTask extends AiVisionTask {
3286
4101
  }
3287
4102
  }
3288
4103
  var handLandmarker = (input, config) => {
3289
- return new HandLandmarkerTask({}, config).run(input);
4104
+ return new HandLandmarkerTask(config).run(input);
3290
4105
  };
3291
- Workflow17.prototype.handLandmarker = CreateWorkflow17(HandLandmarkerTask);
4106
+ Workflow19.prototype.handLandmarker = CreateWorkflow19(HandLandmarkerTask);
3292
4107
 
3293
4108
  // src/task/HierarchicalChunkerTask.ts
3294
4109
  import {
@@ -3297,9 +4112,9 @@ import {
3297
4112
  getChildren as getChildren2,
3298
4113
  hasChildren as hasChildren2
3299
4114
  } from "@workglow/knowledge-base";
3300
- import { CreateWorkflow as CreateWorkflow18, Task as Task9, Workflow as Workflow18 } from "@workglow/task-graph";
4115
+ import { CreateWorkflow as CreateWorkflow20, Task as Task10, Workflow as Workflow20 } from "@workglow/task-graph";
3301
4116
  import { uuid4 } from "@workglow/util";
3302
- var modelSchema12 = TypeModel("model", {
4117
+ var modelSchema14 = TypeModel("model", {
3303
4118
  title: "Model",
3304
4119
  description: "Model to use for token counting"
3305
4120
  });
@@ -3343,7 +4158,7 @@ var inputSchema8 = {
3343
4158
  description: "Strategy for chunking",
3344
4159
  default: "hierarchical"
3345
4160
  },
3346
- model: modelSchema12
4161
+ model: modelSchema14
3347
4162
  },
3348
4163
  required: ["doc_id", "documentTree"],
3349
4164
  additionalProperties: false
@@ -3378,7 +4193,7 @@ var outputSchema8 = {
3378
4193
  additionalProperties: false
3379
4194
  };
3380
4195
 
3381
- class HierarchicalChunkerTask extends Task9 {
4196
+ class HierarchicalChunkerTask extends Task10 {
3382
4197
  static type = "HierarchicalChunkerTask";
3383
4198
  static category = "Document";
3384
4199
  static title = "Hierarchical Chunker";
@@ -3413,7 +4228,7 @@ class HierarchicalChunkerTask extends Task9 {
3413
4228
  };
3414
4229
  let countFn = async (text) => estimateTokens2(text);
3415
4230
  if (input.model) {
3416
- const countTask = context.own(new CountTokensTask({ model: input.model }));
4231
+ const countTask = context.own(new CountTokensTask({ defaults: { model: input.model } }));
3417
4232
  countFn = async (text) => {
3418
4233
  try {
3419
4234
  const result = await countTask.run({ text });
@@ -3520,16 +4335,13 @@ class HierarchicalChunkerTask extends Task9 {
3520
4335
  }
3521
4336
  }
3522
4337
  var hierarchicalChunker = (input, config) => {
3523
- return new HierarchicalChunkerTask({}, config).run(input);
4338
+ return new HierarchicalChunkerTask(config).run(input);
3524
4339
  };
3525
- Workflow18.prototype.hierarchicalChunker = CreateWorkflow18(HierarchicalChunkerTask);
4340
+ Workflow20.prototype.hierarchicalChunker = CreateWorkflow20(HierarchicalChunkerTask);
3526
4341
 
3527
4342
  // src/task/HierarchyJoinTask.ts
3528
- import {
3529
- ChunkRecordArraySchema,
3530
- TypeKnowledgeBase as TypeKnowledgeBase5
3531
- } from "@workglow/knowledge-base";
3532
- import { CreateWorkflow as CreateWorkflow19, Task as Task10, Workflow as Workflow19 } from "@workglow/task-graph";
4343
+ import { ChunkRecordArraySchema, TypeKnowledgeBase as TypeKnowledgeBase5 } from "@workglow/knowledge-base";
4344
+ import { CreateWorkflow as CreateWorkflow21, Task as Task11, Workflow as Workflow21 } from "@workglow/task-graph";
3533
4345
  var inputSchema9 = {
3534
4346
  type: "object",
3535
4347
  properties: {
@@ -3604,7 +4416,7 @@ var outputSchema9 = {
3604
4416
  additionalProperties: false
3605
4417
  };
3606
4418
 
3607
- class HierarchyJoinTask extends Task10 {
4419
+ class HierarchyJoinTask extends Task11 {
3608
4420
  static type = "HierarchyJoinTask";
3609
4421
  static category = "RAG";
3610
4422
  static title = "Hierarchy Join";
@@ -3696,18 +4508,18 @@ class HierarchyJoinTask extends Task10 {
3696
4508
  }
3697
4509
  }
3698
4510
  var hierarchyJoin = (input, config) => {
3699
- return new HierarchyJoinTask({}, config).run(input);
4511
+ return new HierarchyJoinTask(config).run(input);
3700
4512
  };
3701
- Workflow19.prototype.hierarchyJoin = CreateWorkflow19(HierarchyJoinTask);
4513
+ Workflow21.prototype.hierarchyJoin = CreateWorkflow21(HierarchyJoinTask);
3702
4514
 
3703
4515
  // src/task/ImageClassificationTask.ts
3704
- import { CreateWorkflow as CreateWorkflow20, Workflow as Workflow20 } from "@workglow/task-graph";
3705
- var modelSchema13 = TypeModel("model:ImageClassificationTask");
4516
+ import { CreateWorkflow as CreateWorkflow22, Workflow as Workflow22 } from "@workglow/task-graph";
4517
+ var modelSchema15 = TypeModel("model:ImageClassificationTask");
3706
4518
  var ImageClassificationInputSchema = {
3707
4519
  type: "object",
3708
4520
  properties: {
3709
4521
  image: TypeImageInput,
3710
- model: modelSchema13,
4522
+ model: modelSchema15,
3711
4523
  categories: {
3712
4524
  type: "array",
3713
4525
  items: {
@@ -3759,21 +4571,21 @@ class ImageClassificationTask extends AiVisionTask {
3759
4571
  }
3760
4572
  }
3761
4573
  var imageClassification = (input, config) => {
3762
- return new ImageClassificationTask({}, config).run(input);
4574
+ return new ImageClassificationTask(config).run(input);
3763
4575
  };
3764
- Workflow20.prototype.imageClassification = CreateWorkflow20(ImageClassificationTask);
4576
+ Workflow22.prototype.imageClassification = CreateWorkflow22(ImageClassificationTask);
3765
4577
 
3766
4578
  // src/task/ImageEmbeddingTask.ts
3767
- import { CreateWorkflow as CreateWorkflow21, Workflow as Workflow21 } from "@workglow/task-graph";
4579
+ import { CreateWorkflow as CreateWorkflow23, Workflow as Workflow23 } from "@workglow/task-graph";
3768
4580
  import {
3769
4581
  TypedArraySchema as TypedArraySchema7
3770
4582
  } from "@workglow/util/schema";
3771
- var modelSchema14 = TypeModel("model:ImageEmbeddingTask");
4583
+ var modelSchema16 = TypeModel("model:ImageEmbeddingTask");
3772
4584
  var ImageEmbeddingInputSchema = {
3773
4585
  type: "object",
3774
4586
  properties: {
3775
4587
  image: TypeSingleOrArray(TypeImageInput),
3776
- model: modelSchema14
4588
+ model: modelSchema16
3777
4589
  },
3778
4590
  required: ["image", "model"],
3779
4591
  additionalProperties: false
@@ -3803,18 +4615,18 @@ class ImageEmbeddingTask extends AiVisionTask {
3803
4615
  }
3804
4616
  }
3805
4617
  var imageEmbedding = (input, config) => {
3806
- return new ImageEmbeddingTask({}, config).run(input);
4618
+ return new ImageEmbeddingTask(config).run(input);
3807
4619
  };
3808
- Workflow21.prototype.imageEmbedding = CreateWorkflow21(ImageEmbeddingTask);
4620
+ Workflow23.prototype.imageEmbedding = CreateWorkflow23(ImageEmbeddingTask);
3809
4621
 
3810
4622
  // src/task/ImageSegmentationTask.ts
3811
- import { CreateWorkflow as CreateWorkflow22, Workflow as Workflow22 } from "@workglow/task-graph";
3812
- var modelSchema15 = TypeModel("model:ImageSegmentationTask");
4623
+ import { CreateWorkflow as CreateWorkflow24, Workflow as Workflow24 } from "@workglow/task-graph";
4624
+ var modelSchema17 = TypeModel("model:ImageSegmentationTask");
3813
4625
  var ImageSegmentationInputSchema = {
3814
4626
  type: "object",
3815
4627
  properties: {
3816
4628
  image: TypeImageInput,
3817
- model: modelSchema15,
4629
+ model: modelSchema17,
3818
4630
  threshold: {
3819
4631
  type: "number",
3820
4632
  title: "Threshold",
@@ -3891,13 +4703,13 @@ class ImageSegmentationTask extends AiVisionTask {
3891
4703
  }
3892
4704
  }
3893
4705
  var imageSegmentation = (input, config) => {
3894
- return new ImageSegmentationTask({}, config).run(input);
4706
+ return new ImageSegmentationTask(config).run(input);
3895
4707
  };
3896
- Workflow22.prototype.imageSegmentation = CreateWorkflow22(ImageSegmentationTask);
4708
+ Workflow24.prototype.imageSegmentation = CreateWorkflow24(ImageSegmentationTask);
3897
4709
 
3898
4710
  // src/task/ImageToTextTask.ts
3899
- import { CreateWorkflow as CreateWorkflow23, Workflow as Workflow23 } from "@workglow/task-graph";
3900
- var modelSchema16 = TypeModel("model:ImageToTextTask");
4711
+ import { CreateWorkflow as CreateWorkflow25, Workflow as Workflow25 } from "@workglow/task-graph";
4712
+ var modelSchema18 = TypeModel("model:ImageToTextTask");
3901
4713
  var generatedTextSchema = {
3902
4714
  type: "string",
3903
4715
  title: "Text",
@@ -3907,7 +4719,7 @@ var ImageToTextInputSchema = {
3907
4719
  type: "object",
3908
4720
  properties: {
3909
4721
  image: TypeImageInput,
3910
- model: modelSchema16,
4722
+ model: modelSchema18,
3911
4723
  maxTokens: {
3912
4724
  type: "number",
3913
4725
  title: "Max Tokens",
@@ -3946,17 +4758,17 @@ class ImageToTextTask extends AiVisionTask {
3946
4758
  }
3947
4759
  }
3948
4760
  var imageToText = (input, config) => {
3949
- return new ImageToTextTask({}, config).run(input);
4761
+ return new ImageToTextTask(config).run(input);
3950
4762
  };
3951
- Workflow23.prototype.imageToText = CreateWorkflow23(ImageToTextTask);
4763
+ Workflow25.prototype.imageToText = CreateWorkflow25(ImageToTextTask);
3952
4764
 
3953
4765
  // src/task/ModelInfoTask.ts
3954
- import { CreateWorkflow as CreateWorkflow24, Workflow as Workflow24 } from "@workglow/task-graph";
3955
- var modelSchema17 = TypeModel("model");
4766
+ import { CreateWorkflow as CreateWorkflow26, Workflow as Workflow26 } from "@workglow/task-graph";
4767
+ var modelSchema19 = TypeModel("model");
3956
4768
  var ModelInfoInputSchema = {
3957
4769
  type: "object",
3958
4770
  properties: {
3959
- model: modelSchema17,
4771
+ model: modelSchema19,
3960
4772
  detail: {
3961
4773
  type: "string",
3962
4774
  enum: ["cached_status", "files", "files_with_metadata"],
@@ -3969,7 +4781,7 @@ var ModelInfoInputSchema = {
3969
4781
  var ModelInfoOutputSchema = {
3970
4782
  type: "object",
3971
4783
  properties: {
3972
- model: modelSchema17,
4784
+ model: modelSchema19,
3973
4785
  is_local: { type: "boolean" },
3974
4786
  is_remote: { type: "boolean" },
3975
4787
  supports_browser: { type: "boolean" },
@@ -4017,12 +4829,12 @@ class ModelInfoTask extends AiTask {
4017
4829
  }
4018
4830
  }
4019
4831
  var modelInfo = (input, config) => {
4020
- return new ModelInfoTask({}, config).run(input);
4832
+ return new ModelInfoTask(config).run(input);
4021
4833
  };
4022
- Workflow24.prototype.modelInfo = CreateWorkflow24(ModelInfoTask);
4834
+ Workflow26.prototype.modelInfo = CreateWorkflow26(ModelInfoTask);
4023
4835
 
4024
4836
  // src/task/ModelSearchTask.ts
4025
- import { CreateWorkflow as CreateWorkflow25, Task as Task11, Workflow as Workflow25 } from "@workglow/task-graph";
4837
+ import { CreateWorkflow as CreateWorkflow27, Task as Task12, Workflow as Workflow27 } from "@workglow/task-graph";
4026
4838
  var ModelSearchInputSchema = {
4027
4839
  type: "object",
4028
4840
  properties: {
@@ -4087,7 +4899,7 @@ var ModelSearchOutputSchema = {
4087
4899
  additionalProperties: false
4088
4900
  };
4089
4901
 
4090
- class ModelSearchTask extends Task11 {
4902
+ class ModelSearchTask extends Task12 {
4091
4903
  static type = "ModelSearchTask";
4092
4904
  static category = "AI Model";
4093
4905
  static title = "Model Search";
@@ -4111,13 +4923,13 @@ class ModelSearchTask extends Task11 {
4111
4923
  }
4112
4924
  }
4113
4925
  var modelSearch = (input, config) => {
4114
- return new ModelSearchTask({}, config).run(input);
4926
+ return new ModelSearchTask(config).run(input);
4115
4927
  };
4116
- Workflow25.prototype.modelSearch = CreateWorkflow25(ModelSearchTask);
4928
+ Workflow27.prototype.modelSearch = CreateWorkflow27(ModelSearchTask);
4117
4929
 
4118
4930
  // src/task/ObjectDetectionTask.ts
4119
- import { CreateWorkflow as CreateWorkflow26, Workflow as Workflow26 } from "@workglow/task-graph";
4120
- var modelSchema18 = TypeModel("model:ObjectDetectionTask");
4931
+ import { CreateWorkflow as CreateWorkflow28, Workflow as Workflow28 } from "@workglow/task-graph";
4932
+ var modelSchema20 = TypeModel("model:ObjectDetectionTask");
4121
4933
  var detectionSchema = {
4122
4934
  type: "object",
4123
4935
  properties: {
@@ -4142,7 +4954,7 @@ var ObjectDetectionInputSchema = {
4142
4954
  type: "object",
4143
4955
  properties: {
4144
4956
  image: TypeImageInput,
4145
- model: modelSchema18,
4957
+ model: modelSchema20,
4146
4958
  labels: {
4147
4959
  type: "array",
4148
4960
  items: {
@@ -4194,13 +5006,13 @@ class ObjectDetectionTask extends AiVisionTask {
4194
5006
  }
4195
5007
  }
4196
5008
  var objectDetection = (input, config) => {
4197
- return new ObjectDetectionTask({}, config).run(input);
5009
+ return new ObjectDetectionTask(config).run(input);
4198
5010
  };
4199
- Workflow26.prototype.objectDetection = CreateWorkflow26(ObjectDetectionTask);
5011
+ Workflow28.prototype.objectDetection = CreateWorkflow28(ObjectDetectionTask);
4200
5012
 
4201
5013
  // src/task/PoseLandmarkerTask.ts
4202
- import { CreateWorkflow as CreateWorkflow27, Workflow as Workflow27 } from "@workglow/task-graph";
4203
- var modelSchema19 = TypeModel("model:PoseLandmarkerTask");
5014
+ import { CreateWorkflow as CreateWorkflow29, Workflow as Workflow29 } from "@workglow/task-graph";
5015
+ var modelSchema21 = TypeModel("model:PoseLandmarkerTask");
4204
5016
  var TypePoseLandmark = {
4205
5017
  type: "object",
4206
5018
  properties: {
@@ -4279,7 +5091,7 @@ var PoseLandmarkerInputSchema = {
4279
5091
  type: "object",
4280
5092
  properties: {
4281
5093
  image: TypeImageInput,
4282
- model: modelSchema19,
5094
+ model: modelSchema21,
4283
5095
  numPoses: {
4284
5096
  type: "number",
4285
5097
  minimum: 1,
@@ -4356,12 +5168,12 @@ class PoseLandmarkerTask extends AiVisionTask {
4356
5168
  }
4357
5169
  }
4358
5170
  var poseLandmarker = (input, config) => {
4359
- return new PoseLandmarkerTask({}, config).run(input);
5171
+ return new PoseLandmarkerTask(config).run(input);
4360
5172
  };
4361
- Workflow27.prototype.poseLandmarker = CreateWorkflow27(PoseLandmarkerTask);
5173
+ Workflow29.prototype.poseLandmarker = CreateWorkflow29(PoseLandmarkerTask);
4362
5174
 
4363
5175
  // src/task/QueryExpanderTask.ts
4364
- import { CreateWorkflow as CreateWorkflow28, Task as Task12, Workflow as Workflow28 } from "@workglow/task-graph";
5176
+ import { CreateWorkflow as CreateWorkflow30, Task as Task13, Workflow as Workflow30 } from "@workglow/task-graph";
4365
5177
  var QueryExpansionMethod = {
4366
5178
  MULTI_QUERY: "multi-query",
4367
5179
  HYDE: "hyde",
@@ -4429,7 +5241,7 @@ var outputSchema10 = {
4429
5241
  additionalProperties: false
4430
5242
  };
4431
5243
 
4432
- class QueryExpanderTask extends Task12 {
5244
+ class QueryExpanderTask extends Task13 {
4433
5245
  static type = "QueryExpanderTask";
4434
5246
  static category = "RAG";
4435
5247
  static title = "Query Expander";
@@ -4569,16 +5381,16 @@ class QueryExpanderTask extends Task12 {
4569
5381
  }
4570
5382
  }
4571
5383
  var queryExpander = (input, config) => {
4572
- return new QueryExpanderTask({}, config).run(input);
5384
+ return new QueryExpanderTask(config).run(input);
4573
5385
  };
4574
- Workflow28.prototype.queryExpander = CreateWorkflow28(QueryExpanderTask);
5386
+ Workflow30.prototype.queryExpander = CreateWorkflow30(QueryExpanderTask);
4575
5387
 
4576
5388
  // src/task/RerankerTask.ts
4577
- import { CreateWorkflow as CreateWorkflow30, Task as Task13, Workflow as Workflow30 } from "@workglow/task-graph";
5389
+ import { CreateWorkflow as CreateWorkflow32, Task as Task14, Workflow as Workflow32 } from "@workglow/task-graph";
4578
5390
 
4579
5391
  // src/task/TextClassificationTask.ts
4580
- import { CreateWorkflow as CreateWorkflow29, Workflow as Workflow29 } from "@workglow/task-graph";
4581
- var modelSchema20 = TypeModel("model:TextClassificationTask");
5392
+ import { CreateWorkflow as CreateWorkflow31, Workflow as Workflow31 } from "@workglow/task-graph";
5393
+ var modelSchema22 = TypeModel("model:TextClassificationTask");
4582
5394
  var TextClassificationInputSchema = {
4583
5395
  type: "object",
4584
5396
  properties: {
@@ -4605,7 +5417,7 @@ var TextClassificationInputSchema = {
4605
5417
  description: "The maximum number of categories to return",
4606
5418
  "x-ui-group": "Configuration"
4607
5419
  },
4608
- model: modelSchema20
5420
+ model: modelSchema22
4609
5421
  },
4610
5422
  required: ["text", "model"],
4611
5423
  additionalProperties: false
@@ -4653,9 +5465,9 @@ class TextClassificationTask extends AiTask {
4653
5465
  }
4654
5466
  }
4655
5467
  var textClassification = (input, config) => {
4656
- return new TextClassificationTask({}, config).run(input);
5468
+ return new TextClassificationTask(config).run(input);
4657
5469
  };
4658
- Workflow29.prototype.textClassification = CreateWorkflow29(TextClassificationTask);
5470
+ Workflow31.prototype.textClassification = CreateWorkflow31(TextClassificationTask);
4659
5471
 
4660
5472
  // src/task/RerankerTask.ts
4661
5473
  var inputSchema11 = {
@@ -4750,7 +5562,7 @@ var outputSchema11 = {
4750
5562
  additionalProperties: false
4751
5563
  };
4752
5564
 
4753
- class RerankerTask extends Task13 {
5565
+ class RerankerTask extends Task14 {
4754
5566
  static type = "RerankerTask";
4755
5567
  static category = "RAG";
4756
5568
  static title = "Reranker";
@@ -4801,8 +5613,8 @@ class RerankerTask extends Task13 {
4801
5613
  }
4802
5614
  const items = await Promise.all(chunks.map(async (chunk, index) => {
4803
5615
  const pairText = `${query} [SEP] ${chunk}`;
4804
- const task = context.own(new TextClassificationTask({ text: pairText, model, maxCategories: 2 }));
4805
- const result = await task.run();
5616
+ const task = context.own(new TextClassificationTask({ defaults: { model } }));
5617
+ const result = await task.run({ text: pairText, maxCategories: 2 });
4806
5618
  const crossScore = this.extractCrossEncoderScore(result.categories);
4807
5619
  return {
4808
5620
  chunk,
@@ -4877,13 +5689,13 @@ class RerankerTask extends Task13 {
4877
5689
  }
4878
5690
  }
4879
5691
  var reranker = (input, config) => {
4880
- return new RerankerTask({}, config).run(input);
5692
+ return new RerankerTask(config).run(input);
4881
5693
  };
4882
- Workflow30.prototype.reranker = CreateWorkflow30(RerankerTask);
5694
+ Workflow32.prototype.reranker = CreateWorkflow32(RerankerTask);
4883
5695
 
4884
5696
  // src/task/StructuralParserTask.ts
4885
5697
  import { StructuralParser } from "@workglow/knowledge-base";
4886
- import { CreateWorkflow as CreateWorkflow31, Task as Task14, Workflow as Workflow31 } from "@workglow/task-graph";
5698
+ import { CreateWorkflow as CreateWorkflow33, Task as Task15, Workflow as Workflow33 } from "@workglow/task-graph";
4887
5699
  import { uuid4 as uuid42 } from "@workglow/util";
4888
5700
  var inputSchema12 = {
4889
5701
  type: "object",
@@ -4941,7 +5753,7 @@ var outputSchema12 = {
4941
5753
  additionalProperties: false
4942
5754
  };
4943
5755
 
4944
- class StructuralParserTask extends Task14 {
5756
+ class StructuralParserTask extends Task15 {
4945
5757
  static type = "StructuralParserTask";
4946
5758
  static category = "Document";
4947
5759
  static title = "Structural Parser";
@@ -4982,17 +5794,17 @@ class StructuralParserTask extends Task14 {
4982
5794
  }
4983
5795
  }
4984
5796
  var structuralParser = (input, config) => {
4985
- return new StructuralParserTask({}, config).run(input);
5797
+ return new StructuralParserTask(config).run(input);
4986
5798
  };
4987
- Workflow31.prototype.structuralParser = CreateWorkflow31(StructuralParserTask);
5799
+ Workflow33.prototype.structuralParser = CreateWorkflow33(StructuralParserTask);
4988
5800
 
4989
5801
  // src/task/StructuredGenerationTask.ts
4990
- import { CreateWorkflow as CreateWorkflow32, Workflow as Workflow32 } from "@workglow/task-graph";
4991
- var modelSchema21 = TypeModel("model:StructuredGenerationTask");
5802
+ import { CreateWorkflow as CreateWorkflow34, Workflow as Workflow34 } from "@workglow/task-graph";
5803
+ var modelSchema23 = TypeModel("model:StructuredGenerationTask");
4992
5804
  var StructuredGenerationInputSchema = {
4993
5805
  type: "object",
4994
5806
  properties: {
4995
- model: modelSchema21,
5807
+ model: modelSchema23,
4996
5808
  prompt: {
4997
5809
  type: "string",
4998
5810
  title: "Prompt",
@@ -5053,12 +5865,12 @@ class StructuredGenerationTask extends StreamingAiTask {
5053
5865
  }
5054
5866
  }
5055
5867
  var structuredGeneration = (input, config) => {
5056
- return new StructuredGenerationTask({}, config).run(input);
5868
+ return new StructuredGenerationTask(config).run(input);
5057
5869
  };
5058
- Workflow32.prototype.structuredGeneration = CreateWorkflow32(StructuredGenerationTask);
5870
+ Workflow34.prototype.structuredGeneration = CreateWorkflow34(StructuredGenerationTask);
5059
5871
 
5060
5872
  // src/task/TextChunkerTask.ts
5061
- import { CreateWorkflow as CreateWorkflow33, Task as Task15, Workflow as Workflow33 } from "@workglow/task-graph";
5873
+ import { CreateWorkflow as CreateWorkflow35, Task as Task16, Workflow as Workflow35 } from "@workglow/task-graph";
5062
5874
  var ChunkingStrategy = {
5063
5875
  FIXED: "fixed",
5064
5876
  SENTENCE: "sentence",
@@ -5127,7 +5939,7 @@ var outputSchema13 = {
5127
5939
  additionalProperties: false
5128
5940
  };
5129
5941
 
5130
- class TextChunkerTask extends Task15 {
5942
+ class TextChunkerTask extends Task16 {
5131
5943
  static type = "TextChunkerTask";
5132
5944
  static category = "Document";
5133
5945
  static title = "Text Chunker";
@@ -5305,13 +6117,13 @@ class TextChunkerTask extends Task15 {
5305
6117
  }
5306
6118
  }
5307
6119
  var textChunker = (input, config) => {
5308
- return new TextChunkerTask({}, config).run(input);
6120
+ return new TextChunkerTask(config).run(input);
5309
6121
  };
5310
- Workflow33.prototype.textChunker = CreateWorkflow33(TextChunkerTask);
6122
+ Workflow35.prototype.textChunker = CreateWorkflow35(TextChunkerTask);
5311
6123
 
5312
6124
  // src/task/TextFillMaskTask.ts
5313
- import { CreateWorkflow as CreateWorkflow34, Workflow as Workflow34 } from "@workglow/task-graph";
5314
- var modelSchema22 = TypeModel("model:TextFillMaskTask");
6125
+ import { CreateWorkflow as CreateWorkflow36, Workflow as Workflow36 } from "@workglow/task-graph";
6126
+ var modelSchema24 = TypeModel("model:TextFillMaskTask");
5315
6127
  var TextFillMaskInputSchema = {
5316
6128
  type: "object",
5317
6129
  properties: {
@@ -5320,7 +6132,7 @@ var TextFillMaskInputSchema = {
5320
6132
  title: "Text",
5321
6133
  description: "The text with a mask token to fill"
5322
6134
  },
5323
- model: modelSchema22
6135
+ model: modelSchema24
5324
6136
  },
5325
6137
  required: ["text", "model"],
5326
6138
  additionalProperties: false
@@ -5373,23 +6185,23 @@ class TextFillMaskTask extends AiTask {
5373
6185
  }
5374
6186
  }
5375
6187
  var textFillMask = (input, config) => {
5376
- return new TextFillMaskTask({}, config).run(input);
6188
+ return new TextFillMaskTask(config).run(input);
5377
6189
  };
5378
- Workflow34.prototype.textFillMask = CreateWorkflow34(TextFillMaskTask);
6190
+ Workflow36.prototype.textFillMask = CreateWorkflow36(TextFillMaskTask);
5379
6191
 
5380
6192
  // src/task/TextGenerationTask.ts
5381
- import { CreateWorkflow as CreateWorkflow35, Workflow as Workflow35 } from "@workglow/task-graph";
6193
+ import { CreateWorkflow as CreateWorkflow37, Workflow as Workflow37 } from "@workglow/task-graph";
5382
6194
  var generatedTextSchema2 = {
5383
6195
  type: "string",
5384
6196
  title: "Text",
5385
6197
  description: "The generated text",
5386
6198
  "x-stream": "append"
5387
6199
  };
5388
- var modelSchema23 = TypeModel("model:TextGenerationTask");
6200
+ var modelSchema25 = TypeModel("model:TextGenerationTask");
5389
6201
  var TextGenerationInputSchema = {
5390
6202
  type: "object",
5391
6203
  properties: {
5392
- model: modelSchema23,
6204
+ model: modelSchema25,
5393
6205
  prompt: {
5394
6206
  type: "string",
5395
6207
  title: "Prompt",
@@ -5461,13 +6273,13 @@ class TextGenerationTask extends StreamingAiTask {
5461
6273
  }
5462
6274
  }
5463
6275
  var textGeneration = (input, config) => {
5464
- return new TextGenerationTask({}, config).run(input);
6276
+ return new TextGenerationTask(config).run(input);
5465
6277
  };
5466
- Workflow35.prototype.textGeneration = CreateWorkflow35(TextGenerationTask);
6278
+ Workflow37.prototype.textGeneration = CreateWorkflow37(TextGenerationTask);
5467
6279
 
5468
6280
  // src/task/TextLanguageDetectionTask.ts
5469
- import { CreateWorkflow as CreateWorkflow36, Workflow as Workflow36 } from "@workglow/task-graph";
5470
- var modelSchema24 = TypeModel("model:TextLanguageDetectionTask");
6281
+ import { CreateWorkflow as CreateWorkflow38, Workflow as Workflow38 } from "@workglow/task-graph";
6282
+ var modelSchema26 = TypeModel("model:TextLanguageDetectionTask");
5471
6283
  var TextLanguageDetectionInputSchema = {
5472
6284
  type: "object",
5473
6285
  properties: {
@@ -5484,7 +6296,7 @@ var TextLanguageDetectionInputSchema = {
5484
6296
  title: "Max Languages",
5485
6297
  description: "The maximum number of languages to return"
5486
6298
  },
5487
- model: modelSchema24
6299
+ model: modelSchema26
5488
6300
  },
5489
6301
  required: ["text", "model"],
5490
6302
  additionalProperties: false
@@ -5532,12 +6344,12 @@ class TextLanguageDetectionTask extends AiTask {
5532
6344
  }
5533
6345
  }
5534
6346
  var textLanguageDetection = (input, config) => {
5535
- return new TextLanguageDetectionTask({}, config).run(input);
6347
+ return new TextLanguageDetectionTask(config).run(input);
5536
6348
  };
5537
- Workflow36.prototype.textLanguageDetection = CreateWorkflow36(TextLanguageDetectionTask);
6349
+ Workflow38.prototype.textLanguageDetection = CreateWorkflow38(TextLanguageDetectionTask);
5538
6350
 
5539
6351
  // src/task/TextQuestionAnswerTask.ts
5540
- import { CreateWorkflow as CreateWorkflow37, Workflow as Workflow37 } from "@workglow/task-graph";
6352
+ import { CreateWorkflow as CreateWorkflow39, Workflow as Workflow39 } from "@workglow/task-graph";
5541
6353
  var contextSchema = {
5542
6354
  type: "string",
5543
6355
  title: "Context",
@@ -5554,13 +6366,13 @@ var textSchema = {
5554
6366
  description: "The generated text",
5555
6367
  "x-stream": "append"
5556
6368
  };
5557
- var modelSchema25 = TypeModel("model:TextQuestionAnswerTask");
6369
+ var modelSchema27 = TypeModel("model:TextQuestionAnswerTask");
5558
6370
  var TextQuestionAnswerInputSchema = {
5559
6371
  type: "object",
5560
6372
  properties: {
5561
6373
  context: contextSchema,
5562
6374
  question: questionSchema,
5563
- model: modelSchema25
6375
+ model: modelSchema27
5564
6376
  },
5565
6377
  required: ["context", "question", "model"],
5566
6378
  additionalProperties: false
@@ -5587,13 +6399,13 @@ class TextQuestionAnswerTask extends StreamingAiTask {
5587
6399
  }
5588
6400
  }
5589
6401
  var textQuestionAnswer = (input, config) => {
5590
- return new TextQuestionAnswerTask({}, config).run(input);
6402
+ return new TextQuestionAnswerTask(config).run(input);
5591
6403
  };
5592
- Workflow37.prototype.textQuestionAnswer = CreateWorkflow37(TextQuestionAnswerTask);
6404
+ Workflow39.prototype.textQuestionAnswer = CreateWorkflow39(TextQuestionAnswerTask);
5593
6405
 
5594
6406
  // src/task/TextRewriterTask.ts
5595
- import { CreateWorkflow as CreateWorkflow38, Workflow as Workflow38 } from "@workglow/task-graph";
5596
- var modelSchema26 = TypeModel("model:TextRewriterTask");
6407
+ import { CreateWorkflow as CreateWorkflow40, Workflow as Workflow40 } from "@workglow/task-graph";
6408
+ var modelSchema28 = TypeModel("model:TextRewriterTask");
5597
6409
  var TextRewriterInputSchema = {
5598
6410
  type: "object",
5599
6411
  properties: {
@@ -5607,7 +6419,7 @@ var TextRewriterInputSchema = {
5607
6419
  title: "Prompt",
5608
6420
  description: "The prompt to direct the rewriting"
5609
6421
  },
5610
- model: modelSchema26
6422
+ model: modelSchema28
5611
6423
  },
5612
6424
  required: ["text", "prompt", "model"],
5613
6425
  additionalProperties: false
@@ -5639,13 +6451,13 @@ class TextRewriterTask extends StreamingAiTask {
5639
6451
  }
5640
6452
  }
5641
6453
  var textRewriter = (input, config) => {
5642
- return new TextRewriterTask({}, config).run(input);
6454
+ return new TextRewriterTask(config).run(input);
5643
6455
  };
5644
- Workflow38.prototype.textRewriter = CreateWorkflow38(TextRewriterTask);
6456
+ Workflow40.prototype.textRewriter = CreateWorkflow40(TextRewriterTask);
5645
6457
 
5646
6458
  // src/task/TextTranslationTask.ts
5647
- import { CreateWorkflow as CreateWorkflow39, Workflow as Workflow39 } from "@workglow/task-graph";
5648
- var modelSchema27 = TypeModel("model:TextTranslationTask");
6459
+ import { CreateWorkflow as CreateWorkflow41, Workflow as Workflow41 } from "@workglow/task-graph";
6460
+ var modelSchema29 = TypeModel("model:TextTranslationTask");
5649
6461
  var translationTextSchema = {
5650
6462
  type: "string",
5651
6463
  title: "Text",
@@ -5672,7 +6484,7 @@ var TextTranslationInputSchema = {
5672
6484
  minLength: 2,
5673
6485
  maxLength: 2
5674
6486
  }),
5675
- model: modelSchema27
6487
+ model: modelSchema29
5676
6488
  },
5677
6489
  required: ["text", "source_lang", "target_lang", "model"],
5678
6490
  additionalProperties: false
@@ -5705,12 +6517,12 @@ class TextTranslationTask extends StreamingAiTask {
5705
6517
  }
5706
6518
  }
5707
6519
  var textTranslation = (input, config) => {
5708
- return new TextTranslationTask({}, config).run(input);
6520
+ return new TextTranslationTask(config).run(input);
5709
6521
  };
5710
- Workflow39.prototype.textTranslation = CreateWorkflow39(TextTranslationTask);
6522
+ Workflow41.prototype.textTranslation = CreateWorkflow41(TextTranslationTask);
5711
6523
 
5712
6524
  // src/task/TopicSegmenterTask.ts
5713
- import { CreateWorkflow as CreateWorkflow40, Task as Task16, Workflow as Workflow40 } from "@workglow/task-graph";
6525
+ import { CreateWorkflow as CreateWorkflow42, Task as Task17, Workflow as Workflow42 } from "@workglow/task-graph";
5714
6526
  var SegmentationMethod = {
5715
6527
  HEURISTIC: "heuristic",
5716
6528
  EMBEDDING_SIMILARITY: "embedding-similarity",
@@ -5785,7 +6597,7 @@ var outputSchema14 = {
5785
6597
  additionalProperties: false
5786
6598
  };
5787
6599
 
5788
- class TopicSegmenterTask extends Task16 {
6600
+ class TopicSegmenterTask extends Task17 {
5789
6601
  static type = "TopicSegmenterTask";
5790
6602
  static category = "Document";
5791
6603
  static title = "Topic Segmenter";
@@ -5988,17 +6800,17 @@ class TopicSegmenterTask extends Task16 {
5988
6800
  }
5989
6801
  }
5990
6802
  var topicSegmenter = (input, config) => {
5991
- return new TopicSegmenterTask({}, config).run(input);
6803
+ return new TopicSegmenterTask(config).run(input);
5992
6804
  };
5993
- Workflow40.prototype.topicSegmenter = CreateWorkflow40(TopicSegmenterTask);
6805
+ Workflow42.prototype.topicSegmenter = CreateWorkflow42(TopicSegmenterTask);
5994
6806
 
5995
6807
  // src/task/UnloadModelTask.ts
5996
- import { CreateWorkflow as CreateWorkflow41, Workflow as Workflow41 } from "@workglow/task-graph";
5997
- var modelSchema28 = TypeModel("model");
6808
+ import { CreateWorkflow as CreateWorkflow43, Workflow as Workflow43 } from "@workglow/task-graph";
6809
+ var modelSchema30 = TypeModel("model");
5998
6810
  var UnloadModelInputSchema = {
5999
6811
  type: "object",
6000
6812
  properties: {
6001
- model: modelSchema28
6813
+ model: modelSchema30
6002
6814
  },
6003
6815
  required: ["model"],
6004
6816
  additionalProperties: false
@@ -6006,7 +6818,7 @@ var UnloadModelInputSchema = {
6006
6818
  var UnloadModelOutputSchema = {
6007
6819
  type: "object",
6008
6820
  properties: {
6009
- model: modelSchema28
6821
+ model: modelSchema30
6010
6822
  },
6011
6823
  required: ["model"],
6012
6824
  additionalProperties: false
@@ -6026,12 +6838,12 @@ class UnloadModelTask extends AiTask {
6026
6838
  static cacheable = false;
6027
6839
  }
6028
6840
  var unloadModel = (input, config) => {
6029
- return new UnloadModelTask({}, config).run(input);
6841
+ return new UnloadModelTask(config).run(input);
6030
6842
  };
6031
- Workflow41.prototype.unloadModel = CreateWorkflow41(UnloadModelTask);
6843
+ Workflow43.prototype.unloadModel = CreateWorkflow43(UnloadModelTask);
6032
6844
 
6033
6845
  // src/task/VectorQuantizeTask.ts
6034
- import { CreateWorkflow as CreateWorkflow42, Task as Task17, Workflow as Workflow42 } from "@workglow/task-graph";
6846
+ import { CreateWorkflow as CreateWorkflow44, Task as Task18, Workflow as Workflow44 } from "@workglow/task-graph";
6035
6847
  import {
6036
6848
  normalizeNumberArray,
6037
6849
  TensorType,
@@ -6111,7 +6923,7 @@ var outputSchema15 = {
6111
6923
  additionalProperties: false
6112
6924
  };
6113
6925
 
6114
- class VectorQuantizeTask extends Task17 {
6926
+ class VectorQuantizeTask extends Task18 {
6115
6927
  static type = "VectorQuantizeTask";
6116
6928
  static category = "Vector";
6117
6929
  static title = "Quantize";
@@ -6209,12 +7021,12 @@ class VectorQuantizeTask extends Task17 {
6209
7021
  }
6210
7022
  }
6211
7023
  var vectorQuantize = (input, config) => {
6212
- return new VectorQuantizeTask({}, config).run(input);
7024
+ return new VectorQuantizeTask(config).run(input);
6213
7025
  };
6214
- Workflow42.prototype.vectorQuantize = CreateWorkflow42(VectorQuantizeTask);
7026
+ Workflow44.prototype.vectorQuantize = CreateWorkflow44(VectorQuantizeTask);
6215
7027
 
6216
7028
  // src/task/VectorSimilarityTask.ts
6217
- import { CreateWorkflow as CreateWorkflow43, GraphAsTask, Workflow as Workflow43 } from "@workglow/task-graph";
7029
+ import { CreateWorkflow as CreateWorkflow45, GraphAsTask, Workflow as Workflow45 } from "@workglow/task-graph";
6218
7030
  import {
6219
7031
  cosineSimilarity,
6220
7032
  hammingSimilarity,
@@ -6318,13 +7130,210 @@ class VectorSimilarityTask extends GraphAsTask {
6318
7130
  }
6319
7131
  }
6320
7132
  var similarity = (input, config) => {
6321
- return new VectorSimilarityTask({}, config).run(input);
6322
- };
6323
- Workflow43.prototype.similarity = CreateWorkflow43(VectorSimilarityTask);
7133
+ return new VectorSimilarityTask(config).run(input);
7134
+ };
7135
+ Workflow45.prototype.similarity = CreateWorkflow45(VectorSimilarityTask);
7136
+ // src/task/MessageConversion.ts
7137
+ function getInputMessages(input) {
7138
+ const messages = input.messages;
7139
+ if (!messages || messages.length === 0)
7140
+ return;
7141
+ return messages;
7142
+ }
7143
+ function toOpenAIMessages(input) {
7144
+ const messages = [];
7145
+ if (input.systemPrompt) {
7146
+ messages.push({ role: "system", content: input.systemPrompt });
7147
+ }
7148
+ const inputMessages = getInputMessages(input);
7149
+ if (!inputMessages) {
7150
+ if (!Array.isArray(input.prompt)) {
7151
+ messages.push({ role: "user", content: input.prompt });
7152
+ } else if (input.prompt.every((item) => typeof item === "string")) {
7153
+ messages.push({ role: "user", content: input.prompt.join(`
7154
+ `) });
7155
+ } else {
7156
+ const parts = [];
7157
+ for (const item of input.prompt) {
7158
+ if (typeof item === "string") {
7159
+ parts.push({ type: "text", text: item });
7160
+ } else {
7161
+ const b = item;
7162
+ if (b.type === "text") {
7163
+ parts.push({ type: "text", text: b.text });
7164
+ } else if (b.type === "image") {
7165
+ parts.push({
7166
+ type: "image_url",
7167
+ image_url: { url: `data:${b.mimeType};base64,${b.data}` }
7168
+ });
7169
+ } else if (b.type === "audio") {
7170
+ const format = b.mimeType.replace(/^audio\//, "");
7171
+ parts.push({
7172
+ type: "input_audio",
7173
+ input_audio: { data: b.data, format }
7174
+ });
7175
+ }
7176
+ }
7177
+ }
7178
+ messages.push({ role: "user", content: parts });
7179
+ }
7180
+ return messages;
7181
+ }
7182
+ for (const msg of inputMessages) {
7183
+ if (msg.role === "user") {
7184
+ if (typeof msg.content === "string") {
7185
+ messages.push({ role: "user", content: msg.content });
7186
+ } else if (Array.isArray(msg.content) && msg.content.length > 0 && typeof msg.content[0]?.type === "string") {
7187
+ const parts = [];
7188
+ for (const block of msg.content) {
7189
+ const b = block;
7190
+ if (b.type === "text") {
7191
+ parts.push({ type: "text", text: b.text });
7192
+ } else if (b.type === "image") {
7193
+ parts.push({
7194
+ type: "image_url",
7195
+ image_url: { url: `data:${b.mimeType};base64,${b.data}` }
7196
+ });
7197
+ } else if (b.type === "audio") {
7198
+ const format = b.mimeType.replace(/^audio\//, "");
7199
+ parts.push({
7200
+ type: "input_audio",
7201
+ input_audio: { data: b.data, format }
7202
+ });
7203
+ }
7204
+ }
7205
+ messages.push({ role: "user", content: parts });
7206
+ } else {
7207
+ try {
7208
+ messages.push({ role: "user", content: JSON.stringify(msg.content) });
7209
+ } catch {
7210
+ messages.push({ role: "user", content: String(msg.content) });
7211
+ }
7212
+ }
7213
+ } else if (msg.role === "assistant") {
7214
+ if (typeof msg.content === "string") {
7215
+ messages.push({ role: "assistant", content: msg.content.length > 0 ? msg.content : null });
7216
+ } else if (Array.isArray(msg.content)) {
7217
+ const textParts = msg.content.filter((b) => b.type === "text").map((b) => b.text).join("");
7218
+ const toolCalls = msg.content.filter((b) => b.type === "tool_use").map((b) => ({
7219
+ id: b.id,
7220
+ type: "function",
7221
+ function: {
7222
+ name: b.name,
7223
+ arguments: JSON.stringify(b.input)
7224
+ }
7225
+ }));
7226
+ const entry = {
7227
+ role: "assistant",
7228
+ content: textParts.length > 0 ? textParts : null
7229
+ };
7230
+ if (toolCalls.length > 0) {
7231
+ entry.tool_calls = toolCalls;
7232
+ }
7233
+ messages.push(entry);
7234
+ }
7235
+ } else if (msg.role === "tool" && Array.isArray(msg.content)) {
7236
+ for (const block of msg.content) {
7237
+ const b = block;
7238
+ let content;
7239
+ if (typeof b.content === "string") {
7240
+ content = b.content;
7241
+ } else if (Array.isArray(b.content)) {
7242
+ const parts = [];
7243
+ for (const inner of b.content) {
7244
+ if (inner.type === "text") {
7245
+ parts.push({ type: "text", text: inner.text });
7246
+ } else if (inner.type === "image") {
7247
+ parts.push({
7248
+ type: "image_url",
7249
+ image_url: { url: `data:${inner.mimeType};base64,${inner.data}` }
7250
+ });
7251
+ }
7252
+ }
7253
+ content = parts;
7254
+ } else {
7255
+ content = "";
7256
+ }
7257
+ messages.push({
7258
+ role: "tool",
7259
+ content,
7260
+ tool_call_id: b.tool_use_id
7261
+ });
7262
+ }
7263
+ }
7264
+ }
7265
+ return messages;
7266
+ }
7267
+ function toTextFlatMessages(input) {
7268
+ const messages = [];
7269
+ if (input.systemPrompt) {
7270
+ messages.push({ role: "system", content: input.systemPrompt });
7271
+ }
7272
+ const inputMessages = getInputMessages(input);
7273
+ if (!inputMessages) {
7274
+ let promptContent;
7275
+ if (!Array.isArray(input.prompt)) {
7276
+ promptContent = input.prompt;
7277
+ } else {
7278
+ promptContent = input.prompt.map((item) => {
7279
+ if (typeof item === "string")
7280
+ return item;
7281
+ const b = item;
7282
+ return b.type === "text" ? b.text : "";
7283
+ }).filter((s) => s !== "").join(`
7284
+ `);
7285
+ }
7286
+ messages.push({ role: "user", content: promptContent });
7287
+ return messages;
7288
+ }
7289
+ for (const msg of inputMessages) {
7290
+ if (msg.role === "user") {
7291
+ let content = "";
7292
+ if (typeof msg.content === "string") {
7293
+ content = msg.content;
7294
+ } else if (Array.isArray(msg.content) && msg.content.length > 0 && typeof msg.content[0]?.type === "string") {
7295
+ content = msg.content.filter((b) => b.type === "text").map((b) => b.text).join("");
7296
+ } else if (msg.content != null) {
7297
+ try {
7298
+ content = JSON.stringify(msg.content);
7299
+ } catch {
7300
+ content = String(msg.content);
7301
+ }
7302
+ }
7303
+ messages.push({ role: "user", content });
7304
+ } else if (msg.role === "assistant") {
7305
+ if (typeof msg.content === "string") {
7306
+ if (msg.content) {
7307
+ messages.push({ role: "assistant", content: msg.content });
7308
+ }
7309
+ } else if (Array.isArray(msg.content)) {
7310
+ const text = msg.content.filter((b) => b.type === "text").map((b) => b.text).join("");
7311
+ if (text) {
7312
+ messages.push({ role: "assistant", content: text });
7313
+ }
7314
+ }
7315
+ } else if (msg.role === "tool" && Array.isArray(msg.content)) {
7316
+ for (const block of msg.content) {
7317
+ const b = block;
7318
+ let content;
7319
+ if (typeof b.content === "string") {
7320
+ content = b.content;
7321
+ } else if (Array.isArray(b.content)) {
7322
+ content = b.content.filter((inner) => inner.type === "text").map((inner) => inner.text).join("");
7323
+ } else {
7324
+ content = "";
7325
+ }
7326
+ messages.push({ role: "tool", content });
7327
+ }
7328
+ }
7329
+ }
7330
+ return messages;
7331
+ }
6324
7332
 
6325
7333
  // src/task/index.ts
6326
7334
  var registerAiTasks = () => {
6327
7335
  const tasks = [
7336
+ AgentTask,
6328
7337
  BackgroundRemovalTask,
6329
7338
  ChunkToVectorTask,
6330
7339
  CountTokensTask,
@@ -6364,6 +7373,7 @@ var registerAiTasks = () => {
6364
7373
  TextRewriterTask,
6365
7374
  TextSummaryTask,
6366
7375
  TextTranslationTask,
7376
+ ToolCallingTask,
6367
7377
  TopicSegmenterTask,
6368
7378
  UnloadModelTask,
6369
7379
  VectorQuantizeTask,
@@ -6375,8 +7385,14 @@ var registerAiTasks = () => {
6375
7385
  export {
6376
7386
  vectorStoreSearch,
6377
7387
  vectorQuantize,
7388
+ userMessage,
6378
7389
  unloadModel,
6379
7390
  topicSegmenter,
7391
+ toolSourceDefinitions,
7392
+ toolMessage,
7393
+ toolCalling,
7394
+ toTextFlatMessages,
7395
+ toOpenAIMessages,
6380
7396
  textTranslation,
6381
7397
  textSummary,
6382
7398
  textRewriter,
@@ -6388,6 +7404,7 @@ export {
6388
7404
  textEmbedding,
6389
7405
  textClassification,
6390
7406
  textChunker,
7407
+ taskTypesToTools,
6391
7408
  structuredGeneration,
6392
7409
  structuralParser,
6393
7410
  similarity,
@@ -6401,27 +7418,42 @@ export {
6401
7418
  objectDetection,
6402
7419
  modelSearch,
6403
7420
  modelInfo,
7421
+ isAllowedToolName,
6404
7422
  imageToText,
6405
7423
  imageSegmentation,
6406
7424
  imageEmbedding,
6407
7425
  imageClassification,
7426
+ imageBlockFromDataUri,
7427
+ imageBlock,
6408
7428
  hybridSearch,
6409
7429
  hierarchyJoin,
6410
7430
  hierarchicalChunker,
7431
+ hasToolCalls,
6411
7432
  handLandmarker,
6412
7433
  getGlobalModelRepository,
6413
7434
  getAiProviderRegistry,
6414
7435
  gestureRecognizer,
7436
+ findToolSource,
7437
+ filterValidToolCalls,
6415
7438
  faceLandmarker,
6416
7439
  faceDetector,
7440
+ executeToolCalls,
7441
+ executeToolCall,
6417
7442
  downloadModel,
6418
7443
  documentEnricher,
6419
7444
  countTokens,
7445
+ countAssistantToolUses,
6420
7446
  contextBuilder,
6421
7447
  chunkVectorUpsert,
6422
7448
  chunkToVector,
6423
7449
  chunkRetrieval,
7450
+ buildToolSources,
7451
+ buildToolDescription,
6424
7452
  backgroundRemoval,
7453
+ audioBlockFromDataUri,
7454
+ audioBlock,
7455
+ assistantMessage,
7456
+ agent,
6425
7457
  VectorSimilarityTask,
6426
7458
  VectorQuantizeTask,
6427
7459
  UnloadModelTask,
@@ -6435,6 +7467,10 @@ export {
6435
7467
  TypeBoundingBox,
6436
7468
  TypeAudioInput,
6437
7469
  TopicSegmenterTask,
7470
+ ToolDefinitionSchema,
7471
+ ToolCallingTask,
7472
+ ToolCallingOutputSchema,
7473
+ ToolCallingInputSchema,
6438
7474
  TextTranslationTask,
6439
7475
  TextTranslationOutputSchema,
6440
7476
  TextTranslationInputSchema,
@@ -6538,7 +7574,10 @@ export {
6538
7574
  AiTask,
6539
7575
  AiProviderRegistry,
6540
7576
  AiProvider,
6541
- AiJob
7577
+ AiJob,
7578
+ AgentTask,
7579
+ AgentOutputSchema,
7580
+ AgentInputSchema
6542
7581
  };
6543
7582
 
6544
- //# debugId=833980E5CCD244A264756E2164756E21
7583
+ //# debugId=64037AF9B0D88FB164756E2164756E21