@mantyx/sdk 0.15.0 → 0.15.1
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/CHANGELOG.md +7 -0
- package/dist/a2a-server.cjs.map +1 -1
- package/dist/a2a-server.js +1 -1
- package/dist/{chunk-TLKXNZYY.js → chunk-YXTU725K.js} +55 -17
- package/dist/chunk-YXTU725K.js.map +1 -0
- package/dist/index.cjs +55 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-TLKXNZYY.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -581,7 +581,20 @@ function parseEventBlock(block) {
|
|
|
581
581
|
|
|
582
582
|
// src/zod-to-json-schema.ts
|
|
583
583
|
var import_zod = require("zod");
|
|
584
|
+
function isZodSchema(value) {
|
|
585
|
+
if (!value || typeof value !== "object") return false;
|
|
586
|
+
const o = value;
|
|
587
|
+
return typeof o._def !== "undefined" || typeof o._zod !== "undefined";
|
|
588
|
+
}
|
|
584
589
|
function zodToJsonSchema(schema) {
|
|
590
|
+
const instance = schema;
|
|
591
|
+
if (typeof instance.toJSONSchema === "function") {
|
|
592
|
+
try {
|
|
593
|
+
const out = instance.toJSONSchema();
|
|
594
|
+
if (out && typeof out === "object") return out;
|
|
595
|
+
} catch {
|
|
596
|
+
}
|
|
597
|
+
}
|
|
585
598
|
const builtIn = import_zod.z.toJSONSchema;
|
|
586
599
|
if (typeof builtIn === "function") {
|
|
587
600
|
try {
|
|
@@ -592,24 +605,40 @@ function zodToJsonSchema(schema) {
|
|
|
592
605
|
}
|
|
593
606
|
return convertNode(schema);
|
|
594
607
|
}
|
|
608
|
+
function schemaKind(def) {
|
|
609
|
+
if (!def) return void 0;
|
|
610
|
+
if (typeof def.typeName === "string") return def.typeName;
|
|
611
|
+
if (typeof def.type === "string") return def.type;
|
|
612
|
+
return void 0;
|
|
613
|
+
}
|
|
614
|
+
function isOptionalField(field) {
|
|
615
|
+
const kind = schemaKind(field._def);
|
|
616
|
+
return kind === "ZodOptional" || kind === "ZodDefault" || kind === "optional" || kind === "default";
|
|
617
|
+
}
|
|
595
618
|
function convertNode(schema) {
|
|
596
619
|
const def = schema._def;
|
|
597
|
-
const
|
|
598
|
-
switch (
|
|
620
|
+
const kind = schemaKind(def);
|
|
621
|
+
switch (kind) {
|
|
599
622
|
case "ZodString":
|
|
623
|
+
case "string":
|
|
600
624
|
return { type: "string" };
|
|
601
625
|
case "ZodNumber":
|
|
626
|
+
case "number":
|
|
602
627
|
return { type: "number" };
|
|
603
628
|
case "ZodBoolean":
|
|
629
|
+
case "boolean":
|
|
604
630
|
return { type: "boolean" };
|
|
605
631
|
case "ZodNull":
|
|
632
|
+
case "null":
|
|
606
633
|
return { type: "null" };
|
|
607
|
-
case "ZodLiteral":
|
|
608
|
-
|
|
634
|
+
case "ZodLiteral":
|
|
635
|
+
case "literal": {
|
|
636
|
+
const value = def?.value;
|
|
609
637
|
return { const: value, type: typeof value };
|
|
610
638
|
}
|
|
611
|
-
case "ZodEnum":
|
|
612
|
-
|
|
639
|
+
case "ZodEnum":
|
|
640
|
+
case "enum": {
|
|
641
|
+
const values = def?.values ?? [];
|
|
613
642
|
return { type: "string", enum: [...values] };
|
|
614
643
|
}
|
|
615
644
|
case "ZodArray": {
|
|
@@ -619,26 +648,35 @@ function convertNode(schema) {
|
|
|
619
648
|
items: inner ? convertNode(inner) : {}
|
|
620
649
|
};
|
|
621
650
|
}
|
|
651
|
+
case "array": {
|
|
652
|
+
const inner = def?.element;
|
|
653
|
+
return {
|
|
654
|
+
type: "array",
|
|
655
|
+
items: inner ? convertNode(inner) : {}
|
|
656
|
+
};
|
|
657
|
+
}
|
|
622
658
|
case "ZodOptional":
|
|
623
|
-
case "ZodNullable":
|
|
624
|
-
|
|
659
|
+
case "ZodNullable":
|
|
660
|
+
case "optional":
|
|
661
|
+
case "nullable": {
|
|
662
|
+
const inner = def?.innerType;
|
|
625
663
|
return inner ? convertNode(inner) : {};
|
|
626
664
|
}
|
|
627
|
-
case "ZodDefault":
|
|
628
|
-
|
|
665
|
+
case "ZodDefault":
|
|
666
|
+
case "default": {
|
|
667
|
+
const inner = def?.innerType;
|
|
629
668
|
return inner ? convertNode(inner) : {};
|
|
630
669
|
}
|
|
631
|
-
case "ZodObject":
|
|
632
|
-
|
|
670
|
+
case "ZodObject":
|
|
671
|
+
case "object": {
|
|
672
|
+
const shape = def?.shape;
|
|
633
673
|
const fields = typeof shape === "function" ? shape() : shape;
|
|
634
674
|
const properties = {};
|
|
635
675
|
const required = [];
|
|
636
676
|
if (fields) {
|
|
637
677
|
for (const [key, value] of Object.entries(fields)) {
|
|
638
678
|
properties[key] = convertNode(value);
|
|
639
|
-
|
|
640
|
-
const innerTypeName = innerDef?.typeName;
|
|
641
|
-
if (innerTypeName !== "ZodOptional" && innerTypeName !== "ZodDefault") {
|
|
679
|
+
if (!isOptionalField(value)) {
|
|
642
680
|
required.push(key);
|
|
643
681
|
}
|
|
644
682
|
}
|
|
@@ -653,7 +691,7 @@ function convertNode(schema) {
|
|
|
653
691
|
}
|
|
654
692
|
function toToolParametersWire(parameters) {
|
|
655
693
|
if (!parameters) return { type: "object", properties: {} };
|
|
656
|
-
if (
|
|
694
|
+
if (isZodSchema(parameters)) {
|
|
657
695
|
return zodToJsonSchema(parameters);
|
|
658
696
|
}
|
|
659
697
|
return parameters;
|
|
@@ -1915,7 +1953,7 @@ function normalizeScope(scope) {
|
|
|
1915
1953
|
}
|
|
1916
1954
|
|
|
1917
1955
|
// src/version.ts
|
|
1918
|
-
var SDK_VERSION = "0.15.
|
|
1956
|
+
var SDK_VERSION = "0.15.1";
|
|
1919
1957
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1920
1958
|
0 && (module.exports = {
|
|
1921
1959
|
AgentSession,
|