@teamlearners/clawops 0.3.0 → 0.4.0
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 +78 -8
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.js +72 -2
- package/dist/agent/index.js.map +1 -1
- package/dist/{chunk-JNSHMKDI.cjs → chunk-6IQN5RQD.cjs} +11 -2
- package/dist/chunk-6IQN5RQD.cjs.map +1 -0
- package/dist/{chunk-UKAT24I6.js → chunk-7S2OEBS6.js} +11 -3
- package/dist/chunk-7S2OEBS6.js.map +1 -0
- package/dist/index.cjs +36 -32
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-JNSHMKDI.cjs.map +0 -1
- package/dist/chunk-UKAT24I6.js.map +0 -1
package/dist/agent/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_BASE_URL, AgentError, AgentConnectionError } from '../chunk-
|
|
1
|
+
import { DEFAULT_BASE_URL, AgentError, AgentConnectionError } from '../chunk-7S2OEBS6.js';
|
|
2
2
|
import * as fs from 'fs';
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
|
|
@@ -1717,6 +1717,74 @@ var HANG_UP_TOOL2 = {
|
|
|
1717
1717
|
description: "End the phone call. Use when the conversation is finished or the caller says goodbye.",
|
|
1718
1718
|
parameters: { type: "object", properties: {} }
|
|
1719
1719
|
};
|
|
1720
|
+
function resolveRef(ref, defs) {
|
|
1721
|
+
const parts = ref.replace(/^#\//, "").split("/");
|
|
1722
|
+
let result = defs;
|
|
1723
|
+
for (const part of parts) {
|
|
1724
|
+
if (result && typeof result === "object" && !Array.isArray(result)) {
|
|
1725
|
+
result = result[part];
|
|
1726
|
+
} else {
|
|
1727
|
+
return {};
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
return typeof result === "object" && result !== null && !Array.isArray(result) ? result : {};
|
|
1731
|
+
}
|
|
1732
|
+
function sanitizeSchemaForGemini(schema, defs, depth = 0) {
|
|
1733
|
+
if (depth > 15) return { type: "object", properties: {} };
|
|
1734
|
+
if (!schema || typeof schema !== "object") return { type: "object", properties: {} };
|
|
1735
|
+
if (defs === void 0) {
|
|
1736
|
+
defs = schema["$defs"] ?? schema["definitions"] ?? {};
|
|
1737
|
+
}
|
|
1738
|
+
if (typeof schema["$ref"] === "string") {
|
|
1739
|
+
const resolved = resolveRef(schema["$ref"], { $defs: defs, definitions: defs });
|
|
1740
|
+
if (resolved && Object.keys(resolved).length > 0) {
|
|
1741
|
+
return sanitizeSchemaForGemini(resolved, defs, depth + 1);
|
|
1742
|
+
}
|
|
1743
|
+
return { type: "object", properties: {} };
|
|
1744
|
+
}
|
|
1745
|
+
for (const comboKey of ["oneOf", "anyOf", "allOf"]) {
|
|
1746
|
+
const variants = schema[comboKey];
|
|
1747
|
+
if (Array.isArray(variants) && variants.length > 0) {
|
|
1748
|
+
for (const v of variants) {
|
|
1749
|
+
if (v && typeof v === "object") {
|
|
1750
|
+
const resolved = sanitizeSchemaForGemini(v, defs, depth + 1);
|
|
1751
|
+
if (resolved["type"] === "object" && resolved["properties"]) {
|
|
1752
|
+
return resolved;
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
const first = variants[0];
|
|
1757
|
+
if (first && typeof first === "object") {
|
|
1758
|
+
return sanitizeSchemaForGemini(first, defs, depth + 1);
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
const result = {};
|
|
1763
|
+
let schemaType = schema["type"];
|
|
1764
|
+
if (Array.isArray(schemaType)) {
|
|
1765
|
+
const nonNull = schemaType.filter((t) => t !== "null");
|
|
1766
|
+
schemaType = nonNull[0] ?? "string";
|
|
1767
|
+
}
|
|
1768
|
+
if (schemaType) result["type"] = schemaType;
|
|
1769
|
+
if (schema["description"]) result["description"] = schema["description"];
|
|
1770
|
+
if (schema["enum"]) result["enum"] = schema["enum"];
|
|
1771
|
+
if (schema["required"]) result["required"] = schema["required"];
|
|
1772
|
+
if (schema["properties"] && typeof schema["properties"] === "object") {
|
|
1773
|
+
const props = {};
|
|
1774
|
+
for (const [key, val] of Object.entries(schema["properties"])) {
|
|
1775
|
+
if (val && typeof val === "object") {
|
|
1776
|
+
props[key] = sanitizeSchemaForGemini(val, defs, depth + 1);
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
result["properties"] = props;
|
|
1780
|
+
}
|
|
1781
|
+
if (schema["items"] && typeof schema["items"] === "object" && !Array.isArray(schema["items"])) {
|
|
1782
|
+
result["items"] = sanitizeSchemaForGemini(schema["items"], defs, depth + 1);
|
|
1783
|
+
}
|
|
1784
|
+
if (!result["type"] && result["properties"]) result["type"] = "object";
|
|
1785
|
+
if (result["type"] === "object" && !result["properties"]) result["properties"] = {};
|
|
1786
|
+
return result;
|
|
1787
|
+
}
|
|
1720
1788
|
var GeminiRealtime = class {
|
|
1721
1789
|
_apiKey;
|
|
1722
1790
|
_systemPrompt;
|
|
@@ -1838,7 +1906,9 @@ var GeminiRealtime = class {
|
|
|
1838
1906
|
const toolDefs = this._tools ? this._tools.toOpenAITools().map((t) => ({
|
|
1839
1907
|
name: t.function.name,
|
|
1840
1908
|
description: t.function.description,
|
|
1841
|
-
parameters:
|
|
1909
|
+
parameters: sanitizeSchemaForGemini(
|
|
1910
|
+
t.function.parameters ?? { type: "object", properties: {} }
|
|
1911
|
+
)
|
|
1842
1912
|
})) : [];
|
|
1843
1913
|
toolDefs.push(HANG_UP_TOOL2);
|
|
1844
1914
|
setupConfig["tools"] = [{ functionDeclarations: toolDefs }];
|