@workglow/ai 0.2.13 → 0.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +27 -15
- package/dist/browser.js.map +7 -7
- package/dist/bun.js +27 -15
- package/dist/bun.js.map +7 -7
- package/dist/node.js +27 -15
- package/dist/node.js.map +7 -7
- package/dist/provider/AiProviderRegistry.d.ts +16 -0
- package/dist/provider/AiProviderRegistry.d.ts.map +1 -1
- package/dist/task/AiChatTask.d.ts +150 -231
- package/dist/task/AiChatTask.d.ts.map +1 -1
- package/dist/task/ChatMessage.d.ts +110 -155
- package/dist/task/ChatMessage.d.ts.map +1 -1
- package/dist/task/StructuredGenerationTask.d.ts +1 -1
- package/dist/task/StructuredGenerationTask.d.ts.map +1 -1
- package/dist/task/ToolCallingTask.d.ts +50 -77
- package/dist/task/ToolCallingTask.d.ts.map +1 -1
- package/dist/task/base/AiVisionTask.d.ts.map +1 -1
- package/dist/task/base/StreamingAiTask.d.ts +10 -0
- package/dist/task/base/StreamingAiTask.d.ts.map +1 -1
- package/dist/worker.js.map +2 -2
- package/package.json +11 -11
package/dist/bun.js
CHANGED
|
@@ -1250,6 +1250,9 @@ var ContentBlockToolUseSchema = {
|
|
|
1250
1250
|
required: ["type", "id", "name", "input"],
|
|
1251
1251
|
additionalProperties: false
|
|
1252
1252
|
};
|
|
1253
|
+
var ContentBlockInToolResultBodySchema = {
|
|
1254
|
+
oneOf: [ContentBlockTextSchema, ContentBlockImageSchema, ContentBlockToolUseSchema]
|
|
1255
|
+
};
|
|
1253
1256
|
var ContentBlockToolResultSchema = {
|
|
1254
1257
|
type: "object",
|
|
1255
1258
|
properties: {
|
|
@@ -1257,7 +1260,7 @@ var ContentBlockToolResultSchema = {
|
|
|
1257
1260
|
tool_use_id: { type: "string" },
|
|
1258
1261
|
content: {
|
|
1259
1262
|
type: "array",
|
|
1260
|
-
items:
|
|
1263
|
+
items: ContentBlockInToolResultBodySchema
|
|
1261
1264
|
},
|
|
1262
1265
|
is_error: { type: "boolean" }
|
|
1263
1266
|
},
|
|
@@ -1271,16 +1274,6 @@ var ContentBlockSchema = {
|
|
|
1271
1274
|
ContentBlockToolUseSchema,
|
|
1272
1275
|
ContentBlockToolResultSchema
|
|
1273
1276
|
],
|
|
1274
|
-
definitions: {
|
|
1275
|
-
ContentBlock: {
|
|
1276
|
-
oneOf: [
|
|
1277
|
-
ContentBlockTextSchema,
|
|
1278
|
-
ContentBlockImageSchema,
|
|
1279
|
-
ContentBlockToolUseSchema,
|
|
1280
|
-
ContentBlockToolResultSchema
|
|
1281
|
-
]
|
|
1282
|
-
}
|
|
1283
|
-
},
|
|
1284
1277
|
title: "ContentBlock",
|
|
1285
1278
|
description: "A single content block within a chat message"
|
|
1286
1279
|
};
|
|
@@ -1298,6 +1291,21 @@ var ChatMessageSchema = {
|
|
|
1298
1291
|
title: "ChatMessage",
|
|
1299
1292
|
description: "A single chat message with role and structured content blocks"
|
|
1300
1293
|
};
|
|
1294
|
+
function isContentBlockInToolResultBody(value) {
|
|
1295
|
+
if (!value || typeof value !== "object")
|
|
1296
|
+
return false;
|
|
1297
|
+
const v = value;
|
|
1298
|
+
switch (v.type) {
|
|
1299
|
+
case "text":
|
|
1300
|
+
return typeof v.text === "string";
|
|
1301
|
+
case "image":
|
|
1302
|
+
return typeof v.mimeType === "string" && typeof v.data === "string";
|
|
1303
|
+
case "tool_use":
|
|
1304
|
+
return typeof v.id === "string" && typeof v.name === "string" && v.input !== null && typeof v.input === "object";
|
|
1305
|
+
default:
|
|
1306
|
+
return false;
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1301
1309
|
function isContentBlock(value) {
|
|
1302
1310
|
if (!value || typeof value !== "object")
|
|
1303
1311
|
return false;
|
|
@@ -1310,7 +1318,7 @@ function isContentBlock(value) {
|
|
|
1310
1318
|
case "tool_use":
|
|
1311
1319
|
return typeof v.id === "string" && typeof v.name === "string" && v.input !== null && typeof v.input === "object";
|
|
1312
1320
|
case "tool_result":
|
|
1313
|
-
return typeof v.tool_use_id === "string" && Array.isArray(v.content) && v.content.every(
|
|
1321
|
+
return typeof v.tool_use_id === "string" && Array.isArray(v.content) && v.content.every(isContentBlockInToolResultBody);
|
|
1314
1322
|
default:
|
|
1315
1323
|
return false;
|
|
1316
1324
|
}
|
|
@@ -1571,7 +1579,7 @@ class AiChatTask extends StreamingAiTask {
|
|
|
1571
1579
|
import { CreateWorkflow, Workflow } from "@workglow/task-graph";
|
|
1572
1580
|
|
|
1573
1581
|
// src/task/base/AiVisionTask.ts
|
|
1574
|
-
import {
|
|
1582
|
+
import { Image } from "@workglow/util/media";
|
|
1575
1583
|
class AiVisionTask extends AiTask {
|
|
1576
1584
|
static type = "AiVisionTask";
|
|
1577
1585
|
async getJobInput(input) {
|
|
@@ -1584,7 +1592,8 @@ class AiVisionTask extends AiTask {
|
|
|
1584
1592
|
} else if (typeof providerName === "string" && providerName.startsWith("TENSORFLOW_MEDIAPIPE") && "VideoFrame" in globalThis) {
|
|
1585
1593
|
supports.push("VideoFrame");
|
|
1586
1594
|
}
|
|
1587
|
-
const
|
|
1595
|
+
const toSupported = (img) => Image.from(img).toFirstSupported(supports);
|
|
1596
|
+
const image = Array.isArray(input.image) ? await Promise.all(input.image.map(toSupported)) : await toSupported(input.image);
|
|
1588
1597
|
jobInput.taskInput.image = image;
|
|
1589
1598
|
}
|
|
1590
1599
|
return jobInput;
|
|
@@ -5788,6 +5797,8 @@ class StructuredGenerationTask extends StreamingAiTask {
|
|
|
5788
5797
|
let validator;
|
|
5789
5798
|
try {
|
|
5790
5799
|
validator = compileSchema2(input.outputSchema);
|
|
5800
|
+
if (!input.outputSchema)
|
|
5801
|
+
throw new Error("outputSchema is not a valid JSON Schema");
|
|
5791
5802
|
} catch (err2) {
|
|
5792
5803
|
const msg = err2 instanceof Error ? err2.message : String(err2);
|
|
5793
5804
|
const configErr = new TaskConfigurationError4(`StructuredGenerationTask: invalid outputSchema \u2014 ${msg}`);
|
|
@@ -7596,6 +7607,7 @@ export {
|
|
|
7596
7607
|
modelSearch,
|
|
7597
7608
|
modelInfo,
|
|
7598
7609
|
kbToDocuments,
|
|
7610
|
+
isContentBlockInToolResultBody,
|
|
7599
7611
|
isContentBlock,
|
|
7600
7612
|
isChatMessage,
|
|
7601
7613
|
isAllowedToolName,
|
|
@@ -7755,4 +7767,4 @@ export {
|
|
|
7755
7767
|
AiChatInputSchema
|
|
7756
7768
|
};
|
|
7757
7769
|
|
|
7758
|
-
//# debugId=
|
|
7770
|
+
//# debugId=3CD3867D0171540164756E2164756E21
|