@teamlearners/clawops 0.29.0 → 0.31.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.
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkSBK45525_cjs = require('../chunk-SBK45525.cjs');
4
- var chunkXAOA3XFQ_cjs = require('../chunk-XAOA3XFQ.cjs');
3
+ var chunkKHEU4DKD_cjs = require('../chunk-KHEU4DKD.cjs');
4
+ var chunkQD2ZY4UP_cjs = require('../chunk-QD2ZY4UP.cjs');
5
5
  var fs = require('fs');
6
6
  var path = require('path');
7
7
  var os = require('os');
@@ -59,7 +59,7 @@ var ControlWebSocket = class {
59
59
  _closed = false;
60
60
  _connectedResolve = null;
61
61
  _connectedPromise;
62
- _log = chunkXAOA3XFQ_cjs.NOOP_LOGGER;
62
+ _log = chunkQD2ZY4UP_cjs.NOOP_LOGGER;
63
63
  _pingTimer = null;
64
64
  setLogger(logger) {
65
65
  this._log = logger;
@@ -224,7 +224,7 @@ var ControlWebSocket = class {
224
224
  var MCPClient = class {
225
225
  _servers = /* @__PURE__ */ new Map();
226
226
  _clients = /* @__PURE__ */ new Map();
227
- _log = chunkXAOA3XFQ_cjs.NOOP_LOGGER;
227
+ _log = chunkQD2ZY4UP_cjs.NOOP_LOGGER;
228
228
  setLogger(logger) {
229
229
  this._log = logger;
230
230
  }
@@ -366,7 +366,7 @@ var MediaWebSocket = class {
366
366
  _onClose = null;
367
367
  _onDtmf = null;
368
368
  _markWaiters = /* @__PURE__ */ new Map();
369
- _log = chunkXAOA3XFQ_cjs.NOOP_LOGGER;
369
+ _log = chunkQD2ZY4UP_cjs.NOOP_LOGGER;
370
370
  setLogger(logger) {
371
371
  this._log = logger;
372
372
  }
@@ -592,7 +592,7 @@ var AudioRecorder = class {
592
592
  _started = false;
593
593
  _baseTs = null;
594
594
  _outCursor = 0;
595
- _log = chunkXAOA3XFQ_cjs.NOOP_LOGGER;
595
+ _log = chunkQD2ZY4UP_cjs.NOOP_LOGGER;
596
596
  setLogger(logger) {
597
597
  this._log = logger;
598
598
  }
@@ -728,7 +728,7 @@ var MAX_ERROR_MESSAGE_LENGTH = 200;
728
728
  function getSdkInfo() {
729
729
  return {
730
730
  name: "clawops-node",
731
- version: chunkSBK45525_cjs.VERSION,
731
+ version: chunkKHEU4DKD_cjs.VERSION,
732
732
  runtime: `node/${process.versions.node}`,
733
733
  os: `${process.platform}/${os__default.default.arch()}`
734
734
  };
@@ -788,7 +788,7 @@ var CallSession = class {
788
788
  _dtmfCollectorActive = false;
789
789
  _dtmfResolvers = [];
790
790
  _dtmfBuffer = [];
791
- _log = chunkXAOA3XFQ_cjs.NOOP_LOGGER;
791
+ _log = chunkQD2ZY4UP_cjs.NOOP_LOGGER;
792
792
  _handlers = /* @__PURE__ */ new Map();
793
793
  _endedPromise;
794
794
  _resolveEnded;
@@ -954,11 +954,27 @@ var CallSession = class {
954
954
  * directly to a SIP endpoint without going through the PSTN carrier. Requires the
955
955
  * account to have an active `sip_trunk` add-on; otherwise the transfer fails and
956
956
  * the call continues with the AI (result `{ status: 'failed', ... }`).
957
+ *
958
+ * 전환받는 쪽에 표시되는 발신번호는 기본이 **계정 보유번호**(인바운드면 착신 070)다.
959
+ *
960
+ * `callerIdMode: 'original'` 은 인바운드 통화의 **원 발신자 번호를 승계하려는 선호**다.
961
+ * 승계할 수 없는 통화(KCT 직결 인입이 아니거나 국내 번호로 정규화되지 않는 발신번호)면
962
+ * 조용히 계정 보유번호로 내려앉고 **전환은 그대로 성사된다**.
963
+ *
964
+ * `callerId` 는 번호를 직접 주는 **지시**라 성격이 다르다. 허용 범위(계정 보유번호 또는
965
+ * KCT 직결 인입의 원 발신자)를 벗어나면 전환 자체가 실패한다. 둘 다 주면 `callerId` 가
966
+ * 이기고 `callerIdMode` 는 무시된다 — 우선순위 판단은 서버가 한다.
957
967
  */
958
968
  async transfer(to, options) {
959
969
  if (!this._transferFn) {
960
970
  throw new Error("transfer not available");
961
971
  }
972
+ const callerIdMode = options?.callerIdMode;
973
+ if (callerIdMode !== void 0 && callerIdMode !== "account" && callerIdMode !== "original") {
974
+ throw new Error(
975
+ `callerIdMode must be 'account' or 'original', got ${JSON.stringify(callerIdMode)}`
976
+ );
977
+ }
962
978
  return this._transferFn({
963
979
  to,
964
980
  destinationType: options?.destinationType ?? "pstn",
@@ -968,7 +984,9 @@ var CallSession = class {
968
984
  whisper: options?.whisper ?? null,
969
985
  context: options?.context ?? null,
970
986
  callerId: options?.callerId ?? null,
971
- timeout: options?.timeout ?? 30
987
+ timeout: options?.timeout ?? 30,
988
+ // 안 주면 키를 붙이지 않는다 — 구 서버와 기존 동작을 그대로 둔다(additive).
989
+ ...callerIdMode !== void 0 ? { callerIdMode } : {}
972
990
  });
973
991
  }
974
992
  /** Register an event handler. */
@@ -1105,7 +1123,7 @@ function generateComfortTone(volume = 0.12) {
1105
1123
  }
1106
1124
  }
1107
1125
  const pcm = int16ArrayToBuffer(concatInt16Arrays(...parts));
1108
- const ulaw = chunkXAOA3XFQ_cjs.pcm16ToUlaw(pcm);
1126
+ const ulaw = chunkQD2ZY4UP_cjs.pcm16ToUlaw(pcm);
1109
1127
  const chunks = [];
1110
1128
  for (let i = 0; i < ulaw.length; i += CHUNK_SIZE) {
1111
1129
  chunks.push(ulaw.subarray(i, i + CHUNK_SIZE));
@@ -1162,9 +1180,9 @@ function loadHoldAudio(source) {
1162
1180
  pcmData = mono;
1163
1181
  }
1164
1182
  if (sampleRate !== SAMPLE_RATE2) {
1165
- pcmData = chunkXAOA3XFQ_cjs.resamplePcm16(pcmData, sampleRate, SAMPLE_RATE2);
1183
+ pcmData = chunkQD2ZY4UP_cjs.resamplePcm16(pcmData, sampleRate, SAMPLE_RATE2);
1166
1184
  }
1167
- const ulaw = chunkXAOA3XFQ_cjs.pcm16ToUlaw(pcmData);
1185
+ const ulaw = chunkQD2ZY4UP_cjs.pcm16ToUlaw(pcmData);
1168
1186
  const chunks = [];
1169
1187
  for (let i = 0; i < ulaw.length; i += CHUNK_SIZE) {
1170
1188
  chunks.push(ulaw.subarray(i, i + CHUNK_SIZE));
@@ -1433,13 +1451,13 @@ var ClawOpsAgent = class _ClawOpsAgent {
1433
1451
  constructor(options) {
1434
1452
  this._apiKey = options.apiKey ?? process.env["CLAWOPS_API_KEY"] ?? "";
1435
1453
  this._accountId = options.accountId ?? process.env["CLAWOPS_ACCOUNT_ID"] ?? "";
1436
- this._baseUrl = options.baseUrl ?? chunkSBK45525_cjs.DEFAULT_BASE_URL;
1454
+ this._baseUrl = options.baseUrl ?? chunkKHEU4DKD_cjs.DEFAULT_BASE_URL;
1437
1455
  this._fromNumber = options.from;
1438
1456
  this._session = options.session;
1439
1457
  this._recording = options.recording ?? false;
1440
1458
  this._recordingPath = options.recordingPath ?? "./recordings";
1441
1459
  this._mcpServers = options.mcpServers ?? [];
1442
- this._builtinTools = chunkXAOA3XFQ_cjs.resolveBuiltinTools(options.builtinTools ?? "all" /* ALL */);
1460
+ this._builtinTools = chunkQD2ZY4UP_cjs.resolveBuiltinTools(options.builtinTools ?? "all" /* ALL */);
1443
1461
  this._passiveDtmfDebounceMs = options.passiveDtmfDebounceMs ?? 500;
1444
1462
  this._rxGain = _ClawOpsAgent._validateGain("rxGain", options.rxGain ?? 1);
1445
1463
  this._txGain = _ClawOpsAgent._validateGain("txGain", options.txGain ?? 1);
@@ -1448,8 +1466,8 @@ var ClawOpsAgent = class _ClawOpsAgent {
1448
1466
  if (options.tracing) {
1449
1467
  setTracingConfig(options.tracing);
1450
1468
  }
1451
- this._log = chunkXAOA3XFQ_cjs.createAgentLogger(options.logger);
1452
- this._pipelineLog = chunkXAOA3XFQ_cjs.createPipelineLogger(this._log);
1469
+ this._log = chunkQD2ZY4UP_cjs.createAgentLogger(options.logger);
1470
+ this._pipelineLog = chunkQD2ZY4UP_cjs.createPipelineLogger(this._log);
1453
1471
  this._isPipelineSession = "_stt" in this._session && "_llm" in this._session;
1454
1472
  if (options.toolConfig?.holdAudio) {
1455
1473
  this._holdAudioChunks = loadHoldAudio(options.toolConfig.holdAudio);
@@ -1457,7 +1475,7 @@ var ClawOpsAgent = class _ClawOpsAgent {
1457
1475
  }
1458
1476
  static _validateGain(name, gain) {
1459
1477
  if (typeof gain !== "number" || !Number.isFinite(gain) || gain < 0) {
1460
- throw new chunkSBK45525_cjs.AgentError(`${name}=${gain} must be a finite number >= 0`);
1478
+ throw new chunkKHEU4DKD_cjs.AgentError(`${name}=${gain} must be a finite number >= 0`);
1461
1479
  }
1462
1480
  return gain;
1463
1481
  }
@@ -1471,7 +1489,7 @@ var ClawOpsAgent = class _ClawOpsAgent {
1471
1489
  tool(nameOrTool, description, parameters, handler) {
1472
1490
  if (typeof nameOrTool === "string") {
1473
1491
  if (!description || !parameters || !handler) {
1474
- throw new chunkSBK45525_cjs.AgentError(
1492
+ throw new chunkKHEU4DKD_cjs.AgentError(
1475
1493
  "tool(name, description, parameters, handler) requires all arguments."
1476
1494
  );
1477
1495
  }
@@ -1507,10 +1525,10 @@ var ClawOpsAgent = class _ClawOpsAgent {
1507
1525
  async connect() {
1508
1526
  if (this._controlWs) return;
1509
1527
  if (!this._apiKey) {
1510
- throw new chunkSBK45525_cjs.AgentError("API key is required. Set CLAWOPS_API_KEY or pass apiKey option.");
1528
+ throw new chunkKHEU4DKD_cjs.AgentError("API key is required. Set CLAWOPS_API_KEY or pass apiKey option.");
1511
1529
  }
1512
1530
  if (!this._accountId) {
1513
- throw new chunkSBK45525_cjs.AgentError(
1531
+ throw new chunkKHEU4DKD_cjs.AgentError(
1514
1532
  "Account ID is required. Set CLAWOPS_ACCOUNT_ID or pass accountId option."
1515
1533
  );
1516
1534
  }
@@ -1534,7 +1552,7 @@ var ClawOpsAgent = class _ClawOpsAgent {
1534
1552
  } catch {
1535
1553
  }
1536
1554
  } catch (err) {
1537
- throw new chunkSBK45525_cjs.AgentConnectionError(
1555
+ throw new chunkKHEU4DKD_cjs.AgentConnectionError(
1538
1556
  `Failed to connect to ClawOps: ${err instanceof Error ? err.message : String(err)}`
1539
1557
  );
1540
1558
  }
@@ -1598,7 +1616,7 @@ var ClawOpsAgent = class _ClawOpsAgent {
1598
1616
  });
1599
1617
  if (resp.status !== 201) {
1600
1618
  const error = await resp.json();
1601
- throw new chunkSBK45525_cjs.AgentError(`\uBC1C\uC2E0 \uC2E4\uD328 (${resp.status}): ${error["error"] ?? ""}`);
1619
+ throw new chunkKHEU4DKD_cjs.AgentError(`\uBC1C\uC2E0 \uC2E4\uD328 (${resp.status}): ${error["error"] ?? ""}`);
1602
1620
  }
1603
1621
  const data = await resp.json();
1604
1622
  const callSession = new CallSession({
@@ -1896,9 +1914,9 @@ var ClawOpsAgent = class _ClawOpsAgent {
1896
1914
  let latestMediaTs = 0;
1897
1915
  session._bindTransport(
1898
1916
  (audio) => {
1899
- const gained = chunkXAOA3XFQ_cjs.applyUlawGain(audio, this._txGain);
1917
+ const gained = chunkQD2ZY4UP_cjs.applyUlawGain(audio, this._txGain);
1900
1918
  if (recorder) {
1901
- recorder.writeOutbound(chunkXAOA3XFQ_cjs.ulawToPcm16(gained), latestMediaTs);
1919
+ recorder.writeOutbound(chunkQD2ZY4UP_cjs.ulawToPcm16(gained), latestMediaTs);
1902
1920
  }
1903
1921
  mediaWs.sendAudio(gained.toString("base64"));
1904
1922
  session.recordFirstResponse();
@@ -1928,9 +1946,9 @@ var ClawOpsAgent = class _ClawOpsAgent {
1928
1946
  this._callSessions.set(session.callId, sessionHandler);
1929
1947
  mediaWs.onAudio((ulawAudio, timestamp) => {
1930
1948
  latestMediaTs = timestamp;
1931
- const gained = chunkXAOA3XFQ_cjs.applyUlawGain(ulawAudio, this._rxGain);
1949
+ const gained = chunkQD2ZY4UP_cjs.applyUlawGain(ulawAudio, this._rxGain);
1932
1950
  if (recorder) {
1933
- recorder.writeInbound(chunkXAOA3XFQ_cjs.ulawToPcm16(gained), timestamp);
1951
+ recorder.writeInbound(chunkQD2ZY4UP_cjs.ulawToPcm16(gained), timestamp);
1934
1952
  }
1935
1953
  if (sessionHandler) {
1936
1954
  sessionHandler.feedAudio(gained, timestamp);
@@ -2045,7 +2063,7 @@ var PipelineSession = class {
2045
2063
  _speaking = false;
2046
2064
  _builtinTools = null;
2047
2065
  _holdAudioChunks = null;
2048
- _log = chunkXAOA3XFQ_cjs.NOOP_LOGGER;
2066
+ _log = chunkQD2ZY4UP_cjs.NOOP_LOGGER;
2049
2067
  constructor(options) {
2050
2068
  this._stt = options.stt;
2051
2069
  this._llm = options.llm;
@@ -2107,7 +2125,7 @@ var PipelineSession = class {
2107
2125
  */
2108
2126
  async prewarm(tools) {
2109
2127
  if (tools) this._tools = tools;
2110
- this._callSession = new chunkXAOA3XFQ_cjs.BufferingCall();
2128
+ this._callSession = new chunkQD2ZY4UP_cjs.BufferingCall();
2111
2129
  this._running = true;
2112
2130
  this._conversation = [];
2113
2131
  this._log.info("PipelineSession prewarmed");
@@ -2130,7 +2148,7 @@ var PipelineSession = class {
2130
2148
  async attach(callSession) {
2131
2149
  const prev = this._callSession;
2132
2150
  this._callSession = callSession;
2133
- chunkXAOA3XFQ_cjs.attachBuffered(prev, callSession);
2151
+ chunkQD2ZY4UP_cjs.attachBuffered(prev, callSession);
2134
2152
  }
2135
2153
  async start(callSession, tools) {
2136
2154
  this._tools = tools ?? null;
@@ -2177,8 +2195,8 @@ var PipelineSession = class {
2177
2195
  while (this._running) {
2178
2196
  if (this._audioBuffer.length > 0) {
2179
2197
  const ulaw = this._audioBuffer.shift();
2180
- const pcm8k = chunkXAOA3XFQ_cjs.ulawToPcm16(ulaw);
2181
- const pcm16k = chunkXAOA3XFQ_cjs.resamplePcm16(pcm8k, 8e3, 16e3);
2198
+ const pcm8k = chunkQD2ZY4UP_cjs.ulawToPcm16(ulaw);
2199
+ const pcm16k = chunkQD2ZY4UP_cjs.resamplePcm16(pcm8k, 8e3, 16e3);
2182
2200
  yield pcm16k;
2183
2201
  } else {
2184
2202
  await new Promise((resolve) => setTimeout(resolve, 20));
@@ -2194,7 +2212,7 @@ var PipelineSession = class {
2194
2212
  await this._respond();
2195
2213
  }
2196
2214
  _buildEffectiveTools() {
2197
- const builtinSchemas = chunkXAOA3XFQ_cjs.getBuiltinToolSchemas(this._builtinTools, "chat");
2215
+ const builtinSchemas = chunkQD2ZY4UP_cjs.getBuiltinToolSchemas(this._builtinTools, "chat");
2198
2216
  const dtmfSchemas = builtinSchemas.filter((s) => {
2199
2217
  const name = s["function"]?.["name"];
2200
2218
  return name === "collect_dtmf" || name === "send_dtmf";
@@ -2243,8 +2261,8 @@ var PipelineSession = class {
2243
2261
  const { id, name, arguments: argsStr } = chunk.toolCall;
2244
2262
  try {
2245
2263
  const args = JSON.parse(argsStr);
2246
- if (chunkXAOA3XFQ_cjs.BUILTIN_TOOL_NAMES.has(name) && this._callSession && !(this._callSession instanceof chunkXAOA3XFQ_cjs.BufferingCall)) {
2247
- const result2 = await chunkXAOA3XFQ_cjs.executeBuiltinTool(name, args, this._callSession);
2264
+ if (chunkQD2ZY4UP_cjs.BUILTIN_TOOL_NAMES.has(name) && this._callSession && !(this._callSession instanceof chunkQD2ZY4UP_cjs.BufferingCall)) {
2265
+ const result2 = await chunkQD2ZY4UP_cjs.executeBuiltinTool(name, args, this._callSession);
2248
2266
  if (result2 !== null) {
2249
2267
  if (name === "hang_up") return;
2250
2268
  this._conversation.push({ role: "tool", content: result2, tool_call_id: id, name });
@@ -2252,11 +2270,11 @@ var PipelineSession = class {
2252
2270
  return;
2253
2271
  }
2254
2272
  }
2255
- if (chunkXAOA3XFQ_cjs.BUILTIN_TOOL_NAMES.has(name) && this._callSession instanceof chunkXAOA3XFQ_cjs.BufferingCall) {
2273
+ if (chunkQD2ZY4UP_cjs.BUILTIN_TOOL_NAMES.has(name) && this._callSession instanceof chunkQD2ZY4UP_cjs.BufferingCall) {
2256
2274
  this._log.warn("Builtin tool %s called before answer \u2014 deferring", name);
2257
2275
  this._conversation.push({
2258
2276
  role: "tool",
2259
- content: chunkXAOA3XFQ_cjs.CALL_NOT_READY_RESULT,
2277
+ content: chunkQD2ZY4UP_cjs.CALL_NOT_READY_RESULT,
2260
2278
  tool_call_id: id,
2261
2279
  name
2262
2280
  });
@@ -2265,7 +2283,7 @@ var PipelineSession = class {
2265
2283
  }
2266
2284
  if (!this._tools) return;
2267
2285
  this._callSession?.recordToolCall();
2268
- const player = this._holdAudioChunks && this._callSession && !(this._callSession instanceof chunkXAOA3XFQ_cjs.BufferingCall) ? new HoldAudioPlayer(this._callSession, this._holdAudioChunks) : null;
2286
+ const player = this._holdAudioChunks && this._callSession && !(this._callSession instanceof chunkQD2ZY4UP_cjs.BufferingCall) ? new HoldAudioPlayer(this._callSession, this._holdAudioChunks) : null;
2269
2287
  player?.start();
2270
2288
  let result;
2271
2289
  try {
@@ -2316,8 +2334,8 @@ var PipelineSession = class {
2316
2334
  sampleRate: this._sampleRate
2317
2335
  })) {
2318
2336
  if (!this._running || !this._speaking) break;
2319
- const pcm8k = chunkXAOA3XFQ_cjs.resamplePcm16(audioChunk, this._sampleRate, 8e3);
2320
- const ulaw = chunkXAOA3XFQ_cjs.pcm16ToUlaw(pcm8k);
2337
+ const pcm8k = chunkQD2ZY4UP_cjs.resamplePcm16(audioChunk, this._sampleRate, 8e3);
2338
+ const ulaw = chunkQD2ZY4UP_cjs.pcm16ToUlaw(pcm8k);
2321
2339
  for (let off = 0; off < ulaw.length; off += 160) {
2322
2340
  let chunk = ulaw.subarray(off, off + 160);
2323
2341
  if (chunk.length < 160) {
@@ -2344,7 +2362,7 @@ var OpenAIRealtime = class {
2344
2362
  _language;
2345
2363
  _turnDetection;
2346
2364
  _greeting;
2347
- _log = chunkXAOA3XFQ_cjs.NOOP_LOGGER;
2365
+ _log = chunkQD2ZY4UP_cjs.NOOP_LOGGER;
2348
2366
  _builtinTools = null;
2349
2367
  /**
2350
2368
  * 마지막 session.update 로 LLM 에 알린 tool 이름들. attach() 가 이 값과 현재
@@ -2421,7 +2439,7 @@ var OpenAIRealtime = class {
2421
2439
  /** Open WS + session.update + (optional) response.create without a CallSession. */
2422
2440
  async prewarm(tools) {
2423
2441
  if (tools) this._tools = tools;
2424
- this._call = new chunkXAOA3XFQ_cjs.BufferingCall();
2442
+ this._call = new chunkQD2ZY4UP_cjs.BufferingCall();
2425
2443
  this._closed = false;
2426
2444
  this._playback = null;
2427
2445
  this._latestMediaTs = 0;
@@ -2463,7 +2481,7 @@ var OpenAIRealtime = class {
2463
2481
  this._resyncTools();
2464
2482
  const prev = this._call;
2465
2483
  this._call = callSession;
2466
- chunkXAOA3XFQ_cjs.attachBuffered(prev, callSession);
2484
+ chunkQD2ZY4UP_cjs.attachBuffered(prev, callSession);
2467
2485
  }
2468
2486
  async start(callSession, tools) {
2469
2487
  if (tools) this._tools = tools;
@@ -2524,7 +2542,7 @@ var OpenAIRealtime = class {
2524
2542
  /** Current tool schemas: user tools + builtin tools (flat realtime format). */
2525
2543
  _currentToolSchemas() {
2526
2544
  const toolSchemas = this._tools ? this._tools.toOpenAITools().map((t) => ({ type: "function", ...t.function })) : [];
2527
- toolSchemas.push(...chunkXAOA3XFQ_cjs.getBuiltinToolSchemas(this._builtinTools, "realtime"));
2545
+ toolSchemas.push(...chunkQD2ZY4UP_cjs.getBuiltinToolSchemas(this._builtinTools, "realtime"));
2528
2546
  return toolSchemas;
2529
2547
  }
2530
2548
  /**
@@ -2695,9 +2713,9 @@ var OpenAIRealtime = class {
2695
2713
  const controller = new AbortController();
2696
2714
  this._pendingToolCalls.set(callId, controller);
2697
2715
  try {
2698
- if (chunkXAOA3XFQ_cjs.BUILTIN_TOOL_NAMES.has(funcName) && this._call && !(this._call instanceof chunkXAOA3XFQ_cjs.BufferingCall)) {
2716
+ if (chunkQD2ZY4UP_cjs.BUILTIN_TOOL_NAMES.has(funcName) && this._call && !(this._call instanceof chunkQD2ZY4UP_cjs.BufferingCall)) {
2699
2717
  const args = JSON.parse(item["arguments"] ?? "{}");
2700
- const result2 = await chunkXAOA3XFQ_cjs.executeBuiltinTool(funcName, args, this._call);
2718
+ const result2 = await chunkQD2ZY4UP_cjs.executeBuiltinTool(funcName, args, this._call);
2701
2719
  if (result2 !== null) {
2702
2720
  if (funcName === "hang_up") return;
2703
2721
  if (controller.signal.aborted) return;
@@ -2714,7 +2732,7 @@ var OpenAIRealtime = class {
2714
2732
  return;
2715
2733
  }
2716
2734
  }
2717
- if (chunkXAOA3XFQ_cjs.BUILTIN_TOOL_NAMES.has(funcName) && this._call instanceof chunkXAOA3XFQ_cjs.BufferingCall) {
2735
+ if (chunkQD2ZY4UP_cjs.BUILTIN_TOOL_NAMES.has(funcName) && this._call instanceof chunkQD2ZY4UP_cjs.BufferingCall) {
2718
2736
  this._log.warn("Builtin tool %s called before answer \u2014 deferring", funcName);
2719
2737
  await this._waitForResponseDone();
2720
2738
  this._send({
@@ -2722,7 +2740,7 @@ var OpenAIRealtime = class {
2722
2740
  item: {
2723
2741
  type: "function_call_output",
2724
2742
  call_id: callId,
2725
- output: chunkXAOA3XFQ_cjs.CALL_NOT_READY_RESULT
2743
+ output: chunkQD2ZY4UP_cjs.CALL_NOT_READY_RESULT
2726
2744
  }
2727
2745
  });
2728
2746
  this._send({ type: "response.create" });
@@ -2743,7 +2761,7 @@ var OpenAIRealtime = class {
2743
2761
  return;
2744
2762
  }
2745
2763
  let result;
2746
- const player = this._holdAudioChunks && this._call && !(this._call instanceof chunkXAOA3XFQ_cjs.BufferingCall) ? new HoldAudioPlayer(this._call, this._holdAudioChunks) : null;
2764
+ const player = this._holdAudioChunks && this._call && !(this._call instanceof chunkQD2ZY4UP_cjs.BufferingCall) ? new HoldAudioPlayer(this._call, this._holdAudioChunks) : null;
2747
2765
  player?.start();
2748
2766
  try {
2749
2767
  const args = JSON.parse(item["arguments"] ?? "{}");
@@ -2892,7 +2910,7 @@ var GeminiRealtime = class _GeminiRealtime {
2892
2910
  _toolDrainTimer = null;
2893
2911
  _lastAudioTime = 0;
2894
2912
  _holdAudioChunks = null;
2895
- _log = chunkXAOA3XFQ_cjs.NOOP_LOGGER;
2913
+ _log = chunkQD2ZY4UP_cjs.NOOP_LOGGER;
2896
2914
  constructor(options = {}) {
2897
2915
  this._apiKey = options.apiKey ?? process.env["GOOGLE_API_KEY"] ?? "";
2898
2916
  this._systemPrompt = options.systemPrompt ?? "";
@@ -2938,7 +2956,7 @@ var GeminiRealtime = class _GeminiRealtime {
2938
2956
  /** Open Live session (no CallSession). Audio deltas accumulate into BufferingCall until attach(). */
2939
2957
  async prewarm(tools) {
2940
2958
  if (tools) this._tools = tools;
2941
- this._call = new chunkXAOA3XFQ_cjs.BufferingCall();
2959
+ this._call = new chunkQD2ZY4UP_cjs.BufferingCall();
2942
2960
  this._closed = false;
2943
2961
  this._sentAudioChunks = 0;
2944
2962
  this._audioRemainder = Buffer.alloc(0);
@@ -2995,7 +3013,7 @@ var GeminiRealtime = class _GeminiRealtime {
2995
3013
  async attach(callSession) {
2996
3014
  const prev = this._call;
2997
3015
  this._call = callSession;
2998
- chunkXAOA3XFQ_cjs.attachBuffered(prev, callSession);
3016
+ chunkQD2ZY4UP_cjs.attachBuffered(prev, callSession);
2999
3017
  }
3000
3018
  async start(callSession, tools) {
3001
3019
  if (tools) this._tools = tools;
@@ -3004,8 +3022,8 @@ var GeminiRealtime = class _GeminiRealtime {
3004
3022
  }
3005
3023
  feedAudio(audio) {
3006
3024
  if (this._session && !this._closed) {
3007
- const pcm8k = chunkXAOA3XFQ_cjs.ulawToPcm16(audio);
3008
- const pcm16k = chunkXAOA3XFQ_cjs.resamplePcm16(pcm8k, 8e3, 16e3);
3025
+ const pcm8k = chunkQD2ZY4UP_cjs.ulawToPcm16(audio);
3026
+ const pcm16k = chunkQD2ZY4UP_cjs.resamplePcm16(pcm8k, 8e3, 16e3);
3009
3027
  this._session.sendRealtimeInput({
3010
3028
  audio: {
3011
3029
  data: Buffer.from(pcm16k).toString("base64"),
@@ -3049,7 +3067,7 @@ var GeminiRealtime = class _GeminiRealtime {
3049
3067
  t.function.parameters ?? { type: "object", properties: {} }
3050
3068
  )
3051
3069
  })) : [];
3052
- toolDefs.push(...chunkXAOA3XFQ_cjs.getBuiltinToolSchemas(this._builtinTools, "gemini"));
3070
+ toolDefs.push(...chunkQD2ZY4UP_cjs.getBuiltinToolSchemas(this._builtinTools, "gemini"));
3053
3071
  return toolDefs;
3054
3072
  }
3055
3073
  _handleMessage(msg) {
@@ -3109,8 +3127,8 @@ var GeminiRealtime = class _GeminiRealtime {
3109
3127
  _handleAudioData(b64Data) {
3110
3128
  if (!this._call) return;
3111
3129
  const pcm24k = Buffer.from(b64Data, "base64");
3112
- const pcm8k = chunkXAOA3XFQ_cjs.resamplePcm16(pcm24k, 24e3, 8e3);
3113
- const ulaw = chunkXAOA3XFQ_cjs.pcm16ToUlaw(pcm8k);
3130
+ const pcm8k = chunkQD2ZY4UP_cjs.resamplePcm16(pcm24k, 24e3, 8e3);
3131
+ const ulaw = chunkQD2ZY4UP_cjs.pcm16ToUlaw(pcm8k);
3114
3132
  const combined = Buffer.concat([this._audioRemainder, ulaw]);
3115
3133
  const chunkSize = 160;
3116
3134
  const fullEnd = Math.floor(combined.length / chunkSize) * chunkSize;
@@ -3153,7 +3171,7 @@ var GeminiRealtime = class _GeminiRealtime {
3153
3171
  const functionCalls = toolCall.functionCalls;
3154
3172
  if (!functionCalls) return;
3155
3173
  const responses = [];
3156
- const player = this._holdAudioChunks && this._call && !(this._call instanceof chunkXAOA3XFQ_cjs.BufferingCall) ? new HoldAudioPlayer(this._call, this._holdAudioChunks) : null;
3174
+ const player = this._holdAudioChunks && this._call && !(this._call instanceof chunkQD2ZY4UP_cjs.BufferingCall) ? new HoldAudioPlayer(this._call, this._holdAudioChunks) : null;
3157
3175
  player?.start();
3158
3176
  try {
3159
3177
  for (const fc of functionCalls) {
@@ -3161,8 +3179,8 @@ var GeminiRealtime = class _GeminiRealtime {
3161
3179
  const fcId = fc.id ?? "";
3162
3180
  const args = fc.args ?? {};
3163
3181
  this._log.info({ tool: name, args }, "Tool call: %s", name);
3164
- if (chunkXAOA3XFQ_cjs.BUILTIN_TOOL_NAMES.has(name) && this._call && !(this._call instanceof chunkXAOA3XFQ_cjs.BufferingCall)) {
3165
- const result = await chunkXAOA3XFQ_cjs.executeBuiltinTool(
3182
+ if (chunkQD2ZY4UP_cjs.BUILTIN_TOOL_NAMES.has(name) && this._call && !(this._call instanceof chunkQD2ZY4UP_cjs.BufferingCall)) {
3183
+ const result = await chunkQD2ZY4UP_cjs.executeBuiltinTool(
3166
3184
  name,
3167
3185
  args,
3168
3186
  this._call
@@ -3177,9 +3195,9 @@ var GeminiRealtime = class _GeminiRealtime {
3177
3195
  continue;
3178
3196
  }
3179
3197
  }
3180
- if (chunkXAOA3XFQ_cjs.BUILTIN_TOOL_NAMES.has(name) && this._call instanceof chunkXAOA3XFQ_cjs.BufferingCall) {
3198
+ if (chunkQD2ZY4UP_cjs.BUILTIN_TOOL_NAMES.has(name) && this._call instanceof chunkQD2ZY4UP_cjs.BufferingCall) {
3181
3199
  this._log.warn("Builtin tool %s called before answer \u2014 deferring", name);
3182
- responses.push({ id: fcId, name, response: { result: chunkXAOA3XFQ_cjs.CALL_NOT_READY_RESULT } });
3200
+ responses.push({ id: fcId, name, response: { result: chunkQD2ZY4UP_cjs.CALL_NOT_READY_RESULT } });
3183
3201
  continue;
3184
3202
  }
3185
3203
  if (!this._tools || !this._tools.has(name)) {
@@ -3224,7 +3242,7 @@ var GeminiRealtime = class _GeminiRealtime {
3224
3242
  // src/agent/pipeline/stt/deepgram-stt.ts
3225
3243
  var DeepgramSTT = class {
3226
3244
  _options;
3227
- _log = chunkXAOA3XFQ_cjs.NOOP_LOGGER;
3245
+ _log = chunkQD2ZY4UP_cjs.NOOP_LOGGER;
3228
3246
  get provider() {
3229
3247
  return "deepgram";
3230
3248
  }
@@ -3351,7 +3369,7 @@ var DeepgramSTT = class {
3351
3369
  // src/agent/pipeline/tts/elevenlabs-tts.ts
3352
3370
  var ElevenLabsTTS = class {
3353
3371
  _options;
3354
- _log = chunkXAOA3XFQ_cjs.NOOP_LOGGER;
3372
+ _log = chunkQD2ZY4UP_cjs.NOOP_LOGGER;
3355
3373
  get provider() {
3356
3374
  return "elevenlabs";
3357
3375
  }
@@ -4097,47 +4115,47 @@ function mcpServerHTTP(options) {
4097
4115
 
4098
4116
  Object.defineProperty(exports, "BUILTIN_TOOL_NAMES", {
4099
4117
  enumerable: true,
4100
- get: function () { return chunkXAOA3XFQ_cjs.BUILTIN_TOOL_NAMES; }
4118
+ get: function () { return chunkQD2ZY4UP_cjs.BUILTIN_TOOL_NAMES; }
4101
4119
  });
4102
4120
  Object.defineProperty(exports, "BuiltinTool", {
4103
4121
  enumerable: true,
4104
- get: function () { return chunkXAOA3XFQ_cjs.BuiltinTool; }
4122
+ get: function () { return chunkQD2ZY4UP_cjs.BuiltinTool; }
4105
4123
  });
4106
4124
  Object.defineProperty(exports, "DECODE_TABLE", {
4107
4125
  enumerable: true,
4108
- get: function () { return chunkXAOA3XFQ_cjs.DECODE_TABLE; }
4126
+ get: function () { return chunkQD2ZY4UP_cjs.DECODE_TABLE; }
4109
4127
  });
4110
4128
  Object.defineProperty(exports, "createAgentLogger", {
4111
4129
  enumerable: true,
4112
- get: function () { return chunkXAOA3XFQ_cjs.createAgentLogger; }
4130
+ get: function () { return chunkQD2ZY4UP_cjs.createAgentLogger; }
4113
4131
  });
4114
4132
  Object.defineProperty(exports, "createPipelineLogger", {
4115
4133
  enumerable: true,
4116
- get: function () { return chunkXAOA3XFQ_cjs.createPipelineLogger; }
4134
+ get: function () { return chunkQD2ZY4UP_cjs.createPipelineLogger; }
4117
4135
  });
4118
4136
  Object.defineProperty(exports, "executeBuiltinTool", {
4119
4137
  enumerable: true,
4120
- get: function () { return chunkXAOA3XFQ_cjs.executeBuiltinTool; }
4138
+ get: function () { return chunkQD2ZY4UP_cjs.executeBuiltinTool; }
4121
4139
  });
4122
4140
  Object.defineProperty(exports, "getBuiltinToolSchemas", {
4123
4141
  enumerable: true,
4124
- get: function () { return chunkXAOA3XFQ_cjs.getBuiltinToolSchemas; }
4142
+ get: function () { return chunkQD2ZY4UP_cjs.getBuiltinToolSchemas; }
4125
4143
  });
4126
4144
  Object.defineProperty(exports, "isBuiltinTool", {
4127
4145
  enumerable: true,
4128
- get: function () { return chunkXAOA3XFQ_cjs.isBuiltinTool; }
4146
+ get: function () { return chunkQD2ZY4UP_cjs.isBuiltinTool; }
4129
4147
  });
4130
4148
  Object.defineProperty(exports, "pcm16ToUlaw", {
4131
4149
  enumerable: true,
4132
- get: function () { return chunkXAOA3XFQ_cjs.pcm16ToUlaw; }
4150
+ get: function () { return chunkQD2ZY4UP_cjs.pcm16ToUlaw; }
4133
4151
  });
4134
4152
  Object.defineProperty(exports, "resamplePcm16", {
4135
4153
  enumerable: true,
4136
- get: function () { return chunkXAOA3XFQ_cjs.resamplePcm16; }
4154
+ get: function () { return chunkQD2ZY4UP_cjs.resamplePcm16; }
4137
4155
  });
4138
4156
  Object.defineProperty(exports, "ulawToPcm16", {
4139
4157
  enumerable: true,
4140
- get: function () { return chunkXAOA3XFQ_cjs.ulawToPcm16; }
4158
+ get: function () { return chunkQD2ZY4UP_cjs.ulawToPcm16; }
4141
4159
  });
4142
4160
  exports.AnthropicLLM = AnthropicLLM;
4143
4161
  exports.AudioRecorder = AudioRecorder;