@teamlearners/clawops 0.22.0 → 0.23.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,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkCJ2LJZDQ_cjs = require('../chunk-CJ2LJZDQ.cjs');
3
+ var chunkNXMTLS2U_cjs = require('../chunk-NXMTLS2U.cjs');
4
4
  var pino = require('pino');
5
5
  var fs = require('fs');
6
6
  var path = require('path');
@@ -1079,7 +1079,7 @@ var MAX_ERROR_MESSAGE_LENGTH = 200;
1079
1079
  function getSdkInfo() {
1080
1080
  return {
1081
1081
  name: "clawops-node",
1082
- version: chunkCJ2LJZDQ_cjs.VERSION,
1082
+ version: chunkNXMTLS2U_cjs.VERSION,
1083
1083
  runtime: `node/${process.versions.node}`,
1084
1084
  os: `${process.platform}/${os__default.default.arch()}`
1085
1085
  };
@@ -1279,7 +1279,9 @@ var CallSession = class {
1279
1279
  *
1280
1280
  * destinationType='pstn' (default): `to` is a phone number dialed via carrier.
1281
1281
  * 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.
1282
+ * directly to a SIP endpoint without going through the PSTN carrier. Requires the
1283
+ * account to have an active `sip_trunk` add-on; otherwise the transfer fails and
1284
+ * the call continues with the AI (result `{ status: 'failed', ... }`).
1283
1285
  */
1284
1286
  async transfer(to, options) {
1285
1287
  if (!this._transferFn) {
@@ -1771,10 +1773,12 @@ var ClawOpsAgent = class _ClawOpsAgent {
1771
1773
  /** prewarm 세션이 실제 CallSession 에 attach 완료된 callId. attached 이후의 stop() 은 정상 종료 경로가 책임진다. */
1772
1774
  _prewarmAttached = /* @__PURE__ */ new Set();
1773
1775
  _prewarmEnabled;
1776
+ /** 모든 발신에 적용되는 AMD default. call() 인자로 호출별 override 가능. */
1777
+ _machineDetection;
1774
1778
  constructor(options) {
1775
1779
  this._apiKey = options.apiKey ?? process.env["CLAWOPS_API_KEY"] ?? "";
1776
1780
  this._accountId = options.accountId ?? process.env["CLAWOPS_ACCOUNT_ID"] ?? "";
1777
- this._baseUrl = options.baseUrl ?? chunkCJ2LJZDQ_cjs.DEFAULT_BASE_URL;
1781
+ this._baseUrl = options.baseUrl ?? chunkNXMTLS2U_cjs.DEFAULT_BASE_URL;
1778
1782
  this._fromNumber = options.from;
1779
1783
  this._session = options.session;
1780
1784
  this._recording = options.recording ?? false;
@@ -1785,6 +1789,7 @@ var ClawOpsAgent = class _ClawOpsAgent {
1785
1789
  this._rxGain = _ClawOpsAgent._validateGain("rxGain", options.rxGain ?? 1);
1786
1790
  this._txGain = _ClawOpsAgent._validateGain("txGain", options.txGain ?? 1);
1787
1791
  this._prewarmEnabled = options.prewarmEnabled ?? true;
1792
+ this._machineDetection = options.machineDetection;
1788
1793
  if (options.tracing) {
1789
1794
  setTracingConfig(options.tracing);
1790
1795
  }
@@ -1797,7 +1802,7 @@ var ClawOpsAgent = class _ClawOpsAgent {
1797
1802
  }
1798
1803
  static _validateGain(name, gain) {
1799
1804
  if (typeof gain !== "number" || !Number.isFinite(gain) || gain < 0) {
1800
- throw new chunkCJ2LJZDQ_cjs.AgentError(`${name}=${gain} must be a finite number >= 0`);
1805
+ throw new chunkNXMTLS2U_cjs.AgentError(`${name}=${gain} must be a finite number >= 0`);
1801
1806
  }
1802
1807
  return gain;
1803
1808
  }
@@ -1811,7 +1816,7 @@ var ClawOpsAgent = class _ClawOpsAgent {
1811
1816
  tool(nameOrTool, description, parameters, handler) {
1812
1817
  if (typeof nameOrTool === "string") {
1813
1818
  if (!description || !parameters || !handler) {
1814
- throw new chunkCJ2LJZDQ_cjs.AgentError(
1819
+ throw new chunkNXMTLS2U_cjs.AgentError(
1815
1820
  "tool(name, description, parameters, handler) requires all arguments."
1816
1821
  );
1817
1822
  }
@@ -1847,10 +1852,10 @@ var ClawOpsAgent = class _ClawOpsAgent {
1847
1852
  async connect() {
1848
1853
  if (this._controlWs) return;
1849
1854
  if (!this._apiKey) {
1850
- throw new chunkCJ2LJZDQ_cjs.AgentError("API key is required. Set CLAWOPS_API_KEY or pass apiKey option.");
1855
+ throw new chunkNXMTLS2U_cjs.AgentError("API key is required. Set CLAWOPS_API_KEY or pass apiKey option.");
1851
1856
  }
1852
1857
  if (!this._accountId) {
1853
- throw new chunkCJ2LJZDQ_cjs.AgentError(
1858
+ throw new chunkNXMTLS2U_cjs.AgentError(
1854
1859
  "Account ID is required. Set CLAWOPS_ACCOUNT_ID or pass accountId option."
1855
1860
  );
1856
1861
  }
@@ -1874,7 +1879,7 @@ var ClawOpsAgent = class _ClawOpsAgent {
1874
1879
  } catch {
1875
1880
  }
1876
1881
  } catch (err) {
1877
- throw new chunkCJ2LJZDQ_cjs.AgentConnectionError(
1882
+ throw new chunkNXMTLS2U_cjs.AgentConnectionError(
1878
1883
  `Failed to connect to ClawOps: ${err instanceof Error ? err.message : String(err)}`
1879
1884
  );
1880
1885
  }
@@ -1913,6 +1918,8 @@ var ClawOpsAgent = class _ClawOpsAgent {
1913
1918
  *
1914
1919
  * @param options.machineDetection 자동응답기/음성사서함 감지(AMD).
1915
1920
  * `'Enable'`=감지 후 `AnsweredBy` 통보(통화 계속), `'Hangup'`=음성사서함 감지 시 자동 종료.
1921
+ * 미지정 시 인스턴스 default(생성자의 `machineDetection`)를 따른다.
1922
+ * 우선순위: 호출 인자 > 인스턴스 default > 비활성.
1916
1923
  */
1917
1924
  async call(to, options) {
1918
1925
  await this.connect();
@@ -1922,8 +1929,9 @@ var ClawOpsAgent = class _ClawOpsAgent {
1922
1929
  From: this._fromNumber,
1923
1930
  Timeout: options?.timeout ?? 60
1924
1931
  };
1925
- if (options?.machineDetection) {
1926
- body["MachineDetection"] = options.machineDetection;
1932
+ const effectiveMd = options?.machineDetection ?? this._machineDetection;
1933
+ if (effectiveMd) {
1934
+ body["MachineDetection"] = effectiveMd;
1927
1935
  }
1928
1936
  const resp = await fetch(url, {
1929
1937
  method: "POST",
@@ -1935,7 +1943,7 @@ var ClawOpsAgent = class _ClawOpsAgent {
1935
1943
  });
1936
1944
  if (resp.status !== 201) {
1937
1945
  const error = await resp.json();
1938
- throw new chunkCJ2LJZDQ_cjs.AgentError(`\uBC1C\uC2E0 \uC2E4\uD328 (${resp.status}): ${error["error"] ?? ""}`);
1946
+ throw new chunkNXMTLS2U_cjs.AgentError(`\uBC1C\uC2E0 \uC2E4\uD328 (${resp.status}): ${error["error"] ?? ""}`);
1939
1947
  }
1940
1948
  const data = await resp.json();
1941
1949
  const callSession = new CallSession({