@connekz/connekz-agent 2.2.1 → 2.4.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
1
  class WorkletProcessor extends AudioWorkletProcessor {
2
- process(inputs, outputs, parameters) {
2
+ process(inputs) {
3
3
  const input = inputs[0];
4
4
  if (input.length > 0) {
5
5
  const data = input[0];
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@connekz/connekz-agent",
3
3
  "private": false,
4
4
  "type": "module",
5
- "version": "2.2.1",
5
+ "version": "2.4.0",
6
6
  "description": "A package for Connekz clients to integrate Connekz Agent into their applications.",
7
7
  "main": "./dist/connekz-agent.umd.js",
8
8
  "module": "./dist/connekz-agent.es.js",
package/types.d.ts CHANGED
@@ -28,6 +28,17 @@ export type ConnekzTranscript = {
28
28
  forcedDisplay?: boolean; // Whether force to display this message
29
29
  }
30
30
 
31
+ /**
32
+ * A single message in the full conversation history returned by
33
+ * `connekzAgent.getConversation()`. Covers both voice and text turns.
34
+ */
35
+ export type ConnekzConversationMessage = {
36
+ id?: string; // Server message id (absent for not-yet-persisted local messages)
37
+ role: 'user' | 'ai' | 'system';
38
+ message: string;
39
+ at: string; // ISO date string (message createdAt)
40
+ }
41
+
31
42
  // Export types for consumers of the package
32
43
  export type ConnekzOptions = {
33
44
  clientId: string; // Client ID for the connekz instance
@@ -61,18 +72,30 @@ export type ConnectionQuality = {
61
72
  /**
62
73
  * Error codes for Connekz Agent errors.
63
74
  *
64
- * CNKZ_ERR_1001 - Unable to reach the Connekz server (wrong URL, server down, network issue)
65
- * CNKZ_ERR_1002 - Invalid client ID or client secret
66
- * CNKZ_ERR_1003 - Usage quota exceeded (out of tokens)
67
- * CNKZ_ERR_1004 - Weak network connection (voice unreliable)
75
+ * CNKZ_ERR_1001 - Unable to reach the Connekz server (wrong URL, server down, network/proxy issue).
76
+ * The agent keeps retrying automatically, walking a websocket → polling transport ladder.
77
+ * CNKZ_ERR_1002 - Invalid client ID or client secret. Not retried.
78
+ * CNKZ_ERR_1003 - Usage quota exceeded (out of tokens / connection limit). Not retried.
79
+ * CNKZ_ERR_1004 - Weak network connection (voice unreliable; text chat suggested)
68
80
  * CNKZ_ERR_1005 - Agent runtime error
81
+ * CNKZ_ERR_1006 - Browser is offline. Reconnects automatically when connectivity returns.
82
+ * CNKZ_ERR_1007 - Session/ephemeral token expired. Mint a fresh token server-side and re-initialize. Not retried.
83
+ * CNKZ_ERR_1008 - This page's origin is not in the instance's authorized domains list. Not retried.
84
+ * CNKZ_ERR_1009 - Browser unsupported (no realtime transport available at all). Not retried.
85
+ * CNKZ_ERR_1010 - Voice unsupported in this environment (insecure context, no mic API/hardware).
86
+ * Text chat continues to work.
69
87
  */
70
88
  export type ConnekzErrorCode =
71
89
  | 'CNKZ_ERR_1001'
72
90
  | 'CNKZ_ERR_1002'
73
91
  | 'CNKZ_ERR_1003'
74
92
  | 'CNKZ_ERR_1004'
75
- | 'CNKZ_ERR_1005';
93
+ | 'CNKZ_ERR_1005'
94
+ | 'CNKZ_ERR_1006'
95
+ | 'CNKZ_ERR_1007'
96
+ | 'CNKZ_ERR_1008'
97
+ | 'CNKZ_ERR_1009'
98
+ | 'CNKZ_ERR_1010';
76
99
 
77
100
  export type ConnekzError = {
78
101
  code: ConnekzErrorCode;
@@ -80,6 +103,35 @@ export type ConnekzError = {
80
103
  timestamp: number;
81
104
  };
82
105
 
106
+ /** Environment capability snapshot (see ConnekzSocketAPI.getDiagnostics). */
107
+ export type ConnekzCapabilities = {
108
+ webSocket: boolean;
109
+ httpTransport: boolean;
110
+ secureContext: boolean;
111
+ online: boolean;
112
+ mediaDevices: boolean;
113
+ audioContext: boolean;
114
+ audioWorklet: boolean;
115
+ localStorage: boolean;
116
+ };
117
+
118
+ /**
119
+ * Connection internals snapshot for debugging and support tickets.
120
+ * `transportStrategy` is the ladder rung last attempted
121
+ * (websocket / polling-upgrade / polling-only); `activeTransport` is what
122
+ * engine.io is actually using when connected.
123
+ */
124
+ export type ConnekzDiagnostics = {
125
+ connected: boolean;
126
+ connecting: boolean;
127
+ transportStrategy: string | null;
128
+ activeTransport: string | null;
129
+ attempts: number;
130
+ lastError: { code: ConnekzErrorCode; userMessage: string; devMessage: string; retryable?: boolean } | null;
131
+ capabilities: ConnekzCapabilities;
132
+ baseUrl: string;
133
+ };
134
+
83
135
  // New: Subscription types
84
136
  export type Unsubscriber = () => void;
85
137
  export interface SocketSubscribeAPI {
@@ -103,6 +155,12 @@ export interface ConnekzSocketAPI {
103
155
  connect: (force?: boolean) => void;
104
156
  disconnect: () => void;
105
157
  cleanup: () => void;
158
+ /**
159
+ * Snapshot of connection internals: transport in use, attempt count, last
160
+ * classified error and environment capabilities. Include this in bug
161
+ * reports/support tickets for connection issues.
162
+ */
163
+ getDiagnostics: () => ConnekzDiagnostics;
106
164
  subscribe: SocketSubscribeAPI;
107
165
  }
108
166
 
@@ -122,6 +180,21 @@ export interface VoiceAgentAPI {
122
180
  stopCaptureTest: () => void;
123
181
  playCapturedAudio: () => void;
124
182
  toggleMic: () => void;
183
+ /**
184
+ * Returns the full conversation history for the current thread as a
185
+ * chronological snapshot (ascending by time). Includes BOTH voice and text
186
+ * turns — seeded from the server thread history and kept live as new messages
187
+ * arrive. Returns an empty array before any conversation exists.
188
+ *
189
+ * Typical use: call this inside an `onToolCall` handler (e.g. when a booking
190
+ * tool fires) to capture the transcript and forward it to your own backend.
191
+ */
192
+ getConversation: () => ConnekzConversationMessage[];
193
+ /**
194
+ * Returns the current chat thread id, or null before a thread is established.
195
+ * Useful for correlating a captured transcript with the server-side thread.
196
+ */
197
+ getThreadId: () => string | null;
125
198
  subscribe: AgentSubscribeAPI;
126
199
  }
127
200