@midscene/core 1.10.13-beta-20260818121107.0 → 1.11.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 (43) hide show
  1. package/dist/es/agent/utils.mjs +1 -1
  2. package/dist/es/ai-model/prompt/planning/action-description.mjs +4 -3
  3. package/dist/es/ai-model/prompt/planning/action-description.mjs.map +1 -1
  4. package/dist/es/ai-model/prompt/planning/action-example.mjs +3 -30
  5. package/dist/es/ai-model/prompt/planning/action-example.mjs.map +1 -1
  6. package/dist/es/ai-model/prompt/planning/action-output-protocol.mjs +39 -0
  7. package/dist/es/ai-model/prompt/planning/action-output-protocol.mjs.map +1 -0
  8. package/dist/es/ai-model/prompt/planning/index.mjs +3 -2
  9. package/dist/es/ai-model/prompt/planning/multi-turn-example.mjs +11 -5
  10. package/dist/es/ai-model/prompt/planning/multi-turn-example.mjs.map +1 -1
  11. package/dist/es/ai-model/prompt/planning/system-prompt.mjs +82 -72
  12. package/dist/es/ai-model/prompt/planning/system-prompt.mjs.map +1 -1
  13. package/dist/es/task-runner.mjs +3 -9
  14. package/dist/es/task-runner.mjs.map +1 -1
  15. package/dist/es/utils.mjs +2 -2
  16. package/dist/lib/agent/utils.js +1 -1
  17. package/dist/lib/ai-model/prompt/planning/action-description.js +4 -3
  18. package/dist/lib/ai-model/prompt/planning/action-description.js.map +1 -1
  19. package/dist/lib/ai-model/prompt/planning/action-example.js +4 -34
  20. package/dist/lib/ai-model/prompt/planning/action-example.js.map +1 -1
  21. package/dist/lib/ai-model/prompt/planning/action-output-protocol.js +76 -0
  22. package/dist/lib/ai-model/prompt/planning/action-output-protocol.js.map +1 -0
  23. package/dist/lib/ai-model/prompt/planning/index.js +5 -1
  24. package/dist/lib/ai-model/prompt/planning/multi-turn-example.js +11 -5
  25. package/dist/lib/ai-model/prompt/planning/multi-turn-example.js.map +1 -1
  26. package/dist/lib/ai-model/prompt/planning/system-prompt.js +82 -72
  27. package/dist/lib/ai-model/prompt/planning/system-prompt.js.map +1 -1
  28. package/dist/lib/task-runner.js +3 -9
  29. package/dist/lib/task-runner.js.map +1 -1
  30. package/dist/lib/utils.js +2 -2
  31. package/dist/types/ai-model/prompt/planning/action-description.d.ts +5 -2
  32. package/dist/types/ai-model/prompt/planning/action-example.d.ts +4 -11
  33. package/dist/types/ai-model/prompt/planning/action-output-protocol.d.ts +18 -0
  34. package/dist/types/ai-model/prompt/planning/index.d.ts +3 -1
  35. package/dist/types/ai-model/prompt/planning/multi-turn-example.d.ts +3 -1
  36. package/dist/types/ai-model/prompt/planning/system-prompt.d.ts +2 -0
  37. package/dist/types/task-runner.d.ts +0 -13
  38. package/package.json +2 -2
  39. package/dist/es/ai-model/prompt/planning/action-guidelines.mjs +0 -14
  40. package/dist/es/ai-model/prompt/planning/action-guidelines.mjs.map +0 -1
  41. package/dist/lib/ai-model/prompt/planning/action-guidelines.js +0 -48
  42. package/dist/lib/ai-model/prompt/planning/action-guidelines.js.map +0 -1
  43. package/dist/types/ai-model/prompt/planning/action-guidelines.d.ts +0 -2
@@ -181,7 +181,7 @@ async function matchElementFromCache(context, cacheEntry, cachePrompt, cacheable
181
181
  return;
182
182
  }
183
183
  }
184
- const getMidsceneVersion = ()=>"1.10.13-beta-20260818121107.0";
184
+ const getMidsceneVersion = ()=>"1.11.0";
185
185
  const parsePrompt = (prompt)=>{
186
186
  if ('string' == typeof prompt) return {
187
187
  textPrompt: prompt,
@@ -17,7 +17,7 @@ const findDefaultValue = (field)=>{
17
17
  else break;
18
18
  }
19
19
  };
20
- const buildActionDescription = (action, { includeLocateInPlanning = false, locatePromptSpec } = {})=>{
20
+ const buildActionDescription = (action, { includeLocateInPlanning = false, locatePromptSpec, actionOutputProtocol })=>{
21
21
  const locateParamTypeDescription = locateParamSchemaDescription(includeLocateInPlanning ? locatePromptSpec : void 0);
22
22
  const actionDescription = {
23
23
  type: action.name,
@@ -56,12 +56,13 @@ const buildActionDescription = (action, { includeLocateInPlanning = false, locat
56
56
  }
57
57
  }
58
58
  const actionExample = buildActionExample(action, {
59
- locatePromptSpec: includeLocateInPlanning ? locatePromptSpec : void 0
59
+ locatePromptSpec: includeLocateInPlanning ? locatePromptSpec : void 0,
60
+ actionOutputProtocol
60
61
  });
61
62
  if (actionExample) actionDescription.sample = actionExample;
62
63
  return actionDescription;
63
64
  };
64
- const buildActionSpaceDescription = (actionSpace, options = {})=>js_yaml.dump(actionSpace.map((action)=>buildActionDescription(action, options)), {
65
+ const buildActionSpaceDescription = (actionSpace, options)=>js_yaml.dump(actionSpace.map((action)=>buildActionDescription(action, options)), {
65
66
  indent: 2,
66
67
  lineWidth: -1,
67
68
  noRefs: true
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/prompt/planning/action-description.mjs","sources":["../../../../../src/ai-model/prompt/planning/action-description.ts"],"sourcesContent":["import type { DeviceAction } from '@/types';\nimport {\n getZodDescription,\n getZodTypeName,\n} from '@midscene/shared/zod-schema-utils';\nimport yaml from 'js-yaml';\nimport type { z } from 'zod';\nimport type { LocateResultPromptSpec } from '../../shared/model-locate-result';\nimport { buildActionExample } from './action-example';\n\nexport const locateParamSchemaDescription = (\n promptSpec?: LocateResultPromptSpec,\n) => {\n if (promptSpec) {\n return `{ prompt: string, ${promptSpec.resultKey}: ${promptSpec.resultValueSchema} /* ${promptSpec.resultValueDescription} */ }`;\n }\n return '{ prompt: string /* description of the target element */ }';\n};\n\n/**\n * Find ZodDefault in the wrapper chain and return its default value\n */\nconst findDefaultValue = (field: unknown): any | undefined => {\n let current = field;\n const visited = new Set<unknown>();\n\n while (current && !visited.has(current)) {\n visited.add(current);\n const currentWithDef = current as {\n _def?: {\n typeName?: string;\n defaultValue?: () => any;\n innerType?: unknown;\n };\n };\n\n if (!currentWithDef._def?.typeName) break;\n\n if (currentWithDef._def.typeName === 'ZodDefault') {\n return currentWithDef._def.defaultValue?.();\n }\n\n // Continue unwrapping if it's a wrapper type\n if (\n currentWithDef._def.typeName === 'ZodOptional' ||\n currentWithDef._def.typeName === 'ZodNullable'\n ) {\n current = currentWithDef._def.innerType;\n } else {\n break;\n }\n }\n\n return undefined;\n};\n\ntype ActionParamDescription = {\n type: string;\n optional?: true;\n description?: string;\n default?: unknown;\n instruction?: string;\n};\n\ntype ActionDescription = {\n type: string;\n description: string;\n param?: Record<string, ActionParamDescription> | ActionParamDescription;\n sample?: string;\n};\n\nexport const buildActionDescription = (\n action: DeviceAction<any>,\n {\n includeLocateInPlanning = false,\n locatePromptSpec,\n }: {\n includeLocateInPlanning?: boolean;\n locatePromptSpec?: LocateResultPromptSpec;\n } = {},\n) => {\n const locateParamTypeDescription = locateParamSchemaDescription(\n includeLocateInPlanning ? locatePromptSpec : undefined,\n );\n const actionDescription: ActionDescription = {\n type: action.name,\n description: action.description || 'No description provided',\n };\n\n // Handle paramSchema if it exists\n if (action.paramSchema) {\n // Check if paramSchema is a ZodObject with shape\n const schema = action.paramSchema as {\n _def?: { typeName?: string };\n shape?: Record<string, unknown>;\n };\n const isZodObject = schema._def?.typeName === 'ZodObject';\n\n if (isZodObject && schema.shape) {\n const shape = schema.shape;\n const param: Record<string, ActionParamDescription> = {};\n\n for (const [key, field] of Object.entries(shape)) {\n if (field && typeof field === 'object') {\n // Check if field is optional\n const isOptional =\n typeof (field as { isOptional?: () => boolean }).isOptional ===\n 'function' &&\n (field as { isOptional: () => boolean }).isOptional();\n const typeName = getZodTypeName(field, locateParamTypeDescription);\n const description = getZodDescription(field as z.ZodTypeAny);\n const defaultValue = findDefaultValue(field);\n const hasDefault = defaultValue !== undefined;\n\n const paramDescription: ActionParamDescription = {\n type: typeName,\n };\n if (isOptional) {\n paramDescription.optional = true;\n }\n if (description) {\n paramDescription.description = description;\n }\n if (hasDefault) {\n paramDescription.default = defaultValue;\n }\n\n param[key] = paramDescription;\n }\n }\n\n if (Object.keys(param).length > 0) {\n actionDescription.param = param;\n }\n } else {\n const typeName = getZodTypeName(schema);\n const description = getZodDescription(schema as z.ZodTypeAny);\n const paramDescription: ActionParamDescription = {\n type: typeName,\n instruction: 'Pass the value directly, not as an object.',\n };\n if (description) {\n paramDescription.description = description;\n }\n actionDescription.param = paramDescription;\n }\n }\n\n const actionExample = buildActionExample(action, {\n locatePromptSpec: includeLocateInPlanning ? locatePromptSpec : undefined,\n });\n if (actionExample) {\n actionDescription.sample = actionExample;\n }\n\n return actionDescription;\n};\n\nexport const buildActionSpaceDescription = (\n actionSpace: DeviceAction<any>[],\n options: {\n includeLocateInPlanning?: boolean;\n locatePromptSpec?: LocateResultPromptSpec;\n } = {},\n) =>\n yaml\n .dump(\n actionSpace.map((action) => buildActionDescription(action, options)),\n {\n indent: 2,\n lineWidth: -1,\n noRefs: true,\n },\n )\n .trim();\n"],"names":["locateParamSchemaDescription","promptSpec","findDefaultValue","field","current","visited","Set","currentWithDef","buildActionDescription","action","includeLocateInPlanning","locatePromptSpec","locateParamTypeDescription","undefined","actionDescription","schema","isZodObject","shape","param","key","Object","isOptional","typeName","getZodTypeName","description","getZodDescription","defaultValue","hasDefault","paramDescription","actionExample","buildActionExample","buildActionSpaceDescription","actionSpace","options","yaml"],"mappings":";;;AAUO,MAAMA,+BAA+B,CAC1CC;IAEA,IAAIA,YACF,OAAO,CAAC,kBAAkB,EAAEA,WAAW,SAAS,CAAC,EAAE,EAAEA,WAAW,iBAAiB,CAAC,IAAI,EAAEA,WAAW,sBAAsB,CAAC,KAAK,CAAC;IAElI,OAAO;AACT;AAKA,MAAMC,mBAAmB,CAACC;IACxB,IAAIC,UAAUD;IACd,MAAME,UAAU,IAAIC;IAEpB,MAAOF,WAAW,CAACC,QAAQ,GAAG,CAACD,SAAU;QACvCC,QAAQ,GAAG,CAACD;QACZ,MAAMG,iBAAiBH;QAQvB,IAAI,CAACG,eAAe,IAAI,EAAE,UAAU;QAEpC,IAAIA,AAAiC,iBAAjCA,eAAe,IAAI,CAAC,QAAQ,EAC9B,OAAOA,eAAe,IAAI,CAAC,YAAY;QAIzC,IACEA,AAAiC,kBAAjCA,eAAe,IAAI,CAA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C,MAAMS,cAAcC,kBAAkBV;YACtC,MAAMa,mBAA2C;gBAC/C,MAAMN;gBACN,aAAa;YACf;YACA,IAAIE,aACFI,iBAAiB,WAAW,GAAGJ;YAEjCV,kBAAkB,KAAK,GAAGc;QAC5B;IACF;IAEA,MAAMC,gBAAgBC,mBAAmBrB,QAAQ;QAC/C,kBAAkBC,0BAA0BC,mBAAmBE;IACjE;IACA,IAAIgB,eACFf,kBAAkB,MAAM,GAAGe;IAG7B,OAAOf;AACT;AAEO,MAAMiB,8BAA8B,CACzCC,aACAC,UAGI,CAAC,CAAC,GAENC,QAAAA,IACO,CACHF,YAAY,GAAG,CAAC,CAACvB,SAAWD,uBAAuBC,QAAQwB,WAC3D;QACE,QAAQ;QACR,WAAW;QACX,QAAQ;IACV,GAED,IAAI"}
1
+ {"version":3,"file":"ai-model/prompt/planning/action-description.mjs","sources":["../../../../../src/ai-model/prompt/planning/action-description.ts"],"sourcesContent":["import type { DeviceAction } from '@/types';\nimport {\n getZodDescription,\n getZodTypeName,\n} from '@midscene/shared/zod-schema-utils';\nimport yaml from 'js-yaml';\nimport type { z } from 'zod';\nimport type { LocateResultPromptSpec } from '../../shared/model-locate-result';\nimport { buildActionExample } from './action-example';\nimport type { PlanningActionOutputProtocol } from './action-output-protocol';\n\nexport const locateParamSchemaDescription = (\n promptSpec?: LocateResultPromptSpec,\n) => {\n if (promptSpec) {\n return `{ prompt: string, ${promptSpec.resultKey}: ${promptSpec.resultValueSchema} /* ${promptSpec.resultValueDescription} */ }`;\n }\n return '{ prompt: string /* description of the target element */ }';\n};\n\n/**\n * Find ZodDefault in the wrapper chain and return its default value\n */\nconst findDefaultValue = (field: unknown): any | undefined => {\n let current = field;\n const visited = new Set<unknown>();\n\n while (current && !visited.has(current)) {\n visited.add(current);\n const currentWithDef = current as {\n _def?: {\n typeName?: string;\n defaultValue?: () => any;\n innerType?: unknown;\n };\n };\n\n if (!currentWithDef._def?.typeName) break;\n\n if (currentWithDef._def.typeName === 'ZodDefault') {\n return currentWithDef._def.defaultValue?.();\n }\n\n // Continue unwrapping if it's a wrapper type\n if (\n currentWithDef._def.typeName === 'ZodOptional' ||\n currentWithDef._def.typeName === 'ZodNullable'\n ) {\n current = currentWithDef._def.innerType;\n } else {\n break;\n }\n }\n\n return undefined;\n};\n\ntype ActionParamDescription = {\n type: string;\n optional?: true;\n description?: string;\n default?: unknown;\n instruction?: string;\n};\n\ntype ActionDescription = {\n type: string;\n description: string;\n param?: Record<string, ActionParamDescription> | ActionParamDescription;\n sample?: string;\n};\n\nexport const buildActionDescription = (\n action: DeviceAction<any>,\n {\n includeLocateInPlanning = false,\n locatePromptSpec,\n actionOutputProtocol,\n }: {\n includeLocateInPlanning?: boolean;\n locatePromptSpec?: LocateResultPromptSpec;\n actionOutputProtocol: PlanningActionOutputProtocol;\n },\n) => {\n const locateParamTypeDescription = locateParamSchemaDescription(\n includeLocateInPlanning ? locatePromptSpec : undefined,\n );\n const actionDescription: ActionDescription = {\n type: action.name,\n description: action.description || 'No description provided',\n };\n\n // Handle paramSchema if it exists\n if (action.paramSchema) {\n // Check if paramSchema is a ZodObject with shape\n const schema = action.paramSchema as {\n _def?: { typeName?: string };\n shape?: Record<string, unknown>;\n };\n const isZodObject = schema._def?.typeName === 'ZodObject';\n\n if (isZodObject && schema.shape) {\n const shape = schema.shape;\n const param: Record<string, ActionParamDescription> = {};\n\n for (const [key, field] of Object.entries(shape)) {\n if (field && typeof field === 'object') {\n // Check if field is optional\n const isOptional =\n typeof (field as { isOptional?: () => boolean }).isOptional ===\n 'function' &&\n (field as { isOptional: () => boolean }).isOptional();\n const typeName = getZodTypeName(field, locateParamTypeDescription);\n const description = getZodDescription(field as z.ZodTypeAny);\n const defaultValue = findDefaultValue(field);\n const hasDefault = defaultValue !== undefined;\n\n const paramDescription: ActionParamDescription = {\n type: typeName,\n };\n if (isOptional) {\n paramDescription.optional = true;\n }\n if (description) {\n paramDescription.description = description;\n }\n if (hasDefault) {\n paramDescription.default = defaultValue;\n }\n\n param[key] = paramDescription;\n }\n }\n\n if (Object.keys(param).length > 0) {\n actionDescription.param = param;\n }\n } else {\n const typeName = getZodTypeName(schema);\n const description = getZodDescription(schema as z.ZodTypeAny);\n const paramDescription: ActionParamDescription = {\n type: typeName,\n instruction: 'Pass the value directly, not as an object.',\n };\n if (description) {\n paramDescription.description = description;\n }\n actionDescription.param = paramDescription;\n }\n }\n\n const actionExample = buildActionExample(action, {\n locatePromptSpec: includeLocateInPlanning ? locatePromptSpec : undefined,\n actionOutputProtocol,\n });\n if (actionExample) {\n actionDescription.sample = actionExample;\n }\n\n return actionDescription;\n};\n\nexport const buildActionSpaceDescription = (\n actionSpace: DeviceAction<any>[],\n options: {\n includeLocateInPlanning?: boolean;\n locatePromptSpec?: LocateResultPromptSpec;\n actionOutputProtocol: PlanningActionOutputProtocol;\n },\n) =>\n yaml\n .dump(\n actionSpace.map((action) => buildActionDescription(action, options)),\n {\n indent: 2,\n lineWidth: -1,\n noRefs: true,\n },\n )\n .trim();\n"],"names":["locateParamSchemaDescription","promptSpec","findDefaultValue","field","current","visited","Set","currentWithDef","buildActionDescription","action","includeLocateInPlanning","locatePromptSpec","actionOutputProtocol","locateParamTypeDescription","undefined","actionDescription","schema","isZodObject","shape","param","key","Object","isOptional","typeName","getZodTypeName","description","getZodDescription","defaultValue","hasDefault","paramDescription","actionExample","buildActionExample","buildActionSpaceDescription","actionSpace","options","yaml"],"mappings":";;;AAWO,MAAMA,+BAA+B,CAC1CC;IAEA,IAAIA,YACF,OAAO,CAAC,kBAAkB,EAAEA,WAAW,SAAS,CAAC,EAAE,EAAEA,WAAW,iBAAiB,CAAC,IAAI,EAAEA,WAAW,sBAAsB,CAAC,KAAK,CAAC;IAElI,OAAO;AACT;AAKA,MAAMC,mBAAmB,CAACC;IACxB,IAAIC,UAAUD;IACd,MAAME,UAAU,IAAIC;IAEpB,MAAOF,WAAW,CAACC,QAAQ,GAAG,CAACD,SAAU;QACvCC,QAAQ,GAAG,CAACD;QACZ,M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,IAAIG,YACFC,iBAAiB,OAAO,GAAGF;gBAG7BR,KAAK,CAACC,IAAI,GAAGS;YACf;YAGF,IAAIR,OAAO,IAAI,CAACF,OAAO,MAAM,GAAG,GAC9BJ,kBAAkB,KAAK,GAAGI;QAE9B,OAAO;YACL,MAAMI,WAAWC,eAAeR;YAChC,MAAMS,cAAcC,kBAAkBV;YACtC,MAAMa,mBAA2C;gBAC/C,MAAMN;gBACN,aAAa;YACf;YACA,IAAIE,aACFI,iBAAiB,WAAW,GAAGJ;YAEjCV,kBAAkB,KAAK,GAAGc;QAC5B;IACF;IAEA,MAAMC,gBAAgBC,mBAAmBtB,QAAQ;QAC/C,kBAAkBC,0BAA0BC,mBAAmBG;QAC/DF;IACF;IACA,IAAIkB,eACFf,kBAAkB,MAAM,GAAGe;IAG7B,OAAOf;AACT;AAEO,MAAMiB,8BAA8B,CACzCC,aACAC,UAMAC,QAAAA,IACO,CACHF,YAAY,GAAG,CAAC,CAACxB,SAAWD,uBAAuBC,QAAQyB,WAC3D;QACE,QAAQ;QACR,WAAW;QACX,QAAQ;IACV,GAED,IAAI"}
@@ -1,32 +1,5 @@
1
1
  import { findAllMidsceneLocatorField } from "../../../common.mjs";
2
2
  import { actionInputParamSchema, actionTapParamSchema } from "../../../device/index.mjs";
3
- import { formatLocateExampleValue } from "../../shared/model-locate-result/index.mjs";
4
- const serializeActionParam = (param, locateFields, locatePromptSpec)=>{
5
- const locatorObjects = new WeakSet();
6
- for (const field of locateFields){
7
- const value = param[field];
8
- if (value && 'object' == typeof value) locatorObjects.add(value);
9
- }
10
- const originalJson = JSON.stringify(param);
11
- let markerPrefix = '__MIDSCENE_LOCATE_RESULT_EXAMPLE_';
12
- while(originalJson.includes(markerPrefix))markerPrefix = `_${markerPrefix}`;
13
- const replacements = new Map();
14
- const serializedParam = JSON.stringify(param, function(key, value) {
15
- if (locatorObjects.has(this) && key === locatePromptSpec.resultKey) {
16
- const marker = `${markerPrefix}${replacements.size}__`;
17
- replacements.set(marker, formatLocateExampleValue(value));
18
- return marker;
19
- }
20
- return value;
21
- }, 2);
22
- return [
23
- ...replacements
24
- ].reduce((result, [marker, locateResultValue])=>result.replace(JSON.stringify(marker), locateResultValue), serializedParam);
25
- };
26
- const buildPlanningActionOutput = ({ type, param }, { locateFields, locatePromptSpec } = {})=>`<action-type>${type}</action-type>
27
- <action-param-json>
28
- ${locateFields && locatePromptSpec ? serializeActionParam(param, locateFields, locatePromptSpec) : JSON.stringify(param, null, 2)}
29
- </action-param-json>`;
30
3
  const injectLocateResultIntoSample = (sample, locateFields, promptSpec, locateResultExampleIndex)=>{
31
4
  const result = {
32
5
  ...sample
@@ -41,11 +14,11 @@ const injectLocateResultIntoSample = (sample, locateFields, promptSpec, locateRe
41
14
  }
42
15
  return result;
43
16
  };
44
- const buildActionExample = (action, { locatePromptSpec, locateResultExampleIndex = 0 } = {})=>{
17
+ const buildActionExample = (action, { locatePromptSpec, locateResultExampleIndex = 0, actionOutputProtocol })=>{
45
18
  if (!action.sample || 'object' != typeof action.sample) return;
46
19
  const locateFields = findAllMidsceneLocatorField(action.paramSchema);
47
20
  const sampleWithLocateResult = locatePromptSpec ? injectLocateResultIntoSample(action.sample, locateFields, locatePromptSpec, locateResultExampleIndex) : action.sample;
48
- return buildPlanningActionOutput({
21
+ return actionOutputProtocol.buildActionOutput({
49
22
  type: action.name,
50
23
  param: sampleWithLocateResult
51
24
  }, {
@@ -75,6 +48,6 @@ const createSampleInputAction = (value)=>{
75
48
  sample
76
49
  };
77
50
  };
78
- export { buildActionExample, buildPlanningActionOutput, createSampleInputAction, createSampleTapAction };
51
+ export { buildActionExample, createSampleInputAction, createSampleTapAction };
79
52
 
80
53
  //# sourceMappingURL=action-example.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/prompt/planning/action-example.mjs","sources":["../../../../../src/ai-model/prompt/planning/action-example.ts"],"sourcesContent":["import { findAllMidsceneLocatorField } from '@/common';\nimport { actionInputParamSchema, actionTapParamSchema } from '@/device';\nimport type { DeviceAction } from '@/types';\nimport type { z } from 'zod';\nimport {\n type LocateResultPromptSpec,\n formatLocateExampleValue,\n} from '../../shared/model-locate-result';\n\nexport type ActionExampleDefinition = Pick<\n DeviceAction<any>,\n 'name' | 'paramSchema' | 'sample'\n>;\n\ntype PlanningActionOutput = {\n type: string;\n param: Record<string, unknown>;\n};\n\nconst serializeActionParam = (\n param: Record<string, unknown>,\n locateFields: string[],\n locatePromptSpec: LocateResultPromptSpec,\n) => {\n const locatorObjects = new WeakSet<object>();\n for (const field of locateFields) {\n const value = param[field];\n if (value && typeof value === 'object') {\n locatorObjects.add(value);\n }\n }\n\n const originalJson = JSON.stringify(param);\n // Ensure generated markers cannot collide with strings already present in the sample.\n let markerPrefix = '__MIDSCENE_LOCATE_RESULT_EXAMPLE_';\n while (originalJson.includes(markerPrefix)) {\n markerPrefix = `_${markerPrefix}`;\n }\n\n const replacements = new Map<string, string>();\n const serializedParam = JSON.stringify(\n param,\n function (this: object, key, value) {\n if (locatorObjects.has(this) && key === locatePromptSpec.resultKey) {\n const marker = `${markerPrefix}${replacements.size}__`;\n replacements.set(marker, formatLocateExampleValue(value));\n return marker;\n }\n return value;\n },\n 2,\n );\n\n return [...replacements].reduce(\n (result, [marker, locateResultValue]) =>\n result.replace(JSON.stringify(marker), locateResultValue),\n serializedParam,\n );\n};\n\nexport const buildPlanningActionOutput = (\n { type, param }: PlanningActionOutput,\n {\n locateFields,\n locatePromptSpec,\n }: {\n locateFields?: string[];\n locatePromptSpec?: LocateResultPromptSpec;\n } = {},\n) => `<action-type>${type}</action-type>\n<action-param-json>\n${\n // Keep locate result arrays on one line when serializing action examples.\n locateFields && locatePromptSpec\n ? serializeActionParam(param, locateFields, locatePromptSpec)\n : JSON.stringify(param, null, 2)\n}\n</action-param-json>`;\n\nconst injectLocateResultIntoSample = (\n sample: Record<string, any>,\n locateFields: string[],\n promptSpec: LocateResultPromptSpec,\n locateResultExampleIndex: number,\n): Record<string, any> => {\n const result = { ...sample };\n let exampleIndex = locateResultExampleIndex;\n\n for (const field of locateFields) {\n if (\n result[field] &&\n typeof result[field] === 'object' &&\n result[field].prompt\n ) {\n result[field] = {\n ...result[field],\n [promptSpec.resultKey]:\n promptSpec.exampleValues[\n exampleIndex % promptSpec.exampleValues.length\n ],\n };\n exampleIndex++;\n }\n }\n\n return result;\n};\n\nexport const buildActionExample = (\n action: ActionExampleDefinition,\n {\n locatePromptSpec,\n locateResultExampleIndex = 0,\n }: {\n locatePromptSpec?: LocateResultPromptSpec;\n /**\n * Selects the locate result example value injected into this action.\n * Keep the same index for the same example across multi-turn prompt\n * variants, and use different indexes for different examples to avoid\n * reusing identical locate coordinates.\n */\n locateResultExampleIndex?: number;\n } = {},\n) => {\n if (!action.sample || typeof action.sample !== 'object') {\n return undefined;\n }\n\n const locateFields = findAllMidsceneLocatorField(action.paramSchema);\n const sampleWithLocateResult = locatePromptSpec\n ? injectLocateResultIntoSample(\n action.sample,\n locateFields,\n locatePromptSpec,\n locateResultExampleIndex,\n )\n : action.sample;\n\n return buildPlanningActionOutput(\n {\n type: action.name,\n param: sampleWithLocateResult,\n },\n {\n locateFields,\n locatePromptSpec,\n },\n );\n};\n\nexport const createSampleTapAction = (\n prompt: string,\n): ActionExampleDefinition => {\n const sample: z.input<typeof actionTapParamSchema> = {\n locate: { prompt },\n };\n return {\n name: 'Tap',\n paramSchema: actionTapParamSchema,\n sample,\n };\n};\n\nexport const createSampleInputAction = (\n value: string,\n): ActionExampleDefinition => {\n const sample: z.input<typeof actionInputParamSchema> = { value };\n return {\n name: 'Input',\n paramSchema: actionInputParamSchema,\n sample,\n };\n};\n"],"names":["serializeActionParam","param","locateFields","locatePromptSpec","locatorObjects","WeakSet","field","value","originalJson","JSON","markerPrefix","replacements","Map","serializedParam","key","marker","formatLocateExampleValue","result","locateResultValue","buildPlanningActionOutput","type","injectLocateResultIntoSample","sample","promptSpec","locateResultExampleIndex","exampleIndex","buildActionExample","action","findAllMidsceneLocatorField","sampleWithLocateResult","createSampleTapAction","prompt","actionTapParamSchema","createSampleInputAction","actionInputParamSchema"],"mappings":";;;AAmBA,MAAMA,uBAAuB,CAC3BC,OACAC,cACAC;IAEA,MAAMC,iBAAiB,IAAIC;IAC3B,KAAK,MAAMC,SAASJ,aAAc;QAChC,MAAMK,QAAQN,KAAK,CAACK,MAAM;QAC1B,IAAIC,SAAS,AAAiB,YAAjB,OAAOA,OAClBH,eAAe,GAAG,CAACG;IAEvB;IAEA,MAAMC,eAAeC,KAAK,SAAS,CAACR;IAEpC,IAAIS,eAAe;IACnB,MAAOF,aAAa,QAAQ,CAACE,cAC3BA,eAAe,CAAC,CAAC,EAAEA,cAAc;IAGnC,MAAMC,eAAe,IAAIC;IACzB,MAAMC,kBAAkBJ,KAAK,SAAS,CACpCR,OACA,SAAwBa,GAAG,EAAEP,KAAK;QAChC,IAAIH,eAAe,GAAG,CAAC,IAAI,KAAKU,QAAQX,iBAAiB,SAAS,EAAE;YAClE,MAAMY,SAAS,GAAGL,eAAeC,aAAa,IAAI,CAAC,EAAE,CAAC;YACtDA,aAAa,GAAG,CAACI,QAAQC,yBAAyBT;YAClD,OAAOQ;QACT;QACA,OAAOR;IACT,GACA;IAGF,OAAO;WAAII;KAAa,CAAC,MAAM,CAC7B,CAACM,QAAQ,CAACF,QAAQG,kBAAkB,GAClCD,OAAO,OAAO,CAACR,KAAK,SAAS,CAACM,SAASG,oBACzCL;AAEJ;AAEO,MAAMM,4BAA4B,CACvC,EAAEC,IAAI,EAAEnB,KAAK,EAAwB,EACrC,EACEC,YAAY,EACZC,gBAAgB,EAIjB,GAAG,CAAC,CAAC,GACH,CAAC,aAAa,EAAEiB,KAAK;;AAE1B,EAEElB,gBAAgBC,mBACZH,qBAAqBC,OAAOC,cAAcC,oBAC1CM,KAAK,SAAS,CAACR,OAAO,MAAM,GACjC;oBACmB,CAAC;AAErB,MAAMoB,+BAA+B,CACnCC,QACApB,cACAqB,YACAC;IAEA,MAAMP,SAAS;QAAE,GAAGK,MAAM;IAAC;IAC3B,IAAIG,eAAeD;IAEnB,KAAK,MAAMlB,SAASJ,aAClB,IACEe,MAAM,CAACX,MAAM,IACb,AAAyB,YAAzB,OAAOW,MAAM,CAACX,MAAM,IACpBW,MAAM,CAACX,MAAM,CAAC,MAAM,EACpB;QACAW,MAAM,CAACX,MAAM,GAAG;YACd,GAAGW,MAAM,CAACX,MAAM;YAChB,CAACiB,WAAW,SAAS,CAAC,EACpBA,WAAW,aAAa,CACtBE,eAAeF,WAAW,aAAa,CAAC,MAAM,CAC/C;QACL;QACAE;IACF;IAGF,OAAOR;AACT;AAEO,MAAMS,qBAAqB,CAChCC,QACA,EACExB,gBAAgB,EAChBqB,2BAA2B,CAAC,EAU7B,GAAG,CAAC,CAAC;IAEN,IAAI,CAACG,OAAO,MAAM,IAAI,AAAyB,YAAzB,OAAOA,OAAO,MAAM,EACxC;IAGF,MAAMzB,eAAe0B,4BAA4BD,OAAO,WAAW;IACnE,MAAME,yBAAyB1B,mBAC3BkB,6BACEM,OAAO,MAAM,EACbzB,cACAC,kBACAqB,4BAEFG,OAAO,MAAM;IAEjB,OAAOR,0BACL;QACE,MAAMQ,OAAO,IAAI;QACjB,OAAOE;IACT,GACA;QACE3B;QACAC;IACF;AAEJ;AAEO,MAAM2B,wBAAwB,CACnCC;IAEA,MAAMT,SAA+C;QACnD,QAAQ;YAAES;QAAO;IACnB;IACA,OAAO;QACL,MAAM;QACN,aAAaC;QACbV;IACF;AACF;AAEO,MAAMW,0BAA0B,CACrC1B;IAEA,MAAMe,SAAiD;QAAEf;IAAM;IAC/D,OAAO;QACL,MAAM;QACN,aAAa2B;QACbZ;IACF;AACF"}
1
+ {"version":3,"file":"ai-model/prompt/planning/action-example.mjs","sources":["../../../../../src/ai-model/prompt/planning/action-example.ts"],"sourcesContent":["import { findAllMidsceneLocatorField } from '@/common';\nimport { actionInputParamSchema, actionTapParamSchema } from '@/device';\nimport type { DeviceAction } from '@/types';\nimport type { z } from 'zod';\nimport type { LocateResultPromptSpec } from '../../shared/model-locate-result';\nimport type { PlanningActionOutputProtocol } from './action-output-protocol';\n\nexport type ActionExampleDefinition = Pick<\n DeviceAction<any>,\n 'name' | 'paramSchema' | 'sample'\n>;\n\nconst injectLocateResultIntoSample = (\n sample: Record<string, any>,\n locateFields: string[],\n promptSpec: LocateResultPromptSpec,\n locateResultExampleIndex: number,\n): Record<string, any> => {\n const result = { ...sample };\n let exampleIndex = locateResultExampleIndex;\n\n for (const field of locateFields) {\n if (\n result[field] &&\n typeof result[field] === 'object' &&\n result[field].prompt\n ) {\n result[field] = {\n ...result[field],\n [promptSpec.resultKey]:\n promptSpec.exampleValues[\n exampleIndex % promptSpec.exampleValues.length\n ],\n };\n exampleIndex++;\n }\n }\n\n return result;\n};\n\nexport const buildActionExample = (\n action: ActionExampleDefinition,\n {\n locatePromptSpec,\n locateResultExampleIndex = 0,\n actionOutputProtocol,\n }: {\n locatePromptSpec?: LocateResultPromptSpec;\n /**\n * Selects the locate result example value injected into this action.\n * Keep the same index for the same example across multi-turn prompt\n * variants, and use different indexes for different examples to avoid\n * reusing identical locate coordinates.\n */\n locateResultExampleIndex?: number;\n actionOutputProtocol: PlanningActionOutputProtocol;\n },\n) => {\n if (!action.sample || typeof action.sample !== 'object') {\n return undefined;\n }\n\n const locateFields = findAllMidsceneLocatorField(action.paramSchema);\n const sampleWithLocateResult = locatePromptSpec\n ? injectLocateResultIntoSample(\n action.sample,\n locateFields,\n locatePromptSpec,\n locateResultExampleIndex,\n )\n : action.sample;\n\n return actionOutputProtocol.buildActionOutput(\n {\n type: action.name,\n param: sampleWithLocateResult,\n },\n {\n locateFields,\n locatePromptSpec,\n },\n );\n};\n\nexport const createSampleTapAction = (\n prompt: string,\n): ActionExampleDefinition => {\n const sample: z.input<typeof actionTapParamSchema> = {\n locate: { prompt },\n };\n return {\n name: 'Tap',\n paramSchema: actionTapParamSchema,\n sample,\n };\n};\n\nexport const createSampleInputAction = (\n value: string,\n): ActionExampleDefinition => {\n const sample: z.input<typeof actionInputParamSchema> = { value };\n return {\n name: 'Input',\n paramSchema: actionInputParamSchema,\n sample,\n };\n};\n"],"names":["injectLocateResultIntoSample","sample","locateFields","promptSpec","locateResultExampleIndex","result","exampleIndex","field","buildActionExample","action","locatePromptSpec","actionOutputProtocol","findAllMidsceneLocatorField","sampleWithLocateResult","createSampleTapAction","prompt","actionTapParamSchema","createSampleInputAction","value","actionInputParamSchema"],"mappings":";;AAYA,MAAMA,+BAA+B,CACnCC,QACAC,cACAC,YACAC;IAEA,MAAMC,SAAS;QAAE,GAAGJ,MAAM;IAAC;IAC3B,IAAIK,eAAeF;IAEnB,KAAK,MAAMG,SAASL,aAClB,IACEG,MAAM,CAACE,MAAM,IACb,AAAyB,YAAzB,OAAOF,MAAM,CAACE,MAAM,IACpBF,MAAM,CAACE,MAAM,CAAC,MAAM,EACpB;QACAF,MAAM,CAACE,MAAM,GAAG;YACd,GAAGF,MAAM,CAACE,MAAM;YAChB,CAACJ,WAAW,SAAS,CAAC,EACpBA,WAAW,aAAa,CACtBG,eAAeH,WAAW,aAAa,CAAC,MAAM,CAC/C;QACL;QACAG;IACF;IAGF,OAAOD;AACT;AAEO,MAAMG,qBAAqB,CAChCC,QACA,EACEC,gBAAgB,EAChBN,2BAA2B,CAAC,EAC5BO,oBAAoB,EAWrB;IAED,IAAI,CAACF,OAAO,MAAM,IAAI,AAAyB,YAAzB,OAAOA,OAAO,MAAM,EACxC;IAGF,MAAMP,eAAeU,4BAA4BH,OAAO,WAAW;IACnE,MAAMI,yBAAyBH,mBAC3BV,6BACES,OAAO,MAAM,EACbP,cACAQ,kBACAN,4BAEFK,OAAO,MAAM;IAEjB,OAAOE,qBAAqB,iBAAiB,CAC3C;QACE,MAAMF,OAAO,IAAI;QACjB,OAAOI;IACT,GACA;QACEX;QACAQ;IACF;AAEJ;AAEO,MAAMI,wBAAwB,CACnCC;IAEA,MAAMd,SAA+C;QACnD,QAAQ;YAAEc;QAAO;IACnB;IACA,OAAO;QACL,MAAM;QACN,aAAaC;QACbf;IACF;AACF;AAEO,MAAMgB,0BAA0B,CACrCC;IAEA,MAAMjB,SAAiD;QAAEiB;IAAM;IAC/D,OAAO;QACL,MAAM;QACN,aAAaC;QACblB;IACF;AACF"}
@@ -0,0 +1,39 @@
1
+ import { formatLocateExampleValue } from "../../shared/model-locate-result/index.mjs";
2
+ const serializeActionParam = (param, locateFields, locatePromptSpec)=>{
3
+ const locatorObjects = new WeakSet();
4
+ for (const field of locateFields){
5
+ const value = param[field];
6
+ if (value && 'object' == typeof value) locatorObjects.add(value);
7
+ }
8
+ const originalJson = JSON.stringify(param);
9
+ let markerPrefix = '__MIDSCENE_LOCATE_RESULT_EXAMPLE_';
10
+ while(originalJson.includes(markerPrefix))markerPrefix = `_${markerPrefix}`;
11
+ const replacements = new Map();
12
+ const serializedParam = JSON.stringify(param, function(key, value) {
13
+ if (locatorObjects.has(this) && key === locatePromptSpec.resultKey) {
14
+ const marker = `${markerPrefix}${replacements.size}__`;
15
+ replacements.set(marker, formatLocateExampleValue(value));
16
+ return marker;
17
+ }
18
+ return value;
19
+ }, 2);
20
+ return [
21
+ ...replacements
22
+ ].reduce((result, [marker, locateResultValue])=>result.replace(JSON.stringify(marker), locateResultValue), serializedParam);
23
+ };
24
+ const buildPlanningActionOutput = ({ type, param }, { locateFields, locatePromptSpec } = {})=>`<action-type>${type}</action-type>
25
+ <action-param-json>
26
+ ${locateFields && locatePromptSpec ? serializeActionParam(param, locateFields, locatePromptSpec) : JSON.stringify(param, null, 2)}
27
+ </action-param-json>`;
28
+ const defaultMidsceneActionOutputProtocol = {
29
+ actionOutputTagNames: [
30
+ 'action-type',
31
+ 'action-param-json'
32
+ ],
33
+ actionOutputRules: "- Use the <action-type> and <action-param-json> tags to output the action to be executed.\n- The value inside <action-type> MUST exactly match the 'type' field of one action in the Supporting actions list. 'complete' is NOT a valid action-type.\n- Parameter names are strict. Use EXACTLY the field names listed for the selected action. Do NOT invent alias fields. If the selected action provides a \"sample\" field, use the XML structure shown in that sample as the exact format for the action output.",
34
+ actionOutputPlaceholder: "<action-type>...</action-type>\n<action-param-json>...</action-param-json>",
35
+ buildActionOutput: buildPlanningActionOutput
36
+ };
37
+ export { buildPlanningActionOutput, defaultMidsceneActionOutputProtocol };
38
+
39
+ //# sourceMappingURL=action-output-protocol.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-model/prompt/planning/action-output-protocol.mjs","sources":["../../../../../src/ai-model/prompt/planning/action-output-protocol.ts"],"sourcesContent":["import type { LocateResultPromptSpec } from '../../shared/model-locate-result';\nimport { formatLocateExampleValue } from '../../shared/model-locate-result';\n\nexport type PlanningActionOutput = {\n type: string;\n param: Record<string, unknown>;\n};\n\ntype BuildPlanningActionOutputOptions = {\n locateFields?: string[];\n locatePromptSpec?: LocateResultPromptSpec;\n};\n\nexport type PlanningActionOutputProtocol = {\n actionOutputTagNames: readonly [string, ...string[]];\n actionOutputRules: string;\n actionOutputPlaceholder: string;\n buildActionOutput: (\n action: PlanningActionOutput,\n options?: BuildPlanningActionOutputOptions,\n ) => string;\n};\n\nconst serializeActionParam = (\n param: Record<string, unknown>,\n locateFields: string[],\n locatePromptSpec: LocateResultPromptSpec,\n) => {\n const locatorObjects = new WeakSet<object>();\n for (const field of locateFields) {\n const value = param[field];\n if (value && typeof value === 'object') {\n locatorObjects.add(value);\n }\n }\n\n const originalJson = JSON.stringify(param);\n // Ensure generated markers cannot collide with strings already present in the sample.\n let markerPrefix = '__MIDSCENE_LOCATE_RESULT_EXAMPLE_';\n while (originalJson.includes(markerPrefix)) {\n markerPrefix = `_${markerPrefix}`;\n }\n\n const replacements = new Map<string, string>();\n const serializedParam = JSON.stringify(\n param,\n function (this: object, key, value) {\n if (locatorObjects.has(this) && key === locatePromptSpec.resultKey) {\n const marker = `${markerPrefix}${replacements.size}__`;\n replacements.set(marker, formatLocateExampleValue(value));\n return marker;\n }\n return value;\n },\n 2,\n );\n\n return [...replacements].reduce(\n (result, [marker, locateResultValue]) =>\n result.replace(JSON.stringify(marker), locateResultValue),\n serializedParam,\n );\n};\n\nexport const buildPlanningActionOutput = (\n { type, param }: PlanningActionOutput,\n { locateFields, locatePromptSpec }: BuildPlanningActionOutputOptions = {},\n) => `<action-type>${type}</action-type>\n<action-param-json>\n${\n // Keep locate result arrays on one line when serializing action examples.\n locateFields && locatePromptSpec\n ? serializeActionParam(param, locateFields, locatePromptSpec)\n : JSON.stringify(param, null, 2)\n}\n</action-param-json>`;\n\nexport const defaultMidsceneActionOutputProtocol: PlanningActionOutputProtocol =\n {\n actionOutputTagNames: ['action-type', 'action-param-json'],\n actionOutputRules: [\n '- Use the <action-type> and <action-param-json> tags to output the action to be executed.',\n \"- The value inside <action-type> MUST exactly match the 'type' field of one action in the Supporting actions list. 'complete' is NOT a valid action-type.\",\n '- Parameter names are strict. Use EXACTLY the field names listed for the selected action. Do NOT invent alias fields. If the selected action provides a \"sample\" field, use the XML structure shown in that sample as the exact format for the action output.',\n ].join('\\n'),\n actionOutputPlaceholder: [\n '<action-type>...</action-type>',\n '<action-param-json>...</action-param-json>',\n ].join('\\n'),\n buildActionOutput: buildPlanningActionOutput,\n };\n"],"names":["serializeActionParam","param","locateFields","locatePromptSpec","locatorObjects","WeakSet","field","value","originalJson","JSON","markerPrefix","replacements","Map","serializedParam","key","marker","formatLocateExampleValue","result","locateResultValue","buildPlanningActionOutput","type","defaultMidsceneActionOutputProtocol"],"mappings":";AAuBA,MAAMA,uBAAuB,CAC3BC,OACAC,cACAC;IAEA,MAAMC,iBAAiB,IAAIC;IAC3B,KAAK,MAAMC,SAASJ,aAAc;QAChC,MAAMK,QAAQN,KAAK,CAACK,MAAM;QAC1B,IAAIC,SAAS,AAAiB,YAAjB,OAAOA,OAClBH,eAAe,GAAG,CAACG;IAEvB;IAEA,MAAMC,eAAeC,KAAK,SAAS,CAACR;IAEpC,IAAIS,eAAe;IACnB,MAAOF,aAAa,QAAQ,CAACE,cAC3BA,eAAe,CAAC,CAAC,EAAEA,cAAc;IAGnC,MAAMC,eAAe,IAAIC;IACzB,MAAMC,kBAAkBJ,KAAK,SAAS,CACpCR,OACA,SAAwBa,GAAG,EAAEP,KAAK;QAChC,IAAIH,eAAe,GAAG,CAAC,IAAI,KAAKU,QAAQX,iBAAiB,SAAS,EAAE;YAClE,MAAMY,SAAS,GAAGL,eAAeC,aAAa,IAAI,CAAC,EAAE,CAAC;YACtDA,aAAa,GAAG,CAACI,QAAQC,yBAAyBT;YAClD,OAAOQ;QACT;QACA,OAAOR;IACT,GACA;IAGF,OAAO;WAAII;KAAa,CAAC,MAAM,CAC7B,CAACM,QAAQ,CAACF,QAAQG,kBAAkB,GAClCD,OAAO,OAAO,CAACR,KAAK,SAAS,CAACM,SAASG,oBACzCL;AAEJ;AAEO,MAAMM,4BAA4B,CACvC,EAAEC,IAAI,EAAEnB,KAAK,EAAwB,EACrC,EAAEC,YAAY,EAAEC,gBAAgB,EAAoC,GAAG,CAAC,CAAC,GACtE,CAAC,aAAa,EAAEiB,KAAK;;AAE1B,EAEElB,gBAAgBC,mBACZH,qBAAqBC,OAAOC,cAAcC,oBAC1CM,KAAK,SAAS,CAACR,OAAO,MAAM,GACjC;oBACmB,CAAC;AAEd,MAAMoB,sCACX;IACE,sBAAsB;QAAC;QAAe;KAAoB;IAC1D,mBAAmB;IAKnB,yBAAyB;IAIzB,mBAAmBF;AACrB"}
@@ -1,6 +1,7 @@
1
1
  import { buildStandardPlanningSystemPrompt } from "./system-prompt.mjs";
2
- import { buildActionExample, buildPlanningActionOutput, createSampleInputAction, createSampleTapAction } from "./action-example.mjs";
2
+ import { buildActionExample, createSampleInputAction, createSampleTapAction } from "./action-example.mjs";
3
+ import { buildPlanningActionOutput, defaultMidsceneActionOutputProtocol } from "./action-output-protocol.mjs";
3
4
  import { buildPlanningResponseExample } from "./planning-response-example.mjs";
4
5
  import { buildSubGoalsText } from "./sub-goals-text.mjs";
5
6
  import { buildActionDescription, buildActionSpaceDescription, locateParamSchemaDescription } from "./action-description.mjs";
6
- export { buildActionDescription, buildActionExample, buildActionSpaceDescription, buildPlanningActionOutput, buildPlanningResponseExample, buildStandardPlanningSystemPrompt, buildSubGoalsText, createSampleInputAction, createSampleTapAction, locateParamSchemaDescription };
7
+ export { buildActionDescription, buildActionExample, buildActionSpaceDescription, buildPlanningActionOutput, buildPlanningResponseExample, buildStandardPlanningSystemPrompt, buildSubGoalsText, createSampleInputAction, createSampleTapAction, defaultMidsceneActionOutputProtocol, locateParamSchemaDescription };
@@ -13,18 +13,24 @@ const sampleReturnEmailSubGoal = {
13
13
  index: 3,
14
14
  description: 'Return the filled email address'
15
15
  };
16
- const buildPlanningMultiTurnExample = ({ includeSubGoals, locatePromptSpec })=>{
16
+ const buildPlanningMultiTurnExample = ({ includeSubGoals, locatePromptSpec, actionOutputProtocol })=>{
17
17
  const renderSubGoalsContent = (content, fallbackContent = '')=>includeSubGoals ? content : fallbackContent;
18
18
  const tapNameFieldExample = buildActionExample(createSampleTapAction('Name input field in the registration form'), {
19
19
  locatePromptSpec,
20
- locateResultExampleIndex: 2
20
+ locateResultExampleIndex: 2,
21
+ actionOutputProtocol
22
+ });
23
+ const inputNameExample = buildActionExample(createSampleInputAction('John'), {
24
+ actionOutputProtocol
21
25
  });
22
- const inputNameExample = buildActionExample(createSampleInputAction('John'));
23
26
  const tapEmailFieldExample = buildActionExample(createSampleTapAction('Email input field in the registration form'), {
24
27
  locatePromptSpec,
25
- locateResultExampleIndex: 3
28
+ locateResultExampleIndex: 3,
29
+ actionOutputProtocol
30
+ });
31
+ const inputEmailExample = buildActionExample(createSampleInputAction('john@example.com'), {
32
+ actionOutputProtocol
26
33
  });
27
- const inputEmailExample = buildActionExample(createSampleInputAction('john@example.com'));
28
34
  return `
29
35
  ## Multi-turn Conversation Example
30
36
 
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/prompt/planning/multi-turn-example.mjs","sources":["../../../../../src/ai-model/prompt/planning/multi-turn-example.ts"],"sourcesContent":["import type { LocateResultPromptSpec } from '../../shared/model-locate-result';\nimport {\n buildActionExample,\n createSampleInputAction,\n createSampleTapAction,\n} from './action-example';\nimport { buildPlanningResponseExample } from './planning-response-example';\nimport { buildSubGoalsText } from './sub-goals-text';\n\nconst sampleNameSubGoal = {\n index: 1,\n description: \"Fill in the Name field with 'John'\",\n};\nconst sampleEmailSubGoal = {\n index: 2,\n description: \"Fill in the Email field with 'john@example.com'\",\n};\nconst sampleReturnEmailSubGoal = {\n index: 3,\n description: 'Return the filled email address',\n};\n\nexport const buildPlanningMultiTurnExample = ({\n includeSubGoals,\n locatePromptSpec,\n}: {\n includeSubGoals: boolean;\n locatePromptSpec?: LocateResultPromptSpec;\n}) => {\n const renderSubGoalsContent = (content: string, fallbackContent = '') =>\n includeSubGoals ? content : fallbackContent;\n\n const tapNameFieldExample = buildActionExample(\n createSampleTapAction('Name input field in the registration form'),\n {\n locatePromptSpec,\n locateResultExampleIndex: 2,\n },\n );\n const inputNameExample = buildActionExample(createSampleInputAction('John'));\n const tapEmailFieldExample = buildActionExample(\n createSampleTapAction('Email input field in the registration form'),\n {\n locatePromptSpec,\n locateResultExampleIndex: 3,\n },\n );\n const inputEmailExample = buildActionExample(\n createSampleInputAction('john@example.com'),\n );\n\n return `\n## Multi-turn Conversation Example\n\nBelow is an example of a multi-turn conversation for \"fill out the registration form with name 'John' and email 'john@example.com', then return the filled email address\":\n\n### Turn 1 - Initial instruction\n\n**User message:**\n<user_instruction>fill out the registration form with name 'John' and email 'john@example.com', then return the filled email address</user_instruction>\n\n**Screenshot:** [Shows a registration form with empty Name and Email fields]\n\n**Your response:**\n\n${buildPlanningResponseExample({\n planning: `The user wants me to fill out the registration form with specific values and return the email address. I can see the form has two fields: Name and Email. Both are currently empty. ${renderSubGoalsContent(\n \"I'll break this down into sub-goals and start with the Name field.\",\n 'I should start by clicking on the Name field.',\n )} Note: The instruction is to fill the form only (not submit), and return the email at the end.`,\n updateSubGoals: includeSubGoals\n ? [\n {\n ...sampleNameSubGoal,\n status: 'pending',\n },\n {\n ...sampleEmailSubGoal,\n status: 'pending',\n },\n {\n ...sampleReturnEmailSubGoal,\n status: 'pending',\n },\n ]\n : undefined,\n log: 'Click on the Name field to start filling the form',\n actionExample: tapNameFieldExample,\n})}\n\n### Turn 2 - After clicking Name field\n\n**User message:**\nThe previous action has been executed, here is the latest screenshot. Please continue according to the instruction.\n\n${renderSubGoalsContent(\n buildSubGoalsText([\n {\n ...sampleNameSubGoal,\n status: 'running',\n logs: ['Click on the Name field to start filling the form'],\n },\n { ...sampleEmailSubGoal, status: 'pending' },\n { ...sampleReturnEmailSubGoal, status: 'pending' },\n ]),\n)}\n\n**Screenshot:** [Shows the form with Name field now focused/active]\n\n**Your response:**\n\n${buildPlanningResponseExample({\n planning: `The Name field is now focused. I need to type 'John' into this field. ${renderSubGoalsContent(\n 'Current sub-goal is running, will be completed after input.',\n \"After this, I'll need to fill the Email field as well.\",\n )}`,\n log: \"Typing 'John' into the Name field\",\n actionExample: inputNameExample,\n})}\n\n### Turn 3 - After entering name\n\n**User message:**\nThe previous action has been executed, here is the latest screenshot. Please continue according to the instruction.\n\n${renderSubGoalsContent(\n buildSubGoalsText([\n {\n ...sampleNameSubGoal,\n status: 'running',\n logs: [\n 'Click on the Name field to start filling the form',\n \"Typing 'John' into the Name field\",\n ],\n },\n { ...sampleEmailSubGoal, status: 'pending' },\n { ...sampleReturnEmailSubGoal, status: 'pending' },\n ]),\n)}\n\n**Screenshot:** [Shows the form with Name field containing 'John']\n\n**Your response:**\n\n${buildPlanningResponseExample({\n planning: `The Name field now shows 'John'. ${renderSubGoalsContent(\n 'Sub-goal 1 is complete. Next, I need to fill the Email field for sub-goal 2.',\n \"Next, I need to fill the Email field with 'john@example.com'. I'll click on the Email field first.\",\n )}`,\n markSubGoalsDone: includeSubGoals ? [1] : undefined,\n memory: includeSubGoals\n ? \"Name field has been filled with 'John'\"\n : undefined,\n log: 'Moving to the Email field',\n actionExample: tapEmailFieldExample,\n})}\n\n### Turn 4 - After clicking Email field\n\n**User message:**\nThe previous action has been executed, here is the latest screenshot. Please continue according to the instruction.\n\n${renderSubGoalsContent(\n buildSubGoalsText([\n { ...sampleNameSubGoal, status: 'finished' },\n {\n ...sampleEmailSubGoal,\n status: 'running',\n logs: ['Moving to the Email field'],\n },\n { ...sampleReturnEmailSubGoal, status: 'pending' },\n ]),\n)}\n\n**Screenshot:** [Shows the form with Name='John' and Email field focused]\n\n**Your response:**\n\n${buildPlanningResponseExample({\n planning: `The Email field is now focused. I'll enter 'john@example.com'. ${renderSubGoalsContent(\n 'After this, sub-goal 2 will be complete and my task will be done.',\n 'After this, both required fields will be filled and my task will be complete.',\n )}`,\n log: 'Typing email address into the Email field',\n actionExample: inputEmailExample,\n})}\n\n### Turn 5 - After entering email (${renderSubGoalsContent('Goal accomplished', 'Instruction fulfilled')})\n\n**User message:**\nThe previous action has been executed, here is the latest screenshot. Please continue according to the instruction.\n\n${renderSubGoalsContent(\n buildSubGoalsText([\n { ...sampleNameSubGoal, status: 'finished' },\n {\n ...sampleEmailSubGoal,\n status: 'running',\n logs: [\n 'Moving to the Email field',\n 'Typing email address into the Email field',\n ],\n },\n { ...sampleReturnEmailSubGoal, status: 'pending' },\n ]),\n)}\n\n**Screenshot:** [Shows the form with Name='John' and Email='john@example.com']\n\n**Your response:**\n\n${buildPlanningResponseExample({\n planning: `Both fields are now filled: Name shows 'John' and Email shows 'john@example.com'. ${renderSubGoalsContent(\n \"Sub-goal 2 is complete. The user asked me to return the filled email address, so I need to include 'john@example.com' in my response. All sub-goals are now finished.\",\n \"The user asked me to return the filled email address, so I should include 'john@example.com' in my response. The instruction has been fulfilled.\",\n )}`,\n markSubGoalsDone: includeSubGoals ? [2, 3] : undefined,\n complete: {\n success: true,\n message: 'john@example.com',\n },\n})}\n`;\n};\n"],"names":["sampleNameSubGoal","sampleEmailSubGoal","sampleReturnEmailSubGoal","buildPlanningMultiTurnExample","includeSubGoals","locatePromptSpec","renderSubGoalsContent","content","fallbackContent","tapNameFieldExample","buildActionExample","createSampleTapAction","inputNameExample","createSampleInputAction","tapEmailFieldExample","inputEmailExample","buildPlanningResponseExample","undefined","buildSubGoalsText"],"mappings":";;;AASA,MAAMA,oBAAoB;IACxB,OAAO;IACP,aAAa;AACf;AACA,MAAMC,qBAAqB;IACzB,OAAO;IACP,aAAa;AACf;AACA,MAAMC,2BAA2B;IAC/B,OAAO;IACP,aAAa;AACf;AAEO,MAAMC,gCAAgC,CAAC,EAC5CC,eAAe,EACfC,gBAAgB,EAIjB;IACC,MAAMC,wBAAwB,CAACC,SAAiBC,kBAAkB,EAAE,GAClEJ,kBAAkBG,UAAUC;IAE9B,MAAMC,sBAAsBC,mBAC1BC,sBAAsB,8CACtB;QACEN;QACA,0BAA0B;IAC5B;IAEF,MAAMO,mBAAmBF,mBAAmBG,wBAAwB;IACpE,MAAMC,uBAAuBJ,mBAC3BC,sBAAsB,+CACtB;QACEN;QACA,0BAA0B;IAC5B;IAEF,MAAMU,oBAAoBL,mBACxBG,wBAAwB;IAG1B,OAAO,CAAC;;;;;;;;;;;;;;AAcV,EAAEG,6BAA6B;QAC7B,UAAU,CAAC,oLAAoL,EAAEV,sBAC/L,sEACA,iDACA,8FAA8F,CAAC;QACjG,gBAAgBF,kBACZ;YACE;gBACE,GAAGJ,iBAAiB;gBACpB,QAAQ;YACV;YACA;gBACE,GAAGC,kBAAkB;gBACrB,QAAQ;YACV;YACA;gBACE,GAAGC,wBAAwB;gBAC3B,QAAQ;YACV;SACD,GACDe;QACJ,KAAK;QACL,eAAeR;IACjB,GAAG;;;;;;;AAOH,EAAEH,sBACAY,kBAAkB;QAChB;YACE,GAAGlB,iBAAiB;YACpB,QAAQ;YACR,MAAM;gBAAC;aAAoD;QAC7D;QACA;YAAE,GAAGC,kBAAkB;YAAE,QAAQ;QAAU;QAC3C;YAAE,GAAGC,wBAAwB;YAAE,QAAQ;QAAU;KAClD,GACD;;;;;;AAMF,EAAEc,6BAA6B;QAC7B,UAAU,CAAC,sEAAsE,EAAEV,sBACjF,+DACA,2D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 {"version":3,"file":"ai-model/prompt/planning/multi-turn-example.mjs","sources":["../../../../../src/ai-model/prompt/planning/multi-turn-example.ts"],"sourcesContent":["import type { LocateResultPromptSpec } from '../../shared/model-locate-result';\nimport {\n buildActionExample,\n createSampleInputAction,\n createSampleTapAction,\n} from './action-example';\nimport type { PlanningActionOutputProtocol } from './action-output-protocol';\nimport { buildPlanningResponseExample } from './planning-response-example';\nimport { buildSubGoalsText } from './sub-goals-text';\n\nconst sampleNameSubGoal = {\n index: 1,\n description: \"Fill in the Name field with 'John'\",\n};\nconst sampleEmailSubGoal = {\n index: 2,\n description: \"Fill in the Email field with 'john@example.com'\",\n};\nconst sampleReturnEmailSubGoal = {\n index: 3,\n description: 'Return the filled email address',\n};\n\nexport const buildPlanningMultiTurnExample = ({\n includeSubGoals,\n locatePromptSpec,\n actionOutputProtocol,\n}: {\n includeSubGoals: boolean;\n locatePromptSpec?: LocateResultPromptSpec;\n actionOutputProtocol: PlanningActionOutputProtocol;\n}) => {\n const renderSubGoalsContent = (content: string, fallbackContent = '') =>\n includeSubGoals ? content : fallbackContent;\n\n const tapNameFieldExample = buildActionExample(\n createSampleTapAction('Name input field in the registration form'),\n {\n locatePromptSpec,\n locateResultExampleIndex: 2,\n actionOutputProtocol,\n },\n );\n const inputNameExample = buildActionExample(createSampleInputAction('John'), {\n actionOutputProtocol,\n });\n const tapEmailFieldExample = buildActionExample(\n createSampleTapAction('Email input field in the registration form'),\n {\n locatePromptSpec,\n locateResultExampleIndex: 3,\n actionOutputProtocol,\n },\n );\n const inputEmailExample = buildActionExample(\n createSampleInputAction('john@example.com'),\n { actionOutputProtocol },\n );\n\n return `\n## Multi-turn Conversation Example\n\nBelow is an example of a multi-turn conversation for \"fill out the registration form with name 'John' and email 'john@example.com', then return the filled email address\":\n\n### Turn 1 - Initial instruction\n\n**User message:**\n<user_instruction>fill out the registration form with name 'John' and email 'john@example.com', then return the filled email address</user_instruction>\n\n**Screenshot:** [Shows a registration form with empty Name and Email fields]\n\n**Your response:**\n\n${buildPlanningResponseExample({\n planning: `The user wants me to fill out the registration form with specific values and return the email address. I can see the form has two fields: Name and Email. Both are currently empty. ${renderSubGoalsContent(\n \"I'll break this down into sub-goals and start with the Name field.\",\n 'I should start by clicking on the Name field.',\n )} Note: The instruction is to fill the form only (not submit), and return the email at the end.`,\n updateSubGoals: includeSubGoals\n ? [\n {\n ...sampleNameSubGoal,\n status: 'pending',\n },\n {\n ...sampleEmailSubGoal,\n status: 'pending',\n },\n {\n ...sampleReturnEmailSubGoal,\n status: 'pending',\n },\n ]\n : undefined,\n log: 'Click on the Name field to start filling the form',\n actionExample: tapNameFieldExample,\n})}\n\n### Turn 2 - After clicking Name field\n\n**User message:**\nThe previous action has been executed, here is the latest screenshot. Please continue according to the instruction.\n\n${renderSubGoalsContent(\n buildSubGoalsText([\n {\n ...sampleNameSubGoal,\n status: 'running',\n logs: ['Click on the Name field to start filling the form'],\n },\n { ...sampleEmailSubGoal, status: 'pending' },\n { ...sampleReturnEmailSubGoal, status: 'pending' },\n ]),\n)}\n\n**Screenshot:** [Shows the form with Name field now focused/active]\n\n**Your response:**\n\n${buildPlanningResponseExample({\n planning: `The Name field is now focused. I need to type 'John' into this field. ${renderSubGoalsContent(\n 'Current sub-goal is running, will be completed after input.',\n \"After this, I'll need to fill the Email field as well.\",\n )}`,\n log: \"Typing 'John' into the Name field\",\n actionExample: inputNameExample,\n})}\n\n### Turn 3 - After entering name\n\n**User message:**\nThe previous action has been executed, here is the latest screenshot. Please continue according to the instruction.\n\n${renderSubGoalsContent(\n buildSubGoalsText([\n {\n ...sampleNameSubGoal,\n status: 'running',\n logs: [\n 'Click on the Name field to start filling the form',\n \"Typing 'John' into the Name field\",\n ],\n },\n { ...sampleEmailSubGoal, status: 'pending' },\n { ...sampleReturnEmailSubGoal, status: 'pending' },\n ]),\n)}\n\n**Screenshot:** [Shows the form with Name field containing 'John']\n\n**Your response:**\n\n${buildPlanningResponseExample({\n planning: `The Name field now shows 'John'. ${renderSubGoalsContent(\n 'Sub-goal 1 is complete. Next, I need to fill the Email field for sub-goal 2.',\n \"Next, I need to fill the Email field with 'john@example.com'. I'll click on the Email field first.\",\n )}`,\n markSubGoalsDone: includeSubGoals ? [1] : undefined,\n memory: includeSubGoals\n ? \"Name field has been filled with 'John'\"\n : undefined,\n log: 'Moving to the Email field',\n actionExample: tapEmailFieldExample,\n})}\n\n### Turn 4 - After clicking Email field\n\n**User message:**\nThe previous action has been executed, here is the latest screenshot. Please continue according to the instruction.\n\n${renderSubGoalsContent(\n buildSubGoalsText([\n { ...sampleNameSubGoal, status: 'finished' },\n {\n ...sampleEmailSubGoal,\n status: 'running',\n logs: ['Moving to the Email field'],\n },\n { ...sampleReturnEmailSubGoal, status: 'pending' },\n ]),\n)}\n\n**Screenshot:** [Shows the form with Name='John' and Email field focused]\n\n**Your response:**\n\n${buildPlanningResponseExample({\n planning: `The Email field is now focused. I'll enter 'john@example.com'. ${renderSubGoalsContent(\n 'After this, sub-goal 2 will be complete and my task will be done.',\n 'After this, both required fields will be filled and my task will be complete.',\n )}`,\n log: 'Typing email address into the Email field',\n actionExample: inputEmailExample,\n})}\n\n### Turn 5 - After entering email (${renderSubGoalsContent('Goal accomplished', 'Instruction fulfilled')})\n\n**User message:**\nThe previous action has been executed, here is the latest screenshot. Please continue according to the instruction.\n\n${renderSubGoalsContent(\n buildSubGoalsText([\n { ...sampleNameSubGoal, status: 'finished' },\n {\n ...sampleEmailSubGoal,\n status: 'running',\n logs: [\n 'Moving to the Email field',\n 'Typing email address into the Email field',\n ],\n },\n { ...sampleReturnEmailSubGoal, status: 'pending' },\n ]),\n)}\n\n**Screenshot:** [Shows the form with Name='John' and Email='john@example.com']\n\n**Your response:**\n\n${buildPlanningResponseExample({\n planning: `Both fields are now filled: Name shows 'John' and Email shows 'john@example.com'. ${renderSubGoalsContent(\n \"Sub-goal 2 is complete. The user asked me to return the filled email address, so I need to include 'john@example.com' in my response. All sub-goals are now finished.\",\n \"The user asked me to return the filled email address, so I should include 'john@example.com' in my response. The instruction has been fulfilled.\",\n )}`,\n markSubGoalsDone: includeSubGoals ? [2, 3] : undefined,\n complete: {\n success: true,\n message: 'john@example.com',\n },\n})}\n`;\n};\n"],"names":["sampleNameSubGoal","sampleEmailSubGoal","sampleReturnEmailSubGoal","buildPlanningMultiTurnExample","includeSubGoals","locatePromptSpec","actionOutputProtocol","renderSubGoalsContent","content","fallbackContent","tapNameFieldExample","buildActionExample","createSampleTapAction","inputNameExample","createSampleInputAction","tapEmailFieldExample","inputEmailExample","buildPlanningResponseExample","undefined","buildSubGoalsText"],"mappings":";;;AAUA,MAAMA,oBAAoB;IACxB,OAAO;IACP,aAAa;AACf;AACA,MAAMC,qBAAqB;IACzB,OAAO;IACP,aAAa;AACf;AACA,MAAMC,2BAA2B;IAC/B,OAAO;IACP,aAAa;AACf;AAEO,MAAMC,gCAAgC,CAAC,EAC5CC,eAAe,EACfC,gBAAgB,EAChBC,oBAAoB,EAKrB;IACC,MAAMC,wBAAwB,CAACC,SAAiBC,kBAAkB,EAAE,GAClEL,kBAAkBI,UAAUC;IAE9B,MAAMC,sBAAsBC,mBAC1BC,sBAAsB,8CACtB;QACEP;QACA,0BAA0B;QAC1BC;IACF;IAEF,MAAMO,mBAAmBF,mBAAmBG,wBAAwB,SAAS;QAC3ER;IACF;IACA,MAAMS,uBAAuBJ,mBAC3BC,sBAAsB,+CACtB;QACEP;QACA,0BAA0B;QAC1BC;IACF;IAEF,MAAMU,oBAAoBL,mBACxBG,wBAAwB,qBACxB;QAAER;IAAqB;IAGzB,OAAO,CAAC;;;;;;;;;;;;;;AAcV,EAAEW,6BAA6B;QAC7B,UAAU,CAAC,oLAAoL,EAAEV,sBAC/L,sEACA,iDACA,8FAA8F,CAAC;QACjG,gBAAgBH,kBACZ;YACE;gBACE,GAAGJ,iBAAiB;gBACpB,QAAQ;YACV;YACA;gBACE,GAAGC,kBAAkB;gBACrB,QAAQ;YACV;YACA;gBACE,GAAGC,wBAAwB;gBAC3B,Q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