@minded-ai/mindedjs 1.0.108 → 1.0.109-beta-1
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/dist/agent.d.ts +12 -12
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +37 -13
- package/dist/agent.js.map +1 -1
- package/dist/browserTask/README.md +419 -0
- package/dist/browserTask/browserAgent.py +632 -0
- package/dist/browserTask/captcha_isolated.png +0 -0
- package/dist/browserTask/executeBrowserTask.d.ts +1 -11
- package/dist/browserTask/executeBrowserTask.d.ts.map +1 -1
- package/dist/browserTask/executeBrowserTask.js +67 -170
- package/dist/browserTask/executeBrowserTask.js.map +1 -1
- package/dist/browserTask/executeBrowserTask.ts +79 -0
- package/dist/browserTask/requirements.txt +8 -0
- package/dist/browserTask/setup.sh +144 -0
- package/dist/cli/index.js +103 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/edges/createLogicalRouter.d.ts +3 -1
- package/dist/edges/createLogicalRouter.d.ts.map +1 -1
- package/dist/edges/createLogicalRouter.js +41 -2
- package/dist/edges/createLogicalRouter.js.map +1 -1
- package/dist/edges/edgeFactory.d.ts.map +1 -1
- package/dist/edges/edgeFactory.js +7 -7
- package/dist/edges/edgeFactory.js.map +1 -1
- package/dist/events/AgentEvents.d.ts +19 -1
- package/dist/events/AgentEvents.d.ts.map +1 -1
- package/dist/events/AgentEvents.js +2 -0
- package/dist/events/AgentEvents.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/internalTools/timer.d.ts +3 -3
- package/dist/internalTools/timer.d.ts.map +1 -1
- package/dist/internalTools/timer.js +3 -3
- package/dist/internalTools/timer.js.map +1 -1
- package/dist/nodes/addBrowserTaskNode.d.ts +1 -3
- package/dist/nodes/addBrowserTaskNode.d.ts.map +1 -1
- package/dist/nodes/addBrowserTaskNode.js +54 -186
- package/dist/nodes/addBrowserTaskNode.js.map +1 -1
- package/dist/nodes/nodeFactory.js +1 -1
- package/dist/nodes/nodeFactory.js.map +1 -1
- package/docs/SUMMARY.md +8 -4
- package/docs/low-code-editor/edges.md +4 -0
- package/docs/sdk/debugging.md +342 -0
- package/docs/{platform → sdk}/events.md +168 -1
- package/package.json +12 -5
- package/dist/nodes/addBrowserTaskRunNode.d.ts +0 -13
- package/dist/nodes/addBrowserTaskRunNode.d.ts.map +0 -1
- package/dist/nodes/addBrowserTaskRunNode.js +0 -130
- package/dist/nodes/addBrowserTaskRunNode.js.map +0 -1
- package/src/agent.ts +0 -928
- package/src/browserTask/executeBrowserTask.ts +0 -213
- package/src/checkpointer/checkpointSaverFactory.ts +0 -18
- package/src/cli/index.ts +0 -170
- package/src/cli/lambdaHandlerTemplate.ts +0 -45
- package/src/edges/createDirectEdge.ts +0 -16
- package/src/edges/createLogicalRouter.ts +0 -114
- package/src/edges/createPromptRouter.ts +0 -218
- package/src/edges/edgeFactory.ts +0 -141
- package/src/events/AgentEvents.ts +0 -47
- package/src/events/index.ts +0 -3
- package/src/index.ts +0 -70
- package/src/interfaces/zendesk.ts +0 -157
- package/src/internalTools/appActionRunnerTool.ts +0 -68
- package/src/internalTools/documentExtraction/documentExtraction.ts +0 -809
- package/src/internalTools/documentExtraction/types.ts +0 -59
- package/src/internalTools/libraryActionRunnerTool.ts +0 -63
- package/src/internalTools/retell.ts +0 -28
- package/src/internalTools/sendPlaceholderMessage.ts +0 -27
- package/src/internalTools/timer.ts +0 -137
- package/src/llm/createLlmInstance.ts +0 -33
- package/src/nodes/addAppToolNode.ts +0 -106
- package/src/nodes/addBrowserTaskNode.ts +0 -231
- package/src/nodes/addBrowserTaskRunNode.ts +0 -144
- package/src/nodes/addHumanInTheLoopNode.ts +0 -25
- package/src/nodes/addJumpToNode.ts +0 -25
- package/src/nodes/addJunctionNode.ts +0 -20
- package/src/nodes/addPromptNode.ts +0 -119
- package/src/nodes/addToolNode.ts +0 -72
- package/src/nodes/addToolRunNode.ts +0 -76
- package/src/nodes/addTriggerNode.ts +0 -27
- package/src/nodes/nodeFactory.ts +0 -57
- package/src/platform/config.ts +0 -77
- package/src/platform/mindedCheckpointSaver.ts +0 -146
- package/src/platform/mindedConnection.ts +0 -199
- package/src/platform/mindedConnectionTypes.ts +0 -220
- package/src/platform/models/mindedChatOpenAI.ts +0 -49
- package/src/platform/models/parallelWrapper.ts +0 -141
- package/src/platform/piiGateway/gateway.ts +0 -103
- package/src/platform/piiGateway/index.ts +0 -5
- package/src/platform/piiGateway/types.ts +0 -29
- package/src/platform/utils/parseAttachments.ts +0 -56
- package/src/playbooks/playbooks.ts +0 -209
- package/src/toolsLibrary/index.ts +0 -6
- package/src/toolsLibrary/parseDocument.ts +0 -136
- package/src/triggers/triggerTypeToDefaultMessage.ts +0 -9
- package/src/types/Agent.types.ts +0 -67
- package/src/types/Flows.types.ts +0 -200
- package/src/types/LLM.types.ts +0 -15
- package/src/types/LangGraph.types.ts +0 -53
- package/src/types/Platform.types.ts +0 -1
- package/src/types/Tools.types.ts +0 -31
- package/src/types/Voice.types.ts +0 -4
- package/src/utils/extractStateMemoryResponse.ts +0 -16
- package/src/utils/history.ts +0 -9
- package/src/utils/logger.ts +0 -22
- package/src/utils/wait.ts +0 -1
- package/src/voice/elevenLabsUtils.ts +0 -81
- package/src/voice/voiceSession.ts +0 -294
- /package/docs/{platform → sdk}/logging.md +0 -0
- /package/docs/{platform → sdk}/memory.md +0 -0
- /package/docs/{platform → sdk}/parallel-llm.md +0 -0
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { BaseMessage, HumanMessage } from '@langchain/core/messages';
|
|
2
|
-
|
|
3
|
-
const triggerTypeToDefaultMessage: Record<string, Record<string, (triggerBody: any) => Array<BaseMessage>>> = {
|
|
4
|
-
['Slack']: {
|
|
5
|
-
'New Direct Message (Instant)': (triggerBody: any) => [new HumanMessage({ content: triggerBody.text })],
|
|
6
|
-
},
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export default triggerTypeToDefaultMessage;
|
package/src/types/Agent.types.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { AgentEventRequestPayloads, AgentEventResponsePayloads } from '../events/AgentEvents';
|
|
2
|
-
import { LLMConfig } from './LLM.types';
|
|
3
|
-
import { NodeType } from './Flows.types';
|
|
4
|
-
|
|
5
|
-
export type EmitSignature<Memory, E extends keyof AgentEventRequestPayloads<Memory>> = (
|
|
6
|
-
event: E,
|
|
7
|
-
payload: AgentEventRequestPayloads<Memory>[E],
|
|
8
|
-
) => Promise<AgentEventResponsePayloads<Memory>[E][]>;
|
|
9
|
-
|
|
10
|
-
export type MindedSDKConfig = {
|
|
11
|
-
flows: string[];
|
|
12
|
-
llm: LLMConfig;
|
|
13
|
-
tools: string[];
|
|
14
|
-
/**
|
|
15
|
-
* Optional directories containing playbook definition files. If omitted, no playbooks will be loaded.
|
|
16
|
-
*/
|
|
17
|
-
playbooks?: string[];
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Parameters for the Agent invoke method
|
|
22
|
-
*/
|
|
23
|
-
export interface AgentInvokeParams {
|
|
24
|
-
/** The payload/data associated with the trigger */
|
|
25
|
-
triggerBody: any;
|
|
26
|
-
/** The name/type of the trigger being invoked */
|
|
27
|
-
triggerName: string;
|
|
28
|
-
/** Optional session identifier for conversation continuity */
|
|
29
|
-
sessionId?: string;
|
|
30
|
-
/** Optional name of the application triggering the agent in case of an app trigger */
|
|
31
|
-
appName?: string;
|
|
32
|
-
}
|
|
33
|
-
export interface HistoryStep {
|
|
34
|
-
type: NodeType;
|
|
35
|
-
step: number;
|
|
36
|
-
raw: any;
|
|
37
|
-
nodeId: string;
|
|
38
|
-
nodeDisplayName: string;
|
|
39
|
-
messageIds?: string[];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface AppTriggerHistoryStep extends HistoryStep {
|
|
43
|
-
type: NodeType.TRIGGER;
|
|
44
|
-
appName: string;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface TriggerHistoryStep extends HistoryStep {
|
|
48
|
-
type: NodeType.TRIGGER;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export interface AppActionInvocationHistoryStep extends HistoryStep {
|
|
52
|
-
type: NodeType.APP_TOOL;
|
|
53
|
-
appName: string;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface CustomActionInvocationHistoryStep extends HistoryStep {
|
|
57
|
-
type: NodeType.TOOL;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface JunctionHistoryStep extends HistoryStep {
|
|
61
|
-
type: NodeType.JUNCTION;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export enum SessionType {
|
|
65
|
-
VOICE = 'voice',
|
|
66
|
-
TEXT = 'text',
|
|
67
|
-
}
|
package/src/types/Flows.types.ts
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import { LLMConfig } from './LLM.types';
|
|
2
|
-
export interface Position {
|
|
3
|
-
x: number;
|
|
4
|
-
y: number;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export enum NodeType {
|
|
8
|
-
TRIGGER = 'trigger',
|
|
9
|
-
JUNCTION = 'junction',
|
|
10
|
-
TOOL = 'tool',
|
|
11
|
-
APP_TOOL = 'appTool',
|
|
12
|
-
PROMPT_NODE = 'promptNode',
|
|
13
|
-
JUMP_TO_NODE = 'jumpToNode',
|
|
14
|
-
BROWSER_TASK = 'browserTask',
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export enum EdgeType {
|
|
18
|
-
LOGICAL_CONDITION = 'logicalCondition',
|
|
19
|
-
PROMPT_CONDITION = 'promptCondition',
|
|
20
|
-
STEP_FORWARD = 'stepForward',
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface BaseNode {
|
|
24
|
-
name: string;
|
|
25
|
-
type: NodeType;
|
|
26
|
-
position?: Position;
|
|
27
|
-
humanInTheLoop?: boolean;
|
|
28
|
-
canStayOnNode?: boolean;
|
|
29
|
-
displayName: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export enum TriggerType {
|
|
33
|
-
APP = 'app',
|
|
34
|
-
WEBHOOK = 'webhook',
|
|
35
|
-
MANUAL = 'manual',
|
|
36
|
-
VOICE = 'voice',
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface BaseTriggerNode extends BaseNode {
|
|
40
|
-
type: NodeType.TRIGGER;
|
|
41
|
-
triggerType: TriggerType;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface BaseAppNode {
|
|
45
|
-
appName: string;
|
|
46
|
-
appImgSrc: string;
|
|
47
|
-
account?: string;
|
|
48
|
-
mockDataInstructions?: string;
|
|
49
|
-
textSentToModel?: string;
|
|
50
|
-
parameters?: Record<string, any>;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface AppTriggerNode extends BaseTriggerNode, BaseAppNode {
|
|
54
|
-
triggerType: TriggerType.APP;
|
|
55
|
-
appTriggerId: string;
|
|
56
|
-
appTriggerName: string;
|
|
57
|
-
promptInstructions?: string;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface WebhookTriggerNode extends BaseTriggerNode {
|
|
61
|
-
triggerType: TriggerType.WEBHOOK;
|
|
62
|
-
autoTrigger?: boolean;
|
|
63
|
-
defaultPayload?: string;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface VoiceTriggerNode extends BaseTriggerNode {
|
|
67
|
-
triggerType: TriggerType.VOICE;
|
|
68
|
-
/**
|
|
69
|
-
* Text that will be spoken as the very first message in a voice interaction.
|
|
70
|
-
*/
|
|
71
|
-
firstMessage: string;
|
|
72
|
-
/**
|
|
73
|
-
* Optional ElevenLabs voice ID to be used for TTS.
|
|
74
|
-
*/
|
|
75
|
-
voiceId?: string;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export interface ManualTriggerNode extends BaseTriggerNode {
|
|
79
|
-
triggerType: TriggerType.MANUAL;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export interface PromptNode extends BaseNode {
|
|
83
|
-
type: NodeType.PROMPT_NODE;
|
|
84
|
-
prompt: string;
|
|
85
|
-
llmConfig?: LLMConfig;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export interface JumpToNode extends BaseNode {
|
|
89
|
-
type: NodeType.JUMP_TO_NODE;
|
|
90
|
-
targetNodeId: string;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export interface BrowserTaskNode extends BaseNode {
|
|
94
|
-
type: NodeType.BROWSER_TASK;
|
|
95
|
-
prompt: string;
|
|
96
|
-
model?: string;
|
|
97
|
-
inputSchema?: {
|
|
98
|
-
name: string;
|
|
99
|
-
type: 'string' | 'number';
|
|
100
|
-
description?: string;
|
|
101
|
-
required?: boolean;
|
|
102
|
-
}[];
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export type TriggerNode = AppTriggerNode | WebhookTriggerNode | ManualTriggerNode | VoiceTriggerNode;
|
|
106
|
-
|
|
107
|
-
export interface JunctionNode extends BaseNode {
|
|
108
|
-
type: NodeType.JUNCTION;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export interface ToolNode extends BaseNode {
|
|
112
|
-
type: NodeType.TOOL;
|
|
113
|
-
toolName: string;
|
|
114
|
-
prompt: string;
|
|
115
|
-
appImgSrc?: string;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export interface AppToolNode extends BaseNode, BaseAppNode {
|
|
119
|
-
type: NodeType.APP_TOOL;
|
|
120
|
-
prompt: string;
|
|
121
|
-
appName: string;
|
|
122
|
-
actionName: string;
|
|
123
|
-
metadata: AppNodeMetadata;
|
|
124
|
-
actionKey: string;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export type Node = TriggerNode | JunctionNode | ToolNode | AppToolNode | PromptNode | JumpToNode | BrowserTaskNode;
|
|
128
|
-
|
|
129
|
-
export interface BaseEdge {
|
|
130
|
-
source: string;
|
|
131
|
-
target: string;
|
|
132
|
-
type: EdgeType;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export interface LogicalConditionEdge extends BaseEdge {
|
|
136
|
-
type: EdgeType.LOGICAL_CONDITION;
|
|
137
|
-
condition: string;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export interface PromptConditionEdge extends BaseEdge {
|
|
141
|
-
type: EdgeType.PROMPT_CONDITION;
|
|
142
|
-
prompt: string;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export interface StepForwardEdge extends BaseEdge {
|
|
146
|
-
type: EdgeType.STEP_FORWARD;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export type Edge = LogicalConditionEdge | PromptConditionEdge | StepForwardEdge;
|
|
150
|
-
|
|
151
|
-
export enum AppNodeMetadataType {
|
|
152
|
-
APP_TOOL = 'appTool',
|
|
153
|
-
}
|
|
154
|
-
export interface NodeMetadata {
|
|
155
|
-
type: AppNodeMetadataType;
|
|
156
|
-
}
|
|
157
|
-
export interface AppNodeMetadata extends NodeMetadata {
|
|
158
|
-
type: AppNodeMetadataType.APP_TOOL;
|
|
159
|
-
schema: ActionInputParam[];
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export type ActionInputParam = {
|
|
163
|
-
name: string;
|
|
164
|
-
type: ActionInputParamType;
|
|
165
|
-
description: string;
|
|
166
|
-
example: string | null;
|
|
167
|
-
required: boolean;
|
|
168
|
-
enum?: string[];
|
|
169
|
-
items?: {
|
|
170
|
-
type: ActionInputParamType;
|
|
171
|
-
properties?: ActionInputParam[];
|
|
172
|
-
};
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
export enum ActionInputParamType {
|
|
176
|
-
String = 'string',
|
|
177
|
-
Number = 'number',
|
|
178
|
-
Boolean = 'boolean',
|
|
179
|
-
Array = 'array',
|
|
180
|
-
Object = 'object',
|
|
181
|
-
Any = 'any',
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export interface Flow {
|
|
185
|
-
name: string;
|
|
186
|
-
nodes: Node[];
|
|
187
|
-
edges: Edge[];
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export enum KnownTriggerNames {
|
|
191
|
-
WEBHOOK = 'webhook',
|
|
192
|
-
DASHBOARD_MESSAGE = 'dashboard_message',
|
|
193
|
-
VOICE_MESSAGE = 'voice_message',
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
export enum internalNodesSuffix {
|
|
197
|
-
HUMAN_IN_THE_LOOP = '_humanInTheLoop',
|
|
198
|
-
TOOL_RUN = '_toolRun',
|
|
199
|
-
BROWSER_TASK_RUN = '_browserTaskRun',
|
|
200
|
-
}
|
package/src/types/LLM.types.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { AzureChatOpenAI, ChatOpenAI } from '@langchain/openai';
|
|
2
|
-
import { MindedChatOpenAI } from '../platform/models/mindedChatOpenAI';
|
|
3
|
-
|
|
4
|
-
export type LLMConfig = {
|
|
5
|
-
name: string;
|
|
6
|
-
properties: Record<string, any>;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export type LLMProvider = 'ChatOpenAI' | 'AzureChatOpenAI' | 'MindedChatOpenAI';
|
|
10
|
-
|
|
11
|
-
export const LLMProviders: Record<LLMProvider, any> = {
|
|
12
|
-
ChatOpenAI: ChatOpenAI,
|
|
13
|
-
AzureChatOpenAI: AzureChatOpenAI,
|
|
14
|
-
MindedChatOpenAI,
|
|
15
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { BaseMessage } from '@langchain/core/messages';
|
|
2
|
-
import { Annotation, CompiledStateGraph, StateGraph } from '@langchain/langgraph';
|
|
3
|
-
import { HistoryStep, SessionType } from './Agent.types';
|
|
4
|
-
|
|
5
|
-
export const createStateAnnotation = <Memory = any>() =>
|
|
6
|
-
Annotation.Root({
|
|
7
|
-
messages: Annotation<Array<BaseMessage>>({
|
|
8
|
-
default: () => [],
|
|
9
|
-
reducer: (prevMessages, newMessages) => {
|
|
10
|
-
const res = [...prevMessages];
|
|
11
|
-
for (const message of newMessages) {
|
|
12
|
-
if (message.additional_kwargs?.update) {
|
|
13
|
-
const index = res.findIndex((m) => m.id && m.id === message.id);
|
|
14
|
-
if (index !== -1) {
|
|
15
|
-
res[index].content = message.content;
|
|
16
|
-
res[index].additional_kwargs = { ...res[index].additional_kwargs, ...message.additional_kwargs };
|
|
17
|
-
}
|
|
18
|
-
} else {
|
|
19
|
-
res.push(message);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return res;
|
|
23
|
-
},
|
|
24
|
-
}),
|
|
25
|
-
memory: Annotation<Memory>({
|
|
26
|
-
default: () => ({} as Memory),
|
|
27
|
-
reducer: (a, b) => ({ ...a, ...b }),
|
|
28
|
-
}),
|
|
29
|
-
history: Annotation<Array<HistoryStep>>({
|
|
30
|
-
default: () => [],
|
|
31
|
-
reducer: (a, b) => a.concat(b),
|
|
32
|
-
}),
|
|
33
|
-
sessionId: Annotation<string>(),
|
|
34
|
-
goto: Annotation<string | null | undefined>({
|
|
35
|
-
default: () => null,
|
|
36
|
-
reducer: (a, b) => b,
|
|
37
|
-
}),
|
|
38
|
-
sessionType: Annotation<SessionType>({
|
|
39
|
-
default: () => SessionType.TEXT,
|
|
40
|
-
reducer: (a, b) => b || a,
|
|
41
|
-
}),
|
|
42
|
-
overrideStartFromNodeId: Annotation<string | null>({
|
|
43
|
-
default: () => null,
|
|
44
|
-
reducer: (a, b) => b,
|
|
45
|
-
}),
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
// Default state annotation with any memory type
|
|
49
|
-
export const stateAnnotation = createStateAnnotation();
|
|
50
|
-
|
|
51
|
-
export type CompiledGraph = CompiledStateGraph<any, any, string>;
|
|
52
|
-
export type PreCompiledGraph = StateGraph<any, any, string>;
|
|
53
|
-
export type State<Memory = any> = ReturnType<typeof createStateAnnotation<Memory>>['State'];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type Environment = 'development' | 'sandbox' | 'production' | 'test' | 'sandbox-staging';
|
package/src/types/Tools.types.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { Agent } from '../';
|
|
3
|
-
import { State } from './LangGraph.types';
|
|
4
|
-
|
|
5
|
-
// Type for state updates that allows partial memory
|
|
6
|
-
type StateUpdate<Memory = any> = Omit<Partial<State<Memory>>, 'memory'> & {
|
|
7
|
-
memory?: Partial<Memory>;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
// Valid return type for new API
|
|
11
|
-
export type ToolReturnType<Memory = any> = ({ state?: StateUpdate<Memory>; result?: any }) | void;
|
|
12
|
-
|
|
13
|
-
export interface Tool<Input extends z.ZodSchema, Memory = any> {
|
|
14
|
-
name: string;
|
|
15
|
-
description: string;
|
|
16
|
-
input: Input;
|
|
17
|
-
isGlobal?: boolean;
|
|
18
|
-
execute: (input: ToolExecuteInput<Input, Memory>) => Promise<ToolReturnType<Memory>>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface ToolExecuteInput<Input extends z.ZodSchema, Memory = any> {
|
|
22
|
-
input: z.infer<Input>;
|
|
23
|
-
state: State<Memory>;
|
|
24
|
-
agent: Agent;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface AppActionRunnerInput {
|
|
28
|
-
appName: string;
|
|
29
|
-
actionName: string;
|
|
30
|
-
actionInput: object;
|
|
31
|
-
}
|
package/src/types/Voice.types.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ToolMessage } from '@langchain/core/messages';
|
|
2
|
-
import { logger } from './logger';
|
|
3
|
-
|
|
4
|
-
const extractToolStateResponse = <State>(toolMessage: ToolMessage): Partial<State> => {
|
|
5
|
-
try {
|
|
6
|
-
const parsed = JSON.parse(toolMessage.content as string);
|
|
7
|
-
if (typeof parsed === 'object' && parsed !== null && 'state' in parsed) {
|
|
8
|
-
return parsed.state;
|
|
9
|
-
}
|
|
10
|
-
} catch (error) {
|
|
11
|
-
logger.error({ msg: 'Error parsing tool state response', error });
|
|
12
|
-
}
|
|
13
|
-
return {};
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default extractToolStateResponse;
|
package/src/utils/history.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { HistoryStep } from '../types/Agent.types';
|
|
2
|
-
|
|
3
|
-
export const createHistoryStep = <T extends HistoryStep>(currentHistory: HistoryStep[], stepPayload: Omit<T, 'step'>): HistoryStep => {
|
|
4
|
-
const lastHistoryStep = currentHistory?.[currentHistory?.length - 1];
|
|
5
|
-
return {
|
|
6
|
-
...stepPayload,
|
|
7
|
-
step: lastHistoryStep?.step + 1 || 0,
|
|
8
|
-
} as HistoryStep;
|
|
9
|
-
};
|
package/src/utils/logger.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import pino from 'pino';
|
|
2
|
-
import dotenv from 'dotenv';
|
|
3
|
-
dotenv.config();
|
|
4
|
-
|
|
5
|
-
// Create a Pino logger with a custom log format
|
|
6
|
-
export const logger = pino({
|
|
7
|
-
level: process.env.LOG_LEVEL || 'trace',
|
|
8
|
-
base: null,
|
|
9
|
-
transport: {
|
|
10
|
-
target: 'pino-pretty',
|
|
11
|
-
options: {
|
|
12
|
-
colorize: true,
|
|
13
|
-
crlf: true,
|
|
14
|
-
translateTime: 'SYS:standard',
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
formatters: {
|
|
18
|
-
level(label) {
|
|
19
|
-
return { level: label };
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
});
|
package/src/utils/wait.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
// ----------------- ElevenLabs WebSocket event types -----------------
|
|
2
|
-
|
|
3
|
-
interface BaseEvent {
|
|
4
|
-
type: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
interface UserTranscriptEvent extends BaseEvent {
|
|
8
|
-
type: 'user_transcript';
|
|
9
|
-
user_transcription_event: {
|
|
10
|
-
user_transcript: string;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface AgentResponseEvent extends BaseEvent {
|
|
15
|
-
type: 'agent_response';
|
|
16
|
-
agent_response_event: {
|
|
17
|
-
agent_response: string;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface AudioResponseEvent extends BaseEvent {
|
|
22
|
-
type: 'audio';
|
|
23
|
-
audio_event: {
|
|
24
|
-
audio_base_64: string;
|
|
25
|
-
event_id: number;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface InterruptionEvent extends BaseEvent {
|
|
30
|
-
type: 'interruption';
|
|
31
|
-
interruption_event: {
|
|
32
|
-
event_id: number;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface PingEvent extends BaseEvent {
|
|
37
|
-
type: 'ping';
|
|
38
|
-
ping_event: {
|
|
39
|
-
event_id: number;
|
|
40
|
-
ping_ms: number;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
interface ConversationInitiationMetadataEvent extends BaseEvent {
|
|
45
|
-
type: 'conversation_initiation_metadata';
|
|
46
|
-
conversation_initiation_metadata_event: {
|
|
47
|
-
conversation_id: string;
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export interface AgentResponseCorrectionEvent extends BaseEvent {
|
|
52
|
-
type: 'agent_response_correction';
|
|
53
|
-
agent_response_correction_event: {
|
|
54
|
-
corrected_agent_response: string;
|
|
55
|
-
original_agent_response: string;
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** Union of all possible WebSocket events we care about */
|
|
60
|
-
export type ElevenLabsWebSocketEvent =
|
|
61
|
-
| UserTranscriptEvent
|
|
62
|
-
| AgentResponseEvent
|
|
63
|
-
| AudioResponseEvent
|
|
64
|
-
| InterruptionEvent
|
|
65
|
-
| PingEvent
|
|
66
|
-
| ConversationInitiationMetadataEvent
|
|
67
|
-
| AgentResponseCorrectionEvent;
|
|
68
|
-
|
|
69
|
-
/** Shape of the message sent to ElevenLabs when starting a conversation */
|
|
70
|
-
export interface ConversationInitiationClientData {
|
|
71
|
-
type: 'conversation_initiation_client_data';
|
|
72
|
-
conversation_config_override: {
|
|
73
|
-
agent: {
|
|
74
|
-
first_message: string;
|
|
75
|
-
language: string;
|
|
76
|
-
};
|
|
77
|
-
tts?: {
|
|
78
|
-
voice_id: string;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
}
|