@teamlearners/clawops 0.18.0 → 0.20.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/README.md CHANGED
@@ -183,6 +183,18 @@ const call = await client.calls.create({
183
183
  });
184
184
  console.log(call.callId);
185
185
 
186
+ // 음성사서함 감지(AMD) — Enable=결과만 통보(통화 계속), Hangup=사서함이면 자동 종료
187
+ const amdCall = await client.calls.create({
188
+ to: '01012345678',
189
+ from: '07052358010',
190
+ url: 'https://my-app.com/twiml',
191
+ machineDetection: 'Enable',
192
+ });
193
+ // 통화 종료 후 결과 확인: human(사람) / machine(자동응답기) / unknown(판정 불가)
194
+ const done = await client.calls.get(amdCall.callId);
195
+ console.log(done.answeredBy);
196
+ // statusCallback 을 설정했다면 completed 이벤트 payload 의 AnsweredBy 로도 통보됩니다.
197
+
186
198
  // AI Completion 모드 — AI가 직접 통화를 처리
187
199
  const aiCall = await client.calls.create({
188
200
  to: '01012345678',
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkDQYTVKCT_cjs = require('../chunk-DQYTVKCT.cjs');
3
+ var chunkOUO6NTV6_cjs = require('../chunk-OUO6NTV6.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: chunkDQYTVKCT_cjs.VERSION,
1082
+ version: chunkOUO6NTV6_cjs.VERSION,
1083
1083
  runtime: `node/${process.versions.node}`,
1084
1084
  os: `${process.platform}/${os__default.default.arch()}`
1085
1085
  };
@@ -1767,7 +1767,7 @@ var ClawOpsAgent = class _ClawOpsAgent {
1767
1767
  constructor(options) {
1768
1768
  this._apiKey = options.apiKey ?? process.env["CLAWOPS_API_KEY"] ?? "";
1769
1769
  this._accountId = options.accountId ?? process.env["CLAWOPS_ACCOUNT_ID"] ?? "";
1770
- this._baseUrl = options.baseUrl ?? chunkDQYTVKCT_cjs.DEFAULT_BASE_URL;
1770
+ this._baseUrl = options.baseUrl ?? chunkOUO6NTV6_cjs.DEFAULT_BASE_URL;
1771
1771
  this._fromNumber = options.from;
1772
1772
  this._session = options.session;
1773
1773
  this._recording = options.recording ?? false;
@@ -1790,7 +1790,7 @@ var ClawOpsAgent = class _ClawOpsAgent {
1790
1790
  }
1791
1791
  static _validateGain(name, gain) {
1792
1792
  if (typeof gain !== "number" || !Number.isFinite(gain) || gain < 0) {
1793
- throw new chunkDQYTVKCT_cjs.AgentError(`${name}=${gain} must be a finite number >= 0`);
1793
+ throw new chunkOUO6NTV6_cjs.AgentError(`${name}=${gain} must be a finite number >= 0`);
1794
1794
  }
1795
1795
  return gain;
1796
1796
  }
@@ -1804,7 +1804,7 @@ var ClawOpsAgent = class _ClawOpsAgent {
1804
1804
  tool(nameOrTool, description, parameters, handler) {
1805
1805
  if (typeof nameOrTool === "string") {
1806
1806
  if (!description || !parameters || !handler) {
1807
- throw new chunkDQYTVKCT_cjs.AgentError(
1807
+ throw new chunkOUO6NTV6_cjs.AgentError(
1808
1808
  "tool(name, description, parameters, handler) requires all arguments."
1809
1809
  );
1810
1810
  }
@@ -1840,10 +1840,10 @@ var ClawOpsAgent = class _ClawOpsAgent {
1840
1840
  async connect() {
1841
1841
  if (this._controlWs) return;
1842
1842
  if (!this._apiKey) {
1843
- throw new chunkDQYTVKCT_cjs.AgentError("API key is required. Set CLAWOPS_API_KEY or pass apiKey option.");
1843
+ throw new chunkOUO6NTV6_cjs.AgentError("API key is required. Set CLAWOPS_API_KEY or pass apiKey option.");
1844
1844
  }
1845
1845
  if (!this._accountId) {
1846
- throw new chunkDQYTVKCT_cjs.AgentError(
1846
+ throw new chunkOUO6NTV6_cjs.AgentError(
1847
1847
  "Account ID is required. Set CLAWOPS_ACCOUNT_ID or pass accountId option."
1848
1848
  );
1849
1849
  }
@@ -1867,7 +1867,7 @@ var ClawOpsAgent = class _ClawOpsAgent {
1867
1867
  } catch {
1868
1868
  }
1869
1869
  } catch (err) {
1870
- throw new chunkDQYTVKCT_cjs.AgentConnectionError(
1870
+ throw new chunkOUO6NTV6_cjs.AgentConnectionError(
1871
1871
  `Failed to connect to ClawOps: ${err instanceof Error ? err.message : String(err)}`
1872
1872
  );
1873
1873
  }
@@ -1902,12 +1902,22 @@ var ClawOpsAgent = class _ClawOpsAgent {
1902
1902
  }
1903
1903
  /**
1904
1904
  * Initiate an outbound call.
1905
- * Matches Python SDK: agent.call(to, { timeout })
1905
+ * Matches Python SDK: agent.call(to, { timeout, machineDetection })
1906
+ *
1907
+ * @param options.machineDetection 자동응답기/음성사서함 감지(AMD).
1908
+ * `'Enable'`=감지 후 `AnsweredBy` 통보(통화 계속), `'Hangup'`=음성사서함 감지 시 자동 종료.
1906
1909
  */
1907
1910
  async call(to, options) {
1908
1911
  await this.connect();
1909
1912
  const url = `${this._baseUrl}/v1/accounts/${this._accountId}/calls`;
1910
- const body = { To: to, From: this._fromNumber, Timeout: options?.timeout ?? 60 };
1913
+ const body = {
1914
+ To: to,
1915
+ From: this._fromNumber,
1916
+ Timeout: options?.timeout ?? 60
1917
+ };
1918
+ if (options?.machineDetection) {
1919
+ body["MachineDetection"] = options.machineDetection;
1920
+ }
1911
1921
  const resp = await fetch(url, {
1912
1922
  method: "POST",
1913
1923
  headers: {
@@ -1918,7 +1928,7 @@ var ClawOpsAgent = class _ClawOpsAgent {
1918
1928
  });
1919
1929
  if (resp.status !== 201) {
1920
1930
  const error = await resp.json();
1921
- throw new chunkDQYTVKCT_cjs.AgentError(`\uBC1C\uC2E0 \uC2E4\uD328 (${resp.status}): ${error["error"] ?? ""}`);
1931
+ throw new chunkOUO6NTV6_cjs.AgentError(`\uBC1C\uC2E0 \uC2E4\uD328 (${resp.status}): ${error["error"] ?? ""}`);
1922
1932
  }
1923
1933
  const data = await resp.json();
1924
1934
  const callSession = new CallSession({