@minded-ai/mindedjs 1.0.53-patch6 → 1.0.54

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.
Files changed (120) hide show
  1. package/dist/agent.d.ts +12 -17
  2. package/dist/agent.d.ts.map +1 -1
  3. package/dist/agent.js +21 -78
  4. package/dist/agent.js.map +1 -1
  5. package/dist/edges/edgeFactory.d.ts +3 -1
  6. package/dist/edges/edgeFactory.d.ts.map +1 -1
  7. package/dist/edges/edgeFactory.js +2 -2
  8. package/dist/edges/edgeFactory.js.map +1 -1
  9. package/dist/index.d.ts +4 -5
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js.map +1 -1
  12. package/dist/internalTools/appActionRunnerTool.d.ts.map +1 -1
  13. package/dist/internalTools/appActionRunnerTool.js +1 -1
  14. package/dist/internalTools/appActionRunnerTool.js.map +1 -1
  15. package/dist/nodes/addAppToolNode.d.ts +3 -1
  16. package/dist/nodes/addAppToolNode.d.ts.map +1 -1
  17. package/dist/nodes/addAppToolNode.js +2 -2
  18. package/dist/nodes/addAppToolNode.js.map +1 -1
  19. package/dist/nodes/addPromptNode.d.ts +3 -1
  20. package/dist/nodes/addPromptNode.d.ts.map +1 -1
  21. package/dist/nodes/addPromptNode.js +2 -3
  22. package/dist/nodes/addPromptNode.js.map +1 -1
  23. package/dist/nodes/addToolRunNode.d.ts +3 -1
  24. package/dist/nodes/addToolRunNode.d.ts.map +1 -1
  25. package/dist/nodes/addToolRunNode.js +2 -2
  26. package/dist/nodes/addToolRunNode.js.map +1 -1
  27. package/dist/nodes/nodeFactory.d.ts +3 -1
  28. package/dist/nodes/nodeFactory.d.ts.map +1 -1
  29. package/dist/nodes/nodeFactory.js +3 -3
  30. package/dist/nodes/nodeFactory.js.map +1 -1
  31. package/dist/pii-gateway/gateway.d.ts +17 -0
  32. package/dist/pii-gateway/gateway.d.ts.map +1 -0
  33. package/dist/pii-gateway/gateway.js +77 -0
  34. package/dist/pii-gateway/gateway.js.map +1 -0
  35. package/dist/pii-gateway/index.d.ts +4 -0
  36. package/dist/pii-gateway/index.d.ts.map +1 -0
  37. package/dist/pii-gateway/index.js +14 -0
  38. package/dist/pii-gateway/index.js.map +1 -0
  39. package/dist/pii-gateway/proxy.d.ts +80 -0
  40. package/dist/pii-gateway/proxy.d.ts.map +1 -0
  41. package/dist/pii-gateway/proxy.js +106 -0
  42. package/dist/pii-gateway/proxy.js.map +1 -0
  43. package/dist/pii-gateway/types.d.ts +27 -0
  44. package/dist/pii-gateway/types.d.ts.map +1 -0
  45. package/dist/{types/Voice.types.js → pii-gateway/types.js} +1 -1
  46. package/dist/pii-gateway/types.js.map +1 -0
  47. package/dist/platform/config.d.ts +0 -3
  48. package/dist/platform/config.d.ts.map +1 -1
  49. package/dist/platform/config.js +1 -18
  50. package/dist/platform/config.js.map +1 -1
  51. package/dist/platform/mindedConnection.d.ts +4 -4
  52. package/dist/platform/mindedConnection.d.ts.map +1 -1
  53. package/dist/platform/mindedConnection.js +5 -8
  54. package/dist/platform/mindedConnection.js.map +1 -1
  55. package/dist/platform/mindedConnectionTypes.d.ts +17 -53
  56. package/dist/platform/mindedConnectionTypes.d.ts.map +1 -1
  57. package/dist/platform/mindedConnectionTypes.js +3 -11
  58. package/dist/platform/mindedConnectionTypes.js.map +1 -1
  59. package/dist/platform/piiGateway/gateway.d.ts +16 -0
  60. package/dist/platform/piiGateway/gateway.d.ts.map +1 -0
  61. package/dist/platform/piiGateway/gateway.js +76 -0
  62. package/dist/platform/piiGateway/gateway.js.map +1 -0
  63. package/dist/platform/piiGateway/index.d.ts +3 -0
  64. package/dist/platform/piiGateway/index.d.ts.map +1 -0
  65. package/dist/platform/piiGateway/index.js +7 -0
  66. package/dist/platform/piiGateway/index.js.map +1 -0
  67. package/dist/platform/piiGateway/proxy.d.ts +20 -0
  68. package/dist/platform/piiGateway/proxy.d.ts.map +1 -0
  69. package/dist/platform/piiGateway/proxy.js +24 -0
  70. package/dist/platform/piiGateway/proxy.js.map +1 -0
  71. package/dist/platform/piiGateway/types.d.ts +27 -0
  72. package/dist/platform/piiGateway/types.d.ts.map +1 -0
  73. package/dist/platform/piiGateway/types.js +3 -0
  74. package/dist/platform/piiGateway/types.js.map +1 -0
  75. package/dist/types/Agent.types.d.ts +0 -13
  76. package/dist/types/Agent.types.d.ts.map +1 -1
  77. package/dist/types/Agent.types.js.map +1 -1
  78. package/dist/types/Flows.types.d.ts +2 -15
  79. package/dist/types/Flows.types.d.ts.map +1 -1
  80. package/dist/types/Flows.types.js +0 -1
  81. package/dist/types/Flows.types.js.map +1 -1
  82. package/dist/types/LangGraph.types.d.ts +1 -0
  83. package/dist/types/LangGraph.types.d.ts.map +1 -1
  84. package/dist/types/LangGraph.types.js +1 -0
  85. package/dist/types/LangGraph.types.js.map +1 -1
  86. package/dist/types/Tools.types.d.ts +8 -6
  87. package/dist/types/Tools.types.d.ts.map +1 -1
  88. package/package.json +2 -5
  89. package/src/agent.ts +42 -97
  90. package/src/edges/edgeFactory.ts +4 -1
  91. package/src/index.ts +14 -7
  92. package/src/internalTools/appActionRunnerTool.ts +53 -50
  93. package/src/nodes/addAppToolNode.ts +4 -1
  94. package/src/nodes/addPromptNode.ts +5 -4
  95. package/src/nodes/addToolRunNode.ts +4 -2
  96. package/src/nodes/nodeFactory.ts +7 -4
  97. package/src/platform/config.ts +1 -21
  98. package/src/platform/mindedConnection.ts +9 -15
  99. package/src/platform/mindedConnectionTypes.ts +16 -61
  100. package/src/platform/piiGateway/gateway.ts +97 -0
  101. package/src/platform/piiGateway/index.ts +5 -0
  102. package/src/platform/piiGateway/types.ts +29 -0
  103. package/src/types/Agent.types.ts +0 -14
  104. package/src/types/Flows.types.ts +1 -15
  105. package/src/types/LangGraph.types.ts +1 -0
  106. package/src/types/Tools.types.ts +9 -3
  107. package/dist/types/Voice.types.d.ts +0 -5
  108. package/dist/types/Voice.types.d.ts.map +0 -1
  109. package/dist/types/Voice.types.js.map +0 -1
  110. package/dist/voice/elevenLabsUtils.d.ts +0 -70
  111. package/dist/voice/elevenLabsUtils.d.ts.map +0 -1
  112. package/dist/voice/elevenLabsUtils.js +0 -20
  113. package/dist/voice/elevenLabsUtils.js.map +0 -1
  114. package/dist/voice/voiceSession.d.ts +0 -47
  115. package/dist/voice/voiceSession.d.ts.map +0 -1
  116. package/dist/voice/voiceSession.js +0 -214
  117. package/dist/voice/voiceSession.js.map +0 -1
  118. package/src/types/Voice.types.ts +0 -4
  119. package/src/voice/elevenLabsUtils.ts +0 -101
  120. package/src/voice/voiceSession.ts +0 -257
@@ -1,29 +1,26 @@
1
1
  import { io, Socket } from 'socket.io-client';
2
- import { BaseMindedConnectionSocketMessage, MindedConnectionSocketMessageType, MindedConnectionSocketMessageTypeMap } from './mindedConnectionTypes';
2
+ import { BaseMindedConnectionSocketMessage, MindedConnectionSocketMessageType } from './mindedConnectionTypes';
3
3
  import { stringify } from 'flatted';
4
4
  import { getConfig } from './config';
5
5
 
6
6
  export class MindedConnection {
7
7
  private socket: Socket | null = null;
8
8
  listeners: {
9
- [key: string]: ((message: BaseMindedConnectionSocketMessage, callback: (response: any) => void) => void)[];
9
+ [key: string]: ((message: BaseMindedConnectionSocketMessage) => void)[];
10
10
  } = {};
11
11
 
12
12
  public get isConnected(): boolean {
13
13
  return this.socket?.connected ?? false;
14
14
  }
15
15
 
16
- public on = (event: MindedConnectionSocketMessageType, callback: (message: BaseMindedConnectionSocketMessage, callback: (response: any) => void) => void) => {
16
+ public on = (event: MindedConnectionSocketMessageType, callback: (message: BaseMindedConnectionSocketMessage) => void) => {
17
17
  if (!this.listeners[event]) {
18
18
  this.listeners[event] = [];
19
19
  }
20
20
  this.listeners[event].push(callback);
21
21
  };
22
22
 
23
- public emit = <E extends keyof MindedConnectionSocketMessageTypeMap>(
24
- event: E,
25
- message: MindedConnectionSocketMessageTypeMap[E]
26
- ) => {
23
+ public emit = (event: MindedConnectionSocketMessageType, message: BaseMindedConnectionSocketMessage) => {
27
24
  if (this.socket) {
28
25
  this.socket.emit(event, message);
29
26
  }
@@ -37,7 +34,7 @@ export class MindedConnection {
37
34
  return new Promise((resolve, reject) => {
38
35
  // Set up timeout
39
36
  const timeout = setTimeout(() => {
40
- reject(new Error(`Acknowledgement timeout after ${timeoutMs}ms; Message: ${message}`));
37
+ reject(new Error(`Acknowledgement timeout after ${timeoutMs}ms`));
41
38
  }, timeoutMs);
42
39
 
43
40
  // Emit with acknowledgement callback
@@ -73,8 +70,8 @@ export class MindedConnection {
73
70
  });
74
71
 
75
72
  this.socket.on('connect_error', () => {
76
- console.error('Minded connection error');
77
- reject(new Error('Minded connection error'));
73
+ console.error('Failed to connect to minded platform');
74
+ reject(new Error('Failed to connect to minded platform'));
78
75
  });
79
76
 
80
77
  this.socket.on('disconnect', () => {
@@ -99,15 +96,12 @@ export class MindedConnection {
99
96
  });
100
97
 
101
98
  // Listen for specific message types
102
- this.socket.onAny((event, message, callback) => {
99
+ this.socket.onAny((event, message) => {
103
100
  if (this.listeners[event]) {
104
101
  this.listeners[event].forEach((listener) => {
105
- listener(message, callback);
102
+ listener(message);
106
103
  });
107
104
  }
108
- else {
109
- console.warn({ message: 'No listeners found for event', event });
110
- }
111
105
  });
112
106
 
113
107
  // Handle process termination
@@ -7,43 +7,17 @@ import type {
7
7
  CheckpointTuple,
8
8
  } from '@langchain/langgraph-checkpoint';
9
9
  import type { RunnableConfig } from '@langchain/core/runnables';
10
- import { AgentInvokeParams } from '../types/Agent.types';
11
10
 
12
11
  export enum MindedConnectionSocketMessageType {
13
12
  OnAppTrigger = 'on-app-trigger',
14
13
  OnAppAction = 'on-app-action',
15
- GET_SECRETS = 'get-secrets',
16
- GET_FLOWS = 'get-flows',
17
- INVOKE = 'invoke',
18
- // Checkpoints
19
14
  CHECKPOINT_GET_TUPLE = 'checkpoint-get-tuple',
20
15
  CHECKPOINT_PUT = 'checkpoint-put',
21
16
  CHECKPOINT_LIST = 'checkpoint-list',
22
17
  CHECKPOINT_PUT_WRITES = 'checkpoint-put-writes',
23
- // Voice
24
- DASHBOARD_VOICE_USER_AUDIO = 'dashboard-voice-user-audio',
25
- DASHBOARD_VOICE_AGENT_AUDIO = 'dashboard-voice-agent-audio',
26
- DASHBOARD_VOICE_SESSION_START = 'dashboard-voice-session-start',
27
- DASHBOARD_VOICE_SESSION_END = 'dashboard-voice-session-end',
28
- DASHBOARD_VOICE_INTERRUPTION = 'dashboard-voice-interruption',
29
- DASHBOARD_VOICE_AGENT_RESPONSE_CORRECTION = 'dashboard-voice-agent-response-correction',
30
- }
31
-
32
- export type MindedConnectionSocketMessageTypeMap = {
33
- [MindedConnectionSocketMessageType.OnAppTrigger]: OnAppTrigger;
34
- [MindedConnectionSocketMessageType.OnAppAction]: BaseMindedConnectionSocketMessage;
35
- [MindedConnectionSocketMessageType.GET_SECRETS]: BaseMindedConnectionSocketMessage;
36
- [MindedConnectionSocketMessageType.GET_FLOWS]: BaseMindedConnectionSocketMessage;
37
- [MindedConnectionSocketMessageType.INVOKE]: InvokeMessage;
38
- [MindedConnectionSocketMessageType.CHECKPOINT_GET_TUPLE]: OnCheckpointGetTuple;
39
- [MindedConnectionSocketMessageType.CHECKPOINT_PUT]: OnCheckpointPut;
40
- [MindedConnectionSocketMessageType.CHECKPOINT_LIST]: OnCheckpointList;
41
- [MindedConnectionSocketMessageType.CHECKPOINT_PUT_WRITES]: OnCheckpointPutWrites;
42
- [MindedConnectionSocketMessageType.DASHBOARD_VOICE_USER_AUDIO]: OnVoiceAudioIn;
43
- [MindedConnectionSocketMessageType.DASHBOARD_VOICE_AGENT_AUDIO]: OnVoiceAudioOut;
44
- [MindedConnectionSocketMessageType.DASHBOARD_VOICE_SESSION_START]: BaseVoiceMessage;
45
- [MindedConnectionSocketMessageType.DASHBOARD_VOICE_SESSION_END]: OnVoiceSessionEnd;
46
- [MindedConnectionSocketMessageType.DASHBOARD_VOICE_INTERRUPTION]: OnVoiceInterruption;
18
+ GET_SECRETS = 'get-secrets',
19
+ GET_FLOWS = 'get-flows',
20
+ PII_HTTP_REQUEST = 'pii-http-request',
47
21
  }
48
22
 
49
23
  export interface BaseMindedConnectionSocketMessage {
@@ -94,39 +68,20 @@ export interface OnCheckpointListResponse extends BaseSdkConnectionSocketMessage
94
68
  checkpoints?: CheckpointTuple[];
95
69
  }
96
70
 
97
- export interface BaseVoiceMessage extends BaseMindedConnectionSocketMessage {
71
+ export interface OnPiiHttpRequest extends BaseMindedConnectionSocketMessage {
98
72
  sessionId: string;
99
- timestamp: number;
100
- }
101
-
102
- // Voice/Audio event interfaces
103
- export interface OnVoiceAudioIn extends BaseVoiceMessage {
104
- audioData: string; // base64 encoded audio data
105
- }
106
-
107
- export interface OnVoiceAudioOut extends BaseVoiceMessage {
108
- audioData: string; // base64 encoded audio data
73
+ requestId: string;
74
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
75
+ url: string;
76
+ headers?: Record<string, string>;
77
+ params?: Record<string, any>;
78
+ data?: any;
109
79
  }
110
80
 
111
- export interface OnVoiceMessageIn extends BaseVoiceMessage {
112
- text: string;
81
+ export interface OnPiiHttpResponse extends BaseSdkConnectionSocketMessageResponseCallbackAck {
82
+ requestId: string;
83
+ data?: any;
84
+ status?: number;
85
+ statusText?: string;
86
+ headers?: Record<string, string>;
113
87
  }
114
-
115
- export interface OnVoiceMessageOut extends BaseMindedConnectionSocketMessage {
116
- sessionId: string;
117
- text: string;
118
- timestamp: number;
119
- }
120
-
121
- export interface OnVoiceInterruption extends BaseMindedConnectionSocketMessage {
122
- sessionId: string;
123
- timestamp: number;
124
- }
125
- export interface OnVoiceSessionEnd extends BaseMindedConnectionSocketMessage {
126
- sessionId: string;
127
- timestamp: number;
128
- }
129
-
130
- export interface InvokeMessage extends BaseMindedConnectionSocketMessage, AgentInvokeParams {
131
- type: MindedConnectionSocketMessageType.INVOKE;
132
- }
@@ -0,0 +1,97 @@
1
+ import { v4 as uuidv4 } from 'uuid';
2
+ import { MindedConnection } from '../mindedConnection';
3
+ import { MindedConnectionSocketMessageType, OnPiiHttpRequest, OnPiiHttpResponse } from '../mindedConnectionTypes';
4
+ import { HttpRequestConfig, HttpResponse, PIIGatewayInstance } from './types';
5
+
6
+ export class PIIGateway implements PIIGatewayInstance {
7
+ private mindedConnection: MindedConnection;
8
+
9
+ constructor(mindedConnection: MindedConnection) {
10
+ this.mindedConnection = mindedConnection;
11
+ }
12
+
13
+ private async makeRequest<T = any>(
14
+ sessionId: string,
15
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS',
16
+ url: string,
17
+ data?: any,
18
+ config?: HttpRequestConfig,
19
+ ): Promise<HttpResponse<T>> {
20
+ if (!this.mindedConnection?.isConnected) {
21
+ throw new Error('Minded connection is not established. PII-secured HTTP requests require a connection to the Minded platform.');
22
+ }
23
+
24
+ try {
25
+ const requestId = uuidv4();
26
+ const requestPayload: OnPiiHttpRequest = {
27
+ type: MindedConnectionSocketMessageType.PII_HTTP_REQUEST,
28
+ requestId,
29
+ method,
30
+ url,
31
+ headers: config?.headers as Record<string, string>,
32
+ params: config?.params,
33
+ data,
34
+ sessionId,
35
+ };
36
+
37
+ const response = await this.mindedConnection.awaitEmit<OnPiiHttpRequest, OnPiiHttpResponse>(
38
+ MindedConnectionSocketMessageType.PII_HTTP_REQUEST,
39
+ requestPayload,
40
+ 30000, // 30 second timeout for HTTP requests
41
+ );
42
+
43
+ if (response.error) {
44
+ throw new Error(`HTTP request failed: ${response.error}`);
45
+ }
46
+
47
+ // Verify that the response requestId matches our request
48
+ if (response.requestId && response.requestId !== requestId) {
49
+ console.warn(`Response requestId (${response.requestId}) does not match request requestId (${requestId})`);
50
+ }
51
+
52
+ // Return generic HttpResponse format
53
+ return {
54
+ data: response.data,
55
+ status: response.status || 200,
56
+ statusText: response.statusText || 'OK',
57
+ headers: response.headers || {},
58
+ config: config || {},
59
+ };
60
+ } catch (error) {
61
+ throw new Error(`Secure HTTP request failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
62
+ }
63
+ }
64
+
65
+ async get<T = any>(sessionId: string, url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>> {
66
+ return this.makeRequest<T>(sessionId, 'GET', url, undefined, config);
67
+ }
68
+
69
+ async post<T = any>(sessionId: string, url: string, data?: any, config?: HttpRequestConfig): Promise<HttpResponse<T>> {
70
+ return this.makeRequest<T>(sessionId, 'POST', url, data, config);
71
+ }
72
+
73
+ async put<T = any>(sessionId: string, url: string, data?: any, config?: HttpRequestConfig): Promise<HttpResponse<T>> {
74
+ return this.makeRequest<T>(sessionId, 'PUT', url, data, config);
75
+ }
76
+
77
+ async delete<T = any>(sessionId: string, url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>> {
78
+ return this.makeRequest<T>(sessionId, 'DELETE', url, undefined, config);
79
+ }
80
+
81
+ async patch<T = any>(sessionId: string, url: string, data?: any, config?: HttpRequestConfig): Promise<HttpResponse<T>> {
82
+ return this.makeRequest<T>(sessionId, 'PATCH', url, data, config);
83
+ }
84
+
85
+ async head<T = any>(sessionId: string, url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>> {
86
+ return this.makeRequest<T>(sessionId, 'HEAD', url, undefined, config);
87
+ }
88
+
89
+ async options<T = any>(sessionId: string, url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>> {
90
+ return this.makeRequest<T>(sessionId, 'OPTIONS', url, undefined, config);
91
+ }
92
+
93
+ async request<T = any>(sessionId: string, config: HttpRequestConfig): Promise<HttpResponse<T>> {
94
+ const method = (config.method?.toUpperCase() || 'GET') as any;
95
+ return this.makeRequest<T>(sessionId, method, config.url || '', config.data, config);
96
+ }
97
+ }
@@ -0,0 +1,5 @@
1
+ // Export types
2
+ export type { HttpRequestConfig, HttpResponse, PIIGatewayInstance } from './types';
3
+
4
+ // Export core gateway class and creation function
5
+ export { PIIGateway } from './gateway';
@@ -0,0 +1,29 @@
1
+ // Generic HTTP types (library-agnostic)
2
+ export interface HttpRequestConfig {
3
+ method?: string;
4
+ url?: string;
5
+ headers?: Record<string, string>;
6
+ params?: Record<string, any>;
7
+ data?: any;
8
+ timeout?: number;
9
+ [key: string]: any; // Allow additional properties for extensibility
10
+ }
11
+
12
+ export interface HttpResponse<T = any> {
13
+ data: T;
14
+ status: number;
15
+ statusText: string;
16
+ headers: Record<string, string>;
17
+ config: HttpRequestConfig;
18
+ }
19
+
20
+ export interface PIIGatewayInstance {
21
+ get<T = any>(sessionId: string, url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
22
+ post<T = any>(sessionId: string, url: string, data?: any, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
23
+ put<T = any>(sessionId: string, url: string, data?: any, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
24
+ delete<T = any>(sessionId: string, url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
25
+ patch<T = any>(sessionId: string, url: string, data?: any, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
26
+ head<T = any>(sessionId: string, url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
27
+ options<T = any>(sessionId: string, url: string, config?: HttpRequestConfig): Promise<HttpResponse<T>>;
28
+ request<T = any>(sessionId: string, config: HttpRequestConfig): Promise<HttpResponse<T>>;
29
+ }
@@ -9,20 +9,6 @@ export type MindedSDKConfig = {
9
9
  tools: string[];
10
10
  }
11
11
 
12
- /**
13
- * Parameters for the Agent invoke method
14
- */
15
- export interface AgentInvokeParams {
16
- /** The payload/data associated with the trigger */
17
- triggerBody: any;
18
- /** The name/type of the trigger being invoked */
19
- triggerName: string;
20
- /** Optional session identifier for conversation continuity */
21
- sessionId?: string;
22
- /** Optional name of the application triggering the agent in case of an app trigger */
23
- appName?: string;
24
- }
25
-
26
12
  export enum FlowHistoryType {
27
13
  TRIGGER_INVOCATION = 'triggerInvocation',
28
14
  APP_ACTION_INVOCATION = 'appActionInvocation',
@@ -30,12 +30,10 @@ export enum TriggerType {
30
30
  APP = 'app',
31
31
  WEBHOOK = 'webhook',
32
32
  MANUAL = 'manual',
33
- VOICE = 'voice',
34
33
  }
35
34
 
36
35
  export interface BaseTriggerNode extends BaseNode {
37
36
  type: NodeType.TRIGGER;
38
- triggerType: TriggerType;
39
37
  }
40
38
 
41
39
  export interface BaseAppNode {
@@ -58,18 +56,6 @@ export interface WebhookTriggerNode extends BaseTriggerNode {
58
56
  triggerType: TriggerType.WEBHOOK;
59
57
  }
60
58
 
61
- export interface VoiceTriggerNode extends BaseTriggerNode {
62
- triggerType: TriggerType.VOICE;
63
- /**
64
- * Text that will be spoken as the very first message in a voice interaction.
65
- */
66
- firstMessage: string;
67
- /**
68
- * Optional ElevenLabs voice ID to be used for TTS.
69
- */
70
- voiceId?: string;
71
- }
72
-
73
59
  export interface ManualTriggerNode extends BaseTriggerNode {
74
60
  triggerType: TriggerType.MANUAL;
75
61
  }
@@ -80,7 +66,7 @@ export interface PromptNode extends BaseNode {
80
66
  llmConfig?: LLMConfig;
81
67
  }
82
68
 
83
- export type TriggerNode = AppTriggerNode | WebhookTriggerNode | ManualTriggerNode | VoiceTriggerNode;
69
+ export type TriggerNode = AppTriggerNode | WebhookTriggerNode | ManualTriggerNode;
84
70
 
85
71
  export interface JunctionNode extends BaseNode {
86
72
  type: NodeType.JUNCTION;
@@ -23,6 +23,7 @@ export const stateAnnotation = Annotation.Root({
23
23
  default: () => [],
24
24
  reducer: (a, b) => a.concat(b),
25
25
  }),
26
+ sessionId: Annotation<string>(),
26
27
  });
27
28
 
28
29
  export type CompiledGraph = CompiledStateGraph<any, any, string>;
@@ -1,17 +1,23 @@
1
1
  import { z } from 'zod';
2
- import { FlowHistory } from './Agent.types';
2
+ import { Agent } from '../';
3
+ import { stateAnnotation } from './LangGraph.types';
3
4
 
4
5
  export interface Tool<Input extends z.ZodSchema, Memory> {
5
6
  name: string;
6
7
  description: string;
7
8
  input: Input;
8
9
  isGlobal?: boolean;
9
- execute: ({ input, memory, triggerInvocations }: { input: z.infer<Input>; memory: Memory; triggerInvocations?: Array<FlowHistory> }) => Promise<{ memory?: Partial<Memory>, result?: any } | void>;
10
+ execute: (input: ToolExecuteInput<Input>) => Promise<{ memory?: Partial<Memory>; result?: any } | void>;
10
11
  }
11
12
 
13
+ export interface ToolExecuteInput<Input extends z.ZodSchema> {
14
+ input: z.infer<Input>;
15
+ state: typeof stateAnnotation.State;
16
+ agent: Agent;
17
+ }
12
18
 
13
19
  export interface AppActionRunnerInput {
14
20
  appName: string;
15
21
  actionName: string;
16
22
  actionInput: object;
17
- }
23
+ }
@@ -1,5 +0,0 @@
1
- export type ElevenLabsContext = {
2
- sessionId: string;
3
- mindedToken: string;
4
- };
5
- //# sourceMappingURL=Voice.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Voice.types.d.ts","sourceRoot":"","sources":["../../src/types/Voice.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Voice.types.js","sourceRoot":"","sources":["../../src/types/Voice.types.ts"],"names":[],"mappings":""}
@@ -1,70 +0,0 @@
1
- /** ElevenLabs LLM proxy request body shape */
2
- export interface LLMRequestBody {
3
- messages: Array<{
4
- content: string;
5
- role: string;
6
- tool_call_id?: string;
7
- }>;
8
- model: string;
9
- max_tokens: number;
10
- stream: boolean;
11
- temperature: number;
12
- tools: null;
13
- }
14
- interface BaseEvent {
15
- type: string;
16
- }
17
- interface UserTranscriptEvent extends BaseEvent {
18
- type: 'user_transcript';
19
- user_transcription_event: {
20
- user_transcript: string;
21
- };
22
- }
23
- interface AgentResponseEvent extends BaseEvent {
24
- type: 'agent_response';
25
- agent_response_event: {
26
- agent_response: string;
27
- };
28
- }
29
- interface AudioResponseEvent extends BaseEvent {
30
- type: 'audio';
31
- audio_event: {
32
- audio_base_64: string;
33
- event_id: number;
34
- };
35
- }
36
- interface InterruptionEvent extends BaseEvent {
37
- type: 'interruption';
38
- interruption_event: {
39
- event_id: number;
40
- };
41
- }
42
- interface PingEvent extends BaseEvent {
43
- type: 'ping';
44
- ping_event: {
45
- event_id: number;
46
- ping_ms: number;
47
- };
48
- }
49
- interface ConversationInitiationMetadataEvent extends BaseEvent {
50
- type: 'conversation_initiation_metadata';
51
- conversation_initiation_metadata_event: {
52
- conversation_id: string;
53
- };
54
- }
55
- export interface AgentResponseCorrectionEvent extends BaseEvent {
56
- type: 'agent_response_correction';
57
- agent_response_correction_event: {
58
- corrected_agent_response: string;
59
- original_agent_response: string;
60
- };
61
- }
62
- /** Union of all possible WebSocket events we care about */
63
- export type ElevenLabsWebSocketEvent = UserTranscriptEvent | AgentResponseEvent | AudioResponseEvent | InterruptionEvent | PingEvent | ConversationInitiationMetadataEvent | AgentResponseCorrectionEvent;
64
- /** Fetch signed URL from ElevenLabs API */
65
- export declare const getSignedUrl: ({ agentId, apiKey }: {
66
- agentId: string;
67
- apiKey: string;
68
- }) => Promise<string>;
69
- export {};
70
- //# sourceMappingURL=elevenLabsUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"elevenLabsUtils.d.ts","sourceRoot":"","sources":["../../src/voice/elevenLabsUtils.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,KAAK,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC,CAAC;IACH,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,IAAI,CAAC;CACb;AAID,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,mBAAoB,SAAQ,SAAS;IAC7C,IAAI,EAAE,iBAAiB,CAAC;IACxB,wBAAwB,EAAE;QACxB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAED,UAAU,kBAAmB,SAAQ,SAAS;IAC5C,IAAI,EAAE,gBAAgB,CAAC;IACvB,oBAAoB,EAAE;QACpB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;CACH;AAED,UAAU,kBAAmB,SAAQ,SAAS;IAC5C,IAAI,EAAE,OAAO,CAAC;IACd,WAAW,EAAE;QACX,aAAa,EAAE,MAAM,CAAC;QACtB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,UAAU,iBAAkB,SAAQ,SAAS;IAC3C,IAAI,EAAE,cAAc,CAAC;IACrB,kBAAkB,EAAE;QAClB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,UAAU,SAAU,SAAQ,SAAS;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE;QACV,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED,UAAU,mCAAoC,SAAQ,SAAS;IAC7D,IAAI,EAAE,kCAAkC,CAAC;IACzC,sCAAsC,EAAE;QACtC,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAED,MAAM,WAAW,4BAA6B,SAAQ,SAAS;IAC7D,IAAI,EAAE,2BAA2B,CAAC;IAClC,+BAA+B,EAAE;QAC/B,wBAAwB,EAAE,MAAM,CAAC;QACjC,uBAAuB,EAAE,MAAM,CAAC;KACjC,CAAC;CACH;AAED,2DAA2D;AAC3D,MAAM,MAAM,wBAAwB,GAChC,mBAAmB,GACnB,kBAAkB,GAClB,kBAAkB,GAClB,iBAAiB,GACjB,SAAS,GACT,mCAAmC,GACnC,4BAA4B,CAAC;AAIjC,2CAA2C;AAC3C,eAAO,MAAM,YAAY,GAAU,qBAAqB;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,KAAG,OAAO,CAAC,MAAM,CAe3G,CAAC"}
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSignedUrl = void 0;
4
- // ----------------- ElevenLabs Utility Functions -----------------
5
- /** Fetch signed URL from ElevenLabs API */
6
- const getSignedUrl = async ({ agentId, apiKey }) => {
7
- const response = await fetch(`https://api.elevenlabs.io/v1/convai/conversation/get_signed_url?agent_id=${agentId}`, {
8
- method: 'GET',
9
- headers: {
10
- 'xi-api-key': apiKey,
11
- },
12
- });
13
- if (!response.ok) {
14
- throw new Error(`Failed to fetch signed url - status ${response.status}`);
15
- }
16
- const body = await response.json();
17
- return body.signed_url;
18
- };
19
- exports.getSignedUrl = getSignedUrl;
20
- //# sourceMappingURL=elevenLabsUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"elevenLabsUtils.js","sourceRoot":"","sources":["../../src/voice/elevenLabsUtils.ts"],"names":[],"mappings":";;;AAkFA,mEAAmE;AAEnE,2CAA2C;AACpC,MAAM,YAAY,GAAG,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAuC,EAAmB,EAAE;IAC9G,MAAM,QAAQ,GAAG,MAAM,KAAK,CAC1B,4EAA4E,OAAO,EAAE,EACrF;QACE,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,YAAY,EAAE,MAAM;SACrB;KACF,CACF,CAAC;IACF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,uCAAuC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5E,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnC,OAAO,IAAI,CAAC,UAAU,CAAC;AACzB,CAAC,CAAC;AAfW,QAAA,YAAY,gBAevB"}
@@ -1,47 +0,0 @@
1
- import { Agent } from '../agent';
2
- /**
3
- * Voice Conversation class for managing individual ElevenLabs voice conversations
4
- */
5
- export declare class VoiceSession {
6
- private agent;
7
- private sessionId;
8
- private firstMessage;
9
- private voiceId?;
10
- private elevenLabsSocket?;
11
- private onAudioCallback?;
12
- private onInterruptionCallback?;
13
- private onMessageCallback?;
14
- private onDisconnectCallback?;
15
- constructor({ agent, sessionId, firstMessage, voiceId }: {
16
- agent: Agent;
17
- sessionId: string;
18
- firstMessage: string;
19
- voiceId?: string;
20
- });
21
- /**
22
- * Initialize the voice conversation connection
23
- */
24
- init(): Promise<void>;
25
- private sendToElevenLabs;
26
- private waitForSocketOpen;
27
- private setupSocketHandlers;
28
- private updateAgentResponse;
29
- hangup(): void;
30
- /**
31
- * Set callback for audio data in base64 format
32
- */
33
- onAudio(callback: (data: string) => void): void;
34
- /**
35
- * Set callback for interruption events
36
- */
37
- onInterruption(callback: () => void): void;
38
- /**
39
- * Set callback for disconnect events
40
- */
41
- onDisconnect(callback: () => void): void;
42
- /**
43
- * User audio in base64 format
44
- */
45
- sendAudio(audioData: string): void;
46
- }
47
- //# sourceMappingURL=voiceSession.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"voiceSession.d.ts","sourceRoot":"","sources":["../../src/voice/voiceSession.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAWjC;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,gBAAgB,CAAC,CAAY;IAErC,OAAO,CAAC,eAAe,CAAC,CAAyB;IACjD,OAAO,CAAC,sBAAsB,CAAC,CAAa;IAC5C,OAAO,CAAC,iBAAiB,CAAC,CAA+C;IACzE,OAAO,CAAC,oBAAoB,CAAC,CAAa;gBAE9B,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;IAQpI;;OAEG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YAoBpB,gBAAgB;YAQhB,iBAAiB;IAsB/B,OAAO,CAAC,mBAAmB;YAyGb,mBAAmB;IAe1B,MAAM,IAAI,IAAI;IAKrB;;OAEG;IACH,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI;IAI/C;;OAEG;IACH,cAAc,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAI1C;;OAEG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAIxC;;OAEG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;CAGnC"}