@teamlearners/clawops 0.37.0 → 0.38.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/dist/agent/index.cjs +70 -70
- package/dist/agent/index.js +3 -3
- package/dist/agent/livekit/index.cjs +9 -9
- package/dist/agent/livekit/index.js +2 -2
- package/dist/{chunk-7TEOYLZI.cjs → chunk-ASQU6NA2.cjs} +4 -4
- package/dist/{chunk-7TEOYLZI.cjs.map → chunk-ASQU6NA2.cjs.map} +1 -1
- package/dist/{chunk-2OGQSWTW.js → chunk-EO25KTL4.js} +3 -3
- package/dist/{chunk-2OGQSWTW.js.map → chunk-EO25KTL4.js.map} +1 -1
- package/dist/chunk-J7UIB4EA.js +6 -0
- package/dist/{chunk-CKPVV6SZ.js.map → chunk-J7UIB4EA.js.map} +1 -1
- package/dist/chunk-NXCYAYFT.cjs +8 -0
- package/dist/{chunk-EYI3ULDU.cjs.map → chunk-NXCYAYFT.cjs.map} +1 -1
- package/dist/{client-DKsEma11.d.cts → client-ZOgpzAPe.d.cts} +124 -24
- package/dist/{client-DKsEma11.d.ts → client-ZOgpzAPe.d.ts} +124 -24
- package/dist/index.cjs +26 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +25 -8
- package/dist/index.js.map +1 -1
- package/dist/solapi/index.d.cts +2 -2
- package/dist/solapi/index.d.ts +2 -2
- package/package.json +1 -1
- package/dist/chunk-CKPVV6SZ.js +0 -6
- package/dist/chunk-EYI3ULDU.cjs +0 -8
package/dist/agent/index.cjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var chunkLLPMUDNE_cjs = require('../chunk-LLPMUDNE.cjs');
|
|
4
4
|
var chunkIYSPOOKH_cjs = require('../chunk-IYSPOOKH.cjs');
|
|
5
|
-
var
|
|
6
|
-
require('../chunk-
|
|
5
|
+
var chunkASQU6NA2_cjs = require('../chunk-ASQU6NA2.cjs');
|
|
6
|
+
require('../chunk-NXCYAYFT.cjs');
|
|
7
7
|
var fs = require('fs');
|
|
8
8
|
var path = require('path');
|
|
9
9
|
|
|
@@ -57,7 +57,7 @@ var ControlWebSocket = class {
|
|
|
57
57
|
_closed = false;
|
|
58
58
|
_connectedResolve = null;
|
|
59
59
|
_connectedPromise;
|
|
60
|
-
_log =
|
|
60
|
+
_log = chunkASQU6NA2_cjs.NOOP_LOGGER;
|
|
61
61
|
_pingTimer = null;
|
|
62
62
|
setLogger(logger) {
|
|
63
63
|
this._log = logger;
|
|
@@ -222,7 +222,7 @@ var ControlWebSocket = class {
|
|
|
222
222
|
var MCPClient = class {
|
|
223
223
|
_servers = /* @__PURE__ */ new Map();
|
|
224
224
|
_clients = /* @__PURE__ */ new Map();
|
|
225
|
-
_log =
|
|
225
|
+
_log = chunkASQU6NA2_cjs.NOOP_LOGGER;
|
|
226
226
|
setLogger(logger) {
|
|
227
227
|
this._log = logger;
|
|
228
228
|
}
|
|
@@ -364,7 +364,7 @@ var MediaWebSocket = class {
|
|
|
364
364
|
_onClose = null;
|
|
365
365
|
_onDtmf = null;
|
|
366
366
|
_markWaiters = /* @__PURE__ */ new Map();
|
|
367
|
-
_log =
|
|
367
|
+
_log = chunkASQU6NA2_cjs.NOOP_LOGGER;
|
|
368
368
|
setLogger(logger) {
|
|
369
369
|
this._log = logger;
|
|
370
370
|
}
|
|
@@ -590,7 +590,7 @@ var AudioRecorder = class {
|
|
|
590
590
|
_started = false;
|
|
591
591
|
_baseTs = null;
|
|
592
592
|
_outCursor = 0;
|
|
593
|
-
_log =
|
|
593
|
+
_log = chunkASQU6NA2_cjs.NOOP_LOGGER;
|
|
594
594
|
setLogger(logger) {
|
|
595
595
|
this._log = logger;
|
|
596
596
|
}
|
|
@@ -805,7 +805,7 @@ function generateComfortTone(volume = 0.12) {
|
|
|
805
805
|
}
|
|
806
806
|
}
|
|
807
807
|
const pcm = int16ArrayToBuffer(concatInt16Arrays(...parts));
|
|
808
|
-
const ulaw =
|
|
808
|
+
const ulaw = chunkASQU6NA2_cjs.pcm16ToUlaw(pcm);
|
|
809
809
|
const chunks = [];
|
|
810
810
|
for (let i = 0; i < ulaw.length; i += CHUNK_SIZE) {
|
|
811
811
|
chunks.push(ulaw.subarray(i, i + CHUNK_SIZE));
|
|
@@ -862,9 +862,9 @@ function loadHoldAudio(source) {
|
|
|
862
862
|
pcmData = mono;
|
|
863
863
|
}
|
|
864
864
|
if (sampleRate !== SAMPLE_RATE2) {
|
|
865
|
-
pcmData =
|
|
865
|
+
pcmData = chunkASQU6NA2_cjs.resamplePcm16(pcmData, sampleRate, SAMPLE_RATE2);
|
|
866
866
|
}
|
|
867
|
-
const ulaw =
|
|
867
|
+
const ulaw = chunkASQU6NA2_cjs.pcm16ToUlaw(pcmData);
|
|
868
868
|
const chunks = [];
|
|
869
869
|
for (let i = 0; i < ulaw.length; i += CHUNK_SIZE) {
|
|
870
870
|
chunks.push(ulaw.subarray(i, i + CHUNK_SIZE));
|
|
@@ -1142,7 +1142,7 @@ var ClawOpsAgent = class _ClawOpsAgent {
|
|
|
1142
1142
|
this._recording = options.recording ?? false;
|
|
1143
1143
|
this._recordingPath = options.recordingPath ?? "./recordings";
|
|
1144
1144
|
this._mcpServers = options.mcpServers ?? [];
|
|
1145
|
-
this._builtinTools =
|
|
1145
|
+
this._builtinTools = chunkASQU6NA2_cjs.resolveBuiltinTools(options.builtinTools ?? "all" /* ALL */);
|
|
1146
1146
|
this._passiveDtmfDebounceMs = options.passiveDtmfDebounceMs ?? 500;
|
|
1147
1147
|
this._rxGain = _ClawOpsAgent._validateGain("rxGain", options.rxGain ?? 1);
|
|
1148
1148
|
this._txGain = _ClawOpsAgent._validateGain("txGain", options.txGain ?? 1);
|
|
@@ -1151,8 +1151,8 @@ var ClawOpsAgent = class _ClawOpsAgent {
|
|
|
1151
1151
|
if (options.tracing) {
|
|
1152
1152
|
setTracingConfig(options.tracing);
|
|
1153
1153
|
}
|
|
1154
|
-
this._log =
|
|
1155
|
-
this._pipelineLog =
|
|
1154
|
+
this._log = chunkASQU6NA2_cjs.createAgentLogger(options.logger);
|
|
1155
|
+
this._pipelineLog = chunkASQU6NA2_cjs.createPipelineLogger(this._log);
|
|
1156
1156
|
this._isPipelineSession = "_stt" in this._session && "_llm" in this._session;
|
|
1157
1157
|
if (options.toolConfig?.holdAudio) {
|
|
1158
1158
|
this._holdAudioChunks = loadHoldAudio(options.toolConfig.holdAudio);
|
|
@@ -1233,7 +1233,7 @@ var ClawOpsAgent = class _ClawOpsAgent {
|
|
|
1233
1233
|
await this._controlWs.connect();
|
|
1234
1234
|
await this._controlWs.waitConnected();
|
|
1235
1235
|
try {
|
|
1236
|
-
this._controlWs.send({ event: "agent.hello", sdk:
|
|
1236
|
+
this._controlWs.send({ event: "agent.hello", sdk: chunkASQU6NA2_cjs.getSdkInfo() });
|
|
1237
1237
|
} catch {
|
|
1238
1238
|
}
|
|
1239
1239
|
} catch (err) {
|
|
@@ -1305,7 +1305,7 @@ var ClawOpsAgent = class _ClawOpsAgent {
|
|
|
1305
1305
|
throw new chunkIYSPOOKH_cjs.AgentError(`\uBC1C\uC2E0 \uC2E4\uD328 (${resp.status}): ${error["error"] ?? ""}`);
|
|
1306
1306
|
}
|
|
1307
1307
|
const data = await resp.json();
|
|
1308
|
-
const callSession = new
|
|
1308
|
+
const callSession = new chunkASQU6NA2_cjs.CallSession({
|
|
1309
1309
|
callId: data["callId"],
|
|
1310
1310
|
fromNumber: this._fromNumber,
|
|
1311
1311
|
toNumber: to,
|
|
@@ -1329,7 +1329,7 @@ var ClawOpsAgent = class _ClawOpsAgent {
|
|
|
1329
1329
|
const callId = event["callId"];
|
|
1330
1330
|
const fromNumber = event["from"] ?? "";
|
|
1331
1331
|
const mediaUrl = event["mediaUrl"] ?? "";
|
|
1332
|
-
const session = new
|
|
1332
|
+
const session = new chunkASQU6NA2_cjs.CallSession({
|
|
1333
1333
|
callId,
|
|
1334
1334
|
fromNumber,
|
|
1335
1335
|
toNumber: this._fromNumber,
|
|
@@ -1430,7 +1430,7 @@ var ClawOpsAgent = class _ClawOpsAgent {
|
|
|
1430
1430
|
const mediaUrl = event["mediaUrl"] ?? "";
|
|
1431
1431
|
let session = this._activeSessions.get(callId);
|
|
1432
1432
|
if (!session) {
|
|
1433
|
-
session = new
|
|
1433
|
+
session = new chunkASQU6NA2_cjs.CallSession({
|
|
1434
1434
|
callId,
|
|
1435
1435
|
fromNumber: this._fromNumber,
|
|
1436
1436
|
toNumber: event["to"] ?? "",
|
|
@@ -1632,9 +1632,9 @@ var ClawOpsAgent = class _ClawOpsAgent {
|
|
|
1632
1632
|
let latestMediaTs = 0;
|
|
1633
1633
|
session._bindTransport(
|
|
1634
1634
|
(audio) => {
|
|
1635
|
-
const gained =
|
|
1635
|
+
const gained = chunkASQU6NA2_cjs.applyUlawGain(audio, this._txGain);
|
|
1636
1636
|
if (recorder) {
|
|
1637
|
-
recorder.writeOutbound(
|
|
1637
|
+
recorder.writeOutbound(chunkASQU6NA2_cjs.ulawToPcm16(gained), latestMediaTs);
|
|
1638
1638
|
}
|
|
1639
1639
|
mediaWs.sendAudio(gained.toString("base64"));
|
|
1640
1640
|
session.recordFirstResponse();
|
|
@@ -1664,9 +1664,9 @@ var ClawOpsAgent = class _ClawOpsAgent {
|
|
|
1664
1664
|
this._callSessions.set(session.callId, sessionHandler);
|
|
1665
1665
|
mediaWs.onAudio((ulawAudio, timestamp) => {
|
|
1666
1666
|
latestMediaTs = timestamp;
|
|
1667
|
-
const gained =
|
|
1667
|
+
const gained = chunkASQU6NA2_cjs.applyUlawGain(ulawAudio, this._rxGain);
|
|
1668
1668
|
if (recorder) {
|
|
1669
|
-
recorder.writeInbound(
|
|
1669
|
+
recorder.writeInbound(chunkASQU6NA2_cjs.ulawToPcm16(gained), timestamp);
|
|
1670
1670
|
}
|
|
1671
1671
|
if (sessionHandler) {
|
|
1672
1672
|
sessionHandler.feedAudio(gained, timestamp);
|
|
@@ -1782,7 +1782,7 @@ var PipelineSession = class {
|
|
|
1782
1782
|
_speaking = false;
|
|
1783
1783
|
_builtinTools = null;
|
|
1784
1784
|
_holdAudioChunks = null;
|
|
1785
|
-
_log =
|
|
1785
|
+
_log = chunkASQU6NA2_cjs.NOOP_LOGGER;
|
|
1786
1786
|
constructor(options) {
|
|
1787
1787
|
this._stt = options.stt;
|
|
1788
1788
|
this._llm = options.llm;
|
|
@@ -1844,7 +1844,7 @@ var PipelineSession = class {
|
|
|
1844
1844
|
*/
|
|
1845
1845
|
async prewarm(tools) {
|
|
1846
1846
|
if (tools) this._tools = tools;
|
|
1847
|
-
this._callSession = new
|
|
1847
|
+
this._callSession = new chunkASQU6NA2_cjs.BufferingCall();
|
|
1848
1848
|
this._running = true;
|
|
1849
1849
|
this._conversation = [];
|
|
1850
1850
|
this._log.info("PipelineSession prewarmed");
|
|
@@ -1867,7 +1867,7 @@ var PipelineSession = class {
|
|
|
1867
1867
|
async attach(callSession) {
|
|
1868
1868
|
const prev = this._callSession;
|
|
1869
1869
|
this._callSession = callSession;
|
|
1870
|
-
|
|
1870
|
+
chunkASQU6NA2_cjs.attachBuffered(prev, callSession);
|
|
1871
1871
|
}
|
|
1872
1872
|
async start(callSession, tools) {
|
|
1873
1873
|
this._tools = tools ?? null;
|
|
@@ -1914,8 +1914,8 @@ var PipelineSession = class {
|
|
|
1914
1914
|
while (this._running) {
|
|
1915
1915
|
if (this._audioBuffer.length > 0) {
|
|
1916
1916
|
const ulaw = this._audioBuffer.shift();
|
|
1917
|
-
const pcm8k =
|
|
1918
|
-
const pcm16k =
|
|
1917
|
+
const pcm8k = chunkASQU6NA2_cjs.ulawToPcm16(ulaw);
|
|
1918
|
+
const pcm16k = chunkASQU6NA2_cjs.resamplePcm16(pcm8k, 8e3, 16e3);
|
|
1919
1919
|
yield pcm16k;
|
|
1920
1920
|
} else {
|
|
1921
1921
|
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
@@ -1931,7 +1931,7 @@ var PipelineSession = class {
|
|
|
1931
1931
|
await this._respond();
|
|
1932
1932
|
}
|
|
1933
1933
|
_buildEffectiveTools() {
|
|
1934
|
-
const builtinSchemas =
|
|
1934
|
+
const builtinSchemas = chunkASQU6NA2_cjs.getBuiltinToolSchemas(this._builtinTools, "chat");
|
|
1935
1935
|
const dtmfSchemas = builtinSchemas.filter((s) => {
|
|
1936
1936
|
const name = s["function"]?.["name"];
|
|
1937
1937
|
return name === "collect_dtmf" || name === "send_dtmf";
|
|
@@ -1980,8 +1980,8 @@ var PipelineSession = class {
|
|
|
1980
1980
|
const { id, name, arguments: argsStr } = chunk.toolCall;
|
|
1981
1981
|
try {
|
|
1982
1982
|
const args = JSON.parse(argsStr);
|
|
1983
|
-
if (
|
|
1984
|
-
const result2 = await
|
|
1983
|
+
if (chunkASQU6NA2_cjs.BUILTIN_TOOL_NAMES.has(name) && this._callSession && !(this._callSession instanceof chunkASQU6NA2_cjs.BufferingCall)) {
|
|
1984
|
+
const result2 = await chunkASQU6NA2_cjs.executeBuiltinTool(name, args, this._callSession);
|
|
1985
1985
|
if (result2 !== null) {
|
|
1986
1986
|
if (name === "hang_up") return;
|
|
1987
1987
|
this._conversation.push({ role: "tool", content: result2, tool_call_id: id, name });
|
|
@@ -1989,11 +1989,11 @@ var PipelineSession = class {
|
|
|
1989
1989
|
return;
|
|
1990
1990
|
}
|
|
1991
1991
|
}
|
|
1992
|
-
if (
|
|
1992
|
+
if (chunkASQU6NA2_cjs.BUILTIN_TOOL_NAMES.has(name) && this._callSession instanceof chunkASQU6NA2_cjs.BufferingCall) {
|
|
1993
1993
|
this._log.warn("Builtin tool %s called before answer \u2014 deferring", name);
|
|
1994
1994
|
this._conversation.push({
|
|
1995
1995
|
role: "tool",
|
|
1996
|
-
content:
|
|
1996
|
+
content: chunkASQU6NA2_cjs.CALL_NOT_READY_RESULT,
|
|
1997
1997
|
tool_call_id: id,
|
|
1998
1998
|
name
|
|
1999
1999
|
});
|
|
@@ -2002,7 +2002,7 @@ var PipelineSession = class {
|
|
|
2002
2002
|
}
|
|
2003
2003
|
if (!this._tools) return;
|
|
2004
2004
|
this._callSession?.recordToolCall();
|
|
2005
|
-
const player = this._holdAudioChunks && this._callSession && !(this._callSession instanceof
|
|
2005
|
+
const player = this._holdAudioChunks && this._callSession && !(this._callSession instanceof chunkASQU6NA2_cjs.BufferingCall) ? new HoldAudioPlayer(this._callSession, this._holdAudioChunks) : null;
|
|
2006
2006
|
player?.start();
|
|
2007
2007
|
let result;
|
|
2008
2008
|
try {
|
|
@@ -2053,8 +2053,8 @@ var PipelineSession = class {
|
|
|
2053
2053
|
sampleRate: this._sampleRate
|
|
2054
2054
|
})) {
|
|
2055
2055
|
if (!this._running || !this._speaking) break;
|
|
2056
|
-
const pcm8k =
|
|
2057
|
-
const ulaw =
|
|
2056
|
+
const pcm8k = chunkASQU6NA2_cjs.resamplePcm16(audioChunk, this._sampleRate, 8e3);
|
|
2057
|
+
const ulaw = chunkASQU6NA2_cjs.pcm16ToUlaw(pcm8k);
|
|
2058
2058
|
for (let off = 0; off < ulaw.length; off += 160) {
|
|
2059
2059
|
let chunk = ulaw.subarray(off, off + 160);
|
|
2060
2060
|
if (chunk.length < 160) {
|
|
@@ -2081,7 +2081,7 @@ var OpenAIRealtime = class {
|
|
|
2081
2081
|
_language;
|
|
2082
2082
|
_turnDetection;
|
|
2083
2083
|
_greeting;
|
|
2084
|
-
_log =
|
|
2084
|
+
_log = chunkASQU6NA2_cjs.NOOP_LOGGER;
|
|
2085
2085
|
_builtinTools = null;
|
|
2086
2086
|
/**
|
|
2087
2087
|
* 마지막 session.update 로 LLM 에 알린 tool 이름들. attach() 가 이 값과 현재
|
|
@@ -2158,7 +2158,7 @@ var OpenAIRealtime = class {
|
|
|
2158
2158
|
/** Open WS + session.update + (optional) response.create without a CallSession. */
|
|
2159
2159
|
async prewarm(tools) {
|
|
2160
2160
|
if (tools) this._tools = tools;
|
|
2161
|
-
this._call = new
|
|
2161
|
+
this._call = new chunkASQU6NA2_cjs.BufferingCall();
|
|
2162
2162
|
this._closed = false;
|
|
2163
2163
|
this._playback = null;
|
|
2164
2164
|
this._latestMediaTs = 0;
|
|
@@ -2200,7 +2200,7 @@ var OpenAIRealtime = class {
|
|
|
2200
2200
|
this._resyncTools();
|
|
2201
2201
|
const prev = this._call;
|
|
2202
2202
|
this._call = callSession;
|
|
2203
|
-
|
|
2203
|
+
chunkASQU6NA2_cjs.attachBuffered(prev, callSession);
|
|
2204
2204
|
}
|
|
2205
2205
|
async start(callSession, tools) {
|
|
2206
2206
|
if (tools) this._tools = tools;
|
|
@@ -2261,7 +2261,7 @@ var OpenAIRealtime = class {
|
|
|
2261
2261
|
/** Current tool schemas: user tools + builtin tools (flat realtime format). */
|
|
2262
2262
|
_currentToolSchemas() {
|
|
2263
2263
|
const toolSchemas = this._tools ? this._tools.toOpenAITools().map((t) => ({ type: "function", ...t.function })) : [];
|
|
2264
|
-
toolSchemas.push(...
|
|
2264
|
+
toolSchemas.push(...chunkASQU6NA2_cjs.getBuiltinToolSchemas(this._builtinTools, "realtime"));
|
|
2265
2265
|
return toolSchemas;
|
|
2266
2266
|
}
|
|
2267
2267
|
/**
|
|
@@ -2432,9 +2432,9 @@ var OpenAIRealtime = class {
|
|
|
2432
2432
|
const controller = new AbortController();
|
|
2433
2433
|
this._pendingToolCalls.set(callId, controller);
|
|
2434
2434
|
try {
|
|
2435
|
-
if (
|
|
2435
|
+
if (chunkASQU6NA2_cjs.BUILTIN_TOOL_NAMES.has(funcName) && this._call && !(this._call instanceof chunkASQU6NA2_cjs.BufferingCall)) {
|
|
2436
2436
|
const args = JSON.parse(item["arguments"] ?? "{}");
|
|
2437
|
-
const result2 = await
|
|
2437
|
+
const result2 = await chunkASQU6NA2_cjs.executeBuiltinTool(funcName, args, this._call);
|
|
2438
2438
|
if (result2 !== null) {
|
|
2439
2439
|
if (funcName === "hang_up") return;
|
|
2440
2440
|
if (controller.signal.aborted) return;
|
|
@@ -2451,7 +2451,7 @@ var OpenAIRealtime = class {
|
|
|
2451
2451
|
return;
|
|
2452
2452
|
}
|
|
2453
2453
|
}
|
|
2454
|
-
if (
|
|
2454
|
+
if (chunkASQU6NA2_cjs.BUILTIN_TOOL_NAMES.has(funcName) && this._call instanceof chunkASQU6NA2_cjs.BufferingCall) {
|
|
2455
2455
|
this._log.warn("Builtin tool %s called before answer \u2014 deferring", funcName);
|
|
2456
2456
|
await this._waitForResponseDone();
|
|
2457
2457
|
this._send({
|
|
@@ -2459,7 +2459,7 @@ var OpenAIRealtime = class {
|
|
|
2459
2459
|
item: {
|
|
2460
2460
|
type: "function_call_output",
|
|
2461
2461
|
call_id: callId,
|
|
2462
|
-
output:
|
|
2462
|
+
output: chunkASQU6NA2_cjs.CALL_NOT_READY_RESULT
|
|
2463
2463
|
}
|
|
2464
2464
|
});
|
|
2465
2465
|
this._send({ type: "response.create" });
|
|
@@ -2480,7 +2480,7 @@ var OpenAIRealtime = class {
|
|
|
2480
2480
|
return;
|
|
2481
2481
|
}
|
|
2482
2482
|
let result;
|
|
2483
|
-
const player = this._holdAudioChunks && this._call && !(this._call instanceof
|
|
2483
|
+
const player = this._holdAudioChunks && this._call && !(this._call instanceof chunkASQU6NA2_cjs.BufferingCall) ? new HoldAudioPlayer(this._call, this._holdAudioChunks) : null;
|
|
2484
2484
|
player?.start();
|
|
2485
2485
|
try {
|
|
2486
2486
|
const args = JSON.parse(item["arguments"] ?? "{}");
|
|
@@ -2629,7 +2629,7 @@ var GeminiRealtime = class _GeminiRealtime {
|
|
|
2629
2629
|
_toolDrainTimer = null;
|
|
2630
2630
|
_lastAudioTime = 0;
|
|
2631
2631
|
_holdAudioChunks = null;
|
|
2632
|
-
_log =
|
|
2632
|
+
_log = chunkASQU6NA2_cjs.NOOP_LOGGER;
|
|
2633
2633
|
constructor(options = {}) {
|
|
2634
2634
|
this._apiKey = options.apiKey ?? process.env["GOOGLE_API_KEY"] ?? "";
|
|
2635
2635
|
this._systemPrompt = options.systemPrompt ?? "";
|
|
@@ -2675,7 +2675,7 @@ var GeminiRealtime = class _GeminiRealtime {
|
|
|
2675
2675
|
/** Open Live session (no CallSession). Audio deltas accumulate into BufferingCall until attach(). */
|
|
2676
2676
|
async prewarm(tools) {
|
|
2677
2677
|
if (tools) this._tools = tools;
|
|
2678
|
-
this._call = new
|
|
2678
|
+
this._call = new chunkASQU6NA2_cjs.BufferingCall();
|
|
2679
2679
|
this._closed = false;
|
|
2680
2680
|
this._sentAudioChunks = 0;
|
|
2681
2681
|
this._audioRemainder = Buffer.alloc(0);
|
|
@@ -2732,7 +2732,7 @@ var GeminiRealtime = class _GeminiRealtime {
|
|
|
2732
2732
|
async attach(callSession) {
|
|
2733
2733
|
const prev = this._call;
|
|
2734
2734
|
this._call = callSession;
|
|
2735
|
-
|
|
2735
|
+
chunkASQU6NA2_cjs.attachBuffered(prev, callSession);
|
|
2736
2736
|
}
|
|
2737
2737
|
async start(callSession, tools) {
|
|
2738
2738
|
if (tools) this._tools = tools;
|
|
@@ -2741,8 +2741,8 @@ var GeminiRealtime = class _GeminiRealtime {
|
|
|
2741
2741
|
}
|
|
2742
2742
|
feedAudio(audio) {
|
|
2743
2743
|
if (this._session && !this._closed) {
|
|
2744
|
-
const pcm8k =
|
|
2745
|
-
const pcm16k =
|
|
2744
|
+
const pcm8k = chunkASQU6NA2_cjs.ulawToPcm16(audio);
|
|
2745
|
+
const pcm16k = chunkASQU6NA2_cjs.resamplePcm16(pcm8k, 8e3, 16e3);
|
|
2746
2746
|
this._session.sendRealtimeInput({
|
|
2747
2747
|
audio: {
|
|
2748
2748
|
data: Buffer.from(pcm16k).toString("base64"),
|
|
@@ -2786,7 +2786,7 @@ var GeminiRealtime = class _GeminiRealtime {
|
|
|
2786
2786
|
t.function.parameters ?? { type: "object", properties: {} }
|
|
2787
2787
|
)
|
|
2788
2788
|
})) : [];
|
|
2789
|
-
toolDefs.push(...
|
|
2789
|
+
toolDefs.push(...chunkASQU6NA2_cjs.getBuiltinToolSchemas(this._builtinTools, "gemini"));
|
|
2790
2790
|
return toolDefs;
|
|
2791
2791
|
}
|
|
2792
2792
|
_handleMessage(msg) {
|
|
@@ -2846,8 +2846,8 @@ var GeminiRealtime = class _GeminiRealtime {
|
|
|
2846
2846
|
_handleAudioData(b64Data) {
|
|
2847
2847
|
if (!this._call) return;
|
|
2848
2848
|
const pcm24k = Buffer.from(b64Data, "base64");
|
|
2849
|
-
const pcm8k =
|
|
2850
|
-
const ulaw =
|
|
2849
|
+
const pcm8k = chunkASQU6NA2_cjs.resamplePcm16(pcm24k, 24e3, 8e3);
|
|
2850
|
+
const ulaw = chunkASQU6NA2_cjs.pcm16ToUlaw(pcm8k);
|
|
2851
2851
|
const combined = Buffer.concat([this._audioRemainder, ulaw]);
|
|
2852
2852
|
const chunkSize = 160;
|
|
2853
2853
|
const fullEnd = Math.floor(combined.length / chunkSize) * chunkSize;
|
|
@@ -2890,7 +2890,7 @@ var GeminiRealtime = class _GeminiRealtime {
|
|
|
2890
2890
|
const functionCalls = toolCall.functionCalls;
|
|
2891
2891
|
if (!functionCalls) return;
|
|
2892
2892
|
const responses = [];
|
|
2893
|
-
const player = this._holdAudioChunks && this._call && !(this._call instanceof
|
|
2893
|
+
const player = this._holdAudioChunks && this._call && !(this._call instanceof chunkASQU6NA2_cjs.BufferingCall) ? new HoldAudioPlayer(this._call, this._holdAudioChunks) : null;
|
|
2894
2894
|
player?.start();
|
|
2895
2895
|
try {
|
|
2896
2896
|
for (const fc of functionCalls) {
|
|
@@ -2898,8 +2898,8 @@ var GeminiRealtime = class _GeminiRealtime {
|
|
|
2898
2898
|
const fcId = fc.id ?? "";
|
|
2899
2899
|
const args = fc.args ?? {};
|
|
2900
2900
|
this._log.info({ tool: name, args }, "Tool call: %s", name);
|
|
2901
|
-
if (
|
|
2902
|
-
const result = await
|
|
2901
|
+
if (chunkASQU6NA2_cjs.BUILTIN_TOOL_NAMES.has(name) && this._call && !(this._call instanceof chunkASQU6NA2_cjs.BufferingCall)) {
|
|
2902
|
+
const result = await chunkASQU6NA2_cjs.executeBuiltinTool(
|
|
2903
2903
|
name,
|
|
2904
2904
|
args,
|
|
2905
2905
|
this._call
|
|
@@ -2914,9 +2914,9 @@ var GeminiRealtime = class _GeminiRealtime {
|
|
|
2914
2914
|
continue;
|
|
2915
2915
|
}
|
|
2916
2916
|
}
|
|
2917
|
-
if (
|
|
2917
|
+
if (chunkASQU6NA2_cjs.BUILTIN_TOOL_NAMES.has(name) && this._call instanceof chunkASQU6NA2_cjs.BufferingCall) {
|
|
2918
2918
|
this._log.warn("Builtin tool %s called before answer \u2014 deferring", name);
|
|
2919
|
-
responses.push({ id: fcId, name, response: { result:
|
|
2919
|
+
responses.push({ id: fcId, name, response: { result: chunkASQU6NA2_cjs.CALL_NOT_READY_RESULT } });
|
|
2920
2920
|
continue;
|
|
2921
2921
|
}
|
|
2922
2922
|
if (!this._tools || !this._tools.has(name)) {
|
|
@@ -2961,7 +2961,7 @@ var GeminiRealtime = class _GeminiRealtime {
|
|
|
2961
2961
|
// src/agent/pipeline/stt/deepgram-stt.ts
|
|
2962
2962
|
var DeepgramSTT = class {
|
|
2963
2963
|
_options;
|
|
2964
|
-
_log =
|
|
2964
|
+
_log = chunkASQU6NA2_cjs.NOOP_LOGGER;
|
|
2965
2965
|
get provider() {
|
|
2966
2966
|
return "deepgram";
|
|
2967
2967
|
}
|
|
@@ -3088,7 +3088,7 @@ var DeepgramSTT = class {
|
|
|
3088
3088
|
// src/agent/pipeline/tts/elevenlabs-tts.ts
|
|
3089
3089
|
var ElevenLabsTTS = class {
|
|
3090
3090
|
_options;
|
|
3091
|
-
_log =
|
|
3091
|
+
_log = chunkASQU6NA2_cjs.NOOP_LOGGER;
|
|
3092
3092
|
get provider() {
|
|
3093
3093
|
return "elevenlabs";
|
|
3094
3094
|
}
|
|
@@ -3834,55 +3834,55 @@ function mcpServerHTTP(options) {
|
|
|
3834
3834
|
|
|
3835
3835
|
Object.defineProperty(exports, "BUILTIN_TOOL_NAMES", {
|
|
3836
3836
|
enumerable: true,
|
|
3837
|
-
get: function () { return
|
|
3837
|
+
get: function () { return chunkASQU6NA2_cjs.BUILTIN_TOOL_NAMES; }
|
|
3838
3838
|
});
|
|
3839
3839
|
Object.defineProperty(exports, "BuiltinTool", {
|
|
3840
3840
|
enumerable: true,
|
|
3841
|
-
get: function () { return
|
|
3841
|
+
get: function () { return chunkASQU6NA2_cjs.BuiltinTool; }
|
|
3842
3842
|
});
|
|
3843
3843
|
Object.defineProperty(exports, "CallSession", {
|
|
3844
3844
|
enumerable: true,
|
|
3845
|
-
get: function () { return
|
|
3845
|
+
get: function () { return chunkASQU6NA2_cjs.CallSession; }
|
|
3846
3846
|
});
|
|
3847
3847
|
Object.defineProperty(exports, "DECODE_TABLE", {
|
|
3848
3848
|
enumerable: true,
|
|
3849
|
-
get: function () { return
|
|
3849
|
+
get: function () { return chunkASQU6NA2_cjs.DECODE_TABLE; }
|
|
3850
3850
|
});
|
|
3851
3851
|
Object.defineProperty(exports, "DtmfCollectorBusyError", {
|
|
3852
3852
|
enumerable: true,
|
|
3853
|
-
get: function () { return
|
|
3853
|
+
get: function () { return chunkASQU6NA2_cjs.DtmfCollectorBusyError; }
|
|
3854
3854
|
});
|
|
3855
3855
|
Object.defineProperty(exports, "createAgentLogger", {
|
|
3856
3856
|
enumerable: true,
|
|
3857
|
-
get: function () { return
|
|
3857
|
+
get: function () { return chunkASQU6NA2_cjs.createAgentLogger; }
|
|
3858
3858
|
});
|
|
3859
3859
|
Object.defineProperty(exports, "createPipelineLogger", {
|
|
3860
3860
|
enumerable: true,
|
|
3861
|
-
get: function () { return
|
|
3861
|
+
get: function () { return chunkASQU6NA2_cjs.createPipelineLogger; }
|
|
3862
3862
|
});
|
|
3863
3863
|
Object.defineProperty(exports, "executeBuiltinTool", {
|
|
3864
3864
|
enumerable: true,
|
|
3865
|
-
get: function () { return
|
|
3865
|
+
get: function () { return chunkASQU6NA2_cjs.executeBuiltinTool; }
|
|
3866
3866
|
});
|
|
3867
3867
|
Object.defineProperty(exports, "getBuiltinToolSchemas", {
|
|
3868
3868
|
enumerable: true,
|
|
3869
|
-
get: function () { return
|
|
3869
|
+
get: function () { return chunkASQU6NA2_cjs.getBuiltinToolSchemas; }
|
|
3870
3870
|
});
|
|
3871
3871
|
Object.defineProperty(exports, "isBuiltinTool", {
|
|
3872
3872
|
enumerable: true,
|
|
3873
|
-
get: function () { return
|
|
3873
|
+
get: function () { return chunkASQU6NA2_cjs.isBuiltinTool; }
|
|
3874
3874
|
});
|
|
3875
3875
|
Object.defineProperty(exports, "pcm16ToUlaw", {
|
|
3876
3876
|
enumerable: true,
|
|
3877
|
-
get: function () { return
|
|
3877
|
+
get: function () { return chunkASQU6NA2_cjs.pcm16ToUlaw; }
|
|
3878
3878
|
});
|
|
3879
3879
|
Object.defineProperty(exports, "resamplePcm16", {
|
|
3880
3880
|
enumerable: true,
|
|
3881
|
-
get: function () { return
|
|
3881
|
+
get: function () { return chunkASQU6NA2_cjs.resamplePcm16; }
|
|
3882
3882
|
});
|
|
3883
3883
|
Object.defineProperty(exports, "ulawToPcm16", {
|
|
3884
3884
|
enumerable: true,
|
|
3885
|
-
get: function () { return
|
|
3885
|
+
get: function () { return chunkASQU6NA2_cjs.ulawToPcm16; }
|
|
3886
3886
|
});
|
|
3887
3887
|
exports.AnthropicLLM = AnthropicLLM;
|
|
3888
3888
|
exports.AudioRecorder = AudioRecorder;
|
package/dist/agent/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DEFAULT_BASE_URL } from '../chunk-35XJNMFU.js';
|
|
2
2
|
import { AgentError, AgentConnectionError } from '../chunk-VYGIWHRU.js';
|
|
3
|
-
import { NOOP_LOGGER, resolveBuiltinTools, createAgentLogger, createPipelineLogger, getSdkInfo, CallSession, BufferingCall, attachBuffered, ulawToPcm16, resamplePcm16, getBuiltinToolSchemas, BUILTIN_TOOL_NAMES, executeBuiltinTool, CALL_NOT_READY_RESULT, pcm16ToUlaw, applyUlawGain } from '../chunk-
|
|
4
|
-
export { BUILTIN_TOOL_NAMES, BuiltinTool, CallSession, DECODE_TABLE, DtmfCollectorBusyError, createAgentLogger, createPipelineLogger, executeBuiltinTool, getBuiltinToolSchemas, isBuiltinTool, pcm16ToUlaw, resamplePcm16, ulawToPcm16 } from '../chunk-
|
|
5
|
-
import '../chunk-
|
|
3
|
+
import { NOOP_LOGGER, resolveBuiltinTools, createAgentLogger, createPipelineLogger, getSdkInfo, CallSession, BufferingCall, attachBuffered, ulawToPcm16, resamplePcm16, getBuiltinToolSchemas, BUILTIN_TOOL_NAMES, executeBuiltinTool, CALL_NOT_READY_RESULT, pcm16ToUlaw, applyUlawGain } from '../chunk-EO25KTL4.js';
|
|
4
|
+
export { BUILTIN_TOOL_NAMES, BuiltinTool, CallSession, DECODE_TABLE, DtmfCollectorBusyError, createAgentLogger, createPipelineLogger, executeBuiltinTool, getBuiltinToolSchemas, isBuiltinTool, pcm16ToUlaw, resamplePcm16, ulawToPcm16 } from '../chunk-EO25KTL4.js';
|
|
5
|
+
import '../chunk-J7UIB4EA.js';
|
|
6
6
|
import * as fs from 'fs';
|
|
7
7
|
import * as path from 'path';
|
|
8
8
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../../chunk-
|
|
3
|
+
var chunkASQU6NA2_cjs = require('../../chunk-ASQU6NA2.cjs');
|
|
4
|
+
require('../../chunk-NXCYAYFT.cjs');
|
|
5
5
|
|
|
6
6
|
// src/agent/livekit/io.ts
|
|
7
7
|
var SAMPLE_RATE = 8e3;
|
|
@@ -63,7 +63,7 @@ async function loadClawOpsIO() {
|
|
|
63
63
|
if (this._closed || !this._controller || ulaw.length === 0) return;
|
|
64
64
|
const samples = new Int16Array(ulaw.length);
|
|
65
65
|
for (let i = 0; i < ulaw.length; i++) {
|
|
66
|
-
samples[i] =
|
|
66
|
+
samples[i] = chunkASQU6NA2_cjs.DECODE_TABLE[ulaw[i]];
|
|
67
67
|
}
|
|
68
68
|
const frame = new AudioFrame(samples, SAMPLE_RATE, 1, samples.length);
|
|
69
69
|
try {
|
|
@@ -132,7 +132,7 @@ async function loadClawOpsIO() {
|
|
|
132
132
|
}
|
|
133
133
|
this._pushedDurationMs += frame.samplesPerChannel / frame.sampleRate * 1e3;
|
|
134
134
|
const pcm = Buffer.from(frame.data.buffer, frame.data.byteOffset, frame.data.byteLength);
|
|
135
|
-
const encoded =
|
|
135
|
+
const encoded = chunkASQU6NA2_cjs.pcm16ToUlaw(pcm);
|
|
136
136
|
const ulaw = this._tail.length === 0 ? encoded : Buffer.concat([this._tail, encoded]);
|
|
137
137
|
let off = 0;
|
|
138
138
|
while (off + FRAME_BYTES <= ulaw.length) {
|
|
@@ -243,7 +243,7 @@ function createClawOpsPhoneTools(llm, options) {
|
|
|
243
243
|
};
|
|
244
244
|
const exclude = options.excludeNames ?? /* @__PURE__ */ new Set();
|
|
245
245
|
const ignoreFlag = llm.ToolFlag?.IGNORE_ON_ENTER;
|
|
246
|
-
const schemas =
|
|
246
|
+
const schemas = chunkASQU6NA2_cjs.getBuiltinToolSchemas(options.enabled, "chat");
|
|
247
247
|
const tools = [];
|
|
248
248
|
for (const schema of schemas) {
|
|
249
249
|
const { name, description, parameters } = schema.function;
|
|
@@ -256,7 +256,7 @@ function createClawOpsPhoneTools(llm, options) {
|
|
|
256
256
|
// raw JSON schema (agents-js 가 JSONSchema7 을 그대로 받는다).
|
|
257
257
|
flags: IGNORE_ON_ENTER_TOOLS.has(name) ? ignoreFlag : void 0,
|
|
258
258
|
// raw schema tool 의 execute 는 파싱된 args 를 그대로 받는다.
|
|
259
|
-
execute: async (args) => await
|
|
259
|
+
execute: async (args) => await chunkASQU6NA2_cjs.executeBuiltinTool(name, args ?? {}, requireCall()) ?? ""
|
|
260
260
|
})
|
|
261
261
|
);
|
|
262
262
|
}
|
|
@@ -285,7 +285,7 @@ var LiveKitSession = class {
|
|
|
285
285
|
_userToolCtx = null;
|
|
286
286
|
_toolRegistry = null;
|
|
287
287
|
_builtinTools = null;
|
|
288
|
-
_log =
|
|
288
|
+
_log = chunkASQU6NA2_cjs.NOOP_LOGGER;
|
|
289
289
|
// 동적 로드한 agents-js 네임스페이스 (boot 시 캐시).
|
|
290
290
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
291
291
|
_llm = null;
|
|
@@ -323,7 +323,7 @@ var LiveKitSession = class {
|
|
|
323
323
|
this._output.setCall(callSession);
|
|
324
324
|
this._target = callSession;
|
|
325
325
|
await this._applyTools(callSession);
|
|
326
|
-
|
|
326
|
+
chunkASQU6NA2_cjs.attachBuffered(prev, callSession);
|
|
327
327
|
}
|
|
328
328
|
feedAudio(audio, _timestamp) {
|
|
329
329
|
this._input?.pushUlaw(audio);
|
|
@@ -349,7 +349,7 @@ var LiveKitSession = class {
|
|
|
349
349
|
]);
|
|
350
350
|
this._llm = agents.llm;
|
|
351
351
|
const { ClawOpsAudioInput, ClawOpsAudioOutput } = io;
|
|
352
|
-
const target = call ?? new
|
|
352
|
+
const target = call ?? new chunkASQU6NA2_cjs.BufferingCall();
|
|
353
353
|
const [session, agent] = await this._create(call);
|
|
354
354
|
this._validate(session, agent);
|
|
355
355
|
const input = new ClawOpsAudioInput();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getBuiltinToolSchemas, executeBuiltinTool, NOOP_LOGGER, attachBuffered, BufferingCall, pcm16ToUlaw, DECODE_TABLE } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
1
|
+
import { getBuiltinToolSchemas, executeBuiltinTool, NOOP_LOGGER, attachBuffered, BufferingCall, pcm16ToUlaw, DECODE_TABLE } from '../../chunk-EO25KTL4.js';
|
|
2
|
+
import '../../chunk-J7UIB4EA.js';
|
|
3
3
|
|
|
4
4
|
// src/agent/livekit/io.ts
|
|
5
5
|
var SAMPLE_RATE = 8e3;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkNXCYAYFT_cjs = require('./chunk-NXCYAYFT.cjs');
|
|
4
4
|
var pino = require('pino');
|
|
5
5
|
var os = require('os');
|
|
6
6
|
|
|
@@ -363,7 +363,7 @@ var MAX_ERROR_MESSAGE_LENGTH = 200;
|
|
|
363
363
|
function getSdkInfo() {
|
|
364
364
|
return {
|
|
365
365
|
name: "clawops-node",
|
|
366
|
-
version:
|
|
366
|
+
version: chunkNXCYAYFT_cjs.VERSION,
|
|
367
367
|
runtime: `node/${process.versions.node}`,
|
|
368
368
|
os: `${process.platform}/${os__default.default.arch()}`
|
|
369
369
|
};
|
|
@@ -1008,5 +1008,5 @@ exports.pcm16ToUlaw = pcm16ToUlaw;
|
|
|
1008
1008
|
exports.resamplePcm16 = resamplePcm16;
|
|
1009
1009
|
exports.resolveBuiltinTools = resolveBuiltinTools;
|
|
1010
1010
|
exports.ulawToPcm16 = ulawToPcm16;
|
|
1011
|
-
//# sourceMappingURL=chunk-
|
|
1012
|
-
//# sourceMappingURL=chunk-
|
|
1011
|
+
//# sourceMappingURL=chunk-ASQU6NA2.cjs.map
|
|
1012
|
+
//# sourceMappingURL=chunk-ASQU6NA2.cjs.map
|