@midscene/core 1.17.6 → 1.17.8-beta-20261106101231.0

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 (77) hide show
  1. package/dist/es/agent/agent-report-manager.mjs +1 -1
  2. package/dist/es/agent/agent-report-manager.mjs.map +1 -1
  3. package/dist/es/agent/test-runner-nodes.mjs +1 -1
  4. package/dist/es/agent/test-runner-nodes.mjs.map +1 -1
  5. package/dist/es/agent/utils.mjs +1 -1
  6. package/dist/es/ai-model/model-adapter/locate-prompt-order.mjs +80 -0
  7. package/dist/es/ai-model/model-adapter/locate-prompt-order.mjs.map +1 -0
  8. package/dist/es/ai-model/model-adapter/locate.mjs +2 -1
  9. package/dist/es/ai-model/model-adapter/locate.mjs.map +1 -1
  10. package/dist/es/ai-model/workflows/grounding/locate.mjs +1 -1
  11. package/dist/es/ai-model/workflows/grounding/locate.mjs.map +1 -1
  12. package/dist/es/ai-model/workflows/grounding/section-locate.mjs +1 -1
  13. package/dist/es/ai-model/workflows/grounding/section-locate.mjs.map +1 -1
  14. package/dist/es/ai-model/workflows/grounding/utils.mjs +8 -26
  15. package/dist/es/ai-model/workflows/grounding/utils.mjs.map +1 -1
  16. package/dist/es/dump/report-image-export.mjs +58 -0
  17. package/dist/es/dump/report-image-export.mjs.map +1 -0
  18. package/dist/es/dump/screenshot-store.mjs +5 -0
  19. package/dist/es/dump/screenshot-store.mjs.map +1 -1
  20. package/dist/es/report-cli.mjs +13 -29
  21. package/dist/es/report-cli.mjs.map +1 -1
  22. package/dist/es/report-generator.mjs +22 -8
  23. package/dist/es/report-generator.mjs.map +1 -1
  24. package/dist/es/report-html-template.mjs +1 -1
  25. package/dist/es/report-markdown.mjs +50 -53
  26. package/dist/es/report-markdown.mjs.map +1 -1
  27. package/dist/es/report.mjs +8 -24
  28. package/dist/es/report.mjs.map +1 -1
  29. package/dist/es/utils.mjs +1 -1
  30. package/dist/lib/agent/agent-report-manager.js +1 -1
  31. package/dist/lib/agent/agent-report-manager.js.map +1 -1
  32. package/dist/lib/agent/test-runner-nodes.js +1 -1
  33. package/dist/lib/agent/test-runner-nodes.js.map +1 -1
  34. package/dist/lib/agent/utils.js +1 -1
  35. package/dist/lib/ai-model/model-adapter/locate-prompt-order.js +117 -0
  36. package/dist/lib/ai-model/model-adapter/locate-prompt-order.js.map +1 -0
  37. package/dist/lib/ai-model/model-adapter/locate.js +2 -1
  38. package/dist/lib/ai-model/model-adapter/locate.js.map +1 -1
  39. package/dist/lib/ai-model/workflows/grounding/locate.js +1 -1
  40. package/dist/lib/ai-model/workflows/grounding/locate.js.map +1 -1
  41. package/dist/lib/ai-model/workflows/grounding/section-locate.js +1 -1
  42. package/dist/lib/ai-model/workflows/grounding/section-locate.js.map +1 -1
  43. package/dist/lib/ai-model/workflows/grounding/utils.js +8 -26
  44. package/dist/lib/ai-model/workflows/grounding/utils.js.map +1 -1
  45. package/dist/lib/dump/report-image-export.js +92 -0
  46. package/dist/lib/dump/report-image-export.js.map +1 -0
  47. package/dist/lib/dump/screenshot-store.js +5 -0
  48. package/dist/lib/dump/screenshot-store.js.map +1 -1
  49. package/dist/lib/report-cli.js +12 -28
  50. package/dist/lib/report-cli.js.map +1 -1
  51. package/dist/lib/report-generator.js +22 -8
  52. package/dist/lib/report-generator.js.map +1 -1
  53. package/dist/lib/report-html-template.js +1 -1
  54. package/dist/lib/report-markdown.js +50 -53
  55. package/dist/lib/report-markdown.js.map +1 -1
  56. package/dist/lib/report.js +6 -22
  57. package/dist/lib/report.js.map +1 -1
  58. package/dist/lib/utils.js +1 -1
  59. package/dist/types/agent/test-runner-nodes.d.ts.map +1 -1
  60. package/dist/types/ai-model/model-adapter/locate-prompt-order.d.ts +24 -0
  61. package/dist/types/ai-model/model-adapter/locate-prompt-order.d.ts.map +1 -0
  62. package/dist/types/ai-model/model-adapter/locate.d.ts.map +1 -1
  63. package/dist/types/ai-model/model-adapter/types.d.ts +9 -3
  64. package/dist/types/ai-model/model-adapter/types.d.ts.map +1 -1
  65. package/dist/types/ai-model/workflows/grounding/utils.d.ts +4 -9
  66. package/dist/types/ai-model/workflows/grounding/utils.d.ts.map +1 -1
  67. package/dist/types/dump/report-image-export.d.ts +12 -0
  68. package/dist/types/dump/report-image-export.d.ts.map +1 -0
  69. package/dist/types/dump/screenshot-store.d.ts +2 -0
  70. package/dist/types/dump/screenshot-store.d.ts.map +1 -1
  71. package/dist/types/report-cli.d.ts.map +1 -1
  72. package/dist/types/report-generator.d.ts +4 -2
  73. package/dist/types/report-generator.d.ts.map +1 -1
  74. package/dist/types/report-markdown.d.ts +4 -2
  75. package/dist/types/report-markdown.d.ts.map +1 -1
  76. package/dist/types/report.d.ts.map +1 -1
  77. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"agent/test-runner-nodes.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/agent/test-runner-nodes.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { AGENT_AI_CONTEXT_KEYS } from '@midscene/shared/agent-tools/agent-context';\nimport { z } from 'zod/v4';\nimport type { TUserPrompt } from '../common';\nimport { inputStrategies } from '../device/input-strategy';\nimport { NodeExecutionError } from '../test-runner/errors';\nimport type { LocateOption, ScrollParam } from '../yaml';\nimport { buildDetailedLocateParam } from '../yaml/utils';\nimport type { Agent } from './agent';\n\nexport interface AgentTestRunnerNodeResult<TData = unknown> {\n summary?: string;\n data?: TData;\n}\n\nexport interface AgentTestRunnerNodeExecutionContext {\n signal: AbortSignal;\n}\n\n/** Agent-owned Node description consumed by Test Runner adapters. */\nexport interface AgentTestRunnerNodeDefinition<\n TInput extends Record<string, unknown> = Record<string, unknown>,\n TData = unknown,\n> {\n name: string;\n title?: string;\n description?: string;\n /** Node input field populated by YAML string shorthand; omit to disable. */\n stringInputKey?: string | false;\n inputSchema: z.ZodObject;\n execute(\n agent: unknown,\n input: TInput,\n context: AgentTestRunnerNodeExecutionContext,\n ):\n | Promise<AgentTestRunnerNodeResult<TData> | undefined>\n | AgentTestRunnerNodeResult<TData>\n | undefined;\n}\n\n/** Static capability implemented by Agent classes that expose Runner Nodes. */\nexport interface AgentTestRunnerNodeProvider {\n getTestRunnerNodeDefinitions(): readonly AgentTestRunnerNodeDefinition[];\n}\n\ntype AnyAgentMethod = (...args: any[]) => unknown;\ntype AgentMethodName<TAgent extends object> = {\n [TKey in keyof TAgent]-?: TAgent[TKey] extends AnyAgentMethod ? TKey : never;\n}[keyof TAgent] &\n string;\ntype AgentMethod<\n TAgent extends object,\n TMethod extends AgentMethodName<TAgent>,\n> = Extract<TAgent[TMethod], AnyAgentMethod>;\n\nexport interface DefineAgentTestRunnerNodeOptions<\n TAgent extends object,\n TMethod extends AgentMethodName<TAgent>,\n TSchema extends z.ZodObject,\n TData = unknown,\n> {\n method: TMethod;\n name?: string;\n title?: string;\n description?: string;\n stringInputKey?: (keyof z.output<TSchema> & string) | false;\n inputSchema: TSchema;\n toArgs(\n input: z.output<TSchema>,\n context: AgentTestRunnerNodeExecutionContext,\n ): Parameters<AgentMethod<TAgent, TMethod>>;\n toResult?(\n result: Awaited<ReturnType<AgentMethod<TAgent, TMethod>>>,\n input: z.output<TSchema>,\n ): AgentTestRunnerNodeResult<TData> | undefined;\n}\n\n/** Create a Node factory whose adapters are checked against an Agent API. */\nexport const createAgentTestRunnerNodeDefinition =\n <TAgent extends object>(agentLabel = 'an Agent') =>\n <\n TMethod extends AgentMethodName<TAgent>,\n TSchema extends z.ZodObject,\n TData = unknown,\n >(\n definition: DefineAgentTestRunnerNodeOptions<\n TAgent,\n TMethod,\n TSchema,\n TData\n >,\n ): AgentTestRunnerNodeDefinition => ({\n name: definition.name ?? definition.method,\n ...(definition.title === undefined ? {} : { title: definition.title }),\n ...(definition.description === undefined\n ? {}\n : { description: definition.description }),\n ...(definition.stringInputKey === undefined\n ? {}\n : { stringInputKey: definition.stringInputKey }),\n inputSchema: definition.inputSchema,\n async execute(agent, input, context) {\n if (\n typeof agent !== 'object' ||\n agent === null ||\n typeof (agent as Record<string, unknown>)[definition.method] !==\n 'function'\n ) {\n throw new TypeError(\n `getAgent() must return ${agentLabel} with ${definition.method}().`,\n );\n }\n\n const typedAgent = agent as TAgent;\n const method = typedAgent[definition.method] as AgentMethod<\n TAgent,\n TMethod\n >;\n const typedInput = input as z.output<TSchema>;\n const result = (await method.apply(\n typedAgent,\n definition.toArgs(typedInput, context),\n )) as Awaited<ReturnType<AgentMethod<TAgent, TMethod>>>;\n return definition.toResult?.(result, typedInput);\n },\n });\n\nconst nonBlankText = (description: string) =>\n z\n .string()\n .regex(/\\S/, 'value must contain a non-whitespace character')\n .describe(description);\n\nexport const promptImageInputSchema = z.strictObject({\n name: nonBlankText('The name used to identify this reference image.'),\n url: nonBlankText('The URL, data URL, or file path of this reference image.'),\n});\n\nexport const structuredUserPromptInputSchema = z.strictObject({\n prompt: nonBlankText('The natural-language prompt.'),\n images: z.array(promptImageInputSchema).min(1).optional(),\n convertHttpImage2Base64: z\n .boolean()\n .optional()\n .describe('Whether HTTP reference images are converted to base64 first.'),\n});\n\nexport const userPromptInputSchema = z.union([\n nonBlankText('The natural-language prompt.'),\n structuredUserPromptInputSchema,\n]);\n\nexport const aiActOptionsInputSchema = z.strictObject({\n effort: z\n .enum(['fast', 'balance', 'deepThink'])\n .optional()\n .describe('Action planning effort: fast, balanced, or deeper reasoning.'),\n cacheable: z\n .boolean()\n .optional()\n .describe('Whether this action may use the Midscene cache.'),\n fileChooserAccept: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Accepted file types for a file chooser.'),\n fileChooserAllowedDir: z\n .string()\n .optional()\n .describe('Directory allowed for prompt-driven file uploads.'),\n deepThink: z\n .union([z.literal('unset'), z.boolean()])\n .optional()\n .describe('Whether to enable deep thinking for this action.'),\n deepLocate: z\n .boolean()\n .optional()\n .describe('Whether to use deep element location.'),\n context: z\n .string()\n .optional()\n .describe(\n 'Additional facts, rules, constraints, or output requirements for this AI call. Overrides inherited aiContexts; an empty string disables inherited user context.',\n ),\n});\n\nexport const setAIContextInputSchema = z.strictObject({\n target: z\n .enum(AGENT_AI_CONTEXT_KEYS)\n .describe(\n 'The AI API to configure, e.g. aiAct or aiAssert. Use default as the shared fallback for all AI APIs when neither the call nor the API has its own context.',\n ),\n context: z\n .string()\n .optional()\n .describe(\n 'Agent-level guidance. Omit to remove the selected context; an empty string disables inherited context.',\n ),\n});\n\nexport const aiActInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n options: aiActOptionsInputSchema.optional(),\n});\n\nexport const insightOptionsInputSchema = z.strictObject({\n domIncluded: z\n .union([z.boolean(), z.literal('visible-only')])\n .optional()\n .describe('How DOM information is included.'),\n screenshotIncluded: z\n .boolean()\n .optional()\n .describe('Whether the request includes a screenshot.'),\n context: z\n .string()\n .optional()\n .describe(\n 'Additional facts, rules, constraints, or output requirements for this AI call. Overrides inherited aiContexts; an empty string disables inherited user context.',\n ),\n});\n\nexport const aiAssertOptionsInputSchema = insightOptionsInputSchema.extend({\n keepRawResponse: z\n .boolean()\n .optional()\n .describe('Whether the Agent returns the structured assertion result.'),\n});\n\nexport const aiAssertInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n message: z.string().optional().describe('The assertion failure message.'),\n options: aiAssertOptionsInputSchema.optional(),\n});\n\nexport const locateOptionsInputSchema = z.strictObject({\n context: z\n .string()\n .optional()\n .describe(\n 'Additional facts, rules, constraints, or output requirements for this AI call. Overrides inherited aiContexts; an empty string disables inherited user context.',\n ),\n deepLocate: z\n .boolean()\n .optional()\n .describe('Whether to use deep element location.'),\n deepThink: z\n .boolean()\n .optional()\n .describe('Deprecated alias for deepLocate.'),\n cacheable: z\n .boolean()\n .optional()\n .describe('Whether this location may use the Midscene cache.'),\n xpath: z.string().optional().describe('A web XPath location hint.'),\n fileChooserAccept: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Files accepted when tapping opens a file chooser.'),\n});\n\nexport const aiTapInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n options: locateOptionsInputSchema.optional(),\n});\n\nexport const aiInputInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n value: z.union([z.string(), z.number()]),\n options: locateOptionsInputSchema\n .extend({\n mode: z.enum(['replace', 'clear', 'typeOnly', 'append']).optional(),\n autoDismissKeyboard: z.boolean().optional(),\n keyboardTypeDelay: z.number().nonnegative().optional(),\n inputStrategy: z.enum(inputStrategies).optional(),\n })\n .optional(),\n});\n\nexport const aiKeyboardPressInputSchema = z.strictObject({\n prompt: userPromptInputSchema.optional(),\n keyName: nonBlankText('The key or key combination to press.'),\n options: locateOptionsInputSchema.optional(),\n});\n\nexport const aiScrollInputSchema = z.strictObject({\n prompt: userPromptInputSchema.optional(),\n options: locateOptionsInputSchema\n .extend({\n direction: z.enum(['down', 'up', 'right', 'left']).optional(),\n scrollType: z\n .enum([\n 'singleAction',\n 'scrollToBottom',\n 'scrollToTop',\n 'scrollToRight',\n 'scrollToLeft',\n 'once',\n 'untilBottom',\n 'untilTop',\n 'untilRight',\n 'untilLeft',\n ])\n .optional(),\n distance: z.number().nullable().optional(),\n })\n .optional(),\n});\n\nexport const aiPinchInputSchema = z.strictObject({\n prompt: userPromptInputSchema.optional(),\n direction: z.enum(['in', 'out']),\n options: locateOptionsInputSchema\n .extend({\n distance: z.number().optional(),\n duration: z.number().nonnegative().optional(),\n })\n .optional(),\n});\n\nexport const aiLongPressInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n options: locateOptionsInputSchema\n .extend({ duration: z.number().nonnegative().optional() })\n .optional(),\n});\n\nexport const aiDragAndDropInputSchema = z.strictObject({\n from: userPromptInputSchema,\n to: userPromptInputSchema,\n options: locateOptionsInputSchema.optional(),\n});\n\nexport const aiQueryInputSchema = z.strictObject({\n prompt: z.union([\n nonBlankText('The extraction request.'),\n z.record(z.string(), z.string()),\n ]),\n options: insightOptionsInputSchema.optional(),\n});\n\nexport const aiWaitForOptionsInputSchema = insightOptionsInputSchema\n .extend({\n timeoutMs: z.number().positive().optional(),\n checkIntervalMs: z.number().positive().optional(),\n })\n .superRefine((input, context) => {\n if ((input.checkIntervalMs ?? 3000) > (input.timeoutMs ?? 15000)) {\n context.addIssue({\n code: 'custom',\n path: ['checkIntervalMs'],\n message: 'checkIntervalMs must not exceed timeoutMs',\n });\n }\n });\n\nexport const aiWaitForInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n options: aiWaitForOptionsInputSchema.optional(),\n});\n\nexport type AiWaitForNodeOptions = z.infer<typeof aiWaitForOptionsInputSchema>;\n\nexport const javascriptInputSchema = z.strictObject({\n script: nonBlankText('JavaScript to evaluate through the current interface.'),\n});\n\nexport const runGherkinScenarioInputSchema = z.strictObject({\n scenario: nonBlankText('The Gherkin scenario to execute.'),\n options: aiActOptionsInputSchema.optional(),\n});\n\nexport const actionInputSchema = z.strictObject({\n name: nonBlankText('The ActionSpace action name, for example DragAndDrop.'),\n params: z.unknown().optional(),\n});\n\nexport const insightInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n options: insightOptionsInputSchema.optional(),\n});\n\nexport const reportScreenshotInputSchema = z.strictObject({\n base64: z.string().min(1).describe('A base64-encoded screenshot.'),\n description: z.string().optional().describe('What the screenshot shows.'),\n});\n\nexport const recordToReportOptionsInputSchema = z\n .strictObject({\n content: z.string().optional().describe('The report text content.'),\n screenshotBase64: z\n .string()\n .optional()\n .describe('One base64-encoded screenshot.'),\n screenshots: z\n .array(reportScreenshotInputSchema)\n .min(1)\n .optional()\n .describe('Screenshots attached to the report section.'),\n })\n .superRefine((input, context) => {\n if (\n input.screenshotBase64 !== undefined &&\n input.screenshots !== undefined\n ) {\n context.addIssue({\n code: 'custom',\n message: 'screenshotBase64 and screenshots are mutually exclusive',\n });\n }\n });\n\nexport const recordToReportInputSchema = z.strictObject({\n title: z.string().optional().describe('The report section title.'),\n options: recordToReportOptionsInputSchema.optional(),\n});\n\nexport type UserPromptNodeInput = z.infer<typeof userPromptInputSchema>;\nexport type SetAIContextNodeInput = z.infer<typeof setAIContextInputSchema>;\nexport type AiActNodeOptions = z.infer<typeof aiActOptionsInputSchema>;\nexport type AiActNodeInput = z.infer<typeof aiActInputSchema>;\nexport type AiAssertNodeOptions = z.infer<typeof aiAssertOptionsInputSchema>;\nexport type AiAssertNodeInput = z.infer<typeof aiAssertInputSchema>;\nexport type AiTapNodeOptions = z.infer<typeof locateOptionsInputSchema>;\nexport type AiTapNodeInput = z.infer<typeof aiTapInputSchema>;\nexport type AiInputNodeInput = z.infer<typeof aiInputInputSchema>;\nexport type AiKeyboardPressNodeInput = z.infer<\n typeof aiKeyboardPressInputSchema\n>;\nexport type AiScrollNodeInput = z.infer<typeof aiScrollInputSchema>;\nexport type AiPinchNodeInput = z.infer<typeof aiPinchInputSchema>;\nexport type AiLongPressNodeInput = z.infer<typeof aiLongPressInputSchema>;\nexport type AiDragAndDropNodeInput = z.infer<typeof aiDragAndDropInputSchema>;\nexport type AiQueryNodeInput = z.infer<typeof aiQueryInputSchema>;\nexport type AiWaitForNodeInput = z.infer<typeof aiWaitForInputSchema>;\nexport type JavascriptNodeInput = z.infer<typeof javascriptInputSchema>;\nexport type RunGherkinScenarioNodeInput = z.infer<\n typeof runGherkinScenarioInputSchema\n>;\nexport type ActionNodeInput = z.infer<typeof actionInputSchema>;\nexport type InsightNodeOptions = z.infer<typeof insightOptionsInputSchema>;\nexport type InsightNodeInput = z.infer<typeof insightInputSchema>;\nexport type RecordToReportNodeOptions = z.infer<\n typeof recordToReportOptionsInputSchema\n>;\nexport type RecordToReportNodeInput = z.infer<typeof recordToReportInputSchema>;\n\nexport type CommonAgentTestRunnerApi = Pick<\n Agent,\n | 'aiAct'\n | 'aiTap'\n | 'aiAssert'\n | 'aiBoolean'\n | 'aiNumber'\n | 'aiString'\n | 'aiAsk'\n | 'recordToReport'\n>;\n\nconst defineCommonAgentNode =\n createAgentTestRunnerNodeDefinition<CommonAgentTestRunnerApi>('an Agent');\n\n// Select the current overloads without expanding the minimum API required by\n// existing getAgent() providers. Each Node checks its own method at execution.\ntype AgentActionNodeApi = Pick<\n Agent,\n | 'sleep'\n | 'setAIContext'\n | 'aiHover'\n | 'aiDoubleClick'\n | 'aiRightClick'\n | 'aiMiddleClick'\n | 'aiLongPress'\n | 'aiClearInput'\n | 'aiPinch'\n | 'aiLocate'\n | 'aiQuery'\n | 'aiWaitFor'\n | 'evaluateJavaScript'\n | 'runGherkinScenario'\n | 'callActionInActionSpace'\n> & {\n aiInput(\n prompt: TUserPrompt,\n options: NonNullable<Parameters<Agent['aiInput']>[2]> & {\n value: string | number;\n },\n ): Promise<void>;\n aiKeyboardPress(\n prompt: TUserPrompt | undefined,\n options: LocateOption & { keyName: string },\n ): Promise<void>;\n aiScroll(\n prompt: TUserPrompt | undefined,\n options: LocateOption & ScrollParam,\n ): Promise<void>;\n};\n\nconst defineAgentActionNode =\n createAgentTestRunnerNodeDefinition<AgentActionNodeApi>('an Agent');\n\nconst promptText = (prompt: UserPromptNodeInput): string =>\n typeof prompt === 'string' ? prompt : prompt.prompt;\n\nconst valueResult = (\n value: unknown,\n): AgentTestRunnerNodeResult | undefined => ({ data: value });\n\nconst aiActNode = defineCommonAgentNode({\n method: 'aiAct',\n description: 'Perform a natural-language task with a Midscene UI Agent.',\n stringInputKey: 'prompt',\n inputSchema: aiActInputSchema,\n toArgs(input, context) {\n return [\n input.prompt,\n {\n ...input.options,\n abortSignal: context.signal,\n },\n ];\n },\n toResult(output) {\n return output === undefined ? undefined : { summary: output };\n },\n});\n\nconst aiTapNode = defineCommonAgentNode({\n method: 'aiTap',\n description: 'Locate and tap an element with a Midscene UI Agent.',\n stringInputKey: 'prompt',\n inputSchema: aiTapInputSchema,\n toArgs(input) {\n return [input.prompt, input.options];\n },\n toResult(_output, input) {\n return { summary: `Tapped: ${promptText(input.prompt)}` };\n },\n});\n\nconst aiAssertNode = defineCommonAgentNode({\n method: 'aiAssert',\n description: 'Assert a natural-language condition with a Midscene UI Agent.',\n stringInputKey: 'prompt',\n inputSchema: aiAssertInputSchema,\n toArgs(input, context) {\n return [\n input.prompt,\n input.message,\n {\n keepRawResponse: true,\n ...input.options,\n abortSignal: context.signal,\n },\n ];\n },\n toResult(output, input) {\n const result = {\n summary: `Assertion ${output?.pass === false ? 'failed' : 'passed'}: ${promptText(input.prompt)}`,\n ...(output === undefined\n ? {}\n : {\n data: {\n pass: output.pass,\n ...(output.thought === undefined\n ? {}\n : { thought: output.thought }),\n ...(output.message === undefined\n ? {}\n : { message: output.message }),\n },\n }),\n };\n if (output?.pass === false)\n throw new NodeExecutionError(\n 'aiAssert',\n new Error(\n output.message ||\n input.message ||\n output.thought ||\n `Assertion failed: ${promptText(input.prompt)}`,\n ),\n result,\n );\n return result;\n },\n});\n\nconst locateActionNode = (\n method:\n | 'aiHover'\n | 'aiDoubleClick'\n | 'aiRightClick'\n | 'aiMiddleClick'\n | 'aiClearInput',\n) =>\n defineAgentActionNode({\n method,\n description: {\n aiHover: 'Locate and hover over an element with a Midscene UI Agent.',\n aiDoubleClick:\n 'Locate and double-click an element with a Midscene UI Agent.',\n aiMiddleClick:\n 'Locate and middle-click an element with a Midscene UI Agent.',\n aiRightClick:\n 'Locate and right-click an element with a Midscene UI Agent.',\n aiClearInput:\n 'Locate an input element and clear its value with a Midscene UI Agent.',\n }[method],\n stringInputKey: 'prompt',\n inputSchema: aiTapInputSchema,\n toArgs: (input) => [input.prompt, input.options],\n toResult: (_output, input) => ({\n summary: `${method}: ${promptText(input.prompt)}`,\n }),\n });\n\nconst additionalAgentNodes: readonly AgentTestRunnerNodeDefinition[] = [\n defineAgentActionNode({\n method: 'setAIContext',\n description:\n 'Set or remove Agent-level AI guidance for subsequent calls on the same Agent.',\n inputSchema: setAIContextInputSchema,\n toArgs: (input) => [input.target, input.context],\n }),\n locateActionNode('aiHover'),\n locateActionNode('aiDoubleClick'),\n locateActionNode('aiRightClick'),\n locateActionNode('aiMiddleClick'),\n locateActionNode('aiClearInput'),\n defineAgentActionNode({\n method: 'aiInput',\n description:\n 'Locate an input element and enter a value with a Midscene UI Agent.',\n inputSchema: aiInputInputSchema,\n toArgs: (input) => [input.prompt, { ...input.options, value: input.value }],\n }),\n defineAgentActionNode({\n method: 'aiKeyboardPress',\n description:\n 'Press a key or key combination, optionally targeting a located element.',\n stringInputKey: 'keyName',\n inputSchema: aiKeyboardPressInputSchema,\n toArgs: (input) => [\n input.prompt,\n { ...input.options, keyName: input.keyName },\n ],\n }),\n defineAgentActionNode({\n method: 'aiScroll',\n description:\n 'Scroll the page or a located region with a Midscene UI Agent.',\n stringInputKey: 'prompt',\n inputSchema: aiScrollInputSchema,\n toArgs: (input) => [input.prompt, { ...input.options }],\n }),\n defineAgentActionNode({\n method: 'aiPinch',\n description:\n 'Perform a pinch-in or pinch-out gesture with a Midscene UI Agent.',\n inputSchema: aiPinchInputSchema,\n toArgs: (input) => [\n input.prompt,\n { ...input.options, direction: input.direction },\n ],\n }),\n defineAgentActionNode({\n method: 'aiLongPress',\n description: 'Locate and long-press an element with a Midscene UI Agent.',\n stringInputKey: 'prompt',\n inputSchema: aiLongPressInputSchema,\n toArgs: (input) => [input.prompt, input.options],\n }),\n defineAgentActionNode({\n method: 'callActionInActionSpace',\n name: 'aiDragAndDrop',\n description:\n 'Locate source and destination elements, then drag the source to the destination.',\n inputSchema: aiDragAndDropInputSchema,\n toArgs: (input) => [\n 'DragAndDrop',\n {\n from: buildDetailedLocateParam(input.from, input.options),\n to: buildDetailedLocateParam(input.to, input.options),\n },\n ],\n }),\n defineAgentActionNode({\n method: 'aiLocate',\n description:\n 'Locate an element from a natural-language description and store the result.',\n stringInputKey: 'prompt',\n inputSchema: aiTapInputSchema,\n toArgs: (input, context) => [\n input.prompt,\n { ...input.options, abortSignal: context.signal },\n ],\n toResult: valueResult,\n }),\n defineAgentActionNode({\n method: 'aiQuery',\n description:\n 'Extract structured data from the current interface and store the result.',\n stringInputKey: 'prompt',\n inputSchema: aiQueryInputSchema,\n toArgs: (input, context) => [\n input.prompt,\n { ...input.options, abortSignal: context.signal },\n ],\n toResult: valueResult,\n }),\n defineAgentActionNode({\n method: 'aiWaitFor',\n description: 'Wait until a natural-language condition is satisfied.',\n stringInputKey: 'prompt',\n inputSchema: aiWaitForInputSchema,\n toArgs: (input, context) => [\n input.prompt,\n { ...input.options, abortSignal: context.signal },\n ],\n }),\n defineAgentActionNode({\n method: 'evaluateJavaScript',\n name: 'javascript',\n description:\n 'Evaluate JavaScript in the current interface and store the result.',\n stringInputKey: 'script',\n inputSchema: javascriptInputSchema,\n toArgs: (input) => [input.script],\n toResult: valueResult,\n }),\n defineAgentActionNode({\n method: 'runGherkinScenario',\n description:\n 'Execute a Gherkin scenario with the current Midscene UI Agent.',\n stringInputKey: 'scenario',\n inputSchema: runGherkinScenarioInputSchema,\n toArgs: (input, context) => [\n input.scenario,\n { ...input.options, abortSignal: context.signal },\n ],\n }),\n defineAgentActionNode({\n method: 'callActionInActionSpace',\n name: 'action',\n description:\n 'Call a platform or custom action. Its ActionSpace schema validates params when the action executes.',\n inputSchema: actionInputSchema,\n toArgs: (input) => [input.name, input.params],\n toResult: (value) => (value === undefined ? undefined : valueResult(value)),\n }),\n];\n\nconst insightNode = (method: 'aiBoolean' | 'aiNumber' | 'aiString' | 'aiAsk') =>\n defineCommonAgentNode({\n method,\n description: `Run ${method} with a Midscene UI Agent and store its value.`,\n stringInputKey: 'prompt',\n inputSchema: insightInputSchema,\n toArgs: (input, context) => [\n input.prompt,\n { ...input.options, abortSignal: context.signal },\n ],\n toResult: (value) => ({\n summary: `${method} returned ${\n method === 'aiString' || method === 'aiAsk'\n ? JSON.stringify(value)\n : value\n }`,\n data: { value },\n }),\n });\n\nconst recordToReportNode = defineCommonAgentNode({\n method: 'recordToReport',\n description: 'Add text or screenshots to the current Midscene report.',\n stringInputKey: 'title',\n inputSchema: recordToReportInputSchema,\n toArgs(input) {\n return [input.title, input.options];\n },\n toResult(_output, input) {\n return { summary: `Recorded to report: ${input.title ?? 'untitled'}` };\n },\n});\n\nexport const commonAgentTestRunnerNodeDefinitions: readonly AgentTestRunnerNodeDefinition[] =\n [\n defineAgentActionNode({\n method: 'sleep',\n description:\n 'Wait for a fixed number of milliseconds, recording standard UI snapshots and honoring cancellation.',\n inputSchema: z.strictObject({ ms: z.number().positive() }),\n toArgs(input, { signal }) {\n signal.throwIfAborted();\n return [input.ms, { abortSignal: signal }];\n },\n }),\n aiActNode,\n aiTapNode,\n aiAssertNode,\n insightNode('aiBoolean'),\n insightNode('aiNumber'),\n insightNode('aiString'),\n insightNode('aiAsk'),\n recordToReportNode,\n ...additionalAgentNodes,\n ];\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","createAgentTestRunnerNodeDefinition","agentLabel","undefined","agent","input","context","TypeError","typedAgent","method","typedInput","result","nonBlankText","description","z","promptImageInputSchema","structuredUserPromptInputSchema","userPromptInputSchema","aiActOptionsInputSchema","setAIContextInputSchema","AGENT_AI_CONTEXT_KEYS","aiActInputSchema","insightOptionsInputSchema","aiAssertOptionsInputSchema","aiAssertInputSchema","locateOptionsInputSchema","aiTapInputSchema","aiInputInputSchema","inputStrategies","aiKeyboardPressInputSchema","aiScrollInputSchema","aiPinchInputSchema","aiLongPressInputSchema","aiDragAndDropInputSchema","aiQueryInputSchema","aiWaitForOptionsInputSchema","aiWaitForInputSchema","javascriptInputSchema","runGherkinScenarioInputSchema","actionInputSchema","insightInputSchema","reportScreenshotInputSchema","recordToReportOptionsInputSchema","recordToReportInputSchema","defineCommonAgentNode","defineAgentActionNode","promptText","prompt","valueResult","value","aiActNode","output","aiTapNode","_output","aiAssertNode","NodeExecutionError","Error","locateActionNode","additionalAgentNodes","buildDetailedLocateParam","insightNode","JSON","recordToReportNode","commonAgentTestRunnerNodeDefinitions","signal"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACuEO,MAAMI,sCACX,CAAwBC,aAAa,UAAU,GAC/C,CAKEP,aAMmC;YACnC,MAAMA,WAAW,IAAI,IAAIA,WAAW,MAAM;YAC1C,GAAIA,AAAqBQ,WAArBR,WAAW,KAAK,GAAiB,CAAC,IAAI;gBAAE,OAAOA,WAAW,KAAK;YAAC,CAAC;YACrE,GAAIA,AAA2BQ,WAA3BR,WAAW,WAAW,GACtB,CAAC,IACD;gBAAE,aAAaA,WAAW,WAAW;YAAC,CAAC;YAC3C,GAAIA,AAA8BQ,WAA9BR,WAAW,cAAc,GACzB,CAAC,IACD;gBAAE,gBAAgBA,WAAW,cAAc;YAAC,CAAC;YACjD,aAAaA,WAAW,WAAW;YACnC,MAAM,SAAQS,KA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BACpB,SAAS,GAAGxC,OAAO,UAAU,EAC3BA,AAAW,eAAXA,UAAyBA,AAAW,YAAXA,SACrBoD,KAAK,SAAS,CAACZ,SACfA,OACJ;gBACF,MAAM;oBAAEA;gBAAM;YAChB;IACF;AAEF,MAAMa,qBAAqBlB,sBAAsB;IAC/C,QAAQ;IACR,aAAa;IACb,gBAAgB;IAChB,aAAaD;IACb,QAAOtC,KAAK;QACV,OAAO;YAACA,MAAM,KAAK;YAAEA,MAAM,OAAO;SAAC;IACrC;IACA,UAASgD,OAAO,EAAEhD,KAAK;QACrB,OAAO;YAAE,SAAS,CAAC,oBAAoB,EAAEA,MAAM,KAAK,IAAI,YAAY;QAAC;IACvE;AACF;AAEO,MAAM0D,uCACX;IACElB,sBAAsB;QACpB,QAAQ;QACR,aACE;QACF,aAAa/B,mBAAAA,CAAAA,CAAAA,YAAc,CAAC;YAAE,IAAIA,mBAAAA,CAAAA,CAAAA,MAAQ,GAAG,QAAQ;QAAG;QACxD,QAAOT,KAAK,EAAE,EAAE2D,MAAM,EAAE;YACtBA,OAAO,cAAc;YACrB,OAAO;gBAAC3D,MAAM,EAAE;gBAAE;oBAAE,aAAa2D;gBAAO;aAAE;QAC5C;IACF;IACAd;IACAE;IACAE;IACAM,YAAY;IACZA,YAAY;IACZA,YAAY;IACZA,YAAY;IACZE;OACGJ;CACJ"}
1
+ {"version":3,"file":"agent/test-runner-nodes.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/agent/test-runner-nodes.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { AGENT_AI_CONTEXT_KEYS } from '@midscene/shared/agent-tools/agent-context';\nimport { z } from 'zod/v4';\nimport type { TUserPrompt } from '../common';\nimport { inputStrategies } from '../device/input-strategy';\nimport { NodeExecutionError } from '../test-runner/errors';\nimport type { LocateOption, ScrollParam } from '../yaml';\nimport { buildDetailedLocateParam } from '../yaml/utils';\nimport type { Agent } from './agent';\n\nexport interface AgentTestRunnerNodeResult<TData = unknown> {\n summary?: string;\n data?: TData;\n}\n\nexport interface AgentTestRunnerNodeExecutionContext {\n signal: AbortSignal;\n}\n\n/** Agent-owned Node description consumed by Test Runner adapters. */\nexport interface AgentTestRunnerNodeDefinition<\n TInput extends Record<string, unknown> = Record<string, unknown>,\n TData = unknown,\n> {\n name: string;\n title?: string;\n description?: string;\n /** Node input field populated by YAML string shorthand; omit to disable. */\n stringInputKey?: string | false;\n inputSchema: z.ZodObject;\n execute(\n agent: unknown,\n input: TInput,\n context: AgentTestRunnerNodeExecutionContext,\n ):\n | Promise<AgentTestRunnerNodeResult<TData> | undefined>\n | AgentTestRunnerNodeResult<TData>\n | undefined;\n}\n\n/** Static capability implemented by Agent classes that expose Runner Nodes. */\nexport interface AgentTestRunnerNodeProvider {\n getTestRunnerNodeDefinitions(): readonly AgentTestRunnerNodeDefinition[];\n}\n\ntype AnyAgentMethod = (...args: any[]) => unknown;\ntype AgentMethodName<TAgent extends object> = {\n [TKey in keyof TAgent]-?: TAgent[TKey] extends AnyAgentMethod ? TKey : never;\n}[keyof TAgent] &\n string;\ntype AgentMethod<\n TAgent extends object,\n TMethod extends AgentMethodName<TAgent>,\n> = Extract<TAgent[TMethod], AnyAgentMethod>;\n\nexport interface DefineAgentTestRunnerNodeOptions<\n TAgent extends object,\n TMethod extends AgentMethodName<TAgent>,\n TSchema extends z.ZodObject,\n TData = unknown,\n> {\n method: TMethod;\n name?: string;\n title?: string;\n description?: string;\n stringInputKey?: (keyof z.output<TSchema> & string) | false;\n inputSchema: TSchema;\n toArgs(\n input: z.output<TSchema>,\n context: AgentTestRunnerNodeExecutionContext,\n ): Parameters<AgentMethod<TAgent, TMethod>>;\n toResult?(\n result: Awaited<ReturnType<AgentMethod<TAgent, TMethod>>>,\n input: z.output<TSchema>,\n ): AgentTestRunnerNodeResult<TData> | undefined;\n}\n\n/** Create a Node factory whose adapters are checked against an Agent API. */\nexport const createAgentTestRunnerNodeDefinition =\n <TAgent extends object>(agentLabel = 'an Agent') =>\n <\n TMethod extends AgentMethodName<TAgent>,\n TSchema extends z.ZodObject,\n TData = unknown,\n >(\n definition: DefineAgentTestRunnerNodeOptions<\n TAgent,\n TMethod,\n TSchema,\n TData\n >,\n ): AgentTestRunnerNodeDefinition => ({\n name: definition.name ?? definition.method,\n ...(definition.title === undefined ? {} : { title: definition.title }),\n ...(definition.description === undefined\n ? {}\n : { description: definition.description }),\n ...(definition.stringInputKey === undefined\n ? {}\n : { stringInputKey: definition.stringInputKey }),\n inputSchema: definition.inputSchema,\n async execute(agent, input, context) {\n if (\n typeof agent !== 'object' ||\n agent === null ||\n typeof (agent as Record<string, unknown>)[definition.method] !==\n 'function'\n ) {\n throw new TypeError(\n `getAgent() must return ${agentLabel} with ${definition.method}().`,\n );\n }\n\n const typedAgent = agent as TAgent;\n const method = typedAgent[definition.method] as AgentMethod<\n TAgent,\n TMethod\n >;\n const typedInput = input as z.output<TSchema>;\n const result = (await method.apply(\n typedAgent,\n definition.toArgs(typedInput, context),\n )) as Awaited<ReturnType<AgentMethod<TAgent, TMethod>>>;\n return definition.toResult?.(result, typedInput);\n },\n });\n\nconst nonBlankText = (description: string) =>\n z\n .string()\n .regex(/\\S/, 'value must contain a non-whitespace character')\n .describe(description);\n\nexport const promptImageInputSchema = z.strictObject({\n name: nonBlankText('The name used to identify this reference image.'),\n url: nonBlankText('The URL, data URL, or file path of this reference image.'),\n});\n\nexport const structuredUserPromptInputSchema = z.strictObject({\n prompt: nonBlankText('The natural-language prompt.'),\n images: z.array(promptImageInputSchema).min(1).optional(),\n convertHttpImage2Base64: z\n .boolean()\n .optional()\n .describe('Whether HTTP reference images are converted to base64 first.'),\n});\n\nexport const userPromptInputSchema = z.union([\n nonBlankText('The natural-language prompt.'),\n structuredUserPromptInputSchema,\n]);\n\nexport const aiActOptionsInputSchema = z.strictObject({\n effort: z\n .enum(['fast', 'balance', 'deepThink'])\n .optional()\n .describe('Action planning effort: fast, balanced, or deeper reasoning.'),\n cacheable: z\n .boolean()\n .optional()\n .describe('Whether this action may use the Midscene cache.'),\n fileChooserAccept: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Accepted file types for a file chooser.'),\n fileChooserAllowedDir: z\n .string()\n .optional()\n .describe('Directory allowed for prompt-driven file uploads.'),\n deepThink: z\n .union([z.literal('unset'), z.boolean()])\n .optional()\n .describe('Whether to enable deep thinking for this action.'),\n deepLocate: z\n .boolean()\n .optional()\n .describe('Whether to use deep element location.'),\n context: z\n .string()\n .optional()\n .describe(\n 'Additional facts, rules, constraints, or output requirements for this AI call. Overrides inherited aiContexts; an empty string disables inherited user context.',\n ),\n});\n\nexport const setAIContextInputSchema = z.strictObject({\n target: z\n .enum(AGENT_AI_CONTEXT_KEYS)\n .describe(\n 'The AI API to configure, e.g. aiAct or aiAssert. Use default as the shared fallback for all AI APIs when neither the call nor the API has its own context.',\n ),\n context: z\n .string()\n .optional()\n .describe(\n 'Agent-level guidance. Omit to remove the selected context; an empty string disables inherited context.',\n ),\n});\n\nexport const aiActInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n options: aiActOptionsInputSchema.optional(),\n});\n\nexport const insightOptionsInputSchema = z.strictObject({\n domIncluded: z\n .union([z.boolean(), z.literal('visible-only')])\n .optional()\n .describe('How DOM information is included.'),\n screenshotIncluded: z\n .boolean()\n .optional()\n .describe('Whether the request includes a screenshot.'),\n context: z\n .string()\n .optional()\n .describe(\n 'Additional facts, rules, constraints, or output requirements for this AI call. Overrides inherited aiContexts; an empty string disables inherited user context.',\n ),\n});\n\nexport const aiAssertOptionsInputSchema = insightOptionsInputSchema.extend({\n keepRawResponse: z\n .boolean()\n .optional()\n .describe('Whether the Agent returns the structured assertion result.'),\n});\n\nexport const aiAssertInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n message: z.string().optional().describe('The assertion failure message.'),\n options: aiAssertOptionsInputSchema.optional(),\n});\n\nexport const locateOptionsInputSchema = z.strictObject({\n context: z\n .string()\n .optional()\n .describe(\n 'Additional facts, rules, constraints, or output requirements for this AI call. Overrides inherited aiContexts; an empty string disables inherited user context.',\n ),\n deepLocate: z\n .boolean()\n .optional()\n .describe('Whether to use deep element location.'),\n deepThink: z\n .boolean()\n .optional()\n .describe('Deprecated alias for deepLocate.'),\n cacheable: z\n .boolean()\n .optional()\n .describe('Whether this location may use the Midscene cache.'),\n xpath: z.string().optional().describe('A web XPath location hint.'),\n fileChooserAccept: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Files accepted when tapping opens a file chooser.'),\n});\n\nexport const aiTapInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n options: locateOptionsInputSchema.optional(),\n});\n\nexport const aiInputInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n value: z.union([z.string(), z.number()]),\n options: locateOptionsInputSchema\n .extend({\n mode: z.enum(['replace', 'clear', 'typeOnly', 'append']).optional(),\n autoDismissKeyboard: z.boolean().optional(),\n keyboardTypeDelay: z.number().nonnegative().optional(),\n inputStrategy: z.enum(inputStrategies).optional(),\n })\n .optional(),\n});\n\nexport const aiKeyboardPressInputSchema = z.strictObject({\n prompt: userPromptInputSchema.optional(),\n keyName: nonBlankText('The key or key combination to press.'),\n options: locateOptionsInputSchema.optional(),\n});\n\nexport const aiScrollInputSchema = z.strictObject({\n prompt: userPromptInputSchema\n .optional()\n .describe(\n 'Optional locator for a currently visible scrollable container, such as \"the product list\". Omit for page scrolling. Describe the container, not a scrolling instruction or an off-screen target to find. Set direction, distance, and scrollType in options.',\n ),\n options: locateOptionsInputSchema\n .extend({\n direction: z.enum(['down', 'up', 'right', 'left']).optional(),\n scrollType: z\n .enum([\n 'singleAction',\n 'scrollToBottom',\n 'scrollToTop',\n 'scrollToRight',\n 'scrollToLeft',\n 'once',\n 'untilBottom',\n 'untilTop',\n 'untilRight',\n 'untilLeft',\n ])\n .optional(),\n distance: z.number().nullable().optional(),\n })\n .optional(),\n});\n\nexport const aiPinchInputSchema = z.strictObject({\n prompt: userPromptInputSchema.optional(),\n direction: z.enum(['in', 'out']),\n options: locateOptionsInputSchema\n .extend({\n distance: z.number().optional(),\n duration: z.number().nonnegative().optional(),\n })\n .optional(),\n});\n\nexport const aiLongPressInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n options: locateOptionsInputSchema\n .extend({ duration: z.number().nonnegative().optional() })\n .optional(),\n});\n\nexport const aiDragAndDropInputSchema = z.strictObject({\n from: userPromptInputSchema,\n to: userPromptInputSchema,\n options: locateOptionsInputSchema.optional(),\n});\n\nexport const aiQueryInputSchema = z.strictObject({\n prompt: z.union([\n nonBlankText('The extraction request.'),\n z.record(z.string(), z.string()),\n ]),\n options: insightOptionsInputSchema.optional(),\n});\n\nexport const aiWaitForOptionsInputSchema = insightOptionsInputSchema\n .extend({\n timeoutMs: z.number().positive().optional(),\n checkIntervalMs: z.number().positive().optional(),\n })\n .superRefine((input, context) => {\n if ((input.checkIntervalMs ?? 3000) > (input.timeoutMs ?? 15000)) {\n context.addIssue({\n code: 'custom',\n path: ['checkIntervalMs'],\n message: 'checkIntervalMs must not exceed timeoutMs',\n });\n }\n });\n\nexport const aiWaitForInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n options: aiWaitForOptionsInputSchema.optional(),\n});\n\nexport type AiWaitForNodeOptions = z.infer<typeof aiWaitForOptionsInputSchema>;\n\nexport const javascriptInputSchema = z.strictObject({\n script: nonBlankText('JavaScript to evaluate through the current interface.'),\n});\n\nexport const runGherkinScenarioInputSchema = z.strictObject({\n scenario: nonBlankText('The Gherkin scenario to execute.'),\n options: aiActOptionsInputSchema.optional(),\n});\n\nexport const actionInputSchema = z.strictObject({\n name: nonBlankText('The ActionSpace action name, for example DragAndDrop.'),\n params: z.unknown().optional(),\n});\n\nexport const insightInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n options: insightOptionsInputSchema.optional(),\n});\n\nexport const reportScreenshotInputSchema = z.strictObject({\n base64: z.string().min(1).describe('A base64-encoded screenshot.'),\n description: z.string().optional().describe('What the screenshot shows.'),\n});\n\nexport const recordToReportOptionsInputSchema = z\n .strictObject({\n content: z.string().optional().describe('The report text content.'),\n screenshotBase64: z\n .string()\n .optional()\n .describe('One base64-encoded screenshot.'),\n screenshots: z\n .array(reportScreenshotInputSchema)\n .min(1)\n .optional()\n .describe('Screenshots attached to the report section.'),\n })\n .superRefine((input, context) => {\n if (\n input.screenshotBase64 !== undefined &&\n input.screenshots !== undefined\n ) {\n context.addIssue({\n code: 'custom',\n message: 'screenshotBase64 and screenshots are mutually exclusive',\n });\n }\n });\n\nexport const recordToReportInputSchema = z.strictObject({\n title: z.string().optional().describe('The report section title.'),\n options: recordToReportOptionsInputSchema.optional(),\n});\n\nexport type UserPromptNodeInput = z.infer<typeof userPromptInputSchema>;\nexport type SetAIContextNodeInput = z.infer<typeof setAIContextInputSchema>;\nexport type AiActNodeOptions = z.infer<typeof aiActOptionsInputSchema>;\nexport type AiActNodeInput = z.infer<typeof aiActInputSchema>;\nexport type AiAssertNodeOptions = z.infer<typeof aiAssertOptionsInputSchema>;\nexport type AiAssertNodeInput = z.infer<typeof aiAssertInputSchema>;\nexport type AiTapNodeOptions = z.infer<typeof locateOptionsInputSchema>;\nexport type AiTapNodeInput = z.infer<typeof aiTapInputSchema>;\nexport type AiInputNodeInput = z.infer<typeof aiInputInputSchema>;\nexport type AiKeyboardPressNodeInput = z.infer<\n typeof aiKeyboardPressInputSchema\n>;\nexport type AiScrollNodeInput = z.infer<typeof aiScrollInputSchema>;\nexport type AiPinchNodeInput = z.infer<typeof aiPinchInputSchema>;\nexport type AiLongPressNodeInput = z.infer<typeof aiLongPressInputSchema>;\nexport type AiDragAndDropNodeInput = z.infer<typeof aiDragAndDropInputSchema>;\nexport type AiQueryNodeInput = z.infer<typeof aiQueryInputSchema>;\nexport type AiWaitForNodeInput = z.infer<typeof aiWaitForInputSchema>;\nexport type JavascriptNodeInput = z.infer<typeof javascriptInputSchema>;\nexport type RunGherkinScenarioNodeInput = z.infer<\n typeof runGherkinScenarioInputSchema\n>;\nexport type ActionNodeInput = z.infer<typeof actionInputSchema>;\nexport type InsightNodeOptions = z.infer<typeof insightOptionsInputSchema>;\nexport type InsightNodeInput = z.infer<typeof insightInputSchema>;\nexport type RecordToReportNodeOptions = z.infer<\n typeof recordToReportOptionsInputSchema\n>;\nexport type RecordToReportNodeInput = z.infer<typeof recordToReportInputSchema>;\n\nexport type CommonAgentTestRunnerApi = Pick<\n Agent,\n | 'aiAct'\n | 'aiTap'\n | 'aiAssert'\n | 'aiBoolean'\n | 'aiNumber'\n | 'aiString'\n | 'aiAsk'\n | 'recordToReport'\n>;\n\nconst defineCommonAgentNode =\n createAgentTestRunnerNodeDefinition<CommonAgentTestRunnerApi>('an Agent');\n\n// Select the current overloads without expanding the minimum API required by\n// existing getAgent() providers. Each Node checks its own method at execution.\ntype AgentActionNodeApi = Pick<\n Agent,\n | 'sleep'\n | 'setAIContext'\n | 'aiHover'\n | 'aiDoubleClick'\n | 'aiRightClick'\n | 'aiMiddleClick'\n | 'aiLongPress'\n | 'aiClearInput'\n | 'aiPinch'\n | 'aiLocate'\n | 'aiQuery'\n | 'aiWaitFor'\n | 'evaluateJavaScript'\n | 'runGherkinScenario'\n | 'callActionInActionSpace'\n> & {\n aiInput(\n prompt: TUserPrompt,\n options: NonNullable<Parameters<Agent['aiInput']>[2]> & {\n value: string | number;\n },\n ): Promise<void>;\n aiKeyboardPress(\n prompt: TUserPrompt | undefined,\n options: LocateOption & { keyName: string },\n ): Promise<void>;\n aiScroll(\n prompt: TUserPrompt | undefined,\n options: LocateOption & ScrollParam,\n ): Promise<void>;\n};\n\nconst defineAgentActionNode =\n createAgentTestRunnerNodeDefinition<AgentActionNodeApi>('an Agent');\n\nconst promptText = (prompt: UserPromptNodeInput): string =>\n typeof prompt === 'string' ? prompt : prompt.prompt;\n\nconst valueResult = (\n value: unknown,\n): AgentTestRunnerNodeResult | undefined => ({ data: value });\n\nconst aiActNode = defineCommonAgentNode({\n method: 'aiAct',\n description: 'Perform a natural-language task with a Midscene UI Agent.',\n stringInputKey: 'prompt',\n inputSchema: aiActInputSchema,\n toArgs(input, context) {\n return [\n input.prompt,\n {\n ...input.options,\n abortSignal: context.signal,\n },\n ];\n },\n toResult(output) {\n return output === undefined ? undefined : { summary: output };\n },\n});\n\nconst aiTapNode = defineCommonAgentNode({\n method: 'aiTap',\n description: 'Locate and tap an element with a Midscene UI Agent.',\n stringInputKey: 'prompt',\n inputSchema: aiTapInputSchema,\n toArgs(input) {\n return [input.prompt, input.options];\n },\n toResult(_output, input) {\n return { summary: `Tapped: ${promptText(input.prompt)}` };\n },\n});\n\nconst aiAssertNode = defineCommonAgentNode({\n method: 'aiAssert',\n description: 'Assert a natural-language condition with a Midscene UI Agent.',\n stringInputKey: 'prompt',\n inputSchema: aiAssertInputSchema,\n toArgs(input, context) {\n return [\n input.prompt,\n input.message,\n {\n keepRawResponse: true,\n ...input.options,\n abortSignal: context.signal,\n },\n ];\n },\n toResult(output, input) {\n const result = {\n summary: `Assertion ${output?.pass === false ? 'failed' : 'passed'}: ${promptText(input.prompt)}`,\n ...(output === undefined\n ? {}\n : {\n data: {\n pass: output.pass,\n ...(output.thought === undefined\n ? {}\n : { thought: output.thought }),\n ...(output.message === undefined\n ? {}\n : { message: output.message }),\n },\n }),\n };\n if (output?.pass === false)\n throw new NodeExecutionError(\n 'aiAssert',\n new Error(\n output.message ||\n input.message ||\n output.thought ||\n `Assertion failed: ${promptText(input.prompt)}`,\n ),\n result,\n );\n return result;\n },\n});\n\nconst locateActionNode = (\n method:\n | 'aiHover'\n | 'aiDoubleClick'\n | 'aiRightClick'\n | 'aiMiddleClick'\n | 'aiClearInput',\n) =>\n defineAgentActionNode({\n method,\n description: {\n aiHover: 'Locate and hover over an element with a Midscene UI Agent.',\n aiDoubleClick:\n 'Locate and double-click an element with a Midscene UI Agent.',\n aiMiddleClick:\n 'Locate and middle-click an element with a Midscene UI Agent.',\n aiRightClick:\n 'Locate and right-click an element with a Midscene UI Agent.',\n aiClearInput:\n 'Locate an input element and clear its value with a Midscene UI Agent.',\n }[method],\n stringInputKey: 'prompt',\n inputSchema: aiTapInputSchema,\n toArgs: (input) => [input.prompt, input.options],\n toResult: (_output, input) => ({\n summary: `${method}: ${promptText(input.prompt)}`,\n }),\n });\n\nconst additionalAgentNodes: readonly AgentTestRunnerNodeDefinition[] = [\n defineAgentActionNode({\n method: 'setAIContext',\n description:\n 'Set or remove Agent-level AI guidance for subsequent calls on the same Agent.',\n inputSchema: setAIContextInputSchema,\n toArgs: (input) => [input.target, input.context],\n }),\n locateActionNode('aiHover'),\n locateActionNode('aiDoubleClick'),\n locateActionNode('aiRightClick'),\n locateActionNode('aiMiddleClick'),\n locateActionNode('aiClearInput'),\n defineAgentActionNode({\n method: 'aiInput',\n description:\n 'Locate an input element and enter a value with a Midscene UI Agent.',\n inputSchema: aiInputInputSchema,\n toArgs: (input) => [input.prompt, { ...input.options, value: input.value }],\n }),\n defineAgentActionNode({\n method: 'aiKeyboardPress',\n description:\n 'Press a key or key combination, optionally targeting a located element.',\n stringInputKey: 'keyName',\n inputSchema: aiKeyboardPressInputSchema,\n toArgs: (input) => [\n input.prompt,\n { ...input.options, keyName: input.keyName },\n ],\n }),\n defineAgentActionNode({\n method: 'aiScroll',\n description:\n 'Scroll the page or a located region with a Midscene UI Agent.',\n stringInputKey: 'prompt',\n inputSchema: aiScrollInputSchema,\n toArgs: (input) => [input.prompt, { ...input.options }],\n }),\n defineAgentActionNode({\n method: 'aiPinch',\n description:\n 'Perform a pinch-in or pinch-out gesture with a Midscene UI Agent.',\n inputSchema: aiPinchInputSchema,\n toArgs: (input) => [\n input.prompt,\n { ...input.options, direction: input.direction },\n ],\n }),\n defineAgentActionNode({\n method: 'aiLongPress',\n description: 'Locate and long-press an element with a Midscene UI Agent.',\n stringInputKey: 'prompt',\n inputSchema: aiLongPressInputSchema,\n toArgs: (input) => [input.prompt, input.options],\n }),\n defineAgentActionNode({\n method: 'callActionInActionSpace',\n name: 'aiDragAndDrop',\n description:\n 'Locate source and destination elements, then drag the source to the destination.',\n inputSchema: aiDragAndDropInputSchema,\n toArgs: (input) => [\n 'DragAndDrop',\n {\n from: buildDetailedLocateParam(input.from, input.options),\n to: buildDetailedLocateParam(input.to, input.options),\n },\n ],\n }),\n defineAgentActionNode({\n method: 'aiLocate',\n description:\n 'Locate an element from a natural-language description and store the result.',\n stringInputKey: 'prompt',\n inputSchema: aiTapInputSchema,\n toArgs: (input, context) => [\n input.prompt,\n { ...input.options, abortSignal: context.signal },\n ],\n toResult: valueResult,\n }),\n defineAgentActionNode({\n method: 'aiQuery',\n description:\n 'Extract structured data from the current interface and store the result.',\n stringInputKey: 'prompt',\n inputSchema: aiQueryInputSchema,\n toArgs: (input, context) => [\n input.prompt,\n { ...input.options, abortSignal: context.signal },\n ],\n toResult: valueResult,\n }),\n defineAgentActionNode({\n method: 'aiWaitFor',\n description: 'Wait until a natural-language condition is satisfied.',\n stringInputKey: 'prompt',\n inputSchema: aiWaitForInputSchema,\n toArgs: (input, context) => [\n input.prompt,\n { ...input.options, abortSignal: context.signal },\n ],\n }),\n defineAgentActionNode({\n method: 'evaluateJavaScript',\n name: 'javascript',\n description:\n 'Evaluate JavaScript in the current interface and store the result.',\n stringInputKey: 'script',\n inputSchema: javascriptInputSchema,\n toArgs: (input) => [input.script],\n toResult: valueResult,\n }),\n defineAgentActionNode({\n method: 'runGherkinScenario',\n description:\n 'Execute a Gherkin scenario with the current Midscene UI Agent.',\n stringInputKey: 'scenario',\n inputSchema: runGherkinScenarioInputSchema,\n toArgs: (input, context) => [\n input.scenario,\n { ...input.options, abortSignal: context.signal },\n ],\n }),\n defineAgentActionNode({\n method: 'callActionInActionSpace',\n name: 'action',\n description:\n 'Call a platform or custom action. Its ActionSpace schema validates params when the action executes.',\n inputSchema: actionInputSchema,\n toArgs: (input) => [input.name, input.params],\n toResult: (value) => (value === undefined ? undefined : valueResult(value)),\n }),\n];\n\nconst insightNode = (method: 'aiBoolean' | 'aiNumber' | 'aiString' | 'aiAsk') =>\n defineCommonAgentNode({\n method,\n description: `Run ${method} with a Midscene UI Agent and store its value.`,\n stringInputKey: 'prompt',\n inputSchema: insightInputSchema,\n toArgs: (input, context) => [\n input.prompt,\n { ...input.options, abortSignal: context.signal },\n ],\n toResult: (value) => ({\n summary: `${method} returned ${\n method === 'aiString' || method === 'aiAsk'\n ? JSON.stringify(value)\n : value\n }`,\n data: { value },\n }),\n });\n\nconst recordToReportNode = defineCommonAgentNode({\n method: 'recordToReport',\n description: 'Add text or screenshots to the current Midscene report.',\n stringInputKey: 'title',\n inputSchema: recordToReportInputSchema,\n toArgs(input) {\n return [input.title, input.options];\n },\n toResult(_output, input) {\n return { summary: `Recorded to report: ${input.title ?? 'untitled'}` };\n },\n});\n\nexport const commonAgentTestRunnerNodeDefinitions: readonly AgentTestRunnerNodeDefinition[] =\n [\n defineAgentActionNode({\n method: 'sleep',\n description:\n 'Wait for a fixed number of milliseconds, recording standard UI snapshots and honoring cancellation.',\n inputSchema: z.strictObject({ ms: z.number().positive() }),\n toArgs(input, { signal }) {\n signal.throwIfAborted();\n return [input.ms, { abortSignal: signal }];\n },\n }),\n aiActNode,\n aiTapNode,\n aiAssertNode,\n insightNode('aiBoolean'),\n insightNode('aiNumber'),\n insightNode('aiString'),\n insightNode('aiAsk'),\n recordToReportNode,\n ...additionalAgentNodes,\n ];\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","createAgentTestRunnerNodeDefinition","agentLabel","undefined","agent","input","context","TypeError","typedAgent","method","typedInput","result","nonBlankText","description","z","promptImageInputSchema","structuredUserPromptInputSchema","userPromptInputSchema","aiActOptionsInputSchema","setAIContextInputSchema","AGENT_AI_CONTEXT_KEYS","aiActInputSchema","insightOptionsInputSchema","aiAssertOptionsInputSchema","aiAssertInputSchema","locateOptionsInputSchema","aiTapInputSchema","aiInputInputSchema","inputStrategies","aiKeyboardPressInputSchema","aiScrollInputSchema","aiPinchInputSchema","aiLongPressInputSchema","aiDragAndDropInputSchema","aiQueryInputSchema","aiWaitForOptionsInputSchema","aiWaitForInputSchema","javascriptInputSchema","runGherkinScenarioInputSchema","actionInputSchema","insightInputSchema","reportScreenshotInputSchema","recordToReportOptionsInputSchema","recordToReportInputSchema","defineCommonAgentNode","defineAgentActionNode","promptText","prompt","valueResult","value","aiActNode","output","aiTapNode","_output","aiAssertNode","NodeExecutionError","Error","locateActionNode","additionalAgentNodes","buildDetailedLocateParam","insightNode","JSON","recordToReportNode","commonAgentTestRunnerNodeDefinitions","signal"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;;;;;;;;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E;QAC5C;IACF;IACAd;IACAE;IACAE;IACAM,YAAY;IACZA,YAAY;IACZA,YAAY;IACZA,YAAY;IACZE;OACGJ;CACJ"}
@@ -193,7 +193,7 @@ async function matchElementFromCache(context, cacheEntry, cachePrompt, cacheable
193
193
  return;
194
194
  }
195
195
  }
196
- const getMidsceneVersion = ()=>"1.17.6";
196
+ const getMidsceneVersion = ()=>"1.17.8-beta-20261106101231.0";
197
197
  const parsePrompt = (prompt)=>{
198
198
  if ('string' == typeof prompt) return {
199
199
  textPrompt: prompt,
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ buildLocateMessages: ()=>buildLocateMessages,
28
+ parseLocatePromptOrder: ()=>parseLocatePromptOrder
29
+ });
30
+ const parts = [
31
+ 'instructions',
32
+ 'screenshot',
33
+ 'task',
34
+ 'references'
35
+ ];
36
+ function parseLocatePromptOrder(order = 'system(instructions):userTogether(screenshot:task):userEach(references)') {
37
+ const groups = order.split(/(?<=\)):/);
38
+ const remaining = new Set(parts);
39
+ function invalid(reason) {
40
+ return new Error(`Invalid locate promptOrder "${order}": ${reason}`);
41
+ }
42
+ const promptGroups = groups.map((group)=>{
43
+ const match = /^(system|userTogether|userEach)\(([^()]+)\)$/.exec(group);
44
+ if (!match) throw invalid(`expected system(...), userTogether(...) or userEach(...), got "${group}"`);
45
+ const groupParts = match[2].split(':');
46
+ for (const part of groupParts){
47
+ if (!remaining.delete(part)) throw invalid(`unknown or repeated part "${part}"`);
48
+ if ('system' === match[1] && ('screenshot' === part || 'references' === part)) throw invalid(`system cannot contain image part "${part}"`);
49
+ }
50
+ if ('system' === match[1]) return {
51
+ mode: 'system',
52
+ parts: groupParts
53
+ };
54
+ return {
55
+ mode: match[1],
56
+ parts: groupParts
57
+ };
58
+ });
59
+ if (remaining.size) throw invalid(`missing ${[
60
+ ...remaining
61
+ ].join(', ')}`);
62
+ return {
63
+ groups: promptGroups
64
+ };
65
+ }
66
+ function buildLocateMessages(order, input) {
67
+ const messages = [];
68
+ for (const group of order.groups){
69
+ if ('system' === group.mode) {
70
+ messages.push({
71
+ role: 'system',
72
+ content: group.parts.map((part)=>input[part]).join('\n\n')
73
+ });
74
+ continue;
75
+ }
76
+ const expanded = group.parts.flatMap((part)=>{
77
+ if ('references' === part) return input.references;
78
+ const content = 'screenshot' === part ? [
79
+ {
80
+ type: 'image',
81
+ url: input.screenshot
82
+ }
83
+ ] : input[part];
84
+ return [
85
+ {
86
+ role: 'user',
87
+ content
88
+ }
89
+ ];
90
+ });
91
+ if ('userEach' === group.mode) messages.push(...expanded);
92
+ else if (expanded.length) {
93
+ const content = expanded.flatMap((message)=>'string' == typeof message.content ? [
94
+ {
95
+ type: 'text',
96
+ text: message.content
97
+ }
98
+ ] : message.content);
99
+ messages.push({
100
+ role: 'user',
101
+ content
102
+ });
103
+ }
104
+ }
105
+ return messages;
106
+ }
107
+ exports.buildLocateMessages = __webpack_exports__.buildLocateMessages;
108
+ exports.parseLocatePromptOrder = __webpack_exports__.parseLocatePromptOrder;
109
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
110
+ "buildLocateMessages",
111
+ "parseLocatePromptOrder"
112
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
113
+ Object.defineProperty(exports, '__esModule', {
114
+ value: true
115
+ });
116
+
117
+ //# sourceMappingURL=locate-prompt-order.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-model/model-adapter/locate-prompt-order.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/model-adapter/locate-prompt-order.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type {\n ConversationSystemMessage,\n ConversationUserMessage,\n MessageContent,\n} from '../service-caller/types';\n\nconst parts = ['instructions', 'screenshot', 'task', 'references'] as const;\ntype Part = (typeof parts)[number];\n\nexport type LocateMessages = (\n | ConversationSystemMessage\n | ConversationUserMessage\n)[];\n\ntype TextPart = Extract<Part, 'instructions' | 'task'>;\ntype PromptGroup =\n | { mode: 'system'; parts: TextPart[] }\n | { mode: 'userTogether' | 'userEach'; parts: Part[] };\n\nexport interface LocatePromptOrder {\n groups: readonly PromptGroup[];\n}\n\nexport function parseLocatePromptOrder(\n order = 'system(instructions):userTogether(screenshot:task):userEach(references)',\n): LocatePromptOrder {\n const groups = order.split(/(?<=\\)):/);\n const remaining = new Set<string>(parts);\n\n function invalid(reason: string): Error {\n return new Error(`Invalid locate promptOrder \"${order}\": ${reason}`);\n }\n\n const promptGroups = groups.map((group): PromptGroup => {\n const match = /^(system|userTogether|userEach)\\(([^()]+)\\)$/.exec(group);\n if (!match) {\n throw invalid(\n `expected system(...), userTogether(...) or userEach(...), got \"${group}\"`,\n );\n }\n const groupParts = match[2].split(':');\n for (const part of groupParts) {\n if (!remaining.delete(part)) {\n throw invalid(`unknown or repeated part \"${part}\"`);\n }\n if (\n match[1] === 'system' &&\n (part === 'screenshot' || part === 'references')\n ) {\n throw invalid(`system cannot contain image part \"${part}\"`);\n }\n }\n if (match[1] === 'system') {\n return { mode: 'system', parts: groupParts as TextPart[] };\n }\n return {\n mode: match[1] as 'userTogether' | 'userEach',\n parts: groupParts as Part[],\n };\n });\n if (remaining.size) {\n throw invalid(`missing ${[...remaining].join(', ')}`);\n }\n return { groups: promptGroups };\n}\n\nexport function buildLocateMessages(\n order: LocatePromptOrder,\n input: {\n instructions: string;\n screenshot: string;\n task: string;\n references: ConversationUserMessage[];\n },\n): LocateMessages {\n const messages: LocateMessages = [];\n for (const group of order.groups) {\n if (group.mode === 'system') {\n messages.push({\n role: 'system',\n content: group.parts.map((part) => input[part]).join('\\n\\n'),\n });\n continue;\n }\n const expanded = group.parts.flatMap((part): ConversationUserMessage[] => {\n if (part === 'references') {\n return input.references;\n }\n const content =\n part === 'screenshot'\n ? [{ type: 'image' as const, url: input.screenshot }]\n : input[part];\n return [{ role: 'user', content }];\n });\n if (group.mode === 'userEach') {\n messages.push(...expanded);\n } else if (expanded.length) {\n const content = expanded.flatMap((message): MessageContent[] =>\n typeof message.content === 'string'\n ? [{ type: 'text', text: message.content }]\n : message.content,\n );\n messages.push({ role: 'user', content });\n }\n }\n return messages;\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","parts","parseLocatePromptOrder","order","groups","remaining","Set","invalid","reason","Error","promptGroups","group","match","groupParts","part","buildLocateMessages","input","messages","expanded","content","message"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC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;IACA,OAAOF;AACT"}
@@ -29,6 +29,7 @@ __webpack_require__.d(__webpack_exports__, {
29
29
  const factory_js_namespaceObject = require("../shared/model-locate-result/factory.js");
30
30
  const planning_action_locate_js_namespaceObject = require("../workflows/grounding/planning-action-locate.js");
31
31
  const external_default_locate_protocol_js_namespaceObject = require("./default-locate-protocol.js");
32
+ const external_locate_prompt_order_js_namespaceObject = require("./locate-prompt-order.js");
32
33
  const defaultLocateResultFormatDefinition = {
33
34
  coordinates: {
34
35
  shape: 'bbox',
@@ -59,7 +60,7 @@ function resolveLocate(locate, resolvedCustomPlanner, protocolContext) {
59
60
  const searchAreaResultCodec = searchAreaResultFormat ? (0, factory_js_namespaceObject.createLocateResultCodec)(searchAreaResultFormat) : void 0;
60
61
  return {
61
62
  kind: 'standard',
62
- userMessageContentOrder: locate?.userMessageContentOrder ?? 'image-first',
63
+ promptOrder: (0, external_locate_prompt_order_js_namespaceObject.parseLocatePromptOrder)(locate?.promptOrder),
63
64
  element: {
64
65
  protocol: elementProtocol,
65
66
  resultCodec: elementResultCodec
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/model-adapter/locate.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/model-adapter/locate.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { createLocateResultCodec } from '../shared/model-locate-result/factory';\nimport type { LocateResultFormatDefinition } from '../shared/model-locate-result/types';\nimport { resolvePlanningTapLocator } from '../workflows/grounding/planning-action-locate';\nimport type { ResolvedCustomPlanningDefinition } from './custom-planning-types';\nimport {\n createDefaultElementProtocol,\n createDefaultSearchAreaProtocol,\n} from './default-locate-protocol';\nimport type {\n StandardLocateProtocolContext,\n StandardLocateProtocolDefinition,\n} from './locate-protocol';\nimport type { LocateAdapter, ModelAdapterDefinition } from './types';\n\nconst defaultLocateResultFormatDefinition: LocateResultFormatDefinition = {\n coordinates: { shape: 'bbox', order: 'xy', normalizedBy: 1000 },\n};\n\nconst resolveLocateProtocolDefinition = (\n protocolDefinition: StandardLocateProtocolDefinition,\n protocolContext: StandardLocateProtocolContext,\n) =>\n typeof protocolDefinition === 'function'\n ? protocolDefinition(protocolContext)\n : protocolDefinition;\n\nexport function resolveLocate(\n locate: ModelAdapterDefinition['locate'],\n resolvedCustomPlanner: ResolvedCustomPlanningDefinition | undefined,\n protocolContext: StandardLocateProtocolContext,\n): LocateAdapter {\n if (locate?.kind === 'custom') {\n let locateFn = locate.locateFn;\n\n if (!locateFn) {\n const planningTapLocator = locate.planningTapLocator;\n\n if (!planningTapLocator) {\n throw new Error(\n 'Custom locate definition requires either locateFn or planningTapLocator',\n );\n }\n\n if (!resolvedCustomPlanner) {\n throw new Error(\n 'Custom planning tap locator requires a custom planning planner definition',\n );\n }\n locateFn = resolvePlanningTapLocator(\n planningTapLocator,\n resolvedCustomPlanner,\n );\n }\n\n return {\n kind: 'custom',\n locateFn,\n };\n }\n\n const elementProtocol = resolveLocateProtocolDefinition(\n locate?.element?.protocol ?? createDefaultElementProtocol,\n protocolContext,\n );\n const elementResultFormat =\n locate?.element?.resultFormat ?? defaultLocateResultFormatDefinition;\n const elementResultCodec = createLocateResultCodec(elementResultFormat);\n const searchAreaProtocol =\n locate?.searchArea === false\n ? undefined\n : resolveLocateProtocolDefinition(\n locate?.searchArea?.protocol ?? createDefaultSearchAreaProtocol,\n protocolContext,\n );\n const searchAreaResultFormat =\n locate?.searchArea === false\n ? undefined\n : (locate?.searchArea?.resultFormat ?? elementResultFormat);\n const searchAreaResultCodec = searchAreaResultFormat\n ? createLocateResultCodec(searchAreaResultFormat)\n : undefined;\n\n return {\n kind: 'standard',\n userMessageContentOrder: locate?.userMessageContentOrder ?? 'image-first',\n element: {\n protocol: elementProtocol,\n resultCodec: elementResultCodec,\n },\n ...(searchAreaProtocol && searchAreaResultCodec\n ? {\n searchArea: {\n protocol: searchAreaProtocol,\n resultCodec: searchAreaResultCodec,\n },\n }\n : {}),\n };\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","defaultLocateResultFormatDefinition","resolveLocateProtocolDefinition","protocolDefinition","protocolContext","resolveLocate","locate","resolvedCustomPlanner","locateFn","planningTapLocator","Error","resolvePlanningTapLocator","elementProtocol","createDefaultElementProtocol","elementResultFormat","elementResultCodec","createLocateResultCodec","searchAreaProtocol","undefined","createDefaultSearchAreaProtocol","searchAreaResultFormat","searchAreaResultCodec"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;ACQA,MAAMI,sCAAoE;IACxE,aAAa;QAAE,OAAO;QAAQ,OAAO;QAAM,cAAc;IAAK;AAChE;AAEA,MAAMC,kCAAkC,CACtCC,oBACAC,kBAEA,AAA8B,cAA9B,OAAOD,qBACHA,mBAAmBC,mBACnBD;AAEC,SAASE,cACdC,MAAwC,EACxCC,qBAAmE,EACnEH,eAA8C;IAE9C,IAAIE,QAAQ,SAAS,UAAU;QAC7B,IAAIE,WAAWF,OAAO,QAAQ;QAE9B,IAAI,CAACE,UAAU;YACb,MAAMC,qBAAqBH,OAAO,kBAAkB;YAEpD,IAAI,CAACG,oBACH,MAAM,IAAIC,MACR;YAIJ,IAAI,CAACH,uBACH,MAAM,IAAIG,MACR;YAGJF,WAAWG,AAAAA,IAAAA,0CAAAA,yBAAAA,AAAAA,EACTF,oBACAF;QAEJ;QAEA,OAAO;YACL,MAAM;YACNC;QACF;IACF;IAEA,MAAMI,kBAAkBV,gCACtBI,QAAQ,SAAS,YAAYO,oDAAAA,4BAA4BA,EACzDT;IAEF,MAAMU,sBACJR,QAAQ,SAAS,gBAAgBL;IACnC,MAAMc,qBAAqBC,AAAAA,IAAAA,2BAAAA,uBAAAA,AAAAA,EAAwBF;IACnD,MAAMG,qBACJX,QAAQ,eAAe,QACnBY,SACAhB,gCACEI,QAAQ,YAAY,YAAYa,oDAAAA,+BAA+BA,EAC/Df;IAER,MAAMgB,yBACJd,QAAQ,eAAe,QACnBY,SACCZ,QAAQ,YAAY,gBAAgBQ;IAC3C,MAAMO,wBAAwBD,yBAC1BJ,AAAAA,IAAAA,2BAAAA,uBAAAA,AAAAA,EAAwBI,0BACxBF;IAEJ,OAAO;QACL,MAAM;QACN,yBAAyBZ,QAAQ,2BAA2B;QAC5D,SAAS;YACP,UAAUM;YACV,aAAaG;QACf;QACA,GAAIE,sBAAsBI,wBACtB;YACE,YAAY;gBACV,UAAUJ;gBACV,aAAaI;YACf;QACF,IACA,CAAC,CAAC;IACR;AACF"}
1
+ {"version":3,"file":"ai-model/model-adapter/locate.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/model-adapter/locate.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { createLocateResultCodec } from '../shared/model-locate-result/factory';\nimport type { LocateResultFormatDefinition } from '../shared/model-locate-result/types';\nimport { resolvePlanningTapLocator } from '../workflows/grounding/planning-action-locate';\nimport type { ResolvedCustomPlanningDefinition } from './custom-planning-types';\nimport {\n createDefaultElementProtocol,\n createDefaultSearchAreaProtocol,\n} from './default-locate-protocol';\nimport { parseLocatePromptOrder } from './locate-prompt-order';\nimport type {\n StandardLocateProtocolContext,\n StandardLocateProtocolDefinition,\n} from './locate-protocol';\nimport type { LocateAdapter, ModelAdapterDefinition } from './types';\n\nconst defaultLocateResultFormatDefinition: LocateResultFormatDefinition = {\n coordinates: { shape: 'bbox', order: 'xy', normalizedBy: 1000 },\n};\n\nconst resolveLocateProtocolDefinition = (\n protocolDefinition: StandardLocateProtocolDefinition,\n protocolContext: StandardLocateProtocolContext,\n) =>\n typeof protocolDefinition === 'function'\n ? protocolDefinition(protocolContext)\n : protocolDefinition;\n\nexport function resolveLocate(\n locate: ModelAdapterDefinition['locate'],\n resolvedCustomPlanner: ResolvedCustomPlanningDefinition | undefined,\n protocolContext: StandardLocateProtocolContext,\n): LocateAdapter {\n if (locate?.kind === 'custom') {\n let locateFn = locate.locateFn;\n\n if (!locateFn) {\n const planningTapLocator = locate.planningTapLocator;\n\n if (!planningTapLocator) {\n throw new Error(\n 'Custom locate definition requires either locateFn or planningTapLocator',\n );\n }\n\n if (!resolvedCustomPlanner) {\n throw new Error(\n 'Custom planning tap locator requires a custom planning planner definition',\n );\n }\n locateFn = resolvePlanningTapLocator(\n planningTapLocator,\n resolvedCustomPlanner,\n );\n }\n\n return {\n kind: 'custom',\n locateFn,\n };\n }\n\n const elementProtocol = resolveLocateProtocolDefinition(\n locate?.element?.protocol ?? createDefaultElementProtocol,\n protocolContext,\n );\n const elementResultFormat =\n locate?.element?.resultFormat ?? defaultLocateResultFormatDefinition;\n const elementResultCodec = createLocateResultCodec(elementResultFormat);\n const searchAreaProtocol =\n locate?.searchArea === false\n ? undefined\n : resolveLocateProtocolDefinition(\n locate?.searchArea?.protocol ?? createDefaultSearchAreaProtocol,\n protocolContext,\n );\n const searchAreaResultFormat =\n locate?.searchArea === false\n ? undefined\n : (locate?.searchArea?.resultFormat ?? elementResultFormat);\n const searchAreaResultCodec = searchAreaResultFormat\n ? createLocateResultCodec(searchAreaResultFormat)\n : undefined;\n\n return {\n kind: 'standard',\n promptOrder: parseLocatePromptOrder(locate?.promptOrder),\n element: {\n protocol: elementProtocol,\n resultCodec: elementResultCodec,\n },\n ...(searchAreaProtocol && searchAreaResultCodec\n ? {\n searchArea: {\n protocol: searchAreaProtocol,\n resultCodec: searchAreaResultCodec,\n },\n }\n : {}),\n };\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","defaultLocateResultFormatDefinition","resolveLocateProtocolDefinition","protocolDefinition","protocolContext","resolveLocate","locate","resolvedCustomPlanner","locateFn","planningTapLocator","Error","resolvePlanningTapLocator","elementProtocol","createDefaultElementProtocol","elementResultFormat","elementResultCodec","createLocateResultCodec","searchAreaProtocol","undefined","createDefaultSearchAreaProtocol","searchAreaResultFormat","searchAreaResultCodec","parseLocatePromptOrder"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CA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AAMG,qBACJX,QAAQ,eAAe,QACnBY,SACAhB,gCACEI,QAAQ,YAAY,YAAYa,oDAAAA,+BAA+BA,EAC/Df;IAER,MAAMgB,yBACJd,QAAQ,eAAe,QACnBY,SACCZ,QAAQ,YAAY,gBAAgBQ;IAC3C,MAAMO,wBAAwBD,yBAC1BJ,AAAAA,IAAAA,2BAAAA,uBAAAA,AAAAA,EAAwBI,0BACxBF;IAEJ,OAAO;QACL,MAAM;QACN,aAAaI,AAAAA,IAAAA,gDAAAA,sBAAAA,AAAAA,EAAuBhB,QAAQ;QAC5C,SAAS;YACP,UAAUM;YACV,aAAaG;QACf;QACA,GAAIE,sBAAsBI,wBACtB;YACE,YAAY;gBACV,UAAUJ;gBACV,aAAaI;YACf;QACF,IACA,CAAC,CAAC;IACR;AACF"}
@@ -114,7 +114,7 @@ async function genericLocate(locateRequest) {
114
114
  locateImage: locateRequest.locateImage,
115
115
  imagePreprocess: adapter.imagePreprocess,
116
116
  targetDescription: targetElementDescription,
117
- userMessageContentOrder: adapter.locate.userMessageContentOrder
117
+ promptOrder: adapter.locate.promptOrder
118
118
  });
119
119
  try {
120
120
  return await (0, semantic_retry_js_namespaceObject.callAiAndParseWithRetry)({
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/workflows/grounding/locate.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/workflows/grounding/locate.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { getDebug } from '@midscene/shared/logger';\nimport { assert } from '@midscene/shared/utils';\nimport type { TUserPrompt } from '../../../common';\nimport { userPromptToString } from '../../../common';\nimport { buildElementLocateSystemPrompt } from '../../prompt/locate';\nimport {\n AIResponseParseError,\n callGenerativeAI,\n} from '../../service-caller/index';\nimport {\n callAiAndParseWithRetry,\n withSemanticRetryFeedback,\n} from '../../service-caller/semantic-retry';\nimport { mapSearchAreaResultToOriginalResult } from './search-area-mapping';\nimport type {\n LocateModelResponse,\n LocateOptions,\n LocateRequest,\n LocateResult,\n} from './types';\nimport { formatLocateModelContext, prepareLocateModelInput } from './utils';\n\nconst debugGrounding = getDebug('ai:grounding');\n\nexport { userPromptToString as extraTextFromUserPrompt } from '../../../common';\n\nexport async function AiLocateElement(\n options: LocateOptions & { targetElementDescription: TUserPrompt },\n): Promise<LocateResult> {\n const { targetElementDescription, ...locateOptions } = options;\n assert(\n targetElementDescription,\n 'cannot find the target element description',\n );\n\n const { context } = locateOptions;\n const locateImage = locateOptions.searchConfig?.image ?? {\n imageBase64: context.screenshot.base64,\n width: context.shotSize.width,\n height: context.shotSize.height,\n };\n const locateRequest: LocateRequest = {\n targetElementDescription,\n locateImage,\n options: locateOptions,\n };\n\n const locateAdapter = options.modelRuntime.adapter.locate;\n const locateFn =\n locateAdapter.kind === 'custom' ? locateAdapter.locateFn : genericLocate;\n const locateResponse = await locateFn(locateRequest);\n const {\n locatedPixelResult,\n rawResponse,\n rawAssistantOutput,\n usage,\n reasoningContent,\n errors = [],\n } = locateResponse;\n const baseLocateResult = {\n rawResponse,\n rawAssistantOutput,\n usage,\n reasoning_content: reasoningContent,\n };\n\n if (!locatedPixelResult) {\n return {\n parseResult: {\n element: undefined,\n errors,\n },\n ...baseLocateResult,\n };\n }\n\n try {\n const mappedResult = mapSearchAreaResultToOriginalResult(\n locatedPixelResult,\n locateOptions.searchConfig?.mapping,\n );\n debugGrounding('center', mappedResult.center);\n\n return {\n parseResult: {\n element: {\n ...mappedResult,\n description: userPromptToString(targetElementDescription),\n },\n errors: [],\n },\n ...baseLocateResult,\n };\n } catch (error) {\n const msg =\n error instanceof Error\n ? `Failed to parse locate result: ${error.message}`\n : 'unknown error in locate';\n return {\n parseResult: {\n element: undefined,\n errors: errors.length > 0 ? [...errors, `(${msg})`] : [msg],\n },\n ...baseLocateResult,\n };\n }\n}\n\nexport async function genericLocate(\n locateRequest: LocateRequest,\n): Promise<LocateModelResponse> {\n const { options, targetElementDescription } = locateRequest;\n const modelRuntime = options.modelRuntime;\n const { adapter } = modelRuntime;\n assert(\n adapter.locate.kind === 'standard',\n 'generic locate requires a standard locate adapter',\n );\n const { protocol, resultCodec } = adapter.locate.element;\n\n const systemPrompt = buildElementLocateSystemPrompt({\n systemPromptIntroduction: protocol.systemPromptIntroduction,\n responseInstructions: protocol.buildResponseInstructions(\n resultCodec.promptSpec,\n ),\n });\n\n const userInstructionPrompt = protocol.buildUserPrompt(\n userPromptToString(targetElementDescription),\n );\n\n const { messages, preparedImage } = await prepareLocateModelInput({\n systemPrompt,\n userPrompt: userInstructionPrompt,\n locateImage: locateRequest.locateImage,\n imagePreprocess: adapter.imagePreprocess,\n targetDescription: targetElementDescription,\n userMessageContentOrder: adapter.locate.userMessageContentOrder,\n });\n\n try {\n return await callAiAndParseWithRetry({\n callAi: (retryAttempt, previousParseError) =>\n callGenerativeAI(\n withSemanticRetryFeedback(messages, previousParseError),\n modelRuntime,\n {\n abortSignal: options.abortSignal,\n expectedJsonObjectResponse: protocol.expectedJsonObjectResponse,\n semanticRetryAttempt: retryAttempt,\n },\n ),\n parseResponse: (response): LocateModelResponse => {\n const parsedLocateResult = protocol.parseRawResponse(\n response.content,\n resultCodec.promptSpec,\n );\n const rawResponse = response.content;\n const locateError = parsedLocateResult.error;\n if (parsedLocateResult.kind === 'not-found') {\n return {\n rawResponse,\n rawAssistantOutput: response.rawAssistantOutput,\n usage: response.usage,\n reasoningContent: response.reasoning_content,\n errors: locateError ? [locateError] : [],\n };\n }\n\n try {\n const result = resultCodec.toPixelResult(parsedLocateResult.target, {\n preparedSize: preparedImage.preparedSize,\n contentSize: preparedImage.contentSize,\n });\n return {\n locatedPixelResult: result,\n rawResponse,\n rawAssistantOutput: response.rawAssistantOutput,\n usage: response.usage,\n reasoningContent: response.reasoning_content,\n errors: [],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n const message = [\n locateError && `error in locate result: ${locateError}`,\n `coordinate parsing error: ${errorMessage}`,\n formatLocateModelContext(modelRuntime),\n ]\n .filter(Boolean)\n .join('\\n');\n throw new Error(message, { cause: error });\n }\n },\n toParseError: (error, response) => {\n const parseErrorMessage =\n error instanceof Error\n ? `Failed to parse locate result: ${error.message}`\n : 'unknown error in locate result';\n return new AIResponseParseError(\n parseErrorMessage,\n response.content,\n response.usage,\n response.rawAssistantOutput,\n response.reasoning_content,\n );\n },\n parseRetryTimes: modelRuntime.config.retryCount,\n parseRetryInterval: modelRuntime.config.retryInterval,\n abortSignal: options.abortSignal,\n onParseRetry: (error) => {\n debugGrounding(\n 'retrying locate after coordinate parsing failed: %s',\n error instanceof Error ? error.message : String(error),\n );\n },\n });\n } catch (callError) {\n if (callError instanceof AIResponseParseError) {\n return {\n rawResponse: callError.rawResponse,\n rawAssistantOutput: callError.rawAssistantOutput,\n usage: callError.usage,\n reasoningContent: callError.reasoningContent,\n errors: [callError.message],\n };\n }\n\n const errorMessage =\n callError instanceof Error ? callError.message : String(callError);\n return {\n rawResponse: errorMessage,\n errors: [`AI call error: ${errorMessage}`],\n };\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","debugGrounding","getDebug","AiLocateElement","options","targetElementDescription","locateOptions","assert","context","locateImage","locateRequest","locateAdapter","locateFn","genericLocate","locateResponse","locatedPixelResult","rawResponse","rawAssistantOutput","usage","reasoningContent","errors","baseLocateResult","undefined","mappedResult","mapSearchAreaResultToOriginalResult","userPromptToString","error","msg","Error","modelRuntime","adapter","protocol","resultCodec","systemPrompt","buildElementLocateSystemPrompt","userInstructionPrompt","messages","preparedImage","prepareLocateModelInput","callAiAndParseWithRetry","retryAttempt","previousParseError","callGenerativeAI","withSemanticRetryFeedback","response","parsedLocateResult","locateError","result","errorMessage","String","message","formatLocateModelContext","Boolean","parseErrorMessage","AIResponseParseError","callError"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;;;;ACgBA,MAAMI,iBAAiBC,AAAAA,IAAAA,uBAAAA,QAAAA,AAAAA,EAAS;AAIzB,eAAeC,gBACpBC,OAAkE;IAElE,MAAM,EAAEC,wBAAwB,EAAE,GAAGC,eAAe,GAAGF;IACvDG,IAAAA,sBAAAA,MAAAA,AAAAA,EACEF,0BACA;IAGF,MAAM,EAAEG,OAAO,EAAE,GAAGF;IACpB,MAAMG,cAAcH,cAAc,YAAY,EAAE,SAAS;QACvD,aAAaE,QAAQ,UAAU,CAAC,MAAM;QACtC,OAAOA,QAAQ,QAAQ,CAAC,KAAK;QAC7B,QAAQA,QAAQ,QAAQ,CAAC,MAAM;IACjC;IACA,MAAME,gBAA+B;QACnCL;Q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B,WAAW;QAClB,IAAIA,qBAAqBD,iDAAAA,oBAAoBA,EAC3C,OAAO;YACL,aAAaC,UAAU,WAAW;YAClC,oBAAoBA,UAAU,kBAAkB;YAChD,OAAOA,UAAU,KAAK;YACtB,kBAAkBA,UAAU,gBAAgB;YAC5C,QAAQ;gBAACA,UAAU,OAAO;aAAC;QAC7B;QAGF,MAAMP,eACJO,qBAAqB3B,QAAQ2B,UAAU,OAAO,GAAGN,OAAOM;QAC1D,OAAO;YACL,aAAaP;YACb,QAAQ;gBAAC,CAAC,eAAe,EAAEA,cAAc;aAAC;QAC5C;IACF;AACF"}
1
+ {"version":3,"file":"ai-model/workflows/grounding/locate.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/workflows/grounding/locate.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { getDebug } from '@midscene/shared/logger';\nimport { assert } from '@midscene/shared/utils';\nimport type { TUserPrompt } from '../../../common';\nimport { userPromptToString } from '../../../common';\nimport { buildElementLocateSystemPrompt } from '../../prompt/locate';\nimport {\n AIResponseParseError,\n callGenerativeAI,\n} from '../../service-caller/index';\nimport {\n callAiAndParseWithRetry,\n withSemanticRetryFeedback,\n} from '../../service-caller/semantic-retry';\nimport { mapSearchAreaResultToOriginalResult } from './search-area-mapping';\nimport type {\n LocateModelResponse,\n LocateOptions,\n LocateRequest,\n LocateResult,\n} from './types';\nimport { formatLocateModelContext, prepareLocateModelInput } from './utils';\n\nconst debugGrounding = getDebug('ai:grounding');\n\nexport { userPromptToString as extraTextFromUserPrompt } from '../../../common';\n\nexport async function AiLocateElement(\n options: LocateOptions & { targetElementDescription: TUserPrompt },\n): Promise<LocateResult> {\n const { targetElementDescription, ...locateOptions } = options;\n assert(\n targetElementDescription,\n 'cannot find the target element description',\n );\n\n const { context } = locateOptions;\n const locateImage = locateOptions.searchConfig?.image ?? {\n imageBase64: context.screenshot.base64,\n width: context.shotSize.width,\n height: context.shotSize.height,\n };\n const locateRequest: LocateRequest = {\n targetElementDescription,\n locateImage,\n options: locateOptions,\n };\n\n const locateAdapter = options.modelRuntime.adapter.locate;\n const locateFn =\n locateAdapter.kind === 'custom' ? locateAdapter.locateFn : genericLocate;\n const locateResponse = await locateFn(locateRequest);\n const {\n locatedPixelResult,\n rawResponse,\n rawAssistantOutput,\n usage,\n reasoningContent,\n errors = [],\n } = locateResponse;\n const baseLocateResult = {\n rawResponse,\n rawAssistantOutput,\n usage,\n reasoning_content: reasoningContent,\n };\n\n if (!locatedPixelResult) {\n return {\n parseResult: {\n element: undefined,\n errors,\n },\n ...baseLocateResult,\n };\n }\n\n try {\n const mappedResult = mapSearchAreaResultToOriginalResult(\n locatedPixelResult,\n locateOptions.searchConfig?.mapping,\n );\n debugGrounding('center', mappedResult.center);\n\n return {\n parseResult: {\n element: {\n ...mappedResult,\n description: userPromptToString(targetElementDescription),\n },\n errors: [],\n },\n ...baseLocateResult,\n };\n } catch (error) {\n const msg =\n error instanceof Error\n ? `Failed to parse locate result: ${error.message}`\n : 'unknown error in locate';\n return {\n parseResult: {\n element: undefined,\n errors: errors.length > 0 ? [...errors, `(${msg})`] : [msg],\n },\n ...baseLocateResult,\n };\n }\n}\n\nexport async function genericLocate(\n locateRequest: LocateRequest,\n): Promise<LocateModelResponse> {\n const { options, targetElementDescription } = locateRequest;\n const modelRuntime = options.modelRuntime;\n const { adapter } = modelRuntime;\n assert(\n adapter.locate.kind === 'standard',\n 'generic locate requires a standard locate adapter',\n );\n const { protocol, resultCodec } = adapter.locate.element;\n\n const systemPrompt = buildElementLocateSystemPrompt({\n systemPromptIntroduction: protocol.systemPromptIntroduction,\n responseInstructions: protocol.buildResponseInstructions(\n resultCodec.promptSpec,\n ),\n });\n\n const userInstructionPrompt = protocol.buildUserPrompt(\n userPromptToString(targetElementDescription),\n );\n\n const { messages, preparedImage } = await prepareLocateModelInput({\n systemPrompt,\n userPrompt: userInstructionPrompt,\n locateImage: locateRequest.locateImage,\n imagePreprocess: adapter.imagePreprocess,\n targetDescription: targetElementDescription,\n promptOrder: adapter.locate.promptOrder,\n });\n\n try {\n return await callAiAndParseWithRetry({\n callAi: (retryAttempt, previousParseError) =>\n callGenerativeAI(\n withSemanticRetryFeedback(messages, previousParseError),\n modelRuntime,\n {\n abortSignal: options.abortSignal,\n expectedJsonObjectResponse: protocol.expectedJsonObjectResponse,\n semanticRetryAttempt: retryAttempt,\n },\n ),\n parseResponse: (response): LocateModelResponse => {\n const parsedLocateResult = protocol.parseRawResponse(\n response.content,\n resultCodec.promptSpec,\n );\n const rawResponse = response.content;\n const locateError = parsedLocateResult.error;\n if (parsedLocateResult.kind === 'not-found') {\n return {\n rawResponse,\n rawAssistantOutput: response.rawAssistantOutput,\n usage: response.usage,\n reasoningContent: response.reasoning_content,\n errors: locateError ? [locateError] : [],\n };\n }\n\n try {\n const result = resultCodec.toPixelResult(parsedLocateResult.target, {\n preparedSize: preparedImage.preparedSize,\n contentSize: preparedImage.contentSize,\n });\n return {\n locatedPixelResult: result,\n rawResponse,\n rawAssistantOutput: response.rawAssistantOutput,\n usage: response.usage,\n reasoningContent: response.reasoning_content,\n errors: [],\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n const message = [\n locateError && `error in locate result: ${locateError}`,\n `coordinate parsing error: ${errorMessage}`,\n formatLocateModelContext(modelRuntime),\n ]\n .filter(Boolean)\n .join('\\n');\n throw new Error(message, { cause: error });\n }\n },\n toParseError: (error, response) => {\n const parseErrorMessage =\n error instanceof Error\n ? `Failed to parse locate result: ${error.message}`\n : 'unknown error in locate result';\n return new AIResponseParseError(\n parseErrorMessage,\n response.content,\n response.usage,\n response.rawAssistantOutput,\n response.reasoning_content,\n );\n },\n parseRetryTimes: modelRuntime.config.retryCount,\n parseRetryInterval: modelRuntime.config.retryInterval,\n abortSignal: options.abortSignal,\n onParseRetry: (error) => {\n debugGrounding(\n 'retrying locate after coordinate parsing failed: %s',\n error instanceof Error ? error.message : String(error),\n );\n },\n });\n } catch (callError) {\n if (callError instanceof AIResponseParseError) {\n return {\n rawResponse: callError.rawResponse,\n rawAssistantOutput: callError.rawAssistantOutput,\n usage: callError.usage,\n reasoningContent: callError.reasoningContent,\n errors: [callError.message],\n };\n }\n\n const errorMessage =\n callError instanceof Error ? callError.message : String(callError);\n return {\n rawResponse: errorMessage,\n errors: [`AI call error: ${errorMessage}`],\n };\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","debugGrounding","getDebug","AiLocateElement","options","targetElementDescription","locateOptions","assert","context","locateImage","locateRequest","locateAdapter","locateFn","genericLocate","locateResponse","locatedPixelResult","rawResponse","rawAssistantOutput","usage","reasoningContent","errors","baseLocateResult","undefined","mappedResult","mapSearchAreaResultToOriginalResult","userPromptToString","error","msg","Error","modelRuntime","adapter","protocol","resultCodec","systemPrompt","buildElementLocateSystemPrompt","userInstructionPrompt","messages","preparedImage","prepareLocateModelInput","callAiAndParseWithRetry","retryAttempt","previousParseError","callGenerativeAI","withSemanticRetryFeedback","response","parsedLocateResult","locateError","result","errorMessage","String","message","formatLocateModelContext","Boolean","parseErrorMessage","AIResponseParseError","callError"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD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@@ async function AiLocateSection(options) {
59
59
  },
60
60
  imagePreprocess: adapter.imagePreprocess,
61
61
  targetDescription: sectionDescription,
62
- userMessageContentOrder: adapter.locate.userMessageContentOrder
62
+ promptOrder: adapter.locate.promptOrder
63
63
  });
64
64
  let parsedResult;
65
65
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/workflows/grounding/section-locate.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/workflows/grounding/section-locate.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { RawAssistantOutput } from '@/types';\nimport type { AIUsageInfo, Rect, UIContext } from '@/types';\nimport { getDebug } from '@midscene/shared/logger';\nimport { assert } from '@midscene/shared/utils';\nimport type { TUserPrompt } from '../../../common';\nimport { userPromptToString } from '../../../common';\nimport type { ModelRuntime } from '../../models';\nimport { buildSearchAreaLocateSystemPrompt } from '../../prompt/locate';\nimport {\n AIResponseParseError,\n callGenerativeAI,\n} from '../../service-caller/index';\nimport {\n callAiAndParseWithRetry,\n withSemanticRetryFeedback,\n} from '../../service-caller/semantic-retry';\nimport {\n buildSearchAreaConfig,\n expandSearchArea,\n mergeSearchAreaResults,\n} from './search-area';\nimport type { SearchAreaConfig } from './types';\nimport { formatLocateModelContext, prepareLocateModelInput } from './utils';\n\nconst debugSection = getDebug('ai:grounding:section');\n\ntype SectionLocateRawResponse = Awaited<ReturnType<typeof callGenerativeAI>>;\n\nexport async function AiLocateSection(options: {\n context: UIContext;\n sectionDescription: TUserPrompt;\n modelRuntime: ModelRuntime;\n abortSignal?: AbortSignal;\n}): Promise<{\n searchAreaConfig?: SearchAreaConfig;\n error?: string;\n rawResponse: string;\n rawAssistantOutput?: RawAssistantOutput;\n usage?: AIUsageInfo;\n}> {\n const { context, sectionDescription } = options;\n const modelRuntime = options.modelRuntime;\n const { adapter } = modelRuntime;\n assert(\n adapter.locate.kind === 'standard',\n 'section locate requires a standard locate adapter',\n );\n const searchArea = adapter.locate.searchArea;\n assert(searchArea, 'section locate requires a search area operation');\n const { protocol: searchAreaProtocol, resultCodec } = searchArea;\n const screenshotBase64 = context.screenshot.base64;\n\n const systemPrompt = buildSearchAreaLocateSystemPrompt({\n systemPromptIntroduction: searchAreaProtocol.systemPromptIntroduction,\n responseInstructions: searchAreaProtocol.buildResponseInstructions(\n resultCodec.promptSpec,\n ),\n });\n\n const userInstructionPrompt = searchAreaProtocol.buildUserPrompt(\n userPromptToString(sectionDescription),\n );\n\n const { messages, preparedImage } = await prepareLocateModelInput({\n systemPrompt,\n userPrompt: userInstructionPrompt,\n locateImage: {\n imageBase64: screenshotBase64,\n width: context.shotSize.width,\n height: context.shotSize.height,\n },\n imagePreprocess: adapter.imagePreprocess,\n targetDescription: sectionDescription,\n userMessageContentOrder: adapter.locate.userMessageContentOrder,\n });\n\n let parsedResult:\n | {\n result: SectionLocateRawResponse;\n sectionError?: string;\n mergedRect?: undefined;\n }\n | {\n result: SectionLocateRawResponse;\n sectionError?: string;\n mergedRect: Rect;\n };\n\n try {\n parsedResult = await callAiAndParseWithRetry({\n callAi: (retryAttempt, previousParseError) =>\n callGenerativeAI(\n withSemanticRetryFeedback(messages, previousParseError),\n modelRuntime,\n {\n abortSignal: options.abortSignal,\n expectedJsonObjectResponse:\n searchAreaProtocol.expectedJsonObjectResponse,\n semanticRetryAttempt: retryAttempt,\n },\n ),\n parseResponse: (response) => {\n const parsedLocateResult = searchAreaProtocol.parseRawResponse(\n response.content,\n resultCodec.promptSpec,\n );\n const sectionError = parsedLocateResult.error;\n if (parsedLocateResult.kind === 'not-found') {\n return { result: response, sectionError };\n }\n\n try {\n const locateResultContext = {\n preparedSize: preparedImage.preparedSize,\n contentSize: preparedImage.contentSize,\n };\n const target = resultCodec.toPixelResult(\n parsedLocateResult.target,\n locateResultContext,\n );\n const references = parsedLocateResult.references?.map((reference) =>\n resultCodec.toPixelResult(reference, locateResultContext),\n );\n const mergedRect = mergeSearchAreaResults(target, references);\n debugSection('mergedRect %j', mergedRect);\n return {\n result: response,\n sectionError,\n mergedRect,\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n const message = [\n sectionError && `error in section locate result: ${sectionError}`,\n `coordinate parsing error: ${errorMessage}`,\n formatLocateModelContext(modelRuntime),\n ]\n .filter(Boolean)\n .join('\\n');\n throw new Error(message, { cause: error });\n }\n },\n toParseError: (error, response) => {\n const parseErrorMessage =\n error instanceof Error\n ? `Failed to parse section locate result: ${error.message}`\n : 'unknown error in section locate';\n return new AIResponseParseError(\n parseErrorMessage,\n response.content,\n response.usage,\n response.rawAssistantOutput,\n response.reasoning_content,\n );\n },\n parseRetryTimes: modelRuntime.config.retryCount,\n parseRetryInterval: modelRuntime.config.retryInterval,\n abortSignal: options.abortSignal,\n onParseRetry: (error) => {\n debugSection(\n 'retrying section locate after coordinate parsing failed: %s',\n error instanceof Error ? error.message : String(error),\n );\n },\n });\n } catch (callError) {\n if (callError instanceof AIResponseParseError) {\n return {\n searchAreaConfig: undefined,\n error: callError.message,\n rawResponse: callError.rawResponse,\n rawAssistantOutput: callError.rawAssistantOutput,\n usage: callError.usage,\n };\n }\n\n const errorMessage =\n callError instanceof Error ? callError.message : String(callError);\n return {\n searchAreaConfig: undefined,\n error: `AI call error: ${errorMessage}`,\n rawResponse: errorMessage,\n };\n }\n\n const { result, sectionError, mergedRect } = parsedResult;\n if (!mergedRect) {\n return {\n searchAreaConfig: undefined,\n error: sectionError,\n rawResponse: result.content,\n rawAssistantOutput: result.rawAssistantOutput,\n usage: result.usage,\n };\n }\n\n try {\n const expandedRect = expandSearchArea(mergedRect, context.shotSize);\n const originalWidth = expandedRect.width;\n const originalHeight = expandedRect.height;\n debugSection('expanded sectionRect %j', expandedRect);\n\n const searchAreaConfig = await buildSearchAreaConfig({\n context,\n baseRect: mergedRect,\n });\n\n debugSection(\n 'scaled section image from %dx%d to %dx%d (scale=%d)',\n originalWidth,\n originalHeight,\n searchAreaConfig.image.width,\n searchAreaConfig.image.height,\n searchAreaConfig.mapping.scale,\n );\n return {\n searchAreaConfig,\n error: sectionError,\n rawResponse: result.content,\n rawAssistantOutput: result.rawAssistantOutput,\n usage: result.usage,\n };\n } catch (error) {\n const parseErrorMessage =\n error instanceof Error\n ? `Failed to parse section locate result: ${error.message}`\n : 'unknown error in section locate';\n const errorMessage = sectionError\n ? `${sectionError} (${parseErrorMessage})`\n : parseErrorMessage;\n return {\n searchAreaConfig: undefined,\n error: errorMessage,\n rawResponse: result.content,\n rawAssistantOutput: result.rawAssistantOutput,\n usage: result.usage,\n };\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","debugSection","getDebug","AiLocateSection","options","context","sectionDescription","modelRuntime","adapter","assert","searchArea","searchAreaProtocol","resultCodec","screenshotBase64","systemPrompt","buildSearchAreaLocateSystemPrompt","userInstructionPrompt","userPromptToString","messages","preparedImage","prepareLocateModelInput","parsedResult","callAiAndParseWithRetry","retryAttempt","previousParseError","callGenerativeAI","withSemanticRetryFeedback","response","parsedLocateResult","sectionError","locateResultContext","target","references","reference","mergedRect","mergeSearchAreaResults","error","errorMessage","Error","String","message","formatLocateModelContext","Boolean","parseErrorMessage","AIResponseParseError","callError","undefined","result","expandedRect","expandSearchArea","originalWidth","originalHeight","searchAreaConfig","buildSearchAreaConfig"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBA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IAEA,MAAM,EAAEU,MAAM,EAAElB,YAAY,EAAEK,UAAU,EAAE,GAAGb;IAC7C,IAAI,CAACa,YACH,OAAO;QACL,kBAAkBY;QAClB,OAAOjB;QACP,aAAakB,OAAO,OAAO;QAC3B,oBAAoBA,OAAO,kBAAkB;QAC7C,OAAOA,OAAO,KAAK;IACrB;IAGF,IAAI;QACF,MAAMC,eAAeC,AAAAA,IAAAA,wCAAAA,gBAAAA,AAAAA,EAAiBf,YAAY7B,QAAQ,QAAQ;QAClE,MAAM6C,gBAAgBF,aAAa,KAAK;QACxC,MAAMG,iBAAiBH,aAAa,MAAM;QAC1C/C,aAAa,2BAA2B+C;QAExC,MAAMI,mBAAmB,MAAMC,AAAAA,IAAAA,wCAAAA,qBAAAA,AAAAA,EAAsB;YACnDhD;YACA,UAAU6B;QACZ;QAEAjC,aACE,uDACAiD,eACAC,gBACAC,iBAAiB,KAAK,CAAC,KAAK,EAC5BA,iBAAiB,KAAK,CAAC,MAAM,EAC7BA,iBAAiB,OAAO,CAAC,KAAK;QAEhC,OAAO;YACLA;YACA,OAAOvB;YACP,aAAakB,OAAO,OAAO;YAC3B,oBAAoBA,OAAO,kBAAkB;YAC7C,OAAOA,OAAO,KAAK;QACrB;IACF,EAAE,OAAOX,OAAO;QACd,MAAMO,oBACJP,iBAAiBE,QACb,CAAC,uCAAuC,EAAEF,MAAM,OAAO,EAAE,GACzD;QACN,MAAMC,eAAeR,eACjB,GAAGA,aAAa,EAAE,EAAEc,kBAAkB,CAAC,CAAC,GACxCA;QACJ,OAAO;YACL,kBAAkBG;YAClB,OAAOT;YACP,aAAaU,OAAO,OAAO;YAC3B,oBAAoBA,OAAO,kBAAkB;YAC7C,OAAOA,OAAO,KAAK;QACrB;IACF;AACF"}
1
+ {"version":3,"file":"ai-model/workflows/grounding/section-locate.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/workflows/grounding/section-locate.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { RawAssistantOutput } from '@/types';\nimport type { AIUsageInfo, Rect, UIContext } from '@/types';\nimport { getDebug } from '@midscene/shared/logger';\nimport { assert } from '@midscene/shared/utils';\nimport type { TUserPrompt } from '../../../common';\nimport { userPromptToString } from '../../../common';\nimport type { ModelRuntime } from '../../models';\nimport { buildSearchAreaLocateSystemPrompt } from '../../prompt/locate';\nimport {\n AIResponseParseError,\n callGenerativeAI,\n} from '../../service-caller/index';\nimport {\n callAiAndParseWithRetry,\n withSemanticRetryFeedback,\n} from '../../service-caller/semantic-retry';\nimport {\n buildSearchAreaConfig,\n expandSearchArea,\n mergeSearchAreaResults,\n} from './search-area';\nimport type { SearchAreaConfig } from './types';\nimport { formatLocateModelContext, prepareLocateModelInput } from './utils';\n\nconst debugSection = getDebug('ai:grounding:section');\n\ntype SectionLocateRawResponse = Awaited<ReturnType<typeof callGenerativeAI>>;\n\nexport async function AiLocateSection(options: {\n context: UIContext;\n sectionDescription: TUserPrompt;\n modelRuntime: ModelRuntime;\n abortSignal?: AbortSignal;\n}): Promise<{\n searchAreaConfig?: SearchAreaConfig;\n error?: string;\n rawResponse: string;\n rawAssistantOutput?: RawAssistantOutput;\n usage?: AIUsageInfo;\n}> {\n const { context, sectionDescription } = options;\n const modelRuntime = options.modelRuntime;\n const { adapter } = modelRuntime;\n assert(\n adapter.locate.kind === 'standard',\n 'section locate requires a standard locate adapter',\n );\n const searchArea = adapter.locate.searchArea;\n assert(searchArea, 'section locate requires a search area operation');\n const { protocol: searchAreaProtocol, resultCodec } = searchArea;\n const screenshotBase64 = context.screenshot.base64;\n\n const systemPrompt = buildSearchAreaLocateSystemPrompt({\n systemPromptIntroduction: searchAreaProtocol.systemPromptIntroduction,\n responseInstructions: searchAreaProtocol.buildResponseInstructions(\n resultCodec.promptSpec,\n ),\n });\n\n const userInstructionPrompt = searchAreaProtocol.buildUserPrompt(\n userPromptToString(sectionDescription),\n );\n\n const { messages, preparedImage } = await prepareLocateModelInput({\n systemPrompt,\n userPrompt: userInstructionPrompt,\n locateImage: {\n imageBase64: screenshotBase64,\n width: context.shotSize.width,\n height: context.shotSize.height,\n },\n imagePreprocess: adapter.imagePreprocess,\n targetDescription: sectionDescription,\n promptOrder: adapter.locate.promptOrder,\n });\n\n let parsedResult:\n | {\n result: SectionLocateRawResponse;\n sectionError?: string;\n mergedRect?: undefined;\n }\n | {\n result: SectionLocateRawResponse;\n sectionError?: string;\n mergedRect: Rect;\n };\n\n try {\n parsedResult = await callAiAndParseWithRetry({\n callAi: (retryAttempt, previousParseError) =>\n callGenerativeAI(\n withSemanticRetryFeedback(messages, previousParseError),\n modelRuntime,\n {\n abortSignal: options.abortSignal,\n expectedJsonObjectResponse:\n searchAreaProtocol.expectedJsonObjectResponse,\n semanticRetryAttempt: retryAttempt,\n },\n ),\n parseResponse: (response) => {\n const parsedLocateResult = searchAreaProtocol.parseRawResponse(\n response.content,\n resultCodec.promptSpec,\n );\n const sectionError = parsedLocateResult.error;\n if (parsedLocateResult.kind === 'not-found') {\n return { result: response, sectionError };\n }\n\n try {\n const locateResultContext = {\n preparedSize: preparedImage.preparedSize,\n contentSize: preparedImage.contentSize,\n };\n const target = resultCodec.toPixelResult(\n parsedLocateResult.target,\n locateResultContext,\n );\n const references = parsedLocateResult.references?.map((reference) =>\n resultCodec.toPixelResult(reference, locateResultContext),\n );\n const mergedRect = mergeSearchAreaResults(target, references);\n debugSection('mergedRect %j', mergedRect);\n return {\n result: response,\n sectionError,\n mergedRect,\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n const message = [\n sectionError && `error in section locate result: ${sectionError}`,\n `coordinate parsing error: ${errorMessage}`,\n formatLocateModelContext(modelRuntime),\n ]\n .filter(Boolean)\n .join('\\n');\n throw new Error(message, { cause: error });\n }\n },\n toParseError: (error, response) => {\n const parseErrorMessage =\n error instanceof Error\n ? `Failed to parse section locate result: ${error.message}`\n : 'unknown error in section locate';\n return new AIResponseParseError(\n parseErrorMessage,\n response.content,\n response.usage,\n response.rawAssistantOutput,\n response.reasoning_content,\n );\n },\n parseRetryTimes: modelRuntime.config.retryCount,\n parseRetryInterval: modelRuntime.config.retryInterval,\n abortSignal: options.abortSignal,\n onParseRetry: (error) => {\n debugSection(\n 'retrying section locate after coordinate parsing failed: %s',\n error instanceof Error ? error.message : String(error),\n );\n },\n });\n } catch (callError) {\n if (callError instanceof AIResponseParseError) {\n return {\n searchAreaConfig: undefined,\n error: callError.message,\n rawResponse: callError.rawResponse,\n rawAssistantOutput: callError.rawAssistantOutput,\n usage: callError.usage,\n };\n }\n\n const errorMessage =\n callError instanceof Error ? callError.message : String(callError);\n return {\n searchAreaConfig: undefined,\n error: `AI call error: ${errorMessage}`,\n rawResponse: errorMessage,\n };\n }\n\n const { result, sectionError, mergedRect } = parsedResult;\n if (!mergedRect) {\n return {\n searchAreaConfig: undefined,\n error: sectionError,\n rawResponse: result.content,\n rawAssistantOutput: result.rawAssistantOutput,\n usage: result.usage,\n };\n }\n\n try {\n const expandedRect = expandSearchArea(mergedRect, context.shotSize);\n const originalWidth = expandedRect.width;\n const originalHeight = expandedRect.height;\n debugSection('expanded sectionRect %j', expandedRect);\n\n const searchAreaConfig = await buildSearchAreaConfig({\n context,\n baseRect: mergedRect,\n });\n\n debugSection(\n 'scaled section image from %dx%d to %dx%d (scale=%d)',\n originalWidth,\n originalHeight,\n searchAreaConfig.image.width,\n searchAreaConfig.image.height,\n searchAreaConfig.mapping.scale,\n );\n return {\n searchAreaConfig,\n error: sectionError,\n rawResponse: result.content,\n rawAssistantOutput: result.rawAssistantOutput,\n usage: result.usage,\n };\n } catch (error) {\n const parseErrorMessage =\n error instanceof Error\n ? `Failed to parse section locate result: ${error.message}`\n : 'unknown error in section locate';\n const errorMessage = sectionError\n ? `${sectionError} (${parseErrorMessage})`\n : parseErrorMessage;\n return {\n searchAreaConfig: undefined,\n error: errorMessage,\n rawResponse: result.content,\n rawAssistantOutput: result.rawAssistantOutput,\n usage: result.usage,\n };\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","debugSection","getDebug","AiLocateSection","options","context","sectionDescription","modelRuntime","adapter","assert","searchArea","searchAreaProtocol","resultCodec","screenshotBase64","systemPrompt","buildSearchAreaLocateSystemPrompt","userInstructionPrompt","userPromptToString","messages","preparedImage","prepareLocateModelInput","parsedResult","callAiAndParseWithRetry","retryAttempt","previousParseError","callGenerativeAI","withSemanticRetryFeedback","response","parsedLocateResult","sectionError","locateResultContext","target","references","reference","mergedRect","mergeSearchAreaResults","error","errorMessage","Error","String","message","formatLocateModelContext","Boolean","parseErrorMessage","AIResponseParseError","callError","undefined","result","expandedRect","expandSearchArea","originalWidth","originalHeight","searchAreaConfig","buildSearchAreaConfig"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,E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