@eko-ai/eko 1.0.1-5.alpha-2
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/LICENSE +21 -0
- package/README.md +139 -0
- package/dist/core/eko.d.ts +22 -0
- package/dist/core/tool-registry.d.ts +13 -0
- package/dist/extension/content/index.d.ts +16 -0
- package/dist/extension/core.d.ts +11 -0
- package/dist/extension/index.d.ts +7 -0
- package/dist/extension/script/bing.js +25 -0
- package/dist/extension/script/build_dom_tree.d.ts +38 -0
- package/dist/extension/script/build_dom_tree.js +662 -0
- package/dist/extension/script/common.js +212 -0
- package/dist/extension/script/duckduckgo.js +25 -0
- package/dist/extension/script/google.js +26 -0
- package/dist/extension/tools/browser.d.ts +22 -0
- package/dist/extension/tools/browser_use.d.ts +19 -0
- package/dist/extension/tools/element_click.d.ts +12 -0
- package/dist/extension/tools/export_file.d.ts +18 -0
- package/dist/extension/tools/extract_content.d.ts +18 -0
- package/dist/extension/tools/find_element_position.d.ts +12 -0
- package/dist/extension/tools/get_all_tabs.d.ts +9 -0
- package/dist/extension/tools/html_script.d.ts +10 -0
- package/dist/extension/tools/index.d.ts +13 -0
- package/dist/extension/tools/open_url.d.ts +18 -0
- package/dist/extension/tools/request_login.d.ts +10 -0
- package/dist/extension/tools/screenshot.d.ts +18 -0
- package/dist/extension/tools/tab_management.d.ts +19 -0
- package/dist/extension/tools/web_search.d.ts +18 -0
- package/dist/extension/utils.d.ts +31 -0
- package/dist/extension.cjs.js +2322 -0
- package/dist/extension.esm.js +2315 -0
- package/dist/extension_content_script.js +424 -0
- package/dist/fellou/computer.d.ts +20 -0
- package/dist/fellou/index.d.ts +6 -0
- package/dist/fellou/tools/computer_use.d.ts +18 -0
- package/dist/fellou.cjs.js +238 -0
- package/dist/fellou.esm.js +235 -0
- package/dist/index.cjs.js +9943 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.esm.js +9932 -0
- package/dist/models/action.d.ts +26 -0
- package/dist/models/workflow.d.ts +23 -0
- package/dist/nodejs/core.d.ts +2 -0
- package/dist/nodejs/index.d.ts +3 -0
- package/dist/nodejs/script/build_dom_tree.d.ts +1 -0
- package/dist/nodejs/tools/browser_use.d.ts +28 -0
- package/dist/nodejs/tools/command_execute.d.ts +12 -0
- package/dist/nodejs/tools/file_read.d.ts +11 -0
- package/dist/nodejs/tools/file_write.d.ts +15 -0
- package/dist/nodejs/tools/index.d.ts +5 -0
- package/dist/nodejs.cjs.js +71908 -0
- package/dist/nodejs.esm.js +71905 -0
- package/dist/schemas/workflow.schema.d.ts +77 -0
- package/dist/services/llm/claude-provider.d.ts +12 -0
- package/dist/services/llm/openai-provider.d.ts +12 -0
- package/dist/services/parser/workflow-parser.d.ts +23 -0
- package/dist/services/workflow/generator.d.ts +14 -0
- package/dist/services/workflow/templates.d.ts +8 -0
- package/dist/types/action.types.d.ts +45 -0
- package/dist/types/eko.types.d.ts +24 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/llm.types.d.ts +52 -0
- package/dist/types/parser.types.d.ts +9 -0
- package/dist/types/tools.types.d.ts +131 -0
- package/dist/types/workflow.types.d.ts +54 -0
- package/dist/universal_tools/cancel_workflow.d.ts +9 -0
- package/dist/universal_tools/human.d.ts +30 -0
- package/dist/universal_tools/index.d.ts +4 -0
- package/dist/universal_tools/summary_workflow.d.ts +9 -0
- package/dist/utils/execution-logger.d.ts +69 -0
- package/dist/web/core.d.ts +2 -0
- package/dist/web/index.d.ts +5 -0
- package/dist/web/script/build_dom_tree.d.ts +10 -0
- package/dist/web/tools/browser.d.ts +21 -0
- package/dist/web/tools/browser_use.d.ts +19 -0
- package/dist/web/tools/element_click.d.ts +12 -0
- package/dist/web/tools/export_file.d.ts +18 -0
- package/dist/web/tools/extract_content.d.ts +17 -0
- package/dist/web/tools/find_element_position.d.ts +12 -0
- package/dist/web/tools/html_script.d.ts +10 -0
- package/dist/web/tools/index.d.ts +8 -0
- package/dist/web/tools/screenshot.d.ts +18 -0
- package/dist/web.cjs.js +9651 -0
- package/dist/web.esm.js +9647 -0
- package/package.json +106 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export declare const workflowSchema: {
|
|
2
|
+
type: string;
|
|
3
|
+
required: string[];
|
|
4
|
+
properties: {
|
|
5
|
+
id: {
|
|
6
|
+
type: string;
|
|
7
|
+
};
|
|
8
|
+
name: {
|
|
9
|
+
type: string;
|
|
10
|
+
};
|
|
11
|
+
description: {
|
|
12
|
+
type: string;
|
|
13
|
+
};
|
|
14
|
+
nodes: {
|
|
15
|
+
type: string;
|
|
16
|
+
items: {
|
|
17
|
+
type: string;
|
|
18
|
+
required: string[];
|
|
19
|
+
properties: {
|
|
20
|
+
id: {
|
|
21
|
+
type: string;
|
|
22
|
+
};
|
|
23
|
+
type: {
|
|
24
|
+
type: string;
|
|
25
|
+
enum: string[];
|
|
26
|
+
};
|
|
27
|
+
dependencies: {
|
|
28
|
+
type: string;
|
|
29
|
+
items: {
|
|
30
|
+
type: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
output: {
|
|
34
|
+
type: string;
|
|
35
|
+
properties: {
|
|
36
|
+
name: {
|
|
37
|
+
type: string;
|
|
38
|
+
};
|
|
39
|
+
description: {
|
|
40
|
+
type: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
action: {
|
|
45
|
+
type: string;
|
|
46
|
+
required: string[];
|
|
47
|
+
properties: {
|
|
48
|
+
type: {
|
|
49
|
+
type: string;
|
|
50
|
+
enum: string[];
|
|
51
|
+
};
|
|
52
|
+
name: {
|
|
53
|
+
type: string;
|
|
54
|
+
};
|
|
55
|
+
description: {
|
|
56
|
+
type: string;
|
|
57
|
+
};
|
|
58
|
+
params: {
|
|
59
|
+
type: string;
|
|
60
|
+
};
|
|
61
|
+
tools: {
|
|
62
|
+
type: string;
|
|
63
|
+
items: {
|
|
64
|
+
type: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
variables: {
|
|
73
|
+
type: string;
|
|
74
|
+
additionalProperties: boolean;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Anthropic, { ClientOptions } from '@anthropic-ai/sdk';
|
|
2
|
+
import { LLMProvider, LLMParameters, LLMResponse, Message, LLMStreamHandler } from '../../types/llm.types';
|
|
3
|
+
export declare class ClaudeProvider implements LLMProvider {
|
|
4
|
+
private client;
|
|
5
|
+
private defaultModel;
|
|
6
|
+
constructor(options: Anthropic, defaultModel?: string);
|
|
7
|
+
constructor(options: ClientOptions, defaultModel?: string);
|
|
8
|
+
constructor(apiKey: string, defaultModel?: string | null, options?: ClientOptions);
|
|
9
|
+
private processResponse;
|
|
10
|
+
generateText(messages: Message[], params: LLMParameters): Promise<LLMResponse>;
|
|
11
|
+
generateStream(messages: Message[], params: LLMParameters, handler: LLMStreamHandler): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import OpenAI, { ClientOptions } from 'openai';
|
|
2
|
+
import { LLMProvider, LLMParameters, LLMResponse, Message, LLMStreamHandler } from '../../types/llm.types';
|
|
3
|
+
export declare class OpenaiProvider implements LLMProvider {
|
|
4
|
+
private client;
|
|
5
|
+
private defaultModel;
|
|
6
|
+
constructor(client: OpenAI, defaultModel?: string);
|
|
7
|
+
constructor(options: ClientOptions, defaultModel?: string);
|
|
8
|
+
constructor(apiKey: string, defaultModel?: string | null, options?: ClientOptions);
|
|
9
|
+
private buildParams;
|
|
10
|
+
generateText(messages: Message[], params: LLMParameters): Promise<LLMResponse>;
|
|
11
|
+
generateStream(messages: Message[], params: LLMParameters, handler: LLMStreamHandler): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Workflow } from '../../types/workflow.types';
|
|
2
|
+
import { ValidationResult } from '../../types/parser.types';
|
|
3
|
+
import { EkoConfig } from '../../types';
|
|
4
|
+
export declare class WorkflowParser {
|
|
5
|
+
/**
|
|
6
|
+
* Parse JSON string into runtime Workflow object
|
|
7
|
+
* @throws {Error} if JSON is invalid or schema validation fails
|
|
8
|
+
*/
|
|
9
|
+
static parse(json: string, ekoConfig: EkoConfig): Workflow;
|
|
10
|
+
/**
|
|
11
|
+
* Convert runtime Workflow object to JSON string
|
|
12
|
+
*/
|
|
13
|
+
static serialize(workflow: Workflow): string;
|
|
14
|
+
/**
|
|
15
|
+
* Validate workflow JSON structure against schema
|
|
16
|
+
*/
|
|
17
|
+
static validate(json: unknown): ValidationResult;
|
|
18
|
+
private static toRuntime;
|
|
19
|
+
/**
|
|
20
|
+
* Convert runtime Workflow object to JSON structure
|
|
21
|
+
*/
|
|
22
|
+
private static fromRuntime;
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LLMProvider, Message } from '../../types/llm.types';
|
|
2
|
+
import { Workflow } from '../../types/workflow.types';
|
|
3
|
+
import { ToolRegistry } from '../../core/tool-registry';
|
|
4
|
+
import { EkoConfig } from '@/types';
|
|
5
|
+
export declare class WorkflowGenerator {
|
|
6
|
+
private llmProvider;
|
|
7
|
+
private toolRegistry;
|
|
8
|
+
message_history: Message[];
|
|
9
|
+
constructor(llmProvider: LLMProvider, toolRegistry: ToolRegistry);
|
|
10
|
+
generateWorkflow(prompt: string, ekoConfig: EkoConfig): Promise<Workflow>;
|
|
11
|
+
modifyWorkflow(prompt: string, ekoConfig: EkoConfig): Promise<Workflow>;
|
|
12
|
+
private doGenerateWorkflow;
|
|
13
|
+
private createWorkflowFromData;
|
|
14
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ToolDefinition } from '../../types/llm.types';
|
|
2
|
+
import { ToolRegistry } from '../../core/tool-registry';
|
|
3
|
+
export declare function createWorkflowPrompts(tools: ToolDefinition[]): {
|
|
4
|
+
formatSystemPrompt: () => string;
|
|
5
|
+
formatUserPrompt: (requirement: string) => string;
|
|
6
|
+
modifyUserPrompt: (prompt: string) => string;
|
|
7
|
+
};
|
|
8
|
+
export declare function createWorkflowGenerationTool(registry: ToolRegistry): ToolDefinition;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Workflow } from "./workflow.types";
|
|
2
|
+
import { LLMProvider } from "./llm.types";
|
|
3
|
+
import { NodeOutput, WorkflowCallback } from "./workflow.types";
|
|
4
|
+
import { NodeInput } from "./workflow.types";
|
|
5
|
+
import { EkoConfig } from "./eko.types";
|
|
6
|
+
export interface Tool<T, R> {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
input_schema: InputSchema;
|
|
10
|
+
execute: (context: ExecutionContext, params: T) => Promise<R>;
|
|
11
|
+
destroy?: (context: ExecutionContext) => void;
|
|
12
|
+
}
|
|
13
|
+
export interface InputSchema {
|
|
14
|
+
type: 'object';
|
|
15
|
+
properties?: Properties;
|
|
16
|
+
required?: Array<string>;
|
|
17
|
+
}
|
|
18
|
+
export interface Properties {
|
|
19
|
+
[key: string]: Property;
|
|
20
|
+
}
|
|
21
|
+
export interface Property {
|
|
22
|
+
type: 'string' | 'integer' | 'boolean' | 'array' | 'object';
|
|
23
|
+
description?: string;
|
|
24
|
+
items?: InputSchema;
|
|
25
|
+
enum?: Array<string | number>;
|
|
26
|
+
properties?: Properties;
|
|
27
|
+
}
|
|
28
|
+
export interface ExecutionContext {
|
|
29
|
+
llmProvider: LLMProvider;
|
|
30
|
+
ekoConfig: EkoConfig;
|
|
31
|
+
variables: Map<string, unknown>;
|
|
32
|
+
workflow?: Workflow;
|
|
33
|
+
tools?: Map<string, Tool<any, any>>;
|
|
34
|
+
callback?: WorkflowCallback;
|
|
35
|
+
signal?: AbortSignal;
|
|
36
|
+
[key: string]: any;
|
|
37
|
+
}
|
|
38
|
+
export interface Action {
|
|
39
|
+
type: 'prompt' | 'script' | 'hybrid';
|
|
40
|
+
name: string;
|
|
41
|
+
description: string;
|
|
42
|
+
execute: (input: NodeInput, output: NodeOutput, context: ExecutionContext) => Promise<unknown>;
|
|
43
|
+
tools: Array<Tool<any, any>>;
|
|
44
|
+
llmProvider?: LLMProvider;
|
|
45
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ClientOptions as OpenAiClientOptions } from 'openai';
|
|
2
|
+
import { ClientOptions as ClaudeClientOption } from '@anthropic-ai/sdk';
|
|
3
|
+
import { LLMProvider } from './llm.types';
|
|
4
|
+
import { Tool } from './action.types';
|
|
5
|
+
export interface ClaudeConfig {
|
|
6
|
+
llm: 'claude';
|
|
7
|
+
apiKey: string;
|
|
8
|
+
modelName?: string;
|
|
9
|
+
options?: ClaudeClientOption;
|
|
10
|
+
}
|
|
11
|
+
export interface OpenaiConfig {
|
|
12
|
+
llm: 'openai';
|
|
13
|
+
apiKey: string;
|
|
14
|
+
modelName?: string;
|
|
15
|
+
options?: OpenAiClientOptions;
|
|
16
|
+
}
|
|
17
|
+
export type ClaudeApiKey = string;
|
|
18
|
+
export type LLMConfig = ClaudeApiKey | ClaudeConfig | OpenaiConfig | LLMProvider;
|
|
19
|
+
export interface EkoConfig {
|
|
20
|
+
workingWindowId?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface EkoInvokeParam {
|
|
23
|
+
tools?: Array<string> | Array<Tool<any, any>>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export interface Message {
|
|
2
|
+
role: 'user' | 'assistant' | 'system';
|
|
3
|
+
content: string | unknown[];
|
|
4
|
+
}
|
|
5
|
+
export interface ToolDefinition {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
input_schema: {
|
|
9
|
+
type: "object";
|
|
10
|
+
properties: Record<string, unknown>;
|
|
11
|
+
required?: string[];
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface ToolCall {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
input: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
export interface ToolResult {
|
|
20
|
+
tool_use_id: string;
|
|
21
|
+
content: string | Array<{
|
|
22
|
+
type: string;
|
|
23
|
+
text: string;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
export interface LLMParameters {
|
|
27
|
+
model?: string;
|
|
28
|
+
temperature?: number;
|
|
29
|
+
maxTokens?: number;
|
|
30
|
+
tools?: ToolDefinition[];
|
|
31
|
+
toolChoice?: {
|
|
32
|
+
type: 'auto' | 'tool' | 'any';
|
|
33
|
+
name?: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export interface LLMResponse {
|
|
37
|
+
textContent: string | null;
|
|
38
|
+
content: string | unknown[];
|
|
39
|
+
toolCalls: ToolCall[];
|
|
40
|
+
stop_reason: string | null;
|
|
41
|
+
}
|
|
42
|
+
export interface LLMStreamHandler {
|
|
43
|
+
onStart?: () => void;
|
|
44
|
+
onContent?: (content: string) => void;
|
|
45
|
+
onToolUse?: (toolCall: ToolCall) => void;
|
|
46
|
+
onComplete?: (response: LLMResponse) => void;
|
|
47
|
+
onError?: (error: Error) => void;
|
|
48
|
+
}
|
|
49
|
+
export interface LLMProvider {
|
|
50
|
+
generateText(messages: Message[], params: LLMParameters): Promise<LLMResponse>;
|
|
51
|
+
generateStream(messages: Message[], params: LLMParameters, handler: LLMStreamHandler): Promise<void>;
|
|
52
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
export interface ComputerUseParam {
|
|
2
|
+
action: string;
|
|
3
|
+
coordinate?: [number, number];
|
|
4
|
+
text?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ComputerUseResult {
|
|
7
|
+
success: boolean;
|
|
8
|
+
image?: ScreenshotImage;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
export interface BrowserUseParam {
|
|
12
|
+
action: string;
|
|
13
|
+
index?: number;
|
|
14
|
+
text?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface BrowserUseResult {
|
|
17
|
+
success: boolean;
|
|
18
|
+
image?: ScreenshotImage;
|
|
19
|
+
text?: string;
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}
|
|
22
|
+
export interface ExportFileParam {
|
|
23
|
+
content: string;
|
|
24
|
+
fileType: 'txt' | 'csv' | 'md' | 'html' | 'js' | 'xml' | 'json' | 'yml' | 'sql';
|
|
25
|
+
filename?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ExtractContentResult {
|
|
28
|
+
tabId: number;
|
|
29
|
+
result: {
|
|
30
|
+
title?: string;
|
|
31
|
+
url?: string;
|
|
32
|
+
content: string;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface OpenUrlParam {
|
|
36
|
+
url: string;
|
|
37
|
+
newWindow?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface OpenUrlResult {
|
|
40
|
+
tabId: number;
|
|
41
|
+
windowId: number;
|
|
42
|
+
title?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface BrowserTab {
|
|
45
|
+
id: number;
|
|
46
|
+
url?: string;
|
|
47
|
+
title?: string;
|
|
48
|
+
content: string;
|
|
49
|
+
description: string;
|
|
50
|
+
}
|
|
51
|
+
export interface ScreenshotResult {
|
|
52
|
+
image: ScreenshotImage;
|
|
53
|
+
}
|
|
54
|
+
export interface ScreenshotImage {
|
|
55
|
+
type: 'base64';
|
|
56
|
+
media_type: 'image/png' | 'image/jpeg';
|
|
57
|
+
data: string;
|
|
58
|
+
}
|
|
59
|
+
export interface TabManagementParam {
|
|
60
|
+
command: string;
|
|
61
|
+
}
|
|
62
|
+
export type TabManagementResult = TabInfo | CloseTabInfo | TabInfo[];
|
|
63
|
+
export interface TabInfo {
|
|
64
|
+
tabId?: number;
|
|
65
|
+
windowId?: number;
|
|
66
|
+
title?: string;
|
|
67
|
+
url?: string;
|
|
68
|
+
active?: boolean;
|
|
69
|
+
}
|
|
70
|
+
export interface CloseTabInfo {
|
|
71
|
+
closedTabId: number;
|
|
72
|
+
newTabId?: number;
|
|
73
|
+
newTabTitle?: string;
|
|
74
|
+
}
|
|
75
|
+
export interface WebSearchParam {
|
|
76
|
+
url?: string;
|
|
77
|
+
query: string;
|
|
78
|
+
maxResults?: number;
|
|
79
|
+
}
|
|
80
|
+
export interface WebSearchResult {
|
|
81
|
+
title: string;
|
|
82
|
+
url: string;
|
|
83
|
+
content: string;
|
|
84
|
+
}
|
|
85
|
+
export interface TaskPrompt {
|
|
86
|
+
task_prompt: string;
|
|
87
|
+
}
|
|
88
|
+
export interface ElementRect {
|
|
89
|
+
left: number;
|
|
90
|
+
top: number;
|
|
91
|
+
right?: number;
|
|
92
|
+
bottom?: number;
|
|
93
|
+
width?: number;
|
|
94
|
+
height?: number;
|
|
95
|
+
}
|
|
96
|
+
export interface CancelWorkflowInput {
|
|
97
|
+
reason: string;
|
|
98
|
+
}
|
|
99
|
+
export interface HumanInputTextInput {
|
|
100
|
+
question: string;
|
|
101
|
+
}
|
|
102
|
+
export interface HumanInputTextResult {
|
|
103
|
+
status: string;
|
|
104
|
+
answer: string;
|
|
105
|
+
}
|
|
106
|
+
export interface HumanInputSingleChoiceInput {
|
|
107
|
+
question: string;
|
|
108
|
+
choices: string[];
|
|
109
|
+
}
|
|
110
|
+
export interface HumanInputSingleChoiceResult {
|
|
111
|
+
status: string;
|
|
112
|
+
answer: string;
|
|
113
|
+
}
|
|
114
|
+
export interface HumanInputMultipleChoiceInput {
|
|
115
|
+
question: string;
|
|
116
|
+
choices: string[];
|
|
117
|
+
}
|
|
118
|
+
export interface HumanInputMultipleChoiceResult {
|
|
119
|
+
status: string;
|
|
120
|
+
answer: string[];
|
|
121
|
+
}
|
|
122
|
+
export interface HumanOperateInput {
|
|
123
|
+
reason: string;
|
|
124
|
+
}
|
|
125
|
+
export interface HumanOperateResult {
|
|
126
|
+
status: string;
|
|
127
|
+
userOperation: string;
|
|
128
|
+
}
|
|
129
|
+
export interface SummaryWorkflowInput {
|
|
130
|
+
summary: string;
|
|
131
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Action, ExecutionContext, Tool } from "./action.types";
|
|
2
|
+
import { LLMProvider } from "./llm.types";
|
|
3
|
+
import { ExecutionLogger } from "@/utils/execution-logger";
|
|
4
|
+
import { ExportFileParam } from "./tools.types";
|
|
5
|
+
export interface NodeOutput {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
value?: unknown;
|
|
9
|
+
}
|
|
10
|
+
export interface NodeInput {
|
|
11
|
+
items: NodeOutput[];
|
|
12
|
+
}
|
|
13
|
+
export interface WorkflowNode {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
dependencies: string[];
|
|
18
|
+
action: Action;
|
|
19
|
+
input: NodeInput;
|
|
20
|
+
output: NodeOutput;
|
|
21
|
+
}
|
|
22
|
+
export interface Workflow {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
nodes: WorkflowNode[];
|
|
27
|
+
variables: Map<string, any>;
|
|
28
|
+
llmProvider?: LLMProvider;
|
|
29
|
+
setLogger(logger: ExecutionLogger): void;
|
|
30
|
+
execute(callback?: WorkflowCallback): Promise<NodeOutput[]>;
|
|
31
|
+
cancel(): Promise<void>;
|
|
32
|
+
addNode(node: WorkflowNode): void;
|
|
33
|
+
removeNode(nodeId: string): void;
|
|
34
|
+
getNode(nodeId: string): WorkflowNode;
|
|
35
|
+
validateDAG(): boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface WorkflowCallback {
|
|
38
|
+
hooks: {
|
|
39
|
+
beforeWorkflow?: (workflow: Workflow) => Promise<void>;
|
|
40
|
+
beforeSubtask?: (subtask: WorkflowNode, context: ExecutionContext) => Promise<void>;
|
|
41
|
+
beforeToolUse?: (tool: Tool<any, any>, context: ExecutionContext, input: any) => Promise<any>;
|
|
42
|
+
afterToolUse?: (tool: Tool<any, any>, context: ExecutionContext, result: any) => Promise<any>;
|
|
43
|
+
afterSubtask?: (subtask: WorkflowNode, context: ExecutionContext, result: any) => Promise<void>;
|
|
44
|
+
afterWorkflow?: (workflow: Workflow, variables: Map<string, unknown>) => Promise<void>;
|
|
45
|
+
onTabCreated?: (tabId: number) => Promise<void>;
|
|
46
|
+
onLlmMessage?: (textContent: string) => Promise<void>;
|
|
47
|
+
onHumanInputText?: (question: string) => Promise<string>;
|
|
48
|
+
onHumanInputSingleChoice?: (question: string, choices: string[]) => Promise<string>;
|
|
49
|
+
onHumanInputMultipleChoice?: (question: string, choices: string[]) => Promise<string[]>;
|
|
50
|
+
onHumanOperate?: (reason: string) => Promise<string>;
|
|
51
|
+
onSummaryWorkflow?: (summary: string) => Promise<void>;
|
|
52
|
+
onExportFile?: (param: ExportFileParam) => Promise<void>;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CancelWorkflowInput } from '../types/tools.types';
|
|
2
|
+
import { Tool, InputSchema, ExecutionContext } from '../types/action.types';
|
|
3
|
+
export declare class CancelWorkflow implements Tool<CancelWorkflowInput, void> {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
input_schema: InputSchema;
|
|
7
|
+
constructor();
|
|
8
|
+
execute(context: ExecutionContext, params: CancelWorkflowInput): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { HumanInputTextInput, HumanInputTextResult, HumanInputSingleChoiceInput, HumanInputSingleChoiceResult, HumanInputMultipleChoiceInput, HumanInputMultipleChoiceResult, HumanOperateInput, HumanOperateResult } from '../types/tools.types';
|
|
2
|
+
import { Tool, InputSchema, ExecutionContext } from '../types/action.types';
|
|
3
|
+
export declare class HumanInputText implements Tool<HumanInputTextInput, HumanInputTextResult> {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
input_schema: InputSchema;
|
|
7
|
+
constructor();
|
|
8
|
+
execute(context: ExecutionContext, params: HumanInputTextInput): Promise<HumanInputTextResult>;
|
|
9
|
+
}
|
|
10
|
+
export declare class HumanInputSingleChoice implements Tool<HumanInputSingleChoiceInput, HumanInputSingleChoiceResult> {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
input_schema: InputSchema;
|
|
14
|
+
constructor();
|
|
15
|
+
execute(context: ExecutionContext, params: HumanInputSingleChoiceInput): Promise<HumanInputSingleChoiceResult>;
|
|
16
|
+
}
|
|
17
|
+
export declare class HumanInputMultipleChoice implements Tool<HumanInputMultipleChoiceInput, HumanInputMultipleChoiceResult> {
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
input_schema: InputSchema;
|
|
21
|
+
constructor();
|
|
22
|
+
execute(context: ExecutionContext, params: HumanInputMultipleChoiceInput): Promise<HumanInputMultipleChoiceResult>;
|
|
23
|
+
}
|
|
24
|
+
export declare class HumanOperate implements Tool<HumanOperateInput, HumanOperateResult> {
|
|
25
|
+
name: string;
|
|
26
|
+
description: string;
|
|
27
|
+
input_schema: InputSchema;
|
|
28
|
+
constructor();
|
|
29
|
+
execute(context: ExecutionContext, params: HumanOperateInput): Promise<HumanOperateResult>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CancelWorkflow } from "./cancel_workflow";
|
|
2
|
+
import { HumanInputText, HumanInputSingleChoice, HumanInputMultipleChoice, HumanOperate } from "./human";
|
|
3
|
+
import { SummaryWorkflow } from "./summary_workflow";
|
|
4
|
+
export { CancelWorkflow, HumanInputText, HumanInputSingleChoice, HumanInputMultipleChoice, HumanOperate, SummaryWorkflow, };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SummaryWorkflowInput } from '../types/tools.types';
|
|
2
|
+
import { Tool, InputSchema, ExecutionContext } from '../types/action.types';
|
|
3
|
+
export declare class SummaryWorkflow implements Tool<SummaryWorkflowInput, any> {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
input_schema: InputSchema;
|
|
7
|
+
constructor();
|
|
8
|
+
execute(context: ExecutionContext, params: SummaryWorkflowInput): Promise<any>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Message } from '../types/llm.types';
|
|
2
|
+
import { ExecutionContext } from '../types/action.types';
|
|
3
|
+
interface ImageData {
|
|
4
|
+
type: 'base64';
|
|
5
|
+
media_type: string;
|
|
6
|
+
data: string;
|
|
7
|
+
}
|
|
8
|
+
export interface LogOptions {
|
|
9
|
+
maxHistoryLength?: number;
|
|
10
|
+
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
|
11
|
+
includeTimestamp?: boolean;
|
|
12
|
+
debugImagePath?: string;
|
|
13
|
+
imageSaver?: (imageData: ImageData, filename: string) => Promise<string>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Manages logging for action execution, providing a cleaner view of the execution
|
|
17
|
+
* flow while maintaining important context and history.
|
|
18
|
+
*/
|
|
19
|
+
export declare class ExecutionLogger {
|
|
20
|
+
private history;
|
|
21
|
+
private readonly maxHistoryLength;
|
|
22
|
+
private readonly logLevel;
|
|
23
|
+
private readonly includeTimestamp;
|
|
24
|
+
private readonly debugImagePath?;
|
|
25
|
+
private readonly imageSaver?;
|
|
26
|
+
private readonly isNode;
|
|
27
|
+
constructor(options?: LogOptions);
|
|
28
|
+
/**
|
|
29
|
+
* Logs a message with execution context
|
|
30
|
+
*/
|
|
31
|
+
log(level: string, message: string, context?: ExecutionContext): void;
|
|
32
|
+
/**
|
|
33
|
+
* Updates conversation history while maintaining size limit
|
|
34
|
+
*/
|
|
35
|
+
updateHistory(messages: Message[]): void;
|
|
36
|
+
/**
|
|
37
|
+
* Gets current conversation history
|
|
38
|
+
*/
|
|
39
|
+
getHistory(): Message[];
|
|
40
|
+
/**
|
|
41
|
+
* Summarizes the execution context for logging
|
|
42
|
+
*/
|
|
43
|
+
private summarizeContext;
|
|
44
|
+
/**
|
|
45
|
+
* Checks if message should be logged based on log level
|
|
46
|
+
*/
|
|
47
|
+
private shouldLog;
|
|
48
|
+
/**
|
|
49
|
+
* Logs the start of an action execution
|
|
50
|
+
*/
|
|
51
|
+
logActionStart(actionName: string, input: unknown, context?: ExecutionContext): void;
|
|
52
|
+
/**
|
|
53
|
+
* Logs the completion of an action execution
|
|
54
|
+
*/
|
|
55
|
+
logActionComplete(actionName: string, result: unknown, context?: ExecutionContext): void;
|
|
56
|
+
/**
|
|
57
|
+
* Logs a tool execution
|
|
58
|
+
*/
|
|
59
|
+
logToolExecution(toolName: string, input: unknown, context?: ExecutionContext): void;
|
|
60
|
+
/**
|
|
61
|
+
* Logs an error that occurred during execution
|
|
62
|
+
*/
|
|
63
|
+
logError(error: Error, context?: ExecutionContext): void;
|
|
64
|
+
private extractFromDataUrl;
|
|
65
|
+
private saveDebugImage;
|
|
66
|
+
private formatToolResult;
|
|
67
|
+
logToolResult(toolName: string, result: unknown, context?: ExecutionContext): Promise<void>;
|
|
68
|
+
}
|
|
69
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get clickable elements on the page
|
|
3
|
+
*
|
|
4
|
+
* @param {*} doHighlightElements Is highlighted
|
|
5
|
+
* @param {*} includeAttributes [attr_names...]
|
|
6
|
+
* @returns { element_str, selector_map }
|
|
7
|
+
*/
|
|
8
|
+
export function get_clickable_elements(doHighlightElements: any | undefined, includeAttributes: any): string;
|
|
9
|
+
export function get_highlight_element(highlightIndex: any): any;
|
|
10
|
+
export function remove_highlight(): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ScreenshotResult } from '../../types/tools.types';
|
|
2
|
+
export declare function type(text: string, xpath?: string, highlightIndex?: number): boolean;
|
|
3
|
+
export declare function clear_input(xpath?: string, highlightIndex?: number): boolean;
|
|
4
|
+
export declare function left_click(xpath?: string, highlightIndex?: number): boolean;
|
|
5
|
+
export declare function right_click(xpath?: string, highlightIndex?: number): boolean;
|
|
6
|
+
export declare function double_click(xpath?: string, highlightIndex?: number): boolean;
|
|
7
|
+
export declare function screenshot(compress?: boolean): Promise<ScreenshotResult>;
|
|
8
|
+
export declare function compress_image(dataUrl: string, scale?: number, quality?: number): Promise<string>;
|
|
9
|
+
export declare function scroll_to(xpath?: string, highlightIndex?: number): boolean;
|
|
10
|
+
export declare function get_dropdown_options(xpath?: string, highlightIndex?: number): {
|
|
11
|
+
options: Array<{
|
|
12
|
+
index: number;
|
|
13
|
+
text: string;
|
|
14
|
+
value?: string;
|
|
15
|
+
}>;
|
|
16
|
+
id?: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
} | null;
|
|
19
|
+
export declare function select_dropdown_option(text: string, xpath?: string, highlightIndex?: number): any;
|
|
20
|
+
export declare function extractHtmlContent(): string;
|
|
21
|
+
export declare function size(): [number, number];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BrowserUseParam, BrowserUseResult } from '../../types/tools.types';
|
|
2
|
+
import { Tool, InputSchema, ExecutionContext } from '../../types/action.types';
|
|
3
|
+
/**
|
|
4
|
+
* Browser Use for general
|
|
5
|
+
*/
|
|
6
|
+
export declare class BrowserUse implements Tool<BrowserUseParam, BrowserUseResult> {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
input_schema: InputSchema;
|
|
10
|
+
constructor();
|
|
11
|
+
/**
|
|
12
|
+
* browser
|
|
13
|
+
*
|
|
14
|
+
* @param {*} params { action: 'input_text', index: 1, text: 'string' }
|
|
15
|
+
* @returns > { success: true, image?: { type: 'base64', media_type: 'image/jpeg', data: '/9j...' }, text?: string }
|
|
16
|
+
*/
|
|
17
|
+
execute(context: ExecutionContext, params: BrowserUseParam): Promise<BrowserUseResult>;
|
|
18
|
+
destroy(context: ExecutionContext): void;
|
|
19
|
+
}
|