@midscene/core 1.15.5 → 1.15.6

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 (137) hide show
  1. package/dist/es/agent/agent.mjs +13 -12
  2. package/dist/es/agent/agent.mjs.map +1 -1
  3. package/dist/es/agent/insight.mjs +3 -3
  4. package/dist/es/agent/insight.mjs.map +1 -1
  5. package/dist/es/agent/task-builder.mjs +14 -8
  6. package/dist/es/agent/task-builder.mjs.map +1 -1
  7. package/dist/es/agent/tasks.mjs +18 -13
  8. package/dist/es/agent/tasks.mjs.map +1 -1
  9. package/dist/es/agent/utils.mjs +1 -1
  10. package/dist/es/ai-model/connectivity/run-connectivity-test.mjs +25 -4
  11. package/dist/es/ai-model/connectivity/run-connectivity-test.mjs.map +1 -1
  12. package/dist/es/ai-model/model-adapter/insight.mjs +1 -0
  13. package/dist/es/ai-model/model-adapter/insight.mjs.map +1 -1
  14. package/dist/es/ai-model/model-adapter/resolve.mjs +2 -0
  15. package/dist/es/ai-model/model-adapter/resolve.mjs.map +1 -1
  16. package/dist/es/ai-model/models/gpt.mjs +3 -3
  17. package/dist/es/ai-model/models/gpt.mjs.map +1 -1
  18. package/dist/es/ai-model/models/jev/adapter.mjs +135 -0
  19. package/dist/es/ai-model/models/jev/adapter.mjs.map +1 -0
  20. package/dist/es/ai-model/models/jev/image.mjs +48 -0
  21. package/dist/es/ai-model/models/jev/image.mjs.map +1 -0
  22. package/dist/es/ai-model/models/jev/planning.mjs +168 -0
  23. package/dist/es/ai-model/models/jev/planning.mjs.map +1 -0
  24. package/dist/es/ai-model/models/registry.mjs +2 -0
  25. package/dist/es/ai-model/models/registry.mjs.map +1 -1
  26. package/dist/es/ai-model/models/task-routing.mjs +28 -0
  27. package/dist/es/ai-model/models/task-routing.mjs.map +1 -0
  28. package/dist/es/ai-model/models/utils/intent.mjs +1 -1
  29. package/dist/es/ai-model/models/utils/intent.mjs.map +1 -1
  30. package/dist/es/ai-model/service-caller/call-ai.mjs +15 -2
  31. package/dist/es/ai-model/service-caller/call-ai.mjs.map +1 -1
  32. package/dist/es/ai-model/service-caller/openai/call-openai.mjs +1 -2
  33. package/dist/es/ai-model/service-caller/openai/call-openai.mjs.map +1 -1
  34. package/dist/es/ai-model/service-caller/system-one.mjs +163 -0
  35. package/dist/es/ai-model/service-caller/system-one.mjs.map +1 -0
  36. package/dist/es/ai-model/shared/model-locate-result/errors.mjs +6 -2
  37. package/dist/es/ai-model/shared/model-locate-result/errors.mjs.map +1 -1
  38. package/dist/es/ai-model/workflows/insight/boolean.mjs +20 -0
  39. package/dist/es/ai-model/workflows/insight/boolean.mjs.map +1 -0
  40. package/dist/es/ai-model/workflows/insight/extraction.mjs +2 -0
  41. package/dist/es/ai-model/workflows/insight/extraction.mjs.map +1 -1
  42. package/dist/es/report-html-template.mjs +1 -1
  43. package/dist/es/service/index.mjs +2 -2
  44. package/dist/es/service/index.mjs.map +1 -1
  45. package/dist/es/types.mjs.map +1 -1
  46. package/dist/es/utils.mjs +1 -1
  47. package/dist/lib/agent/agent.js +15 -14
  48. package/dist/lib/agent/agent.js.map +1 -1
  49. package/dist/lib/agent/insight.js +3 -3
  50. package/dist/lib/agent/insight.js.map +1 -1
  51. package/dist/lib/agent/task-builder.js +14 -8
  52. package/dist/lib/agent/task-builder.js.map +1 -1
  53. package/dist/lib/agent/tasks.js +18 -13
  54. package/dist/lib/agent/tasks.js.map +1 -1
  55. package/dist/lib/agent/utils.js +1 -1
  56. package/dist/lib/ai-model/connectivity/run-connectivity-test.js +25 -4
  57. package/dist/lib/ai-model/connectivity/run-connectivity-test.js.map +1 -1
  58. package/dist/lib/ai-model/model-adapter/insight.js +1 -0
  59. package/dist/lib/ai-model/model-adapter/insight.js.map +1 -1
  60. package/dist/lib/ai-model/model-adapter/resolve.js +2 -0
  61. package/dist/lib/ai-model/model-adapter/resolve.js.map +1 -1
  62. package/dist/lib/ai-model/models/gpt.js +3 -3
  63. package/dist/lib/ai-model/models/gpt.js.map +1 -1
  64. package/dist/lib/ai-model/models/jev/adapter.js +169 -0
  65. package/dist/lib/ai-model/models/jev/adapter.js.map +1 -0
  66. package/dist/lib/ai-model/models/jev/image.js +85 -0
  67. package/dist/lib/ai-model/models/jev/image.js.map +1 -0
  68. package/dist/lib/ai-model/models/jev/planning.js +202 -0
  69. package/dist/lib/ai-model/models/jev/planning.js.map +1 -0
  70. package/dist/lib/ai-model/models/registry.js +2 -0
  71. package/dist/lib/ai-model/models/registry.js.map +1 -1
  72. package/dist/lib/ai-model/models/task-routing.js +62 -0
  73. package/dist/lib/ai-model/models/task-routing.js.map +1 -0
  74. package/dist/lib/ai-model/models/utils/intent.js +1 -1
  75. package/dist/lib/ai-model/models/utils/intent.js.map +1 -1
  76. package/dist/lib/ai-model/service-caller/call-ai.js +15 -2
  77. package/dist/lib/ai-model/service-caller/call-ai.js.map +1 -1
  78. package/dist/lib/ai-model/service-caller/openai/call-openai.js +1 -2
  79. package/dist/lib/ai-model/service-caller/openai/call-openai.js.map +1 -1
  80. package/dist/lib/ai-model/service-caller/system-one.js +206 -0
  81. package/dist/lib/ai-model/service-caller/system-one.js.map +1 -0
  82. package/dist/lib/ai-model/shared/model-locate-result/errors.js +8 -4
  83. package/dist/lib/ai-model/shared/model-locate-result/errors.js.map +1 -1
  84. package/dist/lib/ai-model/workflows/insight/boolean.js +54 -0
  85. package/dist/lib/ai-model/workflows/insight/boolean.js.map +1 -0
  86. package/dist/lib/ai-model/workflows/insight/extraction.js +2 -0
  87. package/dist/lib/ai-model/workflows/insight/extraction.js.map +1 -1
  88. package/dist/lib/report-html-template.js +1 -1
  89. package/dist/lib/service/index.js +1 -1
  90. package/dist/lib/service/index.js.map +1 -1
  91. package/dist/lib/types.js.map +1 -1
  92. package/dist/lib/utils.js +1 -1
  93. package/dist/types/agent/agent.d.ts.map +1 -1
  94. package/dist/types/agent/insight.d.ts +2 -1
  95. package/dist/types/agent/insight.d.ts.map +1 -1
  96. package/dist/types/agent/task-builder.d.ts +4 -2
  97. package/dist/types/agent/task-builder.d.ts.map +1 -1
  98. package/dist/types/agent/tasks.d.ts +5 -3
  99. package/dist/types/agent/tasks.d.ts.map +1 -1
  100. package/dist/types/agent/test-runner-nodes.d.ts +1 -1
  101. package/dist/types/ai-model/connectivity/run-connectivity-test.d.ts +1 -0
  102. package/dist/types/ai-model/connectivity/run-connectivity-test.d.ts.map +1 -1
  103. package/dist/types/ai-model/model-adapter/insight-protocol.d.ts +3 -0
  104. package/dist/types/ai-model/model-adapter/insight-protocol.d.ts.map +1 -1
  105. package/dist/types/ai-model/model-adapter/insight.d.ts.map +1 -1
  106. package/dist/types/ai-model/model-adapter/resolve.d.ts +1 -0
  107. package/dist/types/ai-model/model-adapter/resolve.d.ts.map +1 -1
  108. package/dist/types/ai-model/model-adapter/types.d.ts +9 -0
  109. package/dist/types/ai-model/model-adapter/types.d.ts.map +1 -1
  110. package/dist/types/ai-model/models/jev/adapter.d.ts +23 -0
  111. package/dist/types/ai-model/models/jev/adapter.d.ts.map +1 -0
  112. package/dist/types/ai-model/models/jev/image.d.ts +24 -0
  113. package/dist/types/ai-model/models/jev/image.d.ts.map +1 -0
  114. package/dist/types/ai-model/models/jev/planning.d.ts +3 -0
  115. package/dist/types/ai-model/models/jev/planning.d.ts.map +1 -0
  116. package/dist/types/ai-model/models/registry.d.ts +18 -0
  117. package/dist/types/ai-model/models/registry.d.ts.map +1 -1
  118. package/dist/types/ai-model/models/task-routing.d.ts +6 -0
  119. package/dist/types/ai-model/models/task-routing.d.ts.map +1 -0
  120. package/dist/types/ai-model/service-caller/call-ai.d.ts.map +1 -1
  121. package/dist/types/ai-model/service-caller/openai/call-openai.d.ts.map +1 -1
  122. package/dist/types/ai-model/service-caller/system-one.d.ts +216 -0
  123. package/dist/types/ai-model/service-caller/system-one.d.ts.map +1 -0
  124. package/dist/types/ai-model/service-caller/types.d.ts +2 -0
  125. package/dist/types/ai-model/service-caller/types.d.ts.map +1 -1
  126. package/dist/types/ai-model/shared/model-locate-result/errors.d.ts +1 -1
  127. package/dist/types/ai-model/shared/model-locate-result/errors.d.ts.map +1 -1
  128. package/dist/types/ai-model/workflows/insight/boolean.d.ts +15 -0
  129. package/dist/types/ai-model/workflows/insight/boolean.d.ts.map +1 -0
  130. package/dist/types/ai-model/workflows/insight/extraction.d.ts +6 -5
  131. package/dist/types/ai-model/workflows/insight/extraction.d.ts.map +1 -1
  132. package/dist/types/ai-model/workflows/planning/types.d.ts +2 -0
  133. package/dist/types/ai-model/workflows/planning/types.d.ts.map +1 -1
  134. package/dist/types/device/index.d.ts +7 -7
  135. package/dist/types/types.d.ts +8 -1
  136. package/dist/types/types.d.ts.map +1 -1
  137. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/models/gpt.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/models/gpt.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 { TModelFamily } from '@midscene/shared/env';\nimport type {\n BuildResponsesParams,\n ChatCompletionCallContext,\n ChatCompletionParamsResult,\n CodexAppServerCallInput,\n CodexAppServerParamsResult,\n ModelAdapterDefinition,\n ReasoningInput,\n ResolveImageDetail,\n} from '../model-adapter/types';\nimport { isLocateIntent } from './utils/intent';\n\nconst originalImageDetailForDefaultIntent: ResolveImageDetail = (input) =>\n isLocateIntent(input.intent) || input.requiresOriginalImageDetail\n ? 'original'\n : (input.imageDetail ?? 'high');\n\nconst resolveGpt5ReasoningEffort = ({\n reasoningEnabled,\n reasoningEffort,\n}: ReasoningInput): string | undefined => {\n if (reasoningEnabled === 'default') return undefined;\n return reasoningEnabled === true ? (reasoningEffort ?? 'medium') : 'none';\n};\n\n// Astra cannot disable reasoning; use its lowest effort when disabled.\nconst resolveGpt6ReasoningEffort = ({\n reasoningEnabled,\n reasoningEffort,\n}: ReasoningInput): string | undefined => {\n if (reasoningEnabled === 'default') return undefined;\n return reasoningEnabled === true ? (reasoningEffort ?? 'medium') : 'low';\n};\n\nconst buildGpt5CodexAppServerParams = (\n input: CodexAppServerCallInput,\n): CodexAppServerParamsResult => ({\n config: { effort: resolveGpt5ReasoningEffort(input.userConfig ?? {}) },\n});\n\nconst buildGpt6CodexAppServerParams = (\n input: CodexAppServerCallInput,\n): CodexAppServerParamsResult => ({\n config: { effort: resolveGpt6ReasoningEffort(input.userConfig ?? {}) },\n});\n\nconst buildGpt5ResponsesParams: BuildResponsesParams = (input) => {\n const { midsceneDefaults, userConfig, expectedJsonObjectResponse } = input;\n const commonOverrideConfig: Record<string, unknown> = {};\n\n if (userConfig.temperature !== undefined) {\n commonOverrideConfig.temperature = userConfig.temperature;\n }\n\n if (userConfig.responseFormat !== 'none' && expectedJsonObjectResponse) {\n commonOverrideConfig.text = { format: { type: 'json_object' } };\n }\n\n const effectiveReasoningEffort = resolveGpt5ReasoningEffort(userConfig);\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n // Use current-turn reasoning only. Switching to all_turns requires\n // responses.replayRawAssistantOutput to preserve reasoning history.\n reasoning: { effort: effectiveReasoningEffort, context: 'current_turn' },\n },\n };\n};\n\nconst buildGpt6ResponsesParams: BuildResponsesParams = (input) => {\n const { midsceneDefaults, userConfig, expectedJsonObjectResponse } = input;\n const { responseFormat } = userConfig;\n const commonOverrideConfig: Record<string, unknown> = {};\n // GPT-6 does not support temperature; omit it from the serialized request.\n commonOverrideConfig.temperature = undefined;\n if (responseFormat !== 'none' && expectedJsonObjectResponse) {\n commonOverrideConfig.text = { format: { type: 'json_object' } };\n }\n\n const effectiveReasoningEffort = resolveGpt6ReasoningEffort(userConfig);\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n // Use current-turn reasoning only. Switching to all_turns requires\n // responses.replayRawAssistantOutput to preserve reasoning history.\n reasoning: { effort: effectiveReasoningEffort, context: 'current_turn' },\n },\n };\n};\n\nconst buildGpt5ChatCompletionParams = (\n input: ChatCompletionCallContext,\n): ChatCompletionParamsResult => {\n const { midsceneDefaults, userConfig } = input;\n const commonOverrideConfig: Record<string, unknown> = {};\n\n if (userConfig.temperature !== undefined) {\n commonOverrideConfig.temperature = userConfig.temperature;\n }\n\n // OpenAI Chat Completions JSON mode:\n // https://platform.openai.com/docs/guides/structured-outputs?api-mode=chat#json-mode\n if (\n input.userConfig.responseFormat !== 'none' &&\n input.expectedJsonObjectResponse\n ) {\n commonOverrideConfig.response_format = { type: 'json_object' };\n }\n\n const effectiveReasoningEffort = resolveGpt5ReasoningEffort(userConfig);\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n reasoning_effort: effectiveReasoningEffort,\n },\n };\n};\n\nconst buildGpt6ChatCompletionParams = (\n input: ChatCompletionCallContext,\n): ChatCompletionParamsResult => {\n const { midsceneDefaults, userConfig, expectedJsonObjectResponse } = input;\n const { responseFormat } = userConfig;\n const commonOverrideConfig: Record<string, unknown> = {};\n // GPT-6 does not support temperature; omit it from the serialized request.\n commonOverrideConfig.temperature = undefined;\n if (responseFormat !== 'none' && expectedJsonObjectResponse) {\n commonOverrideConfig.response_format = { type: 'json_object' };\n }\n\n const effectiveReasoningEffort = resolveGpt6ReasoningEffort(userConfig);\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n reasoning_effort: effectiveReasoningEffort,\n },\n };\n};\n\nexport const gptAdapters = {\n 'gpt-5': {\n supportedProtocols: ['openai-chat', 'openai-responses'],\n resolveImageDetail: originalImageDetailForDefaultIntent,\n responses: {\n replayRawAssistantOutput: false,\n unsupportedUserConfig: ['reasoningBudget'],\n buildResponsesParams: buildGpt5ResponsesParams,\n },\n buildCodexAppServerParams: buildGpt5CodexAppServerParams,\n chatCompletion: {\n unsupportedUserConfig: ['reasoningBudget'],\n buildChatCompletionParams: buildGpt5ChatCompletionParams,\n },\n locate: {\n element: {\n resultFormat: {\n coordinates: { shape: 'bbox', order: 'xy' },\n },\n },\n },\n },\n 'gpt-6': {\n supportedProtocols: ['openai-chat', 'openai-responses'],\n resolveImageDetail: originalImageDetailForDefaultIntent,\n responses: {\n replayRawAssistantOutput: false,\n unsupportedUserConfig: ['temperature', 'reasoningBudget'],\n buildResponsesParams: buildGpt6ResponsesParams,\n },\n buildCodexAppServerParams: buildGpt6CodexAppServerParams,\n chatCompletion: {\n unsupportedUserConfig: ['temperature', 'reasoningBudget'],\n buildChatCompletionParams: buildGpt6ChatCompletionParams,\n },\n locate: {\n element: {\n resultFormat: {\n coordinates: { shape: 'bbox', order: 'xy' },\n },\n },\n },\n },\n} satisfies Pick<\n Record<TModelFamily, ModelAdapterDefinition>,\n 'gpt-5' | 'gpt-6'\n>;\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","originalImageDetailForDefaultIntent","input","isLocateIntent","resolveGpt5ReasoningEffort","reasoningEnabled","reasoningEffort","resolveGpt6ReasoningEffort","buildGpt5CodexAppServerParams","buildGpt6CodexAppServerParams","buildGpt5ResponsesParams","midsceneDefaults","userConfig","expectedJsonObjectResponse","commonOverrideConfig","undefined","effectiveReasoningEffort","buildGpt6ResponsesParams","responseFormat","buildGpt5ChatCompletionParams","buildGpt6ChatCompletionParams","gptAdapters"],"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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AACF;AAEA,MAAMI,gCAAgC,CACpClB;IAEA,MAAM,EAAES,gBAAgB,EAAEC,UAAU,EAAEC,0BAA0B,EAAE,GAAGX;IACrE,MAAM,EAAEgB,cAAc,EAAE,GAAGN;IAC3B,MAAME,uBAAgD,CAAC;IAEvDA,qBAAqB,WAAW,GAAGC;IACnC,IAAIG,AAAmB,WAAnBA,kBAA6BL,4BAC/BC,qBAAqB,eAAe,GAAG;QAAE,MAAM;IAAc;IAG/D,MAAME,2BAA2BT,2BAA2BK;IAE5D,OAAO;QACL,QAAQ;YACN,GAAGD,gBAAgB;YACnB,GAAGG,oBAAoB;YACvB,kBAAkBE;QACpB;IACF;AACF;AAEO,MAAMK,cAAc;IACzB,SAAS;QACP,oBAAoB;YAAC;YAAe;SAAmB;QACvD,oBAAoBpB;QACpB,WAAW;YACT,0BAA0B;YAC1B,uBAAuB;gBAAC;aAAkB;YAC1C,sBAAsBS;QACxB;QACA,2BAA2BF;QAC3B,gBAAgB;YACd,uBAAuB;gBAAC;aAAkB;YAC1C,2BAA2BW;QAC7B;QACA,QAAQ;YACN,SAAS;gBACP,cAAc;oBACZ,aAAa;wBAAE,OAAO;wBAAQ,OAAO;oBAAK;gBAC5C;YACF;QACF;IACF;IACA,SAAS;QACP,oBAAoB;YAAC;YAAe;SAAmB;QACvD,oBAAoBlB;QACpB,WAAW;YACT,0BAA0B;YAC1B,uBAAuB;gBAAC;gBAAe;aAAkB;YACzD,sBAAsBgB;QACxB;QACA,2BAA2BR;QAC3B,gBAAgB;YACd,uBAAuB;gBAAC;gBAAe;aAAkB;YACzD,2BAA2BW;QAC7B;QACA,QAAQ;YACN,SAAS;gBACP,cAAc;oBACZ,aAAa;wBAAE,OAAO;wBAAQ,OAAO;oBAAK;gBAC5C;YACF;QACF;IACF;AACF"}
1
+ {"version":3,"file":"ai-model/models/gpt.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/models/gpt.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 { TModelFamily } from '@midscene/shared/env';\nimport type {\n BuildResponsesParams,\n ChatCompletionCallContext,\n ChatCompletionParamsResult,\n CodexAppServerCallInput,\n CodexAppServerParamsResult,\n ModelAdapterDefinition,\n ReasoningInput,\n ResolveImageDetail,\n} from '../model-adapter/types';\nimport { isLocateIntent } from './utils/intent';\n\nconst originalImageDetailForLocateIntent: ResolveImageDetail = (input) =>\n isLocateIntent(input.intent) || input.requiresOriginalImageDetail\n ? 'original'\n : (input.imageDetail ?? 'high');\n\nconst resolveGpt5ReasoningEffort = ({\n reasoningEnabled,\n reasoningEffort,\n}: ReasoningInput): string | undefined => {\n if (reasoningEnabled === 'default') return undefined;\n return reasoningEnabled === true ? (reasoningEffort ?? 'medium') : 'none';\n};\n\n// Astra cannot disable reasoning; use its lowest effort when disabled.\nconst resolveGpt6ReasoningEffort = ({\n reasoningEnabled,\n reasoningEffort,\n}: ReasoningInput): string | undefined => {\n if (reasoningEnabled === 'default') return undefined;\n return reasoningEnabled === true ? (reasoningEffort ?? 'medium') : 'low';\n};\n\nconst buildGpt5CodexAppServerParams = (\n input: CodexAppServerCallInput,\n): CodexAppServerParamsResult => ({\n config: { effort: resolveGpt5ReasoningEffort(input.userConfig ?? {}) },\n});\n\nconst buildGpt6CodexAppServerParams = (\n input: CodexAppServerCallInput,\n): CodexAppServerParamsResult => ({\n config: { effort: resolveGpt6ReasoningEffort(input.userConfig ?? {}) },\n});\n\nconst buildGpt5ResponsesParams: BuildResponsesParams = (input) => {\n const { midsceneDefaults, userConfig, expectedJsonObjectResponse } = input;\n const commonOverrideConfig: Record<string, unknown> = {};\n\n if (userConfig.temperature !== undefined) {\n commonOverrideConfig.temperature = userConfig.temperature;\n }\n\n if (userConfig.responseFormat !== 'none' && expectedJsonObjectResponse) {\n commonOverrideConfig.text = { format: { type: 'json_object' } };\n }\n\n const effectiveReasoningEffort = resolveGpt5ReasoningEffort(userConfig);\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n // Use current-turn reasoning only. Switching to all_turns requires\n // responses.replayRawAssistantOutput to preserve reasoning history.\n reasoning: { effort: effectiveReasoningEffort, context: 'current_turn' },\n },\n };\n};\n\nconst buildGpt6ResponsesParams: BuildResponsesParams = (input) => {\n const { midsceneDefaults, userConfig, expectedJsonObjectResponse } = input;\n const { responseFormat } = userConfig;\n const commonOverrideConfig: Record<string, unknown> = {};\n // GPT-6 does not support temperature; omit it from the serialized request.\n commonOverrideConfig.temperature = undefined;\n if (responseFormat !== 'none' && expectedJsonObjectResponse) {\n commonOverrideConfig.text = { format: { type: 'json_object' } };\n }\n\n const effectiveReasoningEffort = resolveGpt6ReasoningEffort(userConfig);\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n // Use current-turn reasoning only. Switching to all_turns requires\n // responses.replayRawAssistantOutput to preserve reasoning history.\n reasoning: { effort: effectiveReasoningEffort, context: 'current_turn' },\n },\n };\n};\n\nconst buildGpt5ChatCompletionParams = (\n input: ChatCompletionCallContext,\n): ChatCompletionParamsResult => {\n const { midsceneDefaults, userConfig } = input;\n const commonOverrideConfig: Record<string, unknown> = {};\n\n if (userConfig.temperature !== undefined) {\n commonOverrideConfig.temperature = userConfig.temperature;\n }\n\n // OpenAI Chat Completions JSON mode:\n // https://platform.openai.com/docs/guides/structured-outputs?api-mode=chat#json-mode\n if (\n input.userConfig.responseFormat !== 'none' &&\n input.expectedJsonObjectResponse\n ) {\n commonOverrideConfig.response_format = { type: 'json_object' };\n }\n\n const effectiveReasoningEffort = resolveGpt5ReasoningEffort(userConfig);\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n reasoning_effort: effectiveReasoningEffort,\n },\n };\n};\n\nconst buildGpt6ChatCompletionParams = (\n input: ChatCompletionCallContext,\n): ChatCompletionParamsResult => {\n const { midsceneDefaults, userConfig, expectedJsonObjectResponse } = input;\n const { responseFormat } = userConfig;\n const commonOverrideConfig: Record<string, unknown> = {};\n // GPT-6 does not support temperature; omit it from the serialized request.\n commonOverrideConfig.temperature = undefined;\n if (responseFormat !== 'none' && expectedJsonObjectResponse) {\n commonOverrideConfig.response_format = { type: 'json_object' };\n }\n\n const effectiveReasoningEffort = resolveGpt6ReasoningEffort(userConfig);\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n reasoning_effort: effectiveReasoningEffort,\n },\n };\n};\n\nexport const gptAdapters = {\n 'gpt-5': {\n supportedProtocols: ['openai-chat', 'openai-responses'],\n resolveImageDetail: originalImageDetailForLocateIntent,\n responses: {\n replayRawAssistantOutput: false,\n unsupportedUserConfig: ['reasoningBudget'],\n buildResponsesParams: buildGpt5ResponsesParams,\n },\n buildCodexAppServerParams: buildGpt5CodexAppServerParams,\n chatCompletion: {\n unsupportedUserConfig: ['reasoningBudget'],\n buildChatCompletionParams: buildGpt5ChatCompletionParams,\n },\n locate: {\n element: {\n resultFormat: {\n coordinates: { shape: 'bbox', order: 'xy' },\n },\n },\n },\n },\n 'gpt-6': {\n supportedProtocols: ['openai-chat', 'openai-responses'],\n resolveImageDetail: originalImageDetailForLocateIntent,\n responses: {\n replayRawAssistantOutput: false,\n unsupportedUserConfig: ['temperature', 'reasoningBudget'],\n buildResponsesParams: buildGpt6ResponsesParams,\n },\n buildCodexAppServerParams: buildGpt6CodexAppServerParams,\n chatCompletion: {\n unsupportedUserConfig: ['temperature', 'reasoningBudget'],\n buildChatCompletionParams: buildGpt6ChatCompletionParams,\n },\n locate: {\n element: {\n resultFormat: {\n coordinates: { shape: 'bbox', order: 'xy' },\n },\n },\n },\n },\n} satisfies Pick<\n Record<TModelFamily, ModelAdapterDefinition>,\n 'gpt-5' | 'gpt-6'\n>;\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","originalImageDetailForLocateIntent","input","isLocateIntent","resolveGpt5ReasoningEffort","reasoningEnabled","reasoningEffort","resolveGpt6ReasoningEffort","buildGpt5CodexAppServerParams","buildGpt6CodexAppServerParams","buildGpt5ResponsesParams","midsceneDefaults","userConfig","expectedJsonObjectResponse","commonOverrideConfig","undefined","effectiveReasoningEffort","buildGpt6ResponsesParams","responseFormat","buildGpt5ChatCompletionParams","buildGpt6ChatCompletionParams","gptAdapters"],"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,qCAAyD,CAACC,QAC9DC,AAAAA,IAAAA,0BAAAA,cAAAA,AAAAA,EAAeD,MAAM,MAAM,KAAKA,MAAM,2BAA2B,GAC7D,aACCA,MAAM,WAAW,IAAI;AAE5B,MAAME,6BAA6B,CAAC,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xB;QACA,2BAA2BF;QAC3B,gBAAgB;YACd,uBAAuB;gBAAC;aAAkB;YAC1C,2BAA2BW;QAC7B;QACA,QAAQ;YACN,SAAS;gBACP,cAAc;oBACZ,aAAa;wBAAE,OAAO;wBAAQ,OAAO;oBAAK;gBAC5C;YACF;QACF;IACF;IACA,SAAS;QACP,oBAAoB;YAAC;YAAe;SAAmB;QACvD,oBAAoBlB;QACpB,WAAW;YACT,0BAA0B;YAC1B,uBAAuB;gBAAC;gBAAe;aAAkB;YACzD,sBAAsBgB;QACxB;QACA,2BAA2BR;QAC3B,gBAAgB;YACd,uBAAuB;gBAAC;gBAAe;aAAkB;YACzD,2BAA2BW;QAC7B;QACA,QAAQ;YACN,SAAS;gBACP,cAAc;oBACZ,aAAa;wBAAE,OAAO;wBAAQ,OAAO;oBAAK;gBAC5C;YACF;QACF;IACF;AACF"}
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ jevAdapters: ()=>jevAdapters
28
+ });
29
+ const external_common_js_namespaceObject = require("../../../common.js");
30
+ const utils_namespaceObject = require("@midscene/shared/utils");
31
+ const index_js_namespaceObject = require("../../service-caller/index.js");
32
+ const system_one_js_namespaceObject = require("../../service-caller/system-one.js");
33
+ const multimodal_prompt_js_namespaceObject = require("../../shared/multimodal-prompt.js");
34
+ const external_image_js_namespaceObject = require("./image.js");
35
+ const external_planning_js_namespaceObject = require("./planning.js");
36
+ async function prepareReferences(prompt) {
37
+ const { referenceImages } = await (0, multimodal_prompt_js_namespaceObject.prepareUserPrompt)(prompt);
38
+ const prepared = await Promise.all(referenceImages.map(async (image, index)=>({
39
+ key: `reference_${index}`,
40
+ name: image.name,
41
+ image: await (0, external_image_js_namespaceObject.prepareJevImage)(image.url)
42
+ })));
43
+ return {
44
+ references: prepared.map(({ key, name })=>({
45
+ image: `\`${key}\``,
46
+ name
47
+ })),
48
+ images: Object.fromEntries(prepared.map(({ key, image })=>[
49
+ key,
50
+ image.imageBase64
51
+ ]))
52
+ };
53
+ }
54
+ const locate = async ({ targetElementDescription, locateImage, options })=>{
55
+ const image = await (0, external_image_js_namespaceObject.prepareJevImage)(locateImage.imageBase64);
56
+ const references = await prepareReferences(targetElementDescription);
57
+ const target = (0, external_common_js_namespaceObject.userPromptToString)(targetElementDescription);
58
+ const response = await (0, index_js_namespaceObject.callAI)([], options.modelRuntime, {
59
+ abortSignal: options.abortSignal,
60
+ systemOneRequest: {
61
+ state: {
62
+ target,
63
+ references: references.references
64
+ },
65
+ images: {
66
+ screenshot: image.imageBase64,
67
+ ...references.images
68
+ },
69
+ questions: {
70
+ present: {
71
+ type: 'noul',
72
+ instructions: 'Is the target described in `target` present in `screenshot`? Reference images, if any, describe the target; they are not the screenshot.'
73
+ },
74
+ target: {
75
+ type: 'box',
76
+ instructions: 'The single target described in `target`, in `screenshot`.'
77
+ }
78
+ }
79
+ }
80
+ });
81
+ const { answers } = system_one_js_namespaceObject.systemOneResponseSchema.parse(JSON.parse(response.content));
82
+ (0, utils_namespaceObject.assert)('noul' === answers.present.type && 'box' === answers.target.type, 'Invalid Jev locate answers');
83
+ return {
84
+ rawResponse: response.content,
85
+ usage: response.usage,
86
+ ...answers.present.noul >= 0.5 ? {
87
+ locatedPixelResult: (0, external_image_js_namespaceObject.mapJevBox)(answers.target.box, image, locateImage)
88
+ } : {
89
+ errors: [
90
+ 'The target is not present in the screenshot'
91
+ ]
92
+ }
93
+ };
94
+ };
95
+ const adapter_boolean = async (options)=>{
96
+ const references = await prepareReferences({
97
+ prompt: '',
98
+ ...options.multimodalPrompt
99
+ });
100
+ const frames = options.extractOption?.screenshotIncluded === false ? [] : options.context.screenshotSequence?.length ? options.context.screenshotSequence : [
101
+ options.context.screenshot
102
+ ];
103
+ const screenshots = await Promise.all(frames.map((frame)=>(0, external_image_js_namespaceObject.prepareJevImage)(frame.base64)));
104
+ const result = await (0, index_js_namespaceObject.callAI)([], options.modelRuntime, {
105
+ abortSignal: options.abortSignal,
106
+ systemOneRequest: {
107
+ state: {
108
+ statement: options.dataQuery,
109
+ context: options.extractOption?.context,
110
+ pageDescription: options.pageDescription,
111
+ frames: screenshots.map((_, index)=>`\`frame_${index}\``),
112
+ references: references.references
113
+ },
114
+ images: {
115
+ ...Object.fromEntries(screenshots.map((image, index)=>[
116
+ `frame_${index}`,
117
+ image.imageBase64
118
+ ])),
119
+ ...references.images
120
+ },
121
+ questions: {
122
+ result: {
123
+ type: 'noul',
124
+ instructions: "Is `statement` true? Screenshots in `frames` are ordered earliest to latest. For current state use the latest frame; for events use the relevant frames. Reference images are supporting context, not screenshots, unless the statement requests comparison. Use the provided context and page description when present."
125
+ }
126
+ }
127
+ }
128
+ });
129
+ const answer = system_one_js_namespaceObject.systemOneResponseSchema.parse(JSON.parse(result.content)).answers.result;
130
+ (0, utils_namespaceObject.assert)('noul' === answer.type, 'Invalid Jev boolean answer');
131
+ return {
132
+ value: answer.noul >= 0.5,
133
+ rawResponse: result.content,
134
+ usage: result.usage
135
+ };
136
+ };
137
+ const jevAdapters = {
138
+ jev: {
139
+ supportedTasks: [
140
+ 'locate',
141
+ 'boolean',
142
+ 'planning'
143
+ ],
144
+ supportedProtocols: [],
145
+ locate: {
146
+ kind: 'custom',
147
+ locateFn: locate
148
+ },
149
+ insight: {
150
+ booleanFn: adapter_boolean
151
+ },
152
+ planning: {
153
+ kind: 'custom',
154
+ planFn: external_planning_js_namespaceObject.jevPlan,
155
+ cacheEnabled: false,
156
+ supportsActionDeepLocate: false,
157
+ defaultReplanningCycleLimit: 20
158
+ }
159
+ }
160
+ };
161
+ exports.jevAdapters = __webpack_exports__.jevAdapters;
162
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
163
+ "jevAdapters"
164
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
165
+ Object.defineProperty(exports, '__esModule', {
166
+ value: true
167
+ });
168
+
169
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-model/models/jev/adapter.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/models/jev/adapter.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 { userPromptToString } from '@/common';\nimport type { TModelFamily } from '@midscene/shared/env';\nimport { assert } from '@midscene/shared/utils';\nimport type { ModelAdapterDefinition } from '../../model-adapter/types';\nimport { callAI } from '../../service-caller';\nimport { systemOneResponseSchema } from '../../service-caller/system-one';\nimport { prepareUserPrompt } from '../../shared/multimodal-prompt';\nimport type { LocateFn } from '../../workflows/grounding/types';\nimport type { BooleanFn } from '../../workflows/insight/boolean';\nimport { mapJevBox, prepareJevImage } from './image';\nimport { jevPlan } from './planning';\n\nasync function prepareReferences(\n prompt: Parameters<typeof prepareUserPrompt>[0],\n) {\n const { referenceImages } = await prepareUserPrompt(prompt);\n const prepared = await Promise.all(\n referenceImages.map(async (image, index) => ({\n key: `reference_${index}`,\n name: image.name,\n image: await prepareJevImage(image.url),\n })),\n );\n return {\n references: prepared.map(({ key, name }) => ({\n image: `\\`${key}\\``,\n name,\n })),\n images: Object.fromEntries(\n prepared.map(({ key, image }) => [key, image.imageBase64]),\n ),\n };\n}\n\nconst locate: LocateFn = async ({\n targetElementDescription,\n locateImage,\n options,\n}) => {\n const image = await prepareJevImage(locateImage.imageBase64);\n const references = await prepareReferences(targetElementDescription);\n const target = userPromptToString(targetElementDescription);\n const response = await callAI([], options.modelRuntime, {\n abortSignal: options.abortSignal,\n systemOneRequest: {\n state: { target, references: references.references },\n images: { screenshot: image.imageBase64, ...references.images },\n questions: {\n present: {\n type: 'noul',\n instructions:\n 'Is the target described in `target` present in `screenshot`? Reference images, if any, describe the target; they are not the screenshot.',\n },\n target: {\n type: 'box',\n instructions:\n 'The single target described in `target`, in `screenshot`.',\n },\n },\n },\n });\n const { answers } = systemOneResponseSchema.parse(\n JSON.parse(response.content),\n );\n assert(\n answers.present.type === 'noul' && answers.target.type === 'box',\n 'Invalid Jev locate answers',\n );\n return {\n rawResponse: response.content,\n usage: response.usage,\n ...(answers.present.noul >= 0.5\n ? {\n locatedPixelResult: mapJevBox(answers.target.box, image, locateImage),\n }\n : { errors: ['The target is not present in the screenshot'] }),\n };\n};\n\nconst boolean: BooleanFn = async (options) => {\n const references = await prepareReferences({\n prompt: '',\n ...options.multimodalPrompt,\n });\n const frames =\n options.extractOption?.screenshotIncluded === false\n ? []\n : options.context.screenshotSequence?.length\n ? options.context.screenshotSequence\n : [options.context.screenshot];\n const screenshots = await Promise.all(\n frames.map((frame) => prepareJevImage(frame.base64)),\n );\n const result = await callAI([], options.modelRuntime, {\n abortSignal: options.abortSignal,\n systemOneRequest: {\n state: {\n statement: options.dataQuery,\n context: options.extractOption?.context,\n pageDescription: options.pageDescription,\n frames: screenshots.map((_, index) => `\\`frame_${index}\\``),\n references: references.references,\n },\n images: {\n ...Object.fromEntries(\n screenshots.map((image, index) => [\n `frame_${index}`,\n image.imageBase64,\n ]),\n ),\n ...references.images,\n },\n questions: {\n result: {\n type: 'noul',\n instructions:\n 'Is `statement` true? Screenshots in `frames` are ordered earliest to latest. For current state use the latest frame; for events use the relevant frames. Reference images are supporting context, not screenshots, unless the statement requests comparison. Use the provided context and page description when present.',\n },\n },\n },\n });\n const answer = systemOneResponseSchema.parse(JSON.parse(result.content))\n .answers.result;\n assert(answer.type === 'noul', 'Invalid Jev boolean answer');\n return {\n value: answer.noul >= 0.5,\n rawResponse: result.content,\n usage: result.usage,\n };\n};\n\nexport const jevAdapters = {\n jev: {\n supportedTasks: ['locate', 'boolean', 'planning'],\n supportedProtocols: [],\n locate: { kind: 'custom', locateFn: locate },\n insight: { booleanFn: boolean },\n planning: {\n kind: 'custom',\n planFn: jevPlan,\n cacheEnabled: false,\n supportsActionDeepLocate: false,\n defaultReplanningCycleLimit: 20,\n },\n },\n} satisfies Pick<Record<TModelFamily, ModelAdapterDefinition>, 'jev'>;\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","prepareReferences","prompt","referenceImages","prepareUserPrompt","prepared","Promise","image","index","prepareJevImage","name","locate","targetElementDescription","locateImage","options","references","target","userPromptToString","response","callAI","answers","systemOneResponseSchema","JSON","assert","mapJevBox","boolean","frames","screenshots","frame","result","_","answer","jevAdapters","jevPlan"],"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,KAAK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Q;QAC9B,UAAU;YACR,MAAM;YACN,QAAQQ,qCAAAA,OAAOA;YACf,cAAc;YACd,0BAA0B;YAC1B,6BAA6B;QAC/B;IACF;AACF"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ mapJevBox: ()=>mapJevBox,
28
+ prepareJevImage: ()=>prepareJevImage
29
+ });
30
+ const external_node_buffer_namespaceObject = require("node:buffer");
31
+ const img_namespaceObject = require("@midscene/shared/img");
32
+ const utils_namespaceObject = require("@midscene/shared/utils");
33
+ async function prepareJevImage(url) {
34
+ const base64 = await (0, img_namespaceObject.preProcessImageUrl)(url, true);
35
+ const source = await (0, img_namespaceObject.imageInfoOfBase64)(base64);
36
+ const scale = Math.min(1, 1568 / source.width, 1568 / source.height);
37
+ const contentSize = {
38
+ width: Math.max(1, Math.round(source.width * scale)),
39
+ height: Math.max(1, Math.round(source.height * scale))
40
+ };
41
+ const resized = await (0, img_namespaceObject.resizeBase64ImageToJpeg)(base64, {
42
+ targetSize: contentSize
43
+ });
44
+ const prepared = await (0, img_namespaceObject.padBase64ImageToMinimumSize)(resized, 280);
45
+ (0, utils_namespaceObject.assert)(external_node_buffer_namespaceObject.Buffer.from((0, img_namespaceObject.parseBase64)(prepared.imageBase64).body, 'base64').length <= 16777216, 'Jev image exceeds 16 MiB');
46
+ return {
47
+ ...prepared,
48
+ contentSize,
49
+ sourceSize: {
50
+ width: source.width,
51
+ height: source.height
52
+ }
53
+ };
54
+ }
55
+ function mapJevBox(box, image, targetSize) {
56
+ const left = box.left * image.width * targetSize.width / image.contentSize.width;
57
+ const top = box.top * image.height * targetSize.height / image.contentSize.height;
58
+ const right = box.right * image.width * targetSize.width / image.contentSize.width;
59
+ const bottom = box.bottom * image.height * targetSize.height / image.contentSize.height;
60
+ const center = [
61
+ (left + right) / 2,
62
+ (top + bottom) / 2
63
+ ];
64
+ (0, utils_namespaceObject.assert)(center[0] >= 0 && center[0] < targetSize.width && center[1] >= 0 && center[1] < targetSize.height, 'Jev returned a target in image padding, outside the screenshot');
65
+ return {
66
+ center,
67
+ rect: {
68
+ left,
69
+ top,
70
+ width: right - left,
71
+ height: bottom - top
72
+ }
73
+ };
74
+ }
75
+ exports.mapJevBox = __webpack_exports__.mapJevBox;
76
+ exports.prepareJevImage = __webpack_exports__.prepareJevImage;
77
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
78
+ "mapJevBox",
79
+ "prepareJevImage"
80
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
81
+ Object.defineProperty(exports, '__esModule', {
82
+ value: true
83
+ });
84
+
85
+ //# sourceMappingURL=image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-model/models/jev/image.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/models/jev/image.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 { Buffer } from 'node:buffer';\nimport {\n imageInfoOfBase64,\n padBase64ImageToMinimumSize,\n parseBase64,\n preProcessImageUrl,\n resizeBase64ImageToJpeg,\n} from '@midscene/shared/img';\nimport { assert } from '@midscene/shared/utils';\nimport type { PixelLocateResult } from '../../shared/model-locate-result';\n\nexport async function prepareJevImage(url: string) {\n const base64 = await preProcessImageUrl(url, true);\n const source = await imageInfoOfBase64(base64);\n const scale = Math.min(1, 1568 / source.width, 1568 / source.height);\n const contentSize = {\n width: Math.max(1, Math.round(source.width * scale)),\n height: Math.max(1, Math.round(source.height * scale)),\n };\n const resized = await resizeBase64ImageToJpeg(base64, {\n targetSize: contentSize,\n });\n const prepared = await padBase64ImageToMinimumSize(resized, 280);\n assert(\n Buffer.from(parseBase64(prepared.imageBase64).body, 'base64').length <=\n 16 * 1024 * 1024,\n 'Jev image exceeds 16 MiB',\n );\n return {\n ...prepared,\n contentSize,\n sourceSize: { width: source.width, height: source.height },\n };\n}\n\nexport function mapJevBox(\n box: { left: number; top: number; right: number; bottom: number },\n image: Awaited<ReturnType<typeof prepareJevImage>>,\n targetSize: { width: number; height: number },\n): PixelLocateResult {\n // Jev returns fractions of the padded image. Undo padding and scale before\n // the grounding workflow maps a DeepLocate crop back to the full screenshot.\n const left =\n (box.left * image.width * targetSize.width) / image.contentSize.width;\n const top =\n (box.top * image.height * targetSize.height) / image.contentSize.height;\n const right =\n (box.right * image.width * targetSize.width) / image.contentSize.width;\n const bottom =\n (box.bottom * image.height * targetSize.height) / image.contentSize.height;\n const center: [number, number] = [(left + right) / 2, (top + bottom) / 2];\n assert(\n center[0] >= 0 &&\n center[0] < targetSize.width &&\n center[1] >= 0 &&\n center[1] < targetSize.height,\n 'Jev returned a target in image padding, outside the screenshot',\n );\n return {\n center,\n rect: { left, top, width: right - left, height: bottom - top },\n };\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","prepareJevImage","url","base64","preProcessImageUrl","source","imageInfoOfBase64","scale","Math","contentSize","resized","resizeBase64ImageToJpeg","prepared","padBase64ImageToMinimumSize","assert","Buffer","parseBase64","mapJevBox","box","image","targetSize","left","top","right","bottom","center"],"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;;;;;;;;;;;ACKO,eAAeI,gBAAgBC,GAAW;IAC/C,MAAMC,SAAS,MAAMC,AAAAA,IAAAA,oBAAAA,kBAAAA,AAAAA,EAAmBF,KAAK;IAC7C,MAAMG,SAAS,MAAMC,AAAAA,IAAAA,oBAAAA,iBAAAA,AAAAA,EAAkBH;IACvC,MAAMI,QAAQC,KAAK,GAAG,CAAC,GAAG,OAAOH,OAAO,KAAK,EAAE,OAAOA,OAAO,MAAM;IACnE,MAAMI,cAAc;QAClB,OAAOD,KAAK,GAAG,CAAC,GAAGA,KAAK,KAAK,CAACH,OAAO,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5BK,MAAM,CAAC,EAAE,IAAI,KACbA,MAAM,CAAC,EAAE,GAAGL,WAAW,MAAM,EAC/B;IAEF,OAAO;QACLK;QACA,MAAM;YAAEJ;YAAMC;YAAK,OAAOC,QAAQF;YAAM,QAAQG,SAASF;QAAI;IAC/D;AACF"}
@@ -0,0 +1,202 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ jevPlan: ()=>jevPlan
28
+ });
29
+ const external_common_js_namespaceObject = require("../../../common.js");
30
+ const utils_namespaceObject = require("@midscene/shared/utils");
31
+ const index_js_namespaceObject = require("../../service-caller/index.js");
32
+ const system_one_js_namespaceObject = require("../../service-caller/system-one.js");
33
+ const standard_planning_js_namespaceObject = require("../../workflows/planning/standard-planning.js");
34
+ const external_image_js_namespaceObject = require("./image.js");
35
+ const jevPlan = async (instruction, options)=>{
36
+ const history = options.conversationHistory;
37
+ const delegate = async (reason)=>{
38
+ (0, utils_namespaceObject.assert)(options.getDefaultModelRuntime, 'Default model runtime is required for Jev planning delegation');
39
+ const base = options.getDefaultModelRuntime();
40
+ (0, utils_namespaceObject.assert)('jev' !== base.config.modelFamily, 'Jev cannot delegate planning to itself');
41
+ const runtime = {
42
+ ...base,
43
+ config: {
44
+ ...base.config,
45
+ intent: 'planning'
46
+ },
47
+ executionId: options.modelRuntime.executionId,
48
+ onUsage: base.onUsage ? (usage)=>base.onUsage?.({
49
+ ...usage,
50
+ intent: 'planning'
51
+ }) : void 0,
52
+ modelRouting: {
53
+ requestedModel: options.modelRuntime.config.modelName,
54
+ requestedSlot: options.modelRuntime.config.slot,
55
+ task: 'planning',
56
+ reason
57
+ }
58
+ };
59
+ const planner = 'custom' === runtime.adapter.planning.kind ? runtime.adapter.planning.planFn : standard_planning_js_namespaceObject.standardPlan;
60
+ return planner(instruction, {
61
+ ...options,
62
+ modelRuntime: runtime,
63
+ includeLocateInPlanning: false
64
+ });
65
+ };
66
+ const image = await (0, external_image_js_namespaceObject.prepareJevImage)(options.context.screenshot.base64);
67
+ const references = await Promise.all(instruction.referenceImages.map(async (reference, index)=>({
68
+ key: `reference_${index}`,
69
+ name: reference.name,
70
+ image: await (0, external_image_js_namespaceObject.prepareJevImage)(reference.url)
71
+ })));
72
+ const state = {
73
+ goal: instruction.text,
74
+ context: options.actionContext,
75
+ history: history.historicalLogsToText(),
76
+ memory: history.memoriesToText(),
77
+ feedback: history.pendingFeedbackMessage,
78
+ references: references.map(({ key, name })=>({
79
+ image: `\`${key}\``,
80
+ name
81
+ })),
82
+ availableActions: options.actionSpace.map(({ name, description })=>({
83
+ name,
84
+ description
85
+ }))
86
+ };
87
+ const criteria = {
88
+ Complete: 'The entire user goal is already satisfied, confirmed by the current screenshot and execution feedback. No text answer is requested.',
89
+ Delegate: 'The next step requires text input, generated output, an action or parameters not covered by the other choices. Also use for impossible tasks needing explanation.'
90
+ };
91
+ for (const action of options.actionSpace)if ('Tap' === action.name || 'Scroll' === action.name || 'Sleep' === action.name) criteria[action.name] = 'Sleep' === action.name ? 'Wait 800 ms for a transient loading state.' : action.description ?? action.name;
92
+ const response = await (0, index_js_namespaceObject.callAI)([], options.modelRuntime, {
93
+ abortSignal: options.abortSignal,
94
+ systemOneRequest: {
95
+ state,
96
+ images: {
97
+ screenshot: image.imageBase64,
98
+ ...Object.fromEntries(references.map(({ key, image })=>[
99
+ key,
100
+ image.imageBase64
101
+ ]))
102
+ },
103
+ questions: {
104
+ action: {
105
+ type: 'choice',
106
+ instructions: 'Choose exactly the next step toward `goal` using the current `screenshot`, context, history and feedback. History records proposed actions; feedback and current screenshot establish what actually happened. Do not repeat completed steps. Reference images describe targets, not the current page.',
107
+ criteria
108
+ },
109
+ ...criteria.Scroll ? {
110
+ direction: {
111
+ type: 'choice',
112
+ instructions: 'If scrolling is the next step toward `goal`, which direction reveals the desired off-screen content? Evaluate from the screenshot and history independently of the action question.',
113
+ criteria: {
114
+ down: 'Reveal content below',
115
+ up: 'Reveal content above',
116
+ left: 'Reveal content to the left',
117
+ right: 'Reveal content to the right'
118
+ }
119
+ }
120
+ } : {}
121
+ }
122
+ }
123
+ });
124
+ const { answers } = system_one_js_namespaceObject.systemOneResponseSchema.parse(JSON.parse(response.content));
125
+ (0, utils_namespaceObject.assert)('choice' === answers.action.type, 'Invalid Jev planning action');
126
+ const selected = answers.action.choice;
127
+ if ('Delegate' === selected) return delegate('The next step requires parameters or output that Jev cannot generate');
128
+ if (('Tap' === selected || 'Scroll' === selected) && options.locateModelRuntime?.config.modelFamily !== 'jev') return delegate("The configured Locate model requires a concrete target description from a general-purpose planner");
129
+ const locate = {
130
+ prompt: `Locate the single ${'Scroll' === selected ? 'scrollable region to scroll' : 'element to tap'} for the NEXT step toward this goal. Use the current screenshot as authoritative. Previous proposals may have failed; use feedback. Task context: ${JSON.stringify(state)}`,
131
+ images: instruction.referenceImages
132
+ };
133
+ const actions = (()=>{
134
+ if ('Complete' === selected) return [];
135
+ if ('Sleep' === selected) return [
136
+ {
137
+ type: 'Sleep',
138
+ param: {
139
+ timeMs: 800
140
+ }
141
+ }
142
+ ];
143
+ if ('Tap' === selected) return [
144
+ {
145
+ type: 'Tap',
146
+ param: {
147
+ locate
148
+ }
149
+ }
150
+ ];
151
+ (0, utils_namespaceObject.assert)('Scroll' === selected && answers.direction?.type === 'choice', 'Invalid Jev scroll action');
152
+ return [
153
+ {
154
+ type: 'Scroll',
155
+ param: {
156
+ locate,
157
+ direction: answers.direction.choice,
158
+ scrollType: 'singleAction'
159
+ }
160
+ }
161
+ ];
162
+ })();
163
+ const log = `Jev selected ${selected}`;
164
+ const feedback = history.pendingFeedbackMessage;
165
+ history.resetPendingFeedbackMessageIfExists();
166
+ history.appendMessage({
167
+ role: 'user',
168
+ content: `Goal: ${instruction.text}\nExecution feedback: ${feedback}`
169
+ });
170
+ history.appendMessage({
171
+ role: 'assistant',
172
+ content: JSON.stringify({
173
+ actions,
174
+ log
175
+ })
176
+ });
177
+ history.appendHistoricalLog(`${log}: ${JSON.stringify(actions.map(({ type, param })=>({
178
+ type,
179
+ direction: param?.direction
180
+ })))}`);
181
+ history.compressHistory(50, 20);
182
+ return {
183
+ actions,
184
+ log,
185
+ rawResponse: response.content,
186
+ usage: response.usage,
187
+ shouldContinuePlanning: 'Complete' !== selected,
188
+ ...'Complete' === selected ? {
189
+ finalizeSuccess: true
190
+ } : {},
191
+ yamlFlow: (0, external_common_js_namespaceObject.buildYamlFlowFromPlans)(actions, options.actionSpace)
192
+ };
193
+ };
194
+ exports.jevPlan = __webpack_exports__.jevPlan;
195
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
196
+ "jevPlan"
197
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
198
+ Object.defineProperty(exports, '__esModule', {
199
+ value: true
200
+ });
201
+
202
+ //# sourceMappingURL=planning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-model/models/jev/planning.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/models/jev/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 { buildYamlFlowFromPlans } from '@/common';\nimport type { AIUsageInfo, PlanningAction } from '@/types';\nimport { assert } from '@midscene/shared/utils';\nimport { callAI } from '../../service-caller';\nimport { systemOneResponseSchema } from '../../service-caller/system-one';\nimport { standardPlan } from '../../workflows/planning/standard-planning';\nimport type { PlanFn } from '../../workflows/planning/types';\nimport { prepareJevImage } from './image';\n\nexport const jevPlan: PlanFn = async (instruction, options) => {\n const history = options.conversationHistory;\n const delegate = async (reason: string) => {\n assert(\n options.getDefaultModelRuntime,\n 'Default model runtime is required for Jev planning delegation',\n );\n const base = options.getDefaultModelRuntime();\n assert(\n base.config.modelFamily !== 'jev',\n 'Jev cannot delegate planning to itself',\n );\n const runtime = {\n ...base,\n config: { ...base.config, intent: 'planning' as const },\n executionId: options.modelRuntime.executionId,\n onUsage: base.onUsage\n ? (usage: AIUsageInfo) =>\n base.onUsage?.({ ...usage, intent: 'planning' })\n : undefined,\n modelRouting: {\n requestedModel: options.modelRuntime.config.modelName,\n requestedSlot: options.modelRuntime.config.slot,\n task: 'planning' as const,\n reason,\n },\n };\n const planner =\n runtime.adapter.planning.kind === 'custom'\n ? runtime.adapter.planning.planFn\n : standardPlan;\n return planner(instruction, {\n ...options,\n modelRuntime: runtime,\n includeLocateInPlanning: false,\n });\n };\n const image = await prepareJevImage(options.context.screenshot.base64);\n const references = await Promise.all(\n instruction.referenceImages.map(async (reference, index) => ({\n key: `reference_${index}`,\n name: reference.name,\n image: await prepareJevImage(reference.url),\n })),\n );\n const state = {\n goal: instruction.text,\n context: options.actionContext,\n history: history.historicalLogsToText(),\n memory: history.memoriesToText(),\n feedback: history.pendingFeedbackMessage,\n references: references.map(({ key, name }) => ({\n image: `\\`${key}\\``,\n name,\n })),\n availableActions: options.actionSpace.map(({ name, description }) => ({\n name,\n description,\n })),\n };\n const criteria: Record<string, string> = {\n Complete:\n 'The entire user goal is already satisfied, confirmed by the current screenshot and execution feedback. No text answer is requested.',\n Delegate:\n 'The next step requires text input, generated output, an action or parameters not covered by the other choices. Also use for impossible tasks needing explanation.',\n };\n for (const action of options.actionSpace) {\n if (\n action.name === 'Tap' ||\n action.name === 'Scroll' ||\n action.name === 'Sleep'\n ) {\n criteria[action.name] =\n action.name === 'Sleep'\n ? 'Wait 800 ms for a transient loading state.'\n : (action.description ?? action.name);\n }\n }\n const response = await callAI([], options.modelRuntime, {\n abortSignal: options.abortSignal,\n systemOneRequest: {\n state,\n images: {\n screenshot: image.imageBase64,\n ...Object.fromEntries(\n references.map(({ key, image }) => [key, image.imageBase64]),\n ),\n },\n questions: {\n action: {\n type: 'choice',\n instructions:\n 'Choose exactly the next step toward `goal` using the current `screenshot`, context, history and feedback. History records proposed actions; feedback and current screenshot establish what actually happened. Do not repeat completed steps. Reference images describe targets, not the current page.',\n criteria,\n },\n ...(criteria.Scroll\n ? {\n direction: {\n type: 'choice' as const,\n instructions:\n 'If scrolling is the next step toward `goal`, which direction reveals the desired off-screen content? Evaluate from the screenshot and history independently of the action question.',\n criteria: {\n down: 'Reveal content below',\n up: 'Reveal content above',\n left: 'Reveal content to the left',\n right: 'Reveal content to the right',\n },\n },\n }\n : {}),\n },\n },\n });\n const { answers } = systemOneResponseSchema.parse(\n JSON.parse(response.content),\n );\n assert(answers.action.type === 'choice', 'Invalid Jev planning action');\n const selected = answers.action.choice;\n if (selected === 'Delegate') {\n return delegate(\n 'The next step requires parameters or output that Jev cannot generate',\n );\n }\n if (\n (selected === 'Tap' || selected === 'Scroll') &&\n options.locateModelRuntime?.config.modelFamily !== 'jev'\n ) {\n return delegate(\n 'The configured Locate model requires a concrete target description from a general-purpose planner',\n );\n }\n // The normal Locate stage resolves this contextual target with its own runtime.\n // Do not embed planning coordinates or bypass the configured Locate model.\n const locate = {\n prompt: `Locate the single ${selected === 'Scroll' ? 'scrollable region to scroll' : 'element to tap'} for the NEXT step toward this goal. Use the current screenshot as authoritative. Previous proposals may have failed; use feedback. Task context: ${JSON.stringify(state)}`,\n images: instruction.referenceImages,\n };\n const actions: PlanningAction[] = (() => {\n if (selected === 'Complete') {\n return [];\n }\n if (selected === 'Sleep') {\n return [{ type: 'Sleep', param: { timeMs: 800 } }];\n }\n if (selected === 'Tap') {\n return [{ type: 'Tap', param: { locate } }];\n }\n assert(\n selected === 'Scroll' && answers.direction?.type === 'choice',\n 'Invalid Jev scroll action',\n );\n return [\n {\n type: 'Scroll',\n param: {\n locate,\n direction: answers.direction.choice,\n scrollType: 'singleAction',\n },\n },\n ];\n })();\n const log = `Jev selected ${selected}`;\n const feedback = history.pendingFeedbackMessage;\n history.resetPendingFeedbackMessageIfExists();\n history.appendMessage({\n role: 'user',\n content: `Goal: ${instruction.text}\\nExecution feedback: ${feedback}`,\n });\n history.appendMessage({\n role: 'assistant',\n content: JSON.stringify({ actions, log }),\n });\n history.appendHistoricalLog(\n `${log}: ${JSON.stringify(actions.map(({ type, param }) => ({ type, direction: param?.direction })))}`,\n );\n history.compressHistory(50, 20);\n return {\n actions,\n log,\n rawResponse: response.content,\n usage: response.usage,\n shouldContinuePlanning: selected !== 'Complete',\n ...(selected === 'Complete' ? { finalizeSuccess: true } : {}),\n yamlFlow: buildYamlFlowFromPlans(actions, options.actionSpace),\n };\n};\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","jevPlan","instruction","options","history","delegate","reason","assert","base","runtime","usage","undefined","planner","standardPlan","image","prepareJevImage","references","Promise","reference","index","state","name","description","criteria","action","response","callAI","answers","systemOneResponseSchema","JSON","selected","locate","actions","log","feedback","type","param","buildYamlFlowFromPlans"],"mappings":";;;IAA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CAAC,CAAC;QAC5D,UAAUO,AAAAA,IAAAA,mCAAAA,sBAAAA,AAAAA,EAAuBL,SAAS7B,QAAQ,WAAW;IAC/D;AACF"}
@@ -37,11 +37,13 @@ const external_doubao_js_namespaceObject = require("./doubao.js");
37
37
  const external_gemini_js_namespaceObject = require("./gemini.js");
38
38
  const external_glm_js_namespaceObject = require("./glm.js");
39
39
  const external_gpt_js_namespaceObject = require("./gpt.js");
40
+ const external_jev_adapter_js_namespaceObject = require("./jev/adapter.js");
40
41
  const external_kimi_js_namespaceObject = require("./kimi.js");
41
42
  const external_mimo_js_namespaceObject = require("./mimo.js");
42
43
  const external_qwen_js_namespaceObject = require("./qwen.js");
43
44
  const external_ui_tars_adapter_js_namespaceObject = require("./ui-tars/adapter.js");
44
45
  const MODEL_ADAPTER_CONFIGS = {
46
+ ...external_jev_adapter_js_namespaceObject.jevAdapters,
45
47
  ...external_qwen_js_namespaceObject.qwenAdapters,
46
48
  ...external_deepseek_adapter_js_namespaceObject.deepSeekAdapters,
47
49
  ...external_doubao_js_namespaceObject.doubaoAdapters,
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/models/registry.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/models/registry.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 { IModelConfig, TModelFamily } from '@midscene/shared/env';\nimport { getDebug } from '@midscene/shared/logger';\nimport { ResolvedModelAdapter } from '../model-adapter/resolve';\nimport type {\n ModelAdapter,\n ModelAdapterDefinition,\n ModelRuntime,\n} from '../model-adapter/types';\nimport { autoGlmAdapters } from './auto-glm/adapter';\nimport { deepSeekAdapters } from './deepseek/adapter';\nimport { defaultOpenAICompatibleAdapterConfig } from './default';\nimport { doubaoAdapters } from './doubao';\nimport { geminiAdapters } from './gemini';\nimport { glmAdapters } from './glm';\nimport { gptAdapters } from './gpt';\nimport { kimiAdapters } from './kimi';\nimport { mimoAdapters } from './mimo';\nimport { qwenAdapters } from './qwen';\nimport { uiTarsAdapters } from './ui-tars/adapter';\n\nexport const MODEL_ADAPTER_CONFIGS = {\n ...qwenAdapters,\n ...deepSeekAdapters,\n ...doubaoAdapters,\n ...geminiAdapters,\n ...uiTarsAdapters,\n ...glmAdapters,\n ...autoGlmAdapters,\n ...gptAdapters,\n ...kimiAdapters,\n ...mimoAdapters,\n} satisfies Record<TModelFamily, ModelAdapterDefinition>;\n\ntype ModelAdapterCacheKey = TModelFamily | 'default';\n\nconst modelAdapterCache = new Map<ModelAdapterCacheKey, ModelAdapter>();\nconst debugModelAdapter = getDebug('ai:model-adapter');\n\nfunction debugAdapterUnsupportedUserConfig(\n modelFamily: ModelAdapterCacheKey,\n adapter: ModelAdapter,\n): void {\n if (adapter.chatCompletion.unsupportedUserConfig.length > 0) {\n debugModelAdapter(\n `model adapter \"${modelFamily}\" (chat-completion) unsupportedUserConfig: ${JSON.stringify(adapter.chatCompletion.unsupportedUserConfig)}`,\n );\n }\n if (adapter.responses.unsupportedUserConfig.length > 0) {\n debugModelAdapter(\n `model adapter \"${modelFamily}\" (responses) unsupportedUserConfig: ${JSON.stringify(adapter.responses.unsupportedUserConfig)}`,\n );\n }\n}\n\nexport function getModelAdapter(modelFamily?: TModelFamily): ModelAdapter {\n const cacheKey: ModelAdapterCacheKey = modelFamily ?? 'default';\n let adapter = modelAdapterCache.get(cacheKey);\n if (adapter) {\n return adapter;\n }\n\n const config = modelFamily\n ? MODEL_ADAPTER_CONFIGS[modelFamily]\n : defaultOpenAICompatibleAdapterConfig;\n if (!config) {\n throw new Error(\n `No model adapter registered for modelFamily: ${modelFamily}`,\n );\n }\n\n adapter = new ResolvedModelAdapter(config, cacheKey);\n modelAdapterCache.set(cacheKey, adapter);\n debugAdapterUnsupportedUserConfig(cacheKey, adapter);\n\n return adapter;\n}\n\nexport function getModelRuntime(config: IModelConfig): ModelRuntime {\n return {\n config,\n adapter: getModelAdapter(config.modelFamily),\n };\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","MODEL_ADAPTER_CONFIGS","qwenAdapters","deepSeekAdapters","doubaoAdapters","geminiAdapters","uiTarsAdapters","glmAdapters","autoGlmAdapters","gptAdapters","kimiAdapters","mimoAdapters","modelAdapterCache","Map","debugModelAdapter","getDebug","debugAdapterUnsupportedUserConfig","modelFamily","adapter","JSON","getModelAdapter","cacheKey","config","defaultOpenAICompatibleAdapterConfig","Error","ResolvedModelAdapter","getModelRuntime"],"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;;;;;;;;;;;;;;;;;;;;;;ACcO,MAAMI,wBAA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AAO,WAAW;IAC7C;AACF"}
1
+ {"version":3,"file":"ai-model/models/registry.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/models/registry.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 { IModelConfig, TModelFamily } from '@midscene/shared/env';\nimport { getDebug } from '@midscene/shared/logger';\nimport { ResolvedModelAdapter } from '../model-adapter/resolve';\nimport type {\n ModelAdapter,\n ModelAdapterDefinition,\n ModelRuntime,\n} from '../model-adapter/types';\nimport { autoGlmAdapters } from './auto-glm/adapter';\nimport { deepSeekAdapters } from './deepseek/adapter';\nimport { defaultOpenAICompatibleAdapterConfig } from './default';\nimport { doubaoAdapters } from './doubao';\nimport { geminiAdapters } from './gemini';\nimport { glmAdapters } from './glm';\nimport { gptAdapters } from './gpt';\nimport { jevAdapters } from './jev/adapter';\nimport { kimiAdapters } from './kimi';\nimport { mimoAdapters } from './mimo';\nimport { qwenAdapters } from './qwen';\nimport { uiTarsAdapters } from './ui-tars/adapter';\n\nexport const MODEL_ADAPTER_CONFIGS = {\n ...jevAdapters,\n ...qwenAdapters,\n ...deepSeekAdapters,\n ...doubaoAdapters,\n ...geminiAdapters,\n ...uiTarsAdapters,\n ...glmAdapters,\n ...autoGlmAdapters,\n ...gptAdapters,\n ...kimiAdapters,\n ...mimoAdapters,\n} satisfies Record<TModelFamily, ModelAdapterDefinition>;\n\ntype ModelAdapterCacheKey = TModelFamily | 'default';\n\nconst modelAdapterCache = new Map<ModelAdapterCacheKey, ModelAdapter>();\nconst debugModelAdapter = getDebug('ai:model-adapter');\n\nfunction debugAdapterUnsupportedUserConfig(\n modelFamily: ModelAdapterCacheKey,\n adapter: ModelAdapter,\n): void {\n if (adapter.chatCompletion.unsupportedUserConfig.length > 0) {\n debugModelAdapter(\n `model adapter \"${modelFamily}\" (chat-completion) unsupportedUserConfig: ${JSON.stringify(adapter.chatCompletion.unsupportedUserConfig)}`,\n );\n }\n if (adapter.responses.unsupportedUserConfig.length > 0) {\n debugModelAdapter(\n `model adapter \"${modelFamily}\" (responses) unsupportedUserConfig: ${JSON.stringify(adapter.responses.unsupportedUserConfig)}`,\n );\n }\n}\n\nexport function getModelAdapter(modelFamily?: TModelFamily): ModelAdapter {\n const cacheKey: ModelAdapterCacheKey = modelFamily ?? 'default';\n let adapter = modelAdapterCache.get(cacheKey);\n if (adapter) {\n return adapter;\n }\n\n const config = modelFamily\n ? MODEL_ADAPTER_CONFIGS[modelFamily]\n : defaultOpenAICompatibleAdapterConfig;\n if (!config) {\n throw new Error(\n `No model adapter registered for modelFamily: ${modelFamily}`,\n );\n }\n\n adapter = new ResolvedModelAdapter(config, cacheKey);\n modelAdapterCache.set(cacheKey, adapter);\n debugAdapterUnsupportedUserConfig(cacheKey, adapter);\n\n return adapter;\n}\n\nexport function getModelRuntime(config: IModelConfig): ModelRuntime {\n return {\n config,\n adapter: getModelAdapter(config.modelFamily),\n };\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","MODEL_ADAPTER_CONFIGS","jevAdapters","qwenAdapters","deepSeekAdapters","doubaoAdapters","geminiAdapters","uiTarsAdapters","glmAdapters","autoGlmAdapters","gptAdapters","kimiAdapters","mimoAdapters","modelAdapterCache","Map","debugModelAdapter","getDebug","debugAdapterUnsupportedUserConfig","modelFamily","adapter","JSON","getModelAdapter","cacheKey","config","defaultOpenAICompatibleAdapterConfig","Error","ResolvedModelAdapter","getMod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