@minded-ai/mindedjs 1.0.96 → 1.0.97-beta-1236

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 (77) hide show
  1. package/dist/browserTask/README.md +419 -0
  2. package/dist/browserTask/browserAgent.py +632 -0
  3. package/dist/browserTask/captcha_isolated.png +0 -0
  4. package/dist/browserTask/executeBrowserTask.d.ts +2 -0
  5. package/dist/browserTask/executeBrowserTask.d.ts.map +1 -0
  6. package/dist/browserTask/executeBrowserTask.js +78 -0
  7. package/dist/browserTask/executeBrowserTask.js.map +1 -0
  8. package/dist/browserTask/executeBrowserTask.ts +78 -0
  9. package/dist/browserTask/requirements.txt +8 -0
  10. package/dist/browserTask/setup.sh +144 -0
  11. package/dist/cli/index.js +103 -1
  12. package/dist/cli/index.js.map +1 -1
  13. package/dist/nodes/addAppToolNode.js +2 -2
  14. package/dist/nodes/addAppToolNode.js.map +1 -1
  15. package/dist/nodes/addBrowserTaskNode.d.ts +11 -0
  16. package/dist/nodes/addBrowserTaskNode.d.ts.map +1 -0
  17. package/dist/nodes/addBrowserTaskNode.js +100 -0
  18. package/dist/nodes/addBrowserTaskNode.js.map +1 -0
  19. package/dist/nodes/nodeFactory.d.ts.map +1 -1
  20. package/dist/nodes/nodeFactory.js +4 -0
  21. package/dist/nodes/nodeFactory.js.map +1 -1
  22. package/dist/types/Flows.types.d.ts +9 -2
  23. package/dist/types/Flows.types.d.ts.map +1 -1
  24. package/dist/types/Flows.types.js +1 -0
  25. package/dist/types/Flows.types.js.map +1 -1
  26. package/dist/utils/logger.js +1 -1
  27. package/dist/utils/logger.js.map +1 -1
  28. package/docs/getting-started/installation.md +42 -0
  29. package/package.json +13 -5
  30. package/src/agent.ts +0 -897
  31. package/src/checkpointer/checkpointSaverFactory.ts +0 -18
  32. package/src/cli/index.ts +0 -170
  33. package/src/cli/lambdaHandlerTemplate.ts +0 -46
  34. package/src/edges/createDirectEdge.ts +0 -11
  35. package/src/edges/createLogicalRouter.ts +0 -98
  36. package/src/edges/createPromptRouter.ts +0 -210
  37. package/src/edges/edgeFactory.ts +0 -125
  38. package/src/events/AgentEvents.ts +0 -47
  39. package/src/events/index.ts +0 -3
  40. package/src/index.ts +0 -51
  41. package/src/interfaces/zendesk.ts +0 -157
  42. package/src/internalTools/appActionRunnerTool.ts +0 -75
  43. package/src/internalTools/sendPlaceholderMessage.ts +0 -27
  44. package/src/internalTools/timer.ts +0 -137
  45. package/src/llm/createLlmInstance.ts +0 -10
  46. package/src/nodes/addAppToolNode.ts +0 -95
  47. package/src/nodes/addHumanInTheLoopNode.ts +0 -25
  48. package/src/nodes/addJumpToNode.ts +0 -24
  49. package/src/nodes/addJunctionNode.ts +0 -19
  50. package/src/nodes/addPromptNode.ts +0 -117
  51. package/src/nodes/addToolNode.ts +0 -71
  52. package/src/nodes/addToolRunNode.ts +0 -74
  53. package/src/nodes/addTriggerNode.ts +0 -26
  54. package/src/nodes/nodeFactory.ts +0 -53
  55. package/src/platform/config.ts +0 -77
  56. package/src/platform/mindedChatOpenAI.ts +0 -19
  57. package/src/platform/mindedCheckpointSaver.ts +0 -146
  58. package/src/platform/mindedConnection.ts +0 -199
  59. package/src/platform/mindedConnectionTypes.ts +0 -191
  60. package/src/platform/piiGateway/gateway.ts +0 -103
  61. package/src/platform/piiGateway/index.ts +0 -5
  62. package/src/platform/piiGateway/types.ts +0 -29
  63. package/src/playbooks/playbooks.ts +0 -209
  64. package/src/triggers/triggerTypeToDefaultMessage.ts +0 -9
  65. package/src/types/Agent.types.ts +0 -67
  66. package/src/types/Flows.types.ts +0 -184
  67. package/src/types/LLM.types.ts +0 -15
  68. package/src/types/LangGraph.types.ts +0 -48
  69. package/src/types/Platform.types.ts +0 -1
  70. package/src/types/Tools.types.ts +0 -31
  71. package/src/types/Voice.types.ts +0 -4
  72. package/src/utils/extractStateMemoryResponse.ts +0 -16
  73. package/src/utils/history.ts +0 -9
  74. package/src/utils/logger.ts +0 -22
  75. package/src/utils/wait.ts +0 -1
  76. package/src/voice/elevenLabsUtils.ts +0 -81
  77. package/src/voice/voiceSession.ts +0 -295
@@ -1,209 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import * as yaml from 'js-yaml';
4
- import * as ejs from 'ejs';
5
- import * as mindedConnection from '../platform/mindedConnection';
6
- import { mindedConnectionSocketMessageType } from '../platform/mindedConnectionTypes';
7
- import { getConfig } from '../platform/config';
8
- import { logger } from '../utils/logger';
9
- import { OutputBlockData } from '@editorjs/editorjs';
10
-
11
- export type Playbook = {
12
- id: string;
13
- name: string;
14
- blocks: OutputBlockData[];
15
- };
16
-
17
- /**
18
- * Convert EditorJS blocks to markdown
19
- */
20
- function editorJsToMarkdown(blocks: OutputBlockData[]): string {
21
- if (!blocks || blocks.length === 0) {
22
- return '';
23
- }
24
-
25
- return blocks
26
- .map((block) => {
27
- try {
28
- switch (block.type) {
29
- case 'header': {
30
- const level = block.data?.level || 1;
31
- const headerPrefix = '#'.repeat(level);
32
- return `${headerPrefix} ${block.data?.text || ''}`;
33
- }
34
-
35
- case 'paragraph': {
36
- return block.data?.text || '';
37
- }
38
-
39
- case 'list': {
40
- const items = block.data?.items || [];
41
- const style = block.data?.style || 'unordered';
42
- return items
43
- .map((item: string, index: number) => {
44
- if (style === 'ordered') {
45
- return `${index + 1}. ${item}`;
46
- } else {
47
- return `- ${item}`;
48
- }
49
- })
50
- .join('\n');
51
- }
52
-
53
- case 'quote': {
54
- const text = block.data?.text || '';
55
- const caption = block.data?.caption ? `\n*${block.data.caption}*` : '';
56
- return `> ${text}${caption}`;
57
- }
58
-
59
- case 'code': {
60
- const code = block.data?.code || '';
61
- return `\`\`\`\n${code}\n\`\`\``;
62
- }
63
-
64
- case 'delimiter': {
65
- return '---';
66
- }
67
-
68
- default: {
69
- logger.warn(`Unknown playbook block type: ${block.type}`);
70
- return '';
71
- }
72
- }
73
- } catch (error) {
74
- logger.error({ message: 'Error converting EditorJS blocks to markdown', error, block });
75
- throw error;
76
- }
77
- })
78
- .join('\n\n');
79
- }
80
-
81
- /**
82
- * Load playbooks from directories or platform
83
- */
84
- export async function loadPlaybooks(playbooksDirectories?: string[]): Promise<Playbook[]> {
85
- const { env, isDeployed } = getConfig();
86
- let playbooks: Playbook[] = [];
87
-
88
- if (['sandbox-staging', 'sandbox'].includes(env) && isDeployed && mindedConnection.isConnected()) {
89
- // Load from platform
90
- const response = await mindedConnection.awaitEmit<object, { playbooks?: Playbook[]; error?: string }>(
91
- mindedConnectionSocketMessageType.GET_PLAYBOOKS,
92
- {},
93
- );
94
-
95
- if (response?.error) {
96
- throw new Error(`Failed to load playbooks from platform: ${response.error}`);
97
- }
98
-
99
- playbooks = response?.playbooks || [];
100
- } else if (playbooksDirectories) {
101
- // Load from directories
102
- playbooks = loadPlaybooksFromDirectories(playbooksDirectories);
103
- }
104
-
105
- return playbooks;
106
- }
107
-
108
- /**
109
- * Load playbooks from local directories
110
- */
111
- function loadPlaybooksFromDirectories(directories: string[]): Playbook[] {
112
- const playbooks: Playbook[] = [];
113
-
114
- for (const directory of directories) {
115
- if (!fs.existsSync(directory)) {
116
- logger.info(`Playbooks directory does not exist: ${directory}`);
117
- continue;
118
- }
119
-
120
- const files = getAllYamlFiles(directory);
121
-
122
- for (const file of files) {
123
- try {
124
- const fileContent = fs.readFileSync(file, 'utf8');
125
- const playbook = yaml.load(fileContent) as Playbook;
126
-
127
- if (playbook && playbook.name && playbook.blocks) {
128
- playbooks.push(playbook);
129
- logger.info(`Loaded playbook: ${playbook.name} from ${file}`);
130
- } else {
131
- logger.warn(`Invalid playbook structure in ${file}`);
132
- }
133
- } catch (error) {
134
- logger.error(`Failed to load playbook file ${file}: ${error}`);
135
- }
136
- }
137
- }
138
-
139
- return playbooks;
140
- }
141
-
142
- /**
143
- * Recursively get all YAML files in a directory
144
- */
145
- function getAllYamlFiles(dir: string): string[] {
146
- const files: string[] = [];
147
- const entries = fs.readdirSync(dir, { withFileTypes: true });
148
-
149
- for (const entry of entries) {
150
- const fullPath = path.join(dir, entry.name);
151
- if (entry.isDirectory()) {
152
- files.push(...getAllYamlFiles(fullPath));
153
- } else if (entry.name.endsWith('.yaml') || entry.name.endsWith('.yml')) {
154
- files.push(fullPath);
155
- }
156
- }
157
-
158
- return files;
159
- }
160
-
161
- /**
162
- * Compile playbooks into a single string with EJS and placeholders
163
- */
164
- export function compilePlaybooks(playbooks: Playbook[], params: Record<string, any> = {}): string {
165
- if (playbooks.length === 0) {
166
- return '';
167
- }
168
-
169
- // Combine all playbooks into sections
170
- const sections = playbooks.map((playbook) => {
171
- const markdownContent = editorJsToMarkdown(playbook.blocks);
172
- return `# ${playbook.name}\n${markdownContent}`;
173
- });
174
-
175
- const combinedPlaybooks = sections.join('\n\n');
176
-
177
- try {
178
- // First, render with EJS
179
- let compiledPlaybooks = ejs.render(combinedPlaybooks, params);
180
-
181
- // Then, replace placeholders in {} format
182
- compiledPlaybooks = replacePlaceholders(compiledPlaybooks, params);
183
-
184
- return compiledPlaybooks;
185
- } catch (error) {
186
- logger.error({ message: 'Error compiling playbooks', error });
187
- return combinedPlaybooks; // Return uncompiled if there's an error
188
- }
189
- }
190
-
191
- /**
192
- * Replace placeholders in {key} format
193
- */
194
- function replacePlaceholders(text: string, params: Record<string, any>): string {
195
- return text.replace(/\{([^}]+)\}/g, (match, key) => {
196
- const keys = key.split('.');
197
- let value: any = params;
198
-
199
- for (const k of keys) {
200
- if (value && typeof value === 'object' && k in value) {
201
- value = value[k];
202
- } else {
203
- return match; // Return original if key not found
204
- }
205
- }
206
-
207
- return String(value);
208
- });
209
- }
@@ -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;
@@ -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
- }
@@ -1,184 +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
- }
15
-
16
- export enum EdgeType {
17
- LOGICAL_CONDITION = 'logicalCondition',
18
- PROMPT_CONDITION = 'promptCondition',
19
- STEP_FORWARD = 'stepForward',
20
- }
21
-
22
- export interface BaseNode {
23
- name: string;
24
- type: NodeType;
25
- position?: Position;
26
- humanInTheLoop?: boolean;
27
- canStayOnNode?: boolean;
28
- displayName: string;
29
- }
30
-
31
- export enum TriggerType {
32
- APP = 'app',
33
- WEBHOOK = 'webhook',
34
- MANUAL = 'manual',
35
- VOICE = 'voice',
36
- }
37
-
38
- export interface BaseTriggerNode extends BaseNode {
39
- type: NodeType.TRIGGER;
40
- triggerType: TriggerType;
41
- }
42
-
43
- export interface BaseAppNode {
44
- appName: string;
45
- appImgSrc: string;
46
- account?: string;
47
- mockDataInstructions?: string;
48
- textSentToModel?: string;
49
- parameters?: Record<string, any>;
50
- }
51
-
52
- export interface AppTriggerNode extends BaseTriggerNode, BaseAppNode {
53
- triggerType: TriggerType.APP;
54
- appTriggerId: string;
55
- appTriggerName: string;
56
- promptInstructions?: string;
57
- }
58
-
59
- export interface WebhookTriggerNode extends BaseTriggerNode {
60
- triggerType: TriggerType.WEBHOOK;
61
- }
62
-
63
- export interface VoiceTriggerNode extends BaseTriggerNode {
64
- triggerType: TriggerType.VOICE;
65
- /**
66
- * Text that will be spoken as the very first message in a voice interaction.
67
- */
68
- firstMessage: string;
69
- /**
70
- * Optional ElevenLabs voice ID to be used for TTS.
71
- */
72
- voiceId?: string;
73
- }
74
-
75
- export interface ManualTriggerNode extends BaseTriggerNode {
76
- triggerType: TriggerType.MANUAL;
77
- }
78
-
79
- export interface PromptNode extends BaseNode {
80
- type: NodeType.PROMPT_NODE;
81
- prompt: string;
82
- llmConfig?: LLMConfig;
83
- }
84
-
85
- export interface JumpToNode extends BaseNode {
86
- type: NodeType.JUMP_TO_NODE;
87
- targetNodeId: string;
88
- }
89
-
90
- export type TriggerNode = AppTriggerNode | WebhookTriggerNode | ManualTriggerNode | VoiceTriggerNode;
91
-
92
- export interface JunctionNode extends BaseNode {
93
- type: NodeType.JUNCTION;
94
- }
95
-
96
- export interface ToolNode extends BaseNode {
97
- type: NodeType.TOOL;
98
- toolName: string;
99
- prompt: string;
100
- appImgSrc?: string;
101
- }
102
-
103
- export interface AppToolNode extends BaseNode, BaseAppNode {
104
- type: NodeType.APP_TOOL;
105
- prompt: string;
106
- appName: string;
107
- actionName: string;
108
- metadata: AppNodeMetadata;
109
- actionKey: string;
110
- }
111
-
112
- export type Node = TriggerNode | JunctionNode | ToolNode | AppToolNode | PromptNode | JumpToNode;
113
-
114
- export interface BaseEdge {
115
- source: string;
116
- target: string;
117
- type: EdgeType;
118
- }
119
-
120
- export interface LogicalConditionEdge extends BaseEdge {
121
- type: EdgeType.LOGICAL_CONDITION;
122
- condition: string;
123
- }
124
-
125
- export interface PromptConditionEdge extends BaseEdge {
126
- type: EdgeType.PROMPT_CONDITION;
127
- prompt: string;
128
- }
129
-
130
- export interface StepForwardEdge extends BaseEdge {
131
- type: EdgeType.STEP_FORWARD;
132
- }
133
-
134
- export type Edge = LogicalConditionEdge | PromptConditionEdge | StepForwardEdge;
135
-
136
- export enum AppNodeMetadataType {
137
- APP_TOOL = 'appTool',
138
- }
139
- export interface NodeMetadata {
140
- type: AppNodeMetadataType;
141
- }
142
- export interface AppNodeMetadata extends NodeMetadata {
143
- type: AppNodeMetadataType.APP_TOOL;
144
- schema: ActionInputParam[];
145
- }
146
-
147
- export type ActionInputParam = {
148
- name: string;
149
- type: ActionInputParamType;
150
- description: string;
151
- example: string | null;
152
- required: boolean;
153
- enum?: string[];
154
- items?: {
155
- type: ActionInputParamType;
156
- properties?: ActionInputParam[];
157
- };
158
- };
159
-
160
- export enum ActionInputParamType {
161
- String = 'string',
162
- Number = 'number',
163
- Boolean = 'boolean',
164
- Array = 'array',
165
- Object = 'object',
166
- Any = 'any',
167
- }
168
-
169
- export interface Flow {
170
- name: string;
171
- nodes: Node[];
172
- edges: Edge[];
173
- }
174
-
175
- export enum KnownTriggerNames {
176
- WEBHOOK = 'webhook',
177
- DASHBOARD_MESSAGE = 'dashboard_message',
178
- VOICE_MESSAGE = 'voice_message',
179
- }
180
-
181
- export enum internalNodesSuffix {
182
- HUMAN_IN_THE_LOOP = '_humanInTheLoop',
183
- TOOL_RUN = '_toolRun',
184
- }
@@ -1,15 +0,0 @@
1
- import { AzureChatOpenAI, ChatOpenAI } from '@langchain/openai';
2
- import { MindedChatOpenAI } from '../platform/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,48 +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
- }
17
- } else {
18
- res.push(message);
19
- }
20
- }
21
- return res;
22
- },
23
- }),
24
- memory: Annotation<Memory>({
25
- default: () => ({} as Memory),
26
- reducer: (a, b) => ({ ...a, ...b }),
27
- }),
28
- history: Annotation<Array<HistoryStep>>({
29
- default: () => [],
30
- reducer: (a, b) => a.concat(b),
31
- }),
32
- sessionId: Annotation<string>(),
33
- sessionType: Annotation<SessionType>({
34
- default: () => SessionType.TEXT,
35
- reducer: (a, b) => b || a,
36
- }),
37
- overrideStartFromNodeId: Annotation<string | null>({
38
- default: () => null,
39
- reducer: (a, b) => b,
40
- }),
41
- });
42
-
43
- // Default state annotation with any memory type
44
- export const stateAnnotation = createStateAnnotation();
45
-
46
- export type CompiledGraph = CompiledStateGraph<any, any, string>;
47
- export type PreCompiledGraph = StateGraph<any, any, string>;
48
- export type State<Memory = any> = ReturnType<typeof createStateAnnotation<Memory>>['State'];
@@ -1 +0,0 @@
1
- export type Environment = 'development' | 'sandbox' | 'production' | 'test' | 'sandbox-staging';
@@ -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
- }
@@ -1,4 +0,0 @@
1
- export type ElevenLabsContext = {
2
- sessionId: string;
3
- mindedToken: string;
4
- }
@@ -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;
@@ -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
- };
@@ -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 || 'info',
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));