autoglm.js 0.0.5 → 0.0.7-beta.4
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/index.d.mts +185 -18
- package/dist/index.mjs +1849 -23
- package/package.json +16 -32
- package/README.md +0 -283
- package/asset/ADBKeyboard.apk +0 -0
- package/dist/check-Ox_8ktAc.mjs +0 -17887
- package/dist/cli.d.mts +0 -1
- package/dist/cli.mjs +0 -372
- package/dist/prompt-Bq8BVVJJ.mjs +0 -847
- package/schema/agent-config.schema.json +0 -69
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,45 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as tinyexec0 from "tinyexec";
|
|
2
|
+
import "dayjs/locale/zh-cn.js";
|
|
3
|
+
import "mitt";
|
|
2
4
|
|
|
3
|
-
//#region src/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
//#region src/constants/app.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Mapping of app names to their package names.
|
|
8
|
+
*/
|
|
9
|
+
declare const APP_PACKAGES: Record<string, string>;
|
|
10
|
+
/**
|
|
11
|
+
* List all supported apps.
|
|
12
|
+
*/
|
|
13
|
+
declare function listSupportedApps(): string[];
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/constants/errorCodes.d.ts
|
|
16
|
+
declare enum ErrorCode {
|
|
17
|
+
/** unknown error */
|
|
18
|
+
UNKNOWN_ERROR = 0,
|
|
19
|
+
/** adb not installed */
|
|
20
|
+
ADB_NOT_INSTALLED = 1,
|
|
21
|
+
/** adb device not connected */
|
|
22
|
+
ADB_DEVICE_UNCONNECTED = 2,
|
|
23
|
+
/** adb keyboard not installed */
|
|
24
|
+
ADB_KEYBOARD_UNINSTALLED = 3,
|
|
25
|
+
/** model api check failed */
|
|
26
|
+
MODEL_API_CHECK_FAILED = 4,
|
|
7
27
|
}
|
|
8
28
|
//#endregion
|
|
9
|
-
//#region src/
|
|
29
|
+
//#region src/constants/filePath.d.ts
|
|
30
|
+
declare const AUTOGLM_FILEPATH: string;
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/constants/prompts_en.d.ts
|
|
33
|
+
declare const SYSTEM_PROMPT_EN: string;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/constants/prompts_zh.d.ts
|
|
36
|
+
/**
|
|
37
|
+
* Chinese system prompt for the agent.
|
|
38
|
+
*/
|
|
39
|
+
declare const SYSTEM_PROMPT_ZH: string;
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/context/types.d.ts
|
|
10
42
|
interface AgentConfigType {
|
|
11
|
-
mode: 'cli' | 'api';
|
|
12
43
|
maxSteps: number;
|
|
13
44
|
lang: 'cn' | 'en';
|
|
14
45
|
deviceId?: string;
|
|
@@ -20,23 +51,159 @@ interface AgentConfigType {
|
|
|
20
51
|
temperature: number;
|
|
21
52
|
topP: number;
|
|
22
53
|
frequencyPenalty: number;
|
|
54
|
+
screenshotQuality?: number;
|
|
55
|
+
}
|
|
56
|
+
interface EventData {
|
|
57
|
+
message: any;
|
|
58
|
+
time: string;
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/adb/constants.d.ts
|
|
62
|
+
declare const CONNECTION_TYPE: {
|
|
63
|
+
readonly USB: "usb";
|
|
64
|
+
readonly TCPIP: "tcpip";
|
|
65
|
+
};
|
|
66
|
+
type ConnectionType = (typeof CONNECTION_TYPE)[keyof typeof CONNECTION_TYPE];
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/adb/types.d.ts
|
|
69
|
+
/**
|
|
70
|
+
* Device information.
|
|
71
|
+
*/
|
|
72
|
+
interface DeviceInfo {
|
|
73
|
+
deviceId: string;
|
|
74
|
+
status: 'device' | 'unauthorized' | 'offline';
|
|
75
|
+
connectionType: ConnectionType;
|
|
76
|
+
model?: string;
|
|
77
|
+
brand?: string;
|
|
78
|
+
manufacturer?: string;
|
|
79
|
+
device?: string;
|
|
80
|
+
androidVersion?: string;
|
|
81
|
+
apiLevel?: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Screenshot data.
|
|
85
|
+
*/
|
|
86
|
+
declare class Screenshot {
|
|
87
|
+
base64Data: string;
|
|
88
|
+
width: number;
|
|
89
|
+
height: number;
|
|
90
|
+
constructor(base64Data: string, width: number, height: number);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* ADB keyboard check result.
|
|
94
|
+
*/
|
|
95
|
+
interface ADBKeyboardCheckResult {
|
|
96
|
+
success: boolean;
|
|
97
|
+
message: string;
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/context/event.d.ts
|
|
101
|
+
declare enum EventType {
|
|
102
|
+
START = "start",
|
|
103
|
+
THINKING = "thinking",
|
|
104
|
+
ACTION = "action",
|
|
105
|
+
TASK_COMPLETE = "task_complete",
|
|
106
|
+
ERROR = "error",
|
|
107
|
+
ABORTED = "aborted",
|
|
108
|
+
THINKING_STREAM = "thinking_stream",
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/context/index.d.ts
|
|
112
|
+
declare class AgentContext {
|
|
113
|
+
private configStore;
|
|
114
|
+
private emitter;
|
|
115
|
+
constructor(config: Partial<AgentConfigType>);
|
|
116
|
+
getConfig(): AgentConfigType;
|
|
117
|
+
updateConfig(config: Partial<AgentConfigType>): void;
|
|
118
|
+
emit(event: EventType, data: unknown): void;
|
|
119
|
+
on(event: any, handler: any): void;
|
|
120
|
+
off(event: any, handler: any): void;
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/adb/manager.d.ts
|
|
124
|
+
declare class ADBManager {
|
|
125
|
+
private ctx;
|
|
126
|
+
private connection;
|
|
127
|
+
private keyboard;
|
|
128
|
+
constructor(context: AgentContext);
|
|
129
|
+
install(customPlatformToolsPath?: string): Promise<void>;
|
|
130
|
+
getVersion(): Promise<{
|
|
131
|
+
success: boolean;
|
|
132
|
+
message: string;
|
|
133
|
+
version: string | null;
|
|
134
|
+
}>;
|
|
135
|
+
getConnectedDevices(): Promise<DeviceInfo[]>;
|
|
136
|
+
devices(): Promise<{
|
|
137
|
+
success: boolean;
|
|
138
|
+
message: string;
|
|
139
|
+
}>;
|
|
140
|
+
connect(address: string): Promise<{
|
|
141
|
+
success: boolean;
|
|
142
|
+
message: string;
|
|
143
|
+
}>;
|
|
144
|
+
disconnect(address?: string): Promise<{
|
|
145
|
+
success: boolean;
|
|
146
|
+
message: string;
|
|
147
|
+
}>;
|
|
148
|
+
enableTCPIP(port?: number, deviceId?: string): Promise<{
|
|
149
|
+
success: boolean;
|
|
150
|
+
message: string;
|
|
151
|
+
}>;
|
|
152
|
+
getDeviceIp(deviceId?: string): Promise<string | null>;
|
|
153
|
+
isKeyboardInstalled(): Promise<{
|
|
154
|
+
success: boolean;
|
|
155
|
+
message: string;
|
|
156
|
+
}>;
|
|
157
|
+
installKeyboard(customApkPath?: string): Promise<{
|
|
158
|
+
success: boolean;
|
|
159
|
+
message: string;
|
|
160
|
+
}>;
|
|
23
161
|
}
|
|
24
162
|
//#endregion
|
|
25
|
-
//#region src/
|
|
163
|
+
//#region src/autoglm.d.ts
|
|
26
164
|
declare class AutoGLM {
|
|
27
165
|
private phoneAgent;
|
|
28
|
-
private
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
task_complete: EventData;
|
|
34
|
-
}>;
|
|
35
|
-
checkModelApi(): Promise<void>;
|
|
166
|
+
private ctx;
|
|
167
|
+
private adbManager;
|
|
168
|
+
constructor(config: Partial<AgentConfigType>);
|
|
169
|
+
get adb(): ADBManager;
|
|
170
|
+
abort(reason?: string): void;
|
|
36
171
|
checkSystemRequirements(): Promise<{
|
|
172
|
+
success: boolean;
|
|
173
|
+
code: ErrorCode;
|
|
174
|
+
message?: undefined;
|
|
175
|
+
} | {
|
|
176
|
+
success: boolean;
|
|
177
|
+
code?: undefined;
|
|
178
|
+
message?: undefined;
|
|
179
|
+
} | {
|
|
37
180
|
success: boolean;
|
|
38
181
|
message: string;
|
|
39
|
-
|
|
182
|
+
code: ErrorCode;
|
|
183
|
+
}>;
|
|
184
|
+
checkModelApi(): Promise<{
|
|
185
|
+
success: boolean;
|
|
186
|
+
code: ErrorCode;
|
|
187
|
+
message?: undefined;
|
|
188
|
+
} | {
|
|
189
|
+
success: boolean;
|
|
190
|
+
code?: undefined;
|
|
191
|
+
message?: undefined;
|
|
192
|
+
} | {
|
|
193
|
+
success: boolean;
|
|
194
|
+
message: string;
|
|
195
|
+
code: ErrorCode;
|
|
196
|
+
}>;
|
|
197
|
+
run(task: string): Promise<string>;
|
|
198
|
+
on(type: '*', handler: (type: EventType, data: EventData) => void): this;
|
|
199
|
+
on(type: EventType, handler: (data: EventData) => void): this;
|
|
200
|
+
off(type: '*', handler: (type: EventType, data: EventData) => void): this;
|
|
201
|
+
off(type: EventType, handler: (data: EventData) => void): this;
|
|
202
|
+
get config(): AgentConfigType;
|
|
203
|
+
updateConfig(config: Partial<AgentConfigType>): void;
|
|
40
204
|
}
|
|
41
205
|
//#endregion
|
|
42
|
-
|
|
206
|
+
//#region src/adb/utils.d.ts
|
|
207
|
+
declare function runAdbCommand(deviceId: string | undefined, args: string[], timeout?: number): Promise<tinyexec0.Output>;
|
|
208
|
+
//#endregion
|
|
209
|
+
export { ADBKeyboardCheckResult, APP_PACKAGES, AUTOGLM_FILEPATH, AgentConfigType, AutoGLM, DeviceInfo, ErrorCode, EventData, EventType, SYSTEM_PROMPT_EN, SYSTEM_PROMPT_ZH, Screenshot, listSupportedApps, runAdbCommand };
|