@donggui/core 1.5.4-donggui.4 → 1.5.6
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/es/agent/agent.mjs +1 -1
- package/dist/es/agent/agent.mjs.map +1 -1
- package/dist/es/agent/cache-adapter.mjs +0 -0
- package/dist/es/agent/task-builder.mjs +2 -2
- package/dist/es/agent/task-builder.mjs.map +1 -1
- package/dist/es/agent/task-cache.mjs +93 -44
- package/dist/es/agent/task-cache.mjs.map +1 -1
- package/dist/es/agent/utils.mjs +1 -1
- package/dist/es/ai-model/prompt/llm-planning.mjs +357 -153
- package/dist/es/ai-model/prompt/llm-planning.mjs.map +1 -1
- package/dist/es/ai-model/service-caller/codex-app-server.mjs +584 -0
- package/dist/es/ai-model/service-caller/codex-app-server.mjs.map +1 -0
- package/dist/es/ai-model/service-caller/index.mjs +2 -0
- package/dist/es/ai-model/service-caller/index.mjs.map +1 -1
- package/dist/es/utils.mjs +2 -2
- package/dist/lib/agent/agent.js +1 -1
- package/dist/lib/agent/agent.js.map +1 -1
- package/dist/lib/agent/cache-adapter.js +20 -0
- package/dist/lib/agent/cache-adapter.js.map +1 -0
- package/dist/lib/agent/task-builder.js +2 -2
- package/dist/lib/agent/task-builder.js.map +1 -1
- package/dist/lib/agent/task-cache.js +93 -44
- package/dist/lib/agent/task-cache.js.map +1 -1
- package/dist/lib/agent/utils.js +1 -1
- package/dist/lib/ai-model/prompt/llm-planning.js +357 -153
- package/dist/lib/ai-model/prompt/llm-planning.js.map +1 -1
- package/dist/lib/ai-model/service-caller/codex-app-server.js +633 -0
- package/dist/lib/ai-model/service-caller/codex-app-server.js.map +1 -0
- package/dist/lib/ai-model/service-caller/index.js +2 -0
- package/dist/lib/ai-model/service-caller/index.js.map +1 -1
- package/dist/lib/utils.js +2 -2
- package/dist/types/agent/cache-adapter.d.ts +32 -0
- package/dist/types/agent/index.d.ts +2 -0
- package/dist/types/agent/task-cache.d.ts +16 -7
- package/dist/types/ai-model/service-caller/codex-app-server.d.ts +46 -0
- package/package.json +3 -3
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CacheFileContent } from './task-cache';
|
|
2
|
+
/**
|
|
3
|
+
* 缓存适配器接口
|
|
4
|
+
* 支持多种存储后端:本地文件、Redis、OSS、数据库等
|
|
5
|
+
*/
|
|
6
|
+
export interface CacheAdapter {
|
|
7
|
+
/**
|
|
8
|
+
* 获取缓存
|
|
9
|
+
* @param cacheId 缓存ID
|
|
10
|
+
* @param prompt 提示词(可选,用于细粒度缓存)
|
|
11
|
+
* @returns 缓存内容,如果不存在返回 null
|
|
12
|
+
*/
|
|
13
|
+
get(cacheId: string, prompt?: string): Promise<CacheFileContent | null>;
|
|
14
|
+
/**
|
|
15
|
+
* 设置缓存
|
|
16
|
+
* @param cacheId 缓存ID
|
|
17
|
+
* @param content 缓存内容
|
|
18
|
+
* @param prompt 提示词(可选)
|
|
19
|
+
* @param ttl 缓存过期时间(秒,可选)
|
|
20
|
+
*/
|
|
21
|
+
set(cacheId: string, content: CacheFileContent, prompt?: string, ttl?: number): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* 删除缓存
|
|
24
|
+
* @param cacheId 缓存ID
|
|
25
|
+
*/
|
|
26
|
+
delete(cacheId: string): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* 检查缓存是否存在
|
|
29
|
+
* @param cacheId 缓存ID
|
|
30
|
+
*/
|
|
31
|
+
exists(cacheId: string): Promise<boolean>;
|
|
32
|
+
}
|
|
@@ -4,6 +4,8 @@ export { getReportFileName, printReportMsg, } from './utils';
|
|
|
4
4
|
export { extractInsightParam, locateParamStr, paramStr, taskTitleStr, typeStr, } from './ui-utils';
|
|
5
5
|
export { type LocateCache, type PlanningCache, TaskCache } from './task-cache';
|
|
6
6
|
export { cacheFileExt } from './task-cache';
|
|
7
|
+
export type { CacheFileContent } from './task-cache';
|
|
8
|
+
export type { CacheAdapter } from './cache-adapter';
|
|
7
9
|
export { TaskExecutor } from './tasks';
|
|
8
10
|
export { getCurrentExecutionFile } from './utils';
|
|
9
11
|
export type { AgentOpt } from '../types';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TUserPrompt } from '../ai-model';
|
|
2
2
|
import type { ElementCacheFeature } from '../types';
|
|
3
|
+
import type { CacheAdapter } from './cache-adapter';
|
|
3
4
|
export declare const debug: import("@midscene/shared/logger").DebugFunction;
|
|
4
5
|
export interface PlanningCache {
|
|
5
6
|
type: 'plan';
|
|
@@ -15,7 +16,9 @@ export interface LocateCache {
|
|
|
15
16
|
}
|
|
16
17
|
export interface MatchCacheResult<T extends PlanningCache | LocateCache> {
|
|
17
18
|
cacheContent: T;
|
|
18
|
-
updateFn: (cb: (cache: T) => void
|
|
19
|
+
updateFn: (cb: (cache: T) => void, options?: {
|
|
20
|
+
ttl?: number;
|
|
21
|
+
}) => Promise<void>;
|
|
19
22
|
}
|
|
20
23
|
export type CacheFileContent = {
|
|
21
24
|
midsceneVersion: string;
|
|
@@ -32,17 +35,23 @@ export declare class TaskCache {
|
|
|
32
35
|
readOnlyMode: boolean;
|
|
33
36
|
writeOnlyMode: boolean;
|
|
34
37
|
private matchedCacheIndices;
|
|
35
|
-
|
|
38
|
+
private cacheAdapter?;
|
|
39
|
+
constructor(cacheId: string, isCacheResultUsed: boolean, cacheAdapterOrPath?: CacheAdapter | string, options?: {
|
|
36
40
|
readOnly?: boolean;
|
|
37
41
|
writeOnly?: boolean;
|
|
38
42
|
});
|
|
39
|
-
matchCache(prompt: TUserPrompt, type: 'plan' | 'locate'): MatchCacheResult<PlanningCache | LocateCache> | undefined
|
|
40
|
-
matchPlanCache(prompt: string): MatchCacheResult<PlanningCache> | undefined
|
|
41
|
-
matchLocateCache(prompt: TUserPrompt): MatchCacheResult<LocateCache> | undefined
|
|
42
|
-
appendCache(cache: PlanningCache | LocateCache): void
|
|
43
|
+
matchCache(prompt: TUserPrompt, type: 'plan' | 'locate'): Promise<MatchCacheResult<PlanningCache | LocateCache> | undefined>;
|
|
44
|
+
matchPlanCache(prompt: string): Promise<MatchCacheResult<PlanningCache> | undefined>;
|
|
45
|
+
matchLocateCache(prompt: TUserPrompt): Promise<MatchCacheResult<LocateCache> | undefined>;
|
|
46
|
+
appendCache(cache: PlanningCache | LocateCache): Promise<void>;
|
|
47
|
+
private loadCache;
|
|
48
|
+
private loadCacheFromAdapter;
|
|
43
49
|
loadCacheFromFile(): CacheFileContent | undefined;
|
|
50
|
+
private flushCache;
|
|
51
|
+
private flushCacheToAdapter;
|
|
44
52
|
flushCacheToFile(options?: {
|
|
45
53
|
cleanUnused?: boolean;
|
|
46
54
|
}): void;
|
|
47
|
-
|
|
55
|
+
private prepareCacheToWrite;
|
|
56
|
+
updateOrAppendCacheRecord(newRecord: PlanningCache | LocateCache, cachedRecord?: MatchCacheResult<PlanningCache | LocateCache>): Promise<void>;
|
|
48
57
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { AIUsageInfo, DeepThinkOption, StreamingCallback } from '../../types';
|
|
2
|
+
import type { IModelConfig } from '@midscene/shared/env';
|
|
3
|
+
import type { ChatCompletionMessageParam } from 'openai/resources/index';
|
|
4
|
+
type CodexReasoningEffort = 'low' | 'medium' | 'high' | 'xhigh';
|
|
5
|
+
type CodexTextInput = {
|
|
6
|
+
type: 'text';
|
|
7
|
+
text: string;
|
|
8
|
+
text_elements: any[];
|
|
9
|
+
};
|
|
10
|
+
type CodexImageInput = {
|
|
11
|
+
type: 'image';
|
|
12
|
+
url: string;
|
|
13
|
+
detail?: string;
|
|
14
|
+
};
|
|
15
|
+
type CodexLocalImageInput = {
|
|
16
|
+
type: 'localImage';
|
|
17
|
+
path: string;
|
|
18
|
+
detail?: string;
|
|
19
|
+
};
|
|
20
|
+
type CodexTurnInput = CodexTextInput | CodexImageInput | CodexLocalImageInput;
|
|
21
|
+
type CodexTurnResult = {
|
|
22
|
+
content: string;
|
|
23
|
+
reasoning_content?: string;
|
|
24
|
+
usage?: AIUsageInfo;
|
|
25
|
+
isStreamed: boolean;
|
|
26
|
+
};
|
|
27
|
+
export declare const isCodexAppServerProvider: (baseURL?: string) => boolean;
|
|
28
|
+
export declare const normalizeCodexLocalImagePath: (imageUrl: string, platform?: NodeJS.Platform) => string;
|
|
29
|
+
export declare const resolveCodexReasoningEffort: ({ deepThink, modelConfig, }: {
|
|
30
|
+
deepThink?: DeepThinkOption;
|
|
31
|
+
modelConfig: IModelConfig;
|
|
32
|
+
}) => CodexReasoningEffort | undefined;
|
|
33
|
+
export declare const buildCodexTurnPayloadFromMessages: (messages: ChatCompletionMessageParam[], options?: {
|
|
34
|
+
imageDetailOverride?: string;
|
|
35
|
+
}) => {
|
|
36
|
+
developerInstructions?: string;
|
|
37
|
+
input: CodexTurnInput[];
|
|
38
|
+
};
|
|
39
|
+
export declare function callAIWithCodexAppServer(messages: ChatCompletionMessageParam[], modelConfig: IModelConfig, options?: {
|
|
40
|
+
stream?: boolean;
|
|
41
|
+
onChunk?: StreamingCallback;
|
|
42
|
+
deepThink?: DeepThinkOption;
|
|
43
|
+
abortSignal?: AbortSignal;
|
|
44
|
+
}): Promise<CodexTurnResult>;
|
|
45
|
+
export declare function __shutdownCodexAppServerForTests(): Promise<void>;
|
|
46
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@donggui/core",
|
|
3
|
-
"description": "Automate browser actions, extract data, and perform assertions using AI.
|
|
4
|
-
"version": "1.5.
|
|
3
|
+
"description": "DongGUI Core - Automate browser actions, extract data, and perform assertions using AI.",
|
|
4
|
+
"version": "1.5.6",
|
|
5
5
|
"repository": "https://github.com/web-infra-dev/midscene",
|
|
6
6
|
"homepage": "https://midscenejs.com/",
|
|
7
7
|
"main": "./dist/lib/index.js",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"test:parse-action": "npm run test:ai -- tests/ai/parse-action.test.ts"
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@midscene/shared": "
|
|
81
|
+
"@midscene/shared": "workspace:*",
|
|
82
82
|
"@ui-tars/action-parser": "1.2.3",
|
|
83
83
|
"dayjs": "^1.11.11",
|
|
84
84
|
"dotenv": "^16.4.5",
|