@teamlearners/clawops 0.24.0 → 0.25.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,5 +1,5 @@
1
- import { F as FunctionTool, S as Session, B as BuiltinTool, C as CallSession, a as STT, L as LLM, T as TTS, b as ToolRegistry, c as SessionTelemetry, d as SpeechEvent, e as ConversationMessage, f as LLMChunk } from '../base-Z-uZdd27.cjs';
2
- export { g as CallDirection, h as CallStatus, O as OpenAIToolDefinition, i as ToolCallRequest, j as functionTool, z as zodToToolParams } from '../base-Z-uZdd27.cjs';
1
+ import { F as FunctionTool, S as Session, B as BuiltinTool, C as CallSession, a as STT, L as LLM, T as TTS, b as ToolRegistry, c as SessionTelemetry, d as SpeechEvent, e as ConversationMessage, f as LLMChunk } from '../base-Cje1TDJi.cjs';
2
+ export { g as CallDirection, h as CallStatus, O as OpenAIToolDefinition, i as ToolCallRequest, j as functionTool, z as zodToToolParams } from '../base-Cje1TDJi.cjs';
3
3
  import { Logger } from 'pino';
4
4
  export { Logger } from 'pino';
5
5
  import 'zod';
@@ -1,5 +1,5 @@
1
- import { F as FunctionTool, S as Session, B as BuiltinTool, C as CallSession, a as STT, L as LLM, T as TTS, b as ToolRegistry, c as SessionTelemetry, d as SpeechEvent, e as ConversationMessage, f as LLMChunk } from '../base-Z-uZdd27.js';
2
- export { g as CallDirection, h as CallStatus, O as OpenAIToolDefinition, i as ToolCallRequest, j as functionTool, z as zodToToolParams } from '../base-Z-uZdd27.js';
1
+ import { F as FunctionTool, S as Session, B as BuiltinTool, C as CallSession, a as STT, L as LLM, T as TTS, b as ToolRegistry, c as SessionTelemetry, d as SpeechEvent, e as ConversationMessage, f as LLMChunk } from '../base-Cje1TDJi.js';
2
+ export { g as CallDirection, h as CallStatus, O as OpenAIToolDefinition, i as ToolCallRequest, j as functionTool, z as zodToToolParams } from '../base-Cje1TDJi.js';
3
3
  import { Logger } from 'pino';
4
4
  export { Logger } from 'pino';
5
5
  import 'zod';
@@ -1,4 +1,4 @@
1
- import { DEFAULT_BASE_URL, AgentError, AgentConnectionError, VERSION } from '../chunk-7P2HGIPS.js';
1
+ import { DEFAULT_BASE_URL, AgentError, AgentConnectionError, VERSION } from '../chunk-THZNZBP2.js';
2
2
  import { NOOP_LOGGER, resolveBuiltinTools, createAgentLogger, createPipelineLogger, BufferingCall, attachBuffered, ulawToPcm16, resamplePcm16, getBuiltinToolSchemas, BUILTIN_TOOL_NAMES, executeBuiltinTool, pcm16ToUlaw, applyUlawGain } from '../chunk-2BAYUQ7O.js';
3
3
  export { BUILTIN_TOOL_NAMES, BuiltinTool, DECODE_TABLE, createAgentLogger, createPipelineLogger, executeBuiltinTool, getBuiltinToolSchemas, isBuiltinTool, pcm16ToUlaw, resamplePcm16, ulawToPcm16 } from '../chunk-2BAYUQ7O.js';
4
4
  import * as fs from 'fs';
@@ -739,6 +739,7 @@ var CallSession = class {
739
739
  startTime;
740
740
  metadata;
741
741
  _status;
742
+ _endedStatus = null;
742
743
  _sendAudioFn = null;
743
744
  _clearAudioFn = null;
744
745
  _hangupFn = null;
@@ -787,6 +788,17 @@ var CallSession = class {
787
788
  get status() {
788
789
  return this._status;
789
790
  }
791
+ /**
792
+ * 서버가 통보한 최종 종료 상태. 통화가 끝나기 전에는 null.
793
+ *
794
+ * `completed`(성사) / `no-answer`(벨은 울렸으나 무응답) / `busy`(통화중) /
795
+ * `rejected`(수신 거절) / `canceled`(응답 전 발신 측 취소) / `failed`(시스템·망 오류).
796
+ * `status` 는 SDK 내부 수명주기(ringing→active→ended)이므로 통화 성사 여부는
797
+ * 이 값이나 `call_failed` 이벤트로 판단한다.
798
+ */
799
+ get endedStatus() {
800
+ return this._endedStatus;
801
+ }
790
802
  get duration() {
791
803
  return (Date.now() - this.startTime.getTime()) / 1e3;
792
804
  }
@@ -947,8 +959,20 @@ var CallSession = class {
947
959
  async wait() {
948
960
  return this._endedPromise;
949
961
  }
950
- /** Mark the session as ended (called internally). */
951
- _markEnded() {
962
+ /**
963
+ * Mark the session as ended (called internally).
964
+ *
965
+ * @param status 서버가 통보한 최종 상태(completed/no-answer/busy/rejected/canceled/
966
+ * failed). 주어지면 `endedStatus` 로 확정한다 — 상대가 받지 않은 통화를 성사된 통화와
967
+ * 구분하기 위함이다. 생략하면 미디어 세션 정리 경로에서의 호출이므로, 아직 종료 전일
968
+ * 때만 'completed' 로 채우고 이미 확정된 서버 상태는 덮어쓰지 않는다.
969
+ */
970
+ _markEnded(status) {
971
+ if (status !== void 0) {
972
+ this._endedStatus = status;
973
+ } else if (this._status !== "ended") {
974
+ this._endedStatus = "completed";
975
+ }
952
976
  this._status = "ended";
953
977
  this._resolveEnded();
954
978
  }
@@ -1600,10 +1624,15 @@ var ClawOpsAgent = class _ClawOpsAgent {
1600
1624
  }
1601
1625
  _handleEnded(event) {
1602
1626
  const callId = event["callId"];
1627
+ const status = event["status"] || "completed";
1603
1628
  const session = this._activeSessions.get(callId);
1604
1629
  if (session) {
1605
- this._log.info("Call ended (server): %s", callId);
1606
- session._markEnded();
1630
+ this._log.info("Call ended (server): %s (status=%s)", callId, status);
1631
+ if (status !== "completed") {
1632
+ this._log.info("Outbound call not connected: %s (%s)", callId, status);
1633
+ session._emit("call_failed", status);
1634
+ }
1635
+ session._markEnded(status);
1607
1636
  this._activeSessions.delete(callId);
1608
1637
  }
1609
1638
  void this._cleanupPrewarm(callId);
@@ -1715,9 +1744,10 @@ var ClawOpsAgent = class _ClawOpsAgent {
1715
1744
  const callId = event["callId"];
1716
1745
  const session = this._activeSessions.get(callId);
1717
1746
  if (session) {
1718
- this._log.info("Outbound call failed: %s (%s)", callId, event["reason"] ?? "failed");
1719
- session._emit("call_failed", event["reason"] ?? "failed");
1720
- session._markEnded();
1747
+ const reason = event["reason"] ?? "failed";
1748
+ this._log.info("Outbound call failed: %s (%s)", callId, reason);
1749
+ session._emit("call_failed", reason);
1750
+ session._markEnded(reason);
1721
1751
  this._activeSessions.delete(callId);
1722
1752
  }
1723
1753
  void this._cleanupPrewarm(callId);