@aiscene/shared 8.0.3 → 8.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.
Files changed (105) hide show
  1. package/dist/es/agent-tools/agent-behavior-init-args.mjs +44 -0
  2. package/dist/es/agent-tools/base-tools.mjs +163 -0
  3. package/dist/es/agent-tools/chrome-path.mjs +50 -0
  4. package/dist/es/agent-tools/cli-report-session.mjs +78 -0
  5. package/dist/es/agent-tools/error-formatter.mjs +106 -0
  6. package/dist/es/agent-tools/index.mjs +9 -0
  7. package/dist/es/agent-tools/init-arg-utils.mjs +38 -0
  8. package/dist/es/agent-tools/observation-artifact.mjs +5 -0
  9. package/dist/es/agent-tools/observation-record.mjs +248 -0
  10. package/dist/es/agent-tools/tool-defaults.mjs +54 -0
  11. package/dist/es/agent-tools/tool-generator.mjs +529 -0
  12. package/dist/es/agent-tools/types.mjs +3 -0
  13. package/dist/es/agent-tools/user-prompt.mjs +66 -0
  14. package/dist/es/cli/interrupt.mjs +116 -0
  15. package/dist/es/cli/record-command.mjs +130 -0
  16. package/dist/es/cli/screenshot-file.mjs +24 -0
  17. package/dist/es/cli/verbose-ai-act.mjs +230 -0
  18. package/dist/es/cli/verbose-screenshot.mjs +134 -0
  19. package/dist/es/cli/verbose.mjs +404 -0
  20. package/dist/es/env/parse-model-config.mjs +1 -1
  21. package/dist/es/env/types.mjs +18 -3
  22. package/dist/es/img/index.mjs +3 -3
  23. package/dist/es/img/info.mjs +45 -1
  24. package/dist/es/img/photon-loader.mjs +4 -0
  25. package/dist/es/img/transform.mjs +113 -3
  26. package/dist/es/recorder.mjs +249 -0
  27. package/dist/lib/agent-tools/agent-behavior-init-args.js +87 -0
  28. package/dist/lib/agent-tools/base-tools.js +197 -0
  29. package/dist/lib/agent-tools/chrome-path.js +87 -0
  30. package/dist/lib/agent-tools/cli-report-session.js +121 -0
  31. package/dist/lib/agent-tools/error-formatter.js +149 -0
  32. package/dist/lib/agent-tools/index.js +114 -0
  33. package/dist/lib/agent-tools/init-arg-utils.js +78 -0
  34. package/dist/lib/agent-tools/observation-artifact.js +42 -0
  35. package/dist/lib/agent-tools/observation-record.js +297 -0
  36. package/dist/lib/agent-tools/tool-defaults.js +97 -0
  37. package/dist/lib/agent-tools/tool-generator.js +569 -0
  38. package/dist/lib/agent-tools/types.js +40 -0
  39. package/dist/lib/agent-tools/user-prompt.js +103 -0
  40. package/dist/lib/cli/interrupt.js +156 -0
  41. package/dist/lib/cli/record-command.js +164 -0
  42. package/dist/lib/cli/screenshot-file.js +58 -0
  43. package/dist/lib/cli/verbose-ai-act.js +273 -0
  44. package/dist/lib/cli/verbose-screenshot.js +177 -0
  45. package/dist/lib/cli/verbose.js +465 -0
  46. package/dist/lib/env/parse-model-config.js +1 -1
  47. package/dist/lib/env/types.js +32 -2
  48. package/dist/lib/img/index.js +29 -5
  49. package/dist/lib/img/info.js +48 -1
  50. package/dist/lib/img/photon-loader.js +38 -0
  51. package/dist/lib/img/transform.js +135 -4
  52. package/dist/lib/recorder.js +307 -0
  53. package/dist/types/agent-tools/agent-behavior-init-args.d.ts +17 -0
  54. package/dist/types/agent-tools/base-tools.d.ts +158 -0
  55. package/dist/types/agent-tools/chrome-path.d.ts +2 -0
  56. package/dist/types/agent-tools/cli-report-session.d.ts +12 -0
  57. package/dist/types/agent-tools/error-formatter.d.ts +30 -0
  58. package/dist/types/agent-tools/index.d.ts +9 -0
  59. package/dist/types/agent-tools/init-arg-utils.d.ts +13 -0
  60. package/dist/types/agent-tools/observation-artifact.d.ts +10 -0
  61. package/dist/types/agent-tools/observation-record.d.ts +38 -0
  62. package/dist/types/agent-tools/tool-defaults.d.ts +63 -0
  63. package/dist/types/agent-tools/tool-generator.d.ts +13 -0
  64. package/dist/types/agent-tools/types.d.ts +213 -0
  65. package/dist/types/agent-tools/user-prompt.d.ts +13 -0
  66. package/dist/types/cli/interrupt.d.ts +49 -0
  67. package/dist/types/cli/record-command.d.ts +3 -0
  68. package/dist/types/cli/screenshot-file.d.ts +10 -0
  69. package/dist/types/cli/verbose-ai-act.d.ts +44 -0
  70. package/dist/types/cli/verbose-screenshot.d.ts +10 -0
  71. package/dist/types/cli/verbose.d.ts +40 -0
  72. package/dist/types/env/types.d.ts +16 -7
  73. package/dist/types/img/index.d.ts +2 -2
  74. package/dist/types/img/info.d.ts +2 -0
  75. package/dist/types/img/photon-loader.d.ts +2 -0
  76. package/dist/types/img/transform.d.ts +22 -2
  77. package/dist/types/mcp/types.d.ts +1 -0
  78. package/dist/types/recorder.d.ts +113 -0
  79. package/package.json +1 -1
  80. package/src/agent-tools/agent-behavior-init-args.ts +109 -0
  81. package/src/agent-tools/base-tools.ts +399 -0
  82. package/src/agent-tools/chrome-path.ts +74 -0
  83. package/src/agent-tools/cli-report-session.ts +130 -0
  84. package/src/agent-tools/error-formatter.ts +177 -0
  85. package/src/agent-tools/index.ts +9 -0
  86. package/src/agent-tools/init-arg-utils.ts +105 -0
  87. package/src/agent-tools/observation-artifact.ts +29 -0
  88. package/src/agent-tools/observation-record.ts +331 -0
  89. package/src/agent-tools/tool-defaults.ts +119 -0
  90. package/src/agent-tools/tool-generator.ts +866 -0
  91. package/src/agent-tools/types.ts +250 -0
  92. package/src/agent-tools/user-prompt.ts +102 -0
  93. package/src/cli/interrupt.ts +207 -0
  94. package/src/cli/record-command.ts +177 -0
  95. package/src/cli/screenshot-file.ts +61 -0
  96. package/src/cli/verbose-ai-act.ts +387 -0
  97. package/src/cli/verbose-screenshot.ts +269 -0
  98. package/src/cli/verbose.ts +753 -0
  99. package/src/env/types.ts +30 -2
  100. package/src/img/index.ts +12 -0
  101. package/src/img/info.ts +61 -0
  102. package/src/img/photon-loader.ts +5 -0
  103. package/src/img/transform.ts +262 -3
  104. package/src/mcp/types.ts +2 -0
  105. package/src/recorder.ts +625 -0
@@ -0,0 +1,13 @@
1
+ import type { ToolDefaults } from './tool-defaults';
2
+ import type { ActionSpaceItem, BaseAgent, ToolCliMetadata, ToolDefinition, ToolSchema } from './types';
3
+ import { composeUserPrompt } from './user-prompt';
4
+ export { composeUserPrompt };
5
+ /**
6
+ * Converts DeviceAction from actionSpace into ToolDefinition.
7
+ * This is the core logic that removes need for hardcoded tool definitions
8
+ */
9
+ export declare function generateToolsFromActionSpace(actionSpace: ActionSpaceItem[], getAgent: (args?: Record<string, unknown>) => Promise<BaseAgent>, sanitizeArgs?: (args: Record<string, unknown>) => Record<string, unknown>, initArgSchema?: ToolSchema, initArgCliMetadata?: ToolCliMetadata, toolDefaults?: ToolDefaults): ToolDefinition[];
10
+ /**
11
+ * Generate common tools (screenshot, act)
12
+ */
13
+ export declare function generateCommonTools(getAgent: (args?: Record<string, unknown>) => Promise<BaseAgent>, initArgSchema?: ToolSchema, initArgCliMetadata?: ToolCliMetadata, toolDefaults?: ToolDefaults): ToolDefinition[];
@@ -0,0 +1,213 @@
1
+ import type { z } from 'zod';
2
+ import type { ToolDefaults } from './tool-defaults';
3
+ /**
4
+ * Default timeout constants for app loading verification
5
+ */
6
+ export declare const defaultAppLoadingTimeoutMs = 10000;
7
+ export declare const defaultAppLoadingCheckIntervalMs = 2000;
8
+ /**
9
+ * Content item types for tool results.
10
+ */
11
+ export type ToolResultContent = {
12
+ type: 'text';
13
+ text: string;
14
+ } | {
15
+ type: 'image';
16
+ data: string;
17
+ mimeType: string;
18
+ } | {
19
+ type: 'audio';
20
+ data: string;
21
+ mimeType: string;
22
+ } | {
23
+ type: 'resource';
24
+ resource: {
25
+ text: string;
26
+ uri: string;
27
+ mimeType?: string;
28
+ } | {
29
+ uri: string;
30
+ blob: string;
31
+ mimeType?: string;
32
+ };
33
+ };
34
+ /**
35
+ * Result type for tool execution.
36
+ */
37
+ export interface ToolResult {
38
+ [x: string]: unknown;
39
+ content: ToolResultContent[];
40
+ isError?: boolean;
41
+ _meta?: Record<string, unknown>;
42
+ }
43
+ /**
44
+ * Tool handler function type
45
+ * Takes parsed arguments and returns a tool result
46
+ */
47
+ export type ToolHandler<T = Record<string, unknown>> = (args: T) => Promise<ToolResult>;
48
+ /**
49
+ * Tool schema type using Zod
50
+ */
51
+ export type ToolSchema = Record<string, z.ZodTypeAny>;
52
+ export interface ToolCliOption {
53
+ preferredName?: string;
54
+ aliases?: string[];
55
+ hidden?: boolean;
56
+ }
57
+ export interface ToolCliMetadata {
58
+ options?: Record<string, ToolCliOption>;
59
+ /** Schema keys populated from leading positional CLI arguments. */
60
+ positionals?: string[];
61
+ }
62
+ /**
63
+ * Tool definition for Midscene CLI and Skill surfaces.
64
+ */
65
+ export interface ToolDefinition<T = Record<string, unknown>> {
66
+ name: string;
67
+ description: string;
68
+ schema: ToolSchema;
69
+ handler: ToolHandler<T>;
70
+ cli?: ToolCliMetadata;
71
+ }
72
+ export type Tool = ToolDefinition;
73
+ /**
74
+ * Action space item definition
75
+ * Note: Intentionally no index signature to maintain compatibility with DeviceAction
76
+ */
77
+ export interface ActionSpaceItem {
78
+ name: string;
79
+ description?: string;
80
+ args?: Record<string, unknown>;
81
+ paramSchema?: z.ZodTypeAny;
82
+ }
83
+ /**
84
+ * Structural shape compatible with @aiscene/core `TUserPrompt`.
85
+ * Declared locally to avoid a circular dep on `@aiscene/core` from `@aiscene/shared`.
86
+ *
87
+ * Consumed by the `assert` and `act` tools in `generateCommonTools`, both of
88
+ * which forward reference images to core (`aiAssert` / `aiAct`). `aiWaitFor`
89
+ * stays string-only at the CLI surface because the tools generator does not
90
+ * yet expose a multimodal entry point for it.
91
+ */
92
+ export type UserPromptLike = string | {
93
+ prompt: string;
94
+ images?: Array<{
95
+ name: string;
96
+ url: string;
97
+ }>;
98
+ convertHttpImage2Base64?: boolean;
99
+ };
100
+ export interface RecordToReportScreenshot {
101
+ /**
102
+ * PNG/JPEG data URI, or raw PNG base64 body.
103
+ */
104
+ base64: string;
105
+ description?: string;
106
+ }
107
+ export interface RecordToReportOptions {
108
+ content?: string;
109
+ /**
110
+ * @deprecated Use `screenshots: [{ base64 }]` instead.
111
+ */
112
+ screenshotBase64?: string;
113
+ screenshots?: RecordToReportScreenshot[];
114
+ }
115
+ /** Generic progress-bus envelope as seen by tool consumers (all untrusted). */
116
+ export interface BaseAgentProgressEvent {
117
+ scope?: unknown;
118
+ phase?: unknown;
119
+ sequence?: unknown;
120
+ data?: unknown;
121
+ }
122
+ /** A single frame in a portable UI observation record. */
123
+ export interface UIObservationFrame {
124
+ /** Path to the captured image. Serialized manifests use relative paths. */
125
+ path: string;
126
+ /** MIME type of the captured image file. */
127
+ mimeType: 'image/png' | 'image/jpeg';
128
+ /** Capture timestamp in milliseconds. */
129
+ capturedAt: number;
130
+ }
131
+ /**
132
+ * Serializable observation window that can be persisted and loaded later.
133
+ * Frames are ordered from earliest to latest; the final frame represents the
134
+ * UI state at the end of the observation window.
135
+ */
136
+ export interface UIObservationRecord {
137
+ type: 'midscene_ui_observation';
138
+ version: 1;
139
+ /** Time when observation sampling started. */
140
+ startedAt: number;
141
+ /** Time when the final representative frame was captured. */
142
+ endedAt: number;
143
+ frames: UIObservationFrame[];
144
+ shotSize: {
145
+ width: number;
146
+ height: number;
147
+ };
148
+ shrunkShotToLogicalRatio: number;
149
+ }
150
+ /** Fixed observation window consumed by shared CLI surfaces. */
151
+ export interface BaseUIObservation {
152
+ readonly frameCount: number;
153
+ readonly startedAt: number;
154
+ readonly endedAt: number;
155
+ aiAssert(assertion: UserPromptLike, message?: string, options?: Record<string, unknown>): Promise<unknown>;
156
+ /** Release any resources owned by this observation. */
157
+ dispose?(): Promise<void>;
158
+ }
159
+ /** Minimal UI observation lifecycle required by shared tool surfaces. */
160
+ export interface BaseUIObserver {
161
+ readonly bufferedFrameCount: number;
162
+ /** Stop sampling and return the fixed observed window. */
163
+ stop(): Promise<BaseUIObservation>;
164
+ /** Release temporary backing files if observation does not complete. */
165
+ dispose?(): Promise<void>;
166
+ }
167
+ /** Options for {@link BaseAgent.startObserving}. */
168
+ export interface BaseUIObserverOptions {
169
+ /** Sampling interval in milliseconds. Defaults to 1000; minimum 200. */
170
+ intervalMs?: number;
171
+ /** Maximum number of buffered frames. Defaults to 30; minimum 2. */
172
+ maxFrames?: number;
173
+ /** Auto-stop timeout in milliseconds. Defaults to 300000; 0 disables it. */
174
+ watchdogMs?: number;
175
+ }
176
+ /**
177
+ * Base agent interface
178
+ * Represents a platform-specific agent (Android, iOS, Web)
179
+ * Note: Return types use `unknown` for compatibility with platform-specific implementations
180
+ */
181
+ export interface BaseAgent {
182
+ getActionSpace(): Promise<ActionSpaceItem[]>;
183
+ destroy?(): Promise<void>;
184
+ reportFile?: string | null;
185
+ page?: {
186
+ screenshotBase64(): Promise<string>;
187
+ };
188
+ addDumpUpdateListener?(listener: (dump: string, executionDump?: unknown) => void): () => void;
189
+ addProgressListener?(listener: (event: BaseAgentProgressEvent) => void): () => void;
190
+ recordToReport?(title?: string, opt?: RecordToReportOptions): Promise<void>;
191
+ callActionInActionSpace?(actionName: string, params?: unknown): Promise<unknown>;
192
+ aiAction?(description: UserPromptLike, params?: Record<string, unknown>): Promise<unknown>;
193
+ aiWaitFor?(assertion: string, options: Record<string, unknown>): Promise<unknown>;
194
+ aiAssert?(assertion: UserPromptLike, msg?: string, options?: Record<string, unknown>): Promise<unknown>;
195
+ /** Start a UI observation window and capture its baseline frame. */
196
+ startObserving?(options?: BaseUIObserverOptions): Promise<BaseUIObserver>;
197
+ }
198
+ /**
199
+ * Base device interface for temporary device instances
200
+ */
201
+ export interface BaseDevice {
202
+ actionSpace(): ActionSpaceItem[];
203
+ destroy?(): Promise<void>;
204
+ }
205
+ /**
206
+ * Interface for platform-specific tools manager.
207
+ */
208
+ export interface IMidsceneTools {
209
+ initTools(): Promise<void>;
210
+ destroy?(): Promise<void>;
211
+ getCliToolDefinitions?(): ToolDefinition[];
212
+ setToolDefaults?(toolDefaults: ToolDefaults): void;
213
+ }
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+ import type { UserPromptLike } from './types';
3
+ export declare function composeUserPrompt(input: {
4
+ prompt: string;
5
+ image?: unknown;
6
+ imageName?: unknown;
7
+ convertHttpImage2Base64?: unknown;
8
+ }): UserPromptLike;
9
+ export declare const promptInputExtraSchema: {
10
+ image: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
11
+ imageName: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
12
+ convertHttpImage2Base64: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
13
+ };
@@ -0,0 +1,49 @@
1
+ export type CliInterruptReason = 'sigint' | 'sigterm' | 'sighup' | 'watchdog';
2
+ type CliInterruptSignal = 'SIGINT' | 'SIGTERM' | 'SIGHUP';
3
+ export interface CliInterruptSource {
4
+ on(event: CliInterruptSignal, listener: () => void): unknown;
5
+ removeListener(event: CliInterruptSignal, listener: () => void): unknown;
6
+ }
7
+ export interface CliInterruptInputSource {
8
+ readonly isTTY?: boolean;
9
+ readonly isRaw?: boolean;
10
+ readonly readableFlowing?: boolean | null;
11
+ on(event: 'data', listener: (chunk: unknown) => void): unknown;
12
+ removeListener(event: 'data', listener: (chunk: unknown) => void): unknown;
13
+ setRawMode?(enabled: boolean): unknown;
14
+ pause?(): unknown;
15
+ }
16
+ export interface CliInterruptWaiter {
17
+ /** Resolves on the first stop signal or watchdog timeout. */
18
+ readonly result: Promise<CliInterruptReason>;
19
+ /** Release signal handlers after asynchronous finalization has completed. */
20
+ dispose(): void;
21
+ }
22
+ export interface CliInterruptWaiterOptions {
23
+ source?: CliInterruptSource;
24
+ input?: CliInterruptInputSource;
25
+ /** Called after restoring the terminal when Ctrl+C is pressed again. */
26
+ forceExit?: (exitCode: number) => void;
27
+ }
28
+ /** Whether a foreground CLI command is currently waiting for this source. */
29
+ export declare function hasActiveCliInterruptWaiter(source?: CliInterruptSource): boolean;
30
+ /**
31
+ * Keep graceful-stop handlers installed until the caller has finished saving.
32
+ *
33
+ * Package runners such as pnpm can deliver SIGINT to the foreground child,
34
+ * immediately follow it with SIGTERM, then cause SIGHUP when the runner exits
35
+ * and its pseudo-terminal closes. Resolving on the first signal is not enough:
36
+ * removing any handler at that point lets a subsequent signal kill the child
37
+ * during asynchronous artifact finalization.
38
+ *
39
+ * On a TTY, Ctrl+C is captured as raw input so the package runner itself stays
40
+ * alive until the child has saved and restored the terminal. Signal handlers
41
+ * remain as the graceful-stop path for externally delivered termination.
42
+ */
43
+ export declare function createCliInterruptWaiter(watchdogMs: number, options?: CliInterruptWaiterOptions): CliInterruptWaiter;
44
+ /**
45
+ * Wait for one stop request and release the handlers immediately afterwards.
46
+ * Long-running finalizers should use {@link createCliInterruptWaiter} instead.
47
+ */
48
+ export declare function waitForCliInterrupt(watchdogMs: number, source?: CliInterruptSource, input?: CliInterruptInputSource | undefined): Promise<CliInterruptReason>;
49
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { BaseAgent, ToolCliMetadata, ToolDefinition, ToolSchema } from '../agent-tools/types';
2
+ /** Create the foreground recording command exposed only by Midscene CLIs. */
3
+ export declare function createRecordCliCommand(getAgent: (args?: Record<string, unknown>) => Promise<BaseAgent>, initArgSchema?: ToolSchema, initArgCliMetadata?: ToolCliMetadata): ToolDefinition;
@@ -0,0 +1,10 @@
1
+ export interface WriteCliScreenshotFileOptions {
2
+ id?: unknown;
3
+ mimeType?: unknown;
4
+ extension?: unknown;
5
+ directoryPath?: string;
6
+ directoryName?: string;
7
+ filenamePrefix?: string;
8
+ overwrite?: boolean;
9
+ }
10
+ export declare function writeCliScreenshotFile(rawBase64: string, options?: WriteCliScreenshotFileOptions): string;
@@ -0,0 +1,44 @@
1
+ import { type CliVerboseScreenshotCollectOptions } from './verbose-screenshot';
2
+ export interface CliVerboseLine {
3
+ key: string;
4
+ text: string;
5
+ }
6
+ /** Generic progress-bus envelope as seen by the CLI (all fields untrusted). */
7
+ export interface CliAgentProgressEvent {
8
+ scope?: unknown;
9
+ phase?: unknown;
10
+ sequence?: unknown;
11
+ data?: unknown;
12
+ }
13
+ /** Flattened, render-ready aiAct payload derived from the envelope. */
14
+ export interface CliAiActProgressPayload {
15
+ phase?: unknown;
16
+ sequence?: unknown;
17
+ prompt?: unknown;
18
+ planIndex?: unknown;
19
+ planLimit?: unknown;
20
+ action?: unknown;
21
+ thought?: unknown;
22
+ log?: unknown;
23
+ output?: unknown;
24
+ durationMs?: unknown;
25
+ error?: unknown;
26
+ screenshots?: Array<Record<string, unknown>>;
27
+ screenshotPath?: string;
28
+ [key: string]: unknown;
29
+ }
30
+ /** aiAct scope tag on the progress bus (mirrors core's `aiActProgressScope`). */
31
+ export declare const cliAiActProgressScope = "aiAct";
32
+ export declare function normalizeAiActProgressEventForCli(event: unknown, screenshotOptions?: CliVerboseScreenshotCollectOptions): CliAiActProgressPayload | undefined;
33
+ export declare function buildAiActProgressEventLines(event: CliAiActProgressPayload): CliVerboseLine[];
34
+ /**
35
+ * A producer-specific renderer for the generic CLI progress dispatcher: turn a
36
+ * raw progress envelope into a normalized payload, then that payload into
37
+ * verbose lines. New producers register their own renderer; the dispatcher core
38
+ * stays untouched.
39
+ */
40
+ export interface CliProgressRenderer {
41
+ normalize(event: unknown, screenshotOptions: CliVerboseScreenshotCollectOptions): Record<string, unknown> | undefined;
42
+ buildLines(payload: Record<string, unknown>): CliVerboseLine[];
43
+ }
44
+ export declare const aiActCliProgressRenderer: CliProgressRenderer;
@@ -0,0 +1,10 @@
1
+ export type CliVerboseScreenshotExportMode = 'none' | 'tmp' | 'report';
2
+ export interface CliVerboseScreenshotCollectOptions {
3
+ reportFile?: unknown;
4
+ exportMode?: CliVerboseScreenshotExportMode;
5
+ cache?: Map<string, string>;
6
+ }
7
+ export declare function collectScreenshotRefs(value: unknown, options?: CliVerboseScreenshotCollectOptions): Array<Record<string, unknown>>;
8
+ export declare function pathForReportScreenshot(path: string, reportFile?: unknown): string;
9
+ export declare function latestScreenshotPathForAiAct(value: unknown, options?: CliVerboseScreenshotCollectOptions): string;
10
+ export declare function renderScreenshotList(screenshots: unknown): string;
@@ -0,0 +1,40 @@
1
+ export declare const cliVerboseFlag = "verbose";
2
+ export type CliVerboseFormat = 'text' | 'jsonl';
3
+ export interface CliVerboseContext {
4
+ enabled: boolean;
5
+ format?: CliVerboseFormat;
6
+ scriptName?: string;
7
+ commandName?: string;
8
+ startedAt?: number;
9
+ renderedLineKeys?: Set<string>;
10
+ }
11
+ export interface CliVerboseEvent {
12
+ event: string;
13
+ scriptName?: string;
14
+ command?: string;
15
+ status?: 'ok' | 'error';
16
+ durationMs?: number;
17
+ error?: string;
18
+ [key: string]: unknown;
19
+ }
20
+ type DumpUpdateAgent = {
21
+ addDumpUpdateListener?: (listener: (dump: string, executionDump?: unknown) => void) => () => void;
22
+ addProgressListener?: (listener: (event: unknown) => void) => () => void;
23
+ reportFile?: string | null;
24
+ };
25
+ export declare function stripVerboseFlag(argv: readonly string[]): {
26
+ rawArgs: string[];
27
+ verbose: boolean;
28
+ format: CliVerboseFormat;
29
+ };
30
+ export declare function withCliVerboseContext<T>(context: CliVerboseContext, fn: () => Promise<T>): Promise<T>;
31
+ export declare function getCliVerboseContext(): CliVerboseContext;
32
+ export declare function isCliVerboseEnabled(): boolean;
33
+ export declare function emitCliVerboseEvent(event: CliVerboseEvent): void;
34
+ declare function errorMessageOf(error: unknown): string;
35
+ export declare function compactCliVerboseValue(value: unknown): unknown;
36
+ export declare function compactCliVerboseArgs(args: Record<string, unknown>): Record<string, unknown>;
37
+ export declare function attachCliVerboseDumpListener(agent: DumpUpdateAgent, options?: {
38
+ toolName?: string;
39
+ }): () => void;
40
+ export { errorMessageOf as cliVerboseErrorMessage };
@@ -6,6 +6,7 @@ export declare const MIDSCENE_DEBUG_MODEL_RESPONSE = "MIDSCENE_DEBUG_MODEL_RESPO
6
6
  export declare const MIDSCENE_DANGEROUSLY_PRINT_ALL_CONFIG = "MIDSCENE_DANGEROUSLY_PRINT_ALL_CONFIG";
7
7
  export declare const MIDSCENE_DEBUG_MODE = "MIDSCENE_DEBUG_MODE";
8
8
  export declare const MIDSCENE_MCP_USE_PUPPETEER_MODE = "MIDSCENE_MCP_USE_PUPPETEER_MODE";
9
+ export declare const MIDSCENE_CHROME_PATH = "MIDSCENE_CHROME_PATH";
9
10
  export declare const MIDSCENE_MCP_CHROME_PATH = "MIDSCENE_MCP_CHROME_PATH";
10
11
  export declare const MIDSCENE_MCP_ANDROID_MODE = "MIDSCENE_MCP_ANDROID_MODE";
11
12
  export declare const DOCKER_CONTAINER = "DOCKER_CONTAINER";
@@ -23,6 +24,9 @@ export declare const MIDSCENE_MODEL_RETRY_INTERVAL = "MIDSCENE_MODEL_RETRY_INTER
23
24
  export declare const MIDSCENE_MODEL_REASONING_EFFORT = "MIDSCENE_MODEL_REASONING_EFFORT";
24
25
  export declare const MIDSCENE_MODEL_REASONING_ENABLED = "MIDSCENE_MODEL_REASONING_ENABLED";
25
26
  export declare const MIDSCENE_MODEL_REASONING_BUDGET = "MIDSCENE_MODEL_REASONING_BUDGET";
27
+ export declare const MIDSCENE_MODEL_RESPONSE_FORMAT = "MIDSCENE_MODEL_RESPONSE_FORMAT";
28
+ export type TModelReasoningEnabled = boolean | 'default';
29
+ export type TModelResponseFormat = 'none' | 'auto';
26
30
  /**
27
31
  * @deprecated Use MIDSCENE_MODEL_API_KEY instead. This is kept for backward compatibility.
28
32
  */
@@ -68,6 +72,7 @@ export declare const MIDSCENE_PREFERRED_LANGUAGE = "MIDSCENE_PREFERRED_LANGUAGE"
68
72
  export declare const MIDSCENE_CACHE_MAX_FILENAME_LENGTH = "MIDSCENE_CACHE_MAX_FILENAME_LENGTH";
69
73
  export declare const MIDSCENE_REPLANNING_CYCLE_LIMIT = "MIDSCENE_REPLANNING_CYCLE_LIMIT";
70
74
  export declare const MIDSCENE_RUN_DIR = "MIDSCENE_RUN_DIR";
75
+ export declare const MIDSCENE_RECORD_MODEL_CALL = "MIDSCENE_RECORD_MODEL_CALL";
71
76
  export declare const MIDSCENE_INSIGHT_MODEL_NAME = "MIDSCENE_INSIGHT_MODEL_NAME";
72
77
  export declare const MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY = "MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY";
73
78
  export declare const MIDSCENE_INSIGHT_MODEL_HTTP_PROXY = "MIDSCENE_INSIGHT_MODEL_HTTP_PROXY";
@@ -83,6 +88,7 @@ export declare const MIDSCENE_INSIGHT_MODEL_FAMILY = "MIDSCENE_INSIGHT_MODEL_FAM
83
88
  export declare const MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT = "MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT";
84
89
  export declare const MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED = "MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED";
85
90
  export declare const MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET = "MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET";
91
+ export declare const MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT = "MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT";
86
92
  export declare const MIDSCENE_PLANNING_MODEL_NAME = "MIDSCENE_PLANNING_MODEL_NAME";
87
93
  export declare const MIDSCENE_PLANNING_MODEL_SOCKS_PROXY = "MIDSCENE_PLANNING_MODEL_SOCKS_PROXY";
88
94
  export declare const MIDSCENE_PLANNING_MODEL_HTTP_PROXY = "MIDSCENE_PLANNING_MODEL_HTTP_PROXY";
@@ -98,6 +104,7 @@ export declare const MIDSCENE_PLANNING_MODEL_FAMILY = "MIDSCENE_PLANNING_MODEL_F
98
104
  export declare const MIDSCENE_PLANNING_MODEL_REASONING_EFFORT = "MIDSCENE_PLANNING_MODEL_REASONING_EFFORT";
99
105
  export declare const MIDSCENE_PLANNING_MODEL_REASONING_ENABLED = "MIDSCENE_PLANNING_MODEL_REASONING_ENABLED";
100
106
  export declare const MIDSCENE_PLANNING_MODEL_REASONING_BUDGET = "MIDSCENE_PLANNING_MODEL_REASONING_BUDGET";
107
+ export declare const MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT = "MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT";
101
108
  export declare const MIDSCENE_MODEL_FAMILY = "MIDSCENE_MODEL_FAMILY";
102
109
  /**
103
110
  * env keys declared but unused
@@ -107,29 +114,29 @@ export declare const UNUSED_ENV_KEYS: string[];
107
114
  * env keys for debug or basic run
108
115
  * can not be override by overrideAIConfig
109
116
  */
110
- export declare const BASIC_ENV_KEYS: readonly ["MIDSCENE_DEBUG_MODE", "MIDSCENE_DEBUG_MODEL_PROFILE", "MIDSCENE_DEBUG_MODEL_RESPONSE", "MIDSCENE_RUN_DIR"];
117
+ export declare const BASIC_ENV_KEYS: readonly ["MIDSCENE_DEBUG_MODE", "MIDSCENE_DEBUG_MODEL_PROFILE", "MIDSCENE_DEBUG_MODEL_RESPONSE", "MIDSCENE_RUN_DIR", "MIDSCENE_RECORD_MODEL_CALL"];
111
118
  export declare const BOOLEAN_ENV_KEYS: readonly ["MIDSCENE_CACHE", "MIDSCENE_MCP_USE_PUPPETEER_MODE", "MIDSCENE_MCP_ANDROID_MODE", "MIDSCENE_LANGSMITH_DEBUG", "MIDSCENE_LANGFUSE_DEBUG", "MIDSCENE_REPORT_QUIET"];
112
119
  export declare const NUMBER_ENV_KEYS: readonly ["MIDSCENE_MODEL_MAX_TOKENS", "MIDSCENE_CACHE_MAX_FILENAME_LENGTH", "MIDSCENE_REPLANNING_CYCLE_LIMIT"];
113
- export declare const STRING_ENV_KEYS: readonly ["MIDSCENE_MODEL_MAX_TOKENS", "OPENAI_MAX_TOKENS", "MIDSCENE_ADB_PATH", "MIDSCENE_ADB_REMOTE_HOST", "MIDSCENE_ADB_REMOTE_PORT", "MIDSCENE_ANDROID_IME_STRATEGY", "MIDSCENE_IOS_DEVICE_UDID", "MIDSCENE_IOS_SIMULATOR_UDID", "MIDSCENE_REPORT_TAG_NAME", "MIDSCENE_PREFERRED_LANGUAGE", "MATCH_BY_POSITION", "MIDSCENE_MCP_CHROME_PATH", "DOCKER_CONTAINER"];
120
+ export declare const STRING_ENV_KEYS: readonly ["MIDSCENE_MODEL_MAX_TOKENS", "OPENAI_MAX_TOKENS", "MIDSCENE_ADB_PATH", "MIDSCENE_ADB_REMOTE_HOST", "MIDSCENE_ADB_REMOTE_PORT", "MIDSCENE_ANDROID_IME_STRATEGY", "MIDSCENE_IOS_DEVICE_UDID", "MIDSCENE_IOS_SIMULATOR_UDID", "MIDSCENE_REPORT_TAG_NAME", "MIDSCENE_PREFERRED_LANGUAGE", "MATCH_BY_POSITION", "MIDSCENE_CHROME_PATH", "MIDSCENE_MCP_CHROME_PATH", "DOCKER_CONTAINER"];
114
121
  /**
115
122
  * Non model related env keys, used for globally controlling the behavior of midscene
116
123
  * Can not be override by agent.modelConfig but can be override by overrideAIConfig
117
124
  * Can be access at any time
118
125
  */
119
- export declare const GLOBAL_ENV_KEYS: readonly ["MIDSCENE_CACHE", "MIDSCENE_MCP_USE_PUPPETEER_MODE", "MIDSCENE_MCP_ANDROID_MODE", "MIDSCENE_LANGSMITH_DEBUG", "MIDSCENE_LANGFUSE_DEBUG", "MIDSCENE_REPORT_QUIET", "MIDSCENE_MODEL_MAX_TOKENS", "MIDSCENE_CACHE_MAX_FILENAME_LENGTH", "MIDSCENE_REPLANNING_CYCLE_LIMIT", "MIDSCENE_MODEL_MAX_TOKENS", "OPENAI_MAX_TOKENS", "MIDSCENE_ADB_PATH", "MIDSCENE_ADB_REMOTE_HOST", "MIDSCENE_ADB_REMOTE_PORT", "MIDSCENE_ANDROID_IME_STRATEGY", "MIDSCENE_IOS_DEVICE_UDID", "MIDSCENE_IOS_SIMULATOR_UDID", "MIDSCENE_REPORT_TAG_NAME", "MIDSCENE_PREFERRED_LANGUAGE", "MATCH_BY_POSITION", "MIDSCENE_MCP_CHROME_PATH", "DOCKER_CONTAINER"];
126
+ export declare const GLOBAL_ENV_KEYS: readonly ["MIDSCENE_CACHE", "MIDSCENE_MCP_USE_PUPPETEER_MODE", "MIDSCENE_MCP_ANDROID_MODE", "MIDSCENE_LANGSMITH_DEBUG", "MIDSCENE_LANGFUSE_DEBUG", "MIDSCENE_REPORT_QUIET", "MIDSCENE_MODEL_MAX_TOKENS", "MIDSCENE_CACHE_MAX_FILENAME_LENGTH", "MIDSCENE_REPLANNING_CYCLE_LIMIT", "MIDSCENE_MODEL_MAX_TOKENS", "OPENAI_MAX_TOKENS", "MIDSCENE_ADB_PATH", "MIDSCENE_ADB_REMOTE_HOST", "MIDSCENE_ADB_REMOTE_PORT", "MIDSCENE_ANDROID_IME_STRATEGY", "MIDSCENE_IOS_DEVICE_UDID", "MIDSCENE_IOS_SIMULATOR_UDID", "MIDSCENE_REPORT_TAG_NAME", "MIDSCENE_PREFERRED_LANGUAGE", "MATCH_BY_POSITION", "MIDSCENE_CHROME_PATH", "MIDSCENE_MCP_CHROME_PATH", "DOCKER_CONTAINER"];
120
127
  /**
121
128
  * Model related eve keys, used for declare which model to use.
122
129
  * Can be override by both agent.modelConfig and overrideAIConfig
123
130
  * Can only be access after agent.constructor
124
131
  */
125
- export declare const MODEL_ENV_KEYS: readonly ["MIDSCENE_MODEL_NAME", "MIDSCENE_MODEL_INIT_CONFIG_JSON", "MIDSCENE_MODEL_EXTRA_BODY_JSON", "MIDSCENE_MODEL_API_KEY", "MIDSCENE_MODEL_BASE_URL", "MIDSCENE_MODEL_SOCKS_PROXY", "MIDSCENE_MODEL_HTTP_PROXY", "MIDSCENE_MODEL_TIMEOUT", "MIDSCENE_MODEL_TEMPERATURE", "MIDSCENE_MODEL_RETRY_COUNT", "MIDSCENE_MODEL_RETRY_INTERVAL", "MIDSCENE_MODEL_REASONING_EFFORT", "MIDSCENE_MODEL_REASONING_ENABLED", "MIDSCENE_MODEL_REASONING_BUDGET", "MIDSCENE_USE_VLM_UI_TARS", "MIDSCENE_USE_QWEN_VL", "MIDSCENE_USE_QWEN3_VL", "MIDSCENE_USE_DOUBAO_VISION", "MIDSCENE_USE_GEMINI", "MIDSCENE_USE_VL_MODEL", "OPENAI_API_KEY", "OPENAI_BASE_URL", "MIDSCENE_OPENAI_INIT_CONFIG_JSON", "MIDSCENE_OPENAI_HTTP_PROXY", "MIDSCENE_OPENAI_SOCKS_PROXY", "MIDSCENE_INSIGHT_MODEL_NAME", "MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY", "MIDSCENE_INSIGHT_MODEL_HTTP_PROXY", "MIDSCENE_INSIGHT_MODEL_BASE_URL", "MIDSCENE_INSIGHT_MODEL_API_KEY", "MIDSCENE_INSIGHT_MODEL_INIT_CONFIG_JSON", "MIDSCENE_INSIGHT_MODEL_EXTRA_BODY_JSON", "MIDSCENE_INSIGHT_MODEL_TIMEOUT", "MIDSCENE_INSIGHT_MODEL_TEMPERATURE", "MIDSCENE_INSIGHT_MODEL_RETRY_COUNT", "MIDSCENE_INSIGHT_MODEL_RETRY_INTERVAL", "MIDSCENE_INSIGHT_MODEL_FAMILY", "MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT", "MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED", "MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET", "MIDSCENE_PLANNING_MODEL_NAME", "MIDSCENE_PLANNING_MODEL_SOCKS_PROXY", "MIDSCENE_PLANNING_MODEL_HTTP_PROXY", "MIDSCENE_PLANNING_MODEL_BASE_URL", "MIDSCENE_PLANNING_MODEL_API_KEY", "MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON", "MIDSCENE_PLANNING_MODEL_EXTRA_BODY_JSON", "MIDSCENE_PLANNING_MODEL_TIMEOUT", "MIDSCENE_PLANNING_MODEL_TEMPERATURE", "MIDSCENE_PLANNING_MODEL_RETRY_COUNT", "MIDSCENE_PLANNING_MODEL_RETRY_INTERVAL", "MIDSCENE_PLANNING_MODEL_FAMILY", "MIDSCENE_PLANNING_MODEL_REASONING_EFFORT", "MIDSCENE_PLANNING_MODEL_REASONING_ENABLED", "MIDSCENE_PLANNING_MODEL_REASONING_BUDGET", "MIDSCENE_MODEL_FAMILY"];
126
- export declare const ALL_ENV_KEYS: readonly [...string[], "MIDSCENE_DEBUG_MODE", "MIDSCENE_DEBUG_MODEL_PROFILE", "MIDSCENE_DEBUG_MODEL_RESPONSE", "MIDSCENE_RUN_DIR", "MIDSCENE_CACHE", "MIDSCENE_MCP_USE_PUPPETEER_MODE", "MIDSCENE_MCP_ANDROID_MODE", "MIDSCENE_LANGSMITH_DEBUG", "MIDSCENE_LANGFUSE_DEBUG", "MIDSCENE_REPORT_QUIET", "MIDSCENE_MODEL_MAX_TOKENS", "MIDSCENE_CACHE_MAX_FILENAME_LENGTH", "MIDSCENE_REPLANNING_CYCLE_LIMIT", "MIDSCENE_MODEL_MAX_TOKENS", "OPENAI_MAX_TOKENS", "MIDSCENE_ADB_PATH", "MIDSCENE_ADB_REMOTE_HOST", "MIDSCENE_ADB_REMOTE_PORT", "MIDSCENE_ANDROID_IME_STRATEGY", "MIDSCENE_IOS_DEVICE_UDID", "MIDSCENE_IOS_SIMULATOR_UDID", "MIDSCENE_REPORT_TAG_NAME", "MIDSCENE_PREFERRED_LANGUAGE", "MATCH_BY_POSITION", "MIDSCENE_MCP_CHROME_PATH", "DOCKER_CONTAINER", "MIDSCENE_MODEL_NAME", "MIDSCENE_MODEL_INIT_CONFIG_JSON", "MIDSCENE_MODEL_EXTRA_BODY_JSON", "MIDSCENE_MODEL_API_KEY", "MIDSCENE_MODEL_BASE_URL", "MIDSCENE_MODEL_SOCKS_PROXY", "MIDSCENE_MODEL_HTTP_PROXY", "MIDSCENE_MODEL_TIMEOUT", "MIDSCENE_MODEL_TEMPERATURE", "MIDSCENE_MODEL_RETRY_COUNT", "MIDSCENE_MODEL_RETRY_INTERVAL", "MIDSCENE_MODEL_REASONING_EFFORT", "MIDSCENE_MODEL_REASONING_ENABLED", "MIDSCENE_MODEL_REASONING_BUDGET", "MIDSCENE_USE_VLM_UI_TARS", "MIDSCENE_USE_QWEN_VL", "MIDSCENE_USE_QWEN3_VL", "MIDSCENE_USE_DOUBAO_VISION", "MIDSCENE_USE_GEMINI", "MIDSCENE_USE_VL_MODEL", "OPENAI_API_KEY", "OPENAI_BASE_URL", "MIDSCENE_OPENAI_INIT_CONFIG_JSON", "MIDSCENE_OPENAI_HTTP_PROXY", "MIDSCENE_OPENAI_SOCKS_PROXY", "MIDSCENE_INSIGHT_MODEL_NAME", "MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY", "MIDSCENE_INSIGHT_MODEL_HTTP_PROXY", "MIDSCENE_INSIGHT_MODEL_BASE_URL", "MIDSCENE_INSIGHT_MODEL_API_KEY", "MIDSCENE_INSIGHT_MODEL_INIT_CONFIG_JSON", "MIDSCENE_INSIGHT_MODEL_EXTRA_BODY_JSON", "MIDSCENE_INSIGHT_MODEL_TIMEOUT", "MIDSCENE_INSIGHT_MODEL_TEMPERATURE", "MIDSCENE_INSIGHT_MODEL_RETRY_COUNT", "MIDSCENE_INSIGHT_MODEL_RETRY_INTERVAL", "MIDSCENE_INSIGHT_MODEL_FAMILY", "MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT", "MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED", "MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET", "MIDSCENE_PLANNING_MODEL_NAME", "MIDSCENE_PLANNING_MODEL_SOCKS_PROXY", "MIDSCENE_PLANNING_MODEL_HTTP_PROXY", "MIDSCENE_PLANNING_MODEL_BASE_URL", "MIDSCENE_PLANNING_MODEL_API_KEY", "MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON", "MIDSCENE_PLANNING_MODEL_EXTRA_BODY_JSON", "MIDSCENE_PLANNING_MODEL_TIMEOUT", "MIDSCENE_PLANNING_MODEL_TEMPERATURE", "MIDSCENE_PLANNING_MODEL_RETRY_COUNT", "MIDSCENE_PLANNING_MODEL_RETRY_INTERVAL", "MIDSCENE_PLANNING_MODEL_FAMILY", "MIDSCENE_PLANNING_MODEL_REASONING_EFFORT", "MIDSCENE_PLANNING_MODEL_REASONING_ENABLED", "MIDSCENE_PLANNING_MODEL_REASONING_BUDGET", "MIDSCENE_MODEL_FAMILY"];
132
+ export declare const MODEL_ENV_KEYS: readonly ["MIDSCENE_MODEL_NAME", "MIDSCENE_MODEL_INIT_CONFIG_JSON", "MIDSCENE_MODEL_EXTRA_BODY_JSON", "MIDSCENE_MODEL_API_KEY", "MIDSCENE_MODEL_BASE_URL", "MIDSCENE_MODEL_SOCKS_PROXY", "MIDSCENE_MODEL_HTTP_PROXY", "MIDSCENE_MODEL_TIMEOUT", "MIDSCENE_MODEL_TEMPERATURE", "MIDSCENE_MODEL_RETRY_COUNT", "MIDSCENE_MODEL_RETRY_INTERVAL", "MIDSCENE_MODEL_REASONING_EFFORT", "MIDSCENE_MODEL_REASONING_ENABLED", "MIDSCENE_MODEL_REASONING_BUDGET", "MIDSCENE_MODEL_RESPONSE_FORMAT", "MIDSCENE_USE_VLM_UI_TARS", "MIDSCENE_USE_QWEN_VL", "MIDSCENE_USE_QWEN3_VL", "MIDSCENE_USE_DOUBAO_VISION", "MIDSCENE_USE_GEMINI", "MIDSCENE_USE_VL_MODEL", "OPENAI_API_KEY", "OPENAI_BASE_URL", "MIDSCENE_OPENAI_INIT_CONFIG_JSON", "MIDSCENE_OPENAI_HTTP_PROXY", "MIDSCENE_OPENAI_SOCKS_PROXY", "MIDSCENE_INSIGHT_MODEL_NAME", "MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY", "MIDSCENE_INSIGHT_MODEL_HTTP_PROXY", "MIDSCENE_INSIGHT_MODEL_BASE_URL", "MIDSCENE_INSIGHT_MODEL_API_KEY", "MIDSCENE_INSIGHT_MODEL_INIT_CONFIG_JSON", "MIDSCENE_INSIGHT_MODEL_EXTRA_BODY_JSON", "MIDSCENE_INSIGHT_MODEL_TIMEOUT", "MIDSCENE_INSIGHT_MODEL_TEMPERATURE", "MIDSCENE_INSIGHT_MODEL_RETRY_COUNT", "MIDSCENE_INSIGHT_MODEL_RETRY_INTERVAL", "MIDSCENE_INSIGHT_MODEL_FAMILY", "MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT", "MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED", "MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET", "MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT", "MIDSCENE_PLANNING_MODEL_NAME", "MIDSCENE_PLANNING_MODEL_SOCKS_PROXY", "MIDSCENE_PLANNING_MODEL_HTTP_PROXY", "MIDSCENE_PLANNING_MODEL_BASE_URL", "MIDSCENE_PLANNING_MODEL_API_KEY", "MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON", "MIDSCENE_PLANNING_MODEL_EXTRA_BODY_JSON", "MIDSCENE_PLANNING_MODEL_TIMEOUT", "MIDSCENE_PLANNING_MODEL_TEMPERATURE", "MIDSCENE_PLANNING_MODEL_RETRY_COUNT", "MIDSCENE_PLANNING_MODEL_RETRY_INTERVAL", "MIDSCENE_PLANNING_MODEL_FAMILY", "MIDSCENE_PLANNING_MODEL_REASONING_EFFORT", "MIDSCENE_PLANNING_MODEL_REASONING_ENABLED", "MIDSCENE_PLANNING_MODEL_REASONING_BUDGET", "MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT", "MIDSCENE_MODEL_FAMILY"];
133
+ export declare const ALL_ENV_KEYS: readonly [...string[], "MIDSCENE_DEBUG_MODE", "MIDSCENE_DEBUG_MODEL_PROFILE", "MIDSCENE_DEBUG_MODEL_RESPONSE", "MIDSCENE_RUN_DIR", "MIDSCENE_RECORD_MODEL_CALL", "MIDSCENE_CACHE", "MIDSCENE_MCP_USE_PUPPETEER_MODE", "MIDSCENE_MCP_ANDROID_MODE", "MIDSCENE_LANGSMITH_DEBUG", "MIDSCENE_LANGFUSE_DEBUG", "MIDSCENE_REPORT_QUIET", "MIDSCENE_MODEL_MAX_TOKENS", "MIDSCENE_CACHE_MAX_FILENAME_LENGTH", "MIDSCENE_REPLANNING_CYCLE_LIMIT", "MIDSCENE_MODEL_MAX_TOKENS", "OPENAI_MAX_TOKENS", "MIDSCENE_ADB_PATH", "MIDSCENE_ADB_REMOTE_HOST", "MIDSCENE_ADB_REMOTE_PORT", "MIDSCENE_ANDROID_IME_STRATEGY", "MIDSCENE_IOS_DEVICE_UDID", "MIDSCENE_IOS_SIMULATOR_UDID", "MIDSCENE_REPORT_TAG_NAME", "MIDSCENE_PREFERRED_LANGUAGE", "MATCH_BY_POSITION", "MIDSCENE_CHROME_PATH", "MIDSCENE_MCP_CHROME_PATH", "DOCKER_CONTAINER", "MIDSCENE_MODEL_NAME", "MIDSCENE_MODEL_INIT_CONFIG_JSON", "MIDSCENE_MODEL_EXTRA_BODY_JSON", "MIDSCENE_MODEL_API_KEY", "MIDSCENE_MODEL_BASE_URL", "MIDSCENE_MODEL_SOCKS_PROXY", "MIDSCENE_MODEL_HTTP_PROXY", "MIDSCENE_MODEL_TIMEOUT", "MIDSCENE_MODEL_TEMPERATURE", "MIDSCENE_MODEL_RETRY_COUNT", "MIDSCENE_MODEL_RETRY_INTERVAL", "MIDSCENE_MODEL_REASONING_EFFORT", "MIDSCENE_MODEL_REASONING_ENABLED", "MIDSCENE_MODEL_REASONING_BUDGET", "MIDSCENE_MODEL_RESPONSE_FORMAT", "MIDSCENE_USE_VLM_UI_TARS", "MIDSCENE_USE_QWEN_VL", "MIDSCENE_USE_QWEN3_VL", "MIDSCENE_USE_DOUBAO_VISION", "MIDSCENE_USE_GEMINI", "MIDSCENE_USE_VL_MODEL", "OPENAI_API_KEY", "OPENAI_BASE_URL", "MIDSCENE_OPENAI_INIT_CONFIG_JSON", "MIDSCENE_OPENAI_HTTP_PROXY", "MIDSCENE_OPENAI_SOCKS_PROXY", "MIDSCENE_INSIGHT_MODEL_NAME", "MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY", "MIDSCENE_INSIGHT_MODEL_HTTP_PROXY", "MIDSCENE_INSIGHT_MODEL_BASE_URL", "MIDSCENE_INSIGHT_MODEL_API_KEY", "MIDSCENE_INSIGHT_MODEL_INIT_CONFIG_JSON", "MIDSCENE_INSIGHT_MODEL_EXTRA_BODY_JSON", "MIDSCENE_INSIGHT_MODEL_TIMEOUT", "MIDSCENE_INSIGHT_MODEL_TEMPERATURE", "MIDSCENE_INSIGHT_MODEL_RETRY_COUNT", "MIDSCENE_INSIGHT_MODEL_RETRY_INTERVAL", "MIDSCENE_INSIGHT_MODEL_FAMILY", "MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT", "MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED", "MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET", "MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT", "MIDSCENE_PLANNING_MODEL_NAME", "MIDSCENE_PLANNING_MODEL_SOCKS_PROXY", "MIDSCENE_PLANNING_MODEL_HTTP_PROXY", "MIDSCENE_PLANNING_MODEL_BASE_URL", "MIDSCENE_PLANNING_MODEL_API_KEY", "MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON", "MIDSCENE_PLANNING_MODEL_EXTRA_BODY_JSON", "MIDSCENE_PLANNING_MODEL_TIMEOUT", "MIDSCENE_PLANNING_MODEL_TEMPERATURE", "MIDSCENE_PLANNING_MODEL_RETRY_COUNT", "MIDSCENE_PLANNING_MODEL_RETRY_INTERVAL", "MIDSCENE_PLANNING_MODEL_FAMILY", "MIDSCENE_PLANNING_MODEL_REASONING_EFFORT", "MIDSCENE_PLANNING_MODEL_REASONING_ENABLED", "MIDSCENE_PLANNING_MODEL_REASONING_BUDGET", "MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT", "MIDSCENE_MODEL_FAMILY"];
127
134
  export type TEnvKeys = (typeof ALL_ENV_KEYS)[number];
128
135
  export type TGlobalConfig = Record<TEnvKeys, string | undefined>;
129
136
  /**
130
137
  * valid Model family types
131
138
  */
132
- export type TModelFamily = 'qwen2.5-vl' | 'qwen3-vl' | 'qwen3.5' | 'qwen3.6' | 'doubao-vision' | 'doubao-seed' | 'gemini' | 'vlm-ui-tars' | 'vlm-ui-tars-doubao' | 'vlm-ui-tars-doubao-1.5' | 'glm-v' | 'auto-glm' | 'auto-glm-multilingual' | 'gpt-5';
139
+ export type TModelFamily = 'qwen2.5-vl' | 'qwen3-vl' | 'qwen3' | 'qwen3.5' | 'qwen3.6' | 'doubao-vision' | 'doubao-seed' | 'gemini' | 'vlm-ui-tars' | 'vlm-ui-tars-doubao' | 'vlm-ui-tars-doubao-1.5' | 'glm-v' | 'auto-glm' | 'auto-glm-multilingual' | 'gpt-5' | 'deepseek' | 'kimi' | 'kimi3' | 'xiaomi-mimo';
133
140
  export declare const MODEL_FAMILY_VALUES: TModelFamily[];
134
141
  export interface IModelConfigForInsight {
135
142
  [MIDSCENE_INSIGHT_MODEL_NAME]: string;
@@ -176,6 +183,7 @@ export interface IModelConfigForDefault {
176
183
  [MIDSCENE_MODEL_REASONING_EFFORT]?: string;
177
184
  [MIDSCENE_MODEL_REASONING_ENABLED]?: string;
178
185
  [MIDSCENE_MODEL_REASONING_BUDGET]?: string;
186
+ [MIDSCENE_MODEL_RESPONSE_FORMAT]?: TModelResponseFormat;
179
187
  }
180
188
  export interface IModelConfigForDefaultLegacy {
181
189
  [MIDSCENE_MODEL_NAME]: string;
@@ -280,12 +288,13 @@ export interface IModelConfig {
280
288
  * Enable/disable reasoning for the model.
281
289
  * Passed through to model-family-specific parameters (e.g., enable_thinking for qwen, thinking.type for doubao/glm-v).
282
290
  */
283
- reasoningEnabled?: boolean;
291
+ reasoningEnabled?: TModelReasoningEnabled;
284
292
  /**
285
293
  * Reasoning token budget for the model.
286
294
  * Passed through to model-family-specific parameters (e.g., thinking_budget for qwen).
287
295
  */
288
296
  reasoningBudget?: number;
297
+ responseFormat?: TModelResponseFormat;
289
298
  /**
290
299
  * Model family - unified model configuration
291
300
  * Maps directly to model families like 'qwen2.5-vl', 'qwen3-vl', 'doubao-vision', 'doubao-seed', etc.
@@ -1,3 +1,3 @@
1
- export { imageInfoOfBase64, isValidPNGImageBuffer, isValidJPEGImageBuffer, isValidImageBuffer, validateScreenshotBuffer, type ValidateScreenshotBufferOptions, } from './info';
2
- export { resizeAndConvertImgBuffer, resizeImgBase64, zoomForGPT4o, saveBase64Image, paddingToMatchBlockByBase64, cropByRect, scaleImage, localImg2Base64, httpImg2Base64, preProcessImageUrl, parseBase64, createImgBase64ByFormat, } from './transform';
1
+ export { encodedImageInfoOfBuffer, imageInfoOfBase64, isValidPNGImageBuffer, isValidJPEGImageBuffer, isValidImageBuffer, validateScreenshotBuffer, type ValidateScreenshotBufferOptions, } from './info';
2
+ export { resizeAndConvertImgBuffer, convertImgBufferToJpeg, convertBase64ImageToJpeg, constrainBase64ImageToMaxSize, resizeBase64ImageToJpeg, resizeImgBase64, zoomForGPT4o, saveBase64Image, paddingToMatchBlockByBase64, cropByRect, scaleImage, localImg2Base64, httpImg2Base64, preProcessImageUrl, parseBase64, createImgBase64ByFormat, inferBase64ImageFormat, normalizeBase64Image, normalizeScreenshotBase64, type NormalizeScreenshotBase64Options, type ConstrainBase64ImageToMaxSizeOptions, type JpegBase64DataUrl, type ResizeBase64ImageToJpegOptions, } from './transform';
3
3
  export { processImageElementInfo, compositeElementInfoImg, annotateRects, } from './box-select';
@@ -1,6 +1,8 @@
1
+ import { Buffer } from 'node:buffer';
1
2
  import type { Size } from '../types';
2
3
  export interface ImageInfo extends Size {
3
4
  }
5
+ export declare function encodedImageInfoOfBuffer(imageBuffer: Buffer): ImageInfo;
4
6
  /**
5
7
  * Retrieves the dimensions of an image from a base64-encoded string
6
8
  *
@@ -0,0 +1,2 @@
1
+ export type PhotonModule = typeof import('@silvia-odwyer/photon');
2
+ export declare function loadPhotonModule(): Promise<PhotonModule>;
@@ -1,6 +1,6 @@
1
1
  import { Buffer } from 'node:buffer';
2
2
  import type { PhotonImage as PhotonImageType } from '@silvia-odwyer/photon-node';
3
- import type { Rect } from '../types';
3
+ import type { Rect, Size } from '../types';
4
4
  /**
5
5
  * Saves a Base64-encoded image to a file
6
6
  *
@@ -26,7 +26,27 @@ export declare function resizeAndConvertImgBuffer(inputFormat: string, inputData
26
26
  buffer: Buffer;
27
27
  format: string;
28
28
  }>;
29
+ export declare function inferBase64ImageFormat(base64Body: string): string;
29
30
  export declare const createImgBase64ByFormat: (format: string, body: string) => string;
31
+ export interface NormalizeScreenshotBase64Options {
32
+ label?: string;
33
+ }
34
+ export declare const normalizeScreenshotBase64: (base64: string, options?: NormalizeScreenshotBase64Options) => string;
35
+ export declare const normalizeBase64Image: (base64: string) => string;
36
+ export type JpegBase64DataUrl = `data:image/jpeg;base64,${string}`;
37
+ export interface ResizeBase64ImageToJpegOptions {
38
+ sourceSize?: Size;
39
+ targetSize: Size;
40
+ jpegQuality?: number;
41
+ }
42
+ export interface ConstrainBase64ImageToMaxSizeOptions {
43
+ maxSize: number;
44
+ jpegQuality?: number;
45
+ }
46
+ export declare function convertImgBufferToJpeg(inputData: Buffer, jpegQuality?: number): Promise<Buffer>;
47
+ export declare function convertBase64ImageToJpeg(inputBase64: string, jpegQuality?: number): Promise<JpegBase64DataUrl>;
48
+ export declare function resizeBase64ImageToJpeg(inputBase64: string, options: ResizeBase64ImageToJpegOptions): Promise<JpegBase64DataUrl>;
49
+ export declare function constrainBase64ImageToMaxSize(inputBase64: string, options: ConstrainBase64ImageToMaxSizeOptions): Promise<string>;
30
50
  export declare function resizeImgBase64(inputBase64: string, newSize: {
31
51
  width: number;
32
52
  height: number;
@@ -58,7 +78,7 @@ export declare function paddingToMatchBlockByBase64(imageBase64: string, blockSi
58
78
  height: number;
59
79
  imageBase64: string;
60
80
  }>;
61
- export declare function cropByRect(imageBase64: string, rect: Rect, paddingImage: boolean): Promise<{
81
+ export declare function cropByRect(imageBase64: string, rect: Rect, paddingImage?: boolean): Promise<{
62
82
  width: number;
63
83
  height: number;
64
84
  imageBase64: string;
@@ -95,6 +95,7 @@ export interface BaseAgent {
95
95
  aiAction?: (description: string, params?: Record<string, unknown>) => Promise<unknown>;
96
96
  aiWaitFor?: (assertion: string, options: Record<string, unknown>) => Promise<unknown>;
97
97
  aiAssert?: (assertion: string, msg?: string, options?: Record<string, unknown>) => Promise<unknown>;
98
+ aiQuery?: (demand: any, opt?: any) => Promise<any>;
98
99
  }
99
100
  /**
100
101
  * Base device interface for temporary device instances