@midscene/core 1.16.2 → 1.16.6-beta-20261023073257.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 (295) hide show
  1. package/dist/es/agent/agent.mjs +11 -11
  2. package/dist/es/agent/agent.mjs.map +1 -1
  3. package/dist/es/agent/insight.mjs.map +1 -1
  4. package/dist/es/agent/tasks.mjs +72 -39
  5. package/dist/es/agent/tasks.mjs.map +1 -1
  6. package/dist/es/agent/utils.mjs +1 -1
  7. package/dist/es/ai-model/connectivity/run-connectivity-test.mjs +27 -22
  8. package/dist/es/ai-model/connectivity/run-connectivity-test.mjs.map +1 -1
  9. package/dist/es/ai-model/index.mjs +4 -2
  10. package/dist/es/ai-model/model-adapter/resolve.mjs +4 -2
  11. package/dist/es/ai-model/model-adapter/resolve.mjs.map +1 -1
  12. package/dist/es/ai-model/models/jev/adapter.mjs +6 -110
  13. package/dist/es/ai-model/models/jev/adapter.mjs.map +1 -1
  14. package/dist/es/ai-model/models/jev/boolean.mjs +48 -0
  15. package/dist/es/ai-model/models/jev/boolean.mjs.map +1 -0
  16. package/dist/es/ai-model/models/jev/image.mjs +39 -36
  17. package/dist/es/ai-model/models/jev/image.mjs.map +1 -1
  18. package/dist/es/ai-model/models/jev/locate.mjs +48 -0
  19. package/dist/es/ai-model/models/jev/locate.mjs.map +1 -0
  20. package/dist/es/ai-model/models/jev/planning-action.mjs +35 -0
  21. package/dist/es/ai-model/models/jev/planning-action.mjs.map +1 -0
  22. package/dist/es/ai-model/models/jev/planning-context.mjs +38 -0
  23. package/dist/es/ai-model/models/jev/planning-context.mjs.map +1 -0
  24. package/dist/es/ai-model/models/jev/planning-decision.mjs +68 -0
  25. package/dist/es/ai-model/models/jev/planning-decision.mjs.map +1 -0
  26. package/dist/es/ai-model/models/jev/planning.mjs +19 -131
  27. package/dist/es/ai-model/models/jev/planning.mjs.map +1 -1
  28. package/dist/es/ai-model/models/model-fallback.mjs +28 -0
  29. package/dist/es/ai-model/models/model-fallback.mjs.map +1 -0
  30. package/dist/es/ai-model/service-caller/call-ai.mjs +54 -27
  31. package/dist/es/ai-model/service-caller/call-ai.mjs.map +1 -1
  32. package/dist/es/ai-model/service-caller/codex/call-codex.mjs.map +1 -1
  33. package/dist/es/ai-model/service-caller/index.mjs +2 -2
  34. package/dist/es/ai-model/service-caller/model-call.mjs +3 -3
  35. package/dist/es/ai-model/service-caller/model-call.mjs.map +1 -1
  36. package/dist/es/ai-model/service-caller/openai/call-openai.mjs +4 -2
  37. package/dist/es/ai-model/service-caller/openai/call-openai.mjs.map +1 -1
  38. package/dist/es/ai-model/service-caller/openai/chat-completion/chat-completion.mjs.map +1 -1
  39. package/dist/es/ai-model/service-caller/openai/openai-client.mjs.map +1 -1
  40. package/dist/es/ai-model/service-caller/openai/responses/responses.mjs.map +1 -1
  41. package/dist/es/ai-model/service-caller/openai/siwc/authorization.mjs +117 -0
  42. package/dist/es/ai-model/service-caller/openai/siwc/authorization.mjs.map +1 -0
  43. package/dist/es/ai-model/service-caller/openai/siwc/credential-storage.mjs +66 -0
  44. package/dist/es/ai-model/service-caller/openai/siwc/credential-storage.mjs.map +1 -0
  45. package/dist/es/ai-model/service-caller/openai/siwc/errors.mjs +42 -0
  46. package/dist/es/ai-model/service-caller/openai/siwc/errors.mjs.map +1 -0
  47. package/dist/es/ai-model/service-caller/openai/siwc/index.mjs +7 -0
  48. package/dist/es/ai-model/service-caller/openai/siwc/prepare-call.mjs +33 -0
  49. package/dist/es/ai-model/service-caller/openai/siwc/prepare-call.mjs.map +1 -0
  50. package/dist/es/ai-model/service-caller/openai/siwc/refresh.mjs +60 -0
  51. package/dist/es/ai-model/service-caller/openai/siwc/refresh.mjs.map +1 -0
  52. package/dist/es/ai-model/service-caller/openai/siwc/token-manager.mjs +51 -0
  53. package/dist/es/ai-model/service-caller/openai/siwc/token-manager.mjs.map +1 -0
  54. package/dist/es/ai-model/service-caller/system-one/call-system-one.mjs +69 -0
  55. package/dist/es/ai-model/service-caller/system-one/call-system-one.mjs.map +1 -0
  56. package/dist/es/ai-model/service-caller/system-one/index.mjs +3 -0
  57. package/dist/es/ai-model/service-caller/system-one/prepare-system-one.mjs +44 -0
  58. package/dist/es/ai-model/service-caller/system-one/prepare-system-one.mjs.map +1 -0
  59. package/dist/es/ai-model/service-caller/system-one/schema.mjs +32 -0
  60. package/dist/es/ai-model/service-caller/system-one/schema.mjs.map +1 -0
  61. package/dist/es/ai-model/service-caller/system-one/utils.mjs +34 -0
  62. package/dist/es/ai-model/service-caller/system-one/utils.mjs.map +1 -0
  63. package/dist/es/ai-model/service-caller/utils.mjs +2 -2
  64. package/dist/es/ai-model/service-caller/utils.mjs.map +1 -1
  65. package/dist/es/ai-model/shared/model-locate-result/factory.mjs +7 -3
  66. package/dist/es/ai-model/shared/model-locate-result/factory.mjs.map +1 -1
  67. package/dist/es/ai-model/shared/model-locate-result/pixel-mapper.mjs +10 -4
  68. package/dist/es/ai-model/shared/model-locate-result/pixel-mapper.mjs.map +1 -1
  69. package/dist/es/ai-model/shared/model-locate-result/types.mjs.map +1 -1
  70. package/dist/es/ai-model/shared/model-locate-result/validation.mjs +4 -0
  71. package/dist/es/ai-model/shared/model-locate-result/validation.mjs.map +1 -1
  72. package/dist/es/ai-model/workflows/grounding/locate.mjs +2 -2
  73. package/dist/es/ai-model/workflows/grounding/locate.mjs.map +1 -1
  74. package/dist/es/ai-model/workflows/grounding/section-locate.mjs +2 -2
  75. package/dist/es/ai-model/workflows/grounding/section-locate.mjs.map +1 -1
  76. package/dist/es/ai-model/workflows/insight/boolean.mjs +1 -1
  77. package/dist/es/ai-model/workflows/insight/boolean.mjs.map +1 -1
  78. package/dist/es/ai-model/workflows/insight/extraction.mjs +3 -3
  79. package/dist/es/ai-model/workflows/insight/extraction.mjs.map +1 -1
  80. package/dist/es/ai-model/workflows/planning/standard-planning.mjs +4 -3
  81. package/dist/es/ai-model/workflows/planning/standard-planning.mjs.map +1 -1
  82. package/dist/es/ai-model/workflows/recorder-generation/playwright.mjs +2 -2
  83. package/dist/es/ai-model/workflows/recorder-generation/playwright.mjs.map +1 -1
  84. package/dist/es/ai-model/workflows/recorder-generation/yaml.mjs +2 -2
  85. package/dist/es/ai-model/workflows/recorder-generation/yaml.mjs.map +1 -1
  86. package/dist/es/device/index.mjs +7 -0
  87. package/dist/es/device/index.mjs.map +1 -1
  88. package/dist/es/report-html-template.mjs +1 -1
  89. package/dist/es/service/index.mjs +2 -1
  90. package/dist/es/service/index.mjs.map +1 -1
  91. package/dist/es/types.mjs.map +1 -1
  92. package/dist/es/utils.mjs +1 -1
  93. package/dist/lib/agent/agent.js +11 -11
  94. package/dist/lib/agent/agent.js.map +1 -1
  95. package/dist/lib/agent/insight.js.map +1 -1
  96. package/dist/lib/agent/tasks.js +72 -39
  97. package/dist/lib/agent/tasks.js.map +1 -1
  98. package/dist/lib/agent/utils.js +1 -1
  99. package/dist/lib/ai-model/connectivity/run-connectivity-test.js +27 -22
  100. package/dist/lib/ai-model/connectivity/run-connectivity-test.js.map +1 -1
  101. package/dist/lib/ai-model/index.js +34 -5
  102. package/dist/lib/ai-model/model-adapter/resolve.js +4 -2
  103. package/dist/lib/ai-model/model-adapter/resolve.js.map +1 -1
  104. package/dist/lib/ai-model/models/jev/adapter.js +6 -110
  105. package/dist/lib/ai-model/models/jev/adapter.js.map +1 -1
  106. package/dist/lib/ai-model/models/jev/boolean.js +82 -0
  107. package/dist/lib/ai-model/models/jev/boolean.js.map +1 -0
  108. package/dist/lib/ai-model/models/jev/image.js +41 -35
  109. package/dist/lib/ai-model/models/jev/image.js.map +1 -1
  110. package/dist/lib/ai-model/models/jev/locate.js +82 -0
  111. package/dist/lib/ai-model/models/jev/locate.js.map +1 -0
  112. package/dist/lib/ai-model/models/jev/planning-action.js +69 -0
  113. package/dist/lib/ai-model/models/jev/planning-action.js.map +1 -0
  114. package/dist/lib/ai-model/models/jev/planning-context.js +72 -0
  115. package/dist/lib/ai-model/models/jev/planning-context.js.map +1 -0
  116. package/dist/lib/ai-model/models/jev/planning-decision.js +102 -0
  117. package/dist/lib/ai-model/models/jev/planning-decision.js.map +1 -0
  118. package/dist/lib/ai-model/models/jev/planning.js +19 -131
  119. package/dist/lib/ai-model/models/jev/planning.js.map +1 -1
  120. package/dist/lib/ai-model/models/{task-routing.js → model-fallback.js} +11 -11
  121. package/dist/lib/ai-model/models/model-fallback.js.map +1 -0
  122. package/dist/lib/ai-model/service-caller/call-ai.js +59 -29
  123. package/dist/lib/ai-model/service-caller/call-ai.js.map +1 -1
  124. package/dist/lib/ai-model/service-caller/codex/call-codex.js.map +1 -1
  125. package/dist/lib/ai-model/service-caller/index.js +6 -3
  126. package/dist/lib/ai-model/service-caller/model-call.js +2 -2
  127. package/dist/lib/ai-model/service-caller/model-call.js.map +1 -1
  128. package/dist/lib/ai-model/service-caller/openai/call-openai.js +4 -2
  129. package/dist/lib/ai-model/service-caller/openai/call-openai.js.map +1 -1
  130. package/dist/lib/ai-model/service-caller/openai/chat-completion/chat-completion.js.map +1 -1
  131. package/dist/lib/ai-model/service-caller/openai/openai-client.js.map +1 -1
  132. package/dist/lib/ai-model/service-caller/openai/responses/responses.js.map +1 -1
  133. package/dist/lib/ai-model/service-caller/openai/siwc/authorization.js +157 -0
  134. package/dist/lib/ai-model/service-caller/openai/siwc/authorization.js.map +1 -0
  135. package/dist/lib/ai-model/service-caller/openai/siwc/credential-storage.js +103 -0
  136. package/dist/lib/ai-model/service-caller/openai/siwc/credential-storage.js.map +1 -0
  137. package/dist/lib/ai-model/service-caller/openai/siwc/errors.js +85 -0
  138. package/dist/lib/ai-model/service-caller/openai/siwc/errors.js.map +1 -0
  139. package/dist/lib/ai-model/service-caller/openai/siwc/index.js +64 -0
  140. package/dist/lib/ai-model/service-caller/openai/siwc/index.js.map +1 -0
  141. package/dist/lib/ai-model/service-caller/openai/siwc/prepare-call.js +67 -0
  142. package/dist/lib/ai-model/service-caller/openai/siwc/prepare-call.js.map +1 -0
  143. package/dist/lib/ai-model/service-caller/openai/siwc/refresh.js +94 -0
  144. package/dist/lib/ai-model/service-caller/openai/siwc/refresh.js.map +1 -0
  145. package/dist/lib/ai-model/service-caller/openai/siwc/token-manager.js +85 -0
  146. package/dist/lib/ai-model/service-caller/openai/siwc/token-manager.js.map +1 -0
  147. package/dist/lib/ai-model/service-caller/system-one/call-system-one.js +103 -0
  148. package/dist/lib/ai-model/service-caller/system-one/call-system-one.js.map +1 -0
  149. package/dist/lib/ai-model/service-caller/system-one/index.js +42 -0
  150. package/dist/lib/ai-model/service-caller/system-one/index.js.map +1 -0
  151. package/dist/lib/ai-model/service-caller/system-one/prepare-system-one.js +78 -0
  152. package/dist/lib/ai-model/service-caller/system-one/prepare-system-one.js.map +1 -0
  153. package/dist/lib/ai-model/service-caller/system-one/schema.js +69 -0
  154. package/dist/lib/ai-model/service-caller/system-one/schema.js.map +1 -0
  155. package/dist/lib/ai-model/service-caller/system-one/utils.js +68 -0
  156. package/dist/lib/ai-model/service-caller/system-one/utils.js.map +1 -0
  157. package/dist/lib/ai-model/service-caller/utils.js +2 -2
  158. package/dist/lib/ai-model/service-caller/utils.js.map +1 -1
  159. package/dist/lib/ai-model/shared/model-locate-result/factory.js +7 -3
  160. package/dist/lib/ai-model/shared/model-locate-result/factory.js.map +1 -1
  161. package/dist/lib/ai-model/shared/model-locate-result/pixel-mapper.js +10 -4
  162. package/dist/lib/ai-model/shared/model-locate-result/pixel-mapper.js.map +1 -1
  163. package/dist/lib/ai-model/shared/model-locate-result/types.js.map +1 -1
  164. package/dist/lib/ai-model/shared/model-locate-result/validation.js +4 -0
  165. package/dist/lib/ai-model/shared/model-locate-result/validation.js.map +1 -1
  166. package/dist/lib/ai-model/workflows/grounding/locate.js +1 -1
  167. package/dist/lib/ai-model/workflows/grounding/locate.js.map +1 -1
  168. package/dist/lib/ai-model/workflows/grounding/section-locate.js +1 -1
  169. package/dist/lib/ai-model/workflows/grounding/section-locate.js.map +1 -1
  170. package/dist/lib/ai-model/workflows/insight/boolean.js +1 -1
  171. package/dist/lib/ai-model/workflows/insight/boolean.js.map +1 -1
  172. package/dist/lib/ai-model/workflows/insight/extraction.js +2 -2
  173. package/dist/lib/ai-model/workflows/insight/extraction.js.map +1 -1
  174. package/dist/lib/ai-model/workflows/planning/standard-planning.js +3 -2
  175. package/dist/lib/ai-model/workflows/planning/standard-planning.js.map +1 -1
  176. package/dist/lib/ai-model/workflows/recorder-generation/playwright.js +1 -1
  177. package/dist/lib/ai-model/workflows/recorder-generation/playwright.js.map +1 -1
  178. package/dist/lib/ai-model/workflows/recorder-generation/yaml.js +1 -1
  179. package/dist/lib/ai-model/workflows/recorder-generation/yaml.js.map +1 -1
  180. package/dist/lib/device/index.js +7 -0
  181. package/dist/lib/device/index.js.map +1 -1
  182. package/dist/lib/report-html-template.js +1 -1
  183. package/dist/lib/service/index.js +2 -1
  184. package/dist/lib/service/index.js.map +1 -1
  185. package/dist/lib/test-runner/engine/index.js +2 -2
  186. package/dist/lib/test-runner/node/index.js +2 -2
  187. package/dist/lib/types.js.map +1 -1
  188. package/dist/lib/utils.js +1 -1
  189. package/dist/types/agent/agent.d.ts.map +1 -1
  190. package/dist/types/agent/insight.d.ts +2 -2
  191. package/dist/types/agent/insight.d.ts.map +1 -1
  192. package/dist/types/agent/tasks.d.ts.map +1 -1
  193. package/dist/types/ai-model/connectivity/run-connectivity-test.d.ts.map +1 -1
  194. package/dist/types/ai-model/index.d.ts +4 -1
  195. package/dist/types/ai-model/index.d.ts.map +1 -1
  196. package/dist/types/ai-model/model-adapter/resolve.d.ts +2 -1
  197. package/dist/types/ai-model/model-adapter/resolve.d.ts.map +1 -1
  198. package/dist/types/ai-model/model-adapter/types.d.ts +8 -5
  199. package/dist/types/ai-model/model-adapter/types.d.ts.map +1 -1
  200. package/dist/types/ai-model/models/gpt.d.ts +2 -2
  201. package/dist/types/ai-model/models/jev/adapter.d.ts +4 -5
  202. package/dist/types/ai-model/models/jev/adapter.d.ts.map +1 -1
  203. package/dist/types/ai-model/models/jev/boolean.d.ts +3 -0
  204. package/dist/types/ai-model/models/jev/boolean.d.ts.map +1 -0
  205. package/dist/types/ai-model/models/jev/image.d.ts +11 -11
  206. package/dist/types/ai-model/models/jev/image.d.ts.map +1 -1
  207. package/dist/types/ai-model/models/jev/locate.d.ts +3 -0
  208. package/dist/types/ai-model/models/jev/locate.d.ts.map +1 -0
  209. package/dist/types/ai-model/models/jev/planning-action.d.ts +6 -0
  210. package/dist/types/ai-model/models/jev/planning-action.d.ts.map +1 -0
  211. package/dist/types/ai-model/models/jev/planning-context.d.ts +23 -0
  212. package/dist/types/ai-model/models/jev/planning-context.d.ts.map +1 -0
  213. package/dist/types/ai-model/models/jev/planning-decision.d.ts +35 -0
  214. package/dist/types/ai-model/models/jev/planning-decision.d.ts.map +1 -0
  215. package/dist/types/ai-model/models/jev/planning.d.ts.map +1 -1
  216. package/dist/types/ai-model/models/model-fallback.d.ts +6 -0
  217. package/dist/types/ai-model/models/model-fallback.d.ts.map +1 -0
  218. package/dist/types/ai-model/models/registry.d.ts +4 -3
  219. package/dist/types/ai-model/models/registry.d.ts.map +1 -1
  220. package/dist/types/ai-model/service-caller/call-ai.d.ts +3 -1
  221. package/dist/types/ai-model/service-caller/call-ai.d.ts.map +1 -1
  222. package/dist/types/ai-model/service-caller/codex/call-codex.d.ts +5 -3
  223. package/dist/types/ai-model/service-caller/codex/call-codex.d.ts.map +1 -1
  224. package/dist/types/ai-model/service-caller/index.d.ts +1 -1
  225. package/dist/types/ai-model/service-caller/index.d.ts.map +1 -1
  226. package/dist/types/ai-model/service-caller/model-call.d.ts +2 -2
  227. package/dist/types/ai-model/service-caller/model-call.d.ts.map +1 -1
  228. package/dist/types/ai-model/service-caller/openai/call-openai.d.ts +2 -2
  229. package/dist/types/ai-model/service-caller/openai/call-openai.d.ts.map +1 -1
  230. package/dist/types/ai-model/service-caller/openai/chat-completion/chat-completion.d.ts +4 -2
  231. package/dist/types/ai-model/service-caller/openai/chat-completion/chat-completion.d.ts.map +1 -1
  232. package/dist/types/ai-model/service-caller/openai/responses/responses.d.ts +4 -2
  233. package/dist/types/ai-model/service-caller/openai/responses/responses.d.ts.map +1 -1
  234. package/dist/types/ai-model/service-caller/openai/siwc/authorization.d.ts +42 -0
  235. package/dist/types/ai-model/service-caller/openai/siwc/authorization.d.ts.map +1 -0
  236. package/dist/types/ai-model/service-caller/openai/siwc/credential-storage.d.ts +21 -0
  237. package/dist/types/ai-model/service-caller/openai/siwc/credential-storage.d.ts.map +1 -0
  238. package/dist/types/ai-model/service-caller/openai/siwc/errors.d.ts +10 -0
  239. package/dist/types/ai-model/service-caller/openai/siwc/errors.d.ts.map +1 -0
  240. package/dist/types/ai-model/service-caller/openai/siwc/index.d.ts +7 -0
  241. package/dist/types/ai-model/service-caller/openai/siwc/index.d.ts.map +1 -0
  242. package/dist/types/ai-model/service-caller/openai/siwc/prepare-call.d.ts +8 -0
  243. package/dist/types/ai-model/service-caller/openai/siwc/prepare-call.d.ts.map +1 -0
  244. package/dist/types/ai-model/service-caller/openai/siwc/refresh.d.ts +19 -0
  245. package/dist/types/ai-model/service-caller/openai/siwc/refresh.d.ts.map +1 -0
  246. package/dist/types/ai-model/service-caller/openai/siwc/token-manager.d.ts +10 -0
  247. package/dist/types/ai-model/service-caller/openai/siwc/token-manager.d.ts.map +1 -0
  248. package/dist/types/ai-model/service-caller/system-one/call-system-one.d.ts +4 -0
  249. package/dist/types/ai-model/service-caller/system-one/call-system-one.d.ts.map +1 -0
  250. package/dist/types/ai-model/service-caller/system-one/index.d.ts +3 -0
  251. package/dist/types/ai-model/service-caller/system-one/index.d.ts.map +1 -0
  252. package/dist/types/ai-model/service-caller/system-one/prepare-system-one.d.ts +21 -0
  253. package/dist/types/ai-model/service-caller/system-one/prepare-system-one.d.ts.map +1 -0
  254. package/dist/types/ai-model/service-caller/{system-one.d.ts → system-one/schema.d.ts} +1 -22
  255. package/dist/types/ai-model/service-caller/system-one/schema.d.ts.map +1 -0
  256. package/dist/types/ai-model/service-caller/system-one/utils.d.ts +6 -0
  257. package/dist/types/ai-model/service-caller/system-one/utils.d.ts.map +1 -0
  258. package/dist/types/ai-model/service-caller/types.d.ts +0 -3
  259. package/dist/types/ai-model/service-caller/types.d.ts.map +1 -1
  260. package/dist/types/ai-model/service-caller/utils.d.ts +3 -3
  261. package/dist/types/ai-model/shared/model-locate-result/factory.d.ts.map +1 -1
  262. package/dist/types/ai-model/shared/model-locate-result/index.d.ts +1 -1
  263. package/dist/types/ai-model/shared/model-locate-result/index.d.ts.map +1 -1
  264. package/dist/types/ai-model/shared/model-locate-result/pixel-mapper.d.ts +3 -3
  265. package/dist/types/ai-model/shared/model-locate-result/pixel-mapper.d.ts.map +1 -1
  266. package/dist/types/ai-model/shared/model-locate-result/types.d.ts +4 -0
  267. package/dist/types/ai-model/shared/model-locate-result/types.d.ts.map +1 -1
  268. package/dist/types/ai-model/shared/model-locate-result/validation.d.ts.map +1 -1
  269. package/dist/types/ai-model/workflows/grounding/locate.d.ts.map +1 -1
  270. package/dist/types/ai-model/workflows/grounding/section-locate.d.ts.map +1 -1
  271. package/dist/types/ai-model/workflows/insight/boolean.d.ts.map +1 -1
  272. package/dist/types/ai-model/workflows/insight/extraction.d.ts +2 -0
  273. package/dist/types/ai-model/workflows/insight/extraction.d.ts.map +1 -1
  274. package/dist/types/ai-model/workflows/planning/standard-planning.d.ts.map +1 -1
  275. package/dist/types/ai-model/workflows/planning/types.d.ts +2 -1
  276. package/dist/types/ai-model/workflows/planning/types.d.ts.map +1 -1
  277. package/dist/types/ai-model/workflows/recorder-generation/playwright.d.ts.map +1 -1
  278. package/dist/types/ai-model/workflows/recorder-generation/yaml.d.ts.map +1 -1
  279. package/dist/types/device/index.d.ts +1 -0
  280. package/dist/types/device/index.d.ts.map +1 -1
  281. package/dist/types/service/index.d.ts +1 -1
  282. package/dist/types/service/index.d.ts.map +1 -1
  283. package/dist/types/types.d.ts +14 -3
  284. package/dist/types/types.d.ts.map +1 -1
  285. package/package.json +3 -2
  286. package/dist/es/ai-model/models/task-routing.mjs +0 -28
  287. package/dist/es/ai-model/models/task-routing.mjs.map +0 -1
  288. package/dist/es/ai-model/service-caller/system-one.mjs +0 -163
  289. package/dist/es/ai-model/service-caller/system-one.mjs.map +0 -1
  290. package/dist/lib/ai-model/models/task-routing.js.map +0 -1
  291. package/dist/lib/ai-model/service-caller/system-one.js +0 -206
  292. package/dist/lib/ai-model/service-caller/system-one.js.map +0 -1
  293. package/dist/types/ai-model/models/task-routing.d.ts +0 -6
  294. package/dist/types/ai-model/models/task-routing.d.ts.map +0 -1
  295. package/dist/types/ai-model/service-caller/system-one.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/service-caller/openai/chat-completion/chat-completion.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../../src/ai-model/service-caller/openai/chat-completion/chat-completion.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { getDebug } from '@midscene/shared/logger';\nimport type { ResolveImageDetail } from '../../../model-adapter/types';\nimport type { ModelRequestConfigInput } from '../../../model-adapter/types';\nimport { createProxyAgentIfNeeded } from '../../proxy';\nimport type { ModelCallContext, OpenAIProtocolCallResult } from '../../types';\nimport { stringifyForDebug } from '../../utils';\nimport { callChatCompletionNonStreaming } from './non-stream';\nimport { callChatCompletionStream } from './stream';\nimport type { ChatCompletionCallOptions } from './types';\nimport { toChatMessages } from './utils';\n\nexport const prepareChatCompletion = async ({\n messages,\n modelRuntime,\n options,\n}: Pick<ModelCallContext, 'messages' | 'modelRuntime' | 'options'>) => {\n const debugCall = getDebug('ai:call');\n const { config: modelConfig, adapter } = modelRuntime;\n\n const modelCallInput: ModelRequestConfigInput = {\n intent: modelConfig.intent,\n userConfig: {\n temperature: modelConfig.temperature,\n reasoningEnabled: modelConfig.reasoningEnabled,\n reasoningEffort: modelConfig.reasoningEffort,\n reasoningBudget: modelConfig.reasoningBudget,\n responseFormat: modelConfig.responseFormat,\n },\n semanticRetryAttempt: options?.semanticRetryAttempt,\n requiresOriginalImageDetail: options?.requiresOriginalImageDetail,\n expectedJsonObjectResponse: options?.expectedJsonObjectResponse,\n };\n\n const { config: adapterChatCompletionParams } =\n adapter.chatCompletion.buildChatCompletionParams(modelCallInput);\n\n debugCall(\n `adapter chat completion params: ${stringifyForDebug({\n config: adapterChatCompletionParams,\n })}`,\n );\n\n const resolveImageDetail: ResolveImageDetail = ({ imageDetail }) =>\n adapter.resolveImageDetail({\n imageDetail,\n intent: modelConfig.intent,\n requiresOriginalImageDetail: options?.requiresOriginalImageDetail,\n });\n\n const requestBodyParams: ChatCompletionCallOptions['requestBodyParams'] = {\n model: modelConfig.modelName,\n messages: toChatMessages(messages, resolveImageDetail),\n ...adapterChatCompletionParams,\n ...(modelConfig.extraBody ?? {}),\n };\n\n const proxyAgent = await createProxyAgentIfNeeded({\n socksProxy: modelConfig.socksProxy,\n httpProxy: modelConfig.httpProxy,\n });\n\n return {\n requestParams: requestBodyParams,\n extractContentAndReasoning:\n adapter.chatCompletion.extractContentAndReasoning,\n useReasoningAsContentFallback:\n adapter.chatCompletion.useReasoningAsContentFallback,\n proxyAgent,\n };\n};\n\nexport function callChatCompletion(\n options: ChatCompletionCallOptions,\n stream: boolean,\n): Promise<OpenAIProtocolCallResult> {\n return stream\n ? callChatCompletionStream(options)\n : callChatCompletionNonStreaming(options);\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","prepareChatCompletion","messages","modelRuntime","options","debugCall","getDebug","modelConfig","adapter","modelCallInput","adapterChatCompletionParams","stringifyForDebug","resolveImageDetail","imageDetail","requestBodyParams","toChatMessages","proxyAgent","createProxyAgentIfNeeded","callChatCompletion","stream","callChatCompletionStream","callChatCompletionNonStreaming"],"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,MAAMI,wBAAwB,OAAO,EAC1CC,QAAQ,EACRC,YAAY,EACZC,OAAO,EACyD;IAChE,MAAMC,YAAYC,AAAAA,IAAAA,uBAAAA,QAAAA,AAAAA,EAAS;IAC3B,MAAM,EAAE,QAAQC,WAAW,EAAEC,OAAO,EAAE,GAAGL;IAEzC,MAAMM,iBAA0C;QAC9C,QAAQF,YAAY,MAAM;QAC1B,YAAY;YACV,aAAaA,YAAY,WAAW;YACpC,kBAAkBA,YAAY,gBAAgB;YAC9C,iBAAiBA,YAAY,eAAe;YAC5C,iBAAiBA,YAAY,eAAe;YAC5C,gBAAgBA,YAAY,cAAc;QAC5C;QACA,sBAAsBH,SAAS;QAC/B,6BAA6BA,SAAS;QACtC,4BAA4BA,SAAS;IACvC;IAEA,MAAM,EAAE,QAAQM,2BAA2B,EAAE,GAC3CF,QAAQ,cAAc,CAAC,yBAAyB,CAACC;IAEnDJ,UACE,CAAC,gCAAgC,EAAEM,AAAAA,IAAAA,kCAAAA,iBAAAA,AAAAA,EAAkB;QACnD,QAAQD;IACV,IAAI;IAGN,MAAME,qBAAyC,CAAC,EAAEC,WAAW,EAAE,GAC7DL,QAAQ,kBAAkB,CAAC;YACzBK;YACA,QAAQN,YAAY,MAAM;YAC1B,6BAA6BH,SAAS;QACxC;IAEF,MAAMU,oBAAoE;QACxE,OAAOP,YAAY,SAAS;QAC5B,UAAUQ,AAAAA,IAAAA,oCAAAA,cAAAA,AAAAA,EAAeb,UAAUU;QACnC,GAAGF,2BAA2B;QAC9B,GAAIH,YAAY,SAAS,IAAI,CAAC,CAAC;IACjC;IAEA,MAAMS,aAAa,MAAMC,AAAAA,IAAAA,yBAAAA,wBAAAA,AAAAA,EAAyB;QAChD,YAAYV,YAAY,UAAU;QAClC,WAAWA,YAAY,SAAS;IAClC;IAEA,OAAO;QACL,eAAeO;QACf,4BACEN,QAAQ,cAAc,CAAC,0BAA0B;QACnD,+BACEA,QAAQ,cAAc,CAAC,6BAA6B;QACtDQ;IACF;AACF;AAEO,SAASE,mBACdd,OAAkC,EAClCe,MAAe;IAEf,OAAOA,SACHC,AAAAA,IAAAA,mCAAAA,wBAAAA,AAAAA,EAAyBhB,WACzBiB,AAAAA,IAAAA,uCAAAA,8BAAAA,AAAAA,EAA+BjB;AACrC"}
1
+ {"version":3,"file":"ai-model/service-caller/openai/chat-completion/chat-completion.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../../src/ai-model/service-caller/openai/chat-completion/chat-completion.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { getDebug } from '@midscene/shared/logger';\nimport type { ResolveImageDetail } from '../../../model-adapter/types';\nimport type { ModelRequestConfigInput } from '../../../model-adapter/types';\nimport { createProxyAgentIfNeeded } from '../../proxy';\nimport type {\n ModelCallContext,\n ModelCallMessages,\n OpenAIProtocolCallResult,\n} from '../../types';\nimport { stringifyForDebug } from '../../utils';\nimport { callChatCompletionNonStreaming } from './non-stream';\nimport { callChatCompletionStream } from './stream';\nimport type { ChatCompletionCallOptions } from './types';\nimport { toChatMessages } from './utils';\n\nexport const prepareChatCompletion = async ({\n messages,\n modelRuntime,\n options,\n}: Pick<ModelCallContext, 'modelRuntime' | 'options'> & {\n messages: ModelCallMessages;\n}) => {\n const debugCall = getDebug('ai:call');\n const { config: modelConfig, adapter } = modelRuntime;\n\n const modelCallInput: ModelRequestConfigInput = {\n intent: modelConfig.intent,\n userConfig: {\n temperature: modelConfig.temperature,\n reasoningEnabled: modelConfig.reasoningEnabled,\n reasoningEffort: modelConfig.reasoningEffort,\n reasoningBudget: modelConfig.reasoningBudget,\n responseFormat: modelConfig.responseFormat,\n },\n semanticRetryAttempt: options?.semanticRetryAttempt,\n requiresOriginalImageDetail: options?.requiresOriginalImageDetail,\n expectedJsonObjectResponse: options?.expectedJsonObjectResponse,\n };\n\n const { config: adapterChatCompletionParams } =\n adapter.chatCompletion.buildChatCompletionParams(modelCallInput);\n\n debugCall(\n `adapter chat completion params: ${stringifyForDebug({\n config: adapterChatCompletionParams,\n })}`,\n );\n\n const resolveImageDetail: ResolveImageDetail = ({ imageDetail }) =>\n adapter.resolveImageDetail({\n imageDetail,\n intent: modelConfig.intent,\n requiresOriginalImageDetail: options?.requiresOriginalImageDetail,\n });\n\n const requestBodyParams: ChatCompletionCallOptions['requestBodyParams'] = {\n model: modelConfig.modelName,\n messages: toChatMessages(messages, resolveImageDetail),\n ...adapterChatCompletionParams,\n ...(modelConfig.extraBody ?? {}),\n };\n\n const proxyAgent = await createProxyAgentIfNeeded({\n socksProxy: modelConfig.socksProxy,\n httpProxy: modelConfig.httpProxy,\n });\n\n return {\n requestParams: requestBodyParams,\n extractContentAndReasoning:\n adapter.chatCompletion.extractContentAndReasoning,\n useReasoningAsContentFallback:\n adapter.chatCompletion.useReasoningAsContentFallback,\n proxyAgent,\n };\n};\n\nexport function callChatCompletion(\n options: ChatCompletionCallOptions,\n stream: boolean,\n): Promise<OpenAIProtocolCallResult> {\n return stream\n ? callChatCompletionStream(options)\n : callChatCompletionNonStreaming(options);\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","prepareChatCompletion","messages","modelRuntime","options","debugCall","getDebug","modelConfig","adapter","modelCallInput","adapterChatCompletionParams","stringifyForDebug","resolveImageDetail","imageDetail","requestBodyParams","toChatMessages","proxyAgent","createProxyAgentIfNeeded","callChatCompletion","stream","callChatCompletionStream","callChatCompletionNonStreaming"],"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,OA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A,OAAO;QACL,eAAeO;QACf,4BACEN,QAAQ,cAAc,CAAC,0BAA0B;QACnD,+BACEA,QAAQ,cAAc,CAAC,6BAA6B;QACtDQ;IACF;AACF;AAEO,SAASE,mBACdd,OAAkC,EAClCe,MAAe;IAEf,OAAOA,SACHC,AAAAA,IAAAA,mCAAAA,wBAAAA,AAAAA,EAAyBhB,WACzBiB,AAAAA,IAAAA,uCAAAA,8BAAAA,AAAAA,EAA+BjB;AACrC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/service-caller/openai/openai-client.js","sources":["webpack/runtime/compat_get_default_export","webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/service-caller/openai/openai-client.ts"],"sourcesContent":["// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__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 {\n type IModelConfig,\n MIDSCENE_LANGFUSE_DEBUG,\n MIDSCENE_LANGSMITH_DEBUG,\n globalConfigManager,\n} from '@midscene/shared/env';\nimport { getDebug } from '@midscene/shared/logger';\nimport { ifInBrowser } from '@midscene/shared/utils';\nimport OpenAI from 'openai';\nimport { getVersion } from '../../../utils';\nimport type { createProxyAgentIfNeeded } from '../proxy';\nimport {\n type OpenAIRequestContext,\n wrapOpenAICompatibleFetch,\n} from './openai-request-context';\n\nconst createAndWrapClient = async ({\n openaiBaseURL,\n openaiApiKey,\n openaiExtraConfig,\n createOpenAIClient,\n effectiveTimeoutMs,\n proxyAgent,\n executionId,\n openAIRequestContext,\n}: {\n openaiBaseURL: IModelConfig['openaiBaseURL'];\n openaiApiKey: IModelConfig['openaiApiKey'];\n openaiExtraConfig: IModelConfig['openaiExtraConfig'];\n createOpenAIClient: IModelConfig['createOpenAIClient'];\n effectiveTimeoutMs: number | null;\n proxyAgent: Awaited<ReturnType<typeof createProxyAgentIfNeeded>>;\n executionId: string;\n openAIRequestContext: OpenAIRequestContext;\n}): Promise<OpenAI> => {\n const warnClient = getDebug('ai:call', { console: true });\n\n const openAIOptions = {\n baseURL: openaiBaseURL,\n apiKey: openaiApiKey,\n // Use fetchOptions.dispatcher for fetch-based SDK instead of httpAgent\n // Note: Type assertion needed due to undici version mismatch between dependencies\n ...(proxyAgent ? { fetchOptions: { dispatcher: proxyAgent as any } } : {}),\n ...openaiExtraConfig,\n // Midscene exposes this setting through MIDSCENE_*_INIT_CONFIG_JSON, so\n // defaultHeaders is expected to be a plain JSON object rather than another\n // HeadersLike representation supported by the OpenAI SDK.\n defaultHeaders: {\n ...(openaiExtraConfig?.defaultHeaders as\n | Record<string, string>\n | undefined),\n // These Midscene-owned headers intentionally override user-supplied\n // headers with the same names.\n 'x-midscene-version': getVersion(),\n 'x-midscene-execution-id': executionId,\n },\n fetch: wrapOpenAICompatibleFetch(openAIRequestContext),\n // Midscene handles request retries in callAI(), so disable SDK-level retries\n // to avoid duplicate attempts and duplicated backoff latency.\n maxRetries: 0,\n // Disabling the Midscene hard timeout leaves the SDK timeout at its\n // configured value or default; it does not disable SDK/network timeouts.\n ...(effectiveTimeoutMs !== null ? { timeout: effectiveTimeoutMs } : {}),\n dangerouslyAllowBrowser: true,\n };\n\n const baseOpenAI = new OpenAI(openAIOptions);\n\n let openai: OpenAI = baseOpenAI;\n\n // LangSmith wrapper\n if (\n openai &&\n globalConfigManager.getEnvConfigInBoolean(MIDSCENE_LANGSMITH_DEBUG)\n ) {\n if (ifInBrowser) {\n throw new Error('langsmith is not supported in browser');\n }\n warnClient('DEBUGGING MODE: langsmith wrapper enabled');\n // Use variable to prevent static analysis by bundlers\n const langsmithModule = 'langsmith/wrappers';\n const { wrapOpenAI } = await import(langsmithModule);\n openai = wrapOpenAI(openai);\n }\n\n // Langfuse wrapper\n if (\n openai &&\n globalConfigManager.getEnvConfigInBoolean(MIDSCENE_LANGFUSE_DEBUG)\n ) {\n if (ifInBrowser) {\n throw new Error('langfuse is not supported in browser');\n }\n warnClient('DEBUGGING MODE: langfuse wrapper enabled');\n // Use variable to prevent static analysis by bundlers\n const langfuseModule = '@langfuse/openai';\n const { observeOpenAI } = await import(langfuseModule);\n openai = observeOpenAI(openai);\n }\n\n if (createOpenAIClient) {\n const wrappedClient = await createOpenAIClient(baseOpenAI, openAIOptions);\n\n if (wrappedClient) {\n openai = wrappedClient as OpenAI;\n }\n }\n\n return openai;\n};\n\nexport async function createClient({\n modelConfig,\n proxyAgent,\n effectiveTimeoutMs,\n executionId,\n recordEvent,\n}: {\n modelConfig: IModelConfig;\n proxyAgent: Awaited<ReturnType<typeof createProxyAgentIfNeeded>>;\n effectiveTimeoutMs: number | null;\n executionId: string;\n recordEvent?: (event: Record<string, unknown>) => void;\n}): Promise<{\n openai: OpenAI;\n openAIRequestContext: OpenAIRequestContext;\n}> {\n const { openaiBaseURL, openaiApiKey, openaiExtraConfig, createOpenAIClient } =\n modelConfig;\n\n const openAIRequestContext: OpenAIRequestContext = {\n recordEvent,\n };\n\n const openai = await createAndWrapClient({\n openaiBaseURL,\n openaiApiKey,\n openaiExtraConfig,\n createOpenAIClient,\n effectiveTimeoutMs,\n proxyAgent,\n executionId,\n openAIRequestContext,\n });\n\n return {\n openai,\n openAIRequestContext,\n };\n}\n"],"names":["__webpack_require__","module","getter","definition","key","Object","obj","prop","Symbol","createAndWrapClient","openaiBaseURL","openaiApiKey","openaiExtraConfig","createOpenAIClient","effectiveTimeoutMs","proxyAgent","executionId","openAIRequestContext","warnClient","getDebug","openAIOptions","getVersion","wrapOpenAICompatibleFetch","baseOpenAI","OpenAI","openai","globalConfigManager","MIDSCENE_LANGSMITH_DEBUG","ifInBrowser","Error","langsmithModule","wrapOpenAI","MIDSCENE_LANGFUSE_DEBUG","langfuseModule","observeOpenAI","wrappedClient","createClient","modelConfig","recordEvent"],"mappings":";;;IACAA,oBAAoB,CAAC,GAAG,CAACC;QACxB,IAAIC,SAASD,UAAUA,OAAO,UAAU,GACvC,IAAOA,MAAM,CAAC,UAAU,GACxB,IAAOA;QACRD,oBAAoB,CAAC,CAACE,QAAQ;YAAE,GAAGA;QAAO;QAC1C,OAAOA;IACR;;;ICPAF,oBAAoB,CAAC,GAAG,CAAC,UAASG;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGH,oBAAoB,CAAC,CAACG,YAAYC,QAAQ,CAACJ,oBAAoB,CAAC,CAAC,UAASI,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAJ,oBAAoB,CAAC,GAAG,CAACM,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFP,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOQ,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;ACUA,MAAMI,sBAAsB,OAAO,EACjCC,aAAa,EACbC,YAAY,EACZC,iBAAiB,EACjBC,kBAAkB,EAClBC,kBAAkB,EAClBC,UAAU,EACVC,WAAW,EACXC,oBAAoB,EAUrB;IACC,MAAMC,aAAaC,AAAAA,IAAAA,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,kBAAkB,EAClBE,WAAW,EACXsB,WAAW,EAOZ;IAIC,MAAM,EAAE5B,aAAa,EAAEC,YAAY,EAAEC,iBAAiB,EAAEC,kBAAkB,EAAE,GAC1EwB;IAEF,MAAMpB,uBAA6C;QACjDqB;IACF;IAEA,MAAMb,SAAS,MAAMhB,oBAAoB;QACvCC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;IACF;IAEA,OAAO;QACLQ;QACAR;IACF;AACF"}
1
+ {"version":3,"file":"ai-model/service-caller/openai/openai-client.js","sources":["webpack/runtime/compat_get_default_export","webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/service-caller/openai/openai-client.ts"],"sourcesContent":["// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__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 {\n type IModelConfig,\n MIDSCENE_LANGFUSE_DEBUG,\n MIDSCENE_LANGSMITH_DEBUG,\n globalConfigManager,\n} from '@midscene/shared/env';\nimport { getDebug } from '@midscene/shared/logger';\nimport { ifInBrowser } from '@midscene/shared/utils';\nimport OpenAI from 'openai';\nimport { getVersion } from '../../../utils';\nimport type { createProxyAgentIfNeeded } from '../proxy';\nimport {\n type OpenAIRequestContext,\n wrapOpenAICompatibleFetch,\n} from './openai-request-context';\n\nconst createAndWrapClient = async ({\n openaiBaseURL,\n openaiApiKey,\n openaiExtraConfig,\n createOpenAIClient,\n effectiveTimeoutMs,\n proxyAgent,\n executionId,\n openAIRequestContext,\n}: {\n openaiBaseURL: IModelConfig['openaiBaseURL'];\n openaiApiKey: IModelConfig['openaiApiKey'];\n openaiExtraConfig: IModelConfig['openaiExtraConfig'];\n createOpenAIClient: IModelConfig['createOpenAIClient'];\n effectiveTimeoutMs: number | null;\n proxyAgent: Awaited<ReturnType<typeof createProxyAgentIfNeeded>>;\n executionId: string;\n openAIRequestContext: OpenAIRequestContext;\n}): Promise<OpenAI> => {\n const warnClient = getDebug('ai:call', { console: true });\n\n const openAIOptions = {\n baseURL: openaiBaseURL,\n apiKey: openaiApiKey,\n // Use fetchOptions.dispatcher for fetch-based SDK instead of httpAgent\n // Note: Type assertion needed due to undici version mismatch between dependencies\n ...(proxyAgent ? { fetchOptions: { dispatcher: proxyAgent as any } } : {}),\n ...openaiExtraConfig,\n // Midscene exposes this setting through MIDSCENE_*_INIT_CONFIG_JSON, so\n // defaultHeaders is expected to be a plain JSON object rather than another\n // HeadersLike representation supported by the OpenAI SDK.\n defaultHeaders: {\n ...(openaiExtraConfig?.defaultHeaders as\n | Record<string, string>\n | undefined),\n // These Midscene-owned headers intentionally override user-supplied\n // headers with the same names.\n 'x-midscene-version': getVersion(),\n 'x-midscene-execution-id': executionId,\n },\n fetch: wrapOpenAICompatibleFetch(openAIRequestContext),\n // Midscene handles request retries in callGenerativeAI(), so disable SDK-level retries\n // to avoid duplicate attempts and duplicated backoff latency.\n maxRetries: 0,\n // Disabling the Midscene hard timeout leaves the SDK timeout at its\n // configured value or default; it does not disable SDK/network timeouts.\n ...(effectiveTimeoutMs !== null ? { timeout: effectiveTimeoutMs } : {}),\n dangerouslyAllowBrowser: true,\n };\n\n const baseOpenAI = new OpenAI(openAIOptions);\n\n let openai: OpenAI = baseOpenAI;\n\n // LangSmith wrapper\n if (\n openai &&\n globalConfigManager.getEnvConfigInBoolean(MIDSCENE_LANGSMITH_DEBUG)\n ) {\n if (ifInBrowser) {\n throw new Error('langsmith is not supported in browser');\n }\n warnClient('DEBUGGING MODE: langsmith wrapper enabled');\n // Use variable to prevent static analysis by bundlers\n const langsmithModule = 'langsmith/wrappers';\n const { wrapOpenAI } = await import(langsmithModule);\n openai = wrapOpenAI(openai);\n }\n\n // Langfuse wrapper\n if (\n openai &&\n globalConfigManager.getEnvConfigInBoolean(MIDSCENE_LANGFUSE_DEBUG)\n ) {\n if (ifInBrowser) {\n throw new Error('langfuse is not supported in browser');\n }\n warnClient('DEBUGGING MODE: langfuse wrapper enabled');\n // Use variable to prevent static analysis by bundlers\n const langfuseModule = '@langfuse/openai';\n const { observeOpenAI } = await import(langfuseModule);\n openai = observeOpenAI(openai);\n }\n\n if (createOpenAIClient) {\n const wrappedClient = await createOpenAIClient(baseOpenAI, openAIOptions);\n\n if (wrappedClient) {\n openai = wrappedClient as OpenAI;\n }\n }\n\n return openai;\n};\n\nexport async function createClient({\n modelConfig,\n proxyAgent,\n effectiveTimeoutMs,\n executionId,\n recordEvent,\n}: {\n modelConfig: IModelConfig;\n proxyAgent: Awaited<ReturnType<typeof createProxyAgentIfNeeded>>;\n effectiveTimeoutMs: number | null;\n executionId: string;\n recordEvent?: (event: Record<string, unknown>) => void;\n}): Promise<{\n openai: OpenAI;\n openAIRequestContext: OpenAIRequestContext;\n}> {\n const { openaiBaseURL, openaiApiKey, openaiExtraConfig, createOpenAIClient } =\n modelConfig;\n\n const openAIRequestContext: OpenAIRequestContext = {\n recordEvent,\n };\n\n const openai = await createAndWrapClient({\n openaiBaseURL,\n openaiApiKey,\n openaiExtraConfig,\n createOpenAIClient,\n effectiveTimeoutMs,\n proxyAgent,\n executionId,\n openAIRequestContext,\n });\n\n return {\n openai,\n openAIRequestContext,\n };\n}\n"],"names":["__webpack_require__","module","getter","definition","key","Object","obj","prop","Symbol","createAndWrapClient","openaiBaseURL","openaiApiKey","openaiExtraConfig","createOpenAIClient","effectiveTimeoutMs","proxyAgent","executionId","openAIRequestContext","warnClient","getDebug","openAIOptions","getVersion","wrapOpenAICompatibleFetch","baseOpenAI","OpenAI","openai","globalConfigManager","MIDSCENE_LANGSMITH_DEBUG","ifInBrowser","Error","langsmithModule","wrapOpenAI","MIDSCENE_LANGFUSE_DEBUG","langfuseModule","observeOpenAI","wrappedClient","createClient","modelConfig","recordEvent"],"mappings":";;;IACAA,oBAAoB,CAAC,GAAG,CAACC;QACxB,IAAIC,SAASD,UAAUA,OAAO,UAAU,GACvC,IAAOA,MAAM,CAAC,UAAU,GACxB,IAAOA;QACRD,oBAAoB,CAAC,CAACE,QAAQ;YAAE,GAAGA;QAAO;QAC1C,OAAOA;IACR;;;ICPAF,oBAAoB,CAAC,GAAG,CAAC,UAASG;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGH,oBAAoB,CAAC,CAACG,YAAYC,QAAQ,CAACJ,oBAAoB,CAAC,CAAC,UAASI,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAJ,oBAAoB,CAAC,GAAG,CAACM,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFP,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOQ,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;ACUA,MAAMI,sBAAsB,OAAO,EACjCC,aAAa,EACbC,YAAY,EACZC,iBAAiB,EACjBC,kBAAkB,EAClBC,kBAAkB,EAClBC,UAAU,EACVC,WAAW,EACXC,oBAAoB,EAUrB;IACC,MAAMC,aAAaC,AAAAA,IAAAA,uBAA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AkB,EAClBE,WAAW,EACXsB,WAAW,EAOZ;IAIC,MAAM,EAAE5B,aAAa,EAAEC,YAAY,EAAEC,iBAAiB,EAAEC,kBAAkB,EAAE,GAC1EwB;IAEF,MAAMpB,uBAA6C;QACjDqB;IACF;IAEA,MAAMb,SAAS,MAAMhB,oBAAoB;QACvCC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;IACF;IAEA,OAAO;QACLQ;QACAR;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/service-caller/openai/responses/responses.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../../src/ai-model/service-caller/openai/responses/responses.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { getDebug } from '@midscene/shared/logger';\nimport type { ResolveImageDetail } from '../../../model-adapter/types';\nimport type { ModelRequestConfigInput } from '../../../model-adapter/types';\nimport { createProxyAgentIfNeeded } from '../../proxy';\nimport type { ModelCallContext, OpenAIProtocolCallResult } from '../../types';\nimport { stringifyForDebug } from '../../utils';\nimport { callResponsesNonStreaming } from './non-stream';\nimport { callResponsesStream } from './stream';\nimport type { ResponsesCallOptions } from './types';\nimport { toResponsesInput } from './utils';\n\nexport async function prepareResponses({\n messages,\n modelRuntime,\n options,\n}: Pick<ModelCallContext, 'messages' | 'modelRuntime' | 'options'>) {\n const debugCall = getDebug('ai:call');\n const { config: modelConfig, adapter } = modelRuntime;\n const modelCallInput: ModelRequestConfigInput = {\n intent: modelConfig.intent,\n userConfig: {\n temperature: modelConfig.temperature,\n reasoningEnabled: modelConfig.reasoningEnabled,\n reasoningEffort: modelConfig.reasoningEffort,\n reasoningBudget: modelConfig.reasoningBudget,\n responseFormat: modelConfig.responseFormat,\n },\n semanticRetryAttempt: options?.semanticRetryAttempt,\n requiresOriginalImageDetail: options?.requiresOriginalImageDetail,\n expectedJsonObjectResponse: options?.expectedJsonObjectResponse,\n };\n const { config } = adapter.responses.buildResponsesParams(modelCallInput);\n debugCall(`adapter responses params: ${stringifyForDebug({ config })}`);\n const resolveImageDetail: ResolveImageDetail = ({ imageDetail }) =>\n adapter.resolveImageDetail({\n imageDetail,\n intent: modelConfig.intent,\n requiresOriginalImageDetail: options?.requiresOriginalImageDetail,\n });\n const requestParams = { ...config, ...modelConfig.extraBody };\n if (requestParams.background === true) {\n throw new Error('Responses background mode is not supported');\n }\n const requestBodyParams: ResponsesCallOptions['requestBodyParams'] = {\n store: false,\n ...requestParams,\n model: modelConfig.modelName,\n input: toResponsesInput(messages, resolveImageDetail),\n };\n const proxyAgent = await createProxyAgentIfNeeded({\n socksProxy: modelConfig.socksProxy,\n httpProxy: modelConfig.httpProxy,\n });\n return {\n requestParams: requestBodyParams,\n proxyAgent,\n };\n}\n\nexport function callResponses(\n options: ResponsesCallOptions,\n stream: boolean,\n): Promise<OpenAIProtocolCallResult> {\n return stream\n ? callResponsesStream(options)\n : callResponsesNonStreaming(options);\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","prepareResponses","messages","modelRuntime","options","debugCall","getDebug","modelConfig","adapter","modelCallInput","config","stringifyForDebug","resolveImageDetail","imageDetail","requestParams","Error","requestBodyParams","toResponsesInput","proxyAgent","createProxyAgentIfNeeded","callResponses","stream","callResponsesStream","callResponsesNonStreaming"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBA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AAY,MAAM;YAC1B,6BAA6BH,SAAS;QACxC;IACF,MAAMU,gBAAgB;QAAE,GAAGJ,MAAM;QAAE,GAAGH,YAAY,SAAS;IAAC;IAC5D,IAAIO,AAA6B,SAA7BA,cAAc,UAAU,EAC1B,MAAM,IAAIC,MAAM;IAElB,MAAMC,oBAA+D;QACnE,OAAO;QACP,GAAGF,aAAa;QAChB,OAAOP,YAAY,SAAS;QAC5B,OAAOU,AAAAA,IAAAA,oCAAAA,gBAAAA,AAAAA,EAAiBf,UAAUU;IACpC;IACA,MAAMM,aAAa,MAAMC,AAAAA,IAAAA,yBAAAA,wBAAAA,AAAAA,EAAyB;QAChD,YAAYZ,YAAY,UAAU;QAClC,WAAWA,YAAY,SAAS;IAClC;IACA,OAAO;QACL,eAAeS;QACfE;IACF;AACF;AAEO,SAASE,cACdhB,OAA6B,EAC7BiB,MAAe;IAEf,OAAOA,SACHC,AAAAA,IAAAA,mCAAAA,mBAAAA,AAAAA,EAAoBlB,WACpBmB,AAAAA,IAAAA,uCAAAA,yBAAAA,AAAAA,EAA0BnB;AAChC"}
1
+ {"version":3,"file":"ai-model/service-caller/openai/responses/responses.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../../src/ai-model/service-caller/openai/responses/responses.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { getDebug } from '@midscene/shared/logger';\nimport type { ResolveImageDetail } from '../../../model-adapter/types';\nimport type { ModelRequestConfigInput } from '../../../model-adapter/types';\nimport { createProxyAgentIfNeeded } from '../../proxy';\nimport type {\n ModelCallContext,\n ModelCallMessages,\n OpenAIProtocolCallResult,\n} from '../../types';\nimport { stringifyForDebug } from '../../utils';\nimport { callResponsesNonStreaming } from './non-stream';\nimport { callResponsesStream } from './stream';\nimport type { ResponsesCallOptions } from './types';\nimport { toResponsesInput } from './utils';\n\nexport async function prepareResponses({\n messages,\n modelRuntime,\n options,\n}: Pick<ModelCallContext, 'modelRuntime' | 'options'> & {\n messages: ModelCallMessages;\n}) {\n const debugCall = getDebug('ai:call');\n const { config: modelConfig, adapter } = modelRuntime;\n const modelCallInput: ModelRequestConfigInput = {\n intent: modelConfig.intent,\n userConfig: {\n temperature: modelConfig.temperature,\n reasoningEnabled: modelConfig.reasoningEnabled,\n reasoningEffort: modelConfig.reasoningEffort,\n reasoningBudget: modelConfig.reasoningBudget,\n responseFormat: modelConfig.responseFormat,\n },\n semanticRetryAttempt: options?.semanticRetryAttempt,\n requiresOriginalImageDetail: options?.requiresOriginalImageDetail,\n expectedJsonObjectResponse: options?.expectedJsonObjectResponse,\n };\n const { config } = adapter.responses.buildResponsesParams(modelCallInput);\n debugCall(`adapter responses params: ${stringifyForDebug({ config })}`);\n const resolveImageDetail: ResolveImageDetail = ({ imageDetail }) =>\n adapter.resolveImageDetail({\n imageDetail,\n intent: modelConfig.intent,\n requiresOriginalImageDetail: options?.requiresOriginalImageDetail,\n });\n const requestParams = { ...config, ...modelConfig.extraBody };\n if (requestParams.background === true) {\n throw new Error('Responses background mode is not supported');\n }\n const requestBodyParams: ResponsesCallOptions['requestBodyParams'] = {\n store: false,\n ...requestParams,\n model: modelConfig.modelName,\n input: toResponsesInput(messages, resolveImageDetail),\n };\n const proxyAgent = await createProxyAgentIfNeeded({\n socksProxy: modelConfig.socksProxy,\n httpProxy: modelConfig.httpProxy,\n });\n return {\n requestParams: requestBodyParams,\n proxyAgent,\n };\n}\n\nexport function callResponses(\n options: ResponsesCallOptions,\n stream: boolean,\n): Promise<OpenAIProtocolCallResult> {\n return stream\n ? callResponsesStream(options)\n : callResponsesNonStreaming(options);\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","prepareResponses","messages","modelRuntime","options","debugCall","getDebug","modelConfig","adapter","modelCallInput","config","stringifyForDebug","resolveImageDetail","imageDetail","requestParams","Error","requestBodyParams","toResponsesInput","proxyAgent","createProxyAgentIfNeeded","callResponses","stream","callResponsesStream","callResponsesNonStreaming"],"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;;;;;;;;;;;;;;ACSO,eAAeI,iBAAiB,EACrCC,QAAQ,EACRC,YAAY,EACZC,OAAO,EAGR;IACC,MAAMC,YAAYC,AAAAA,IAAAA,uBAAAA,QAAAA,AAAAA,EAAS;IAC3B,MAAM,EAAE,QAAQC,WAAW,EAAEC,OAAO,EAAE,GAAGL;IACzC,MAAMM,iBAA0C;QAC9C,QAAQF,YAAY,MAAM;QAC1B,YAAY;YACV,aAAaA,YAAY,WAAW;YACpC,kBAAkBA,YAAY,gBAAgB;YAC9C,iBAAiBA,YAAY,eAAe;YAC5C,iBAAiBA,YAAY,eAAe;YAC5C,gBAAgBA,YAAY,cAAc;QAC5C;QACA,sBAAsBH,SAAS;QAC/B,6BAA6BA,SAAS;QACtC,4BAA4BA,SAAS;IACvC;IACA,MAAM,EAAEM,MAAM,EAAE,GAAGF,QAAQ,SAAS,CAAC,oBAAoB,CAACC;IAC1DJ,UAAU,CAAC,0BAA0B,EAAEM,AAAAA,IAAAA,kCAAAA,iBAAAA,AAAAA,EAAkB;QAAED;IAAO,IAAI;IACtE,MAAME,qBAAyC,CAAC,EAAEC,WAAW,EAAE,GAC7DL,QAAQ,kBAAkB,CAAC;YACzBK;YACA,QAAQN,YAAY,MAAM;YAC1B,6BAA6BH,SAAS;QACxC;IACF,MAAMU,gBAAgB;QAAE,GAAGJ,MAAM;QAAE,GAAGH,YAAY,SAAS;IAAC;IAC5D,IAAIO,AAA6B,SAA7BA,cAAc,UAAU,EAC1B,MAAM,IAAIC,MAAM;IAElB,MAAMC,oBAA+D;QACnE,OAAO;QACP,GAAGF,aAAa;QAChB,OAAOP,YAAY,SAAS;QAC5B,OAAOU,AAAAA,IAAAA,oCAAAA,gBAAAA,AAAAA,EAAiBf,UAAUU;IACpC;IACA,MAAMM,aAAa,MAAMC,AAAAA,IAAAA,yBAAAA,wBAAAA,AAAAA,EAAyB;QAChD,YAAYZ,YAAY,UAAU;QAClC,WAAWA,YAAY,SAAS;IAClC;IACA,OAAO;QACL,eAAeS;QACfE;IACF;AACF;AAEO,SAASE,cACdhB,OAA6B,EAC7BiB,MAAe;IAEf,OAAOA,SACHC,AAAAA,IAAAA,mCAAAA,mBAAAA,AAAAA,EAAoBlB,WACpBmB,AAAAA,IAAAA,uCAAAA,yBAAAA,AAAAA,EAA0BnB;AAChC"}
@@ -0,0 +1,157 @@
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
+ parseSiwcCallback: ()=>parseSiwcCallback,
28
+ exchangeSiwcCode: ()=>exchangeSiwcCode,
29
+ createSiwcAuthorization: ()=>createSiwcAuthorization
30
+ });
31
+ const external_jose_namespaceObject = require("jose");
32
+ const external_errors_js_namespaceObject = require("./errors.js");
33
+ const ISSUER = 'https://auth.openai.com';
34
+ const RESOURCE = 'https://api.openai.com/v1';
35
+ function base64url(bytes) {
36
+ return btoa(String.fromCharCode(...bytes)).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
37
+ }
38
+ async function createSiwcAuthorization(options) {
39
+ const { hostId, clientId, redirectUri, agentName } = options;
40
+ const random = ()=>base64url(crypto.getRandomValues(new Uint8Array(32)));
41
+ const attempt = {
42
+ hostId,
43
+ redirectUri,
44
+ clientId,
45
+ state: random(),
46
+ nonce: random(),
47
+ verifier: random(),
48
+ expiresAt: Date.now() + 300000
49
+ };
50
+ const challenge = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(attempt.verifier));
51
+ const url = new URL(`${ISSUER}/api/accounts/authorize`);
52
+ url.search = new URLSearchParams({
53
+ client_id: clientId ?? 'dynamic_agent_client',
54
+ ...clientId ? {} : {
55
+ agent_name_hint: agentName
56
+ },
57
+ ext_agent_host_id: hostId,
58
+ response_type: 'code',
59
+ redirect_uri: attempt.redirectUri,
60
+ scope: 'openid profile email offline_access resource.invoke chatgpt.tokens.use.direct',
61
+ resource: RESOURCE,
62
+ state: attempt.state,
63
+ nonce: attempt.nonce,
64
+ code_challenge_method: 'S256',
65
+ code_challenge: base64url(new Uint8Array(challenge))
66
+ }).toString();
67
+ return {
68
+ attempt,
69
+ url: url.toString()
70
+ };
71
+ }
72
+ function parseSiwcCallback(url, attempt) {
73
+ const callback = new URL(url);
74
+ const expected = new URL(attempt.redirectUri);
75
+ if (callback.origin !== expected.origin || callback.pathname !== expected.pathname) return;
76
+ const params = callback.searchParams;
77
+ if (1 !== params.getAll('state').length || params.get('state') !== attempt.state) return;
78
+ if (Date.now() >= attempt.expiresAt) throw new Error('Authorization timed out. Start authorization again.');
79
+ if (params.has('error')) throw new Error(`OpenAI authorization failed: ${params.get("error_description") || params.get('error')}`);
80
+ const code = params.get('code');
81
+ const clientId = params.get('client_id') || attempt.clientId;
82
+ if (!code || !clientId || 'dynamic_agent_client' === clientId || 1 !== params.getAll('code').length || params.getAll('client_id').length > 1 || attempt.clientId && clientId !== attempt.clientId) throw new Error('Invalid OpenAI authorization callback.');
83
+ return {
84
+ code,
85
+ clientId
86
+ };
87
+ }
88
+ async function exchangeSiwcCode(attempt, callback, signal, dependencies) {
89
+ signal.throwIfAborted();
90
+ const response = await (0, external_errors_js_namespaceObject.withSiwcStage)('Token exchange', async ()=>{
91
+ const response = await (dependencies?.fetch ?? fetch)(`${ISSUER}/api/accounts/oauth/token`, {
92
+ method: 'POST',
93
+ headers: {
94
+ 'Content-Type': 'application/x-www-form-urlencoded'
95
+ },
96
+ body: new URLSearchParams({
97
+ grant_type: 'authorization_code',
98
+ client_id: callback.clientId,
99
+ code: callback.code,
100
+ code_verifier: attempt.verifier,
101
+ redirect_uri: attempt.redirectUri,
102
+ resource: RESOURCE
103
+ }),
104
+ signal,
105
+ redirect: 'error'
106
+ });
107
+ if (!response.ok) throw await (0, external_errors_js_namespaceObject.tokenResponseError)(response);
108
+ return response;
109
+ });
110
+ const tokens = await (0, external_errors_js_namespaceObject.withSiwcStage)('Token response parsing', ()=>response.json());
111
+ if (!tokens || 'string' != typeof tokens.access_token || !tokens.access_token || 'string' != typeof tokens.refresh_token || !tokens.refresh_token || 'string' != typeof tokens.id_token || 'string' != typeof tokens.scope || 'number' != typeof tokens.expires_in || !Number.isFinite(tokens.expires_in) || tokens.expires_in <= 0 || 'string' != typeof tokens.token_type || 'bearer' !== tokens.token_type.toLowerCase()) throw new Error('OpenAI returned an invalid token response.');
112
+ const scopes = tokens.scope.split(/\s+/);
113
+ if (!scopes.includes('chatgpt.tokens.use.direct')) throw new Error('ChatGPT plan usage was not authorized.');
114
+ const { payload } = await (0, external_errors_js_namespaceObject.withSiwcStage)('ID token verification', ()=>(0, external_jose_namespaceObject.jwtVerify)(tokens.id_token, dependencies?.keys ?? (0, external_jose_namespaceObject.createRemoteJWKSet)(new URL(`${ISSUER}/.well-known/jwks.json`)), {
115
+ issuer: ISSUER,
116
+ audience: callback.clientId,
117
+ algorithms: [
118
+ 'RS256'
119
+ ],
120
+ clockTolerance: 1 / 0,
121
+ requiredClaims: [
122
+ 'sub',
123
+ 'exp',
124
+ 'iat',
125
+ 'nonce'
126
+ ]
127
+ }));
128
+ if (payload.nonce !== attempt.nonce || !payload.sub) throw new Error('OpenAI login identity or nonce did not match.');
129
+ signal.throwIfAborted();
130
+ return {
131
+ ...'string' == typeof payload.email ? {
132
+ email: payload.email
133
+ } : {},
134
+ ext_agent_host_id: attempt.hostId,
135
+ client_id: callback.clientId,
136
+ subject: payload.sub,
137
+ issuer: ISSUER,
138
+ access_token: tokens.access_token,
139
+ refresh_token: tokens.refresh_token,
140
+ id_token: tokens.id_token,
141
+ scopes,
142
+ expires_at: Date.now() + 1000 * tokens.expires_in
143
+ };
144
+ }
145
+ exports.createSiwcAuthorization = __webpack_exports__.createSiwcAuthorization;
146
+ exports.exchangeSiwcCode = __webpack_exports__.exchangeSiwcCode;
147
+ exports.parseSiwcCallback = __webpack_exports__.parseSiwcCallback;
148
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
149
+ "createSiwcAuthorization",
150
+ "exchangeSiwcCode",
151
+ "parseSiwcCallback"
152
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
153
+ Object.defineProperty(exports, '__esModule', {
154
+ value: true
155
+ });
156
+
157
+ //# sourceMappingURL=authorization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-model/service-caller/openai/siwc/authorization.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../../src/ai-model/service-caller/openai/siwc/authorization.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 JWTVerifyGetKey, createRemoteJWKSet, jwtVerify } from 'jose';\nimport { tokenResponseError, withSiwcStage } from './errors';\n\nconst ISSUER = 'https://auth.openai.com';\nconst RESOURCE = 'https://api.openai.com/v1';\nexport interface SiwcLoginAttempt {\n hostId: string;\n redirectUri: string;\n clientId?: string;\n state: string;\n nonce: string;\n verifier: string;\n expiresAt: number;\n}\n\nfunction base64url(bytes: Uint8Array): string {\n return btoa(String.fromCharCode(...bytes))\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=+$/, '');\n}\n\nexport async function createSiwcAuthorization(options: {\n hostId: string;\n clientId?: string;\n redirectUri: string;\n agentName: string;\n}) {\n const { hostId, clientId, redirectUri, agentName } = options;\n const random = () => base64url(crypto.getRandomValues(new Uint8Array(32)));\n const attempt: SiwcLoginAttempt = {\n hostId,\n redirectUri,\n clientId,\n state: random(),\n nonce: random(),\n verifier: random(),\n expiresAt: Date.now() + 5 * 60_000,\n };\n const challenge = await crypto.subtle.digest(\n 'SHA-256',\n new TextEncoder().encode(attempt.verifier),\n );\n const url = new URL(`${ISSUER}/api/accounts/authorize`);\n url.search = new URLSearchParams({\n client_id: clientId ?? 'dynamic_agent_client',\n ...(clientId ? {} : { agent_name_hint: agentName }),\n ext_agent_host_id: hostId,\n response_type: 'code',\n redirect_uri: attempt.redirectUri,\n scope:\n 'openid profile email offline_access resource.invoke chatgpt.tokens.use.direct',\n resource: RESOURCE,\n state: attempt.state,\n nonce: attempt.nonce,\n code_challenge_method: 'S256',\n code_challenge: base64url(new Uint8Array(challenge)),\n }).toString();\n return { attempt, url: url.toString() };\n}\n\nexport function parseSiwcCallback(url: string, attempt: SiwcLoginAttempt) {\n const callback = new URL(url);\n const expected = new URL(attempt.redirectUri);\n if (\n callback.origin !== expected.origin ||\n callback.pathname !== expected.pathname\n ) {\n return undefined;\n }\n const params = callback.searchParams;\n if (\n params.getAll('state').length !== 1 ||\n params.get('state') !== attempt.state\n ) {\n return undefined;\n }\n if (Date.now() >= attempt.expiresAt) {\n throw new Error('Authorization timed out. Start authorization again.');\n }\n if (params.has('error')) {\n throw new Error(\n `OpenAI authorization failed: ${params.get('error_description') || params.get('error')}`,\n );\n }\n const code = params.get('code');\n const clientId = params.get('client_id') || attempt.clientId;\n if (\n !code ||\n !clientId ||\n clientId === 'dynamic_agent_client' ||\n params.getAll('code').length !== 1 ||\n params.getAll('client_id').length > 1 ||\n (attempt.clientId && clientId !== attempt.clientId)\n ) {\n throw new Error('Invalid OpenAI authorization callback.');\n }\n return { code, clientId };\n}\n\nexport async function exchangeSiwcCode(\n attempt: SiwcLoginAttempt,\n callback: { code: string; clientId: string },\n signal: AbortSignal,\n dependencies?: { fetch: typeof fetch; keys: JWTVerifyGetKey },\n) {\n signal.throwIfAborted();\n const response = await withSiwcStage('Token exchange', async () => {\n const response = await (dependencies?.fetch ?? fetch)(\n `${ISSUER}/api/accounts/oauth/token`,\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n body: new URLSearchParams({\n grant_type: 'authorization_code',\n client_id: callback.clientId,\n code: callback.code,\n code_verifier: attempt.verifier,\n redirect_uri: attempt.redirectUri,\n resource: RESOURCE,\n }),\n signal,\n redirect: 'error',\n },\n );\n if (!response.ok) {\n throw await tokenResponseError(response);\n }\n return response;\n });\n const tokens = await withSiwcStage('Token response parsing', () =>\n response.json(),\n );\n if (\n !tokens ||\n typeof tokens.access_token !== 'string' ||\n !tokens.access_token ||\n typeof tokens.refresh_token !== 'string' ||\n !tokens.refresh_token ||\n typeof tokens.id_token !== 'string' ||\n typeof tokens.scope !== 'string' ||\n typeof tokens.expires_in !== 'number' ||\n !Number.isFinite(tokens.expires_in) ||\n tokens.expires_in <= 0 ||\n typeof tokens.token_type !== 'string' ||\n tokens.token_type.toLowerCase() !== 'bearer'\n ) {\n throw new Error('OpenAI returned an invalid token response.');\n }\n const scopes = tokens.scope.split(/\\s+/);\n if (!scopes.includes('chatgpt.tokens.use.direct')) {\n throw new Error('ChatGPT plan usage was not authorized.');\n }\n const { payload } = await withSiwcStage('ID token verification', () =>\n jwtVerify(\n tokens.id_token,\n dependencies?.keys ??\n createRemoteJWKSet(new URL(`${ISSUER}/.well-known/jwks.json`)),\n {\n issuer: ISSUER,\n audience: callback.clientId,\n algorithms: ['RS256'],\n // Some CI machines have incorrect system clocks. Do not compare ID token\n // exp/nbf claims against local time when accepting newly returned tokens.\n // Keep signature, issuer, audience and required-claim validation.\n clockTolerance: Number.POSITIVE_INFINITY,\n requiredClaims: ['sub', 'exp', 'iat', 'nonce'],\n },\n ),\n );\n if (payload.nonce !== attempt.nonce || !payload.sub) {\n throw new Error('OpenAI login identity or nonce did not match.');\n }\n signal.throwIfAborted();\n return {\n ...(typeof payload.email === 'string' ? { email: payload.email } : {}),\n ext_agent_host_id: attempt.hostId,\n client_id: callback.clientId,\n subject: payload.sub,\n issuer: ISSUER,\n access_token: tokens.access_token as string,\n refresh_token: tokens.refresh_token as string,\n id_token: tokens.id_token as string,\n scopes,\n expires_at: Date.now() + tokens.expires_in * 1000,\n };\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","ISSUER","RESOURCE","base64url","bytes","btoa","String","createSiwcAuthorization","options","hostId","clientId","redirectUri","agentName","random","crypto","Uint8Array","attempt","Date","challenge","TextEncoder","url","URL","URLSearchParams","parseSiwcCallback","callback","expected","params","Error","code","exchangeSiwcCode","signal","dependencies","response","withSiwcStage","fetch","tokenResponseError","tokens","Number","scopes","payload","jwtVerify","createRemoteJWKSet"],"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;;;;;;;;;;;ACHA,MAAMI,SAAS;AACf,MAAMC,WAAW;AAWjB,SAASC,UAAUC,KAAiB;IAClC,OAAOC,KAAKC,OAAO,YAAY,IAAIF,QAChC,OAAO,CAAC,OAAO,KACf,OAAO,CAAC,OAAO,KACf,OAAO,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AC,IAAI,CAAC,CAAC;QACrE,mBAAmBvB,QAAQ,MAAM;QACjC,WAAWQ,SAAS,QAAQ;QAC5B,SAASe,QAAQ,GAAG;QACpB,QAAQtC;QACR,cAAcmC,OAAO,YAAY;QACjC,eAAeA,OAAO,aAAa;QACnC,UAAUA,OAAO,QAAQ;QACzBE;QACA,YAAYrB,KAAK,GAAG,KAAKmB,AAAoB,OAApBA,OAAO,UAAU;IAC5C;AACF"}
@@ -0,0 +1,103 @@
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
+ SIWC_AUTH_STORAGE_KEY: ()=>SIWC_AUTH_STORAGE_KEY,
28
+ getCredentialStorage: ()=>getCredentialStorage
29
+ });
30
+ const utils_namespaceObject = require("@midscene/shared/utils");
31
+ const SIWC_AUTH_STORAGE_KEY = 'midscene-siwc-auth';
32
+ async function getCredentialStorage() {
33
+ const chrome = globalThis.chrome;
34
+ if (chrome?.runtime?.id && chrome.storage?.local) {
35
+ const storage = chrome.storage.local;
36
+ const reauthorizationHint = 'Open Model Env Config and select "Use your ChatGPT plan" to sign in again. See https://midscenejs.com/chatgpt-subscription.html';
37
+ return {
38
+ read: async ()=>{
39
+ const saved = await storage.get(SIWC_AUTH_STORAGE_KEY);
40
+ const record = saved[SIWC_AUTH_STORAGE_KEY];
41
+ if ('string' != typeof record?.credentials?.access_token || !record.credentials.access_token.trim()) throw new Error(`SIWC credentials not found in this extension. ${reauthorizationHint}`);
42
+ return record;
43
+ },
44
+ save: (updated)=>storage.set({
45
+ [SIWC_AUTH_STORAGE_KEY]: updated
46
+ }),
47
+ reauthorizationHint
48
+ };
49
+ }
50
+ if (utils_namespaceObject.ifInBrowser) throw new Error('SIWC auth mode requires Node.js or the Midscene Chrome extension.');
51
+ const fsModule = 'node:fs/promises';
52
+ const osModule = 'node:os';
53
+ const pathModule = 'node:path';
54
+ const { readFile, writeFile, rename, rm } = await import(fsModule);
55
+ const { homedir } = await import(osModule);
56
+ const { join } = await import(pathModule);
57
+ const credentialsPath = join(homedir(), '.midscene', 'siwc.json');
58
+ const reauthorizationHint = 'Run "midscene model siwc login" to sign in again. See https://midscenejs.com/chatgpt-subscription.html';
59
+ return {
60
+ read: async ()=>{
61
+ const content = await readFile(credentialsPath, 'utf8').catch((cause)=>{
62
+ throw new Error('ENOENT' === cause.code ? `SIWC credentials not found at ${credentialsPath}. ${reauthorizationHint}` : `Unable to read SIWC credentials at ${credentialsPath}.`, {
63
+ cause
64
+ });
65
+ });
66
+ const record = (()=>{
67
+ try {
68
+ return JSON.parse(content);
69
+ } catch {
70
+ throw new Error(`Invalid JSON in SIWC credentials at ${credentialsPath}.`);
71
+ }
72
+ })();
73
+ if ('string' != typeof record?.credentials?.access_token || !record.credentials.access_token.trim()) throw new Error(`Missing access token in ${credentialsPath}. ${reauthorizationHint}`);
74
+ return record;
75
+ },
76
+ save: async (updated)=>{
77
+ const temporary = `${credentialsPath}.${globalThis.crypto.randomUUID()}.tmp`;
78
+ try {
79
+ await writeFile(temporary, `${JSON.stringify(updated, null, 2)}\n`, {
80
+ mode: 384,
81
+ flag: 'wx'
82
+ });
83
+ await rename(temporary, credentialsPath);
84
+ } finally{
85
+ await rm(temporary, {
86
+ force: true
87
+ });
88
+ }
89
+ },
90
+ reauthorizationHint
91
+ };
92
+ }
93
+ exports.SIWC_AUTH_STORAGE_KEY = __webpack_exports__.SIWC_AUTH_STORAGE_KEY;
94
+ exports.getCredentialStorage = __webpack_exports__.getCredentialStorage;
95
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
96
+ "SIWC_AUTH_STORAGE_KEY",
97
+ "getCredentialStorage"
98
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
99
+ Object.defineProperty(exports, '__esModule', {
100
+ value: true
101
+ });
102
+
103
+ //# sourceMappingURL=credential-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-model/service-caller/openai/siwc/credential-storage.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../../src/ai-model/service-caller/openai/siwc/credential-storage.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 { ifInBrowser } from '@midscene/shared/utils';\n\nexport const SIWC_AUTH_STORAGE_KEY = 'midscene-siwc-auth';\n\ninterface SiwcAuth {\n created_at?: string;\n updated_at?: string;\n credentials: {\n access_token: string;\n expires_at: number;\n subject?: string;\n id_token?: string;\n client_id?: string;\n refresh_token?: string;\n [key: string]: unknown;\n };\n}\n\n// Keep Chrome types optional: Core also runs in Node.js and ordinary web pages.\ntype ChromeExtensionRuntime = {\n runtime?: { id?: string };\n storage?: {\n local?: {\n get(key: string): Promise<Record<string, SiwcAuth | undefined>>;\n set(value: Record<string, SiwcAuth>): Promise<void>;\n };\n };\n};\n\nexport async function getCredentialStorage(): Promise<{\n read: () => Promise<SiwcAuth>;\n save: (record: SiwcAuth) => Promise<void>;\n reauthorizationHint: string;\n}> {\n const chrome = (\n globalThis as typeof globalThis & { chrome?: ChromeExtensionRuntime }\n ).chrome;\n if (chrome?.runtime?.id && chrome.storage?.local) {\n const storage = chrome.storage.local;\n const reauthorizationHint =\n 'Open Model Env Config and select \"Use your ChatGPT plan\" to sign in again. See https://midscenejs.com/chatgpt-subscription.html';\n return {\n read: async () => {\n const saved = await storage.get(SIWC_AUTH_STORAGE_KEY);\n const record = saved[SIWC_AUTH_STORAGE_KEY];\n if (\n typeof record?.credentials?.access_token !== 'string' ||\n !record.credentials.access_token.trim()\n ) {\n throw new Error(\n `SIWC credentials not found in this extension. ${reauthorizationHint}`,\n );\n }\n return record;\n },\n save: (updated) => storage.set({ [SIWC_AUTH_STORAGE_KEY]: updated }),\n reauthorizationHint,\n };\n }\n if (ifInBrowser) {\n throw new Error(\n 'SIWC auth mode requires Node.js or the Midscene Chrome extension.',\n );\n }\n // Keep Node-only dependencies out of browser bundles.\n const fsModule = 'node:fs/promises';\n const osModule = 'node:os';\n const pathModule = 'node:path';\n const { readFile, writeFile, rename, rm } = await import(fsModule);\n const { homedir } = await import(osModule);\n const { join } = await import(pathModule);\n const credentialsPath = join(homedir(), '.midscene', 'siwc.json');\n const reauthorizationHint =\n 'Run \"midscene model siwc login\" to sign in again. See https://midscenejs.com/chatgpt-subscription.html';\n return {\n read: async () => {\n const content = await readFile(credentialsPath, 'utf8').catch(\n (cause: NodeJS.ErrnoException) => {\n throw new Error(\n cause.code === 'ENOENT'\n ? `SIWC credentials not found at ${credentialsPath}. ${reauthorizationHint}`\n : `Unable to read SIWC credentials at ${credentialsPath}.`,\n { cause },\n );\n },\n );\n const record = (() => {\n try {\n return JSON.parse(content) as SiwcAuth;\n } catch {\n throw new Error(\n `Invalid JSON in SIWC credentials at ${credentialsPath}.`,\n );\n }\n })();\n if (\n typeof record?.credentials?.access_token !== 'string' ||\n !record.credentials.access_token.trim()\n ) {\n throw new Error(\n `Missing access token in ${credentialsPath}. ${reauthorizationHint}`,\n );\n }\n return record;\n },\n save: async (updated) => {\n // Replace atomically so another reader never sees a partially written JSON file.\n const temporary = `${credentialsPath}.${globalThis.crypto.randomUUID()}.tmp`;\n try {\n await writeFile(temporary, `${JSON.stringify(updated, null, 2)}\\n`, {\n mode: 0o600,\n flag: 'wx',\n });\n await rename(temporary, credentialsPath);\n } finally {\n await rm(temporary, { force: true });\n }\n },\n reauthorizationHint,\n };\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","SIWC_AUTH_STORAGE_KEY","getCredentialStorage","chrome","globalThis","storage","reauthorizationHint","saved","record","Error","updated","ifInBrowser","fsModule","osModule","pathModule","readFile","writeFile","rename","rm","homedir","join","credentialsPath","content","cause","JSON","temporary"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;ACJO,MAAMI,wBAAwB;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BACf,IAAI;oBACF,OAAOgB,KAAK,KAAK,CAACF;gBACpB,EAAE,OAAM;oBACN,MAAM,IAAIb,MACR,CAAC,oCAAoC,EAAEY,gBAAgB,CAAC,CAAC;gBAE7D;YACF;YACA,IACE,AAA6C,YAA7C,OAAOb,QAAQ,aAAa,gBAC5B,CAACA,OAAO,WAAW,CAAC,YAAY,CAAC,IAAI,IAErC,MAAM,IAAIC,MACR,CAAC,wBAAwB,EAAEY,gBAAgB,EAAE,EAAEf,qBAAqB;YAGxE,OAAOE;QACT;QACA,MAAM,OAAOE;YAEX,MAAMe,YAAY,GAAGJ,gBAAgB,CAAC,EAAEjB,WAAW,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC;YAC5E,IAAI;gBACF,MAAMY,UAAUS,WAAW,GAAGD,KAAK,SAAS,CAACd,SAAS,MAAM,GAAG,EAAE,CAAC,EAAE;oBAClE,MAAM;oBACN,MAAM;gBACR;gBACA,MAAMO,OAAOQ,WAAWJ;YAC1B,SAAU;gBACR,MAAMH,GAAGO,WAAW;oBAAE,OAAO;gBAAK;YACpC;QACF;QACAnB;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
+ SiwcError: ()=>SiwcError,
28
+ SiwcTokenExpiredError: ()=>SiwcTokenExpiredError,
29
+ tokenResponseError: ()=>tokenResponseError,
30
+ withSiwcStage: ()=>withSiwcStage
31
+ });
32
+ function _define_property(obj, key, value) {
33
+ if (key in obj) Object.defineProperty(obj, key, {
34
+ value: value,
35
+ enumerable: true,
36
+ configurable: true,
37
+ writable: true
38
+ });
39
+ else obj[key] = value;
40
+ return obj;
41
+ }
42
+ class SiwcTokenExpiredError extends Error {
43
+ constructor(...args){
44
+ super(...args), _define_property(this, "name", 'SiwcTokenExpiredError');
45
+ }
46
+ }
47
+ class SiwcError extends Error {
48
+ constructor(...args){
49
+ super(...args), _define_property(this, "name", 'SiwcError');
50
+ }
51
+ }
52
+ async function withSiwcStage(stage, action) {
53
+ try {
54
+ return await action();
55
+ } catch (error) {
56
+ throw new SiwcError(`Stage: ${stage}\n${error instanceof Error ? error.message : String(error)}`, {
57
+ cause: error
58
+ });
59
+ }
60
+ }
61
+ async function tokenResponseError(response) {
62
+ try {
63
+ const body = await response.text();
64
+ return new SiwcError(`HTTP status: ${response.status}\nResponse body: ${body}`);
65
+ } catch (error) {
66
+ return new SiwcError(`HTTP status: ${response.status}\nUnable to read response body.`, {
67
+ cause: error
68
+ });
69
+ }
70
+ }
71
+ exports.SiwcError = __webpack_exports__.SiwcError;
72
+ exports.SiwcTokenExpiredError = __webpack_exports__.SiwcTokenExpiredError;
73
+ exports.tokenResponseError = __webpack_exports__.tokenResponseError;
74
+ exports.withSiwcStage = __webpack_exports__.withSiwcStage;
75
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
76
+ "SiwcError",
77
+ "SiwcTokenExpiredError",
78
+ "tokenResponseError",
79
+ "withSiwcStage"
80
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
81
+ Object.defineProperty(exports, '__esModule', {
82
+ value: true
83
+ });
84
+
85
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-model/service-caller/openai/siwc/errors.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../../src/ai-model/service-caller/openai/siwc/errors.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};","/** Signals an expired SIWC token that may be refreshed before replaying output. */\nexport class SiwcTokenExpiredError extends Error {\n override name = 'SiwcTokenExpiredError';\n}\n\nexport class SiwcError extends Error {\n override name = 'SiwcError';\n}\n\nexport async function withSiwcStage<T>(\n stage: string,\n action: () => Promise<T>,\n): Promise<T> {\n try {\n return await action();\n } catch (error) {\n // Browser callers often display only message; keep the cause readable there too.\n throw new SiwcError(\n `Stage: ${stage}\\n${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n}\n\nexport async function tokenResponseError(\n response: Response,\n): Promise<SiwcError> {\n try {\n const body = await response.text();\n return new SiwcError(\n `HTTP status: ${response.status}\\nResponse body: ${body}`,\n );\n } catch (error) {\n return new SiwcError(\n `HTTP status: ${response.status}\\nUnable to read response body.`,\n { cause: error },\n );\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","SiwcTokenExpiredError","Error","SiwcError","withSiwcStage","stage","action","error","String","tokenResponseError","response","body"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAo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>{
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
+ refreshSiwcCredentials: ()=>external_refresh_js_namespaceObject.refreshSiwcCredentials,
28
+ prepareSiwcCall: ()=>external_prepare_call_js_namespaceObject.prepareSiwcCall,
29
+ siwcTokenManager: ()=>external_token_manager_js_namespaceObject.siwcTokenManager,
30
+ SiwcTokenExpiredError: ()=>external_errors_js_namespaceObject.SiwcTokenExpiredError,
31
+ parseSiwcCallback: ()=>external_authorization_js_namespaceObject.parseSiwcCallback,
32
+ SIWC_AUTH_STORAGE_KEY: ()=>external_credential_storage_js_namespaceObject.SIWC_AUTH_STORAGE_KEY,
33
+ exchangeSiwcCode: ()=>external_authorization_js_namespaceObject.exchangeSiwcCode,
34
+ createSiwcAuthorization: ()=>external_authorization_js_namespaceObject.createSiwcAuthorization
35
+ });
36
+ const external_errors_js_namespaceObject = require("./errors.js");
37
+ const external_prepare_call_js_namespaceObject = require("./prepare-call.js");
38
+ const external_credential_storage_js_namespaceObject = require("./credential-storage.js");
39
+ const external_token_manager_js_namespaceObject = require("./token-manager.js");
40
+ const external_refresh_js_namespaceObject = require("./refresh.js");
41
+ const external_authorization_js_namespaceObject = require("./authorization.js");
42
+ exports.SIWC_AUTH_STORAGE_KEY = __webpack_exports__.SIWC_AUTH_STORAGE_KEY;
43
+ exports.SiwcTokenExpiredError = __webpack_exports__.SiwcTokenExpiredError;
44
+ exports.createSiwcAuthorization = __webpack_exports__.createSiwcAuthorization;
45
+ exports.exchangeSiwcCode = __webpack_exports__.exchangeSiwcCode;
46
+ exports.parseSiwcCallback = __webpack_exports__.parseSiwcCallback;
47
+ exports.prepareSiwcCall = __webpack_exports__.prepareSiwcCall;
48
+ exports.refreshSiwcCredentials = __webpack_exports__.refreshSiwcCredentials;
49
+ exports.siwcTokenManager = __webpack_exports__.siwcTokenManager;
50
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
51
+ "SIWC_AUTH_STORAGE_KEY",
52
+ "SiwcTokenExpiredError",
53
+ "createSiwcAuthorization",
54
+ "exchangeSiwcCode",
55
+ "parseSiwcCallback",
56
+ "prepareSiwcCall",
57
+ "refreshSiwcCredentials",
58
+ "siwcTokenManager"
59
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
60
+ Object.defineProperty(exports, '__esModule', {
61
+ value: true
62
+ });
63
+
64
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-model/service-caller/openai/siwc/index.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object"],"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};"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol"],"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"}