@midscene/core 1.12.3 → 1.12.4-beta-20260902093735.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 (61) hide show
  1. package/dist/es/agent/agent.mjs +88 -25
  2. package/dist/es/agent/agent.mjs.map +1 -1
  3. package/dist/es/agent/index.mjs +2 -1
  4. package/dist/es/agent/insight.mjs +40 -10
  5. package/dist/es/agent/insight.mjs.map +1 -1
  6. package/dist/es/agent/prompt-context.mjs +42 -6
  7. package/dist/es/agent/prompt-context.mjs.map +1 -1
  8. package/dist/es/agent/run-gherkin-scenario.mjs.map +1 -1
  9. package/dist/es/agent/utils.mjs +1 -1
  10. package/dist/es/ai-model/prompt/insight/user-prompt.mjs +1 -1
  11. package/dist/es/ai-model/prompt/insight/user-prompt.mjs.map +1 -1
  12. package/dist/es/ai-model/workflows/insight/extraction.mjs +4 -1
  13. package/dist/es/ai-model/workflows/insight/extraction.mjs.map +1 -1
  14. package/dist/es/ai-model/workflows/planning/custom-planning.mjs +3 -3
  15. package/dist/es/ai-model/workflows/planning/custom-planning.mjs.map +1 -1
  16. package/dist/es/ai-model/workflows/planning/standard-planning.mjs +1 -1
  17. package/dist/es/ai-model/workflows/planning/standard-planning.mjs.map +1 -1
  18. package/dist/es/index.mjs +2 -2
  19. package/dist/es/index.mjs.map +1 -1
  20. package/dist/es/report-html-template.mjs +1 -1
  21. package/dist/es/types.mjs.map +1 -1
  22. package/dist/es/utils.mjs +1 -1
  23. package/dist/es/yaml/player.mjs +0 -5
  24. package/dist/es/yaml/player.mjs.map +1 -1
  25. package/dist/es/yaml/utils.mjs +4 -3
  26. package/dist/es/yaml/utils.mjs.map +1 -1
  27. package/dist/lib/agent/agent.js +87 -24
  28. package/dist/lib/agent/agent.js.map +1 -1
  29. package/dist/lib/agent/index.js +5 -1
  30. package/dist/lib/agent/insight.js +40 -10
  31. package/dist/lib/agent/insight.js.map +1 -1
  32. package/dist/lib/agent/prompt-context.js +55 -7
  33. package/dist/lib/agent/prompt-context.js.map +1 -1
  34. package/dist/lib/agent/run-gherkin-scenario.js.map +1 -1
  35. package/dist/lib/agent/utils.js +1 -1
  36. package/dist/lib/ai-model/prompt/insight/user-prompt.js +1 -1
  37. package/dist/lib/ai-model/prompt/insight/user-prompt.js.map +1 -1
  38. package/dist/lib/ai-model/workflows/insight/extraction.js +4 -1
  39. package/dist/lib/ai-model/workflows/insight/extraction.js.map +1 -1
  40. package/dist/lib/ai-model/workflows/planning/custom-planning.js +3 -3
  41. package/dist/lib/ai-model/workflows/planning/custom-planning.js.map +1 -1
  42. package/dist/lib/ai-model/workflows/planning/standard-planning.js +1 -1
  43. package/dist/lib/ai-model/workflows/planning/standard-planning.js.map +1 -1
  44. package/dist/lib/index.js +4 -1
  45. package/dist/lib/index.js.map +1 -1
  46. package/dist/lib/report-html-template.js +1 -1
  47. package/dist/lib/types.js.map +1 -1
  48. package/dist/lib/utils.js +1 -1
  49. package/dist/lib/yaml/player.js +0 -5
  50. package/dist/lib/yaml/player.js.map +1 -1
  51. package/dist/lib/yaml/utils.js +3 -2
  52. package/dist/lib/yaml/utils.js.map +1 -1
  53. package/dist/types/agent/agent.d.ts +22 -3
  54. package/dist/types/agent/index.d.ts +2 -1
  55. package/dist/types/agent/insight.d.ts +6 -1
  56. package/dist/types/agent/prompt-context.d.ts +27 -1
  57. package/dist/types/agent/run-gherkin-scenario.d.ts +1 -0
  58. package/dist/types/index.d.ts +1 -1
  59. package/dist/types/types.d.ts +26 -0
  60. package/dist/types/yaml.d.ts +12 -4
  61. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"agent/insight.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/agent/insight.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 { TUserPrompt } from '@/ai-model/index';\nimport type { ModelRuntime } from '@/ai-model/models';\nimport type {\n AgentAssertResult,\n AssertOptions,\n InsightAPI,\n QueryOptions,\n ServiceExtractParam,\n UIContext,\n} from '@/types';\nimport { TaskExecutionError, type TaskExecutor } from './tasks';\nimport { parsePrompt } from './utils';\n\nconst defaultQueryOptions: QueryOptions = {\n domIncluded: false,\n screenshotIncluded: true,\n};\n\ntype InsightTaskExecutor = Pick<TaskExecutor, 'createTypeQueryExecution'>;\n\n/** Execute read-only AI operations against either live or fixed UI context. */\nexport class Insight implements InsightAPI {\n constructor(\n private readonly taskExecutor: InsightTaskExecutor,\n private readonly resolveModelRuntime: () => ModelRuntime,\n private readonly getUIContext?: () => UIContext,\n ) {}\n\n private executionOptions(\n options?: AssertOptions,\n includeAbortSignal = false,\n ): { abortSignal?: AbortSignal; uiContext?: UIContext } | undefined {\n const uiContext = this.getUIContext?.();\n if (!uiContext && !includeAbortSignal && !options?.abortSignal) {\n return undefined;\n }\n return {\n ...(includeAbortSignal || options?.abortSignal\n ? { abortSignal: options?.abortSignal }\n : {}),\n ...(uiContext ? { uiContext } : {}),\n };\n }\n\n async aiQuery<ReturnType = any>(\n demand: ServiceExtractParam,\n options: QueryOptions = defaultQueryOptions,\n ): Promise<ReturnType> {\n const modelRuntime = this.resolveModelRuntime();\n const executionOptions = this.executionOptions();\n const { output } = executionOptions\n ? await this.taskExecutor.createTypeQueryExecution(\n 'Query',\n demand,\n modelRuntime,\n options,\n undefined,\n executionOptions,\n )\n : await this.taskExecutor.createTypeQueryExecution(\n 'Query',\n demand,\n modelRuntime,\n options,\n );\n return output as ReturnType;\n }\n\n async aiBoolean(\n prompt: TUserPrompt,\n options: QueryOptions = defaultQueryOptions,\n ): Promise<boolean> {\n return this.queryPrimitive('Boolean', prompt, options);\n }\n\n async aiNumber(\n prompt: TUserPrompt,\n options: QueryOptions = defaultQueryOptions,\n ): Promise<number> {\n return this.queryPrimitive('Number', prompt, options);\n }\n\n async aiString(\n prompt: TUserPrompt,\n options: QueryOptions = defaultQueryOptions,\n ): Promise<string> {\n return this.queryPrimitive('String', prompt, options);\n }\n\n async aiAsk(\n prompt: TUserPrompt,\n options: QueryOptions = defaultQueryOptions,\n ): Promise<string> {\n return this.aiString(prompt, options);\n }\n\n private async queryPrimitive<ReturnType>(\n type: 'Boolean' | 'Number' | 'String',\n prompt: TUserPrompt,\n options: QueryOptions,\n ): Promise<ReturnType> {\n const { textPrompt, multimodalPrompt } = parsePrompt(prompt);\n const { output } = await this.taskExecutor.createTypeQueryExecution(\n type,\n textPrompt,\n this.resolveModelRuntime(),\n options,\n multimodalPrompt,\n this.executionOptions(),\n );\n return output as ReturnType;\n }\n\n async aiAssert(\n assertion: TUserPrompt,\n message?: string,\n options?: AssertOptions,\n ): Promise<AgentAssertResult | undefined> {\n const serviceOptions: QueryOptions = {\n domIncluded: options?.domIncluded ?? defaultQueryOptions.domIncluded,\n screenshotIncluded:\n options?.screenshotIncluded ?? defaultQueryOptions.screenshotIncluded,\n ...(options?.context !== undefined ? { context: options.context } : {}),\n };\n const { textPrompt, multimodalPrompt } = parsePrompt(assertion);\n const assertionText =\n typeof assertion === 'string' ? assertion : assertion.prompt;\n\n try {\n const { output, thought } =\n await this.taskExecutor.createTypeQueryExecution<boolean>(\n 'Assert',\n textPrompt,\n this.resolveModelRuntime(),\n serviceOptions,\n multimodalPrompt,\n this.executionOptions(options, true),\n );\n\n const pass = Boolean(output);\n const failureMessage = pass\n ? undefined\n : `Assertion failed: ${message || assertionText}\\nReason: ${thought || '(no_reason)'}`;\n\n if (options?.keepRawResponse) {\n return { pass, thought, message: failureMessage };\n }\n if (!pass) {\n throw new Error(failureMessage);\n }\n } catch (error) {\n if (error instanceof TaskExecutionError) {\n const thought = error.task?.thought;\n const diagnosticMessage =\n error.task?.errorMessage || error.cause.message;\n const reason = thought || diagnosticMessage || '(no_reason)';\n const failureMessage = `Assertion failed: ${message || assertionText}\\nReason: ${reason}`;\n\n if (options?.keepRawResponse) {\n return { pass: false, thought, message: failureMessage };\n }\n throw new Error(failureMessage, { cause: error.cause });\n }\n throw error;\n }\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","defaultQueryOptions","Insight","options","includeAbortSignal","uiContext","demand","modelRuntime","executionOptions","output","undefined","prompt","type","textPrompt","multimodalPrompt","parsePrompt","assertion","message","serviceOptions","assertionText","thought","pass","Boolean","failureMessage","Error","error","TaskExecutionError","diagnosticMessage","reason","taskExecutor","resolveModelRuntime","getUIContext"],"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;;;;;;;;;;;;;;;;;;;ACOA,MAAMI,sBAAoC;IACxC,aAAa;IACb,oBAAoB;AACtB;AAKO,MAAMC;IAOH,iBACNC,OAAuB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MG,SAASR,WAAWO,qBAAqB;gBAC/C,MAAMJ,iBAAiB,CAAC,kBAAkB,EAAEN,WAAWE,cAAc,UAAU,EAAES,QAAQ;gBAEzF,IAAIzB,SAAS,iBACX,OAAO;oBAAE,MAAM;oBAAOiB;oBAAS,SAASG;gBAAe;gBAEzD,MAAM,IAAIC,MAAMD,gBAAgB;oBAAE,OAAOE,MAAM,KAAK;gBAAC;YACvD;YACA,MAAMA;QACR;IACF;IA/IA,YACmBI,YAAiC,EACjCC,mBAAuC,EACvCC,YAA8B,CAC/C;;;;aAHiBF,YAAY,GAAZA;aACAC,mBAAmB,GAAnBA;aACAC,YAAY,GAAZA;IAChB;AA4IL"}
1
+ {"version":3,"file":"agent/insight.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/agent/insight.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 { TUserPrompt } from '@/ai-model/index';\nimport type { ModelRuntime } from '@/ai-model/models';\nimport type {\n AgentAssertResult,\n AssertOptions,\n InsightAPI,\n QueryOptions,\n ServiceExtractParam,\n UIContext,\n} from '@/types';\nimport type { AiApiName } from '@midscene/shared/agent-tools/agent-context';\nimport {\n INTERNAL_AI_CONTEXT_METADATA_KEY,\n type InternalAIContextOptions,\n type ResolvedAIContext,\n} from './prompt-context';\nimport { TaskExecutionError, type TaskExecutor } from './tasks';\nimport { parsePrompt } from './utils';\n\nconst defaultQueryOptions: QueryOptions = {\n domIncluded: false,\n screenshotIncluded: true,\n};\n\ntype InsightTaskExecutor = Pick<TaskExecutor, 'createTypeQueryExecution'>;\n\ntype InsightInternalOptions = InternalAIContextOptions & {\n context?: string;\n};\n\n/** Execute read-only AI operations against either live or fixed UI context. */\nexport class Insight implements InsightAPI {\n constructor(\n private readonly taskExecutor: InsightTaskExecutor,\n private readonly resolveModelRuntime: () => ModelRuntime,\n private readonly getUIContext?: () => UIContext,\n private readonly resolveAgentContext?: (\n apiName: AiApiName,\n callContext?: string,\n ) => ResolvedAIContext | undefined,\n ) {}\n\n private resolveContext(\n apiName: AiApiName,\n options?: InsightInternalOptions,\n ): ResolvedAIContext | undefined {\n if (this.resolveAgentContext) {\n return this.resolveAgentContext(apiName, options?.context);\n }\n\n return options?.context === undefined\n ? undefined\n : {\n value: options.context,\n metadata: { source: 'call' },\n };\n }\n\n private withContext<T extends InsightInternalOptions>(\n apiName: AiApiName,\n options: T,\n ): T {\n const resolvedContext = this.resolveContext(apiName, options);\n if (resolvedContext === undefined) {\n return options;\n }\n\n return {\n ...options,\n context: resolvedContext.value,\n [INTERNAL_AI_CONTEXT_METADATA_KEY]: resolvedContext.metadata,\n };\n }\n\n private executionOptions(\n options?: AssertOptions,\n includeAbortSignal = false,\n ): { abortSignal?: AbortSignal; uiContext?: UIContext } | undefined {\n const uiContext = this.getUIContext?.();\n if (!uiContext && !includeAbortSignal && !options?.abortSignal) {\n return undefined;\n }\n return {\n ...(includeAbortSignal || options?.abortSignal\n ? { abortSignal: options?.abortSignal }\n : {}),\n ...(uiContext ? { uiContext } : {}),\n };\n }\n\n async aiQuery<ReturnType = any>(\n demand: ServiceExtractParam,\n options: QueryOptions = defaultQueryOptions,\n ): Promise<ReturnType> {\n const modelRuntime = this.resolveModelRuntime();\n const executionOptions = this.executionOptions();\n const serviceOptions = this.withContext('aiQuery', options);\n const { output } = executionOptions\n ? await this.taskExecutor.createTypeQueryExecution(\n 'Query',\n demand,\n modelRuntime,\n serviceOptions,\n undefined,\n executionOptions,\n )\n : await this.taskExecutor.createTypeQueryExecution(\n 'Query',\n demand,\n modelRuntime,\n serviceOptions,\n );\n return output as ReturnType;\n }\n\n async aiBoolean(\n prompt: TUserPrompt,\n options: QueryOptions = defaultQueryOptions,\n ): Promise<boolean> {\n return this.queryPrimitive('Boolean', 'aiBoolean', prompt, options);\n }\n\n async aiNumber(\n prompt: TUserPrompt,\n options: QueryOptions = defaultQueryOptions,\n ): Promise<number> {\n return this.queryPrimitive('Number', 'aiNumber', prompt, options);\n }\n\n async aiString(\n prompt: TUserPrompt,\n options: QueryOptions = defaultQueryOptions,\n ): Promise<string> {\n return this.queryPrimitive('String', 'aiString', prompt, options);\n }\n\n async aiAsk(\n prompt: TUserPrompt,\n options: QueryOptions = defaultQueryOptions,\n ): Promise<string> {\n return this.queryPrimitive('String', 'aiAsk', prompt, options);\n }\n\n private async queryPrimitive<ReturnType>(\n type: 'Boolean' | 'Number' | 'String',\n apiName: 'aiBoolean' | 'aiNumber' | 'aiString' | 'aiAsk',\n prompt: TUserPrompt,\n options: QueryOptions,\n ): Promise<ReturnType> {\n const { textPrompt, multimodalPrompt } = parsePrompt(prompt);\n const serviceOptions = this.withContext(apiName, options);\n const { output } = await this.taskExecutor.createTypeQueryExecution(\n type,\n textPrompt,\n this.resolveModelRuntime(),\n serviceOptions,\n multimodalPrompt,\n this.executionOptions(),\n );\n return output as ReturnType;\n }\n\n async aiAssert(\n assertion: TUserPrompt,\n message?: string,\n options?: AssertOptions,\n ): Promise<AgentAssertResult | undefined> {\n const contextOptions = this.withContext(\n 'aiAssert',\n (options ?? {}) as AssertOptions & InsightInternalOptions,\n );\n const serviceOptions: QueryOptions = {\n domIncluded: options?.domIncluded ?? defaultQueryOptions.domIncluded,\n screenshotIncluded:\n options?.screenshotIncluded ?? defaultQueryOptions.screenshotIncluded,\n ...(contextOptions.context !== undefined\n ? { context: contextOptions.context }\n : {}),\n ...(contextOptions[INTERNAL_AI_CONTEXT_METADATA_KEY] !== undefined\n ? {\n [INTERNAL_AI_CONTEXT_METADATA_KEY]:\n contextOptions[INTERNAL_AI_CONTEXT_METADATA_KEY],\n }\n : {}),\n ...(contextOptions._internalAdditionalContext !== undefined\n ? {\n _internalAdditionalContext:\n contextOptions._internalAdditionalContext,\n }\n : {}),\n };\n const { textPrompt, multimodalPrompt } = parsePrompt(assertion);\n const assertionText =\n typeof assertion === 'string' ? assertion : assertion.prompt;\n\n try {\n const { output, thought } =\n await this.taskExecutor.createTypeQueryExecution<boolean>(\n 'Assert',\n textPrompt,\n this.resolveModelRuntime(),\n serviceOptions,\n multimodalPrompt,\n this.executionOptions(options, true),\n );\n\n const pass = Boolean(output);\n const failureMessage = pass\n ? undefined\n : `Assertion failed: ${message || assertionText}\\nReason: ${thought || '(no_reason)'}`;\n\n if (options?.keepRawResponse) {\n return { pass, thought, message: failureMessage };\n }\n if (!pass) {\n throw new Error(failureMessage);\n }\n } catch (error) {\n if (error instanceof TaskExecutionError) {\n const thought = error.task?.thought;\n const diagnosticMessage =\n error.task?.errorMessage || error.cause.message;\n const reason = thought || diagnosticMessage || '(no_reason)';\n const failureMessage = `Assertion failed: ${message || assertionText}\\nReason: ${reason}`;\n\n if (options?.keepRawResponse) {\n return { pass: false, thought, message: failureMessage };\n }\n throw new Error(failureMessage, { cause: error.cause });\n }\n throw error;\n }\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","defaultQueryOptions","Insight","apiName","options","undefined","resolvedContext","INTERNAL_AI_CONTEXT_METADATA_KEY","includeAbortSignal","uiContext","demand","modelRuntime","executionOptions","serviceOptions","output","prompt","type","textPrompt","multimodalPrompt","parsePrompt","assertion","message","contextOptions","assertionText","thought","pass","Boolean","failureMessage","Error","error","TaskExecutionError","diagnosticMessage","reason","taskExecutor","resolveModelRuntime","getUIContext","resolveAgentContext"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oB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EAAEgB,WAAWE,cAAc,UAAU,EAAEC,WAAW,eAAe;YAExF,IAAIpB,SAAS,iBACX,OAAO;gBAAEqB;gBAAMD;gBAAS,SAASG;YAAe;YAElD,IAAI,CAACF,MACH,MAAM,IAAIG,MAAMD;QAEpB,EAAE,OAAOE,OAAO;YACd,IAAIA,iBAAiBC,kCAAAA,kBAAkBA,EAAE;gBACvC,MAAMN,UAAUK,MAAM,IAAI,EAAE;gBAC5B,MAAME,oBACJF,MAAM,IAAI,EAAE,gBAAgBA,MAAM,KAAK,CAAC,OAAO;gBACjD,MAAMG,SAASR,WAAWO,qBAAqB;gBAC/C,MAAMJ,iBAAiB,CAAC,kBAAkB,EAAEN,WAAWE,cAAc,UAAU,EAAES,QAAQ;gBAEzF,IAAI5B,SAAS,iBACX,OAAO;oBAAE,MAAM;oBAAOoB;oBAAS,SAASG;gBAAe;gBAEzD,MAAM,IAAIC,MAAMD,gBAAgB;oBAAE,OAAOE,MAAM,KAAK;gBAAC;YACvD;YACA,MAAMA;QACR;IACF;IAxMA,YACmBI,YAAiC,EACjCC,mBAAuC,EACvCC,YAA8B,EAC9BC,mBAGiB,CAClC;;;;;aAPiBH,YAAY,GAAZA;aACAC,mBAAmB,GAAnBA;aACAC,YAAY,GAAZA;aACAC,mBAAmB,GAAnBA;IAIhB;AAiML"}
@@ -24,36 +24,84 @@ var __webpack_require__ = {};
24
24
  var __webpack_exports__ = {};
25
25
  __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
+ INTERNAL_AI_CONTEXT_METADATA_KEY: ()=>INTERNAL_AI_CONTEXT_METADATA_KEY,
27
28
  buildLocatePromptWithContext: ()=>buildLocatePromptWithContext,
28
- buildPromptWithContext: ()=>buildPromptWithContext
29
+ buildPromptWithContext: ()=>buildPromptWithContext,
30
+ mergeAIContexts: ()=>mergeAIContexts,
31
+ renderAIContext: ()=>renderAIContext,
32
+ resolvedAIContextFromOptions: ()=>resolvedAIContextFromOptions
29
33
  });
34
+ const INTERNAL_AI_CONTEXT_METADATA_KEY = '_internalAIContextMetadata';
35
+ const resolvedAIContextFromOptions = (options)=>{
36
+ if (options?.context === void 0) return;
37
+ return {
38
+ value: options.context,
39
+ metadata: options[INTERNAL_AI_CONTEXT_METADATA_KEY] ?? {
40
+ source: 'call'
41
+ }
42
+ };
43
+ };
44
+ const renderAIContext = (resolvedContext, workflowHistory)=>{
45
+ const blocks = [];
46
+ const context = resolvedContext?.value.trim();
47
+ if (context && resolvedContext) {
48
+ const metadata = resolvedContext.metadata;
49
+ if ('default' === metadata.source) blocks.push(`<GLOBAL_CONTEXT>\n${context}\n</GLOBAL_CONTEXT>`);
50
+ else {
51
+ const apiAttribute = 'api' === metadata.source ? ` api="${metadata.apiName}"` : '';
52
+ blocks.push(`<REQUEST_CONTEXT source="${metadata.source}"${apiAttribute}>\n${context}\n</REQUEST_CONTEXT>`);
53
+ }
54
+ }
55
+ const history = workflowHistory?.trim();
56
+ if (history) blocks.push(`<WORKFLOW_HISTORY read_only="true">\n${history}\n</WORKFLOW_HISTORY>`);
57
+ if (blocks.length > 0) return blocks.join('\n\n');
58
+ return void 0 !== resolvedContext || void 0 !== workflowHistory ? '' : void 0;
59
+ };
60
+ const mergeAIContexts = (...contexts)=>{
61
+ const definedContexts = contexts.filter((context)=>void 0 !== context);
62
+ if (0 === definedContexts.length) return;
63
+ return definedContexts.filter(Boolean).join('\n\n');
64
+ };
30
65
  const buildPromptWithContext = (prompt, context)=>{
31
66
  const trimmedContext = context?.trim();
32
67
  if (!trimmedContext) return prompt;
33
68
  const promptText = 'string' == typeof prompt ? prompt : prompt.prompt;
34
- const promptWithContext = `Context for this request:\n${trimmedContext}\n\n${promptText}`;
69
+ const promptWithContext = `${trimmedContext}\n\n${promptText}`;
35
70
  if ('string' == typeof prompt) return promptWithContext;
36
71
  return {
37
72
  ...prompt,
38
73
  prompt: promptWithContext
39
74
  };
40
75
  };
41
- const buildLocatePromptWithContext = (prompt, context)=>{
42
- const trimmedContext = context?.trim();
43
- if (!trimmedContext) return prompt;
76
+ const buildLocatePromptWithContext = (prompt, context, metadata)=>{
77
+ const renderedContext = renderAIContext(void 0 === context ? void 0 : {
78
+ value: context,
79
+ metadata: metadata ?? {
80
+ source: 'call'
81
+ }
82
+ });
83
+ if (!renderedContext) return prompt;
44
84
  const promptText = 'string' == typeof prompt ? prompt : prompt.prompt;
45
- const promptWithContext = `<CONTEXT>\n${trimmedContext}\n</CONTEXT>\n\n<LOCATE_TARGET>\n${promptText}\n</LOCATE_TARGET>`;
85
+ const promptWithContext = `${renderedContext}\n\n<LOCATE_TARGET>\n${promptText}\n</LOCATE_TARGET>`;
46
86
  if ('string' == typeof prompt) return promptWithContext;
47
87
  return {
48
88
  ...prompt,
49
89
  prompt: promptWithContext
50
90
  };
51
91
  };
92
+ exports.INTERNAL_AI_CONTEXT_METADATA_KEY = __webpack_exports__.INTERNAL_AI_CONTEXT_METADATA_KEY;
52
93
  exports.buildLocatePromptWithContext = __webpack_exports__.buildLocatePromptWithContext;
53
94
  exports.buildPromptWithContext = __webpack_exports__.buildPromptWithContext;
95
+ exports.mergeAIContexts = __webpack_exports__.mergeAIContexts;
96
+ exports.renderAIContext = __webpack_exports__.renderAIContext;
97
+ exports.resolvedAIContextFromOptions = __webpack_exports__.resolvedAIContextFromOptions;
54
98
  for(var __rspack_i in __webpack_exports__)if (-1 === [
99
+ "INTERNAL_AI_CONTEXT_METADATA_KEY",
55
100
  "buildLocatePromptWithContext",
56
- "buildPromptWithContext"
101
+ "buildPromptWithContext",
102
+ "mergeAIContexts",
103
+ "renderAIContext",
104
+ "resolvedAIContextFromOptions"
57
105
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
58
106
  Object.defineProperty(exports, '__esModule', {
59
107
  value: true
@@ -1 +1 @@
1
- {"version":3,"file":"agent/prompt-context.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/agent/prompt-context.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 { TUserPrompt } from '@/ai-model';\n\nexport const buildPromptWithContext = (\n prompt: TUserPrompt,\n context: string | undefined,\n): TUserPrompt => {\n const trimmedContext = context?.trim();\n if (!trimmedContext) {\n return prompt;\n }\n\n const promptText = typeof prompt === 'string' ? prompt : prompt.prompt;\n const promptWithContext = `Context for this request:\\n${trimmedContext}\\n\\n${promptText}`;\n\n if (typeof prompt === 'string') {\n return promptWithContext;\n }\n\n return {\n ...prompt,\n prompt: promptWithContext,\n };\n};\n\nexport const buildLocatePromptWithContext = (\n prompt: TUserPrompt,\n context: string | undefined,\n): TUserPrompt => {\n const trimmedContext = context?.trim();\n if (!trimmedContext) {\n return prompt;\n }\n\n const promptText = typeof prompt === 'string' ? prompt : prompt.prompt;\n const promptWithContext = `<CONTEXT>\\n${trimmedContext}\\n</CONTEXT>\\n\\n<LOCATE_TARGET>\\n${promptText}\\n</LOCATE_TARGET>`;\n\n if (typeof prompt === 'string') {\n return promptWithContext;\n }\n\n return {\n ...prompt,\n prompt: promptWithContext,\n };\n};\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","buildPromptWithContext","prompt","context","trimmedContext","promptText","promptWithContext","buildLocatePromptWithContext"],"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;;;;;;;;ACJO,MAAMI,yBAAyB,CACpCC,QACAC;IAEA,MAAMC,iBAAiBD,SAAS;IAChC,IAAI,CAACC,gBACH,OAAOF;IAGT,MAAMG,aAAa,AAAkB,YAAlB,OAAOH,SAAsBA,SAASA,OAAO,MAAM;IACtE,MAAMI,oBAAoB,CAAC,2BAA2B,EAAEF,eAAe,IAAI,EAAEC,YAAY;IAEzF,IAAI,AAAkB,YAAlB,OAAOH,QACT,OAAOI;IAGT,OAAO;QACL,GAAGJ,MAAM;QACT,QAAQI;IACV;AACF;AAEO,MAAMC,+BAA+B,CAC1CL,QACAC;IAEA,MAAMC,iBAAiBD,SAAS;IAChC,IAAI,CAACC,gBACH,OAAOF;IAGT,MAAMG,aAAa,AAAkB,YAAlB,OAAOH,SAAsBA,SAASA,OAAO,MAAM;IACtE,MAAMI,oBAAoB,CAAC,WAAW,EAAEF,eAAe,iCAAiC,EAAEC,WAAW,kBAAkB,CAAC;IAExH,IAAI,AAAkB,YAAlB,OAAOH,QACT,OAAOI;IAGT,OAAO;QACL,GAAGJ,MAAM;QACT,QAAQI;IACV;AACF"}
1
+ {"version":3,"file":"agent/prompt-context.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/agent/prompt-context.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 { TUserPrompt } from '@/ai-model';\nimport type { AiApiName } from '@midscene/shared/agent-tools/agent-context';\n\nexport type AIContextMetadata =\n | { source: 'default' }\n | { source: 'api'; apiName: AiApiName }\n | { source: 'call' };\n\nexport interface ResolvedAIContext {\n value: string;\n metadata: AIContextMetadata;\n}\n\nexport const INTERNAL_AI_CONTEXT_METADATA_KEY =\n '_internalAIContextMetadata' as const;\n\nexport interface InternalAIContextOptions {\n [INTERNAL_AI_CONTEXT_METADATA_KEY]?: AIContextMetadata;\n /** Framework-owned workflow history appended after the selected context. */\n _internalAdditionalContext?: string;\n}\n\nexport const resolvedAIContextFromOptions = (\n options:\n | ({ context?: string } & Partial<InternalAIContextOptions>)\n | undefined,\n): ResolvedAIContext | undefined => {\n if (options?.context === undefined) {\n return undefined;\n }\n\n return {\n value: options.context,\n metadata: options[INTERNAL_AI_CONTEXT_METADATA_KEY] ?? { source: 'call' },\n };\n};\n\n/** Render the selected user context and framework history as separate blocks. */\nexport const renderAIContext = (\n resolvedContext: ResolvedAIContext | undefined,\n workflowHistory?: string,\n): string | undefined => {\n const blocks: string[] = [];\n const context = resolvedContext?.value.trim();\n\n if (context && resolvedContext) {\n const metadata = resolvedContext.metadata;\n if (metadata.source === 'default') {\n blocks.push(`<GLOBAL_CONTEXT>\\n${context}\\n</GLOBAL_CONTEXT>`);\n } else {\n const apiAttribute =\n metadata.source === 'api' ? ` api=\"${metadata.apiName}\"` : '';\n blocks.push(\n `<REQUEST_CONTEXT source=\"${metadata.source}\"${apiAttribute}>\\n${context}\\n</REQUEST_CONTEXT>`,\n );\n }\n }\n\n const history = workflowHistory?.trim();\n if (history) {\n blocks.push(\n `<WORKFLOW_HISTORY read_only=\"true\">\\n${history}\\n</WORKFLOW_HISTORY>`,\n );\n }\n\n if (blocks.length > 0) {\n return blocks.join('\\n\\n');\n }\n\n return resolvedContext !== undefined || workflowHistory !== undefined\n ? ''\n : undefined;\n};\n\n/** Explicitly concatenate context fragments in the order provided. */\nexport const mergeAIContexts = (\n ...contexts: Array<string | undefined>\n): string | undefined => {\n const definedContexts = contexts.filter(\n (context): context is string => context !== undefined,\n );\n if (definedContexts.length === 0) {\n return undefined;\n }\n\n return definedContexts.filter(Boolean).join('\\n\\n');\n};\n\nexport const buildPromptWithContext = (\n prompt: TUserPrompt,\n context: string | undefined,\n): TUserPrompt => {\n const trimmedContext = context?.trim();\n if (!trimmedContext) {\n return prompt;\n }\n\n const promptText = typeof prompt === 'string' ? prompt : prompt.prompt;\n const promptWithContext = `${trimmedContext}\\n\\n${promptText}`;\n\n if (typeof prompt === 'string') {\n return promptWithContext;\n }\n\n return {\n ...prompt,\n prompt: promptWithContext,\n };\n};\n\nexport const buildLocatePromptWithContext = (\n prompt: TUserPrompt,\n context: string | undefined,\n metadata?: AIContextMetadata,\n): TUserPrompt => {\n const renderedContext = renderAIContext(\n context === undefined\n ? undefined\n : { value: context, metadata: metadata ?? { source: 'call' } },\n );\n if (!renderedContext) {\n return prompt;\n }\n\n const promptText = typeof prompt === 'string' ? prompt : prompt.prompt;\n const promptWithContext = `${renderedContext}\\n\\n<LOCATE_TARGET>\\n${promptText}\\n</LOCATE_TARGET>`;\n\n if (typeof prompt === 'string') {\n return promptWithContext;\n }\n\n return {\n ...prompt,\n prompt: promptWithContext,\n };\n};\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","INTERNAL_AI_CONTEXT_METADATA_KEY","resolvedAIContextFromOptions","options","undefined","renderAIContext","resolvedContext","workflowHistory","blocks","context","metadata","apiAttribute","history","mergeAIContexts","contexts","definedContexts","Boolean","buildPromptWithContext","prompt","trimmedContext","promptText","promptWithContext","buildLocatePromptWithContext","renderedContext"],"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;;;;;;;;;;;;ACOO,MAAMI,mCACX;AAQK,MAAMC,+BAA+B,CAC1CC;IAIA,IAAIA,SAAS,YAAYC,QACvB;IAGF,OAAO;QACL,OAAOD,QAAQ,OAAO;QACtB,UAAUA,OAAO,CAACF,iCAAiC,IAAI;YAAE,QAAQ;QAAO;IAC1E;AACF;AAGO,MAAMI,kBAAkB,CAC7BC,iBACAC;IAEA,MAAMC,SAAmB,EAAE;IAC3B,MAAMC,UAAUH,iBAAiB,MAAM;IAEvC,IAAIG,WAAWH,iBAAiB;QAC9B,MAAMI,WAAWJ,gBAAgB,QAAQ;QACzC,IAAII,AAAoB,cAApBA,SAAS,MAAM,EACjBF,OAAO,IAAI,CAAC,CAAC,kBAAkB,EAAEC,QAAQ,mBAAmB,CAAC;aACxD;YACL,MAAME,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AAsBA,SAASA,OAAO,MAAM;IACtE,MAAMG,oBAAoB,GAAGE,gBAAgB,qBAAqB,EAAEH,WAAW,kBAAkB,CAAC;IAElG,IAAI,AAAkB,YAAlB,OAAOF,QACT,OAAOG;IAGT,OAAO;QACL,GAAGH,MAAM;QACT,QAAQG;IACV;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"agent/run-gherkin-scenario.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/agent/run-gherkin-scenario.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 { AiActOptions } from './agent';\n\nexport type GherkinStepKeyword = 'Given' | 'When' | 'Then' | 'And' | 'But';\n\ntype RunGherkinScenarioStepAction = 'aiAct' | 'aiAssert';\n\nexport type RunGherkinScenarioOptions = AiActOptions & {\n context?: string;\n};\n\ntype GherkinPrimaryKeyword = 'Given' | 'When' | 'Then';\n\ntype ParsedGherkinStep = {\n keyword: GherkinStepKeyword;\n effectiveKeyword: GherkinPrimaryKeyword;\n text: string;\n lineNumber: number;\n};\n\ntype RawGherkinStep = {\n keyword: GherkinStepKeyword;\n text: string;\n lineNumber: number;\n};\n\ntype ParsedGherkinScenario = {\n scenario?: string;\n steps: ParsedGherkinStep[];\n};\n\ntype GherkinScenarioAgent = {\n aiAct: (taskPrompt: string, opt?: AiActOptions) => Promise<unknown>;\n aiAssert: (\n assertion: string,\n msg?: string,\n opt?: { context?: string; abortSignal?: AbortSignal },\n ) => Promise<unknown>;\n};\n\nconst stepKeywordPattern = /^(Given|When|Then|And|But)\\s+(.+)$/i;\nconst headerPattern = /^(Scenario):\\s*(.*)$/i;\nconst unsupportedHeaderPattern =\n /^(Feature|Background|Scenario Outline|Scenario Template|Examples|Rule):/i;\n\nconst normalizeStepKeyword = (keyword: string): GherkinStepKeyword => {\n const lowerKeyword = keyword.toLowerCase();\n if (lowerKeyword === 'given') return 'Given';\n if (lowerKeyword === 'when') return 'When';\n if (lowerKeyword === 'then') return 'Then';\n if (lowerKeyword === 'and') return 'And';\n return 'But';\n};\n\nconst isPrimaryKeyword = (\n keyword: GherkinStepKeyword,\n): keyword is GherkinPrimaryKeyword => {\n return keyword === 'Given' || keyword === 'When' || keyword === 'Then';\n};\n\nconst resolveSteps = (steps: RawGherkinStep[]): ParsedGherkinStep[] => {\n let previousPrimaryKeyword: GherkinPrimaryKeyword | undefined;\n\n return steps.map((step) => {\n const effectiveKeyword = isPrimaryKeyword(step.keyword)\n ? step.keyword\n : previousPrimaryKeyword;\n\n if (!effectiveKeyword) {\n throw new Error(\n `runGherkinScenario cannot resolve \"${step.keyword}\" at line ${step.lineNumber}; use Given, When, or Then before ${step.keyword}.`,\n );\n }\n\n previousPrimaryKeyword = effectiveKeyword;\n\n return {\n ...step,\n effectiveKeyword,\n };\n });\n};\n\nconst throwIfAborted = (abortSignal: AbortSignal | undefined) => {\n if (!abortSignal?.aborted) {\n return;\n }\n\n if (typeof abortSignal.throwIfAborted === 'function') {\n abortSignal.throwIfAborted();\n }\n\n throw new Error(\n `runGherkinScenario aborted: ${abortSignal.reason || 'signal already aborted'}`,\n );\n};\n\nexport const parseGherkinScenario = (\n scenarioText: string,\n): ParsedGherkinScenario => {\n const lines = scenarioText.split(/\\r?\\n/);\n const scenarioSteps: RawGherkinStep[] = [];\n const anonymousSteps: RawGherkinStep[] = [];\n let scenario: string | undefined;\n let scenarioCount = 0;\n let section: 'prelude' | 'scenario' = 'prelude';\n\n for (const [lineIndex, rawLine] of lines.entries()) {\n const lineNumber = lineIndex + 1;\n const line = rawLine.trim();\n\n if (!line || line.startsWith('#') || line.startsWith('@')) {\n continue;\n }\n\n if (line === '\"\"\"' || line === \"'''\") {\n throw new Error(\n `runGherkinScenario does not support doc strings; found one at line ${lineNumber}.`,\n );\n }\n\n if (line.startsWith('|')) {\n throw new Error(\n `runGherkinScenario does not support data tables; found one at line ${lineNumber}.`,\n );\n }\n\n if (unsupportedHeaderPattern.test(line)) {\n throw new Error(\n `runGherkinScenario does not support \"${line}\" at line ${lineNumber}.`,\n );\n }\n\n const headerMatch = line.match(headerPattern);\n if (headerMatch) {\n scenarioCount += 1;\n scenario = headerMatch[2].trim() || undefined;\n section = 'scenario';\n continue;\n }\n\n const stepMatch = line.match(stepKeywordPattern);\n if (stepMatch) {\n const step = {\n keyword: normalizeStepKeyword(stepMatch[1]),\n text: stepMatch[2].trim(),\n lineNumber,\n };\n\n if (section === 'scenario') {\n scenarioSteps.push(step);\n } else {\n anonymousSteps.push(step);\n }\n\n continue;\n }\n\n throw new Error(\n `runGherkinScenario does not support content at line ${lineNumber}: ${line}`,\n );\n }\n\n if (scenarioCount > 1) {\n throw new Error(\n `runGherkinScenario expects exactly one Scenario, but found ${scenarioCount}.`,\n );\n }\n\n if (scenarioCount === 1 && anonymousSteps.length > 0) {\n throw new Error(\n 'runGherkinScenario cannot mix anonymous steps with a Scenario block.',\n );\n }\n\n const rawSteps = scenarioCount === 1 ? scenarioSteps : anonymousSteps;\n\n if (rawSteps.length === 0) {\n throw new Error('runGherkinScenario requires at least one Gherkin step.');\n }\n\n return {\n scenario,\n steps: resolveSteps(rawSteps),\n };\n};\n\nconst buildStepPrompt = (step: ParsedGherkinStep) => {\n if (step.effectiveKeyword === 'Given') {\n return `Set up this precondition: ${step.text}`;\n }\n\n if (step.effectiveKeyword === 'When') {\n return `Perform this user action: ${step.text}`;\n }\n\n return `Verify that ${step.text}`;\n};\n\nconst describeStepExecution = (\n step: ParsedGherkinStep,\n action: RunGherkinScenarioStepAction,\n) => {\n const keywordMapping =\n step.keyword === step.effectiveKeyword\n ? step.keyword\n : `${step.keyword} as ${step.effectiveKeyword}`;\n\n if (step.effectiveKeyword === 'Given') {\n return `setting up the precondition (${keywordMapping} -> ${action})`;\n }\n\n if (step.effectiveKeyword === 'When') {\n return `performing the user action (${keywordMapping} -> ${action})`;\n }\n\n return `verifying the expected result (${keywordMapping} -> ${action})`;\n};\n\nconst describeErrorCause = (error: unknown) => {\n if (error instanceof Error && error.message) {\n return ` Original error: ${error.message}`;\n }\n\n return '';\n};\n\nexport const runGherkinScenario = async (\n agent: GherkinScenarioAgent,\n scenarioText: string,\n opt?: RunGherkinScenarioOptions,\n): Promise<void> => {\n const parsedScenario = parseGherkinScenario(scenarioText);\n const aiActOptions: AiActOptions = {\n ...opt,\n cacheable: false,\n };\n\n for (const step of parsedScenario.steps) {\n throwIfAborted(opt?.abortSignal);\n\n const action: RunGherkinScenarioStepAction =\n step.effectiveKeyword === 'Then' ? 'aiAssert' : 'aiAct';\n const prompt = buildStepPrompt(step);\n\n try {\n if (action === 'aiAct') {\n await agent.aiAct(prompt, aiActOptions);\n } else if (opt?.context || opt?.abortSignal) {\n await agent.aiAssert(prompt, undefined, {\n context: opt.context,\n abortSignal: opt.abortSignal,\n });\n } else {\n await agent.aiAssert(prompt);\n }\n } catch (error) {\n throw new Error(\n `runGherkinScenario failed while ${describeStepExecution(\n step,\n action,\n )} at line ${step.lineNumber}: ${step.keyword} ${step.text}.${describeErrorCause(\n error,\n )}`,\n {\n cause: error,\n },\n );\n }\n }\n};\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","stepKeywordPattern","headerPattern","unsupportedHeaderPattern","normalizeStepKeyword","keyword","lowerKeyword","isPrimaryKeyword","resolveSteps","steps","previousPrimaryKeyword","step","effectiveKeyword","Error","throwIfAborted","abortSignal","parseGherkinScenario","scenarioText","lines","scenarioSteps","anonymousSteps","scenario","scenarioCount","section","lineIndex","rawLine","lineNumber","line","headerMatch","undefined","stepMatch","rawSteps","buildStepPrompt","describeStepExecution","action","keywordMapping","describeErrorCause","error","runGherkinScenario","agent","opt","parsedScenario","aiActOptions","prompt"],"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;;;;;;;;ACiCA,MAAMI,qBAAqB;AAC3B,MAAMC,gBAAgB;AACtB,MAAMC,2BACJ;AAEF,MAAMC,uBAAuB,CAACC;IAC5B,MAAMC,eAAeD,QAAQ,WAAW;IACxC,IAAIC,AAAiB,YAAjBA,cAA0B,OAAO;IACrC,IAAIA,AAAiB,WAAjBA,cAAyB,OAAO;IACpC,IAAIA,AAAiB,WAAjBA,cAAyB,OAAO;IACpC,IAAIA,AAAiB,UAAjBA,cAAwB,OAAO;IACnC,OAAO;AACT;AAEA,MAAMC,mBAAmB,CACvBF,UAEOA,AAAY,YAAZA,WAAuBA,AAAY,WAAZA,WAAsBA,AAAY,WAAZA;AAGtD,MAAMG,eAAe,CAACC;IACpB,IAAIC;IAEJ,OAAOD,MAAM,GAAG,CAAC,CAACE;QAChB,MAAMC,mBAAmBL,iBAAiBI,KAAK,OA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OA;YACT;QAEJ;IACF;AACF"}
1
+ {"version":3,"file":"agent/run-gherkin-scenario.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/agent/run-gherkin-scenario.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 { AiActOptions } from './agent';\n\nexport type GherkinStepKeyword = 'Given' | 'When' | 'Then' | 'And' | 'But';\n\ntype RunGherkinScenarioStepAction = 'aiAct' | 'aiAssert';\n\nexport type RunGherkinScenarioOptions = AiActOptions & {\n /** Additional AI guidance applied to every step in this scenario run. */\n context?: string;\n};\n\ntype GherkinPrimaryKeyword = 'Given' | 'When' | 'Then';\n\ntype ParsedGherkinStep = {\n keyword: GherkinStepKeyword;\n effectiveKeyword: GherkinPrimaryKeyword;\n text: string;\n lineNumber: number;\n};\n\ntype RawGherkinStep = {\n keyword: GherkinStepKeyword;\n text: string;\n lineNumber: number;\n};\n\ntype ParsedGherkinScenario = {\n scenario?: string;\n steps: ParsedGherkinStep[];\n};\n\ntype GherkinScenarioAgent = {\n aiAct: (taskPrompt: string, opt?: AiActOptions) => Promise<unknown>;\n aiAssert: (\n assertion: string,\n msg?: string,\n opt?: { context?: string; abortSignal?: AbortSignal },\n ) => Promise<unknown>;\n};\n\nconst stepKeywordPattern = /^(Given|When|Then|And|But)\\s+(.+)$/i;\nconst headerPattern = /^(Scenario):\\s*(.*)$/i;\nconst unsupportedHeaderPattern =\n /^(Feature|Background|Scenario Outline|Scenario Template|Examples|Rule):/i;\n\nconst normalizeStepKeyword = (keyword: string): GherkinStepKeyword => {\n const lowerKeyword = keyword.toLowerCase();\n if (lowerKeyword === 'given') return 'Given';\n if (lowerKeyword === 'when') return 'When';\n if (lowerKeyword === 'then') return 'Then';\n if (lowerKeyword === 'and') return 'And';\n return 'But';\n};\n\nconst isPrimaryKeyword = (\n keyword: GherkinStepKeyword,\n): keyword is GherkinPrimaryKeyword => {\n return keyword === 'Given' || keyword === 'When' || keyword === 'Then';\n};\n\nconst resolveSteps = (steps: RawGherkinStep[]): ParsedGherkinStep[] => {\n let previousPrimaryKeyword: GherkinPrimaryKeyword | undefined;\n\n return steps.map((step) => {\n const effectiveKeyword = isPrimaryKeyword(step.keyword)\n ? step.keyword\n : previousPrimaryKeyword;\n\n if (!effectiveKeyword) {\n throw new Error(\n `runGherkinScenario cannot resolve \"${step.keyword}\" at line ${step.lineNumber}; use Given, When, or Then before ${step.keyword}.`,\n );\n }\n\n previousPrimaryKeyword = effectiveKeyword;\n\n return {\n ...step,\n effectiveKeyword,\n };\n });\n};\n\nconst throwIfAborted = (abortSignal: AbortSignal | undefined) => {\n if (!abortSignal?.aborted) {\n return;\n }\n\n if (typeof abortSignal.throwIfAborted === 'function') {\n abortSignal.throwIfAborted();\n }\n\n throw new Error(\n `runGherkinScenario aborted: ${abortSignal.reason || 'signal already aborted'}`,\n );\n};\n\nexport const parseGherkinScenario = (\n scenarioText: string,\n): ParsedGherkinScenario => {\n const lines = scenarioText.split(/\\r?\\n/);\n const scenarioSteps: RawGherkinStep[] = [];\n const anonymousSteps: RawGherkinStep[] = [];\n let scenario: string | undefined;\n let scenarioCount = 0;\n let section: 'prelude' | 'scenario' = 'prelude';\n\n for (const [lineIndex, rawLine] of lines.entries()) {\n const lineNumber = lineIndex + 1;\n const line = rawLine.trim();\n\n if (!line || line.startsWith('#') || line.startsWith('@')) {\n continue;\n }\n\n if (line === '\"\"\"' || line === \"'''\") {\n throw new Error(\n `runGherkinScenario does not support doc strings; found one at line ${lineNumber}.`,\n );\n }\n\n if (line.startsWith('|')) {\n throw new Error(\n `runGherkinScenario does not support data tables; found one at line ${lineNumber}.`,\n );\n }\n\n if (unsupportedHeaderPattern.test(line)) {\n throw new Error(\n `runGherkinScenario does not support \"${line}\" at line ${lineNumber}.`,\n );\n }\n\n const headerMatch = line.match(headerPattern);\n if (headerMatch) {\n scenarioCount += 1;\n scenario = headerMatch[2].trim() || undefined;\n section = 'scenario';\n continue;\n }\n\n const stepMatch = line.match(stepKeywordPattern);\n if (stepMatch) {\n const step = {\n keyword: normalizeStepKeyword(stepMatch[1]),\n text: stepMatch[2].trim(),\n lineNumber,\n };\n\n if (section === 'scenario') {\n scenarioSteps.push(step);\n } else {\n anonymousSteps.push(step);\n }\n\n continue;\n }\n\n throw new Error(\n `runGherkinScenario does not support content at line ${lineNumber}: ${line}`,\n );\n }\n\n if (scenarioCount > 1) {\n throw new Error(\n `runGherkinScenario expects exactly one Scenario, but found ${scenarioCount}.`,\n );\n }\n\n if (scenarioCount === 1 && anonymousSteps.length > 0) {\n throw new Error(\n 'runGherkinScenario cannot mix anonymous steps with a Scenario block.',\n );\n }\n\n const rawSteps = scenarioCount === 1 ? scenarioSteps : anonymousSteps;\n\n if (rawSteps.length === 0) {\n throw new Error('runGherkinScenario requires at least one Gherkin step.');\n }\n\n return {\n scenario,\n steps: resolveSteps(rawSteps),\n };\n};\n\nconst buildStepPrompt = (step: ParsedGherkinStep) => {\n if (step.effectiveKeyword === 'Given') {\n return `Set up this precondition: ${step.text}`;\n }\n\n if (step.effectiveKeyword === 'When') {\n return `Perform this user action: ${step.text}`;\n }\n\n return `Verify that ${step.text}`;\n};\n\nconst describeStepExecution = (\n step: ParsedGherkinStep,\n action: RunGherkinScenarioStepAction,\n) => {\n const keywordMapping =\n step.keyword === step.effectiveKeyword\n ? step.keyword\n : `${step.keyword} as ${step.effectiveKeyword}`;\n\n if (step.effectiveKeyword === 'Given') {\n return `setting up the precondition (${keywordMapping} -> ${action})`;\n }\n\n if (step.effectiveKeyword === 'When') {\n return `performing the user action (${keywordMapping} -> ${action})`;\n }\n\n return `verifying the expected result (${keywordMapping} -> ${action})`;\n};\n\nconst describeErrorCause = (error: unknown) => {\n if (error instanceof Error && error.message) {\n return ` Original error: ${error.message}`;\n }\n\n return '';\n};\n\nexport const runGherkinScenario = async (\n agent: GherkinScenarioAgent,\n scenarioText: string,\n opt?: RunGherkinScenarioOptions,\n): Promise<void> => {\n const parsedScenario = parseGherkinScenario(scenarioText);\n const aiActOptions: AiActOptions = {\n ...opt,\n cacheable: false,\n };\n\n for (const step of parsedScenario.steps) {\n throwIfAborted(opt?.abortSignal);\n\n const action: RunGherkinScenarioStepAction =\n step.effectiveKeyword === 'Then' ? 'aiAssert' : 'aiAct';\n const prompt = buildStepPrompt(step);\n\n try {\n if (action === 'aiAct') {\n await agent.aiAct(prompt, aiActOptions);\n } else if (opt?.context || opt?.abortSignal) {\n await agent.aiAssert(prompt, undefined, {\n context: opt.context,\n abortSignal: opt.abortSignal,\n });\n } else {\n await agent.aiAssert(prompt);\n }\n } catch (error) {\n throw new Error(\n `runGherkinScenario failed while ${describeStepExecution(\n step,\n action,\n )} at line ${step.lineNumber}: ${step.keyword} ${step.text}.${describeErrorCause(\n error,\n )}`,\n {\n cause: error,\n },\n );\n }\n }\n};\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","stepKeywordPattern","headerPattern","unsupportedHeaderPattern","normalizeStepKeyword","keyword","lowerKeyword","isPrimaryKeyword","resolveSteps","steps","previousPrimaryKeyword","step","effectiveKeyword","Error","throwIfAborted","abortSignal","parseGherkinScenario","scenarioText","lines","scenarioSteps","anonymousSteps","scenario","scenarioCount","section","lineIndex","rawLine","lineNumber","line","headerMatch","undefined","stepMatch","rawSteps","buildStepPrompt","describeStepExecution","action","keywordMapping","describeErrorCause","error","runGherkinScenario","agent","opt","parsedScenario","aiActOptions","prompt"],"mappings":";;;IAAAA,oBAAoB,C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AAgB,EACvB,OAAO,CAAC,4BAA4B,EAAEwB,eAAe,IAAI,EAAED,OAAO,CAAC,CAAC;IAGtE,OAAO,CAAC,+BAA+B,EAAEC,eAAe,IAAI,EAAED,OAAO,CAAC,CAAC;AACzE;AAEA,MAAME,qBAAqB,CAACC;IAC1B,IAAIA,iBAAiBxB,SAASwB,MAAM,OAAO,EACzC,OAAO,CAAC,iBAAiB,EAAEA,MAAM,OAAO,EAAE;IAG5C,OAAO;AACT;AAEO,MAAMC,qBAAqB,OAChCC,OACAtB,cACAuB;IAEA,MAAMC,iBAAiBzB,qBAAqBC;IAC5C,MAAMyB,eAA6B;QACjC,GAAGF,GAAG;QACN,WAAW;IACb;IAEA,KAAK,MAAM7B,QAAQ8B,eAAe,KAAK,CAAE;QACvC3B,eAAe0B,KAAK;QAEpB,MAAMN,SACJvB,AAA0B,WAA1BA,KAAK,gBAAgB,GAAc,aAAa;QAClD,MAAMgC,SAASX,gBAAgBrB;QAE/B,IAAI;YACF,IAAIuB,AAAW,YAAXA,QACF,MAAMK,MAAM,KAAK,CAACI,QAAQD;iBACrB,IAAIF,KAAK,WAAWA,KAAK,aAC9B,MAAMD,MAAM,QAAQ,CAACI,QAAQd,QAAW;gBACtC,SAASW,IAAI,OAAO;gBACpB,aAAaA,IAAI,WAAW;YAC9B;iBAEA,MAAMD,MAAM,QAAQ,CAACI;QAEzB,EAAE,OAAON,OAAO;YACd,MAAM,IAAIxB,MACR,CAAC,gCAAgC,EAAEoB,sBACjCtB,MACAuB,QACA,SAAS,EAAEvB,KAAK,UAAU,CAAC,EAAE,EAAEA,KAAK,OAAO,CAAC,CAAC,EAAEA,KAAK,IAAI,CAAC,CAAC,EAAEyB,mBAC5DC,QACC,EACH;gBACE,OAAOA;YACT;QAEJ;IACF;AACF"}
@@ -205,7 +205,7 @@ async function matchElementFromCache(context, cacheEntry, cachePrompt, cacheable
205
205
  return;
206
206
  }
207
207
  }
208
- const getMidsceneVersion = ()=>"1.12.3";
208
+ const getMidsceneVersion = ()=>"1.12.4-beta-20260902093735.0";
209
209
  const parsePrompt = (prompt)=>{
210
210
  if ('string' == typeof prompt) return {
211
211
  textPrompt: prompt,
@@ -36,7 +36,7 @@ function buildTypeQueryDemandValue(type, demand) {
36
36
  const extractDataQueryPrompt = (pageDescription, dataQuery, context)=>{
37
37
  const dataQueryText = 'string' == typeof dataQuery ? dataQuery : JSON.stringify(dataQuery, null, 2);
38
38
  const trimmedContext = context?.trim();
39
- const contextSection = trimmedContext ? `\n<CONTEXT>\n${trimmedContext}\n</CONTEXT>\n` : '';
39
+ const contextSection = trimmedContext ? `\n${trimmedContext}\n` : '';
40
40
  return `
41
41
  <PageDescription>
42
42
  ${pageDescription}
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/prompt/insight/user-prompt.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/prompt/insight/user-prompt.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 { ServiceExtractParam } from '@/types';\n\nexport function buildTypeQueryDemandValue(\n type: 'Boolean' | 'Number' | 'String' | 'Assert' | 'WaitFor',\n demand: ServiceExtractParam,\n) {\n const currentScreenshotConstraint =\n 'based on the current screenshot and its contents if provided, unless the user explicitly asks to compare with reference images';\n\n if (type === 'Assert') {\n return `Boolean, ${currentScreenshotConstraint}, whether the following statement is true: ${demand}`;\n }\n\n if (type === 'WaitFor') {\n return `Boolean, the user wants to do some 'wait for' operation. ${currentScreenshotConstraint}, please check whether the following statement is true: ${demand}`;\n }\n\n return `${type}, ${currentScreenshotConstraint}, ${demand}`;\n}\n\nexport const extractDataQueryPrompt = (\n pageDescription: string,\n dataQuery: string | Record<string, string>,\n context?: string,\n) => {\n const dataQueryText =\n typeof dataQuery === 'string'\n ? dataQuery\n : JSON.stringify(dataQuery, null, 2);\n\n const trimmedContext = context?.trim();\n const contextSection = trimmedContext\n ? `\\n<CONTEXT>\\n${trimmedContext}\\n</CONTEXT>\\n`\n : '';\n\n return `\n<PageDescription>\n${pageDescription}\n</PageDescription>\n${contextSection}\n<DATA_DEMAND>\n${dataQueryText}\n</DATA_DEMAND>\n `;\n};\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","buildTypeQueryDemandValue","type","demand","currentScreenshotConstraint","extractDataQueryPrompt","pageDescription","dataQuery","context","dataQueryText","JSON","trimmedContext","contextSection"],"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;;;;;;;;ACJO,SAASI,0BACdC,IAA4D,EAC5DC,MAA2B;IAE3B,MAAMC,8BACJ;IAEF,IAAIF,AAAS,aAATA,MACF,OAAO,CAAC,SAAS,EAAEE,4BAA4B,2CAA2C,EAAED,QAAQ;IAGtG,IAAID,AAAS,cAATA,MACF,OAAO,CAAC,yDAAyD,EAAEE,4BAA4B,wDAAwD,EAAED,QAAQ;IAGnK,OAAO,GAAGD,KAAK,EAAE,EAAEE,4BAA4B,EAAE,EAAED,QAAQ;AAC7D;AAEO,MAAME,yBAAyB,CACpCC,iBACAC,WACAC;IAEA,MAAMC,gBACJ,AAAqB,YAArB,OAAOF,YACHA,YACAG,KAAK,SAAS,CAACH,WAAW,MAAM;IAEtC,MAAMI,iBAAiBH,SAAS;IAChC,MAAMI,iBAAiBD,iBACnB,CAAC,aAAa,EAAEA,eAAe,cAAc,CAAC,GAC9C;IAEJ,OAAO,CAAC;;AAEV,EAAEL,gBAAgB;;AAElB,EAAEM,eAAe;;AAEjB,EAAEH,cAAc;;EAEd,CAAC;AACH"}
1
+ {"version":3,"file":"ai-model/prompt/insight/user-prompt.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/prompt/insight/user-prompt.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 { ServiceExtractParam } from '@/types';\n\nexport function buildTypeQueryDemandValue(\n type: 'Boolean' | 'Number' | 'String' | 'Assert' | 'WaitFor',\n demand: ServiceExtractParam,\n) {\n const currentScreenshotConstraint =\n 'based on the current screenshot and its contents if provided, unless the user explicitly asks to compare with reference images';\n\n if (type === 'Assert') {\n return `Boolean, ${currentScreenshotConstraint}, whether the following statement is true: ${demand}`;\n }\n\n if (type === 'WaitFor') {\n return `Boolean, the user wants to do some 'wait for' operation. ${currentScreenshotConstraint}, please check whether the following statement is true: ${demand}`;\n }\n\n return `${type}, ${currentScreenshotConstraint}, ${demand}`;\n}\n\nexport const extractDataQueryPrompt = (\n pageDescription: string,\n dataQuery: string | Record<string, string>,\n context?: string,\n) => {\n const dataQueryText =\n typeof dataQuery === 'string'\n ? dataQuery\n : JSON.stringify(dataQuery, null, 2);\n\n const trimmedContext = context?.trim();\n const contextSection = trimmedContext ? `\\n${trimmedContext}\\n` : '';\n\n return `\n<PageDescription>\n${pageDescription}\n</PageDescription>\n${contextSection}\n<DATA_DEMAND>\n${dataQueryText}\n</DATA_DEMAND>\n `;\n};\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","buildTypeQueryDemandValue","type","demand","currentScreenshotConstraint","extractDataQueryPrompt","pageDescription","dataQuery","context","dataQueryText","JSON","trimmedContext","contextSection"],"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;;;;;;;;ACJO,SAASI,0BACdC,IAA4D,EAC5DC,MAA2B;IAE3B,MAAMC,8BACJ;IAEF,IAAIF,AAAS,aAATA,MACF,OAAO,CAAC,SAAS,EAAEE,4BAA4B,2CAA2C,EAAED,QAAQ;IAGtG,IAAID,AAAS,cAATA,MACF,OAAO,CAAC,yDAAyD,EAAEE,4BAA4B,wDAAwD,EAAED,QAAQ;IAGnK,OAAO,GAAGD,KAAK,EAAE,EAAEE,4BAA4B,EAAE,EAAED,QAAQ;AAC7D;AAEO,MAAME,yBAAyB,CACpCC,iBACAC,WACAC;IAEA,MAAMC,gBACJ,AAAqB,YAArB,OAAOF,YACHA,YACAG,KAAK,SAAS,CAACH,WAAW,MAAM;IAEtC,MAAMI,iBAAiBH,SAAS;IAChC,MAAMI,iBAAiBD,iBAAiB,CAAC,EAAE,EAAEA,eAAe,EAAE,CAAC,GAAG;IAElE,OAAO,CAAC;;AAEV,EAAEL,gBAAgB;;AAElB,EAAEM,eAAe;;AAEjB,EAAEH,cAAc;;EAEd,CAAC;AACH"}
@@ -27,6 +27,7 @@ __webpack_require__.d(__webpack_exports__, {
27
27
  AiExtractElementInfo: ()=>AiExtractElementInfo
28
28
  });
29
29
  const logger_namespaceObject = require("@midscene/shared/logger");
30
+ const prompt_context_js_namespaceObject = require("../../../agent/prompt-context.js");
30
31
  const index_js_namespaceObject = require("../../prompt/insight/index.js");
31
32
  const external_service_caller_index_js_namespaceObject = require("../../service-caller/index.js");
32
33
  const semantic_retry_js_namespaceObject = require("../../service-caller/semantic-retry.js");
@@ -42,7 +43,9 @@ async function AiExtractElementInfo(options) {
42
43
  insightProtocol
43
44
  });
44
45
  const screenshotBase64 = context.screenshot.base64;
45
- const extractDataPromptText = (0, index_js_namespaceObject.extractDataQueryPrompt)(options.pageDescription || '', dataQuery, extractOption?.context);
46
+ const internalContextOptions = extractOption;
47
+ const renderedContext = (0, prompt_context_js_namespaceObject.renderAIContext)((0, prompt_context_js_namespaceObject.resolvedAIContextFromOptions)(internalContextOptions), internalContextOptions?._internalAdditionalContext);
48
+ const extractDataPromptText = (0, index_js_namespaceObject.extractDataQueryPrompt)(options.pageDescription || '', dataQuery, renderedContext);
46
49
  const userContent = [];
47
50
  if (extractOption?.screenshotIncluded !== false) {
48
51
  const screenshotSequence = context.screenshotSequence;
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/workflows/insight/extraction.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/workflows/insight/extraction.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 { ServiceExtractOption, UIContext } from '@/types';\nimport { getDebug } from '@midscene/shared/logger';\nimport type {\n ChatCompletionSystemMessageParam,\n ChatCompletionUserMessageParam,\n} from 'openai/resources/index';\nimport type { TMultimodalPrompt } from '../../../common';\nimport type { ModelRuntime } from '../../models';\nimport {\n buildInsightSystemPrompt,\n extractDataQueryPrompt,\n} from '../../prompt/insight';\nimport { AIResponseParseError, callAI } from '../../service-caller/index';\nimport {\n callAiAndParseWithRetry,\n withSemanticRetryFeedback,\n} from '../../service-caller/semantic-retry';\nimport { multimodalPromptToChatMessages } from '../../shared/multimodal-prompt';\nimport { parseInsightResponse } from './insight-response-parser';\n\ntype InsightAIArgs = [\n ChatCompletionSystemMessageParam,\n ...ChatCompletionUserMessageParam[],\n];\n\nconst debugInsight = getDebug('ai:insight');\n\nexport async function AiExtractElementInfo<T>(options: {\n dataQuery: string | Record<string, string>;\n multimodalPrompt?: TMultimodalPrompt;\n context: UIContext;\n pageDescription?: string;\n extractOption?: ServiceExtractOption;\n modelRuntime: ModelRuntime;\n abortSignal?: AbortSignal;\n}) {\n const { dataQuery, context, extractOption, multimodalPrompt, modelRuntime } =\n options;\n const insightProtocol = modelRuntime.adapter.insight.protocol;\n const systemPrompt = buildInsightSystemPrompt({\n screenshotIncluded: extractOption?.screenshotIncluded !== false,\n referenceImagesIncluded: !!multimodalPrompt?.images?.length,\n insightProtocol,\n });\n const screenshotBase64 = context.screenshot.base64;\n const extractDataPromptText = extractDataQueryPrompt(\n options.pageDescription || '',\n dataQuery,\n extractOption?.context,\n );\n\n const userContent: ChatCompletionUserMessageParam['content'] = [];\n\n if (extractOption?.screenshotIncluded !== false) {\n const screenshotSequence = context.screenshotSequence;\n if (screenshotSequence && screenshotSequence.length > 1) {\n userContent.push({\n type: 'text',\n text: `The following ${screenshotSequence.length} images are consecutive screenshots captured over a time window, ordered from earliest to latest (Frame 1 is first, Frame ${screenshotSequence.length} is last). They record what appeared on screen during that window. Some UI elements such as toasts, banners, or transitions may appear only in certain frames and be gone by later ones. Interpret the temporal scope from the statement or question itself: if it asks whether something appeared at any point, inspect the whole sequence; if it asks about the final or current state, use the relevant later frame; if it asks about a change or sequence, compare frames in order. Unless <DATA_DEMAND> explicitly asks for comparison or matching against reference images, base your answer on these screenshots and their contents.`,\n });\n\n screenshotSequence.forEach((frame, index) => {\n userContent.push({\n type: 'text',\n text: `Frame ${index + 1}/${screenshotSequence.length}`,\n });\n userContent.push({\n type: 'image_url',\n image_url: {\n url: frame.base64,\n detail: 'high',\n },\n });\n });\n } else {\n userContent.push({\n type: 'text',\n text: 'This is the current screenshot to evaluate. Unless <DATA_DEMAND> explicitly asks for comparison or matching against reference images, base your answer on this screenshot and its contents when provided.',\n });\n\n userContent.push({\n type: 'image_url',\n image_url: {\n url: screenshotBase64,\n detail: 'high',\n },\n });\n }\n }\n\n userContent.push({\n type: 'text',\n text: extractDataPromptText,\n });\n\n const msgs: InsightAIArgs = [\n { role: 'system', content: systemPrompt },\n {\n role: 'user',\n content: userContent,\n },\n ];\n\n if (multimodalPrompt) {\n const addOns = await multimodalPromptToChatMessages(multimodalPrompt);\n msgs.push(...addOns);\n }\n\n return callAiAndParseWithRetry({\n callAi: (retryAttempt, previousParseError) =>\n callAI(\n withSemanticRetryFeedback(msgs, previousParseError),\n modelRuntime,\n {\n abortSignal: options.abortSignal,\n semanticRetryAttempt: retryAttempt,\n },\n ),\n parseResponse: (response) => {\n const {\n content: rawResponse,\n usage,\n reasoning_content,\n rawChoiceMessage,\n } = response;\n const parseResult = parseInsightResponse<T>(\n rawResponse,\n insightProtocol.dataOutput,\n modelRuntime.adapter.jsonParser,\n );\n return {\n parseResult,\n rawResponse,\n rawChoiceMessage,\n usage,\n reasoning_content,\n };\n },\n toParseError: (parseError, response) => {\n const errorMessage =\n parseError instanceof Error ? parseError.message : String(parseError);\n return new AIResponseParseError(\n `XML parse error: ${errorMessage}`,\n response.content,\n response.usage,\n response.rawChoiceMessage,\n );\n },\n parseRetryTimes: modelRuntime.config.retryCount,\n parseRetryInterval: modelRuntime.config.retryInterval,\n abortSignal: options.abortSignal,\n onParseRetry: (error) => {\n debugInsight(\n 'retrying insight after XML parsing failed: %s',\n error instanceof Error ? error.message : String(error),\n );\n },\n });\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","debugInsight","getDebug","AiExtractElementInfo","options","dataQuery","context","extractOption","multimodalPrompt","modelRuntime","insightProtocol","systemPrompt","buildInsightSystemPrompt","screenshotBase64","extractDataPromptText","extractDataQueryPrompt","userContent","screenshotSequence","frame","index","msgs","addOns","multimodalPromptToChatMessages","callAiAndParseWithRetry","retryAttempt","previousParseError","callAI","withSemanticRetryFeedback","response","rawResponse","usage","reasoning_content","rawChoiceMessage","parseResult","parseInsightResponse","parseError","errorMessage","Error","String","AIResponseParseError","error"],"mappings":";;;IAAAA,oBAAoB,CAAC,G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,EACjB,GAAGJ;YACJ,MAAMK,cAAcC,AAAAA,IAAAA,oDAAAA,oBAAAA,AAAAA,EAClBL,aACAnB,gBAAgB,UAAU,EAC1BD,aAAa,OAAO,CAAC,UAAU;YAEjC,OAAO;gBACLwB;gBACAJ;gBACAG;gBACAF;gBACAC;YACF;QACF;QACA,cAAc,CAACI,YAAYP;YACzB,MAAMQ,eACJD,sBAAsBE,QAAQF,WAAW,OAAO,GAAGG,OAAOH;YAC5D,OAAO,IAAII,iDAAAA,oBAAoBA,CAC7B,CAAC,iBAAiB,EAAEH,cAAc,EAClCR,SAAS,OAAO,EAChBA,SAAS,KAAK,EACdA,SAAS,gBAAgB;QAE7B;QACA,iBAAiBnB,aAAa,MAAM,CAAC,UAAU;QAC/C,oBAAoBA,aAAa,MAAM,CAAC,aAAa;QACrD,aAAaL,QAAQ,WAAW;QAChC,cAAc,CAACoC;YACbvC,aACE,iDACAuC,iBAAiBH,QAAQG,MAAM,OAAO,GAAGF,OAAOE;QAEpD;IACF;AACF"}
1
+ {"version":3,"file":"ai-model/workflows/insight/extraction.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/workflows/insight/extraction.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 { ServiceExtractOption, UIContext } from '@/types';\nimport { getDebug } from '@midscene/shared/logger';\nimport type {\n ChatCompletionSystemMessageParam,\n ChatCompletionUserMessageParam,\n} from 'openai/resources/index';\nimport {\n type InternalAIContextOptions,\n renderAIContext,\n resolvedAIContextFromOptions,\n} from '../../../agent/prompt-context';\nimport type { TMultimodalPrompt } from '../../../common';\nimport type { ModelRuntime } from '../../models';\nimport {\n buildInsightSystemPrompt,\n extractDataQueryPrompt,\n} from '../../prompt/insight';\nimport { AIResponseParseError, callAI } from '../../service-caller/index';\nimport {\n callAiAndParseWithRetry,\n withSemanticRetryFeedback,\n} from '../../service-caller/semantic-retry';\nimport { multimodalPromptToChatMessages } from '../../shared/multimodal-prompt';\nimport { parseInsightResponse } from './insight-response-parser';\n\ntype InsightAIArgs = [\n ChatCompletionSystemMessageParam,\n ...ChatCompletionUserMessageParam[],\n];\n\nconst debugInsight = getDebug('ai:insight');\n\nexport async function AiExtractElementInfo<T>(options: {\n dataQuery: string | Record<string, string>;\n multimodalPrompt?: TMultimodalPrompt;\n context: UIContext;\n pageDescription?: string;\n extractOption?: ServiceExtractOption;\n modelRuntime: ModelRuntime;\n abortSignal?: AbortSignal;\n}) {\n const { dataQuery, context, extractOption, multimodalPrompt, modelRuntime } =\n options;\n const insightProtocol = modelRuntime.adapter.insight.protocol;\n const systemPrompt = buildInsightSystemPrompt({\n screenshotIncluded: extractOption?.screenshotIncluded !== false,\n referenceImagesIncluded: !!multimodalPrompt?.images?.length,\n insightProtocol,\n });\n const screenshotBase64 = context.screenshot.base64;\n\n const internalContextOptions = extractOption as\n | (ServiceExtractOption & InternalAIContextOptions)\n | undefined;\n const renderedContext = renderAIContext(\n resolvedAIContextFromOptions(internalContextOptions),\n internalContextOptions?._internalAdditionalContext,\n );\n const extractDataPromptText = extractDataQueryPrompt(\n options.pageDescription || '',\n dataQuery,\n renderedContext,\n );\n\n const userContent: ChatCompletionUserMessageParam['content'] = [];\n\n if (extractOption?.screenshotIncluded !== false) {\n const screenshotSequence = context.screenshotSequence;\n if (screenshotSequence && screenshotSequence.length > 1) {\n userContent.push({\n type: 'text',\n text: `The following ${screenshotSequence.length} images are consecutive screenshots captured over a time window, ordered from earliest to latest (Frame 1 is first, Frame ${screenshotSequence.length} is last). They record what appeared on screen during that window. Some UI elements such as toasts, banners, or transitions may appear only in certain frames and be gone by later ones. Interpret the temporal scope from the statement or question itself: if it asks whether something appeared at any point, inspect the whole sequence; if it asks about the final or current state, use the relevant later frame; if it asks about a change or sequence, compare frames in order. Unless <DATA_DEMAND> explicitly asks for comparison or matching against reference images, base your answer on these screenshots and their contents.`,\n });\n\n screenshotSequence.forEach((frame, index) => {\n userContent.push({\n type: 'text',\n text: `Frame ${index + 1}/${screenshotSequence.length}`,\n });\n userContent.push({\n type: 'image_url',\n image_url: {\n url: frame.base64,\n detail: 'high',\n },\n });\n });\n } else {\n userContent.push({\n type: 'text',\n text: 'This is the current screenshot to evaluate. Unless <DATA_DEMAND> explicitly asks for comparison or matching against reference images, base your answer on this screenshot and its contents when provided.',\n });\n\n userContent.push({\n type: 'image_url',\n image_url: {\n url: screenshotBase64,\n detail: 'high',\n },\n });\n }\n }\n\n userContent.push({\n type: 'text',\n text: extractDataPromptText,\n });\n\n const msgs: InsightAIArgs = [\n { role: 'system', content: systemPrompt },\n {\n role: 'user',\n content: userContent,\n },\n ];\n\n if (multimodalPrompt) {\n const addOns = await multimodalPromptToChatMessages(multimodalPrompt);\n msgs.push(...addOns);\n }\n\n return callAiAndParseWithRetry({\n callAi: (retryAttempt, previousParseError) =>\n callAI(\n withSemanticRetryFeedback(msgs, previousParseError),\n modelRuntime,\n {\n abortSignal: options.abortSignal,\n semanticRetryAttempt: retryAttempt,\n },\n ),\n parseResponse: (response) => {\n const {\n content: rawResponse,\n usage,\n reasoning_content,\n rawChoiceMessage,\n } = response;\n const parseResult = parseInsightResponse<T>(\n rawResponse,\n insightProtocol.dataOutput,\n modelRuntime.adapter.jsonParser,\n );\n return {\n parseResult,\n rawResponse,\n rawChoiceMessage,\n usage,\n reasoning_content,\n };\n },\n toParseError: (parseError, response) => {\n const errorMessage =\n parseError instanceof Error ? parseError.message : String(parseError);\n return new AIResponseParseError(\n `XML parse error: ${errorMessage}`,\n response.content,\n response.usage,\n response.rawChoiceMessage,\n );\n },\n parseRetryTimes: modelRuntime.config.retryCount,\n parseRetryInterval: modelRuntime.config.retryInterval,\n abortSignal: options.abortSignal,\n onParseRetry: (error) => {\n debugInsight(\n 'retrying insight after XML parsing failed: %s',\n error instanceof Error ? error.message : String(error),\n );\n },\n });\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","debugInsight","getDebug","AiExtractElementInfo","options","dataQuery","context","extractOption","multimodalPrompt","modelRuntime","insightProtocol","systemPrompt","buildInsightSystemPrompt","screenshotBase64","internalContextOptions","renderedContext","renderAIContext","resolvedAIContextFromOptions","extractDataPromptText","extractDataQueryPrompt","userContent","screenshotSequence","frame","index","msgs","addOns","multimodalPromptToChatMessages","callAiAndParseWithRetry","retryAttempt","previousParseError","callAI","withSemanticRetryFeedback","response","rawResponse","usage","reasoning_content","rawChoiceMessage","parseResult","parseInsightResponse","parseError","errorMessage","Error","String","AIResponseParseError","error"],"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;;;;;;;;;;;;;;AC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ACdA,SAAS,gBAAgB;QAE7B;QACA,iBAAiBvB,aAAa,MAAM,CAAC,UAAU;QAC/C,oBAAoBA,aAAa,MAAM,CAAC,aAAa;QACrD,aAAaL,QAAQ,WAAW;QAChC,cAAc,CAACwC;YACb3C,aACE,iDACA2C,iBAAiBH,QAAQG,MAAM,OAAO,GAAGF,OAAOE;QAEpD;IACF;AACF"}
@@ -32,13 +32,13 @@ const image_preprocess_js_namespaceObject = require("../../model-adapter/image-p
32
32
  const index_js_namespaceObject = require("../../service-caller/index.js");
33
33
  const multimodal_prompt_js_namespaceObject = require("../../shared/multimodal-prompt.js");
34
34
  const external_locate_normalization_js_namespaceObject = require("./locate-normalization.js");
35
- function appendHighPriorityKnowledge(systemPrompt, actionContext) {
36
- return systemPrompt + (actionContext ? `<high_priority_knowledge>${actionContext}</high_priority_knowledge>\n` : '');
35
+ function appendActionContext(systemPrompt, actionContext) {
36
+ return systemPrompt + (actionContext ? `${actionContext}\n` : '');
37
37
  }
38
38
  function buildCustomPlanningMessages(input, config) {
39
39
  const { options } = input;
40
40
  const { conversationHistory, context, actionContext } = options;
41
- const systemPrompt = appendHighPriorityKnowledge(config.buildSystemPrompt(), actionContext);
41
+ const systemPrompt = appendActionContext(config.buildSystemPrompt(), actionContext);
42
42
  const userInstructionText = input.userInstruction.text;
43
43
  const userInstruction = config.buildUserInstruction ? config.buildUserInstruction(userInstructionText) : userInstructionText;
44
44
  const referenceImageMessages = (0, multimodal_prompt_js_namespaceObject.preparedReferenceImagesToChatMessages)(input.userInstruction.referenceImages);
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/workflows/planning/custom-planning.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/workflows/planning/custom-planning.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 { PlanningAIResponse, PlanningAction } from '@/types';\nimport type { ChatCompletionMessageParam } from 'openai/resources/index';\nimport { ScreenshotItem } from '../../../screenshot-item';\nimport type {\n CustomPlanningInput,\n CustomPlanningMessageConfig,\n ResolvedCustomPlanningDefinition,\n} from '../../model-adapter/custom-planning-types';\nimport { prepareModelImage } from '../../model-adapter/image-preprocess';\nimport type { ParsedPlanningLocateParameter } from '../../model-adapter/planning-protocol';\nimport {\n AIResponseParseError,\n callAIWithStringResponse,\n} from '../../service-caller/index';\nimport {\n type PreparedUserPrompt,\n preparedReferenceImagesToChatMessages,\n} from '../../shared/multimodal-prompt';\nimport { normalizePlanningActionLocateFields } from './locate-normalization';\nimport type { PlanOptions } from './types';\n\nfunction appendHighPriorityKnowledge(\n systemPrompt: string,\n actionContext?: string,\n): string {\n return (\n systemPrompt +\n (actionContext\n ? `<high_priority_knowledge>${actionContext}</high_priority_knowledge>\\n`\n : '')\n );\n}\n\nexport function buildCustomPlanningMessages<TParsed>(\n input: CustomPlanningInput,\n config: CustomPlanningMessageConfig<TParsed>,\n): ChatCompletionMessageParam[] {\n const { options } = input;\n const { conversationHistory, context, actionContext } = options;\n const systemPrompt = appendHighPriorityKnowledge(\n config.buildSystemPrompt(),\n actionContext,\n );\n const userInstructionText = input.userInstruction.text;\n const userInstruction = config.buildUserInstruction\n ? config.buildUserInstruction(userInstructionText)\n : userInstructionText;\n const referenceImageMessages = preparedReferenceImagesToChatMessages(\n input.userInstruction.referenceImages,\n );\n\n if (conversationHistory.pendingFeedbackMessage) {\n conversationHistory.append({\n role: 'user',\n content: [\n {\n type: 'text',\n text: `${conversationHistory.pendingFeedbackMessage}. The previous action has been executed, here is the latest screenshot. Please continue according to the instruction.`,\n },\n ],\n });\n conversationHistory.resetPendingFeedbackMessageIfExists();\n }\n\n conversationHistory.append({\n role: 'user',\n content: [\n {\n type: 'image_url',\n image_url: { url: context.screenshot.base64 },\n },\n ],\n });\n\n if (config.systemPromptPlacement === 'system-message') {\n return [\n { role: 'system', content: systemPrompt },\n {\n role: 'user',\n content: [{ type: 'text', text: userInstruction }],\n },\n ...referenceImageMessages,\n ...conversationHistory.snapshot(config.historyImageLimit),\n ];\n }\n\n return [\n {\n role: 'user',\n content: `${systemPrompt}${userInstruction}`,\n },\n ...referenceImageMessages,\n ...conversationHistory.snapshot(config.historyImageLimit),\n ];\n}\n\nexport async function runCustomPlanning<TParsed>(\n userInstruction: PreparedUserPrompt,\n options: PlanOptions,\n config: ResolvedCustomPlanningDefinition<TParsed>,\n): Promise<PlanningAIResponse> {\n const { context } = options;\n const preparedImage = await prepareModelImage({\n imageBase64: context.screenshot.base64,\n width: context.shotSize.width,\n height: context.shotSize.height,\n policy: options.modelRuntime.adapter.imagePreprocess,\n });\n const preparedOptions: PlanOptions = {\n ...options,\n context: {\n ...context,\n screenshot: ScreenshotItem.create(\n preparedImage.imageBase64,\n context.screenshot.capturedAt,\n ),\n shotSize: preparedImage.preparedSize,\n },\n };\n const input: CustomPlanningInput = {\n userInstruction,\n options: preparedOptions,\n coordinateSystem: config.coordinateSystem,\n };\n\n const messages = buildCustomPlanningMessages(input, config.messages);\n const { content, usage, rawChoiceMessage } = await callAIWithStringResponse(\n messages,\n preparedOptions.modelRuntime,\n {\n abortSignal: preparedOptions.abortSignal,\n requiresOriginalImageDetail: preparedOptions.includeLocateInPlanning,\n },\n );\n\n let parsed: TParsed;\n let actions: PlanningAction[];\n let shouldContinuePlanning: boolean;\n\n try {\n parsed = config.parseResponse(content, input);\n actions = config.transformActions(parsed, input);\n normalizePlanningActionLocateFields(actions, {\n actionSpace: preparedOptions.actionSpace,\n includeLocateInPlanning: preparedOptions.includeLocateInPlanning,\n locateResultCodec: config.coordinateNormalizer,\n locateResultContext: {\n preparedSize: preparedImage.preparedSize,\n contentSize: preparedImage.contentSize,\n },\n acceptBbox2dAlias: preparedOptions.modelRuntime.adapter.acceptBbox2dAlias,\n parseRawLocateParameter: (value) =>\n value as ParsedPlanningLocateParameter,\n });\n shouldContinuePlanning = config.shouldContinuePlanning(parsed, actions);\n } catch (parseError) {\n const errorMessage = `Parse error: ${\n parseError instanceof Error ? parseError.message : String(parseError)\n }`;\n throw new AIResponseParseError(\n errorMessage,\n JSON.stringify(content, undefined, 2),\n usage,\n rawChoiceMessage,\n );\n }\n\n const assistantContent = config.messages.buildAssistantContent?.(\n parsed,\n content,\n input,\n );\n // UI-TARS and Auto-GLM define their own assistant history format.\n if (assistantContent) {\n options.conversationHistory.append({\n role: 'assistant',\n content: assistantContent,\n });\n }\n\n return {\n actions,\n log: config.buildResponseLog(parsed, content),\n usage,\n shouldContinuePlanning,\n rawResponse: JSON.stringify(content, undefined, 2),\n rawChoiceMessage,\n };\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","appendHighPriorityKnowledge","systemPrompt","actionContext","buildCustomPlanningMessages","input","config","options","conversationHistory","context","userInstructionText","userInstruction","referenceImageMessages","preparedReferenceImagesToChatMessages","runCustomPlanning","preparedImage","prepareModelImage","preparedOptions","ScreenshotItem","messages","content","usage","rawChoiceMessage","callAIWithStringResponse","parsed","actions","shouldContinuePlanning","normalizePlanningActionLocateFields","value","parseError","errorMessage","Error","String","AIResponseParseError","JSON","undefined","assistantContent"],"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;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6BAA6BA,gBAAgB,uBAAuB;IACtE;IAGF,IAAIO;IACJ,IAAIC;IACJ,IAAIC;IAEJ,IAAI;QACFF,SAASlB,OAAO,aAAa,CAACc,SAASf;QACvCoB,UAAUnB,OAAO,gBAAgB,CAACkB,QAAQnB;QAC1CsB,IAAAA,iDAAAA,mCAAAA,AAAAA,EAAoCF,SAAS;YAC3C,aAAaR,gBAAgB,WAAW;YACxC,yBAAyBA,gBAAgB,uBAAuB;YAChE,mBAAmBX,OAAO,oBAAoB;YAC9C,qBAAqB;gBACnB,cAAcS,cAAc,YAAY;gBACxC,aAAaA,cAAc,WAAW;YACxC;YACA,mBAAmBE,gBAAgB,YAAY,CAAC,OAAO,CAAC,iBAAiB;YACzE,yBAAyB,CAACW,QACxBA;QACJ;QACAF,yBAAyBpB,OAAO,sBAAsB,CAACkB,QAAQC;IACjE,EAAE,OAAOI,YAAY;QACnB,MAAMC,eAAe,CAAC,aAAa,EACjCD,sBAAsBE,QAAQF,WAAW,OAAO,GAAGG,OAAOH,aAC1D;QACF,MAAM,IAAII,yBAAAA,oBAAoBA,CAC5BH,cACAI,KAAK,SAAS,CAACd,SAASe,QAAW,IACnCd,OACAC;IAEJ;IAEA,MAAMc,mBAAmB9B,OAAO,QAAQ,CAAC,qBAAqB,GAC5DkB,QACAJ,SACAf;IAGF,IAAI+B,kBACF7B,QAAQ,mBAAmB,CAAC,MAAM,CAAC;QACjC,MAAM;QACN,SAAS6B;IACX;IAGF,OAAO;QACLX;QACA,KAAKnB,OAAO,gBAAgB,CAACkB,QAAQJ;QACrCC;QACAK;QACA,aAAaQ,KAAK,SAAS,CAACd,SAASe,QAAW;QAChDb;IACF;AACF"}
1
+ {"version":3,"file":"ai-model/workflows/planning/custom-planning.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/workflows/planning/custom-planning.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 { PlanningAIResponse, PlanningAction } from '@/types';\nimport type { ChatCompletionMessageParam } from 'openai/resources/index';\nimport { ScreenshotItem } from '../../../screenshot-item';\nimport type {\n CustomPlanningInput,\n CustomPlanningMessageConfig,\n ResolvedCustomPlanningDefinition,\n} from '../../model-adapter/custom-planning-types';\nimport { prepareModelImage } from '../../model-adapter/image-preprocess';\nimport type { ParsedPlanningLocateParameter } from '../../model-adapter/planning-protocol';\nimport {\n AIResponseParseError,\n callAIWithStringResponse,\n} from '../../service-caller/index';\nimport {\n type PreparedUserPrompt,\n preparedReferenceImagesToChatMessages,\n} from '../../shared/multimodal-prompt';\nimport { normalizePlanningActionLocateFields } from './locate-normalization';\nimport type { PlanOptions } from './types';\n\nfunction appendActionContext(\n systemPrompt: string,\n actionContext?: string,\n): string {\n return systemPrompt + (actionContext ? `${actionContext}\\n` : '');\n}\n\nexport function buildCustomPlanningMessages<TParsed>(\n input: CustomPlanningInput,\n config: CustomPlanningMessageConfig<TParsed>,\n): ChatCompletionMessageParam[] {\n const { options } = input;\n const { conversationHistory, context, actionContext } = options;\n const systemPrompt = appendActionContext(\n config.buildSystemPrompt(),\n actionContext,\n );\n const userInstructionText = input.userInstruction.text;\n const userInstruction = config.buildUserInstruction\n ? config.buildUserInstruction(userInstructionText)\n : userInstructionText;\n const referenceImageMessages = preparedReferenceImagesToChatMessages(\n input.userInstruction.referenceImages,\n );\n\n if (conversationHistory.pendingFeedbackMessage) {\n conversationHistory.append({\n role: 'user',\n content: [\n {\n type: 'text',\n text: `${conversationHistory.pendingFeedbackMessage}. The previous action has been executed, here is the latest screenshot. Please continue according to the instruction.`,\n },\n ],\n });\n conversationHistory.resetPendingFeedbackMessageIfExists();\n }\n\n conversationHistory.append({\n role: 'user',\n content: [\n {\n type: 'image_url',\n image_url: { url: context.screenshot.base64 },\n },\n ],\n });\n\n if (config.systemPromptPlacement === 'system-message') {\n return [\n { role: 'system', content: systemPrompt },\n {\n role: 'user',\n content: [{ type: 'text', text: userInstruction }],\n },\n ...referenceImageMessages,\n ...conversationHistory.snapshot(config.historyImageLimit),\n ];\n }\n\n return [\n {\n role: 'user',\n content: `${systemPrompt}${userInstruction}`,\n },\n ...referenceImageMessages,\n ...conversationHistory.snapshot(config.historyImageLimit),\n ];\n}\n\nexport async function runCustomPlanning<TParsed>(\n userInstruction: PreparedUserPrompt,\n options: PlanOptions,\n config: ResolvedCustomPlanningDefinition<TParsed>,\n): Promise<PlanningAIResponse> {\n const { context } = options;\n const preparedImage = await prepareModelImage({\n imageBase64: context.screenshot.base64,\n width: context.shotSize.width,\n height: context.shotSize.height,\n policy: options.modelRuntime.adapter.imagePreprocess,\n });\n const preparedOptions: PlanOptions = {\n ...options,\n context: {\n ...context,\n screenshot: ScreenshotItem.create(\n preparedImage.imageBase64,\n context.screenshot.capturedAt,\n ),\n shotSize: preparedImage.preparedSize,\n },\n };\n const input: CustomPlanningInput = {\n userInstruction,\n options: preparedOptions,\n coordinateSystem: config.coordinateSystem,\n };\n\n const messages = buildCustomPlanningMessages(input, config.messages);\n const { content, usage, rawChoiceMessage } = await callAIWithStringResponse(\n messages,\n preparedOptions.modelRuntime,\n {\n abortSignal: preparedOptions.abortSignal,\n requiresOriginalImageDetail: preparedOptions.includeLocateInPlanning,\n },\n );\n\n let parsed: TParsed;\n let actions: PlanningAction[];\n let shouldContinuePlanning: boolean;\n\n try {\n parsed = config.parseResponse(content, input);\n actions = config.transformActions(parsed, input);\n normalizePlanningActionLocateFields(actions, {\n actionSpace: preparedOptions.actionSpace,\n includeLocateInPlanning: preparedOptions.includeLocateInPlanning,\n locateResultCodec: config.coordinateNormalizer,\n locateResultContext: {\n preparedSize: preparedImage.preparedSize,\n contentSize: preparedImage.contentSize,\n },\n acceptBbox2dAlias: preparedOptions.modelRuntime.adapter.acceptBbox2dAlias,\n parseRawLocateParameter: (value) =>\n value as ParsedPlanningLocateParameter,\n });\n shouldContinuePlanning = config.shouldContinuePlanning(parsed, actions);\n } catch (parseError) {\n const errorMessage = `Parse error: ${\n parseError instanceof Error ? parseError.message : String(parseError)\n }`;\n throw new AIResponseParseError(\n errorMessage,\n JSON.stringify(content, undefined, 2),\n usage,\n rawChoiceMessage,\n );\n }\n\n const assistantContent = config.messages.buildAssistantContent?.(\n parsed,\n content,\n input,\n );\n // UI-TARS and Auto-GLM define their own assistant history format.\n if (assistantContent) {\n options.conversationHistory.append({\n role: 'assistant',\n content: assistantContent,\n });\n }\n\n return {\n actions,\n log: config.buildResponseLog(parsed, content),\n usage,\n shouldContinuePlanning,\n rawResponse: JSON.stringify(content, undefined, 2),\n rawChoiceMessage,\n };\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","appendActionContext","systemPrompt","actionContext","buildCustomPlanningMessages","input","config","options","conversationHistory","context","userInstructionText","userInstruction","referenceImageMessages","preparedReferenceImagesToChatMessages","runCustomPlanning","preparedImage","prepareModelImage","preparedOptions","ScreenshotItem","messages","content","usage","rawChoiceMessage","callAIWithStringResponse","parsed","actions","shouldContinuePlanning","normalizePlanningActionLocateFields","value","parseError","errorMessage","Error","String","AIResponseParseError","JSON","undefined","assistantContent"],"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;QAA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BA,gBAAgB,uBAAuB;IACtE;IAGF,IAAIO;IACJ,IAAIC;IACJ,IAAIC;IAEJ,IAAI;QACFF,SAASlB,OAAO,aAAa,CAACc,SAASf;QACvCoB,UAAUnB,OAAO,gBAAgB,CAACkB,QAAQnB;QAC1CsB,IAAAA,iDAAAA,mCAAAA,AAAAA,EAAoCF,SAAS;YAC3C,aAAaR,gBAAgB,WAAW;YACxC,yBAAyBA,gBAAgB,uBAAuB;YAChE,mBAAmBX,OAAO,oBAAoB;YAC9C,qBAAqB;gBACnB,cAAcS,cAAc,YAAY;gBACxC,aAAaA,cAAc,WAAW;YACxC;YACA,mBAAmBE,gBAAgB,YAAY,CAAC,OAAO,CAAC,iBAAiB;YACzE,yBAAyB,CAACW,QACxBA;QACJ;QACAF,yBAAyBpB,OAAO,sBAAsB,CAACkB,QAAQC;IACjE,EAAE,OAAOI,YAAY;QACnB,MAAMC,eAAe,CAAC,aAAa,EACjCD,sBAAsBE,QAAQF,WAAW,OAAO,GAAGG,OAAOH,aAC1D;QACF,MAAM,IAAII,yBAAAA,oBAAoBA,CAC5BH,cACAI,KAAK,SAAS,CAACd,SAASe,QAAW,IACnCd,OACAC;IAEJ;IAEA,MAAMc,mBAAmB9B,OAAO,QAAQ,CAAC,qBAAqB,GAC5DkB,QACAJ,SACAf;IAGF,IAAI+B,kBACF7B,QAAQ,mBAAmB,CAAC,MAAM,CAAC;QACjC,MAAM;QACN,SAAS6B;IACX;IAGF,OAAO;QACLX;QACA,KAAKnB,OAAO,gBAAgB,CAACkB,QAAQJ;QACrCC;QACAK;QACA,aAAaQ,KAAK,SAAS,CAACd,SAASe,QAAW;QAChDb;IACF;AACF"}
@@ -129,7 +129,7 @@ async function standardPlan(userInstruction, opts) {
129
129
  policy: adapter.imagePreprocess
130
130
  });
131
131
  const imagePayload = preparedImage.imageBase64;
132
- const actionContext = opts.actionContext ? `<high_priority_knowledge>${opts.actionContext}</high_priority_knowledge>\n` : '';
132
+ const actionContext = opts.actionContext ? `${opts.actionContext}\n` : '';
133
133
  const referenceImageMessages = (0, multimodal_prompt_js_namespaceObject.preparedReferenceImagesToChatMessages)(userInstruction.referenceImages);
134
134
  const instruction = [
135
135
  {
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/workflows/planning/standard-planning.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/workflows/planning/standard-planning.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 PlanningAIResponse,\n PlanningAction,\n RawResponsePlanningAIResponse,\n} from '@/types';\nimport { getDebug } from '@midscene/shared/logger';\nimport { assert } from '@midscene/shared/utils';\nimport type { ChatCompletionMessageParam } from 'openai/resources/index';\nimport { buildYamlFlowFromPlans } from '../../../common';\nimport { prepareModelImage } from '../../model-adapter/image-preprocess';\nimport { buildStandardPlanningSystemPrompt } from '../../prompt/planning';\nimport { AIResponseParseError, callAI } from '../../service-caller/index';\nimport {\n callAiAndParseWithRetry,\n withSemanticRetryFeedback,\n} from '../../service-caller/semantic-retry';\nimport type {\n LocateResultCodec,\n LocateResultContext,\n} from '../../shared/model-locate-result';\nimport { planningModelFamilyRequiredForLocateMessage } from '../../shared/model-locate-result/errors';\nimport {\n type PreparedUserPrompt,\n preparedReferenceImagesToChatMessages,\n} from '../../shared/multimodal-prompt';\nimport { normalizePlanningActionLocateFields } from './locate-normalization';\nimport { parseStandardPlanningResponse } from './standard-planning-parser';\nimport type { PlanOptions } from './types';\n\nconst debug = getDebug('planning');\nconst warnLog = getDebug('planning', { console: true });\n\nconst noPreviousActionsText =\n 'No previous actions have been executed in this aiAct execution yet. If the instruction asks for actions, choose the first action to execute.';\ntype PlanningCallResponse = Awaited<ReturnType<typeof callAI>>;\n\ntype CallAndParsePlanningResponseOptions = {\n messages: ChatCompletionMessageParam[];\n modelRuntime: PlanOptions['modelRuntime'];\n abortSignal?: AbortSignal;\n includeLocateInPlanning: boolean;\n actionSpace: PlanOptions['actionSpace'];\n locateResultCodec?: LocateResultCodec;\n locateResultContext: LocateResultContext;\n includeThought: boolean;\n includeLog: boolean;\n};\n\nasync function callAndParsePlanningResponse(\n options: CallAndParsePlanningResponseOptions,\n): Promise<{\n response: PlanningCallResponse;\n planFromAI: RawResponsePlanningAIResponse;\n actions: PlanningAction[];\n yamlFlow: ReturnType<typeof buildYamlFlowFromPlans>;\n}> {\n const {\n messages,\n modelRuntime,\n abortSignal,\n includeLocateInPlanning,\n actionSpace,\n locateResultCodec,\n locateResultContext,\n includeThought,\n includeLog,\n } = options;\n assert(\n modelRuntime.adapter.planning.kind === 'standard',\n 'callAndParsePlanningResponse requires a standard planning adapter',\n );\n const actionOutputProtocol =\n modelRuntime.adapter.planning.protocol.actionOutputProtocol;\n\n return callAiAndParseWithRetry({\n callAi: (retryAttempt, previousParseError) =>\n callAI(\n withSemanticRetryFeedback(messages, previousParseError),\n modelRuntime,\n {\n abortSignal,\n requiresOriginalImageDetail: includeLocateInPlanning,\n semanticRetryAttempt: retryAttempt,\n },\n ),\n parseResponse: (response) => {\n const planFromAI = parseStandardPlanningResponse(response.content, {\n includeThought,\n actionOutputProtocol,\n actionSpace,\n logSource: includeLog ? 'model' : 'action',\n });\n if (planFromAI.action && planFromAI.finalizeSuccess !== undefined) {\n warnLog(\n 'Planning response included both an action and <complete>; ignoring <complete> output.',\n );\n planFromAI.finalizeMessage = undefined;\n planFromAI.finalizeSuccess = undefined;\n }\n\n const actions = planFromAI.action ? [planFromAI.action] : [];\n normalizePlanningActionLocateFields(actions, {\n actionSpace,\n includeLocateInPlanning,\n locateResultCodec,\n locateResultContext,\n acceptBbox2dAlias: modelRuntime.adapter.acceptBbox2dAlias,\n parseRawLocateParameter: actionOutputProtocol.parseRawLocateParameter,\n });\n // dumpActionParam keeps only the locator prompt, so runtime-only\n // locatedPixelBbox fields added during normalization are not serialized.\n const yamlFlow = buildYamlFlowFromPlans(actions, actionSpace);\n return { response, planFromAI, actions, yamlFlow };\n },\n toParseError: (parseError, response) => {\n const errorMessage =\n parseError instanceof Error ? parseError.message : String(parseError);\n return new AIResponseParseError(\n `XML parse error: ${errorMessage}`,\n response.content,\n response.usage,\n response.rawChoiceMessage,\n response.reasoning_content,\n );\n },\n parseRetryTimes: modelRuntime.config.retryCount,\n parseRetryInterval: modelRuntime.config.retryInterval,\n abortSignal,\n onParseRetry: (parseError) => {\n debug(\n 'retrying plan after response parsing failed: %s',\n parseError instanceof Error ? parseError.message : String(parseError),\n );\n },\n });\n}\n\nexport async function standardPlan(\n userInstruction: PreparedUserPrompt,\n opts: PlanOptions,\n): Promise<PlanningAIResponse> {\n const { context, conversationHistory } = opts;\n const modelRuntime = opts.modelRuntime;\n const { adapter } = modelRuntime;\n const { shotSize } = context;\n const screenshotBase64 = context.screenshot.base64;\n assert(\n adapter.planning.kind === 'standard',\n 'standardPlan requires a standard planning adapter',\n );\n const planningProtocol = adapter.planning.protocol;\n\n if (opts.includeLocateInPlanning && !modelRuntime.config.modelFamily) {\n throw new Error(\n planningModelFamilyRequiredForLocateMessage(modelRuntime.config.slot),\n );\n }\n\n const locateResultCodec = modelRuntime.config.modelFamily\n ? adapter.planning.locateResultCodec\n : undefined;\n\n // Only enable sub-goals when aiAct is in deep-thinking planning mode.\n const includeSubGoals = opts.effort === 'deepThink';\n const includeThought = opts.effort !== 'fast';\n const includeLog = opts.effort !== 'fast';\n\n if (opts.includeLocateInPlanning && !locateResultCodec) {\n throw new Error(\n planningModelFamilyRequiredForLocateMessage(modelRuntime.config.slot),\n );\n }\n\n const systemPrompt = await buildStandardPlanningSystemPrompt({\n actionSpace: opts.actionSpace,\n includeThought,\n includeLog,\n includeSubGoals,\n planningProtocol,\n ...(opts.includeLocateInPlanning && locateResultCodec\n ? {\n includeLocateInPlanning: true,\n locatePromptSpec: locateResultCodec.promptSpec,\n }\n : { includeLocateInPlanning: false }),\n });\n\n const preparedImage = await prepareModelImage({\n imageBase64: screenshotBase64,\n width: shotSize.width,\n height: shotSize.height,\n policy: adapter.imagePreprocess,\n });\n const imagePayload = preparedImage.imageBase64;\n\n const actionContext = opts.actionContext\n ? `<high_priority_knowledge>${opts.actionContext}</high_priority_knowledge>\\n`\n : '';\n\n const referenceImageMessages = preparedReferenceImagesToChatMessages(\n userInstruction.referenceImages,\n );\n const instruction: ChatCompletionMessageParam[] = [\n {\n role: 'user',\n content: [\n {\n type: 'text',\n text: `${actionContext}<user_instruction>${userInstruction.text}</user_instruction>`,\n },\n ],\n },\n ...referenceImageMessages,\n ];\n\n let latestFeedbackMessage: ChatCompletionMessageParam;\n\n // Build sub-goal status text to include in the message\n // In planning deep-think mode: show full sub-goals with logs\n // Otherwise: show historical execution logs\n const executionProgressText = includeSubGoals\n ? conversationHistory.subGoalsToText()\n : conversationHistory.historicalLogsToText();\n const executionProgressSection = executionProgressText\n ? `\\n\\n${executionProgressText}`\n : conversationHistory.pendingFeedbackMessage\n ? ''\n : `\\n\\n${noPreviousActionsText}`;\n\n // Build memories text to include in the message\n const memoriesText = conversationHistory.memoriesToText();\n const memoriesSection = memoriesText ? `\\n\\n${memoriesText}` : '';\n\n if (conversationHistory.pendingFeedbackMessage) {\n latestFeedbackMessage = {\n role: 'user',\n content: [\n {\n type: 'text',\n text: `${conversationHistory.pendingFeedbackMessage}. The previous action has been executed, here is the latest screenshot. Please continue according to the instruction.${memoriesSection}${executionProgressSection}`,\n },\n {\n type: 'image_url',\n image_url: {\n url: imagePayload,\n detail: 'high',\n },\n },\n ],\n };\n\n conversationHistory.resetPendingFeedbackMessageIfExists();\n } else {\n latestFeedbackMessage = {\n role: 'user',\n content: [\n {\n type: 'text',\n text: `This is the current screenshot.${memoriesSection}${executionProgressSection}`,\n },\n {\n type: 'image_url',\n image_url: {\n url: imagePayload,\n detail: 'high',\n },\n },\n ],\n };\n }\n conversationHistory.append(latestFeedbackMessage);\n\n // Compress history if it exceeds the threshold to avoid context overflow\n conversationHistory.compressHistory(50, 20);\n\n const historyLog = conversationHistory.snapshot(opts.imagesIncludeCount);\n\n const msgs: ChatCompletionMessageParam[] = [\n { role: 'system', content: systemPrompt },\n ...instruction,\n ...historyLog,\n ];\n\n const {\n response: {\n content: rawResponse,\n usage,\n reasoning_content,\n rawChoiceMessage,\n },\n planFromAI,\n actions,\n yamlFlow,\n } = await callAndParsePlanningResponse({\n messages: msgs,\n modelRuntime,\n abortSignal: opts.abortSignal,\n includeLocateInPlanning: opts.includeLocateInPlanning,\n actionSpace: opts.actionSpace,\n locateResultCodec,\n locateResultContext: {\n preparedSize: preparedImage.preparedSize,\n contentSize: preparedImage.contentSize,\n },\n includeThought,\n includeLog,\n });\n\n let shouldContinuePlanning = true;\n\n // Check if task is completed via <complete> tag\n if (planFromAI.finalizeSuccess !== undefined) {\n debug('task completed via <complete> tag, stop planning');\n shouldContinuePlanning = false;\n // Mark all sub-goals as finished when goal is completed in planning deep-think mode.\n if (includeSubGoals) {\n conversationHistory.markAllSubGoalsFinished();\n }\n }\n\n const returnValue: PlanningAIResponse = {\n ...planFromAI,\n actions,\n rawResponse,\n rawChoiceMessage,\n usage,\n reasoning_content,\n yamlFlow,\n shouldContinuePlanning,\n };\n\n assert(planFromAI, \"can't get plans from AI\");\n\n // TODO: The plan log is recorded before its action has executed, so a failed\n // action may still appear in the next round as an action already performed.\n // Move this write to the successful action execution path in TaskExecutor.action.\n // Update sub-goals in conversation history only in planning deep-think mode.\n if (includeSubGoals) {\n if (planFromAI.updateSubGoals?.length) {\n conversationHistory.mergeSubGoals(planFromAI.updateSubGoals);\n }\n if (planFromAI.markFinishedIndexes?.length) {\n for (const index of planFromAI.markFinishedIndexes) {\n conversationHistory.markSubGoalFinished(index);\n }\n }\n // Append the planning log to the currently running sub-goal\n if (planFromAI.log) {\n conversationHistory.appendSubGoalLog(planFromAI.log);\n }\n } else {\n // Without planning deep-think mode, accumulate logs as historical execution steps.\n if (planFromAI.log) {\n conversationHistory.appendHistoricalLog(planFromAI.log);\n }\n }\n\n // Append memory to conversation history if present\n if (planFromAI.memory) {\n conversationHistory.appendMemory(planFromAI.memory);\n }\n\n // Some model providers require opaque assistant fields to be replayed\n // verbatim in later turns. Keep this opt-in per model adapter so that an\n // unverified provider does not receive non-standard response fields.\n if (\n modelRuntime.adapter.chatCompletion.replayRawAssistantMessage &&\n rawChoiceMessage\n ) {\n conversationHistory.append(rawChoiceMessage as ChatCompletionMessageParam);\n } else {\n conversationHistory.append({\n role: 'assistant',\n content: [\n {\n type: 'text',\n text: rawResponse,\n },\n ],\n });\n }\n\n return returnValue;\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","debug","getDebug","warnLog","noPreviousActionsText","callAndParsePlanningResponse","options","messages","modelRuntime","abortSignal","includeLocateInPlanning","actionSpace","locateResultCodec","locateResultContext","includeThought","includeLog","assert","actionOutputProtocol","callAiAndParseWithRetry","retryAttempt","previousParseError","callAI","withSemanticRetryFeedback","response","planFromAI","parseStandardPlanningResponse","undefined","actions","normalizePlanningActionLocateFields","yamlFlow","buildYamlFlowFromPlans","parseError","errorMessage","Error","String","AIResponseParseError","standardPlan","userInstruction","opts","context","conversationHistory","adapter","shotSize","screenshotBase64","planningProtocol","planningModelFamilyRequiredForLocateMessage","includeSubGoals","systemPrompt","buildStandardPlanningSystemPrompt","preparedImage","prepareModelImage","imagePayload","actionContext","referenceImageMessages","preparedReferenceImagesToChatMessages","instruction","latestFeedbackMessage","executionProgressText","executionProgressSection","memoriesText","memoriesSection","historyLog","msgs","rawResponse","usage","reasoning_content","rawChoiceMessage","shouldContin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,GAAG,EAChBgB,oBAAoB,gBAAgB,CAAChB,WAAW,GAAG;IAEvD,OAEE,IAAIA,WAAW,GAAG,EAChBgB,oBAAoB,mBAAmB,CAAChB,WAAW,GAAG;IAK1D,IAAIA,WAAW,MAAM,EACnBgB,oBAAoB,YAAY,CAAChB,WAAW,MAAM;IAMpD,IACEhB,aAAa,OAAO,CAAC,cAAc,CAAC,yBAAyB,IAC7D0D,kBAEA1B,oBAAoB,MAAM,CAAC0B;SAE3B1B,oBAAoB,MAAM,CAAC;QACzB,MAAM;QACN,SAAS;YACP;gBACE,MAAM;gBACN,MAAMuB;YACR;SACD;IACH;IAGF,OAAOK;AACT"}
1
+ {"version":3,"file":"ai-model/workflows/planning/standard-planning.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/workflows/planning/standard-planning.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 PlanningAIResponse,\n PlanningAction,\n RawResponsePlanningAIResponse,\n} from '@/types';\nimport { getDebug } from '@midscene/shared/logger';\nimport { assert } from '@midscene/shared/utils';\nimport type { ChatCompletionMessageParam } from 'openai/resources/index';\nimport { buildYamlFlowFromPlans } from '../../../common';\nimport { prepareModelImage } from '../../model-adapter/image-preprocess';\nimport { buildStandardPlanningSystemPrompt } from '../../prompt/planning';\nimport { AIResponseParseError, callAI } from '../../service-caller/index';\nimport {\n callAiAndParseWithRetry,\n withSemanticRetryFeedback,\n} from '../../service-caller/semantic-retry';\nimport type {\n LocateResultCodec,\n LocateResultContext,\n} from '../../shared/model-locate-result';\nimport { planningModelFamilyRequiredForLocateMessage } from '../../shared/model-locate-result/errors';\nimport {\n type PreparedUserPrompt,\n preparedReferenceImagesToChatMessages,\n} from '../../shared/multimodal-prompt';\nimport { normalizePlanningActionLocateFields } from './locate-normalization';\nimport { parseStandardPlanningResponse } from './standard-planning-parser';\nimport type { PlanOptions } from './types';\n\nconst debug = getDebug('planning');\nconst warnLog = getDebug('planning', { console: true });\n\nconst noPreviousActionsText =\n 'No previous actions have been executed in this aiAct execution yet. If the instruction asks for actions, choose the first action to execute.';\ntype PlanningCallResponse = Awaited<ReturnType<typeof callAI>>;\n\ntype CallAndParsePlanningResponseOptions = {\n messages: ChatCompletionMessageParam[];\n modelRuntime: PlanOptions['modelRuntime'];\n abortSignal?: AbortSignal;\n includeLocateInPlanning: boolean;\n actionSpace: PlanOptions['actionSpace'];\n locateResultCodec?: LocateResultCodec;\n locateResultContext: LocateResultContext;\n includeThought: boolean;\n includeLog: boolean;\n};\n\nasync function callAndParsePlanningResponse(\n options: CallAndParsePlanningResponseOptions,\n): Promise<{\n response: PlanningCallResponse;\n planFromAI: RawResponsePlanningAIResponse;\n actions: PlanningAction[];\n yamlFlow: ReturnType<typeof buildYamlFlowFromPlans>;\n}> {\n const {\n messages,\n modelRuntime,\n abortSignal,\n includeLocateInPlanning,\n actionSpace,\n locateResultCodec,\n locateResultContext,\n includeThought,\n includeLog,\n } = options;\n assert(\n modelRuntime.adapter.planning.kind === 'standard',\n 'callAndParsePlanningResponse requires a standard planning adapter',\n );\n const actionOutputProtocol =\n modelRuntime.adapter.planning.protocol.actionOutputProtocol;\n\n return callAiAndParseWithRetry({\n callAi: (retryAttempt, previousParseError) =>\n callAI(\n withSemanticRetryFeedback(messages, previousParseError),\n modelRuntime,\n {\n abortSignal,\n requiresOriginalImageDetail: includeLocateInPlanning,\n semanticRetryAttempt: retryAttempt,\n },\n ),\n parseResponse: (response) => {\n const planFromAI = parseStandardPlanningResponse(response.content, {\n includeThought,\n actionOutputProtocol,\n actionSpace,\n logSource: includeLog ? 'model' : 'action',\n });\n if (planFromAI.action && planFromAI.finalizeSuccess !== undefined) {\n warnLog(\n 'Planning response included both an action and <complete>; ignoring <complete> output.',\n );\n planFromAI.finalizeMessage = undefined;\n planFromAI.finalizeSuccess = undefined;\n }\n\n const actions = planFromAI.action ? [planFromAI.action] : [];\n normalizePlanningActionLocateFields(actions, {\n actionSpace,\n includeLocateInPlanning,\n locateResultCodec,\n locateResultContext,\n acceptBbox2dAlias: modelRuntime.adapter.acceptBbox2dAlias,\n parseRawLocateParameter: actionOutputProtocol.parseRawLocateParameter,\n });\n // dumpActionParam keeps only the locator prompt, so runtime-only\n // locatedPixelBbox fields added during normalization are not serialized.\n const yamlFlow = buildYamlFlowFromPlans(actions, actionSpace);\n return { response, planFromAI, actions, yamlFlow };\n },\n toParseError: (parseError, response) => {\n const errorMessage =\n parseError instanceof Error ? parseError.message : String(parseError);\n return new AIResponseParseError(\n `XML parse error: ${errorMessage}`,\n response.content,\n response.usage,\n response.rawChoiceMessage,\n response.reasoning_content,\n );\n },\n parseRetryTimes: modelRuntime.config.retryCount,\n parseRetryInterval: modelRuntime.config.retryInterval,\n abortSignal,\n onParseRetry: (parseError) => {\n debug(\n 'retrying plan after response parsing failed: %s',\n parseError instanceof Error ? parseError.message : String(parseError),\n );\n },\n });\n}\n\nexport async function standardPlan(\n userInstruction: PreparedUserPrompt,\n opts: PlanOptions,\n): Promise<PlanningAIResponse> {\n const { context, conversationHistory } = opts;\n const modelRuntime = opts.modelRuntime;\n const { adapter } = modelRuntime;\n const { shotSize } = context;\n const screenshotBase64 = context.screenshot.base64;\n assert(\n adapter.planning.kind === 'standard',\n 'standardPlan requires a standard planning adapter',\n );\n const planningProtocol = adapter.planning.protocol;\n\n if (opts.includeLocateInPlanning && !modelRuntime.config.modelFamily) {\n throw new Error(\n planningModelFamilyRequiredForLocateMessage(modelRuntime.config.slot),\n );\n }\n\n const locateResultCodec = modelRuntime.config.modelFamily\n ? adapter.planning.locateResultCodec\n : undefined;\n\n // Only enable sub-goals when aiAct is in deep-thinking planning mode.\n const includeSubGoals = opts.effort === 'deepThink';\n const includeThought = opts.effort !== 'fast';\n const includeLog = opts.effort !== 'fast';\n\n if (opts.includeLocateInPlanning && !locateResultCodec) {\n throw new Error(\n planningModelFamilyRequiredForLocateMessage(modelRuntime.config.slot),\n );\n }\n\n const systemPrompt = await buildStandardPlanningSystemPrompt({\n actionSpace: opts.actionSpace,\n includeThought,\n includeLog,\n includeSubGoals,\n planningProtocol,\n ...(opts.includeLocateInPlanning && locateResultCodec\n ? {\n includeLocateInPlanning: true,\n locatePromptSpec: locateResultCodec.promptSpec,\n }\n : { includeLocateInPlanning: false }),\n });\n\n const preparedImage = await prepareModelImage({\n imageBase64: screenshotBase64,\n width: shotSize.width,\n height: shotSize.height,\n policy: adapter.imagePreprocess,\n });\n const imagePayload = preparedImage.imageBase64;\n\n const actionContext = opts.actionContext ? `${opts.actionContext}\\n` : '';\n\n const referenceImageMessages = preparedReferenceImagesToChatMessages(\n userInstruction.referenceImages,\n );\n const instruction: ChatCompletionMessageParam[] = [\n {\n role: 'user',\n content: [\n {\n type: 'text',\n text: `${actionContext}<user_instruction>${userInstruction.text}</user_instruction>`,\n },\n ],\n },\n ...referenceImageMessages,\n ];\n\n let latestFeedbackMessage: ChatCompletionMessageParam;\n\n // Build sub-goal status text to include in the message\n // In planning deep-think mode: show full sub-goals with logs\n // Otherwise: show historical execution logs\n const executionProgressText = includeSubGoals\n ? conversationHistory.subGoalsToText()\n : conversationHistory.historicalLogsToText();\n const executionProgressSection = executionProgressText\n ? `\\n\\n${executionProgressText}`\n : conversationHistory.pendingFeedbackMessage\n ? ''\n : `\\n\\n${noPreviousActionsText}`;\n\n // Build memories text to include in the message\n const memoriesText = conversationHistory.memoriesToText();\n const memoriesSection = memoriesText ? `\\n\\n${memoriesText}` : '';\n\n if (conversationHistory.pendingFeedbackMessage) {\n latestFeedbackMessage = {\n role: 'user',\n content: [\n {\n type: 'text',\n text: `${conversationHistory.pendingFeedbackMessage}. The previous action has been executed, here is the latest screenshot. Please continue according to the instruction.${memoriesSection}${executionProgressSection}`,\n },\n {\n type: 'image_url',\n image_url: {\n url: imagePayload,\n detail: 'high',\n },\n },\n ],\n };\n\n conversationHistory.resetPendingFeedbackMessageIfExists();\n } else {\n latestFeedbackMessage = {\n role: 'user',\n content: [\n {\n type: 'text',\n text: `This is the current screenshot.${memoriesSection}${executionProgressSection}`,\n },\n {\n type: 'image_url',\n image_url: {\n url: imagePayload,\n detail: 'high',\n },\n },\n ],\n };\n }\n conversationHistory.append(latestFeedbackMessage);\n\n // Compress history if it exceeds the threshold to avoid context overflow\n conversationHistory.compressHistory(50, 20);\n\n const historyLog = conversationHistory.snapshot(opts.imagesIncludeCount);\n\n const msgs: ChatCompletionMessageParam[] = [\n { role: 'system', content: systemPrompt },\n ...instruction,\n ...historyLog,\n ];\n\n const {\n response: {\n content: rawResponse,\n usage,\n reasoning_content,\n rawChoiceMessage,\n },\n planFromAI,\n actions,\n yamlFlow,\n } = await callAndParsePlanningResponse({\n messages: msgs,\n modelRuntime,\n abortSignal: opts.abortSignal,\n includeLocateInPlanning: opts.includeLocateInPlanning,\n actionSpace: opts.actionSpace,\n locateResultCodec,\n locateResultContext: {\n preparedSize: preparedImage.preparedSize,\n contentSize: preparedImage.contentSize,\n },\n includeThought,\n includeLog,\n });\n\n let shouldContinuePlanning = true;\n\n // Check if task is completed via <complete> tag\n if (planFromAI.finalizeSuccess !== undefined) {\n debug('task completed via <complete> tag, stop planning');\n shouldContinuePlanning = false;\n // Mark all sub-goals as finished when goal is completed in planning deep-think mode.\n if (includeSubGoals) {\n conversationHistory.markAllSubGoalsFinished();\n }\n }\n\n const returnValue: PlanningAIResponse = {\n ...planFromAI,\n actions,\n rawResponse,\n rawChoiceMessage,\n usage,\n reasoning_content,\n yamlFlow,\n shouldContinuePlanning,\n };\n\n assert(planFromAI, \"can't get plans from AI\");\n\n // TODO: The plan log is recorded before its action has executed, so a failed\n // action may still appear in the next round as an action already performed.\n // Move this write to the successful action execution path in TaskExecutor.action.\n // Update sub-goals in conversation history only in planning deep-think mode.\n if (includeSubGoals) {\n if (planFromAI.updateSubGoals?.length) {\n conversationHistory.mergeSubGoals(planFromAI.updateSubGoals);\n }\n if (planFromAI.markFinishedIndexes?.length) {\n for (const index of planFromAI.markFinishedIndexes) {\n conversationHistory.markSubGoalFinished(index);\n }\n }\n // Append the planning log to the currently running sub-goal\n if (planFromAI.log) {\n conversationHistory.appendSubGoalLog(planFromAI.log);\n }\n } else {\n // Without planning deep-think mode, accumulate logs as historical execution steps.\n if (planFromAI.log) {\n conversationHistory.appendHistoricalLog(planFromAI.log);\n }\n }\n\n // Append memory to conversation history if present\n if (planFromAI.memory) {\n conversationHistory.appendMemory(planFromAI.memory);\n }\n\n // Some model providers require opaque assistant fields to be replayed\n // verbatim in later turns. Keep this opt-in per model adapter so that an\n // unverified provider does not receive non-standard response fields.\n if (\n modelRuntime.adapter.chatCompletion.replayRawAssistantMessage &&\n rawChoiceMessage\n ) {\n conversationHistory.append(rawChoiceMessage as ChatCompletionMessageParam);\n } else {\n conversationHistory.append({\n role: 'assistant',\n content: [\n {\n type: 'text',\n text: rawResponse,\n },\n ],\n });\n }\n\n return returnValue;\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","debug","getDebug","warnLog","noPreviousActionsText","callAndParsePlanningResponse","options","messages","modelRuntime","abortSignal","includeLocateInPlanning","actionSpace","locateResultCodec","locateResultContext","includeThought","includeLog","assert","actionOutputProtocol","callAiAndParseWithRetry","retryAttempt","previousParseError","callAI","withSemanticRetryFeedback","response","planFromAI","parseStandardPlanningResponse","undefined","actions","normalizePlanningActionLocateFields","yamlFlow","buildYamlFlowFromPlans","parseError","errorMessage","Error","String","AIResponseParseError","standardPlan","userInstruction","opts","context","conversationHistory","adapter","shotSize","screenshotBase64","planningProtocol","planningModelFamilyRequiredForLocateMessage","includeSubGoals","systemPrompt","buildStandardPlanningSystemPrompt","preparedImage","prepareModelImage","imagePayload","actionContext","referenceImageMessages","preparedReferenceImagesToChatMessages","instruction","latestFeedbackMessage","executionProgressText","executionProgressSection","memoriesText","memoriesSection","historyLog","msgs","rawResponse","usage","reasoning_content","rawChoiceMessage","shouldContinuePlanning","returnValue","index"],"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;;;;;;;;;;;;;;;;;;ACuBA,MAAMI,QAAQC,AAAAA,IAAAA,uBAAAA,QAAAA,AAAAA,EAAS;AACvB,MAAMC,UAAUD,AAAAA,IAAAA,uBAAAA,QAAAA,AAAAA,EAAS,YAAY;IAAE,SAAS;AAAK;AAErD,MAAME,wBACJ;AAeF,eAAeC,6BACbC,OAA4C;IAO5C,MAAM,EACJC,QAAQ,EACRC,YAAY,EACZC,WAAW,EACXC,uBAAuB,EACvBC,WAAW,EACXC,iBAAiB,EACjBC,mBAAmB,EACnBC,cAAc,EACdC,UAAU,EACX,GAAGT;IACJU,IAAAA,sBAAAA,MAAAA,AAA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MnB,IAAIsB,iBAAiB;QACnB,IAAItB,WAAW,cAAc,EAAE,QAC7BgB,oBAAoB,aAAa,CAAChB,WAAW,cAAc;QAE7D,IAAIA,WAAW,mBAAmB,EAAE,QAClC,KAAK,MAAM6C,SAAS7C,WAAW,mBAAmB,CAChDgB,oBAAoB,mBAAmB,CAAC6B;QAI5C,IAAI7C,WAAW,GAAG,EAChBgB,oBAAoB,gBAAgB,CAAChB,WAAW,GAAG;IAEvD,OAEE,IAAIA,WAAW,GAAG,EAChBgB,oBAAoB,mBAAmB,CAAChB,WAAW,GAAG;IAK1D,IAAIA,WAAW,MAAM,EACnBgB,oBAAoB,YAAY,CAAChB,WAAW,MAAM;IAMpD,IACEhB,aAAa,OAAO,CAAC,cAAc,CAAC,yBAAyB,IAC7D0D,kBAEA1B,oBAAoB,MAAM,CAAC0B;SAE3B1B,oBAAoB,MAAM,CAAC;QACzB,MAAM;QACN,SAAS;YACP;gBACE,MAAM;gBACN,MAAMuB;YACR;SACD;IACH;IAGF,OAAOK;AACT"}
package/dist/lib/index.js CHANGED
@@ -51,8 +51,9 @@ __webpack_require__.d(__webpack_exports__, {
51
51
  default: ()=>src,
52
52
  getVersion: ()=>external_utils_js_namespaceObject.getVersion,
53
53
  getMidsceneLocationSchema: ()=>external_ai_model_index_js_namespaceObject.getMidsceneLocationSchema,
54
- parseDumpScript: ()=>external_dump_index_js_namespaceObject.parseDumpScript,
54
+ mergeAIContexts: ()=>external_agent_index_js_namespaceObject.mergeAIContexts,
55
55
  ServiceError: ()=>external_types_js_namespaceObject.ServiceError,
56
+ parseDumpScript: ()=>external_dump_index_js_namespaceObject.parseDumpScript,
56
57
  parseImageScripts: ()=>external_dump_index_js_namespaceObject.parseImageScripts,
57
58
  PointSchema: ()=>external_ai_model_index_js_namespaceObject.PointSchema,
58
59
  RectSchema: ()=>external_ai_model_index_js_namespaceObject.RectSchema,
@@ -142,6 +143,7 @@ exports.getMidsceneLocationSchema = __webpack_exports__.getMidsceneLocationSchem
142
143
  exports.getTaskSearchArea = __webpack_exports__.getTaskSearchArea;
143
144
  exports.getTaskServiceDump = __webpack_exports__.getTaskServiceDump;
144
145
  exports.getVersion = __webpack_exports__.getVersion;
146
+ exports.mergeAIContexts = __webpack_exports__.mergeAIContexts;
145
147
  exports.mergeReportFiles = __webpack_exports__.mergeReportFiles;
146
148
  exports.nullReportGenerator = __webpack_exports__.nullReportGenerator;
147
149
  exports.parseDumpScript = __webpack_exports__.parseDumpScript;
@@ -196,6 +198,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
196
198
  "getTaskSearchArea",
197
199
  "getTaskServiceDump",
198
200
  "getVersion",
201
+ "mergeAIContexts",
199
202
  "mergeReportFiles",
200
203
  "nullReportGenerator",
201
204
  "parseDumpScript",