@teamlearners/clawops 0.3.0 → 0.3.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/LICENSE +1 -1
- package/dist/agent/index.cjs +71 -1
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.js +71 -1
- package/dist/agent/index.js.map +1 -1
- package/package.json +1 -1
package/LICENSE
CHANGED
package/dist/agent/index.cjs
CHANGED
|
@@ -1740,6 +1740,74 @@ var HANG_UP_TOOL2 = {
|
|
|
1740
1740
|
description: "End the phone call. Use when the conversation is finished or the caller says goodbye.",
|
|
1741
1741
|
parameters: { type: "object", properties: {} }
|
|
1742
1742
|
};
|
|
1743
|
+
function resolveRef(ref, defs) {
|
|
1744
|
+
const parts = ref.replace(/^#\//, "").split("/");
|
|
1745
|
+
let result = defs;
|
|
1746
|
+
for (const part of parts) {
|
|
1747
|
+
if (result && typeof result === "object" && !Array.isArray(result)) {
|
|
1748
|
+
result = result[part];
|
|
1749
|
+
} else {
|
|
1750
|
+
return {};
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
return typeof result === "object" && result !== null && !Array.isArray(result) ? result : {};
|
|
1754
|
+
}
|
|
1755
|
+
function sanitizeSchemaForGemini(schema, defs, depth = 0) {
|
|
1756
|
+
if (depth > 15) return { type: "object", properties: {} };
|
|
1757
|
+
if (!schema || typeof schema !== "object") return { type: "object", properties: {} };
|
|
1758
|
+
if (defs === void 0) {
|
|
1759
|
+
defs = schema["$defs"] ?? schema["definitions"] ?? {};
|
|
1760
|
+
}
|
|
1761
|
+
if (typeof schema["$ref"] === "string") {
|
|
1762
|
+
const resolved = resolveRef(schema["$ref"], { $defs: defs, definitions: defs });
|
|
1763
|
+
if (resolved && Object.keys(resolved).length > 0) {
|
|
1764
|
+
return sanitizeSchemaForGemini(resolved, defs, depth + 1);
|
|
1765
|
+
}
|
|
1766
|
+
return { type: "object", properties: {} };
|
|
1767
|
+
}
|
|
1768
|
+
for (const comboKey of ["oneOf", "anyOf", "allOf"]) {
|
|
1769
|
+
const variants = schema[comboKey];
|
|
1770
|
+
if (Array.isArray(variants) && variants.length > 0) {
|
|
1771
|
+
for (const v of variants) {
|
|
1772
|
+
if (v && typeof v === "object") {
|
|
1773
|
+
const resolved = sanitizeSchemaForGemini(v, defs, depth + 1);
|
|
1774
|
+
if (resolved["type"] === "object" && resolved["properties"]) {
|
|
1775
|
+
return resolved;
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
const first = variants[0];
|
|
1780
|
+
if (first && typeof first === "object") {
|
|
1781
|
+
return sanitizeSchemaForGemini(first, defs, depth + 1);
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
const result = {};
|
|
1786
|
+
let schemaType = schema["type"];
|
|
1787
|
+
if (Array.isArray(schemaType)) {
|
|
1788
|
+
const nonNull = schemaType.filter((t) => t !== "null");
|
|
1789
|
+
schemaType = nonNull[0] ?? "string";
|
|
1790
|
+
}
|
|
1791
|
+
if (schemaType) result["type"] = schemaType;
|
|
1792
|
+
if (schema["description"]) result["description"] = schema["description"];
|
|
1793
|
+
if (schema["enum"]) result["enum"] = schema["enum"];
|
|
1794
|
+
if (schema["required"]) result["required"] = schema["required"];
|
|
1795
|
+
if (schema["properties"] && typeof schema["properties"] === "object") {
|
|
1796
|
+
const props = {};
|
|
1797
|
+
for (const [key, val] of Object.entries(schema["properties"])) {
|
|
1798
|
+
if (val && typeof val === "object") {
|
|
1799
|
+
props[key] = sanitizeSchemaForGemini(val, defs, depth + 1);
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
result["properties"] = props;
|
|
1803
|
+
}
|
|
1804
|
+
if (schema["items"] && typeof schema["items"] === "object" && !Array.isArray(schema["items"])) {
|
|
1805
|
+
result["items"] = sanitizeSchemaForGemini(schema["items"], defs, depth + 1);
|
|
1806
|
+
}
|
|
1807
|
+
if (!result["type"] && result["properties"]) result["type"] = "object";
|
|
1808
|
+
if (result["type"] === "object" && !result["properties"]) result["properties"] = {};
|
|
1809
|
+
return result;
|
|
1810
|
+
}
|
|
1743
1811
|
var GeminiRealtime = class {
|
|
1744
1812
|
_apiKey;
|
|
1745
1813
|
_systemPrompt;
|
|
@@ -1861,7 +1929,9 @@ var GeminiRealtime = class {
|
|
|
1861
1929
|
const toolDefs = this._tools ? this._tools.toOpenAITools().map((t) => ({
|
|
1862
1930
|
name: t.function.name,
|
|
1863
1931
|
description: t.function.description,
|
|
1864
|
-
parameters:
|
|
1932
|
+
parameters: sanitizeSchemaForGemini(
|
|
1933
|
+
t.function.parameters ?? { type: "object", properties: {} }
|
|
1934
|
+
)
|
|
1865
1935
|
})) : [];
|
|
1866
1936
|
toolDefs.push(HANG_UP_TOOL2);
|
|
1867
1937
|
setupConfig["tools"] = [{ functionDeclarations: toolDefs }];
|