@yourgpt/copilot-sdk 1.4.32 → 1.4.34
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/README.md +9 -1
- package/dist/{chunk-CVKN4H62.cjs → chunk-4PRWNAXQ.cjs} +161 -52
- package/dist/chunk-4PRWNAXQ.cjs.map +1 -0
- package/dist/{chunk-B7SF5SGS.cjs → chunk-BLSI67J6.cjs} +40 -40
- package/dist/chunk-BLSI67J6.cjs.map +1 -0
- package/dist/{chunk-VZ4RYZQT.js → chunk-CJ7UWN2Y.js} +16 -16
- package/dist/chunk-CJ7UWN2Y.js.map +1 -0
- package/dist/{chunk-55EABH45.js → chunk-JM7PB2LP.js} +161 -52
- package/dist/chunk-JM7PB2LP.js.map +1 -0
- package/dist/core/index.cjs +76 -76
- package/dist/core/index.d.cts +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/react/index.cjs +42 -42
- package/dist/react/index.js +2 -2
- package/dist/styles.css +92 -0
- package/dist/ui/index.cjs +190 -320
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.d.cts +2 -2
- package/dist/ui/index.d.ts +2 -2
- package/dist/ui/index.js +186 -316
- package/dist/ui/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-55EABH45.js.map +0 -1
- package/dist/chunk-B7SF5SGS.cjs.map +0 -1
- package/dist/chunk-CVKN4H62.cjs.map +0 -1
- package/dist/chunk-VZ4RYZQT.js.map +0 -1
package/README.md
CHANGED
|
@@ -39,10 +39,18 @@ function App() {
|
|
|
39
39
|
```css
|
|
40
40
|
/* app/globals.css */
|
|
41
41
|
@import "tailwindcss";
|
|
42
|
-
|
|
42
|
+
|
|
43
|
+
/* IMPORTANT: Path is relative to your CSS file location */
|
|
44
|
+
/* If globals.css is in app/ folder, use ../ prefix */
|
|
45
|
+
@source "../node_modules/@yourgpt/copilot-sdk/dist/**/*.{js,ts,jsx,tsx}";
|
|
46
|
+
|
|
43
47
|
@custom-variant dark (&:is(.dark *));
|
|
44
48
|
```
|
|
45
49
|
|
|
50
|
+
> **Note:** The `@source` path must point to `dist/` (not `src/`) and include all file extensions `{js,ts,jsx,tsx}`.
|
|
51
|
+
|
|
52
|
+
> **Important:** For Tailwind v4, you also need the `@theme inline` block to map CSS variables like `--background` to Tailwind utilities like `bg-background`. If you have shadcn/ui, this is already configured. Otherwise, see the [Quick Start guide](https://copilot-sdk.yourgpt.ai/docs/quickstart) for complete setup.
|
|
53
|
+
|
|
46
54
|
## Theming
|
|
47
55
|
|
|
48
56
|
Works automatically with existing shadcn/ui setup. For projects without shadcn:
|
|
@@ -1602,17 +1602,107 @@ function createSSEStream(generator) {
|
|
|
1602
1602
|
|
|
1603
1603
|
// src/core/utils/zod-to-json-schema.ts
|
|
1604
1604
|
function isZodSchema(value) {
|
|
1605
|
-
|
|
1605
|
+
if (value === null || typeof value !== "object") return false;
|
|
1606
|
+
const obj = value;
|
|
1607
|
+
return "_def" in obj && typeof obj._def === "object" || "_zod" in obj && typeof obj._zod === "object" || "~standard" in obj;
|
|
1606
1608
|
}
|
|
1607
1609
|
function getZodTypeName(schema) {
|
|
1608
1610
|
if (!isZodSchema(schema)) return "unknown";
|
|
1609
|
-
const
|
|
1610
|
-
|
|
1611
|
+
const obj = schema;
|
|
1612
|
+
if ("_zod" in obj) {
|
|
1613
|
+
const zod = obj._zod;
|
|
1614
|
+
if (zod.def && typeof zod.def === "object") {
|
|
1615
|
+
const def2 = zod.def;
|
|
1616
|
+
if (def2.type) return `Zod${capitalize(def2.type)}`;
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
if ("~standard" in obj) {
|
|
1620
|
+
const standard = obj["~standard"];
|
|
1621
|
+
if (standard.type === "object") return "ZodObject";
|
|
1622
|
+
if (standard.type === "string") return "ZodString";
|
|
1623
|
+
if (standard.type === "number") return "ZodNumber";
|
|
1624
|
+
if (standard.type === "boolean") return "ZodBoolean";
|
|
1625
|
+
if (standard.type === "array") return "ZodArray";
|
|
1626
|
+
}
|
|
1627
|
+
const def = obj._def;
|
|
1628
|
+
if (def?.typeName) return def.typeName;
|
|
1629
|
+
return "unknown";
|
|
1630
|
+
}
|
|
1631
|
+
function capitalize(str) {
|
|
1632
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1611
1633
|
}
|
|
1612
1634
|
function getZodDescription(schema) {
|
|
1613
1635
|
if (!isZodSchema(schema)) return void 0;
|
|
1614
|
-
const
|
|
1615
|
-
|
|
1636
|
+
const obj = schema;
|
|
1637
|
+
if ("_zod" in obj) {
|
|
1638
|
+
const zod = obj._zod;
|
|
1639
|
+
if (zod.def && typeof zod.def === "object") {
|
|
1640
|
+
const def2 = zod.def;
|
|
1641
|
+
if (def2.description) return def2.description;
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
const def = obj._def;
|
|
1645
|
+
return def?.description;
|
|
1646
|
+
}
|
|
1647
|
+
function getZodObjectShape(schema) {
|
|
1648
|
+
if (!isZodSchema(schema)) return null;
|
|
1649
|
+
const obj = schema;
|
|
1650
|
+
if ("shape" in obj && typeof obj.shape === "object" && obj.shape !== null) {
|
|
1651
|
+
return obj.shape;
|
|
1652
|
+
}
|
|
1653
|
+
if ("_zod" in obj) {
|
|
1654
|
+
const zod = obj._zod;
|
|
1655
|
+
if (zod.def && typeof zod.def === "object") {
|
|
1656
|
+
const def2 = zod.def;
|
|
1657
|
+
if (def2.shape && typeof def2.shape === "object") {
|
|
1658
|
+
return def2.shape;
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
const def = obj._def;
|
|
1663
|
+
if (def?.shape) {
|
|
1664
|
+
const shape = def.shape;
|
|
1665
|
+
if (typeof shape === "function") return shape();
|
|
1666
|
+
if (typeof shape === "object") return shape;
|
|
1667
|
+
}
|
|
1668
|
+
return null;
|
|
1669
|
+
}
|
|
1670
|
+
function getZodInnerType(schema) {
|
|
1671
|
+
if (!isZodSchema(schema)) return null;
|
|
1672
|
+
const obj = schema;
|
|
1673
|
+
if ("_zod" in obj) {
|
|
1674
|
+
const zod = obj._zod;
|
|
1675
|
+
if (zod.def && typeof zod.def === "object") {
|
|
1676
|
+
const def2 = zod.def;
|
|
1677
|
+
if (def2.innerType) return def2.innerType;
|
|
1678
|
+
if (def2.element) return def2.element;
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
const def = obj._def;
|
|
1682
|
+
if (def?.innerType) return def.innerType;
|
|
1683
|
+
if (def?.type) return def.type;
|
|
1684
|
+
return null;
|
|
1685
|
+
}
|
|
1686
|
+
function getZodEnumValues(schema) {
|
|
1687
|
+
if (!isZodSchema(schema)) return null;
|
|
1688
|
+
const obj = schema;
|
|
1689
|
+
if ("_zod" in obj) {
|
|
1690
|
+
const zod = obj._zod;
|
|
1691
|
+
if (zod.def && typeof zod.def === "object") {
|
|
1692
|
+
const def2 = zod.def;
|
|
1693
|
+
if (def2.entries && Array.isArray(def2.entries)) {
|
|
1694
|
+
return def2.entries;
|
|
1695
|
+
}
|
|
1696
|
+
if (def2.values && Array.isArray(def2.values)) {
|
|
1697
|
+
return def2.values;
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
const def = obj._def;
|
|
1702
|
+
if (def?.values && Array.isArray(def.values)) {
|
|
1703
|
+
return def.values;
|
|
1704
|
+
}
|
|
1705
|
+
return null;
|
|
1616
1706
|
}
|
|
1617
1707
|
function zodToJsonSchema(schema) {
|
|
1618
1708
|
if (!isZodSchema(schema)) {
|
|
@@ -1620,32 +1710,19 @@ function zodToJsonSchema(schema) {
|
|
|
1620
1710
|
}
|
|
1621
1711
|
const typeName = getZodTypeName(schema);
|
|
1622
1712
|
const description = getZodDescription(schema);
|
|
1623
|
-
const def = schema._def;
|
|
1624
1713
|
switch (typeName) {
|
|
1625
1714
|
case "ZodString": {
|
|
1626
1715
|
const result2 = { type: "string" };
|
|
1627
1716
|
if (description) result2.description = description;
|
|
1628
|
-
const checks = def.checks;
|
|
1629
|
-
if (checks) {
|
|
1630
|
-
for (const check of checks) {
|
|
1631
|
-
if (check.kind === "min") result2.minLength = check.value;
|
|
1632
|
-
if (check.kind === "max") result2.maxLength = check.value;
|
|
1633
|
-
if (check.kind === "regex") result2.pattern = String(check.value);
|
|
1634
|
-
}
|
|
1635
|
-
}
|
|
1636
1717
|
return result2;
|
|
1637
1718
|
}
|
|
1638
|
-
case "ZodNumber":
|
|
1639
|
-
|
|
1719
|
+
case "ZodNumber":
|
|
1720
|
+
case "ZodInt":
|
|
1721
|
+
case "ZodFloat": {
|
|
1722
|
+
const result2 = {
|
|
1723
|
+
type: typeName === "ZodInt" ? "integer" : "number"
|
|
1724
|
+
};
|
|
1640
1725
|
if (description) result2.description = description;
|
|
1641
|
-
const checks = def.checks;
|
|
1642
|
-
if (checks) {
|
|
1643
|
-
for (const check of checks) {
|
|
1644
|
-
if (check.kind === "min") result2.minimum = check.value;
|
|
1645
|
-
if (check.kind === "max") result2.maximum = check.value;
|
|
1646
|
-
if (check.kind === "int") result2.type = "integer";
|
|
1647
|
-
}
|
|
1648
|
-
}
|
|
1649
1726
|
return result2;
|
|
1650
1727
|
}
|
|
1651
1728
|
case "ZodBoolean": {
|
|
@@ -1654,26 +1731,31 @@ function zodToJsonSchema(schema) {
|
|
|
1654
1731
|
return result2;
|
|
1655
1732
|
}
|
|
1656
1733
|
case "ZodEnum": {
|
|
1657
|
-
const values =
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1734
|
+
const values = getZodEnumValues(schema);
|
|
1735
|
+
if (values && values.length > 0) {
|
|
1736
|
+
const result2 = {
|
|
1737
|
+
type: typeof values[0] === "number" ? "number" : "string",
|
|
1738
|
+
enum: values
|
|
1739
|
+
};
|
|
1740
|
+
if (description) result2.description = description;
|
|
1741
|
+
return result2;
|
|
1742
|
+
}
|
|
1743
|
+
return { type: "string", description };
|
|
1664
1744
|
}
|
|
1665
1745
|
case "ZodArray": {
|
|
1666
|
-
const innerType =
|
|
1746
|
+
const innerType = getZodInnerType(schema);
|
|
1667
1747
|
const result2 = {
|
|
1668
1748
|
type: "array",
|
|
1669
|
-
items: zodToJsonSchema(innerType)
|
|
1749
|
+
items: innerType ? zodToJsonSchema(innerType) : { type: "string" }
|
|
1670
1750
|
};
|
|
1671
1751
|
if (description) result2.description = description;
|
|
1672
1752
|
return result2;
|
|
1673
1753
|
}
|
|
1674
1754
|
case "ZodObject": {
|
|
1675
|
-
const
|
|
1676
|
-
|
|
1755
|
+
const shapeObj = getZodObjectShape(schema);
|
|
1756
|
+
if (!shapeObj) {
|
|
1757
|
+
return { type: "object", properties: {}, description };
|
|
1758
|
+
}
|
|
1677
1759
|
const properties = {};
|
|
1678
1760
|
const required = [];
|
|
1679
1761
|
for (const [key, value] of Object.entries(shapeObj)) {
|
|
@@ -1693,30 +1775,57 @@ function zodToJsonSchema(schema) {
|
|
|
1693
1775
|
}
|
|
1694
1776
|
case "ZodOptional":
|
|
1695
1777
|
case "ZodNullable": {
|
|
1696
|
-
const innerType =
|
|
1697
|
-
|
|
1778
|
+
const innerType = getZodInnerType(schema);
|
|
1779
|
+
if (innerType) {
|
|
1780
|
+
return zodToJsonSchema(innerType);
|
|
1781
|
+
}
|
|
1782
|
+
return { type: "string", description };
|
|
1698
1783
|
}
|
|
1699
1784
|
case "ZodDefault": {
|
|
1700
|
-
const innerType =
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1785
|
+
const innerType = getZodInnerType(schema);
|
|
1786
|
+
if (innerType) {
|
|
1787
|
+
const result2 = zodToJsonSchema(innerType);
|
|
1788
|
+
return result2;
|
|
1789
|
+
}
|
|
1790
|
+
return { type: "string", description };
|
|
1705
1791
|
}
|
|
1706
1792
|
case "ZodLiteral": {
|
|
1707
|
-
const
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1793
|
+
const obj = schema;
|
|
1794
|
+
let value;
|
|
1795
|
+
if ("_zod" in obj) {
|
|
1796
|
+
const zod = obj._zod;
|
|
1797
|
+
const def = zod.def;
|
|
1798
|
+
value = def?.value;
|
|
1799
|
+
}
|
|
1800
|
+
if (value === void 0) {
|
|
1801
|
+
const def = obj._def;
|
|
1802
|
+
value = def?.value;
|
|
1803
|
+
}
|
|
1804
|
+
if (value !== void 0) {
|
|
1805
|
+
return {
|
|
1806
|
+
type: typeof value === "number" ? "number" : typeof value === "boolean" ? "boolean" : "string",
|
|
1807
|
+
enum: [value],
|
|
1808
|
+
description
|
|
1809
|
+
};
|
|
1810
|
+
}
|
|
1811
|
+
return { type: "string", description };
|
|
1713
1812
|
}
|
|
1714
1813
|
case "ZodUnion": {
|
|
1715
|
-
const
|
|
1814
|
+
const obj = schema;
|
|
1815
|
+
let options;
|
|
1816
|
+
if ("_zod" in obj) {
|
|
1817
|
+
const zod = obj._zod;
|
|
1818
|
+
const def = zod.def;
|
|
1819
|
+
options = def?.options;
|
|
1820
|
+
}
|
|
1821
|
+
if (!options) {
|
|
1822
|
+
const def = obj._def;
|
|
1823
|
+
options = def?.options;
|
|
1824
|
+
}
|
|
1716
1825
|
if (options && options.length > 0) {
|
|
1717
1826
|
return zodToJsonSchema(options[0]);
|
|
1718
1827
|
}
|
|
1719
|
-
return { type: "string" };
|
|
1828
|
+
return { type: "string", description };
|
|
1720
1829
|
}
|
|
1721
1830
|
default:
|
|
1722
1831
|
const result = { type: "string" };
|
|
@@ -2842,5 +2951,5 @@ exports.toolToAnthropicFormat = toolToAnthropicFormat;
|
|
|
2842
2951
|
exports.toolToOpenAIFormat = toolToOpenAIFormat;
|
|
2843
2952
|
exports.zodObjectToInputSchema = zodObjectToInputSchema;
|
|
2844
2953
|
exports.zodToJsonSchema = zodToJsonSchema;
|
|
2845
|
-
//# sourceMappingURL=chunk-
|
|
2846
|
-
//# sourceMappingURL=chunk-
|
|
2954
|
+
//# sourceMappingURL=chunk-4PRWNAXQ.cjs.map
|
|
2955
|
+
//# sourceMappingURL=chunk-4PRWNAXQ.cjs.map
|