@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/LICENSE
CHANGED
package/dist/agent/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk6IQN5RQD_cjs = require('../chunk-6IQN5RQD.cjs');
|
|
4
4
|
var fs = require('fs');
|
|
5
5
|
var path = require('path');
|
|
6
6
|
|
|
@@ -1167,7 +1167,7 @@ var ClawOpsAgent = class {
|
|
|
1167
1167
|
constructor(options) {
|
|
1168
1168
|
this._apiKey = options.apiKey ?? process.env["CLAWOPS_API_KEY"] ?? "";
|
|
1169
1169
|
this._accountId = options.accountId ?? process.env["CLAWOPS_ACCOUNT_ID"] ?? "";
|
|
1170
|
-
this._baseUrl = options.baseUrl ??
|
|
1170
|
+
this._baseUrl = options.baseUrl ?? chunk6IQN5RQD_cjs.DEFAULT_BASE_URL;
|
|
1171
1171
|
this._fromNumber = options.from;
|
|
1172
1172
|
this._session = options.session;
|
|
1173
1173
|
this._recording = options.recording ?? false;
|
|
@@ -1187,7 +1187,7 @@ var ClawOpsAgent = class {
|
|
|
1187
1187
|
tool(nameOrTool, description, parameters, handler) {
|
|
1188
1188
|
if (typeof nameOrTool === "string") {
|
|
1189
1189
|
if (!description || !parameters || !handler) {
|
|
1190
|
-
throw new
|
|
1190
|
+
throw new chunk6IQN5RQD_cjs.AgentError("tool(name, description, parameters, handler) requires all arguments.");
|
|
1191
1191
|
}
|
|
1192
1192
|
this._tools.register({
|
|
1193
1193
|
name: nameOrTool,
|
|
@@ -1220,10 +1220,10 @@ var ClawOpsAgent = class {
|
|
|
1220
1220
|
/** Connect to the ClawOps platform and start listening for calls. */
|
|
1221
1221
|
async connect() {
|
|
1222
1222
|
if (!this._apiKey) {
|
|
1223
|
-
throw new
|
|
1223
|
+
throw new chunk6IQN5RQD_cjs.AgentError("API key is required. Set CLAWOPS_API_KEY or pass apiKey option.");
|
|
1224
1224
|
}
|
|
1225
1225
|
if (!this._accountId) {
|
|
1226
|
-
throw new
|
|
1226
|
+
throw new chunk6IQN5RQD_cjs.AgentError("Account ID is required. Set CLAWOPS_ACCOUNT_ID or pass accountId option.");
|
|
1227
1227
|
}
|
|
1228
1228
|
this._controlWs = new ControlWebSocket({
|
|
1229
1229
|
baseUrl: this._baseUrl,
|
|
@@ -1240,7 +1240,7 @@ var ClawOpsAgent = class {
|
|
|
1240
1240
|
await this._controlWs.connect();
|
|
1241
1241
|
await this._controlWs.waitConnected();
|
|
1242
1242
|
} catch (err) {
|
|
1243
|
-
throw new
|
|
1243
|
+
throw new chunk6IQN5RQD_cjs.AgentConnectionError(
|
|
1244
1244
|
`Failed to connect to ClawOps: ${err instanceof Error ? err.message : String(err)}`
|
|
1245
1245
|
);
|
|
1246
1246
|
}
|
|
@@ -1290,7 +1290,7 @@ var ClawOpsAgent = class {
|
|
|
1290
1290
|
});
|
|
1291
1291
|
if (resp.status !== 201) {
|
|
1292
1292
|
const error = await resp.json();
|
|
1293
|
-
throw new
|
|
1293
|
+
throw new chunk6IQN5RQD_cjs.AgentError(`\uBC1C\uC2E0 \uC2E4\uD328 (${resp.status}): ${error["error"] ?? ""}`);
|
|
1294
1294
|
}
|
|
1295
1295
|
const data = await resp.json();
|
|
1296
1296
|
const callSession = new CallSession({
|
|
@@ -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 }];
|