@voltagent/core 0.1.21 → 0.1.22
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/index.js +31 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -919,14 +919,33 @@ var StreamTextEventSchema = import_zod.z.object({
|
|
|
919
919
|
done: import_zod.z.boolean().optional(),
|
|
920
920
|
error: import_zod.z.string().optional()
|
|
921
921
|
});
|
|
922
|
+
var BasicJsonSchema = import_zod.z.object({
|
|
923
|
+
type: import_zod.z.literal("object"),
|
|
924
|
+
properties: import_zod.z.record(
|
|
925
|
+
import_zod.z.object({
|
|
926
|
+
type: import_zod.z.enum(["string", "number", "boolean", "object", "array", "null", "any"])
|
|
927
|
+
})
|
|
928
|
+
).optional().openapi({
|
|
929
|
+
description: "A dictionary defining each property of the object and its type",
|
|
930
|
+
example: {
|
|
931
|
+
id: { type: "string" },
|
|
932
|
+
age: { type: "number" },
|
|
933
|
+
isActive: { type: "boolean" }
|
|
934
|
+
}
|
|
935
|
+
}),
|
|
936
|
+
required: import_zod.z.array(import_zod.z.string()).optional().openapi({
|
|
937
|
+
description: "List of required property names in the object",
|
|
938
|
+
example: ["id", "age"]
|
|
939
|
+
})
|
|
940
|
+
}).passthrough().openapi({
|
|
941
|
+
description: "The Zod schema for the desired object output (passed as JSON)"
|
|
942
|
+
});
|
|
922
943
|
var ObjectRequestSchema = import_zod.z.object({
|
|
923
944
|
input: import_zod.z.union([
|
|
924
945
|
import_zod.z.string().openapi({ description: "Input text prompt" }),
|
|
925
946
|
import_zod.z.array(MessageObjectSchema).openapi({ description: "Conversation history" })
|
|
926
947
|
]),
|
|
927
|
-
schema:
|
|
928
|
-
description: "The Zod schema for the desired object output (passed as JSON)"
|
|
929
|
-
}),
|
|
948
|
+
schema: BasicJsonSchema,
|
|
930
949
|
options: GenerateOptionsSchema.optional().openapi({
|
|
931
950
|
description: "Optional object generation parameters",
|
|
932
951
|
example: { temperature: 0.2 }
|
|
@@ -1159,6 +1178,7 @@ Example event: 'data: {"partialUpdate": {...}}
|
|
|
1159
1178
|
});
|
|
1160
1179
|
|
|
1161
1180
|
// src/server/api.ts
|
|
1181
|
+
var import_json_schema_to_zod = require("@n8n/json-schema-to-zod");
|
|
1162
1182
|
var app = new import_zod_openapi2.OpenAPIHono();
|
|
1163
1183
|
app.get("/", (c) => {
|
|
1164
1184
|
const html = `
|
|
@@ -1501,7 +1521,8 @@ app.openapi(objectRoute, (c) => __async(void 0, null, function* () {
|
|
|
1501
1521
|
schema,
|
|
1502
1522
|
options = {}
|
|
1503
1523
|
} = c.req.valid("json");
|
|
1504
|
-
const
|
|
1524
|
+
const schemaInZodObject = (0, import_json_schema_to_zod.jsonSchemaToZod)(schema);
|
|
1525
|
+
const response = yield agent.generateObject(input, schemaInZodObject, options);
|
|
1505
1526
|
return c.json(
|
|
1506
1527
|
{ success: true, data: response },
|
|
1507
1528
|
200
|
|
@@ -1533,12 +1554,12 @@ app.openapi(streamObjectRoute, (c) => __async(void 0, null, function* () {
|
|
|
1533
1554
|
schema,
|
|
1534
1555
|
options = {}
|
|
1535
1556
|
} = c.req.valid("json");
|
|
1536
|
-
const
|
|
1557
|
+
const schemaInZodObject = (0, import_json_schema_to_zod.jsonSchemaToZod)(schema);
|
|
1558
|
+
const agentStream = yield agent.streamObject(input, schemaInZodObject, options);
|
|
1537
1559
|
const sseStream = new ReadableStream({
|
|
1538
1560
|
start(controller) {
|
|
1539
1561
|
return __async(this, null, function* () {
|
|
1540
|
-
const reader = agentStream.getReader();
|
|
1541
|
-
const decoder = new TextDecoder();
|
|
1562
|
+
const reader = agentStream.objectStream.getReader();
|
|
1542
1563
|
try {
|
|
1543
1564
|
while (true) {
|
|
1544
1565
|
const { done, value } = yield reader.read();
|
|
@@ -1553,8 +1574,7 @@ app.openapi(streamObjectRoute, (c) => __async(void 0, null, function* () {
|
|
|
1553
1574
|
`);
|
|
1554
1575
|
break;
|
|
1555
1576
|
}
|
|
1556
|
-
|
|
1557
|
-
controller.enqueue(`data: ${chunkString}
|
|
1577
|
+
controller.enqueue(`data: ${JSON.stringify(value)}
|
|
1558
1578
|
|
|
1559
1579
|
`);
|
|
1560
1580
|
}
|
|
@@ -7537,7 +7557,7 @@ var import_sse = require("@modelcontextprotocol/sdk/client/sse.js");
|
|
|
7537
7557
|
var import_stdio = require("@modelcontextprotocol/sdk/client/stdio.js");
|
|
7538
7558
|
var import_protocol = require("@modelcontextprotocol/sdk/shared/protocol.js");
|
|
7539
7559
|
var import_types2 = require("@modelcontextprotocol/sdk/types.js");
|
|
7540
|
-
var
|
|
7560
|
+
var import_json_schema_to_zod2 = require("@n8n/json-schema-to-zod");
|
|
7541
7561
|
var MCPClient = class extends import_node_events2.EventEmitter {
|
|
7542
7562
|
// Renamed back from identity
|
|
7543
7563
|
/**
|
|
@@ -7681,7 +7701,7 @@ var MCPClient = class extends import_node_events2.EventEmitter {
|
|
|
7681
7701
|
const executableTools = {};
|
|
7682
7702
|
for (const toolDef of Object.values(definitions)) {
|
|
7683
7703
|
try {
|
|
7684
|
-
const zodSchema = (0,
|
|
7704
|
+
const zodSchema = (0, import_json_schema_to_zod2.jsonSchemaToZod)(toolDef.inputSchema);
|
|
7685
7705
|
const namespacedToolName = `${this.clientInfo.name}_${toolDef.name}`;
|
|
7686
7706
|
const agentTool = createTool({
|
|
7687
7707
|
name: namespacedToolName,
|