@cotestdev/ai-runner 0.0.3 → 0.0.5
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/ai-runner/src/runner.d.ts +1 -0
- package/dist/ai-runner/src/runner.d.ts.map +1 -1
- package/dist/ai-runner/src/runner.js +9 -1
- package/dist/ai-runner/src/runner.js.map +1 -1
- package/package.json +6 -1
- package/dist/agents/heal-agent.d.ts +0 -30
- package/dist/agents/heal-agent.d.ts.map +0 -1
- package/dist/agents/heal-agent.js +0 -76
- package/dist/agents/heal-agent.js.map +0 -1
- package/dist/agents/healer.d.ts +0 -73
- package/dist/agents/healer.d.ts.map +0 -1
- package/dist/agents/healer.js +0 -538
- package/dist/agents/healer.js.map +0 -1
- package/dist/agents/tools/form.d.ts +0 -22
- package/dist/agents/tools/form.d.ts.map +0 -1
- package/dist/agents/tools/form.js +0 -134
- package/dist/agents/tools/form.js.map +0 -1
- package/dist/agents/tools/index.d.ts +0 -13
- package/dist/agents/tools/index.d.ts.map +0 -1
- package/dist/agents/tools/index.js +0 -33
- package/dist/agents/tools/index.js.map +0 -1
- package/dist/agents/tools/navigate.d.ts +0 -22
- package/dist/agents/tools/navigate.d.ts.map +0 -1
- package/dist/agents/tools/navigate.js +0 -74
- package/dist/agents/tools/navigate.js.map +0 -1
- package/dist/agents/tools/snapshot.d.ts +0 -22
- package/dist/agents/tools/snapshot.d.ts.map +0 -1
- package/dist/agents/tools/snapshot.js +0 -110
- package/dist/agents/tools/snapshot.js.map +0 -1
- package/dist/agents/tools/verify.d.ts +0 -34
- package/dist/agents/tools/verify.d.ts.map +0 -1
- package/dist/agents/tools/verify.js +0 -169
- package/dist/agents/tools/verify.js.map +0 -1
- package/dist/agents/tools/wait.d.ts +0 -22
- package/dist/agents/tools/wait.d.ts.map +0 -1
- package/dist/agents/tools/wait.js +0 -104
- package/dist/agents/tools/wait.js.map +0 -1
- package/dist/agents/types.d.ts +0 -51
- package/dist/agents/types.d.ts.map +0 -1
- package/dist/agents/types.js +0 -6
- package/dist/agents/types.js.map +0 -1
- package/dist/ai-runner/src/examples/test-final.d.ts +0 -6
- package/dist/ai-runner/src/examples/test-final.d.ts.map +0 -1
- package/dist/ai-runner/src/examples/test-final.js +0 -73
- package/dist/ai-runner/src/examples/test-final.js.map +0 -1
- package/dist/ai-runner/src/examples/test-simple-tools.d.ts +0 -6
- package/dist/ai-runner/src/examples/test-simple-tools.d.ts.map +0 -1
- package/dist/ai-runner/src/examples/test-simple-tools.js +0 -149
- package/dist/ai-runner/src/examples/test-simple-tools.js.map +0 -1
- package/dist/ai-runner/src/examples/test-working.d.ts +0 -5
- package/dist/ai-runner/src/examples/test-working.d.ts.map +0 -1
- package/dist/ai-runner/src/examples/test-working.js +0 -43
- package/dist/ai-runner/src/examples/test-working.js.map +0 -1
- package/dist/ai-runner/src/examples/v-test-backend-adapter.d.ts +0 -15
- package/dist/ai-runner/src/examples/v-test-backend-adapter.d.ts.map +0 -1
- package/dist/ai-runner/src/examples/v-test-backend-adapter.js +0 -240
- package/dist/ai-runner/src/examples/v-test-backend-adapter.js.map +0 -1
- package/dist/core/runner.d.ts +0 -194
- package/dist/core/runner.d.ts.map +0 -1
- package/dist/core/runner.js +0 -650
- package/dist/core/runner.js.map +0 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -11
- package/dist/index.js.map +0 -1
- package/dist/types/external.d.ts +0 -6
- package/dist/types/external.d.ts.map +0 -1
- package/dist/types/external.js +0 -7
- package/dist/types/external.js.map +0 -1
- package/dist/types/index.d.ts +0 -153
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -26
- package/dist/types/index.js.map +0 -1
- package/docs/PLAYWRIGHT_MCP_ADAPTER.md +0 -132
- package/docs/SCHEMA_EXTRACTION.md +0 -224
- package/playwright-report/data/26c3117906b682c9086892b9834f119fdef0ca60.webm +0 -0
- package/playwright-report/data/534e0d700217810c792ffbaf34b2d4160992d0ec.md +0 -210
- package/playwright-report/data/56a09464231ba6c36c441f95019b40b9238c9da5.zip +0 -0
- package/playwright-report/data/9c6ffeb3926521c8a7b610e82e1b29d49e859932.png +0 -0
- package/playwright-report/index.html +0 -85
- package/playwright-report/trace/assets/codeMirrorModule-Bucv2d7q.js +0 -25
- package/playwright-report/trace/assets/defaultSettingsView-BEpdCv1S.js +0 -266
- package/playwright-report/trace/codeMirrorModule.C3UTv-Ge.css +0 -1
- package/playwright-report/trace/codicon.DCmgc-ay.ttf +0 -0
- package/playwright-report/trace/defaultSettingsView.ConWv5KN.css +0 -1
- package/playwright-report/trace/index.BxQ34UMZ.js +0 -2
- package/playwright-report/trace/index.C4Y3Aw8n.css +0 -1
- package/playwright-report/trace/index.html +0 -43
- package/playwright-report/trace/manifest.webmanifest +0 -16
- package/playwright-report/trace/playwright-logo.svg +0 -9
- package/playwright-report/trace/snapshot.html +0 -21
- package/playwright-report/trace/sw.bundle.js +0 -3
- package/playwright-report/trace/uiMode.BWTwXl41.js +0 -5
- package/playwright-report/trace/uiMode.Btcz36p_.css +0 -1
- package/playwright-report/trace/uiMode.html +0 -17
- package/playwright-report/trace/xtermModule.DYP7pi_n.css +0 -32
- package/playwright.config.ts +0 -38
- package/src/agents/logger.ts +0 -20
- package/src/agents/playwright-executor.ts +0 -252
- package/src/agents/tools/playwright-backend-adapter.ts +0 -134
- package/src/agents/tools/playwright-mcp-types.d.ts +0 -71
- package/src/agents/types.ts +0 -80
- package/src/index.ts +0 -27
- package/src/runner.ts +0 -214
- package/src/tools/index.ts +0 -48
- package/src/tools/playwright-groups.ts +0 -54
- package/src/types/external.ts +0 -7
- package/src/types/index.ts +0 -118
- package/test-results/.last-run.json +0 -6
- package/test-results/tests-agent-test-heal-agent-Register-user-1-chromium/error-context.md +0 -210
- package/test-results/tests-agent-test-heal-agent-Register-user-1-chromium/test-failed-1.png +0 -0
- package/test-results/tests-agent-test-heal-agent-Register-user-1-chromium/trace.zip +0 -0
- package/test-results/tests-agent-test-heal-agent-Register-user-1-chromium/video.webm +0 -0
- package/tests/agent/test-heal-agent.spec.ts +0 -54
- package/tsconfig.json +0 -26
package/src/runner.ts
DELETED
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import type {
|
|
3
|
-
RunnerConfig,
|
|
4
|
-
HealContext,
|
|
5
|
-
} from './types';
|
|
6
|
-
import type { Page, BrowserContext } from 'playwright';
|
|
7
|
-
import { createModel, StorageService } from '@cotestdev/core-infra';
|
|
8
|
-
import { expect } from '@playwright/test';
|
|
9
|
-
import { PlaywrightAgentState } from './agents/types';
|
|
10
|
-
import { Logger } from './agents/logger';
|
|
11
|
-
import { PlaywrightExecutor } from './agents/playwright-executor';
|
|
12
|
-
import { PlaywrightGroup } from './tools/playwright-groups';
|
|
13
|
-
import { PlaywrightBackendAdapter } from './agents/tools/playwright-backend-adapter';
|
|
14
|
-
import { BaseLanguageModel } from '@langchain/core/language_models/base';
|
|
15
|
-
|
|
16
|
-
export class Runner {
|
|
17
|
-
private config: RunnerConfig;
|
|
18
|
-
private model?: BaseLanguageModel;
|
|
19
|
-
private storageService: StorageService;
|
|
20
|
-
private logger: Logger;
|
|
21
|
-
private canHeal: boolean = false;
|
|
22
|
-
private executor: PlaywrightExecutor | undefined;
|
|
23
|
-
private state: PlaywrightAgentState | undefined;
|
|
24
|
-
private script?: string;
|
|
25
|
-
private variables: Map<string, any> = new Map<string, any>();
|
|
26
|
-
|
|
27
|
-
private constructor(config: RunnerConfig) {
|
|
28
|
-
this.config = config;
|
|
29
|
-
this.storageService = StorageService.getInstance(config.projectId);
|
|
30
|
-
this.logger = new Logger();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
static NewInstance(projectId: string, testCaseId: string): Runner {
|
|
34
|
-
const runner = new Runner({ projectId, testCaseId });
|
|
35
|
-
|
|
36
|
-
try {
|
|
37
|
-
const script = runner.loadOriginalScript();
|
|
38
|
-
if (!script) {
|
|
39
|
-
runner.logger.error('No script found for the specified test case.');
|
|
40
|
-
return runner;
|
|
41
|
-
}
|
|
42
|
-
runner.script = script;
|
|
43
|
-
|
|
44
|
-
// 同步加载模型配置
|
|
45
|
-
const allConfigs = runner.storageService.listModelConfigsSync();
|
|
46
|
-
const config = allConfigs.find(c => c.isDefault === true);
|
|
47
|
-
if (config) {
|
|
48
|
-
runner.model = createModel(config);
|
|
49
|
-
runner.canHeal = true;
|
|
50
|
-
} else {
|
|
51
|
-
runner.logger.error('No default model configuration available in the system.');
|
|
52
|
-
}
|
|
53
|
-
} catch (error) {
|
|
54
|
-
runner.logger.error(`Failed to initialize runner: ${error}`);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return runner;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async init(page: Page, context: BrowserContext, data?: Record<string, any>): Promise<void> {
|
|
61
|
-
const adapter = await PlaywrightBackendAdapter.create(context);
|
|
62
|
-
this.state = {
|
|
63
|
-
page,
|
|
64
|
-
context,
|
|
65
|
-
variables: this.variables,
|
|
66
|
-
logger: this.logger,
|
|
67
|
-
model: this.model,
|
|
68
|
-
originalScript: this.state?.originalScript || this.script || '',
|
|
69
|
-
adapter: adapter,
|
|
70
|
-
playwrightGroup: new PlaywrightGroup(adapter),
|
|
71
|
-
testCaseId: this.config.testCaseId,
|
|
72
|
-
storageService: this.storageService,
|
|
73
|
-
};
|
|
74
|
-
if (data) {
|
|
75
|
-
for (const [key, value] of Object.entries(data)) {
|
|
76
|
-
this.variables.set(key, value);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
this.executor = new PlaywrightExecutor(this.state);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
private loadOriginalScript(): string {
|
|
83
|
-
if (!this.config.testCaseId) {
|
|
84
|
-
throw new Error('Cannot load original script: testCaseId is not provided');
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
this.logger.log(`Attempting to load script from database: ${this.config.projectId}/${this.config.testCaseId}`);
|
|
88
|
-
const script = this.storageService.loadTestScript(this.config.testCaseId);
|
|
89
|
-
if (!script) {
|
|
90
|
-
throw new Error(`Cannot load original script: Test case not found in database (ID: ${this.config.testCaseId})`);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return script;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async runStep(description: string, fn: () => Promise<void>) {
|
|
97
|
-
const startTime = Date.now();
|
|
98
|
-
const context: HealContext = {
|
|
99
|
-
stepDescription: description,
|
|
100
|
-
originalCode: fn.toString(),
|
|
101
|
-
success: false
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
try {
|
|
105
|
-
await fn();
|
|
106
|
-
context.success = true;
|
|
107
|
-
return;
|
|
108
|
-
} catch (error) {
|
|
109
|
-
if (!this.canHeal || !(error instanceof Error)) {
|
|
110
|
-
throw error;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const healable = this.isHealableError(error);
|
|
114
|
-
if (!healable) {
|
|
115
|
-
throw error;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
context.error = (error as Error).message;
|
|
119
|
-
context.stackTrace = (error as Error).stack;
|
|
120
|
-
|
|
121
|
-
this.logger.error(`Step failed: ${description}, Error: ${context.error}`);
|
|
122
|
-
this.logger.log(`Agent will attempt to self-heal...`);
|
|
123
|
-
|
|
124
|
-
await this.executor!.execute(context);
|
|
125
|
-
|
|
126
|
-
const duration = (Date.now() - startTime) / 1000;
|
|
127
|
-
if (context.success) {
|
|
128
|
-
this.logger.log(`Test step healed, duration: ${duration}s`);
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
this.logger.error(`Failed to fix step: ${context.healError}, duration: ${duration}s`);
|
|
133
|
-
throw new Error(`original error: ${context.error}; heal error: ${context.healError}`);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
private isHealableError(err: Error): boolean {
|
|
138
|
-
// 方式1:枚举所有 Symbol 属性(最常见尝试)
|
|
139
|
-
const symbols = Object.getOwnPropertySymbols(err);
|
|
140
|
-
|
|
141
|
-
for (const sym of symbols) {
|
|
142
|
-
try {
|
|
143
|
-
const value = (err as any)[sym];
|
|
144
|
-
|
|
145
|
-
// 如果有 category 字段,大概率就是我们要找的 step
|
|
146
|
-
if (value && typeof value === 'object' && 'category' in value) {
|
|
147
|
-
if (value.category === 'expect' || value.category === 'pw:api') {
|
|
148
|
-
return true;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
} catch (e) {
|
|
152
|
-
// 访问可能会抛错,忽略即可
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
set(key: string, value: any): void {
|
|
160
|
-
this.variables.set(key, value);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
get(key: string): any {
|
|
164
|
-
return this.variables.get(key);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
has(key: string): boolean {
|
|
168
|
-
return this.variables.has(key);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
delete(key: string): boolean {
|
|
172
|
-
return this.variables.delete(key);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
clear(): void {
|
|
176
|
-
this.variables.clear();
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
keys(): string[] {
|
|
180
|
-
return Array.from(this.variables.keys());
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
getAll(): Record<string, unknown> {
|
|
184
|
-
return Object.fromEntries(this.variables);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
async reuseTest(useTestCaseId: string, description: string): Promise<Map<string, unknown>> {
|
|
188
|
-
const scriptContent = this.storageService.loadTestScript(useTestCaseId);
|
|
189
|
-
if (!scriptContent) {
|
|
190
|
-
throw new Error(`Reusable test script not found: ${useTestCaseId}`);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
const reuseRunner = Runner.NewInstance(this.config.projectId, useTestCaseId);
|
|
194
|
-
await reuseRunner.init(this.state!.page, this.state!.context);
|
|
195
|
-
|
|
196
|
-
this.logger.log(`Starting to execute reusable test case: ${description}`);
|
|
197
|
-
|
|
198
|
-
try {
|
|
199
|
-
const executeScript = new Function('runner', 'page', 'context', 'expect', `
|
|
200
|
-
return (async () => {
|
|
201
|
-
${scriptContent}
|
|
202
|
-
})();
|
|
203
|
-
`);
|
|
204
|
-
|
|
205
|
-
await executeScript(reuseRunner, this.state!.page, this.state!.context, expect);
|
|
206
|
-
|
|
207
|
-
this.logger.log(`Reusable test case executed successfully`);
|
|
208
|
-
|
|
209
|
-
return reuseRunner.state?.variables || new Map<string, unknown>();
|
|
210
|
-
} catch (error) {
|
|
211
|
-
throw new Error(`reuseTest execution failed, error: ${error instanceof Error ? error.message : String(error)}`);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
package/src/tools/index.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { DynamicStructuredTool } from "langchain";
|
|
2
|
-
|
|
3
|
-
export interface ToolGroup {
|
|
4
|
-
name: string;
|
|
5
|
-
description: string;
|
|
6
|
-
tools?: string[];
|
|
7
|
-
loadByDefault: boolean;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export abstract class AbstractGroup {
|
|
11
|
-
groups: ToolGroup[];
|
|
12
|
-
|
|
13
|
-
constructor(groups: ToolGroup[]) {
|
|
14
|
-
this.groups = groups;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
abstract getAllTools(): DynamicStructuredTool[];
|
|
18
|
-
|
|
19
|
-
getDefaultTools(): DynamicStructuredTool[] {
|
|
20
|
-
return this.getAllTools().filter(tool => {
|
|
21
|
-
return this.groups.some(group => group.loadByDefault && (!group.tools || group.tools.includes(tool.name)));
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
getAvailableTools(groupName: string): DynamicStructuredTool[] {
|
|
26
|
-
const group = this.groups.find(g => g.name === groupName);
|
|
27
|
-
if (group) {
|
|
28
|
-
const toolNames = group.tools;
|
|
29
|
-
const all = this.getAllTools();
|
|
30
|
-
if (!toolNames) {
|
|
31
|
-
return all;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return toolNames.filter(name => all.some(tool => tool.name === name)).map(name => all.find(tool => tool.name === name)!);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
throw new Error(`Tool group ${groupName} not found`);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
getNonDefaultGroupInfo(): Record<string, string> {
|
|
41
|
-
return this.groups
|
|
42
|
-
.filter(group => !group.loadByDefault)
|
|
43
|
-
.reduce((acc, group) => {
|
|
44
|
-
acc[group.name] = group.description;
|
|
45
|
-
return acc;
|
|
46
|
-
}, {} as Record<string, string>);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
/**
|
|
3
|
-
* MCP (Model Context Protocol) Client for Playwright integration
|
|
4
|
-
* Integrates with https://github.com/microsoft/playwright-mcp
|
|
5
|
-
*/
|
|
6
|
-
import { DynamicStructuredTool } from 'langchain';
|
|
7
|
-
import { AbstractGroup } from '.';
|
|
8
|
-
import { PlaywrightBackendAdapter } from 'src/agents/tools/playwright-backend-adapter';
|
|
9
|
-
export interface PlaywrightMCPOpts {
|
|
10
|
-
language: string,
|
|
11
|
-
headless?: boolean,
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export class PlaywrightGroup extends AbstractGroup {
|
|
15
|
-
private allTools: DynamicStructuredTool[];
|
|
16
|
-
private adapter: PlaywrightBackendAdapter;
|
|
17
|
-
|
|
18
|
-
constructor(adapter: PlaywrightBackendAdapter) {
|
|
19
|
-
super([{
|
|
20
|
-
name: 'playwright_basic',
|
|
21
|
-
description: 'Basic Playwright tools for browser interactions',
|
|
22
|
-
tools: ['browser_navigate', 'browser_click', 'browser_fill_form', 'browser_press_key', 'browser_run_code', 'browser_select_option', 'browser_snapshot', 'browser_type', 'browser_wait_for'],
|
|
23
|
-
loadByDefault: true,
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
name: 'playwright_browser_manage',
|
|
27
|
-
description: `Playwright tools tab management, including: list, create, close, select a tab`,
|
|
28
|
-
tools: ['browser_tabs'],
|
|
29
|
-
loadByDefault: false,
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
name: 'playwright_other',
|
|
33
|
-
description: `Other Playwright tools for browser interactions, including: mouse hover on element, drag and drop an element, upload file, handle dialog, evaluate JavaScript on page or element
|
|
34
|
-
1. mouse hover on element
|
|
35
|
-
2. drag and drop an element
|
|
36
|
-
3. upload file
|
|
37
|
-
4. handle dialog
|
|
38
|
-
5. evaluate JavaScript on page or element`,
|
|
39
|
-
tools: ['browser_hover', 'browser_drag', 'browser_file_upload', 'browser_handle_dialog', 'browser_evaluate'],
|
|
40
|
-
loadByDefault: false,
|
|
41
|
-
}
|
|
42
|
-
]);
|
|
43
|
-
this.adapter = adapter;
|
|
44
|
-
this.allTools = this.adapter.getTools();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async callTool(toolName: string, args: any): Promise<any> {
|
|
48
|
-
return this.adapter.callTool(toolName, args);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
getAllTools(): DynamicStructuredTool[] {
|
|
52
|
-
return this.allTools
|
|
53
|
-
}
|
|
54
|
-
}
|
package/src/types/external.ts
DELETED
package/src/types/index.ts
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ai-heal Core Type Definitions (MVP)
|
|
3
|
-
* Maintain simplicity, include only necessary types
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// Playwright types are used in type definitions below
|
|
7
|
-
|
|
8
|
-
export interface RunnerConfig {
|
|
9
|
-
/** Test Case ID */
|
|
10
|
-
testCaseId: string;
|
|
11
|
-
/** Project ID */
|
|
12
|
-
projectId: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// ============================================================================
|
|
16
|
-
// Execution Context
|
|
17
|
-
// ============================================================================
|
|
18
|
-
|
|
19
|
-
export interface RunStepOptions {
|
|
20
|
-
/** Step description for AI to understand */
|
|
21
|
-
description: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface ReActStep {
|
|
25
|
-
/** Step number */
|
|
26
|
-
stepNumber: number;
|
|
27
|
-
/** Step type */
|
|
28
|
-
stepType: 'thought' | 'action' | 'observation' | 'reflection';
|
|
29
|
-
/** Timestamp */
|
|
30
|
-
timestamp: number;
|
|
31
|
-
/** LLM thought process (thought step) */
|
|
32
|
-
thought?: string;
|
|
33
|
-
/** Tool call information (action step) */
|
|
34
|
-
toolCall?: {
|
|
35
|
-
name: string;
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
-
input: any;
|
|
38
|
-
};
|
|
39
|
-
/** Tool execution result (observation step) */
|
|
40
|
-
toolResult?: {
|
|
41
|
-
output: string;
|
|
42
|
-
success: boolean;
|
|
43
|
-
duration?: number;
|
|
44
|
-
};
|
|
45
|
-
/** Reflection content (reflection step) */
|
|
46
|
-
reflection?: string;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Context information for a single self-healing process
|
|
51
|
-
*/
|
|
52
|
-
export interface HealContext {
|
|
53
|
-
/** Step description */
|
|
54
|
-
stepDescription: string;
|
|
55
|
-
/** original error */
|
|
56
|
-
error?: string;
|
|
57
|
-
/** Stack trace */
|
|
58
|
-
stackTrace?: string;
|
|
59
|
-
/** Original code */
|
|
60
|
-
originalCode: string;
|
|
61
|
-
/** Whether successful */
|
|
62
|
-
success: boolean;
|
|
63
|
-
/** Total steps executed by Agent */
|
|
64
|
-
agentSteps?: number;
|
|
65
|
-
healError?: string;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// ============================================================================
|
|
69
|
-
// Execution Result
|
|
70
|
-
// ============================================================================
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Code execution result
|
|
74
|
-
*/
|
|
75
|
-
export interface ExecutionResult {
|
|
76
|
-
/** Whether successful */
|
|
77
|
-
success: boolean;
|
|
78
|
-
/** Return value */
|
|
79
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
80
|
-
returnValue: any;
|
|
81
|
-
/** Local variables */
|
|
82
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
83
|
-
locals: Record<string, any>;
|
|
84
|
-
/** Error message */
|
|
85
|
-
error?: Error;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// ============================================================================
|
|
89
|
-
// Self-Healing Summary
|
|
90
|
-
// ============================================================================
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Self-healing summary information
|
|
94
|
-
*/
|
|
95
|
-
export interface HealSummary {
|
|
96
|
-
/** Total number of steps */
|
|
97
|
-
totalSteps: number;
|
|
98
|
-
/** Number of successfully healed steps */
|
|
99
|
-
healedSteps: number;
|
|
100
|
-
/** Fixed script */
|
|
101
|
-
modifiedScript?: string;
|
|
102
|
-
/** List of self-healing details */
|
|
103
|
-
healingDetails: HealingDetail[];
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Single self-healing detail
|
|
108
|
-
*/
|
|
109
|
-
export interface HealingDetail {
|
|
110
|
-
/** Step description */
|
|
111
|
-
step: string;
|
|
112
|
-
/** Error message */
|
|
113
|
-
error: string;
|
|
114
|
-
/** Recovery time */
|
|
115
|
-
recoveryTime: number;
|
|
116
|
-
/** Number of LLM interactions */
|
|
117
|
-
llmInteractions: number;
|
|
118
|
-
}
|