@teamlearners/clawops 0.22.0 → 0.24.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 chunkCJ2LJZDQ_cjs = require('../chunk-CJ2LJZDQ.cjs');
4
- var pino = require('pino');
3
+ var chunkLUA53NPZ_cjs = require('../chunk-LUA53NPZ.cjs');
4
+ var chunkU4UFTVLX_cjs = require('../chunk-U4UFTVLX.cjs');
5
5
  var fs = require('fs');
6
6
  var path = require('path');
7
7
  var os = require('os');
@@ -26,361 +26,10 @@ function _interopNamespace(e) {
26
26
  return Object.freeze(n);
27
27
  }
28
28
 
29
- var pino__default = /*#__PURE__*/_interopDefault(pino);
30
29
  var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
31
30
  var path__namespace = /*#__PURE__*/_interopNamespace(path);
32
31
  var os__default = /*#__PURE__*/_interopDefault(os);
33
32
 
34
- // src/agent/audio.ts
35
- var _BIAS = 132;
36
- var _CLIP = 32635;
37
- var DECODE_TABLE = [
38
- -32124,
39
- -31100,
40
- -30076,
41
- -29052,
42
- -28028,
43
- -27004,
44
- -25980,
45
- -24956,
46
- -23932,
47
- -22908,
48
- -21884,
49
- -20860,
50
- -19836,
51
- -18812,
52
- -17788,
53
- -16764,
54
- -15996,
55
- -15484,
56
- -14972,
57
- -14460,
58
- -13948,
59
- -13436,
60
- -12924,
61
- -12412,
62
- -11900,
63
- -11388,
64
- -10876,
65
- -10364,
66
- -9852,
67
- -9340,
68
- -8828,
69
- -8316,
70
- -7932,
71
- -7676,
72
- -7420,
73
- -7164,
74
- -6908,
75
- -6652,
76
- -6396,
77
- -6140,
78
- -5884,
79
- -5628,
80
- -5372,
81
- -5116,
82
- -4860,
83
- -4604,
84
- -4348,
85
- -4092,
86
- -3900,
87
- -3772,
88
- -3644,
89
- -3516,
90
- -3388,
91
- -3260,
92
- -3132,
93
- -3004,
94
- -2876,
95
- -2748,
96
- -2620,
97
- -2492,
98
- -2364,
99
- -2236,
100
- -2108,
101
- -1980,
102
- -1884,
103
- -1820,
104
- -1756,
105
- -1692,
106
- -1628,
107
- -1564,
108
- -1500,
109
- -1436,
110
- -1372,
111
- -1308,
112
- -1244,
113
- -1180,
114
- -1116,
115
- -1052,
116
- -988,
117
- -924,
118
- -876,
119
- -844,
120
- -812,
121
- -780,
122
- -748,
123
- -716,
124
- -684,
125
- -652,
126
- -620,
127
- -588,
128
- -556,
129
- -524,
130
- -492,
131
- -460,
132
- -428,
133
- -396,
134
- -372,
135
- -356,
136
- -340,
137
- -324,
138
- -308,
139
- -292,
140
- -276,
141
- -260,
142
- -244,
143
- -228,
144
- -212,
145
- -196,
146
- -180,
147
- -164,
148
- -148,
149
- -132,
150
- -120,
151
- -112,
152
- -104,
153
- -96,
154
- -88,
155
- -80,
156
- -72,
157
- -64,
158
- -56,
159
- -48,
160
- -40,
161
- -32,
162
- -24,
163
- -16,
164
- -8,
165
- 0,
166
- 32124,
167
- 31100,
168
- 30076,
169
- 29052,
170
- 28028,
171
- 27004,
172
- 25980,
173
- 24956,
174
- 23932,
175
- 22908,
176
- 21884,
177
- 20860,
178
- 19836,
179
- 18812,
180
- 17788,
181
- 16764,
182
- 15996,
183
- 15484,
184
- 14972,
185
- 14460,
186
- 13948,
187
- 13436,
188
- 12924,
189
- 12412,
190
- 11900,
191
- 11388,
192
- 10876,
193
- 10364,
194
- 9852,
195
- 9340,
196
- 8828,
197
- 8316,
198
- 7932,
199
- 7676,
200
- 7420,
201
- 7164,
202
- 6908,
203
- 6652,
204
- 6396,
205
- 6140,
206
- 5884,
207
- 5628,
208
- 5372,
209
- 5116,
210
- 4860,
211
- 4604,
212
- 4348,
213
- 4092,
214
- 3900,
215
- 3772,
216
- 3644,
217
- 3516,
218
- 3388,
219
- 3260,
220
- 3132,
221
- 3004,
222
- 2876,
223
- 2748,
224
- 2620,
225
- 2492,
226
- 2364,
227
- 2236,
228
- 2108,
229
- 1980,
230
- 1884,
231
- 1820,
232
- 1756,
233
- 1692,
234
- 1628,
235
- 1564,
236
- 1500,
237
- 1436,
238
- 1372,
239
- 1308,
240
- 1244,
241
- 1180,
242
- 1116,
243
- 1052,
244
- 988,
245
- 924,
246
- 876,
247
- 844,
248
- 812,
249
- 780,
250
- 748,
251
- 716,
252
- 684,
253
- 652,
254
- 620,
255
- 588,
256
- 556,
257
- 524,
258
- 492,
259
- 460,
260
- 428,
261
- 396,
262
- 372,
263
- 356,
264
- 340,
265
- 324,
266
- 308,
267
- 292,
268
- 276,
269
- 260,
270
- 244,
271
- 228,
272
- 212,
273
- 196,
274
- 180,
275
- 164,
276
- 148,
277
- 132,
278
- 120,
279
- 112,
280
- 104,
281
- 96,
282
- 88,
283
- 80,
284
- 72,
285
- 64,
286
- 56,
287
- 48,
288
- 40,
289
- 32,
290
- 24,
291
- 16,
292
- 8,
293
- 0
294
- ];
295
- function encodeUlawSample(sample) {
296
- let sign = 0;
297
- if (sample < 0) {
298
- sign = 128;
299
- sample = -sample;
300
- }
301
- if (sample > _CLIP) {
302
- sample = _CLIP;
303
- }
304
- sample += _BIAS;
305
- let exponent = 7;
306
- const expValues = [16384, 8192, 4096, 2048, 1024, 512, 256];
307
- for (const expVal of expValues) {
308
- if (sample >= expVal) {
309
- break;
310
- }
311
- exponent -= 1;
312
- }
313
- const mantissa = sample >> exponent + 3 & 15;
314
- return ~(sign | exponent << 4 | mantissa) & 255;
315
- }
316
- function pcm16ToUlaw(pcm) {
317
- if (!pcm.length) return Buffer.alloc(0);
318
- const nSamples = pcm.length >> 1;
319
- const out = Buffer.alloc(nSamples);
320
- for (let i = 0; i < nSamples; i++) {
321
- const sample = pcm.readInt16LE(i * 2);
322
- out[i] = encodeUlawSample(sample);
323
- }
324
- return out;
325
- }
326
- function ulawToPcm16(ulaw) {
327
- if (!ulaw.length) return Buffer.alloc(0);
328
- const out = Buffer.alloc(ulaw.length * 2);
329
- for (let i = 0; i < ulaw.length; i++) {
330
- out.writeInt16LE(DECODE_TABLE[ulaw[i]], i * 2);
331
- }
332
- return out;
333
- }
334
- function applyPcm16Gain(pcm, gain) {
335
- if (!pcm.length) return Buffer.alloc(0);
336
- if (gain === 1) return pcm;
337
- if (!Number.isFinite(gain) || gain < 0) {
338
- throw new Error("gain must be a finite number >= 0");
339
- }
340
- const nSamples = pcm.length >> 1;
341
- const out = Buffer.alloc(nSamples * 2);
342
- for (let i = 0; i < nSamples; i++) {
343
- let value = Math.round(pcm.readInt16LE(i * 2) * gain);
344
- if (value > 32767) value = 32767;
345
- else if (value < -32768) value = -32768;
346
- out.writeInt16LE(value, i * 2);
347
- }
348
- return out;
349
- }
350
- function applyUlawGain(ulaw, gain) {
351
- if (!ulaw.length) return Buffer.alloc(0);
352
- if (gain === 1) return ulaw;
353
- return pcm16ToUlaw(applyPcm16Gain(ulawToPcm16(ulaw), gain));
354
- }
355
- function resamplePcm16(pcm, fromRate, toRate) {
356
- if (fromRate === toRate || !pcm.length) return pcm;
357
- const nSamples = pcm.length >> 1;
358
- const ratio = fromRate / toRate;
359
- const outLen = Math.floor(nSamples / ratio);
360
- const out = Buffer.alloc(outLen * 2);
361
- for (let i = 0; i < outLen; i++) {
362
- const srcPos = i * ratio;
363
- const idx = Math.floor(srcPos);
364
- const frac = srcPos - idx;
365
- let val;
366
- if (idx + 1 < nSamples) {
367
- val = pcm.readInt16LE(idx * 2) * (1 - frac) + pcm.readInt16LE((idx + 1) * 2) * frac;
368
- } else {
369
- val = pcm.readInt16LE(idx * 2);
370
- }
371
- out.writeInt16LE(Math.round(val), i * 2);
372
- }
373
- return out;
374
- }
375
- var DEFAULT_LOGGER = pino__default.default({ name: "clawops.agent" });
376
- var NOOP_LOGGER = pino__default.default({ level: "silent" });
377
- function createAgentLogger(userLogger) {
378
- return userLogger ?? DEFAULT_LOGGER;
379
- }
380
- function createPipelineLogger(parent) {
381
- return parent.child({ module: "pipeline" });
382
- }
383
-
384
33
  // src/agent/control-ws.ts
385
34
  var INITIAL_RECONNECT_DELAY = 1e3;
386
35
  var MAX_RECONNECT_DELAY = 3e4;
@@ -410,7 +59,7 @@ var ControlWebSocket = class {
410
59
  _closed = false;
411
60
  _connectedResolve = null;
412
61
  _connectedPromise;
413
- _log = NOOP_LOGGER;
62
+ _log = chunkU4UFTVLX_cjs.NOOP_LOGGER;
414
63
  _pingTimer = null;
415
64
  setLogger(logger) {
416
65
  this._log = logger;
@@ -575,7 +224,7 @@ var ControlWebSocket = class {
575
224
  var MCPClient = class {
576
225
  _servers = /* @__PURE__ */ new Map();
577
226
  _clients = /* @__PURE__ */ new Map();
578
- _log = NOOP_LOGGER;
227
+ _log = chunkU4UFTVLX_cjs.NOOP_LOGGER;
579
228
  setLogger(logger) {
580
229
  this._log = logger;
581
230
  }
@@ -717,7 +366,7 @@ var MediaWebSocket = class {
717
366
  _onClose = null;
718
367
  _onDtmf = null;
719
368
  _markWaiters = /* @__PURE__ */ new Map();
720
- _log = NOOP_LOGGER;
369
+ _log = chunkU4UFTVLX_cjs.NOOP_LOGGER;
721
370
  setLogger(logger) {
722
371
  this._log = logger;
723
372
  }
@@ -943,7 +592,7 @@ var AudioRecorder = class {
943
592
  _started = false;
944
593
  _baseTs = null;
945
594
  _outCursor = 0;
946
- _log = NOOP_LOGGER;
595
+ _log = chunkU4UFTVLX_cjs.NOOP_LOGGER;
947
596
  setLogger(logger) {
948
597
  this._log = logger;
949
598
  }
@@ -1079,7 +728,7 @@ var MAX_ERROR_MESSAGE_LENGTH = 200;
1079
728
  function getSdkInfo() {
1080
729
  return {
1081
730
  name: "clawops-node",
1082
- version: chunkCJ2LJZDQ_cjs.VERSION,
731
+ version: chunkLUA53NPZ_cjs.VERSION,
1083
732
  runtime: `node/${process.versions.node}`,
1084
733
  os: `${process.platform}/${os__default.default.arch()}`
1085
734
  };
@@ -1124,10 +773,21 @@ var CallSession = class {
1124
773
  _transferFn = null;
1125
774
  /** @internal */
1126
775
  _isTransportConnected = null;
776
+ /**
777
+ * @internal Media WS playout 마커 훅. LiveKit(`ClawOpsAudioOutput`)이 재생 완료
778
+ * 판정(mark echo)과 barge-in 절단 위치 계산에 쓴다. 다른 세션 타입은 읽지 않는다.
779
+ * prewarm 중(BufferingCall)에는 바인딩되지 않아 null 이다.
780
+ */
781
+ /** @internal */
782
+ _sendMark = null;
783
+ /** @internal */
784
+ _waitForMark = null;
785
+ /** @internal */
786
+ _flushTransport = null;
1127
787
  _dtmfCollectorActive = false;
1128
788
  _dtmfResolvers = [];
1129
789
  _dtmfBuffer = [];
1130
- _log = NOOP_LOGGER;
790
+ _log = chunkU4UFTVLX_cjs.NOOP_LOGGER;
1131
791
  _handlers = /* @__PURE__ */ new Map();
1132
792
  _endedPromise;
1133
793
  _resolveEnded;
@@ -1279,7 +939,9 @@ var CallSession = class {
1279
939
  *
1280
940
  * destinationType='pstn' (default): `to` is a phone number dialed via carrier.
1281
941
  * destinationType='sip': `to` is a SIP URI (e.g. `sip:user@host`) connected
1282
- * directly to a SIP endpoint without going through the PSTN carrier.
942
+ * directly to a SIP endpoint without going through the PSTN carrier. Requires the
943
+ * account to have an active `sip_trunk` add-on; otherwise the transfer fails and
944
+ * the call continues with the AI (result `{ status: 'failed', ... }`).
1283
945
  */
1284
946
  async transfer(to, options) {
1285
947
  if (!this._transferFn) {
@@ -1335,35 +997,6 @@ var CallSession = class {
1335
997
  }
1336
998
  }
1337
999
  };
1338
-
1339
- // src/agent/builtin-tool.ts
1340
- var BuiltinTool = /* @__PURE__ */ ((BuiltinTool2) => {
1341
- BuiltinTool2["HANG_UP"] = "hang_up";
1342
- BuiltinTool2["COLLECT_DTMF"] = "collect_dtmf";
1343
- BuiltinTool2["SEND_DTMF"] = "send_dtmf";
1344
- BuiltinTool2["TRANSFER_CALL"] = "transfer_call";
1345
- BuiltinTool2["ALL"] = "all";
1346
- BuiltinTool2["NONE"] = "none";
1347
- return BuiltinTool2;
1348
- })(BuiltinTool || {});
1349
- var INDIVIDUAL_TOOLS = /* @__PURE__ */ new Set([
1350
- "hang_up" /* HANG_UP */,
1351
- "collect_dtmf" /* COLLECT_DTMF */,
1352
- "send_dtmf" /* SEND_DTMF */,
1353
- "transfer_call" /* TRANSFER_CALL */
1354
- ]);
1355
- function resolveBuiltinTools(value) {
1356
- if (typeof value === "string") {
1357
- if (value === "all" /* ALL */) {
1358
- return new Set(INDIVIDUAL_TOOLS);
1359
- }
1360
- if (value === "none" /* NONE */) {
1361
- return /* @__PURE__ */ new Set();
1362
- }
1363
- return /* @__PURE__ */ new Set([value]);
1364
- }
1365
- return new Set(value.filter((t) => INDIVIDUAL_TOOLS.has(t)));
1366
- }
1367
1000
  var CHUNK_SIZE = 160;
1368
1001
  var SAMPLE_RATE2 = 8e3;
1369
1002
  var BELL_PARTIALS = [
@@ -1448,7 +1081,7 @@ function generateComfortTone(volume = 0.12) {
1448
1081
  }
1449
1082
  }
1450
1083
  const pcm = int16ArrayToBuffer(concatInt16Arrays(...parts));
1451
- const ulaw = pcm16ToUlaw(pcm);
1084
+ const ulaw = chunkU4UFTVLX_cjs.pcm16ToUlaw(pcm);
1452
1085
  const chunks = [];
1453
1086
  for (let i = 0; i < ulaw.length; i += CHUNK_SIZE) {
1454
1087
  chunks.push(ulaw.subarray(i, i + CHUNK_SIZE));
@@ -1505,9 +1138,9 @@ function loadHoldAudio(source) {
1505
1138
  pcmData = mono;
1506
1139
  }
1507
1140
  if (sampleRate !== SAMPLE_RATE2) {
1508
- pcmData = resamplePcm16(pcmData, sampleRate, SAMPLE_RATE2);
1141
+ pcmData = chunkU4UFTVLX_cjs.resamplePcm16(pcmData, sampleRate, SAMPLE_RATE2);
1509
1142
  }
1510
- const ulaw = pcm16ToUlaw(pcmData);
1143
+ const ulaw = chunkU4UFTVLX_cjs.pcm16ToUlaw(pcmData);
1511
1144
  const chunks = [];
1512
1145
  for (let i = 0; i < ulaw.length; i += CHUNK_SIZE) {
1513
1146
  chunks.push(ulaw.subarray(i, i + CHUNK_SIZE));
@@ -1771,25 +1404,28 @@ var ClawOpsAgent = class _ClawOpsAgent {
1771
1404
  /** prewarm 세션이 실제 CallSession 에 attach 완료된 callId. attached 이후의 stop() 은 정상 종료 경로가 책임진다. */
1772
1405
  _prewarmAttached = /* @__PURE__ */ new Set();
1773
1406
  _prewarmEnabled;
1407
+ /** 모든 발신에 적용되는 AMD default. call() 인자로 호출별 override 가능. */
1408
+ _machineDetection;
1774
1409
  constructor(options) {
1775
1410
  this._apiKey = options.apiKey ?? process.env["CLAWOPS_API_KEY"] ?? "";
1776
1411
  this._accountId = options.accountId ?? process.env["CLAWOPS_ACCOUNT_ID"] ?? "";
1777
- this._baseUrl = options.baseUrl ?? chunkCJ2LJZDQ_cjs.DEFAULT_BASE_URL;
1412
+ this._baseUrl = options.baseUrl ?? chunkLUA53NPZ_cjs.DEFAULT_BASE_URL;
1778
1413
  this._fromNumber = options.from;
1779
1414
  this._session = options.session;
1780
1415
  this._recording = options.recording ?? false;
1781
1416
  this._recordingPath = options.recordingPath ?? "./recordings";
1782
1417
  this._mcpServers = options.mcpServers ?? [];
1783
- this._builtinTools = resolveBuiltinTools(options.builtinTools ?? "all" /* ALL */);
1418
+ this._builtinTools = chunkU4UFTVLX_cjs.resolveBuiltinTools(options.builtinTools ?? "all" /* ALL */);
1784
1419
  this._passiveDtmfDebounceMs = options.passiveDtmfDebounceMs ?? 500;
1785
1420
  this._rxGain = _ClawOpsAgent._validateGain("rxGain", options.rxGain ?? 1);
1786
1421
  this._txGain = _ClawOpsAgent._validateGain("txGain", options.txGain ?? 1);
1787
1422
  this._prewarmEnabled = options.prewarmEnabled ?? true;
1423
+ this._machineDetection = options.machineDetection;
1788
1424
  if (options.tracing) {
1789
1425
  setTracingConfig(options.tracing);
1790
1426
  }
1791
- this._log = createAgentLogger(options.logger);
1792
- this._pipelineLog = createPipelineLogger(this._log);
1427
+ this._log = chunkU4UFTVLX_cjs.createAgentLogger(options.logger);
1428
+ this._pipelineLog = chunkU4UFTVLX_cjs.createPipelineLogger(this._log);
1793
1429
  this._isPipelineSession = "_stt" in this._session && "_llm" in this._session;
1794
1430
  if (options.toolConfig?.holdAudio) {
1795
1431
  this._holdAudioChunks = loadHoldAudio(options.toolConfig.holdAudio);
@@ -1797,7 +1433,7 @@ var ClawOpsAgent = class _ClawOpsAgent {
1797
1433
  }
1798
1434
  static _validateGain(name, gain) {
1799
1435
  if (typeof gain !== "number" || !Number.isFinite(gain) || gain < 0) {
1800
- throw new chunkCJ2LJZDQ_cjs.AgentError(`${name}=${gain} must be a finite number >= 0`);
1436
+ throw new chunkLUA53NPZ_cjs.AgentError(`${name}=${gain} must be a finite number >= 0`);
1801
1437
  }
1802
1438
  return gain;
1803
1439
  }
@@ -1811,7 +1447,7 @@ var ClawOpsAgent = class _ClawOpsAgent {
1811
1447
  tool(nameOrTool, description, parameters, handler) {
1812
1448
  if (typeof nameOrTool === "string") {
1813
1449
  if (!description || !parameters || !handler) {
1814
- throw new chunkCJ2LJZDQ_cjs.AgentError(
1450
+ throw new chunkLUA53NPZ_cjs.AgentError(
1815
1451
  "tool(name, description, parameters, handler) requires all arguments."
1816
1452
  );
1817
1453
  }
@@ -1847,10 +1483,10 @@ var ClawOpsAgent = class _ClawOpsAgent {
1847
1483
  async connect() {
1848
1484
  if (this._controlWs) return;
1849
1485
  if (!this._apiKey) {
1850
- throw new chunkCJ2LJZDQ_cjs.AgentError("API key is required. Set CLAWOPS_API_KEY or pass apiKey option.");
1486
+ throw new chunkLUA53NPZ_cjs.AgentError("API key is required. Set CLAWOPS_API_KEY or pass apiKey option.");
1851
1487
  }
1852
1488
  if (!this._accountId) {
1853
- throw new chunkCJ2LJZDQ_cjs.AgentError(
1489
+ throw new chunkLUA53NPZ_cjs.AgentError(
1854
1490
  "Account ID is required. Set CLAWOPS_ACCOUNT_ID or pass accountId option."
1855
1491
  );
1856
1492
  }
@@ -1874,7 +1510,7 @@ var ClawOpsAgent = class _ClawOpsAgent {
1874
1510
  } catch {
1875
1511
  }
1876
1512
  } catch (err) {
1877
- throw new chunkCJ2LJZDQ_cjs.AgentConnectionError(
1513
+ throw new chunkLUA53NPZ_cjs.AgentConnectionError(
1878
1514
  `Failed to connect to ClawOps: ${err instanceof Error ? err.message : String(err)}`
1879
1515
  );
1880
1516
  }
@@ -1913,6 +1549,8 @@ var ClawOpsAgent = class _ClawOpsAgent {
1913
1549
  *
1914
1550
  * @param options.machineDetection 자동응답기/음성사서함 감지(AMD).
1915
1551
  * `'Enable'`=감지 후 `AnsweredBy` 통보(통화 계속), `'Hangup'`=음성사서함 감지 시 자동 종료.
1552
+ * 미지정 시 인스턴스 default(생성자의 `machineDetection`)를 따른다.
1553
+ * 우선순위: 호출 인자 > 인스턴스 default > 비활성.
1916
1554
  */
1917
1555
  async call(to, options) {
1918
1556
  await this.connect();
@@ -1922,8 +1560,9 @@ var ClawOpsAgent = class _ClawOpsAgent {
1922
1560
  From: this._fromNumber,
1923
1561
  Timeout: options?.timeout ?? 60
1924
1562
  };
1925
- if (options?.machineDetection) {
1926
- body["MachineDetection"] = options.machineDetection;
1563
+ const effectiveMd = options?.machineDetection ?? this._machineDetection;
1564
+ if (effectiveMd) {
1565
+ body["MachineDetection"] = effectiveMd;
1927
1566
  }
1928
1567
  const resp = await fetch(url, {
1929
1568
  method: "POST",
@@ -1935,7 +1574,7 @@ var ClawOpsAgent = class _ClawOpsAgent {
1935
1574
  });
1936
1575
  if (resp.status !== 201) {
1937
1576
  const error = await resp.json();
1938
- throw new chunkCJ2LJZDQ_cjs.AgentError(`\uBC1C\uC2E0 \uC2E4\uD328 (${resp.status}): ${error["error"] ?? ""}`);
1577
+ throw new chunkLUA53NPZ_cjs.AgentError(`\uBC1C\uC2E0 \uC2E4\uD328 (${resp.status}): ${error["error"] ?? ""}`);
1939
1578
  }
1940
1579
  const data = await resp.json();
1941
1580
  const callSession = new CallSession({
@@ -2194,9 +1833,9 @@ var ClawOpsAgent = class _ClawOpsAgent {
2194
1833
  let latestMediaTs = 0;
2195
1834
  session._bindTransport(
2196
1835
  (audio) => {
2197
- const gained = applyUlawGain(audio, this._txGain);
1836
+ const gained = chunkU4UFTVLX_cjs.applyUlawGain(audio, this._txGain);
2198
1837
  if (recorder) {
2199
- recorder.writeOutbound(ulawToPcm16(gained), latestMediaTs);
1838
+ recorder.writeOutbound(chunkU4UFTVLX_cjs.ulawToPcm16(gained), latestMediaTs);
2200
1839
  }
2201
1840
  mediaWs.sendAudio(gained.toString("base64"));
2202
1841
  session.recordFirstResponse();
@@ -2218,6 +1857,9 @@ var ClawOpsAgent = class _ClawOpsAgent {
2218
1857
  () => mediaWs.isConnected
2219
1858
  );
2220
1859
  session._transferFn = (params) => this._controlWs.requestTransfer(session.callId, params);
1860
+ session._sendMark = (name) => mediaWs.sendMark(name);
1861
+ session._waitForMark = (name, timeoutMs) => mediaWs.waitForMark(name, timeoutMs);
1862
+ session._flushTransport = () => mediaWs.flush();
2221
1863
  const sessionHandler = this._session;
2222
1864
  if ("setToolRegistry" in sessionHandler && typeof sessionHandler.setToolRegistry === "function") {
2223
1865
  sessionHandler.setToolRegistry(sessionTools);
@@ -2237,9 +1879,9 @@ var ClawOpsAgent = class _ClawOpsAgent {
2237
1879
  this._callSessions.set(session.callId, sessionHandler);
2238
1880
  mediaWs.onAudio((ulawAudio, timestamp) => {
2239
1881
  latestMediaTs = timestamp;
2240
- const gained = applyUlawGain(ulawAudio, this._rxGain);
1882
+ const gained = chunkU4UFTVLX_cjs.applyUlawGain(ulawAudio, this._rxGain);
2241
1883
  if (recorder) {
2242
- recorder.writeInbound(ulawToPcm16(gained), timestamp);
1884
+ recorder.writeInbound(chunkU4UFTVLX_cjs.ulawToPcm16(gained), timestamp);
2243
1885
  }
2244
1886
  if (sessionHandler) {
2245
1887
  sessionHandler.feedAudio(gained, timestamp);
@@ -2333,232 +1975,6 @@ var ClawOpsAgent = class _ClawOpsAgent {
2333
1975
  }
2334
1976
  };
2335
1977
 
2336
- // src/agent/pipeline/builtin-tool-schemas.ts
2337
- var HANG_UP = {
2338
- name: "hang_up",
2339
- description: "End the phone call. Use when the conversation is finished or the caller says goodbye.",
2340
- parameters: { type: "object", properties: {} }
2341
- };
2342
- var COLLECT_DTMF = {
2343
- name: "collect_dtmf",
2344
- description: "\uC0AC\uC6A9\uC790\uB85C\uBD80\uD130 DTMF(\uC804\uD654 \uD0A4\uD328\uB4DC) \uC785\uB825\uC744 \uC218\uC9D1\uD569\uB2C8\uB2E4. \uBC18\uB4DC\uC2DC \uC0AC\uC6A9\uC790\uC5D0\uAC8C \uBB34\uC5C7\uC744 \uC785\uB825\uD574\uC57C \uD558\uB294\uC9C0 \uC548\uB0B4\uD55C \uD6C4 \uD638\uCD9C\uD558\uC138\uC694.",
2345
- parameters: {
2346
- type: "object",
2347
- properties: {
2348
- max_digits: { type: "integer", description: "\uC218\uC9D1\uD560 \uCD5C\uB300 \uC790\uB9BF\uC218" },
2349
- finish_on_key: { type: "string", description: "\uC785\uB825 \uC885\uB8CC \uD0A4 (\uAE30\uBCF8: #)" },
2350
- timeout: { type: "integer", description: "\uC785\uB825 \uB300\uAE30 \uC2DC\uAC04(\uCD08, \uAE30\uBCF8: 5)" }
2351
- },
2352
- required: ["max_digits"]
2353
- }
2354
- };
2355
- var SEND_DTMF = {
2356
- name: "send_dtmf",
2357
- description: "DTMF \uC2E0\uD638\uB97C \uC804\uC1A1\uD569\uB2C8\uB2E4. ARS \uBA54\uB274 \uD0D0\uC0C9\uC774\uB098 \uB0B4\uC120\uBC88\uD638 \uC785\uB825 \uC2DC \uC0AC\uC6A9\uD569\uB2C8\uB2E4.",
2358
- parameters: {
2359
- type: "object",
2360
- properties: {
2361
- digits: {
2362
- type: "string",
2363
- description: "\uC804\uC1A1\uD560 \uBC88\uD638 (0-9, *, #). 'w'\uB294 500ms \uB300\uAE30, 'W'\uB294 1000ms \uB300\uAE30. \uC608: '1', '1234#', '1w2'"
2364
- }
2365
- },
2366
- required: ["digits"]
2367
- }
2368
- };
2369
- var TRANSFER_CALL = {
2370
- name: "transfer_call",
2371
- description: "Transfer the current call to another phone number or SIP endpoint. Use for blind transfer (direct handoff) or warm transfer (with whisper message to the target).",
2372
- parameters: {
2373
- type: "object",
2374
- properties: {
2375
- to: { type: "string", description: "Transfer destination. A phone number when destination_type is 'pstn', or a SIP URI (e.g. 'sip:user@host') when destination_type is 'sip'." },
2376
- destination_type: { type: "string", enum: ["pstn", "sip"], description: "pstn: dial a phone number via carrier (default). sip: connect directly to a SIP endpoint (no carrier/PSTN)." },
2377
- mode: { type: "string", enum: ["blind", "warm"], description: "blind: direct transfer (default), warm: play whisper to target first" },
2378
- after_transfer: { type: "string", enum: ["terminate", "return"], description: "terminate: end AI session (default), return: AI resumes after transfer ends" },
2379
- whisper: { type: "string", description: "Message to speak to transfer target before connecting customer (warm mode only)" },
2380
- caller_id: { type: "string", description: "Override caller ID for the transfer leg" },
2381
- timeout: { type: "integer", description: "Seconds to wait for transfer target to answer (default 30)" }
2382
- },
2383
- required: ["to"]
2384
- }
2385
- };
2386
- var TOOL_MAP = /* @__PURE__ */ new Map([
2387
- ["hang_up" /* HANG_UP */, HANG_UP],
2388
- ["collect_dtmf" /* COLLECT_DTMF */, COLLECT_DTMF],
2389
- ["send_dtmf" /* SEND_DTMF */, SEND_DTMF],
2390
- ["transfer_call" /* TRANSFER_CALL */, TRANSFER_CALL]
2391
- ]);
2392
- var BUILTIN_TOOL_NAMES = new Set(
2393
- Array.from(TOOL_MAP.values()).map((s) => s.name)
2394
- );
2395
- function toChatCompletions(schema) {
2396
- return {
2397
- type: "function",
2398
- function: {
2399
- name: schema.name,
2400
- description: schema.description,
2401
- parameters: schema.parameters
2402
- }
2403
- };
2404
- }
2405
- function toRealtime(schema) {
2406
- return {
2407
- type: "function",
2408
- name: schema.name,
2409
- description: schema.description,
2410
- parameters: schema.parameters
2411
- };
2412
- }
2413
- function toGemini(schema) {
2414
- return {
2415
- name: schema.name,
2416
- description: schema.description,
2417
- parameters: schema.parameters
2418
- };
2419
- }
2420
- var CONVERTERS = {
2421
- chat: toChatCompletions,
2422
- realtime: toRealtime,
2423
- gemini: toGemini
2424
- };
2425
- function getBuiltinToolSchemas(builtinTools, fmt) {
2426
- const converter = CONVERTERS[fmt];
2427
- const result = [];
2428
- for (const [toolEnum, schema] of TOOL_MAP) {
2429
- if (builtinTools === null || builtinTools.has(toolEnum)) {
2430
- result.push(converter(schema));
2431
- }
2432
- }
2433
- return result;
2434
- }
2435
- function isBuiltinTool(name) {
2436
- return BUILTIN_TOOL_NAMES.has(name);
2437
- }
2438
- async function executeBuiltinTool(funcName, args, call) {
2439
- if (funcName === "hang_up") {
2440
- await call.hangup();
2441
- return "";
2442
- }
2443
- if (funcName === "collect_dtmf") {
2444
- try {
2445
- const result = await call.collectDtmf({
2446
- maxDigits: args["max_digits"] ?? 4,
2447
- finishOnKey: args["finish_on_key"] ?? "#",
2448
- timeout: args["timeout"] ?? 5
2449
- });
2450
- return result || "(\uD0C0\uC784\uC544\uC6C3 - \uC785\uB825 \uC5C6\uC74C)";
2451
- } catch (e) {
2452
- return `Error: ${e}`;
2453
- }
2454
- }
2455
- if (funcName === "send_dtmf") {
2456
- try {
2457
- await call.sendDtmfSequence(args["digits"] ?? "");
2458
- return "sent";
2459
- } catch (e) {
2460
- return `Error: ${e}`;
2461
- }
2462
- }
2463
- if (funcName === "transfer_call") {
2464
- try {
2465
- call.transfer(args["to"], {
2466
- destinationType: args["destination_type"] ?? void 0,
2467
- mode: args["mode"] ?? void 0,
2468
- afterTransfer: args["after_transfer"] ?? void 0,
2469
- whisper: args["whisper"] ?? void 0,
2470
- callerId: args["caller_id"] ?? void 0,
2471
- timeout: args["timeout"] ?? void 0
2472
- }).catch(() => {
2473
- });
2474
- return JSON.stringify({ status: "transfer_initiated" });
2475
- } catch (e) {
2476
- return `Error: ${e}`;
2477
- }
2478
- }
2479
- return null;
2480
- }
2481
-
2482
- // src/agent/pipeline/buffering-call.ts
2483
- var MetricsStub = class {
2484
- recordToolCall() {
2485
- }
2486
- recordInterrupt() {
2487
- }
2488
- recordToolError() {
2489
- }
2490
- };
2491
- var BufferingCall = class {
2492
- _buffer = [];
2493
- _droppedEvents = {};
2494
- metrics = new MetricsStub();
2495
- async sendAudio(chunk) {
2496
- this._buffer.push(chunk);
2497
- }
2498
- /** clearAudio 도 prewarm 동안엔 no-op (드물긴 하지만 안전하게). */
2499
- clearAudio() {
2500
- this._buffer = [];
2501
- }
2502
- /**
2503
- * transcript 등 lifecycle 이벤트는 prewarm 동안 무시한다. silent drop 은 디버깅이
2504
- * 어려우므로 event name 별 카운터로 누적하고 attachBuffered() 시 한 번에 로깅한다.
2505
- */
2506
- _emit(...args) {
2507
- this._recordDropped(args);
2508
- }
2509
- async emit(...args) {
2510
- this._recordDropped(args);
2511
- }
2512
- _recordDropped(args) {
2513
- let eventName = "?";
2514
- if (args.length > 0 && typeof args[0] === "string") {
2515
- eventName = args[0];
2516
- }
2517
- this._droppedEvents[eventName] = (this._droppedEvents[eventName] ?? 0) + 1;
2518
- }
2519
- recordToolCall() {
2520
- }
2521
- recordToolError() {
2522
- }
2523
- recordFirstResponse() {
2524
- }
2525
- recordBargeIn() {
2526
- }
2527
- drainBuffer() {
2528
- const out = this._buffer;
2529
- this._buffer = [];
2530
- return out;
2531
- }
2532
- drainDroppedEvents() {
2533
- const out = this._droppedEvents;
2534
- this._droppedEvents = {};
2535
- return out;
2536
- }
2537
- };
2538
- function attachBuffered(prev, next) {
2539
- if (!(prev instanceof BufferingCall)) {
2540
- return false;
2541
- }
2542
- const drained = prev.drainBuffer();
2543
- const flushed = drained.length > 0;
2544
- const callId = next.callId ?? "?";
2545
- if (flushed) {
2546
- console.info(
2547
- `[PREWARM-T] first-audio call_id=${callId} t=${(process.hrtime.bigint() / 1000000n).toString()} buffered_chunks=${drained.length} source=prebuffer`
2548
- );
2549
- }
2550
- for (const chunk of drained) {
2551
- next.sendAudio(chunk);
2552
- }
2553
- const dropped = prev.drainDroppedEvents();
2554
- if (Object.keys(dropped).length > 0) {
2555
- console.info(
2556
- `[PREWARM] dropped events during prewarm call_id=${callId} events=${JSON.stringify(dropped)}`
2557
- );
2558
- }
2559
- return flushed;
2560
- }
2561
-
2562
1978
  // src/agent/pipeline/pipeline-session.ts
2563
1979
  var PipelineSession = class {
2564
1980
  _stt;
@@ -2580,7 +1996,7 @@ var PipelineSession = class {
2580
1996
  _speaking = false;
2581
1997
  _builtinTools = null;
2582
1998
  _holdAudioChunks = null;
2583
- _log = NOOP_LOGGER;
1999
+ _log = chunkU4UFTVLX_cjs.NOOP_LOGGER;
2584
2000
  constructor(options) {
2585
2001
  this._stt = options.stt;
2586
2002
  this._llm = options.llm;
@@ -2642,7 +2058,7 @@ var PipelineSession = class {
2642
2058
  */
2643
2059
  async prewarm(tools) {
2644
2060
  if (tools) this._tools = tools;
2645
- this._callSession = new BufferingCall();
2061
+ this._callSession = new chunkU4UFTVLX_cjs.BufferingCall();
2646
2062
  this._running = true;
2647
2063
  this._conversation = [];
2648
2064
  this._log.info("PipelineSession prewarmed");
@@ -2665,7 +2081,7 @@ var PipelineSession = class {
2665
2081
  async attach(callSession) {
2666
2082
  const prev = this._callSession;
2667
2083
  this._callSession = callSession;
2668
- attachBuffered(prev, callSession);
2084
+ chunkU4UFTVLX_cjs.attachBuffered(prev, callSession);
2669
2085
  }
2670
2086
  async start(callSession, tools) {
2671
2087
  this._tools = tools ?? null;
@@ -2712,8 +2128,8 @@ var PipelineSession = class {
2712
2128
  while (this._running) {
2713
2129
  if (this._audioBuffer.length > 0) {
2714
2130
  const ulaw = this._audioBuffer.shift();
2715
- const pcm8k = ulawToPcm16(ulaw);
2716
- const pcm16k = resamplePcm16(pcm8k, 8e3, 16e3);
2131
+ const pcm8k = chunkU4UFTVLX_cjs.ulawToPcm16(ulaw);
2132
+ const pcm16k = chunkU4UFTVLX_cjs.resamplePcm16(pcm8k, 8e3, 16e3);
2717
2133
  yield pcm16k;
2718
2134
  } else {
2719
2135
  await new Promise((resolve) => setTimeout(resolve, 20));
@@ -2729,7 +2145,7 @@ var PipelineSession = class {
2729
2145
  await this._respond();
2730
2146
  }
2731
2147
  _buildEffectiveTools() {
2732
- const builtinSchemas = getBuiltinToolSchemas(this._builtinTools, "chat");
2148
+ const builtinSchemas = chunkU4UFTVLX_cjs.getBuiltinToolSchemas(this._builtinTools, "chat");
2733
2149
  const dtmfSchemas = builtinSchemas.filter((s) => {
2734
2150
  const name = s["function"]?.["name"];
2735
2151
  return name === "collect_dtmf" || name === "send_dtmf";
@@ -2778,8 +2194,8 @@ var PipelineSession = class {
2778
2194
  const { id, name, arguments: argsStr } = chunk.toolCall;
2779
2195
  try {
2780
2196
  const args = JSON.parse(argsStr);
2781
- if (BUILTIN_TOOL_NAMES.has(name) && this._callSession && !(this._callSession instanceof BufferingCall)) {
2782
- const result2 = await executeBuiltinTool(name, args, this._callSession);
2197
+ if (chunkU4UFTVLX_cjs.BUILTIN_TOOL_NAMES.has(name) && this._callSession && !(this._callSession instanceof chunkU4UFTVLX_cjs.BufferingCall)) {
2198
+ const result2 = await chunkU4UFTVLX_cjs.executeBuiltinTool(name, args, this._callSession);
2783
2199
  if (result2 !== null) {
2784
2200
  if (name === "hang_up") return;
2785
2201
  this._conversation.push({ role: "tool", content: result2, tool_call_id: id, name });
@@ -2789,7 +2205,7 @@ var PipelineSession = class {
2789
2205
  }
2790
2206
  if (!this._tools) return;
2791
2207
  this._callSession?.recordToolCall();
2792
- const player = this._holdAudioChunks && this._callSession && !(this._callSession instanceof BufferingCall) ? new HoldAudioPlayer(this._callSession, this._holdAudioChunks) : null;
2208
+ const player = this._holdAudioChunks && this._callSession && !(this._callSession instanceof chunkU4UFTVLX_cjs.BufferingCall) ? new HoldAudioPlayer(this._callSession, this._holdAudioChunks) : null;
2793
2209
  player?.start();
2794
2210
  let result;
2795
2211
  try {
@@ -2840,8 +2256,8 @@ var PipelineSession = class {
2840
2256
  sampleRate: this._sampleRate
2841
2257
  })) {
2842
2258
  if (!this._running || !this._speaking) break;
2843
- const pcm8k = resamplePcm16(audioChunk, this._sampleRate, 8e3);
2844
- const ulaw = pcm16ToUlaw(pcm8k);
2259
+ const pcm8k = chunkU4UFTVLX_cjs.resamplePcm16(audioChunk, this._sampleRate, 8e3);
2260
+ const ulaw = chunkU4UFTVLX_cjs.pcm16ToUlaw(pcm8k);
2845
2261
  for (let off = 0; off < ulaw.length; off += 160) {
2846
2262
  let chunk = ulaw.subarray(off, off + 160);
2847
2263
  if (chunk.length < 160) {
@@ -2868,7 +2284,7 @@ var OpenAIRealtime = class {
2868
2284
  _language;
2869
2285
  _turnDetection;
2870
2286
  _greeting;
2871
- _log = NOOP_LOGGER;
2287
+ _log = chunkU4UFTVLX_cjs.NOOP_LOGGER;
2872
2288
  _builtinTools = null;
2873
2289
  setLogger(logger) {
2874
2290
  this._log = logger;
@@ -2940,7 +2356,7 @@ var OpenAIRealtime = class {
2940
2356
  /** Open WS + session.update + (optional) response.create without a CallSession. */
2941
2357
  async prewarm(tools) {
2942
2358
  if (tools) this._tools = tools;
2943
- this._call = new BufferingCall();
2359
+ this._call = new chunkU4UFTVLX_cjs.BufferingCall();
2944
2360
  this._closed = false;
2945
2361
  this._playback = null;
2946
2362
  this._latestMediaTs = 0;
@@ -2981,7 +2397,7 @@ var OpenAIRealtime = class {
2981
2397
  async attach(callSession) {
2982
2398
  const prev = this._call;
2983
2399
  this._call = callSession;
2984
- attachBuffered(prev, callSession);
2400
+ chunkU4UFTVLX_cjs.attachBuffered(prev, callSession);
2985
2401
  }
2986
2402
  async start(callSession, tools) {
2987
2403
  if (tools) this._tools = tools;
@@ -3042,7 +2458,7 @@ var OpenAIRealtime = class {
3042
2458
  _sendSessionUpdate() {
3043
2459
  if (!this._ws || this._ws.readyState !== 1) return;
3044
2460
  const toolSchemas = this._tools ? this._tools.toOpenAITools().map((t) => ({ type: "function", ...t.function })) : [];
3045
- toolSchemas.push(...getBuiltinToolSchemas(this._builtinTools, "realtime"));
2461
+ toolSchemas.push(...chunkU4UFTVLX_cjs.getBuiltinToolSchemas(this._builtinTools, "realtime"));
3046
2462
  this._send({
3047
2463
  type: "session.update",
3048
2464
  session: {
@@ -3187,9 +2603,9 @@ var OpenAIRealtime = class {
3187
2603
  const controller = new AbortController();
3188
2604
  this._pendingToolCalls.set(callId, controller);
3189
2605
  try {
3190
- if (BUILTIN_TOOL_NAMES.has(funcName) && this._call && !(this._call instanceof BufferingCall)) {
2606
+ if (chunkU4UFTVLX_cjs.BUILTIN_TOOL_NAMES.has(funcName) && this._call && !(this._call instanceof chunkU4UFTVLX_cjs.BufferingCall)) {
3191
2607
  const args = JSON.parse(item["arguments"] ?? "{}");
3192
- const result2 = await executeBuiltinTool(funcName, args, this._call);
2608
+ const result2 = await chunkU4UFTVLX_cjs.executeBuiltinTool(funcName, args, this._call);
3193
2609
  if (result2 !== null) {
3194
2610
  if (funcName === "hang_up") return;
3195
2611
  if (controller.signal.aborted) return;
@@ -3221,7 +2637,7 @@ var OpenAIRealtime = class {
3221
2637
  return;
3222
2638
  }
3223
2639
  let result;
3224
- const player = this._holdAudioChunks && this._call && !(this._call instanceof BufferingCall) ? new HoldAudioPlayer(this._call, this._holdAudioChunks) : null;
2640
+ const player = this._holdAudioChunks && this._call && !(this._call instanceof chunkU4UFTVLX_cjs.BufferingCall) ? new HoldAudioPlayer(this._call, this._holdAudioChunks) : null;
3225
2641
  player?.start();
3226
2642
  try {
3227
2643
  const args = JSON.parse(item["arguments"] ?? "{}");
@@ -3363,7 +2779,7 @@ var GeminiRealtime = class _GeminiRealtime {
3363
2779
  _toolDrainTimer = null;
3364
2780
  _lastAudioTime = 0;
3365
2781
  _holdAudioChunks = null;
3366
- _log = NOOP_LOGGER;
2782
+ _log = chunkU4UFTVLX_cjs.NOOP_LOGGER;
3367
2783
  constructor(options = {}) {
3368
2784
  this._apiKey = options.apiKey ?? process.env["GOOGLE_API_KEY"] ?? "";
3369
2785
  this._systemPrompt = options.systemPrompt ?? "";
@@ -3409,7 +2825,7 @@ var GeminiRealtime = class _GeminiRealtime {
3409
2825
  /** Open Live session (no CallSession). Audio deltas accumulate into BufferingCall until attach(). */
3410
2826
  async prewarm(tools) {
3411
2827
  if (tools) this._tools = tools;
3412
- this._call = new BufferingCall();
2828
+ this._call = new chunkU4UFTVLX_cjs.BufferingCall();
3413
2829
  this._closed = false;
3414
2830
  this._sentAudioChunks = 0;
3415
2831
  this._audioRemainder = Buffer.alloc(0);
@@ -3466,7 +2882,7 @@ var GeminiRealtime = class _GeminiRealtime {
3466
2882
  async attach(callSession) {
3467
2883
  const prev = this._call;
3468
2884
  this._call = callSession;
3469
- attachBuffered(prev, callSession);
2885
+ chunkU4UFTVLX_cjs.attachBuffered(prev, callSession);
3470
2886
  }
3471
2887
  async start(callSession, tools) {
3472
2888
  if (tools) this._tools = tools;
@@ -3475,8 +2891,8 @@ var GeminiRealtime = class _GeminiRealtime {
3475
2891
  }
3476
2892
  feedAudio(audio) {
3477
2893
  if (this._session && !this._closed) {
3478
- const pcm8k = ulawToPcm16(audio);
3479
- const pcm16k = resamplePcm16(pcm8k, 8e3, 16e3);
2894
+ const pcm8k = chunkU4UFTVLX_cjs.ulawToPcm16(audio);
2895
+ const pcm16k = chunkU4UFTVLX_cjs.resamplePcm16(pcm8k, 8e3, 16e3);
3480
2896
  this._session.sendRealtimeInput({
3481
2897
  audio: {
3482
2898
  data: Buffer.from(pcm16k).toString("base64"),
@@ -3520,7 +2936,7 @@ var GeminiRealtime = class _GeminiRealtime {
3520
2936
  t.function.parameters ?? { type: "object", properties: {} }
3521
2937
  )
3522
2938
  })) : [];
3523
- toolDefs.push(...getBuiltinToolSchemas(this._builtinTools, "gemini"));
2939
+ toolDefs.push(...chunkU4UFTVLX_cjs.getBuiltinToolSchemas(this._builtinTools, "gemini"));
3524
2940
  return toolDefs;
3525
2941
  }
3526
2942
  _handleMessage(msg) {
@@ -3580,8 +2996,8 @@ var GeminiRealtime = class _GeminiRealtime {
3580
2996
  _handleAudioData(b64Data) {
3581
2997
  if (!this._call) return;
3582
2998
  const pcm24k = Buffer.from(b64Data, "base64");
3583
- const pcm8k = resamplePcm16(pcm24k, 24e3, 8e3);
3584
- const ulaw = pcm16ToUlaw(pcm8k);
2999
+ const pcm8k = chunkU4UFTVLX_cjs.resamplePcm16(pcm24k, 24e3, 8e3);
3000
+ const ulaw = chunkU4UFTVLX_cjs.pcm16ToUlaw(pcm8k);
3585
3001
  const combined = Buffer.concat([this._audioRemainder, ulaw]);
3586
3002
  const chunkSize = 160;
3587
3003
  const fullEnd = Math.floor(combined.length / chunkSize) * chunkSize;
@@ -3624,7 +3040,7 @@ var GeminiRealtime = class _GeminiRealtime {
3624
3040
  const functionCalls = toolCall.functionCalls;
3625
3041
  if (!functionCalls) return;
3626
3042
  const responses = [];
3627
- const player = this._holdAudioChunks && this._call && !(this._call instanceof BufferingCall) ? new HoldAudioPlayer(this._call, this._holdAudioChunks) : null;
3043
+ const player = this._holdAudioChunks && this._call && !(this._call instanceof chunkU4UFTVLX_cjs.BufferingCall) ? new HoldAudioPlayer(this._call, this._holdAudioChunks) : null;
3628
3044
  player?.start();
3629
3045
  try {
3630
3046
  for (const fc of functionCalls) {
@@ -3632,8 +3048,8 @@ var GeminiRealtime = class _GeminiRealtime {
3632
3048
  const fcId = fc.id ?? "";
3633
3049
  const args = fc.args ?? {};
3634
3050
  this._log.info({ tool: name, args }, "Tool call: %s", name);
3635
- if (BUILTIN_TOOL_NAMES.has(name) && this._call && !(this._call instanceof BufferingCall)) {
3636
- const result = await executeBuiltinTool(
3051
+ if (chunkU4UFTVLX_cjs.BUILTIN_TOOL_NAMES.has(name) && this._call && !(this._call instanceof chunkU4UFTVLX_cjs.BufferingCall)) {
3052
+ const result = await chunkU4UFTVLX_cjs.executeBuiltinTool(
3637
3053
  name,
3638
3054
  args,
3639
3055
  this._call
@@ -3690,7 +3106,7 @@ var GeminiRealtime = class _GeminiRealtime {
3690
3106
  // src/agent/pipeline/stt/deepgram-stt.ts
3691
3107
  var DeepgramSTT = class {
3692
3108
  _options;
3693
- _log = NOOP_LOGGER;
3109
+ _log = chunkU4UFTVLX_cjs.NOOP_LOGGER;
3694
3110
  get provider() {
3695
3111
  return "deepgram";
3696
3112
  }
@@ -3817,7 +3233,7 @@ var DeepgramSTT = class {
3817
3233
  // src/agent/pipeline/tts/elevenlabs-tts.ts
3818
3234
  var ElevenLabsTTS = class {
3819
3235
  _options;
3820
- _log = NOOP_LOGGER;
3236
+ _log = chunkU4UFTVLX_cjs.NOOP_LOGGER;
3821
3237
  get provider() {
3822
3238
  return "elevenlabs";
3823
3239
  }
@@ -4561,14 +3977,55 @@ function mcpServerHTTP(options) {
4561
3977
  };
4562
3978
  }
4563
3979
 
3980
+ Object.defineProperty(exports, "BUILTIN_TOOL_NAMES", {
3981
+ enumerable: true,
3982
+ get: function () { return chunkU4UFTVLX_cjs.BUILTIN_TOOL_NAMES; }
3983
+ });
3984
+ Object.defineProperty(exports, "BuiltinTool", {
3985
+ enumerable: true,
3986
+ get: function () { return chunkU4UFTVLX_cjs.BuiltinTool; }
3987
+ });
3988
+ Object.defineProperty(exports, "DECODE_TABLE", {
3989
+ enumerable: true,
3990
+ get: function () { return chunkU4UFTVLX_cjs.DECODE_TABLE; }
3991
+ });
3992
+ Object.defineProperty(exports, "createAgentLogger", {
3993
+ enumerable: true,
3994
+ get: function () { return chunkU4UFTVLX_cjs.createAgentLogger; }
3995
+ });
3996
+ Object.defineProperty(exports, "createPipelineLogger", {
3997
+ enumerable: true,
3998
+ get: function () { return chunkU4UFTVLX_cjs.createPipelineLogger; }
3999
+ });
4000
+ Object.defineProperty(exports, "executeBuiltinTool", {
4001
+ enumerable: true,
4002
+ get: function () { return chunkU4UFTVLX_cjs.executeBuiltinTool; }
4003
+ });
4004
+ Object.defineProperty(exports, "getBuiltinToolSchemas", {
4005
+ enumerable: true,
4006
+ get: function () { return chunkU4UFTVLX_cjs.getBuiltinToolSchemas; }
4007
+ });
4008
+ Object.defineProperty(exports, "isBuiltinTool", {
4009
+ enumerable: true,
4010
+ get: function () { return chunkU4UFTVLX_cjs.isBuiltinTool; }
4011
+ });
4012
+ Object.defineProperty(exports, "pcm16ToUlaw", {
4013
+ enumerable: true,
4014
+ get: function () { return chunkU4UFTVLX_cjs.pcm16ToUlaw; }
4015
+ });
4016
+ Object.defineProperty(exports, "resamplePcm16", {
4017
+ enumerable: true,
4018
+ get: function () { return chunkU4UFTVLX_cjs.resamplePcm16; }
4019
+ });
4020
+ Object.defineProperty(exports, "ulawToPcm16", {
4021
+ enumerable: true,
4022
+ get: function () { return chunkU4UFTVLX_cjs.ulawToPcm16; }
4023
+ });
4564
4024
  exports.AnthropicLLM = AnthropicLLM;
4565
4025
  exports.AudioRecorder = AudioRecorder;
4566
- exports.BUILTIN_TOOL_NAMES = BUILTIN_TOOL_NAMES;
4567
- exports.BuiltinTool = BuiltinTool;
4568
4026
  exports.CallSession = CallSession;
4569
4027
  exports.ClawOpsAgent = ClawOpsAgent;
4570
4028
  exports.ControlWebSocket = ControlWebSocket;
4571
- exports.DECODE_TABLE = DECODE_TABLE;
4572
4029
  exports.DeepSeekLLM = DeepSeekLLM;
4573
4030
  exports.DeepgramSTT = DeepgramSTT;
4574
4031
  exports.ElevenLabsTTS = ElevenLabsTTS;
@@ -4589,20 +4046,12 @@ exports.TogetherLLM = TogetherLLM;
4589
4046
  exports.ToolRegistry = ToolRegistry;
4590
4047
  exports.XaiLLM = XaiLLM;
4591
4048
  exports.buildControlWsUrl = buildControlWsUrl;
4592
- exports.createAgentLogger = createAgentLogger;
4593
- exports.createPipelineLogger = createPipelineLogger;
4594
- exports.executeBuiltinTool = executeBuiltinTool;
4595
4049
  exports.functionTool = functionTool;
4596
- exports.getBuiltinToolSchemas = getBuiltinToolSchemas;
4597
4050
  exports.getTracingConfig = getTracingConfig;
4598
- exports.isBuiltinTool = isBuiltinTool;
4599
4051
  exports.mcpServerHTTP = mcpServerHTTP;
4600
4052
  exports.mcpServerStdio = mcpServerStdio;
4601
- exports.pcm16ToUlaw = pcm16ToUlaw;
4602
- exports.resamplePcm16 = resamplePcm16;
4603
4053
  exports.resetTracingConfig = resetTracingConfig;
4604
4054
  exports.setTracingConfig = setTracingConfig;
4605
- exports.ulawToPcm16 = ulawToPcm16;
4606
4055
  exports.zodToToolParams = zodToToolParams;
4607
4056
  //# sourceMappingURL=index.cjs.map
4608
4057
  //# sourceMappingURL=index.cjs.map