@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/browser.js
CHANGED
|
@@ -1249,6 +1249,9 @@ var ContentBlockToolUseSchema = {
|
|
|
1249
1249
|
required: ["type", "id", "name", "input"],
|
|
1250
1250
|
additionalProperties: false
|
|
1251
1251
|
};
|
|
1252
|
+
var ContentBlockInToolResultBodySchema = {
|
|
1253
|
+
oneOf: [ContentBlockTextSchema, ContentBlockImageSchema, ContentBlockToolUseSchema]
|
|
1254
|
+
};
|
|
1252
1255
|
var ContentBlockToolResultSchema = {
|
|
1253
1256
|
type: "object",
|
|
1254
1257
|
properties: {
|
|
@@ -1256,7 +1259,7 @@ var ContentBlockToolResultSchema = {
|
|
|
1256
1259
|
tool_use_id: { type: "string" },
|
|
1257
1260
|
content: {
|
|
1258
1261
|
type: "array",
|
|
1259
|
-
items:
|
|
1262
|
+
items: ContentBlockInToolResultBodySchema
|
|
1260
1263
|
},
|
|
1261
1264
|
is_error: { type: "boolean" }
|
|
1262
1265
|
},
|
|
@@ -1270,16 +1273,6 @@ var ContentBlockSchema = {
|
|
|
1270
1273
|
ContentBlockToolUseSchema,
|
|
1271
1274
|
ContentBlockToolResultSchema
|
|
1272
1275
|
],
|
|
1273
|
-
definitions: {
|
|
1274
|
-
ContentBlock: {
|
|
1275
|
-
oneOf: [
|
|
1276
|
-
ContentBlockTextSchema,
|
|
1277
|
-
ContentBlockImageSchema,
|
|
1278
|
-
ContentBlockToolUseSchema,
|
|
1279
|
-
ContentBlockToolResultSchema
|
|
1280
|
-
]
|
|
1281
|
-
}
|
|
1282
|
-
},
|
|
1283
1276
|
title: "ContentBlock",
|
|
1284
1277
|
description: "A single content block within a chat message"
|
|
1285
1278
|
};
|
|
@@ -1297,6 +1290,21 @@ var ChatMessageSchema = {
|
|
|
1297
1290
|
title: "ChatMessage",
|
|
1298
1291
|
description: "A single chat message with role and structured content blocks"
|
|
1299
1292
|
};
|
|
1293
|
+
function isContentBlockInToolResultBody(value) {
|
|
1294
|
+
if (!value || typeof value !== "object")
|
|
1295
|
+
return false;
|
|
1296
|
+
const v = value;
|
|
1297
|
+
switch (v.type) {
|
|
1298
|
+
case "text":
|
|
1299
|
+
return typeof v.text === "string";
|
|
1300
|
+
case "image":
|
|
1301
|
+
return typeof v.mimeType === "string" && typeof v.data === "string";
|
|
1302
|
+
case "tool_use":
|
|
1303
|
+
return typeof v.id === "string" && typeof v.name === "string" && v.input !== null && typeof v.input === "object";
|
|
1304
|
+
default:
|
|
1305
|
+
return false;
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1300
1308
|
function isContentBlock(value) {
|
|
1301
1309
|
if (!value || typeof value !== "object")
|
|
1302
1310
|
return false;
|
|
@@ -1309,7 +1317,7 @@ function isContentBlock(value) {
|
|
|
1309
1317
|
case "tool_use":
|
|
1310
1318
|
return typeof v.id === "string" && typeof v.name === "string" && v.input !== null && typeof v.input === "object";
|
|
1311
1319
|
case "tool_result":
|
|
1312
|
-
return typeof v.tool_use_id === "string" && Array.isArray(v.content) && v.content.every(
|
|
1320
|
+
return typeof v.tool_use_id === "string" && Array.isArray(v.content) && v.content.every(isContentBlockInToolResultBody);
|
|
1313
1321
|
default:
|
|
1314
1322
|
return false;
|
|
1315
1323
|
}
|
|
@@ -1570,7 +1578,7 @@ class AiChatTask extends StreamingAiTask {
|
|
|
1570
1578
|
import { CreateWorkflow, Workflow } from "@workglow/task-graph";
|
|
1571
1579
|
|
|
1572
1580
|
// src/task/base/AiVisionTask.ts
|
|
1573
|
-
import {
|
|
1581
|
+
import { Image } from "@workglow/util/media";
|
|
1574
1582
|
class AiVisionTask extends AiTask {
|
|
1575
1583
|
static type = "AiVisionTask";
|
|
1576
1584
|
async getJobInput(input) {
|
|
@@ -1583,7 +1591,8 @@ class AiVisionTask extends AiTask {
|
|
|
1583
1591
|
} else if (typeof providerName === "string" && providerName.startsWith("TENSORFLOW_MEDIAPIPE") && "VideoFrame" in globalThis) {
|
|
1584
1592
|
supports.push("VideoFrame");
|
|
1585
1593
|
}
|
|
1586
|
-
const
|
|
1594
|
+
const toSupported = (img) => Image.from(img).toFirstSupported(supports);
|
|
1595
|
+
const image = Array.isArray(input.image) ? await Promise.all(input.image.map(toSupported)) : await toSupported(input.image);
|
|
1587
1596
|
jobInput.taskInput.image = image;
|
|
1588
1597
|
}
|
|
1589
1598
|
return jobInput;
|
|
@@ -5787,6 +5796,8 @@ class StructuredGenerationTask extends StreamingAiTask {
|
|
|
5787
5796
|
let validator;
|
|
5788
5797
|
try {
|
|
5789
5798
|
validator = compileSchema2(input.outputSchema);
|
|
5799
|
+
if (!input.outputSchema)
|
|
5800
|
+
throw new Error("outputSchema is not a valid JSON Schema");
|
|
5790
5801
|
} catch (err2) {
|
|
5791
5802
|
const msg = err2 instanceof Error ? err2.message : String(err2);
|
|
5792
5803
|
const configErr = new TaskConfigurationError4(`StructuredGenerationTask: invalid outputSchema — ${msg}`);
|
|
@@ -7595,6 +7606,7 @@ export {
|
|
|
7595
7606
|
modelSearch,
|
|
7596
7607
|
modelInfo,
|
|
7597
7608
|
kbToDocuments,
|
|
7609
|
+
isContentBlockInToolResultBody,
|
|
7598
7610
|
isContentBlock,
|
|
7599
7611
|
isChatMessage,
|
|
7600
7612
|
isAllowedToolName,
|
|
@@ -7754,4 +7766,4 @@ export {
|
|
|
7754
7766
|
AiChatInputSchema
|
|
7755
7767
|
};
|
|
7756
7768
|
|
|
7757
|
-
//# debugId=
|
|
7769
|
+
//# debugId=C2FFB1F0D75C8A6864756E2164756E21
|