@aiscene/shared 8.0.3 → 8.0.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.
Files changed (99) 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 +3 -1
  22. package/dist/es/img/info.mjs +45 -1
  23. package/dist/es/img/photon-loader.mjs +4 -0
  24. package/dist/es/recorder.mjs +249 -0
  25. package/dist/lib/agent-tools/agent-behavior-init-args.js +87 -0
  26. package/dist/lib/agent-tools/base-tools.js +197 -0
  27. package/dist/lib/agent-tools/chrome-path.js +87 -0
  28. package/dist/lib/agent-tools/cli-report-session.js +121 -0
  29. package/dist/lib/agent-tools/error-formatter.js +149 -0
  30. package/dist/lib/agent-tools/index.js +114 -0
  31. package/dist/lib/agent-tools/init-arg-utils.js +78 -0
  32. package/dist/lib/agent-tools/observation-artifact.js +42 -0
  33. package/dist/lib/agent-tools/observation-record.js +297 -0
  34. package/dist/lib/agent-tools/tool-defaults.js +97 -0
  35. package/dist/lib/agent-tools/tool-generator.js +569 -0
  36. package/dist/lib/agent-tools/types.js +40 -0
  37. package/dist/lib/agent-tools/user-prompt.js +103 -0
  38. package/dist/lib/cli/interrupt.js +156 -0
  39. package/dist/lib/cli/record-command.js +164 -0
  40. package/dist/lib/cli/screenshot-file.js +58 -0
  41. package/dist/lib/cli/verbose-ai-act.js +273 -0
  42. package/dist/lib/cli/verbose-screenshot.js +177 -0
  43. package/dist/lib/cli/verbose.js +465 -0
  44. package/dist/lib/env/parse-model-config.js +1 -1
  45. package/dist/lib/env/types.js +5 -0
  46. package/dist/lib/img/info.js +48 -1
  47. package/dist/lib/img/photon-loader.js +38 -0
  48. package/dist/lib/recorder.js +307 -0
  49. package/dist/types/agent-tools/agent-behavior-init-args.d.ts +17 -0
  50. package/dist/types/agent-tools/base-tools.d.ts +158 -0
  51. package/dist/types/agent-tools/chrome-path.d.ts +2 -0
  52. package/dist/types/agent-tools/cli-report-session.d.ts +12 -0
  53. package/dist/types/agent-tools/error-formatter.d.ts +30 -0
  54. package/dist/types/agent-tools/index.d.ts +9 -0
  55. package/dist/types/agent-tools/init-arg-utils.d.ts +13 -0
  56. package/dist/types/agent-tools/observation-artifact.d.ts +10 -0
  57. package/dist/types/agent-tools/observation-record.d.ts +38 -0
  58. package/dist/types/agent-tools/tool-defaults.d.ts +63 -0
  59. package/dist/types/agent-tools/tool-generator.d.ts +13 -0
  60. package/dist/types/agent-tools/types.d.ts +213 -0
  61. package/dist/types/agent-tools/user-prompt.d.ts +13 -0
  62. package/dist/types/cli/interrupt.d.ts +49 -0
  63. package/dist/types/cli/record-command.d.ts +3 -0
  64. package/dist/types/cli/screenshot-file.d.ts +10 -0
  65. package/dist/types/cli/verbose-ai-act.d.ts +44 -0
  66. package/dist/types/cli/verbose-screenshot.d.ts +10 -0
  67. package/dist/types/cli/verbose.d.ts +40 -0
  68. package/dist/types/env/types.d.ts +4 -3
  69. package/dist/types/img/info.d.ts +2 -0
  70. package/dist/types/img/photon-loader.d.ts +2 -0
  71. package/dist/types/mcp/types.d.ts +1 -0
  72. package/dist/types/recorder.d.ts +113 -0
  73. package/package.json +1 -1
  74. package/src/agent-tools/agent-behavior-init-args.ts +109 -0
  75. package/src/agent-tools/base-tools.ts +399 -0
  76. package/src/agent-tools/chrome-path.ts +74 -0
  77. package/src/agent-tools/cli-report-session.ts +130 -0
  78. package/src/agent-tools/error-formatter.ts +177 -0
  79. package/src/agent-tools/index.ts +9 -0
  80. package/src/agent-tools/init-arg-utils.ts +105 -0
  81. package/src/agent-tools/observation-artifact.ts +29 -0
  82. package/src/agent-tools/observation-record.ts +331 -0
  83. package/src/agent-tools/tool-defaults.ts +119 -0
  84. package/src/agent-tools/tool-generator.ts +866 -0
  85. package/src/agent-tools/types.ts +250 -0
  86. package/src/agent-tools/user-prompt.ts +102 -0
  87. package/src/cli/interrupt.ts +207 -0
  88. package/src/cli/record-command.ts +177 -0
  89. package/src/cli/screenshot-file.ts +61 -0
  90. package/src/cli/verbose-ai-act.ts +387 -0
  91. package/src/cli/verbose-screenshot.ts +269 -0
  92. package/src/cli/verbose.ts +753 -0
  93. package/src/env/types.ts +2 -0
  94. package/src/img/index.ts +12 -0
  95. package/src/img/info.ts +61 -0
  96. package/src/img/photon-loader.ts +5 -0
  97. package/src/img/transform.ts +261 -2
  98. package/src/mcp/types.ts +2 -0
  99. 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";
@@ -110,20 +111,20 @@ export declare const UNUSED_ENV_KEYS: string[];
110
111
  export declare const BASIC_ENV_KEYS: readonly ["MIDSCENE_DEBUG_MODE", "MIDSCENE_DEBUG_MODEL_PROFILE", "MIDSCENE_DEBUG_MODEL_RESPONSE", "MIDSCENE_RUN_DIR"];
111
112
  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
113
  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"];
114
+ 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
115
  /**
115
116
  * Non model related env keys, used for globally controlling the behavior of midscene
116
117
  * Can not be override by agent.modelConfig but can be override by overrideAIConfig
117
118
  * Can be access at any time
118
119
  */
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"];
120
+ 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
121
  /**
121
122
  * Model related eve keys, used for declare which model to use.
122
123
  * Can be override by both agent.modelConfig and overrideAIConfig
123
124
  * Can only be access after agent.constructor
124
125
  */
125
126
  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"];
127
+ 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_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_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"];
127
128
  export type TEnvKeys = (typeof ALL_ENV_KEYS)[number];
128
129
  export type TGlobalConfig = Record<TEnvKeys, string | undefined>;
129
130
  /**
@@ -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>;
@@ -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
@@ -0,0 +1,113 @@
1
+ export type MidsceneRecorderEventType = 'click' | 'drag' | 'scroll' | 'input' | 'navigation' | 'setViewport' | 'keydown';
2
+ export type MidsceneRecorderSourceKind = 'studio-preview' | 'unsupported' | (string & {});
3
+ export type MidsceneRecorderPlatformId = 'web' | 'android' | 'ios' | 'computer' | 'harmony' | (string & {});
4
+ export interface MidsceneRecorderElementRect {
5
+ left?: number;
6
+ top?: number;
7
+ width?: number;
8
+ height?: number;
9
+ x?: number;
10
+ y?: number;
11
+ }
12
+ export interface MidsceneRecorderPageInfo {
13
+ width: number;
14
+ height: number;
15
+ }
16
+ /**
17
+ * A screenshot stored outside the recording event payload.
18
+ *
19
+ * Recorder events are persisted in the Studio renderer. Keeping full data
20
+ * URLs there makes long recordings retain every screenshot in the renderer
21
+ * heap, so screenshot bytes live in the Playground run directory instead.
22
+ */
23
+ export interface MidsceneRecorderScreenshotAssetRef {
24
+ id: string;
25
+ mimeType: string;
26
+ bytes: number;
27
+ }
28
+ export interface MidsceneRecorderEvent {
29
+ type: MidsceneRecorderEventType;
30
+ source?: MidsceneRecorderSourceKind;
31
+ actionType?: string;
32
+ rawPayload?: Record<string, unknown>;
33
+ url?: string;
34
+ title?: string;
35
+ value?: string;
36
+ elementRect?: MidsceneRecorderElementRect;
37
+ pageInfo: MidsceneRecorderPageInfo;
38
+ screenshotBefore?: string;
39
+ screenshotAfter?: string;
40
+ /** The single screenshot retained for AI description and Markdown export. */
41
+ screenshotAsset?: MidsceneRecorderScreenshotAssetRef;
42
+ semantic?: MidsceneRecorderSemantic;
43
+ elementDescription?: string;
44
+ descriptionLoading?: boolean;
45
+ screenshotWithBox?: string;
46
+ timestamp: number;
47
+ hashId: string;
48
+ mergedHashIds?: string[];
49
+ }
50
+ export type MidsceneRecorderSemanticSource = 'aiDescribe' | 'recorderAI' | 'heuristic';
51
+ export type MidsceneRecorderSemanticStatus = 'pending' | 'ready' | 'failed';
52
+ export type MidsceneRecorderSemanticConfidence = 'high' | 'medium' | 'low';
53
+ export interface MidsceneRecorderSemanticAiDescribe {
54
+ verifyPrompt: boolean;
55
+ verifyPassed?: boolean;
56
+ deepLocate?: boolean;
57
+ centerDistance?: number;
58
+ expectedCenter?: [number, number];
59
+ actualCenter?: [number, number];
60
+ annotatedScreenshotPath?: string;
61
+ }
62
+ export interface MidsceneRecorderSemantic {
63
+ source: MidsceneRecorderSemanticSource;
64
+ status: MidsceneRecorderSemanticStatus;
65
+ elementDescription?: string;
66
+ replayInstruction?: string;
67
+ actionSummary?: string;
68
+ confidence?: MidsceneRecorderSemanticConfidence;
69
+ error?: string;
70
+ aiDescribe?: MidsceneRecorderSemanticAiDescribe;
71
+ fallbackFrom?: MidsceneRecorderSemantic;
72
+ }
73
+ export interface MidsceneRecorderSemanticAction {
74
+ type: MidsceneRecorderEventType;
75
+ actionType?: string;
76
+ value?: string;
77
+ url?: string;
78
+ scrollDestinationDescription?: string;
79
+ }
80
+ export interface MidsceneRecorderTarget {
81
+ platformId: MidsceneRecorderPlatformId;
82
+ deviceId?: string;
83
+ label?: string;
84
+ values: Record<string, string | number | boolean>;
85
+ }
86
+ export interface MidsceneRecorderGeneratedCode {
87
+ markdown?: string;
88
+ yaml?: string;
89
+ playwright?: string;
90
+ updatedAt?: number;
91
+ }
92
+ export interface MidsceneRecorderMarkdownScreenshotAsset {
93
+ eventIndex: number;
94
+ eventHashId: string;
95
+ eventType: MidsceneRecorderEventType;
96
+ relativePath: string;
97
+ dataUrl: string;
98
+ base64Data: string;
99
+ mimeType: string;
100
+ }
101
+ export interface MidsceneRecorderMarkdownScreenshotOptions {
102
+ baseDir?: string;
103
+ maxScreenshots?: number;
104
+ }
105
+ export declare const DEFAULT_MIDSCENE_RECORDER_MARKDOWN_MAX_SCREENSHOTS = 20;
106
+ export declare function getMidsceneRecorderSemantic(event: Pick<MidsceneRecorderEvent, 'semantic'>): MidsceneRecorderSemantic | undefined;
107
+ export declare function buildMidsceneRecorderReplayInstruction(event: MidsceneRecorderSemanticAction, elementDescription: string): string;
108
+ export declare function buildMidsceneRecorderActionSummary(event: MidsceneRecorderSemanticAction, elementDescription: string): string;
109
+ export declare function getMidsceneRecorderEventDescription(event: MidsceneRecorderEvent): string;
110
+ export declare function getMidsceneRecorderScreenshotsForLLM(events: MidsceneRecorderEvent[], maxScreenshots?: number): string[];
111
+ export declare function sanitizeMidsceneRecorderFileName(value: string): string;
112
+ export declare function createMidsceneRecorderMarkdownScreenshotAssets(events: MidsceneRecorderEvent[], options?: MidsceneRecorderMarkdownScreenshotOptions): MidsceneRecorderMarkdownScreenshotAsset[];
113
+ export declare function stringifyMidsceneRecorderTargetBlock(target: MidsceneRecorderTarget): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiscene/shared",
3
- "version": "8.0.3",
3
+ "version": "8.0.4",
4
4
  "repository": "https://github.com/web-infra-dev/midscene",
5
5
  "homepage": "https://midscenejs.com/",
6
6
  "types": "./dist/types/index.d.ts",