@midscene/core 1.13.4-beta-20260928072823.0 → 1.14.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.
- package/dist/es/agent/task-builder.mjs +1 -1
- package/dist/es/agent/task-builder.mjs.map +1 -1
- package/dist/es/agent/tasks.mjs +4 -4
- package/dist/es/agent/tasks.mjs.map +1 -1
- package/dist/es/agent/utils.mjs +1 -1
- package/dist/es/ai-model/connectivity/run-connectivity-test.mjs +2 -5
- package/dist/es/ai-model/connectivity/run-connectivity-test.mjs.map +1 -1
- package/dist/es/ai-model/model-adapter/chat-completion.mjs +8 -11
- package/dist/es/ai-model/model-adapter/chat-completion.mjs.map +1 -1
- package/dist/es/ai-model/model-adapter/default-locate-protocol.mjs +7 -8
- package/dist/es/ai-model/model-adapter/default-locate-protocol.mjs.map +1 -1
- package/dist/es/ai-model/model-adapter/locate.mjs +3 -7
- package/dist/es/ai-model/model-adapter/locate.mjs.map +1 -1
- package/dist/es/ai-model/model-adapter/resolve.mjs +11 -3
- package/dist/es/ai-model/model-adapter/resolve.mjs.map +1 -1
- package/dist/es/ai-model/model-adapter/responses.mjs +38 -0
- package/dist/es/ai-model/model-adapter/responses.mjs.map +1 -0
- package/dist/es/ai-model/model-adapter/temperature-with-semantic-retry.mjs +7 -0
- package/dist/es/ai-model/model-adapter/temperature-with-semantic-retry.mjs.map +1 -0
- package/dist/es/ai-model/models/gpt.mjs +73 -9
- package/dist/es/ai-model/models/gpt.mjs.map +1 -1
- package/dist/es/ai-model/models/qwen.mjs +8 -2
- package/dist/es/ai-model/models/qwen.mjs.map +1 -1
- package/dist/es/ai-model/models/registry.mjs +2 -2
- package/dist/es/ai-model/models/registry.mjs.map +1 -1
- package/dist/es/ai-model/service-caller/call-ai.mjs +22 -13
- package/dist/es/ai-model/service-caller/call-ai.mjs.map +1 -1
- package/dist/es/ai-model/service-caller/codex/call-codex.mjs +10 -8
- package/dist/es/ai-model/service-caller/codex/call-codex.mjs.map +1 -1
- package/dist/es/ai-model/service-caller/codex/codex-app-server.mjs +29 -28
- package/dist/es/ai-model/service-caller/codex/codex-app-server.mjs.map +1 -1
- package/dist/es/ai-model/service-caller/index.mjs +1 -2
- package/dist/es/ai-model/service-caller/model-call.mjs +4 -4
- package/dist/es/ai-model/service-caller/model-call.mjs.map +1 -1
- package/dist/es/ai-model/service-caller/openai/call-openai.mjs +18 -8
- package/dist/es/ai-model/service-caller/openai/call-openai.mjs.map +1 -1
- package/dist/es/ai-model/service-caller/openai/chat-completion/chat-completion.mjs +11 -7
- package/dist/es/ai-model/service-caller/openai/chat-completion/chat-completion.mjs.map +1 -1
- package/dist/es/ai-model/service-caller/openai/chat-completion/non-stream.mjs +9 -9
- package/dist/es/ai-model/service-caller/openai/chat-completion/non-stream.mjs.map +1 -1
- package/dist/es/ai-model/service-caller/openai/chat-completion/stream.mjs +4 -8
- package/dist/es/ai-model/service-caller/openai/chat-completion/stream.mjs.map +1 -1
- package/dist/es/ai-model/service-caller/openai/chat-completion/utils.mjs +28 -1
- package/dist/es/ai-model/service-caller/openai/chat-completion/utils.mjs.map +1 -1
- package/dist/es/ai-model/service-caller/openai/openai-client.mjs +3 -3
- package/dist/es/ai-model/service-caller/openai/openai-client.mjs.map +1 -1
- package/dist/es/ai-model/service-caller/openai/responses/non-stream.mjs +21 -0
- package/dist/es/ai-model/service-caller/openai/responses/non-stream.mjs.map +1 -0
- package/dist/es/ai-model/service-caller/openai/responses/responses.mjs +57 -0
- package/dist/es/ai-model/service-caller/openai/responses/responses.mjs.map +1 -0
- package/dist/es/ai-model/service-caller/openai/responses/stream.mjs +56 -0
- package/dist/es/ai-model/service-caller/openai/responses/stream.mjs.map +1 -0
- package/dist/es/ai-model/service-caller/openai/responses/types.mjs +0 -0
- package/dist/es/ai-model/service-caller/openai/responses/utils.mjs +72 -0
- package/dist/es/ai-model/service-caller/openai/responses/utils.mjs.map +1 -0
- package/dist/es/ai-model/service-caller/semantic-retry.mjs.map +1 -1
- package/dist/es/ai-model/service-caller/utils.mjs +6 -25
- package/dist/es/ai-model/service-caller/utils.mjs.map +1 -1
- package/dist/es/ai-model/shared/model-locate-result/factory.mjs +4 -1
- package/dist/es/ai-model/shared/model-locate-result/factory.mjs.map +1 -1
- package/dist/es/ai-model/shared/model-locate-result/prompt-spec.mjs +3 -2
- package/dist/es/ai-model/shared/model-locate-result/prompt-spec.mjs.map +1 -1
- package/dist/es/ai-model/shared/model-locate-result/result-field.mjs +13 -0
- package/dist/es/ai-model/shared/model-locate-result/result-field.mjs.map +1 -0
- package/dist/es/ai-model/shared/model-locate-result/types.mjs.map +1 -1
- package/dist/es/ai-model/shared/multimodal-prompt.mjs +5 -8
- package/dist/es/ai-model/shared/multimodal-prompt.mjs.map +1 -1
- package/dist/es/ai-model/workflows/grounding/locate.mjs +6 -6
- package/dist/es/ai-model/workflows/grounding/locate.mjs.map +1 -1
- package/dist/es/ai-model/workflows/grounding/planning-action-locate.mjs +5 -5
- package/dist/es/ai-model/workflows/grounding/planning-action-locate.mjs.map +1 -1
- package/dist/es/ai-model/workflows/grounding/section-locate.mjs +5 -5
- package/dist/es/ai-model/workflows/grounding/section-locate.mjs.map +1 -1
- package/dist/es/ai-model/workflows/grounding/utils.mjs +4 -7
- package/dist/es/ai-model/workflows/grounding/utils.mjs.map +1 -1
- package/dist/es/ai-model/workflows/insight/extraction.mjs +9 -15
- package/dist/es/ai-model/workflows/insight/extraction.mjs.map +1 -1
- package/dist/es/ai-model/workflows/insight/order-sensitive.mjs.map +1 -1
- package/dist/es/ai-model/workflows/planning/conversation-history.mjs +17 -9
- package/dist/es/ai-model/workflows/planning/conversation-history.mjs.map +1 -1
- package/dist/es/ai-model/workflows/planning/custom-planning.mjs +12 -14
- package/dist/es/ai-model/workflows/planning/custom-planning.mjs.map +1 -1
- package/dist/es/ai-model/workflows/planning/locate-normalization.mjs +5 -9
- package/dist/es/ai-model/workflows/planning/locate-normalization.mjs.map +1 -1
- package/dist/es/ai-model/workflows/planning/standard-planning.mjs +25 -28
- package/dist/es/ai-model/workflows/planning/standard-planning.mjs.map +1 -1
- package/dist/es/ai-model/workflows/recorder-generation/common.mjs +2 -4
- package/dist/es/ai-model/workflows/recorder-generation/common.mjs.map +1 -1
- package/dist/es/ai-model/workflows/recorder-generation/markdown.mjs +3 -5
- package/dist/es/ai-model/workflows/recorder-generation/markdown.mjs.map +1 -1
- package/dist/es/ai-model/workflows/recorder-generation/metadata.mjs +2 -4
- package/dist/es/ai-model/workflows/recorder-generation/metadata.mjs.map +1 -1
- package/dist/es/ai-model/workflows/recorder-generation/playwright.mjs.map +1 -1
- package/dist/es/ai-model/workflows/recorder-generation/yaml.mjs +2 -4
- package/dist/es/ai-model/workflows/recorder-generation/yaml.mjs.map +1 -1
- package/dist/es/report-html-template.mjs +1 -1
- package/dist/es/service/index.mjs +17 -26
- package/dist/es/service/index.mjs.map +1 -1
- package/dist/es/types.mjs.map +1 -1
- package/dist/es/utils.mjs +1 -1
- package/dist/lib/agent/task-builder.js +1 -1
- package/dist/lib/agent/task-builder.js.map +1 -1
- package/dist/lib/agent/tasks.js +4 -4
- package/dist/lib/agent/tasks.js.map +1 -1
- package/dist/lib/agent/utils.js +1 -1
- package/dist/lib/ai-model/connectivity/run-connectivity-test.js +2 -5
- package/dist/lib/ai-model/connectivity/run-connectivity-test.js.map +1 -1
- package/dist/lib/ai-model/model-adapter/chat-completion.js +8 -11
- package/dist/lib/ai-model/model-adapter/chat-completion.js.map +1 -1
- package/dist/lib/ai-model/model-adapter/default-locate-protocol.js +7 -8
- package/dist/lib/ai-model/model-adapter/default-locate-protocol.js.map +1 -1
- package/dist/lib/ai-model/model-adapter/locate.js +3 -7
- package/dist/lib/ai-model/model-adapter/locate.js.map +1 -1
- package/dist/lib/ai-model/model-adapter/resolve.js +11 -3
- package/dist/lib/ai-model/model-adapter/resolve.js.map +1 -1
- package/dist/lib/ai-model/model-adapter/responses.js +75 -0
- package/dist/lib/ai-model/model-adapter/responses.js.map +1 -0
- package/dist/lib/ai-model/model-adapter/temperature-with-semantic-retry.js +41 -0
- package/dist/lib/ai-model/model-adapter/temperature-with-semantic-retry.js.map +1 -0
- package/dist/lib/ai-model/models/gpt.js +73 -9
- package/dist/lib/ai-model/models/gpt.js.map +1 -1
- package/dist/lib/ai-model/models/qwen.js +8 -2
- package/dist/lib/ai-model/models/qwen.js.map +1 -1
- package/dist/lib/ai-model/models/registry.js +2 -2
- package/dist/lib/ai-model/models/registry.js.map +1 -1
- package/dist/lib/ai-model/service-caller/call-ai.js +22 -13
- package/dist/lib/ai-model/service-caller/call-ai.js.map +1 -1
- package/dist/lib/ai-model/service-caller/codex/call-codex.js +10 -8
- package/dist/lib/ai-model/service-caller/codex/call-codex.js.map +1 -1
- package/dist/lib/ai-model/service-caller/codex/codex-app-server.js +29 -28
- package/dist/lib/ai-model/service-caller/codex/codex-app-server.js.map +1 -1
- package/dist/lib/ai-model/service-caller/index.js +0 -4
- package/dist/lib/ai-model/service-caller/model-call.js +4 -4
- package/dist/lib/ai-model/service-caller/model-call.js.map +1 -1
- package/dist/lib/ai-model/service-caller/openai/call-openai.js +17 -7
- package/dist/lib/ai-model/service-caller/openai/call-openai.js.map +1 -1
- package/dist/lib/ai-model/service-caller/openai/chat-completion/chat-completion.js +10 -6
- package/dist/lib/ai-model/service-caller/openai/chat-completion/chat-completion.js.map +1 -1
- package/dist/lib/ai-model/service-caller/openai/chat-completion/non-stream.js +9 -9
- package/dist/lib/ai-model/service-caller/openai/chat-completion/non-stream.js.map +1 -1
- package/dist/lib/ai-model/service-caller/openai/chat-completion/stream.js +4 -8
- package/dist/lib/ai-model/service-caller/openai/chat-completion/stream.js.map +1 -1
- package/dist/lib/ai-model/service-caller/openai/chat-completion/utils.js +32 -2
- package/dist/lib/ai-model/service-caller/openai/chat-completion/utils.js.map +1 -1
- package/dist/lib/ai-model/service-caller/openai/openai-client.js +5 -5
- package/dist/lib/ai-model/service-caller/openai/openai-client.js.map +1 -1
- package/dist/lib/ai-model/service-caller/openai/responses/non-stream.js +55 -0
- package/dist/lib/ai-model/service-caller/openai/responses/non-stream.js.map +1 -0
- package/dist/lib/ai-model/service-caller/openai/responses/responses.js +94 -0
- package/dist/lib/ai-model/service-caller/openai/responses/responses.js.map +1 -0
- package/dist/lib/ai-model/service-caller/openai/responses/stream.js +90 -0
- package/dist/lib/ai-model/service-caller/openai/responses/stream.js.map +1 -0
- package/dist/lib/ai-model/service-caller/openai/responses/types.js +20 -0
- package/dist/lib/ai-model/service-caller/openai/responses/types.js.map +1 -0
- package/dist/lib/ai-model/service-caller/openai/responses/utils.js +112 -0
- package/dist/lib/ai-model/service-caller/openai/responses/utils.js.map +1 -0
- package/dist/lib/ai-model/service-caller/semantic-retry.js.map +1 -1
- package/dist/lib/ai-model/service-caller/utils.js +5 -27
- package/dist/lib/ai-model/service-caller/utils.js.map +1 -1
- package/dist/lib/ai-model/shared/model-locate-result/factory.js +4 -1
- package/dist/lib/ai-model/shared/model-locate-result/factory.js.map +1 -1
- package/dist/lib/ai-model/shared/model-locate-result/prompt-spec.js +3 -2
- package/dist/lib/ai-model/shared/model-locate-result/prompt-spec.js.map +1 -1
- package/dist/lib/ai-model/shared/model-locate-result/result-field.js +50 -0
- package/dist/lib/ai-model/shared/model-locate-result/result-field.js.map +1 -0
- package/dist/lib/ai-model/shared/model-locate-result/types.js.map +1 -1
- package/dist/lib/ai-model/shared/multimodal-prompt.js +11 -14
- package/dist/lib/ai-model/shared/multimodal-prompt.js.map +1 -1
- package/dist/lib/ai-model/workflows/grounding/locate.js +6 -6
- package/dist/lib/ai-model/workflows/grounding/locate.js.map +1 -1
- package/dist/lib/ai-model/workflows/grounding/planning-action-locate.js +5 -5
- package/dist/lib/ai-model/workflows/grounding/planning-action-locate.js.map +1 -1
- package/dist/lib/ai-model/workflows/grounding/section-locate.js +5 -5
- package/dist/lib/ai-model/workflows/grounding/section-locate.js.map +1 -1
- package/dist/lib/ai-model/workflows/grounding/utils.js +3 -6
- package/dist/lib/ai-model/workflows/grounding/utils.js.map +1 -1
- package/dist/lib/ai-model/workflows/insight/extraction.js +8 -14
- package/dist/lib/ai-model/workflows/insight/extraction.js.map +1 -1
- package/dist/lib/ai-model/workflows/insight/order-sensitive.js.map +1 -1
- package/dist/lib/ai-model/workflows/planning/conversation-history.js +17 -9
- package/dist/lib/ai-model/workflows/planning/conversation-history.js.map +1 -1
- package/dist/lib/ai-model/workflows/planning/custom-planning.js +11 -13
- package/dist/lib/ai-model/workflows/planning/custom-planning.js.map +1 -1
- package/dist/lib/ai-model/workflows/planning/locate-normalization.js +5 -9
- package/dist/lib/ai-model/workflows/planning/locate-normalization.js.map +1 -1
- package/dist/lib/ai-model/workflows/planning/standard-planning.js +24 -27
- package/dist/lib/ai-model/workflows/planning/standard-planning.js.map +1 -1
- package/dist/lib/ai-model/workflows/recorder-generation/common.js +2 -4
- package/dist/lib/ai-model/workflows/recorder-generation/common.js.map +1 -1
- package/dist/lib/ai-model/workflows/recorder-generation/markdown.js +3 -5
- package/dist/lib/ai-model/workflows/recorder-generation/markdown.js.map +1 -1
- package/dist/lib/ai-model/workflows/recorder-generation/metadata.js +2 -4
- package/dist/lib/ai-model/workflows/recorder-generation/metadata.js.map +1 -1
- package/dist/lib/ai-model/workflows/recorder-generation/playwright.js.map +1 -1
- package/dist/lib/ai-model/workflows/recorder-generation/yaml.js +2 -4
- package/dist/lib/ai-model/workflows/recorder-generation/yaml.js.map +1 -1
- package/dist/lib/report-html-template.js +1 -1
- package/dist/lib/service/index.js +17 -26
- package/dist/lib/service/index.js.map +1 -1
- package/dist/lib/types.js.map +1 -1
- package/dist/lib/utils.js +1 -1
- package/dist/types/ai-model/connectivity/run-connectivity-test.d.ts.map +1 -1
- package/dist/types/ai-model/index.d.ts +1 -1
- package/dist/types/ai-model/index.d.ts.map +1 -1
- package/dist/types/ai-model/model-adapter/chat-completion.d.ts.map +1 -1
- package/dist/types/ai-model/model-adapter/default-locate-protocol.d.ts +2 -6
- package/dist/types/ai-model/model-adapter/default-locate-protocol.d.ts.map +1 -1
- package/dist/types/ai-model/model-adapter/locate.d.ts +1 -1
- package/dist/types/ai-model/model-adapter/locate.d.ts.map +1 -1
- package/dist/types/ai-model/model-adapter/resolve.d.ts +4 -2
- package/dist/types/ai-model/model-adapter/resolve.d.ts.map +1 -1
- package/dist/types/ai-model/model-adapter/responses.d.ts +4 -0
- package/dist/types/ai-model/model-adapter/responses.d.ts.map +1 -0
- package/dist/types/ai-model/model-adapter/temperature-with-semantic-retry.d.ts +6 -0
- package/dist/types/ai-model/model-adapter/temperature-with-semantic-retry.d.ts.map +1 -0
- package/dist/types/ai-model/model-adapter/types.d.ts +42 -20
- package/dist/types/ai-model/model-adapter/types.d.ts.map +1 -1
- package/dist/types/ai-model/models/gpt.d.ts +15 -3
- package/dist/types/ai-model/models/gpt.d.ts.map +1 -1
- package/dist/types/ai-model/models/qwen.d.ts +2 -1
- package/dist/types/ai-model/models/qwen.d.ts.map +1 -1
- package/dist/types/ai-model/models/registry.d.ts +16 -3
- package/dist/types/ai-model/models/registry.d.ts.map +1 -1
- package/dist/types/ai-model/service-caller/call-ai.d.ts +2 -2
- package/dist/types/ai-model/service-caller/call-ai.d.ts.map +1 -1
- package/dist/types/ai-model/service-caller/codex/call-codex.d.ts +4 -2
- package/dist/types/ai-model/service-caller/codex/call-codex.d.ts.map +1 -1
- package/dist/types/ai-model/service-caller/codex/codex-app-server.d.ts +5 -4
- package/dist/types/ai-model/service-caller/codex/codex-app-server.d.ts.map +1 -1
- package/dist/types/ai-model/service-caller/index.d.ts +0 -1
- package/dist/types/ai-model/service-caller/index.d.ts.map +1 -1
- package/dist/types/ai-model/service-caller/model-call.d.ts +6 -6
- package/dist/types/ai-model/service-caller/model-call.d.ts.map +1 -1
- package/dist/types/ai-model/service-caller/openai/call-openai.d.ts +9 -1
- package/dist/types/ai-model/service-caller/openai/call-openai.d.ts.map +1 -1
- package/dist/types/ai-model/service-caller/openai/chat-completion/chat-completion.d.ts +3 -4
- package/dist/types/ai-model/service-caller/openai/chat-completion/chat-completion.d.ts.map +1 -1
- package/dist/types/ai-model/service-caller/openai/chat-completion/non-stream.d.ts +1 -1
- package/dist/types/ai-model/service-caller/openai/chat-completion/non-stream.d.ts.map +1 -1
- package/dist/types/ai-model/service-caller/openai/chat-completion/stream.d.ts +1 -1
- package/dist/types/ai-model/service-caller/openai/chat-completion/stream.d.ts.map +1 -1
- package/dist/types/ai-model/service-caller/openai/chat-completion/types.d.ts +5 -5
- package/dist/types/ai-model/service-caller/openai/chat-completion/types.d.ts.map +1 -1
- package/dist/types/ai-model/service-caller/openai/chat-completion/utils.d.ts +5 -0
- package/dist/types/ai-model/service-caller/openai/chat-completion/utils.d.ts.map +1 -1
- package/dist/types/ai-model/service-caller/openai/openai-client.d.ts +2 -2
- package/dist/types/ai-model/service-caller/openai/openai-client.d.ts.map +1 -1
- package/dist/types/ai-model/service-caller/openai/responses/non-stream.d.ts +4 -0
- package/dist/types/ai-model/service-caller/openai/responses/non-stream.d.ts.map +1 -0
- package/dist/types/ai-model/service-caller/openai/responses/responses.d.ts +8 -0
- package/dist/types/ai-model/service-caller/openai/responses/responses.d.ts.map +1 -0
- package/dist/types/ai-model/service-caller/openai/responses/stream.d.ts +4 -0
- package/dist/types/ai-model/service-caller/openai/responses/stream.d.ts.map +1 -0
- package/dist/types/ai-model/service-caller/openai/responses/types.d.ts +8 -0
- package/dist/types/ai-model/service-caller/openai/responses/types.d.ts.map +1 -0
- package/dist/types/ai-model/service-caller/openai/responses/utils.d.ts +8 -0
- package/dist/types/ai-model/service-caller/openai/responses/utils.d.ts.map +1 -0
- package/dist/types/ai-model/service-caller/semantic-retry.d.ts +2 -2
- package/dist/types/ai-model/service-caller/semantic-retry.d.ts.map +1 -1
- package/dist/types/ai-model/service-caller/types.d.ts +35 -5
- package/dist/types/ai-model/service-caller/types.d.ts.map +1 -1
- package/dist/types/ai-model/service-caller/utils.d.ts +5 -9
- package/dist/types/ai-model/service-caller/utils.d.ts.map +1 -1
- package/dist/types/ai-model/shared/model-locate-result/factory.d.ts.map +1 -1
- package/dist/types/ai-model/shared/model-locate-result/prompt-spec.d.ts +4 -1
- package/dist/types/ai-model/shared/model-locate-result/prompt-spec.d.ts.map +1 -1
- package/dist/types/ai-model/shared/model-locate-result/result-field.d.ts +5 -0
- package/dist/types/ai-model/shared/model-locate-result/result-field.d.ts.map +1 -0
- package/dist/types/ai-model/shared/model-locate-result/types.d.ts +6 -0
- package/dist/types/ai-model/shared/model-locate-result/types.d.ts.map +1 -1
- package/dist/types/ai-model/shared/multimodal-prompt.d.ts +3 -3
- package/dist/types/ai-model/shared/multimodal-prompt.d.ts.map +1 -1
- package/dist/types/ai-model/workflows/grounding/planning-action-locate.d.ts.map +1 -1
- package/dist/types/ai-model/workflows/grounding/section-locate.d.ts +2 -1
- package/dist/types/ai-model/workflows/grounding/section-locate.d.ts.map +1 -1
- package/dist/types/ai-model/workflows/grounding/types.d.ts +3 -2
- package/dist/types/ai-model/workflows/grounding/types.d.ts.map +1 -1
- package/dist/types/ai-model/workflows/grounding/utils.d.ts +3 -3
- package/dist/types/ai-model/workflows/grounding/utils.d.ts.map +1 -1
- package/dist/types/ai-model/workflows/insight/extraction.d.ts +1 -1
- package/dist/types/ai-model/workflows/insight/extraction.d.ts.map +1 -1
- package/dist/types/ai-model/workflows/insight/order-sensitive.d.ts.map +1 -1
- package/dist/types/ai-model/workflows/planning/conversation-history.d.ts +10 -8
- package/dist/types/ai-model/workflows/planning/conversation-history.d.ts.map +1 -1
- package/dist/types/ai-model/workflows/planning/custom-planning.d.ts +2 -2
- package/dist/types/ai-model/workflows/planning/custom-planning.d.ts.map +1 -1
- package/dist/types/ai-model/workflows/planning/locate-normalization.d.ts +1 -2
- package/dist/types/ai-model/workflows/planning/locate-normalization.d.ts.map +1 -1
- package/dist/types/ai-model/workflows/planning/standard-planning.d.ts.map +1 -1
- package/dist/types/ai-model/workflows/recorder-generation/common.d.ts +2 -1
- package/dist/types/ai-model/workflows/recorder-generation/common.d.ts.map +1 -1
- package/dist/types/ai-model/workflows/recorder-generation/markdown.d.ts +2 -2
- package/dist/types/ai-model/workflows/recorder-generation/markdown.d.ts.map +1 -1
- package/dist/types/ai-model/workflows/recorder-generation/metadata.d.ts.map +1 -1
- package/dist/types/ai-model/workflows/recorder-generation/playwright.d.ts.map +1 -1
- package/dist/types/ai-model/workflows/recorder-generation/yaml.d.ts.map +1 -1
- package/dist/types/service/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +11 -2
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { getTemperatureWithSemanticRetry } from "./temperature-with-semantic-retry.mjs";
|
|
2
2
|
const defaultChatCompletionParams = ({ midsceneDefaults, userConfig })=>({
|
|
3
3
|
config: {
|
|
4
4
|
temperature: userConfig.temperature ?? midsceneDefaults.temperature
|
|
@@ -31,7 +31,6 @@ function resolveExtractContentAndReasoning(chatCompletion) {
|
|
|
31
31
|
}
|
|
32
32
|
function resolveChatCompletion(chatCompletion) {
|
|
33
33
|
const buildChatCompletionParams = chatCompletion?.buildChatCompletionParams ?? defaultChatCompletionParams;
|
|
34
|
-
const resolveImageDetail = chatCompletion?.resolveImageDetail ?? defaultImageDetail;
|
|
35
34
|
const unsupportedUserConfig = chatCompletion?.unsupportedUserConfig ?? [];
|
|
36
35
|
const extractContentAndReasoning = resolveExtractContentAndReasoning(chatCompletion);
|
|
37
36
|
const useReasoningAsContentFallback = chatCompletion?.useReasoningAsContentFallback ?? false;
|
|
@@ -45,20 +44,18 @@ function resolveChatCompletion(chatCompletion) {
|
|
|
45
44
|
midsceneDefaults: midsceneChatCompletionDefaults
|
|
46
45
|
};
|
|
47
46
|
const params = buildChatCompletionParams(context);
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
return {
|
|
48
|
+
...params,
|
|
50
49
|
config: {
|
|
51
50
|
...params.config,
|
|
52
|
-
temperature:
|
|
51
|
+
temperature: getTemperatureWithSemanticRetry({
|
|
52
|
+
temperature: params.config.temperature,
|
|
53
|
+
userTemperature: input.userConfig?.temperature,
|
|
54
|
+
semanticRetryAttempt: input.semanticRetryAttempt
|
|
55
|
+
})
|
|
53
56
|
}
|
|
54
57
|
};
|
|
55
|
-
return params;
|
|
56
58
|
},
|
|
57
|
-
resolveImageDetail: (input)=>resolveImageDetail({
|
|
58
|
-
...input,
|
|
59
|
-
userConfig: input.userConfig ?? {},
|
|
60
|
-
midsceneDefaults: midsceneChatCompletionDefaults
|
|
61
|
-
}),
|
|
62
59
|
extractContentAndReasoning,
|
|
63
60
|
useReasoningAsContentFallback,
|
|
64
61
|
replayRawAssistantMessage
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-model/model-adapter/chat-completion.mjs","sources":["../../../../src/ai-model/model-adapter/chat-completion.ts"],"sourcesContent":["import type {\n ChatCompletionAdapter,\n ChatCompletionCallContext,\n ExtractContentAndReasoning,\n MidsceneChatCompletionDefaults,\n ModelAdapterDefinition,\n} from './types';\n\nconst
|
|
1
|
+
{"version":3,"file":"ai-model/model-adapter/chat-completion.mjs","sources":["../../../../src/ai-model/model-adapter/chat-completion.ts"],"sourcesContent":["import { getTemperatureWithSemanticRetry } from './temperature-with-semantic-retry';\nimport type {\n ChatCompletionAdapter,\n ChatCompletionCallContext,\n ExtractContentAndReasoning,\n MidsceneChatCompletionDefaults,\n ModelAdapterDefinition,\n} from './types';\n\nconst defaultChatCompletionParams = ({\n midsceneDefaults,\n userConfig,\n}: ChatCompletionCallContext) => ({\n config: {\n temperature: userConfig.temperature ?? midsceneDefaults.temperature,\n },\n});\n\nconst midsceneChatCompletionDefaults: MidsceneChatCompletionDefaults = {\n temperature: 0,\n};\n\nfunction createDefaultExtractContentAndReasoning(\n reasoningContentKeys: string[],\n): ExtractContentAndReasoning {\n return (message) => {\n if (!message) {\n return {\n content: '',\n reasoning_content: '',\n };\n }\n\n const messageRecord = message as Record<string, unknown>;\n const rawReasoning = reasoningContentKeys\n .map((key) => messageRecord[key])\n .find((value) => typeof value === 'string');\n const messageReasoning =\n typeof rawReasoning === 'string' ? rawReasoning : '';\n\n return {\n content: typeof message.content === 'string' ? message.content : '',\n reasoning_content: messageReasoning,\n };\n };\n}\n\nfunction resolveExtractContentAndReasoning(\n chatCompletion: ModelAdapterDefinition['chatCompletion'],\n): ExtractContentAndReasoning {\n const messageExtraction = chatCompletion?.messageExtraction;\n if (messageExtraction?.kind === 'custom') {\n return messageExtraction.extractContentAndReasoning;\n }\n\n return createDefaultExtractContentAndReasoning(\n messageExtraction?.reasoningContentKeys ?? ['reasoning_content'],\n );\n}\n\nexport function resolveChatCompletion(\n chatCompletion: ModelAdapterDefinition['chatCompletion'],\n): ChatCompletionAdapter {\n const buildChatCompletionParams =\n chatCompletion?.buildChatCompletionParams ?? defaultChatCompletionParams;\n const unsupportedUserConfig = chatCompletion?.unsupportedUserConfig ?? [];\n const extractContentAndReasoning =\n resolveExtractContentAndReasoning(chatCompletion);\n const useReasoningAsContentFallback =\n chatCompletion?.useReasoningAsContentFallback ?? false;\n const replayRawAssistantMessage =\n chatCompletion?.replayRawAssistantMessage ?? false;\n\n return {\n unsupportedUserConfig,\n buildChatCompletionParams: (input) => {\n const context = {\n ...input,\n userConfig: input.userConfig ?? {},\n midsceneDefaults: midsceneChatCompletionDefaults,\n };\n const params = buildChatCompletionParams(context);\n return {\n ...params,\n config: {\n ...params.config,\n temperature: getTemperatureWithSemanticRetry({\n temperature: params.config.temperature,\n userTemperature: input.userConfig?.temperature,\n semanticRetryAttempt: input.semanticRetryAttempt,\n }),\n },\n };\n },\n extractContentAndReasoning,\n useReasoningAsContentFallback,\n replayRawAssistantMessage,\n };\n}\n"],"names":["defaultChatCompletionParams","midsceneDefaults","userConfig","midsceneChatCompletionDefaults","createDefaultExtractContentAndReasoning","reasoningContentKeys","message","messageRecord","rawReasoning","key","value","messageReasoning","resolveExtractContentAndReasoning","chatCompletion","messageExtraction","resolveChatCompletion","buildChatCompletionParams","unsupportedUserConfig","extractContentAndReasoning","useReasoningAsContentFallback","replayRawAssistantMessage","input","context","params","getTemperatureWithSemanticRetry"],"mappings":";AASA,MAAMA,8BAA8B,CAAC,EACnCC,gBAAgB,EAChBC,UAAU,EACgB,GAAM;QAChC,QAAQ;YACN,aAAaA,WAAW,WAAW,IAAID,iBAAiB,WAAW;QACrE;IACF;AAEA,MAAME,iCAAiE;IACrE,aAAa;AACf;AAEA,SAASC,wCACPC,oBAA8B;IAE9B,OAAO,CAACC;QACN,IAAI,CAACA,SACH,OAAO;YACL,SAAS;YACT,mBAAmB;QACrB;QAGF,MAAMC,gBAAgBD;QACtB,MAAME,eAAeH,qBAClB,GAAG,CAAC,CAACI,MAAQF,aAAa,CAACE,IAAI,EAC/B,IAAI,CAAC,CAACC,QAAU,AAAiB,YAAjB,OAAOA;QAC1B,MAAMC,mBACJ,AAAwB,YAAxB,OAAOH,eAA4BA,eAAe;QAEpD,OAAO;YACL,SAAS,AAA2B,YAA3B,OAAOF,QAAQ,OAAO,GAAgBA,QAAQ,OAAO,GAAG;YACjE,mBAAmBK;QACrB;IACF;AACF;AAEA,SAASC,kCACPC,cAAwD;IAExD,MAAMC,oBAAoBD,gBAAgB;IAC1C,IAAIC,mBAAmB,SAAS,UAC9B,OAAOA,kBAAkB,0BAA0B;IAGrD,OAAOV,wCACLU,mBAAmB,wBAAwB;QAAC;KAAoB;AAEpE;AAEO,SAASC,sBACdF,cAAwD;IAExD,MAAMG,4BACJH,gBAAgB,6BAA6Bb;IAC/C,MAAMiB,wBAAwBJ,gBAAgB,yBAAyB,EAAE;IACzE,MAAMK,6BACJN,kCAAkCC;IACpC,MAAMM,gCACJN,gBAAgB,iCAAiC;IACnD,MAAMO,4BACJP,gBAAgB,6BAA6B;IAE/C,OAAO;QACLI;QACA,2BAA2B,CAACI;YAC1B,MAAMC,UAAU;gBACd,GAAGD,KAAK;gBACR,YAAYA,MAAM,UAAU,IAAI,CAAC;gBACjC,kBAAkBlB;YACpB;YACA,MAAMoB,SAASP,0BAA0BM;YACzC,OAAO;gBACL,GAAGC,MAAM;gBACT,QAAQ;oBACN,GAAGA,OAAO,MAAM;oBAChB,aAAaC,gCAAgC;wBAC3C,aAAaD,OAAO,MAAM,CAAC,WAAW;wBACtC,iBAAiBF,MAAM,UAAU,EAAE;wBACnC,sBAAsBA,MAAM,oBAAoB;oBAClD;gBACF;YACF;QACF;QACAH;QACAC;QACAC;IACF;AACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getPreferredLanguage } from "@midscene/shared/env";
|
|
2
2
|
import { assertJsonObject } from "../shared/json.mjs";
|
|
3
3
|
import { formatLocateExampleValue } from "../shared/model-locate-result/index.mjs";
|
|
4
|
+
import { readLocateResultField } from "../shared/model-locate-result/result-field.mjs";
|
|
4
5
|
const markdownCodeFence = '```';
|
|
5
6
|
const defaultLocateSystemPromptIntroduction = `## Role:
|
|
6
7
|
You are an AI assistant that helps identify UI elements.
|
|
@@ -89,7 +90,7 @@ const createParseRawResponse = (jsonParser, source, options)=>(content, promptSp
|
|
|
89
90
|
});
|
|
90
91
|
assertJsonObject(parsedResponse);
|
|
91
92
|
const record = parsedResponse;
|
|
92
|
-
const target =
|
|
93
|
+
const target = readLocateResultField(record, promptSpec);
|
|
93
94
|
const error = 'string' == typeof record.error ? record.error : void 0;
|
|
94
95
|
if (void 0 === target) throw new Error(`Missing required coordinate field "${promptSpec.resultKey}". Expected "${promptSpec.resultKey}": ${promptSpec.resultValueSchema}; use an empty array when no element is found.${error ? ` Model error: ${error}` : ''}`);
|
|
95
96
|
if (Array.isArray(target) && 0 === target.length) return {
|
|
@@ -105,7 +106,7 @@ const createParseRawResponse = (jsonParser, source, options)=>(content, promptSp
|
|
|
105
106
|
error
|
|
106
107
|
} : {}
|
|
107
108
|
};
|
|
108
|
-
const rawReferences = record
|
|
109
|
+
const rawReferences = readLocateResultField(record, promptSpec, 'references_');
|
|
109
110
|
const references = null == rawReferences ? void 0 : Array.isArray(rawReferences) ? rawReferences : [
|
|
110
111
|
rawReferences
|
|
111
112
|
];
|
|
@@ -120,24 +121,22 @@ const createParseRawResponse = (jsonParser, source, options)=>(content, promptSp
|
|
|
120
121
|
} : {}
|
|
121
122
|
};
|
|
122
123
|
};
|
|
123
|
-
const createDefaultElementProtocol = ({ jsonParser }
|
|
124
|
+
const createDefaultElementProtocol = ({ jsonParser })=>({
|
|
124
125
|
systemPromptIntroduction: defaultLocateSystemPromptIntroduction,
|
|
125
126
|
buildResponseInstructions,
|
|
126
127
|
buildUserPrompt,
|
|
127
128
|
expectedJsonObjectResponse: true,
|
|
128
129
|
parseRawResponse: createParseRawResponse(jsonParser, 'locate', {
|
|
129
|
-
includeReferences: false
|
|
130
|
-
acceptBbox2dAlias: options.acceptBbox2dAlias
|
|
130
|
+
includeReferences: false
|
|
131
131
|
})
|
|
132
132
|
});
|
|
133
|
-
const createDefaultSearchAreaProtocol = ({ jsonParser }
|
|
133
|
+
const createDefaultSearchAreaProtocol = ({ jsonParser })=>({
|
|
134
134
|
systemPromptIntroduction: defaultSearchAreaSystemPromptIntroduction,
|
|
135
135
|
buildResponseInstructions: buildSearchAreaResponseInstructions,
|
|
136
136
|
buildUserPrompt: buildSearchAreaUserPrompt,
|
|
137
137
|
expectedJsonObjectResponse: true,
|
|
138
138
|
parseRawResponse: createParseRawResponse(jsonParser, 'section-locator', {
|
|
139
|
-
includeReferences: true
|
|
140
|
-
acceptBbox2dAlias: options.acceptBbox2dAlias
|
|
139
|
+
includeReferences: true
|
|
141
140
|
})
|
|
142
141
|
});
|
|
143
142
|
export { createDefaultElementProtocol, createDefaultSearchAreaProtocol };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-model/model-adapter/default-locate-protocol.mjs","sources":["../../../../src/ai-model/model-adapter/default-locate-protocol.ts"],"sourcesContent":["import { getPreferredLanguage } from '@midscene/shared/env';\nimport {\n type JsonParser,\n type JsonParserSource,\n assertJsonObject,\n} from '../shared/json';\nimport {\n type LocateResultPromptSpec,\n formatLocateExampleValue,\n} from '../shared/model-locate-result';\nimport type {\n ParsedLocateResponse,\n StandardLocateProtocol,\n StandardLocateProtocolContext,\n} from './locate-protocol';\n\nconst markdownCodeFence = '```';\n\nconst defaultLocateSystemPromptIntroduction = `## Role:\nYou are an AI assistant that helps identify UI elements.\n\n## Objective:\n- Identify elements in screenshots that match the user's description.\n- Provide the coordinates of the element that matches the user's description.`;\n\nconst defaultSearchAreaSystemPromptIntroduction = `## Role:\nYou are an AI assistant that helps identify UI elements.\n\n## Objective:\n- Find a section containing the target element\n- If the description mentions reference elements, also locate sections containing those references`;\n\nconst buildResponseInstructions = (promptSpec: LocateResultPromptSpec) => {\n const preferredLanguage = getPreferredLanguage();\n const resultKey = promptSpec.resultKey;\n const exampleValueText = formatLocateExampleValue(\n promptSpec.exampleValues[0],\n );\n const resultFieldDescription = `the ${promptSpec.resultNoun} of the element that matches the user's description`;\n return `## Output Format:\n${markdownCodeFence}json\n{\n \"${resultKey}\": ${promptSpec.resultValueSchema}, // ${promptSpec.resultValueDescription}\n \"error\": string // optional\n}\n${markdownCodeFence}\n\nFields:\n* \\`${resultKey}\\` is ${resultFieldDescription}\n* \\`error\\` is an optional error message (if any)\n\nFor example, when an element is found:\n${markdownCodeFence}json\n{\n \"${resultKey}\": ${exampleValueText}\n}\n${markdownCodeFence}\n\nWhen no element is found:\n${markdownCodeFence}json\n{\n \"${resultKey}\": [],\n \"error\": \"I can see ..., but {some element} is not found. Use ${preferredLanguage}.\"\n}\n${markdownCodeFence}\n`;\n};\n\nconst buildUserPrompt = (targetElementDescription: string) =>\n `Find: ${targetElementDescription}`;\n\nconst buildSearchAreaResponseInstructions = (\n promptSpec: LocateResultPromptSpec,\n) => {\n const preferredLanguage = getPreferredLanguage();\n const resultKey = promptSpec.resultKey;\n const exampleValueText = formatLocateExampleValue(\n promptSpec.exampleValues[0],\n );\n const resultJsonProperty = `\"${resultKey}\": ${promptSpec.resultValueSchema}, // ${promptSpec.resultValueDescription}`;\n const resultFieldDescription = `${promptSpec.resultNoun} of the section containing the target element`;\n const referenceFieldDescription = `Optional array of ${promptSpec.resultNounPlural} of reference elements`;\n return `## Output Format:\n${markdownCodeFence}json\n{\n ${resultJsonProperty}\n \"references_${resultKey}\"?: [\n ${promptSpec.resultValueSchema},\n ...\n ],\n \"error\"?: string\n}\n${markdownCodeFence}\n\nFields:\n* \\`${resultKey}\\` - ${resultFieldDescription}\n* \\`references_${resultKey}\\` - ${referenceFieldDescription}\n* \\`error\\` - Optional error message if the section cannot be found. Use ${preferredLanguage}.\n\nExample:\nIf the description is \"delete button on the second row with title 'Peter'\", return:\n${markdownCodeFence}json\n{\n \"${resultKey}\": ${exampleValueText},\n \"references_${resultKey}\": [${exampleValueText}]\n}\n${markdownCodeFence}\n`;\n};\n\nconst buildSearchAreaUserPrompt = (sectionDescription: string) =>\n `Find section containing: ${sectionDescription}`;\n\ntype ParseRawResponseOptions = {\n includeReferences: boolean;\n acceptBbox2dAlias?: boolean;\n};\n\nconst createParseRawResponse =\n (\n jsonParser: JsonParser,\n source: JsonParserSource,\n options: ParseRawResponseOptions,\n ) =>\n (\n content: string,\n promptSpec: LocateResultPromptSpec,\n ): ParsedLocateResponse => {\n const parsedResponse = jsonParser(content, {\n source,\n });\n assertJsonObject(parsedResponse);\n const record = parsedResponse;\n const target =\n record[promptSpec.resultKey] !== undefined\n ? record[promptSpec.resultKey]\n : options.acceptBbox2dAlias && promptSpec.resultKey === 'bbox'\n ? record.bbox_2d\n : undefined;\n const error = typeof record.error === 'string' ? record.error : undefined;\n if (target === undefined) {\n throw new Error(\n `Missing required coordinate field \"${promptSpec.resultKey}\". Expected \"${promptSpec.resultKey}\": ${promptSpec.resultValueSchema}; use an empty array when no element is found.${error ? ` Model error: ${error}` : ''}`,\n );\n }\n if (Array.isArray(target) && target.length === 0) {\n return { kind: 'not-found', ...(error ? { error } : {}) };\n }\n\n if (!options.includeReferences) {\n return { kind: 'located', target, ...(error ? { error } : {}) };\n }\n\n const rawReferences = record[`references_${promptSpec.resultKey}`];\n const references =\n rawReferences === undefined || rawReferences === null\n ? undefined\n : Array.isArray(rawReferences)\n ? rawReferences\n : [rawReferences];\n return {\n kind: 'located',\n target,\n ...(references?.length ? { references } : {}),\n ...(error ? { error } : {}),\n };\n };\n\ntype DefaultLocateProtocolOptions = {\n acceptBbox2dAlias?: boolean;\n};\n\nexport const createDefaultElementProtocol = (\n { jsonParser }: StandardLocateProtocolContext,\n options: DefaultLocateProtocolOptions = {},\n): StandardLocateProtocol => ({\n systemPromptIntroduction: defaultLocateSystemPromptIntroduction,\n buildResponseInstructions,\n buildUserPrompt,\n expectedJsonObjectResponse: true,\n parseRawResponse: createParseRawResponse(jsonParser, 'locate', {\n includeReferences: false,\n acceptBbox2dAlias: options.acceptBbox2dAlias,\n }),\n});\n\nexport const createDefaultSearchAreaProtocol = (\n { jsonParser }: StandardLocateProtocolContext,\n options: DefaultLocateProtocolOptions = {},\n): StandardLocateProtocol => ({\n systemPromptIntroduction: defaultSearchAreaSystemPromptIntroduction,\n buildResponseInstructions: buildSearchAreaResponseInstructions,\n buildUserPrompt: buildSearchAreaUserPrompt,\n expectedJsonObjectResponse: true,\n parseRawResponse: createParseRawResponse(jsonParser, 'section-locator', {\n includeReferences: true,\n acceptBbox2dAlias: options.acceptBbox2dAlias,\n }),\n});\n"],"names":["markdownCodeFence","defaultLocateSystemPromptIntroduction","defaultSearchAreaSystemPromptIntroduction","buildResponseInstructions","promptSpec","preferredLanguage","getPreferredLanguage","resultKey","exampleValueText","formatLocateExampleValue","resultFieldDescription","buildUserPrompt","targetElementDescription","buildSearchAreaResponseInstructions","resultJsonProperty","referenceFieldDescription","buildSearchAreaUserPrompt","sectionDescription","createParseRawResponse","jsonParser","source","options","content","parsedResponse","assertJsonObject","record","target","undefined","error","Error","Array","rawReferences","references","createDefaultElementProtocol","createDefaultSearchAreaProtocol"],"mappings":";;;AAgBA,MAAMA,oBAAoB;AAE1B,MAAMC,wCAAwC,CAAC;;;;;6E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Q,GAAIE,QAAQ;gBAAEA;YAAM,IAAI,CAAC,CAAC;QAAE;QAGhE,MAAMG,gBAAgBN,MAAM,CAAC,CAAC,WAAW,EAAErB,WAAW,SAAS,EAAE,CAAC;QAClE,MAAM4B,aACJD,QAAAA,gBACIJ,SACAG,MAAM,OAAO,CAACC,iBACZA,gBACA;YAACA;SAAc;QACvB,OAAO;YACL,MAAM;YACNL;YACA,GAAIM,YAAY,SAAS;gBAAEA;YAAW,IAAI,CAAC,CAAC;YAC5C,GAAIJ,QAAQ;gBAAEA;YAAM,IAAI,CAAC,CAAC;QAC5B;IACF;AAMK,MAAMK,+BAA+B,CAC1C,EAAEd,UAAU,EAAiC,EAC7CE,UAAwC,CAAC,CAAC,GACd;QAC5B,0BAA0BpB;QAC1BE;QACAQ;QACA,4BAA4B;QAC5B,kBAAkBO,uBAAuBC,YAAY,UAAU;YAC7D,mBAAmB;YACnB,mBAAmBE,QAAQ,iBAAiB;QAC9C;IACF;AAEO,MAAMa,kCAAkC,CAC7C,EAAEf,UAAU,EAAiC,EAC7CE,UAAwC,CAAC,CAAC,GACd;QAC5B,0BAA0BnB;QAC1B,2BAA2BW;QAC3B,iBAAiBG;QACjB,4BAA4B;QAC5B,kBAAkBE,uBAAuBC,YAAY,mBAAmB;YACtE,mBAAmB;YACnB,mBAAmBE,QAAQ,iBAAiB;QAC9C;IACF"}
|
|
1
|
+
{"version":3,"file":"ai-model/model-adapter/default-locate-protocol.mjs","sources":["../../../../src/ai-model/model-adapter/default-locate-protocol.ts"],"sourcesContent":["import { getPreferredLanguage } from '@midscene/shared/env';\nimport {\n type JsonParser,\n type JsonParserSource,\n assertJsonObject,\n} from '../shared/json';\nimport {\n type LocateResultPromptSpec,\n formatLocateExampleValue,\n} from '../shared/model-locate-result';\nimport { readLocateResultField } from '../shared/model-locate-result/result-field';\nimport type {\n ParsedLocateResponse,\n StandardLocateProtocol,\n StandardLocateProtocolContext,\n} from './locate-protocol';\n\nconst markdownCodeFence = '```';\n\nconst defaultLocateSystemPromptIntroduction = `## Role:\nYou are an AI assistant that helps identify UI elements.\n\n## Objective:\n- Identify elements in screenshots that match the user's description.\n- Provide the coordinates of the element that matches the user's description.`;\n\nconst defaultSearchAreaSystemPromptIntroduction = `## Role:\nYou are an AI assistant that helps identify UI elements.\n\n## Objective:\n- Find a section containing the target element\n- If the description mentions reference elements, also locate sections containing those references`;\n\nconst buildResponseInstructions = (promptSpec: LocateResultPromptSpec) => {\n const preferredLanguage = getPreferredLanguage();\n const resultKey = promptSpec.resultKey;\n const exampleValueText = formatLocateExampleValue(\n promptSpec.exampleValues[0],\n );\n const resultFieldDescription = `the ${promptSpec.resultNoun} of the element that matches the user's description`;\n return `## Output Format:\n${markdownCodeFence}json\n{\n \"${resultKey}\": ${promptSpec.resultValueSchema}, // ${promptSpec.resultValueDescription}\n \"error\": string // optional\n}\n${markdownCodeFence}\n\nFields:\n* \\`${resultKey}\\` is ${resultFieldDescription}\n* \\`error\\` is an optional error message (if any)\n\nFor example, when an element is found:\n${markdownCodeFence}json\n{\n \"${resultKey}\": ${exampleValueText}\n}\n${markdownCodeFence}\n\nWhen no element is found:\n${markdownCodeFence}json\n{\n \"${resultKey}\": [],\n \"error\": \"I can see ..., but {some element} is not found. Use ${preferredLanguage}.\"\n}\n${markdownCodeFence}\n`;\n};\n\nconst buildUserPrompt = (targetElementDescription: string) =>\n `Find: ${targetElementDescription}`;\n\nconst buildSearchAreaResponseInstructions = (\n promptSpec: LocateResultPromptSpec,\n) => {\n const preferredLanguage = getPreferredLanguage();\n const resultKey = promptSpec.resultKey;\n const exampleValueText = formatLocateExampleValue(\n promptSpec.exampleValues[0],\n );\n const resultJsonProperty = `\"${resultKey}\": ${promptSpec.resultValueSchema}, // ${promptSpec.resultValueDescription}`;\n const resultFieldDescription = `${promptSpec.resultNoun} of the section containing the target element`;\n const referenceFieldDescription = `Optional array of ${promptSpec.resultNounPlural} of reference elements`;\n return `## Output Format:\n${markdownCodeFence}json\n{\n ${resultJsonProperty}\n \"references_${resultKey}\"?: [\n ${promptSpec.resultValueSchema},\n ...\n ],\n \"error\"?: string\n}\n${markdownCodeFence}\n\nFields:\n* \\`${resultKey}\\` - ${resultFieldDescription}\n* \\`references_${resultKey}\\` - ${referenceFieldDescription}\n* \\`error\\` - Optional error message if the section cannot be found. Use ${preferredLanguage}.\n\nExample:\nIf the description is \"delete button on the second row with title 'Peter'\", return:\n${markdownCodeFence}json\n{\n \"${resultKey}\": ${exampleValueText},\n \"references_${resultKey}\": [${exampleValueText}]\n}\n${markdownCodeFence}\n`;\n};\n\nconst buildSearchAreaUserPrompt = (sectionDescription: string) =>\n `Find section containing: ${sectionDescription}`;\n\ntype ParseRawResponseOptions = {\n includeReferences: boolean;\n};\n\nconst createParseRawResponse =\n (\n jsonParser: JsonParser,\n source: JsonParserSource,\n options: ParseRawResponseOptions,\n ) =>\n (\n content: string,\n promptSpec: LocateResultPromptSpec,\n ): ParsedLocateResponse => {\n const parsedResponse = jsonParser(content, {\n source,\n });\n assertJsonObject(parsedResponse);\n const record = parsedResponse;\n const target = readLocateResultField(record, promptSpec);\n const error = typeof record.error === 'string' ? record.error : undefined;\n if (target === undefined) {\n throw new Error(\n `Missing required coordinate field \"${promptSpec.resultKey}\". Expected \"${promptSpec.resultKey}\": ${promptSpec.resultValueSchema}; use an empty array when no element is found.${error ? ` Model error: ${error}` : ''}`,\n );\n }\n if (Array.isArray(target) && target.length === 0) {\n return { kind: 'not-found', ...(error ? { error } : {}) };\n }\n\n if (!options.includeReferences) {\n return { kind: 'located', target, ...(error ? { error } : {}) };\n }\n\n const rawReferences = readLocateResultField(\n record,\n promptSpec,\n 'references_',\n );\n const references =\n rawReferences === undefined || rawReferences === null\n ? undefined\n : Array.isArray(rawReferences)\n ? rawReferences\n : [rawReferences];\n return {\n kind: 'located',\n target,\n ...(references?.length ? { references } : {}),\n ...(error ? { error } : {}),\n };\n };\n\nexport const createDefaultElementProtocol = ({\n jsonParser,\n}: StandardLocateProtocolContext): StandardLocateProtocol => ({\n systemPromptIntroduction: defaultLocateSystemPromptIntroduction,\n buildResponseInstructions,\n buildUserPrompt,\n expectedJsonObjectResponse: true,\n parseRawResponse: createParseRawResponse(jsonParser, 'locate', {\n includeReferences: false,\n }),\n});\n\nexport const createDefaultSearchAreaProtocol = ({\n jsonParser,\n}: StandardLocateProtocolContext): StandardLocateProtocol => ({\n systemPromptIntroduction: defaultSearchAreaSystemPromptIntroduction,\n buildResponseInstructions: buildSearchAreaResponseInstructions,\n buildUserPrompt: buildSearchAreaUserPrompt,\n expectedJsonObjectResponse: true,\n parseRawResponse: createParseRawResponse(jsonParser, 'section-locator', {\n includeReferences: true,\n }),\n});\n"],"names":["markdownCodeFence","defaultLocateSystemPromptIntroduction","defaultSearchAreaSystemPromptIntroduction","buildResponseInstructions","promptSpec","preferredLanguage","getPreferredLanguage","resultKey","exampleValueText","formatLocateExampleValue","resultFieldDescription","buildUserPrompt","targetElementDescription","buildSearchAreaResponseInstructions","resultJsonProperty","referenceFieldDescription","buildSearchAreaUserPrompt","sectionDescription","createParseRawResponse","jsonParser","source","options","content","parsedResponse","assertJsonObject","record","target","readLocateResultField","error","undefined","Error","Array","rawReferences","references","createDefaultElementProtocol","createDefaultSearchAreaProtocol"],"mappings":";;;;AAiBA,MAAMA,oBAAoB;AAE1B,MAAMC,wCAAwC,CAAC;;;;;6EAK8B,CAAC;AAE9E,MAAMC,4CAA4C,CAAC;;;;;kGAK+C,CAAC;AAEnG,MAAMC,4BAA4B,CAACC;IACjC,MAAMC,oBAAoBC;IAC1B,MAAMC,YAAYH,WAAW,SAAS;IACtC,MAAMI,mBAAmBC,yBACvBL,WAAW,aAAa,CAAC,EAAE;IAE7B,MAAMM,yBAAyB,CAAC,IAAI,EAAEN,WAAW,UAAU,CAAC,mDAAmD,CAAC;IAChH,OAAO,CAAC;AACV,EAAEJ,kBAAkB;;GAEjB,EAAEO,UAAU,GAAG,EAAEH,WAAW,iBAAiB,CAAC,MAAM,EAAEA,WAAW,sBAAsB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,GAA8B;QAC5D,0BAA0BjB;QAC1B,2BAA2BW;QAC3B,iBAAiBG;QACjB,4BAA4B;QAC5B,kBAAkBE,uBAAuBC,YAAY,mBAAmB;YACtE,mBAAmB;QACrB;IACF"}
|
|
@@ -9,7 +9,7 @@ const defaultLocateResultFormatDefinition = {
|
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
11
|
const resolveLocateProtocolDefinition = (protocolDefinition, protocolContext)=>'function' == typeof protocolDefinition ? protocolDefinition(protocolContext) : protocolDefinition;
|
|
12
|
-
function resolveLocate(locate, resolvedCustomPlanner, protocolContext
|
|
12
|
+
function resolveLocate(locate, resolvedCustomPlanner, protocolContext) {
|
|
13
13
|
if (locate?.kind === 'custom') {
|
|
14
14
|
let locateFn = locate.locateFn;
|
|
15
15
|
if (!locateFn) {
|
|
@@ -23,14 +23,10 @@ function resolveLocate(locate, resolvedCustomPlanner, protocolContext, acceptBbo
|
|
|
23
23
|
locateFn
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
const elementProtocol = resolveLocateProtocolDefinition(locate?.element?.protocol ??
|
|
27
|
-
acceptBbox2dAlias
|
|
28
|
-
})), protocolContext);
|
|
26
|
+
const elementProtocol = resolveLocateProtocolDefinition(locate?.element?.protocol ?? createDefaultElementProtocol, protocolContext);
|
|
29
27
|
const elementResultFormat = locate?.element?.resultFormat ?? defaultLocateResultFormatDefinition;
|
|
30
28
|
const elementResultCodec = createLocateResultCodec(elementResultFormat);
|
|
31
|
-
const searchAreaProtocol = locate?.searchArea === false ? void 0 : resolveLocateProtocolDefinition(locate?.searchArea?.protocol ??
|
|
32
|
-
acceptBbox2dAlias
|
|
33
|
-
})), protocolContext);
|
|
29
|
+
const searchAreaProtocol = locate?.searchArea === false ? void 0 : resolveLocateProtocolDefinition(locate?.searchArea?.protocol ?? createDefaultSearchAreaProtocol, protocolContext);
|
|
34
30
|
const searchAreaResultFormat = locate?.searchArea === false ? void 0 : locate?.searchArea?.resultFormat ?? elementResultFormat;
|
|
35
31
|
const searchAreaResultCodec = searchAreaResultFormat ? createLocateResultCodec(searchAreaResultFormat) : void 0;
|
|
36
32
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-model/model-adapter/locate.mjs","sources":["../../../../src/ai-model/model-adapter/locate.ts"],"sourcesContent":["import { createLocateResultCodec } from '../shared/model-locate-result/factory';\nimport type { LocateResultFormatDefinition } from '../shared/model-locate-result/types';\nimport { resolvePlanningTapLocator } from '../workflows/grounding/planning-action-locate';\nimport type { ResolvedCustomPlanningDefinition } from './custom-planning-types';\nimport {\n createDefaultElementProtocol,\n createDefaultSearchAreaProtocol,\n} from './default-locate-protocol';\nimport type {\n StandardLocateProtocolContext,\n StandardLocateProtocolDefinition,\n} from './locate-protocol';\nimport type { LocateAdapter, ModelAdapterDefinition } from './types';\n\nconst defaultLocateResultFormatDefinition: LocateResultFormatDefinition = {\n coordinates: { shape: 'bbox', order: 'xy', normalizedBy: 1000 },\n};\n\nconst resolveLocateProtocolDefinition = (\n protocolDefinition: StandardLocateProtocolDefinition,\n protocolContext: StandardLocateProtocolContext,\n) =>\n typeof protocolDefinition === 'function'\n ? protocolDefinition(protocolContext)\n : protocolDefinition;\n\nexport function resolveLocate(\n locate: ModelAdapterDefinition['locate'],\n resolvedCustomPlanner: ResolvedCustomPlanningDefinition | undefined,\n protocolContext: StandardLocateProtocolContext,\n
|
|
1
|
+
{"version":3,"file":"ai-model/model-adapter/locate.mjs","sources":["../../../../src/ai-model/model-adapter/locate.ts"],"sourcesContent":["import { createLocateResultCodec } from '../shared/model-locate-result/factory';\nimport type { LocateResultFormatDefinition } from '../shared/model-locate-result/types';\nimport { resolvePlanningTapLocator } from '../workflows/grounding/planning-action-locate';\nimport type { ResolvedCustomPlanningDefinition } from './custom-planning-types';\nimport {\n createDefaultElementProtocol,\n createDefaultSearchAreaProtocol,\n} from './default-locate-protocol';\nimport type {\n StandardLocateProtocolContext,\n StandardLocateProtocolDefinition,\n} from './locate-protocol';\nimport type { LocateAdapter, ModelAdapterDefinition } from './types';\n\nconst defaultLocateResultFormatDefinition: LocateResultFormatDefinition = {\n coordinates: { shape: 'bbox', order: 'xy', normalizedBy: 1000 },\n};\n\nconst resolveLocateProtocolDefinition = (\n protocolDefinition: StandardLocateProtocolDefinition,\n protocolContext: StandardLocateProtocolContext,\n) =>\n typeof protocolDefinition === 'function'\n ? protocolDefinition(protocolContext)\n : protocolDefinition;\n\nexport function resolveLocate(\n locate: ModelAdapterDefinition['locate'],\n resolvedCustomPlanner: ResolvedCustomPlanningDefinition | undefined,\n protocolContext: StandardLocateProtocolContext,\n): LocateAdapter {\n if (locate?.kind === 'custom') {\n let locateFn = locate.locateFn;\n\n if (!locateFn) {\n const planningTapLocator = locate.planningTapLocator;\n\n if (!planningTapLocator) {\n throw new Error(\n 'Custom locate definition requires either locateFn or planningTapLocator',\n );\n }\n\n if (!resolvedCustomPlanner) {\n throw new Error(\n 'Custom planning tap locator requires a custom planning planner definition',\n );\n }\n locateFn = resolvePlanningTapLocator(\n planningTapLocator,\n resolvedCustomPlanner,\n );\n }\n\n return {\n kind: 'custom',\n locateFn,\n };\n }\n\n const elementProtocol = resolveLocateProtocolDefinition(\n locate?.element?.protocol ?? createDefaultElementProtocol,\n protocolContext,\n );\n const elementResultFormat =\n locate?.element?.resultFormat ?? defaultLocateResultFormatDefinition;\n const elementResultCodec = createLocateResultCodec(elementResultFormat);\n const searchAreaProtocol =\n locate?.searchArea === false\n ? undefined\n : resolveLocateProtocolDefinition(\n locate?.searchArea?.protocol ?? createDefaultSearchAreaProtocol,\n protocolContext,\n );\n const searchAreaResultFormat =\n locate?.searchArea === false\n ? undefined\n : (locate?.searchArea?.resultFormat ?? elementResultFormat);\n const searchAreaResultCodec = searchAreaResultFormat\n ? createLocateResultCodec(searchAreaResultFormat)\n : undefined;\n\n return {\n kind: 'standard',\n userMessageContentOrder: locate?.userMessageContentOrder ?? 'image-first',\n element: {\n protocol: elementProtocol,\n resultCodec: elementResultCodec,\n },\n ...(searchAreaProtocol && searchAreaResultCodec\n ? {\n searchArea: {\n protocol: searchAreaProtocol,\n resultCodec: searchAreaResultCodec,\n },\n }\n : {}),\n };\n}\n"],"names":["defaultLocateResultFormatDefinition","resolveLocateProtocolDefinition","protocolDefinition","protocolContext","resolveLocate","locate","resolvedCustomPlanner","locateFn","planningTapLocator","Error","resolvePlanningTapLocator","elementProtocol","createDefaultElementProtocol","elementResultFormat","elementResultCodec","createLocateResultCodec","searchAreaProtocol","undefined","createDefaultSearchAreaProtocol","searchAreaResultFormat","searchAreaResultCodec"],"mappings":";;;AAcA,MAAMA,sCAAoE;IACxE,aAAa;QAAE,OAAO;QAAQ,OAAO;QAAM,cAAc;IAAK;AAChE;AAEA,MAAMC,kCAAkC,CACtCC,oBACAC,kBAEA,AAA8B,cAA9B,OAAOD,qBACHA,mBAAmBC,mBACnBD;AAEC,SAASE,cACdC,MAAwC,EACxCC,qBAAmE,EACnEH,eAA8C;IAE9C,IAAIE,QAAQ,SAAS,UAAU;QAC7B,IAAIE,WAAWF,OAAO,QAAQ;QAE9B,IAAI,CAACE,UAAU;YACb,MAAMC,qBAAqBH,OAAO,kBAAkB;YAEpD,IAAI,CAACG,oBACH,MAAM,IAAIC,MACR;YAIJ,IAAI,CAACH,uBACH,MAAM,IAAIG,MACR;YAGJF,WAAWG,0BACTF,oBACAF;QAEJ;QAEA,OAAO;YACL,MAAM;YACNC;QACF;IACF;IAEA,MAAMI,kBAAkBV,gCACtBI,QAAQ,SAAS,YAAYO,8BAC7BT;IAEF,MAAMU,sBACJR,QAAQ,SAAS,gBAAgBL;IACnC,MAAMc,qBAAqBC,wBAAwBF;IACnD,MAAMG,qBACJX,QAAQ,eAAe,QACnBY,SACAhB,gCACEI,QAAQ,YAAY,YAAYa,iCAChCf;IAER,MAAMgB,yBACJd,QAAQ,eAAe,QACnBY,SACCZ,QAAQ,YAAY,gBAAgBQ;IAC3C,MAAMO,wBAAwBD,yBAC1BJ,wBAAwBI,0BACxBF;IAEJ,OAAO;QACL,MAAM;QACN,yBAAyBZ,QAAQ,2BAA2B;QAC5D,SAAS;YACP,UAAUM;YACV,aAAaG;QACf;QACA,GAAIE,sBAAsBI,wBACtB;YACE,YAAY;gBACV,UAAUJ;gBACV,aAAaI;YACf;QACF,IACA,CAAC,CAAC;IACR;AACF"}
|
|
@@ -4,6 +4,7 @@ import { buildDefaultCodexAppServerParams } from "./codex-app-server.mjs";
|
|
|
4
4
|
import { resolveInsight } from "./insight.mjs";
|
|
5
5
|
import { resolveLocate } from "./locate.mjs";
|
|
6
6
|
import { resolveCustomPlanningDefinition, resolvePlanning } from "./planning.mjs";
|
|
7
|
+
import { resolveResponses } from "./responses.mjs";
|
|
7
8
|
function _define_property(obj, key, value) {
|
|
8
9
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
9
10
|
value: value,
|
|
@@ -14,6 +15,7 @@ function _define_property(obj, key, value) {
|
|
|
14
15
|
else obj[key] = value;
|
|
15
16
|
return obj;
|
|
16
17
|
}
|
|
18
|
+
const defaultImageDetail = ({ imageDetail })=>imageDetail ?? 'high';
|
|
17
19
|
function resolveJsonParser(jsonParser) {
|
|
18
20
|
if (!jsonParser || 'lenient-json' === jsonParser) return parseModelResponseJson;
|
|
19
21
|
if ('function' == typeof jsonParser) return jsonParser;
|
|
@@ -26,18 +28,24 @@ function resolveImagePreprocess(imagePreprocess) {
|
|
|
26
28
|
}
|
|
27
29
|
class ResolvedModelAdapter {
|
|
28
30
|
constructor(config, modelFamily){
|
|
31
|
+
_define_property(this, "supportedProtocols", void 0);
|
|
29
32
|
_define_property(this, "jsonParser", void 0);
|
|
30
33
|
_define_property(this, "chatCompletion", void 0);
|
|
34
|
+
_define_property(this, "resolveImageDetail", void 0);
|
|
35
|
+
_define_property(this, "responses", void 0);
|
|
31
36
|
_define_property(this, "buildCodexAppServerParams", void 0);
|
|
32
|
-
_define_property(this, "acceptBbox2dAlias", void 0);
|
|
33
37
|
_define_property(this, "imagePreprocess", void 0);
|
|
34
38
|
_define_property(this, "insight", void 0);
|
|
35
39
|
_define_property(this, "planning", void 0);
|
|
36
40
|
_define_property(this, "locate", void 0);
|
|
41
|
+
this.supportedProtocols = config.supportedProtocols ?? [
|
|
42
|
+
'openai-chat'
|
|
43
|
+
];
|
|
37
44
|
this.jsonParser = resolveJsonParser(config.jsonParser);
|
|
38
45
|
this.chatCompletion = resolveChatCompletion(config.chatCompletion);
|
|
46
|
+
this.resolveImageDetail = config.resolveImageDetail ?? defaultImageDetail;
|
|
47
|
+
this.responses = resolveResponses(config.responses);
|
|
39
48
|
this.buildCodexAppServerParams = config.buildCodexAppServerParams ?? buildDefaultCodexAppServerParams;
|
|
40
|
-
this.acceptBbox2dAlias = config.acceptBbox2dAlias ?? false;
|
|
41
49
|
this.imagePreprocess = resolveImagePreprocess(config.imagePreprocess);
|
|
42
50
|
this.insight = resolveInsight(config.insight, {
|
|
43
51
|
jsonParser: this.jsonParser
|
|
@@ -46,7 +54,7 @@ class ResolvedModelAdapter {
|
|
|
46
54
|
const resolvedCustomPlanner = customPlanner ? resolveCustomPlanningDefinition(customPlanner) : void 0;
|
|
47
55
|
this.locate = resolveLocate(config.locate, resolvedCustomPlanner, {
|
|
48
56
|
jsonParser: this.jsonParser
|
|
49
|
-
}
|
|
57
|
+
});
|
|
50
58
|
this.planning = resolvePlanning(config.planning, resolvedCustomPlanner, {
|
|
51
59
|
jsonParser: this.jsonParser
|
|
52
60
|
}, 'standard' === this.locate.kind ? this.locate.element.resultCodec : void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-model/model-adapter/resolve.mjs","sources":["../../../../src/ai-model/model-adapter/resolve.ts"],"sourcesContent":["import { parseModelResponseJson } from '../shared/json';\nimport { resolveChatCompletion } from './chat-completion';\nimport { buildDefaultCodexAppServerParams } from './codex-app-server';\nimport { resolveInsight } from './insight';\nimport type { InsightAdapter } from './insight-protocol';\nimport { resolveLocate } from './locate';\nimport { resolveCustomPlanningDefinition, resolvePlanning } from './planning';\nimport type {\n BuildCodexAppServerParams,\n ChatCompletionAdapter,\n ImagePreprocessPolicy,\n JsonParser,\n LocateAdapter,\n ModelAdapter,\n ModelAdapterDefinition,\n PlanningAdapter,\n} from './types';\n\nfunction resolveJsonParser(\n jsonParser: ModelAdapterDefinition['jsonParser'],\n): JsonParser {\n if (!jsonParser || jsonParser === 'lenient-json') {\n return parseModelResponseJson;\n }\n\n if (typeof jsonParser === 'function') {\n return jsonParser;\n }\n\n throw new Error(`Unknown json parser preset: ${jsonParser}`);\n}\n\nfunction resolveImagePreprocess(\n imagePreprocess: ModelAdapterDefinition['imagePreprocess'],\n): ImagePreprocessPolicy {\n return {\n padBlockSize: imagePreprocess?.padBlockSize,\n };\n}\n\nexport class ResolvedModelAdapter implements ModelAdapter {\n readonly jsonParser: JsonParser;\n readonly chatCompletion: ChatCompletionAdapter;\n readonly
|
|
1
|
+
{"version":3,"file":"ai-model/model-adapter/resolve.mjs","sources":["../../../../src/ai-model/model-adapter/resolve.ts"],"sourcesContent":["import { parseModelResponseJson } from '../shared/json';\nimport { resolveChatCompletion } from './chat-completion';\nimport { buildDefaultCodexAppServerParams } from './codex-app-server';\nimport { resolveInsight } from './insight';\nimport type { InsightAdapter } from './insight-protocol';\nimport { resolveLocate } from './locate';\nimport { resolveCustomPlanningDefinition, resolvePlanning } from './planning';\nimport { resolveResponses } from './responses';\nimport type {\n BuildCodexAppServerParams,\n ChatCompletionAdapter,\n ImagePreprocessPolicy,\n JsonParser,\n LocateAdapter,\n ModelAdapter,\n ModelAdapterDefinition,\n PlanningAdapter,\n ResolveImageDetail,\n ResponsesAdapter,\n} from './types';\n\nconst defaultImageDetail: ResolveImageDetail = ({ imageDetail }) =>\n imageDetail ?? 'high';\n\nfunction resolveJsonParser(\n jsonParser: ModelAdapterDefinition['jsonParser'],\n): JsonParser {\n if (!jsonParser || jsonParser === 'lenient-json') {\n return parseModelResponseJson;\n }\n\n if (typeof jsonParser === 'function') {\n return jsonParser;\n }\n\n throw new Error(`Unknown json parser preset: ${jsonParser}`);\n}\n\nfunction resolveImagePreprocess(\n imagePreprocess: ModelAdapterDefinition['imagePreprocess'],\n): ImagePreprocessPolicy {\n return {\n padBlockSize: imagePreprocess?.padBlockSize,\n };\n}\n\nexport class ResolvedModelAdapter implements ModelAdapter {\n readonly supportedProtocols: ModelAdapter['supportedProtocols'];\n readonly jsonParser: JsonParser;\n readonly chatCompletion: ChatCompletionAdapter;\n readonly resolveImageDetail: ResolveImageDetail;\n readonly responses: ResponsesAdapter;\n readonly buildCodexAppServerParams: BuildCodexAppServerParams;\n readonly imagePreprocess: ImagePreprocessPolicy;\n readonly insight: InsightAdapter;\n readonly planning: PlanningAdapter;\n readonly locate: LocateAdapter;\n\n constructor(config: ModelAdapterDefinition, modelFamily: string) {\n this.supportedProtocols = config.supportedProtocols ?? ['openai-chat'];\n this.jsonParser = resolveJsonParser(config.jsonParser);\n this.chatCompletion = resolveChatCompletion(config.chatCompletion);\n this.resolveImageDetail = config.resolveImageDetail ?? defaultImageDetail;\n this.responses = resolveResponses(config.responses);\n this.buildCodexAppServerParams =\n config.buildCodexAppServerParams ?? buildDefaultCodexAppServerParams;\n this.imagePreprocess = resolveImagePreprocess(config.imagePreprocess);\n this.insight = resolveInsight(config.insight, {\n jsonParser: this.jsonParser,\n });\n const customPlanner =\n config.planning?.kind === 'custom' ? config.planning.planner : undefined;\n const resolvedCustomPlanner = customPlanner\n ? resolveCustomPlanningDefinition(customPlanner)\n : undefined;\n this.locate = resolveLocate(config.locate, resolvedCustomPlanner, {\n jsonParser: this.jsonParser,\n });\n this.planning = resolvePlanning(\n config.planning,\n resolvedCustomPlanner,\n { jsonParser: this.jsonParser },\n this.locate.kind === 'standard'\n ? this.locate.element.resultCodec\n : undefined,\n );\n }\n}\n"],"names":["defaultImageDetail","imageDetail","resolveJsonParser","jsonParser","parseModelResponseJson","Error","resolveImagePreprocess","imagePreprocess","ResolvedModelAdapter","config","modelFamily","resolveChatCompletion","resolveResponses","buildDefaultCodexAppServerParams","resolveInsight","customPlanner","undefined","resolvedCustomPlanner","resolveCustomPlanningDefinition","resolveLocate","resolvePlanning"],"mappings":";;;;;;;;;;;;;;;;;AAqBA,MAAMA,qBAAyC,CAAC,EAAEC,WAAW,EAAE,GAC7DA,eAAe;AAEjB,SAASC,kBACPC,UAAgD;IAEhD,IAAI,CAACA,cAAcA,AAAe,mBAAfA,YACjB,OAAOC;IAGT,IAAI,AAAsB,cAAtB,OAAOD,YACT,OAAOA;IAGT,MAAM,IAAIE,MAAM,CAAC,4BAA4B,EAAEF,YAAY;AAC7D;AAEA,SAASG,uBACPC,eAA0D;IAE1D,OAAO;QACL,cAAcA,iBAAiB;IACjC;AACF;AAEO,MAAMC;IAYX,YAAYC,MAA8B,EAAEC,WAAmB,CAAE;QAXjE,uBAAS,sBAAT;QACA,uBAAS,cAAT;QACA,uBAAS,kBAAT;QACA,uBAAS,sBAAT;QACA,uBAAS,aAAT;QACA,uBAAS,6BAAT;QACA,uBAAS,mBAAT;QACA,uBAAS,WAAT;QACA,uBAAS,YAAT;QACA,uBAAS,UAAT;QAGE,IAAI,CAAC,kBAAkB,GAAGD,OAAO,kBAAkB,IAAI;YAAC;SAAc;QACtE,IAAI,CAAC,UAAU,GAAGP,kBAAkBO,OAAO,UAAU;QACrD,IAAI,CAAC,cAAc,GAAGE,sBAAsBF,OAAO,cAAc;QACjE,IAAI,CAAC,kBAAkB,GAAGA,OAAO,kBAAkB,IAAIT;QACvD,IAAI,CAAC,SAAS,GAAGY,iBAAiBH,OAAO,SAAS;QAClD,IAAI,CAAC,yBAAyB,GAC5BA,OAAO,yBAAyB,IAAII;QACtC,IAAI,CAAC,eAAe,GAAGP,uBAAuBG,OAAO,eAAe;QACpE,IAAI,CAAC,OAAO,GAAGK,eAAeL,OAAO,OAAO,EAAE;YAC5C,YAAY,IAAI,CAAC,UAAU;QAC7B;QACA,MAAMM,gBACJN,OAAO,QAAQ,EAAE,SAAS,WAAWA,OAAO,QAAQ,CAAC,OAAO,GAAGO;QACjE,MAAMC,wBAAwBF,gBAC1BG,gCAAgCH,iBAChCC;QACJ,IAAI,CAAC,MAAM,GAAGG,cAAcV,OAAO,MAAM,EAAEQ,uBAAuB;YAChE,YAAY,IAAI,CAAC,UAAU;QAC7B;QACA,IAAI,CAAC,QAAQ,GAAGG,gBACdX,OAAO,QAAQ,EACfQ,uBACA;YAAE,YAAY,IAAI,CAAC,UAAU;QAAC,GAC9B,AAAqB,eAArB,IAAI,CAAC,MAAM,CAAC,IAAI,GACZ,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,GAC/BD;IAER;AACF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getTemperatureWithSemanticRetry } from "./temperature-with-semantic-retry.mjs";
|
|
2
|
+
const midsceneResponsesDefaults = {
|
|
3
|
+
temperature: 0
|
|
4
|
+
};
|
|
5
|
+
const buildDefaultResponsesParams = ({ midsceneDefaults, userConfig })=>({
|
|
6
|
+
config: {
|
|
7
|
+
temperature: userConfig.temperature ?? midsceneDefaults.temperature
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
function resolveResponses(responses) {
|
|
11
|
+
const buildResponsesParams = responses?.buildResponsesParams ?? buildDefaultResponsesParams;
|
|
12
|
+
return {
|
|
13
|
+
replayRawAssistantOutput: responses?.replayRawAssistantOutput ?? false,
|
|
14
|
+
unsupportedUserConfig: responses?.unsupportedUserConfig ?? [],
|
|
15
|
+
buildResponsesParams: (input)=>{
|
|
16
|
+
const context = {
|
|
17
|
+
...input,
|
|
18
|
+
userConfig: input.userConfig ?? {},
|
|
19
|
+
midsceneDefaults: midsceneResponsesDefaults
|
|
20
|
+
};
|
|
21
|
+
const params = buildResponsesParams(context);
|
|
22
|
+
return {
|
|
23
|
+
...params,
|
|
24
|
+
config: {
|
|
25
|
+
...params.config,
|
|
26
|
+
temperature: getTemperatureWithSemanticRetry({
|
|
27
|
+
temperature: params.config.temperature,
|
|
28
|
+
userTemperature: input.userConfig?.temperature,
|
|
29
|
+
semanticRetryAttempt: input.semanticRetryAttempt
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export { buildDefaultResponsesParams, resolveResponses };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=responses.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-model/model-adapter/responses.mjs","sources":["../../../../src/ai-model/model-adapter/responses.ts"],"sourcesContent":["import { getTemperatureWithSemanticRetry } from './temperature-with-semantic-retry';\nimport type {\n BuildResponsesParams,\n MidsceneResponsesDefaults,\n ModelAdapterDefinition,\n ResponsesAdapter,\n} from './types';\n\nconst midsceneResponsesDefaults: MidsceneResponsesDefaults = {\n temperature: 0,\n};\n\nexport const buildDefaultResponsesParams: BuildResponsesParams = ({\n midsceneDefaults,\n userConfig,\n}) => ({\n config: {\n temperature: userConfig.temperature ?? midsceneDefaults.temperature,\n },\n});\n\nexport function resolveResponses(\n responses: ModelAdapterDefinition['responses'],\n): ResponsesAdapter {\n const buildResponsesParams =\n responses?.buildResponsesParams ?? buildDefaultResponsesParams;\n return {\n replayRawAssistantOutput: responses?.replayRawAssistantOutput ?? false,\n unsupportedUserConfig: responses?.unsupportedUserConfig ?? [],\n buildResponsesParams: (input) => {\n const context = {\n ...input,\n userConfig: input.userConfig ?? {},\n midsceneDefaults: midsceneResponsesDefaults,\n };\n const params = buildResponsesParams(context);\n return {\n ...params,\n config: {\n ...params.config,\n temperature: getTemperatureWithSemanticRetry({\n temperature: params.config.temperature,\n userTemperature: input.userConfig?.temperature,\n semanticRetryAttempt: input.semanticRetryAttempt,\n }),\n },\n };\n },\n };\n}\n"],"names":["midsceneResponsesDefaults","buildDefaultResponsesParams","midsceneDefaults","userConfig","resolveResponses","responses","buildResponsesParams","input","context","params","getTemperatureWithSemanticRetry"],"mappings":";AAQA,MAAMA,4BAAuD;IAC3D,aAAa;AACf;AAEO,MAAMC,8BAAoD,CAAC,EAChEC,gBAAgB,EAChBC,UAAU,EACX,GAAM;QACL,QAAQ;YACN,aAAaA,WAAW,WAAW,IAAID,iBAAiB,WAAW;QACrE;IACF;AAEO,SAASE,iBACdC,SAA8C;IAE9C,MAAMC,uBACJD,WAAW,wBAAwBJ;IACrC,OAAO;QACL,0BAA0BI,WAAW,4BAA4B;QACjE,uBAAuBA,WAAW,yBAAyB,EAAE;QAC7D,sBAAsB,CAACE;YACrB,MAAMC,UAAU;gBACd,GAAGD,KAAK;gBACR,YAAYA,MAAM,UAAU,IAAI,CAAC;gBACjC,kBAAkBP;YACpB;YACA,MAAMS,SAASH,qBAAqBE;YACpC,OAAO;gBACL,GAAGC,MAAM;gBACT,QAAQ;oBACN,GAAGA,OAAO,MAAM;oBAChB,aAAaC,gCAAgC;wBAC3C,aAAaD,OAAO,MAAM,CAAC,WAAW;wBACtC,iBAAiBF,MAAM,UAAU,EAAE;wBACnC,sBAAsBA,MAAM,oBAAoB;oBAClD;gBACF;YACF;QACF;IACF;AACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
function getTemperatureWithSemanticRetry({ temperature, userTemperature, semanticRetryAttempt = 0 }) {
|
|
2
|
+
if (semanticRetryAttempt > 0 && void 0 === userTemperature && 0 === temperature) return 0.2;
|
|
3
|
+
return temperature;
|
|
4
|
+
}
|
|
5
|
+
export { getTemperatureWithSemanticRetry };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=temperature-with-semantic-retry.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-model/model-adapter/temperature-with-semantic-retry.mjs","sources":["../../../../src/ai-model/model-adapter/temperature-with-semantic-retry.ts"],"sourcesContent":["export function getTemperatureWithSemanticRetry<T>({\n temperature,\n userTemperature,\n semanticRetryAttempt = 0,\n}: {\n temperature: T;\n userTemperature?: number;\n semanticRetryAttempt?: number;\n}): T | number {\n // Only perturb the default deterministic request after a semantic parse\n // failure: preserve an explicit user temperature, and avoid adding a\n // temperature to adapters whose normal parameters do not include one.\n if (\n semanticRetryAttempt > 0 &&\n userTemperature === undefined &&\n temperature === 0\n ) {\n return 0.2;\n }\n return temperature;\n}\n"],"names":["getTemperatureWithSemanticRetry","temperature","userTemperature","semanticRetryAttempt","undefined"],"mappings":"AAAO,SAASA,gCAAmC,EACjDC,WAAW,EACXC,eAAe,EACfC,uBAAuB,CAAC,EAKzB;IAIC,IACEA,uBAAuB,KACvBD,AAAoBE,WAApBF,mBACAD,AAAgB,MAAhBA,aAEA,OAAO;IAET,OAAOA;AACT"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isLocateIntent } from "./utils/intent.mjs";
|
|
2
|
-
const originalImageDetailForDefaultIntent = (input)=>isLocateIntent(input.intent) || input.requiresOriginalImageDetail ? 'original' :
|
|
2
|
+
const originalImageDetailForDefaultIntent = (input)=>isLocateIntent(input.intent) || input.requiresOriginalImageDetail ? 'original' : input.imageDetail ?? 'high';
|
|
3
3
|
const resolveGpt5ReasoningEffort = ({ reasoningEnabled, reasoningEffort })=>{
|
|
4
4
|
if ('default' === reasoningEnabled) return;
|
|
5
5
|
return true === reasoningEnabled ? reasoningEffort ?? 'medium' : 'none';
|
|
@@ -11,15 +11,56 @@ const resolveGpt6ReasoningEffort = ({ reasoningEnabled, reasoningEffort })=>{
|
|
|
11
11
|
const buildGpt5CodexAppServerParams = (input)=>({
|
|
12
12
|
config: {
|
|
13
13
|
effort: resolveGpt5ReasoningEffort(input.userConfig ?? {})
|
|
14
|
-
}
|
|
15
|
-
imageDetail: originalImageDetailForDefaultIntent(input)
|
|
14
|
+
}
|
|
16
15
|
});
|
|
17
16
|
const buildGpt6CodexAppServerParams = (input)=>({
|
|
18
17
|
config: {
|
|
19
18
|
effort: resolveGpt6ReasoningEffort(input.userConfig ?? {})
|
|
20
|
-
}
|
|
21
|
-
imageDetail: originalImageDetailForDefaultIntent(input)
|
|
19
|
+
}
|
|
22
20
|
});
|
|
21
|
+
const buildGpt5ResponsesParams = (input)=>{
|
|
22
|
+
const { midsceneDefaults, userConfig, expectedJsonObjectResponse } = input;
|
|
23
|
+
const commonOverrideConfig = {};
|
|
24
|
+
if (void 0 !== userConfig.temperature) commonOverrideConfig.temperature = userConfig.temperature;
|
|
25
|
+
if ('none' !== userConfig.responseFormat && expectedJsonObjectResponse) commonOverrideConfig.text = {
|
|
26
|
+
format: {
|
|
27
|
+
type: 'json_object'
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const effectiveReasoningEffort = resolveGpt5ReasoningEffort(userConfig);
|
|
31
|
+
return {
|
|
32
|
+
config: {
|
|
33
|
+
...midsceneDefaults,
|
|
34
|
+
...commonOverrideConfig,
|
|
35
|
+
reasoning: {
|
|
36
|
+
effort: effectiveReasoningEffort,
|
|
37
|
+
context: 'current_turn'
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
const buildGpt6ResponsesParams = (input)=>{
|
|
43
|
+
const { midsceneDefaults, userConfig, expectedJsonObjectResponse } = input;
|
|
44
|
+
const { responseFormat } = userConfig;
|
|
45
|
+
const commonOverrideConfig = {};
|
|
46
|
+
commonOverrideConfig.temperature = void 0;
|
|
47
|
+
if ('none' !== responseFormat && expectedJsonObjectResponse) commonOverrideConfig.text = {
|
|
48
|
+
format: {
|
|
49
|
+
type: 'json_object'
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const effectiveReasoningEffort = resolveGpt6ReasoningEffort(userConfig);
|
|
53
|
+
return {
|
|
54
|
+
config: {
|
|
55
|
+
...midsceneDefaults,
|
|
56
|
+
...commonOverrideConfig,
|
|
57
|
+
reasoning: {
|
|
58
|
+
effort: effectiveReasoningEffort,
|
|
59
|
+
context: 'current_turn'
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
};
|
|
23
64
|
const buildGpt5ChatCompletionParams = (input)=>{
|
|
24
65
|
const { midsceneDefaults, userConfig } = input;
|
|
25
66
|
const commonOverrideConfig = {};
|
|
@@ -55,13 +96,24 @@ const buildGpt6ChatCompletionParams = (input)=>{
|
|
|
55
96
|
};
|
|
56
97
|
const gptAdapters = {
|
|
57
98
|
'gpt-5': {
|
|
99
|
+
supportedProtocols: [
|
|
100
|
+
'openai-chat',
|
|
101
|
+
'openai-responses'
|
|
102
|
+
],
|
|
103
|
+
resolveImageDetail: originalImageDetailForDefaultIntent,
|
|
104
|
+
responses: {
|
|
105
|
+
replayRawAssistantOutput: false,
|
|
106
|
+
unsupportedUserConfig: [
|
|
107
|
+
'reasoningBudget'
|
|
108
|
+
],
|
|
109
|
+
buildResponsesParams: buildGpt5ResponsesParams
|
|
110
|
+
},
|
|
58
111
|
buildCodexAppServerParams: buildGpt5CodexAppServerParams,
|
|
59
112
|
chatCompletion: {
|
|
60
113
|
unsupportedUserConfig: [
|
|
61
114
|
'reasoningBudget'
|
|
62
115
|
],
|
|
63
|
-
buildChatCompletionParams: buildGpt5ChatCompletionParams
|
|
64
|
-
resolveImageDetail: originalImageDetailForDefaultIntent
|
|
116
|
+
buildChatCompletionParams: buildGpt5ChatCompletionParams
|
|
65
117
|
},
|
|
66
118
|
locate: {
|
|
67
119
|
element: {
|
|
@@ -75,14 +127,26 @@ const gptAdapters = {
|
|
|
75
127
|
}
|
|
76
128
|
},
|
|
77
129
|
'gpt-6': {
|
|
130
|
+
supportedProtocols: [
|
|
131
|
+
'openai-chat',
|
|
132
|
+
'openai-responses'
|
|
133
|
+
],
|
|
134
|
+
resolveImageDetail: originalImageDetailForDefaultIntent,
|
|
135
|
+
responses: {
|
|
136
|
+
replayRawAssistantOutput: false,
|
|
137
|
+
unsupportedUserConfig: [
|
|
138
|
+
'temperature',
|
|
139
|
+
'reasoningBudget'
|
|
140
|
+
],
|
|
141
|
+
buildResponsesParams: buildGpt6ResponsesParams
|
|
142
|
+
},
|
|
78
143
|
buildCodexAppServerParams: buildGpt6CodexAppServerParams,
|
|
79
144
|
chatCompletion: {
|
|
80
145
|
unsupportedUserConfig: [
|
|
81
146
|
'temperature',
|
|
82
147
|
'reasoningBudget'
|
|
83
148
|
],
|
|
84
|
-
buildChatCompletionParams: buildGpt6ChatCompletionParams
|
|
85
|
-
resolveImageDetail: originalImageDetailForDefaultIntent
|
|
149
|
+
buildChatCompletionParams: buildGpt6ChatCompletionParams
|
|
86
150
|
},
|
|
87
151
|
locate: {
|
|
88
152
|
element: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-model/models/gpt.mjs","sources":["../../../../src/ai-model/models/gpt.ts"],"sourcesContent":["import type { TModelFamily } from '@midscene/shared/env';\nimport type {\n ChatCompletionCallContext,\n ChatCompletionParamsResult,\n CodexAppServerCallInput,\n CodexAppServerParamsResult,\n
|
|
1
|
+
{"version":3,"file":"ai-model/models/gpt.mjs","sources":["../../../../src/ai-model/models/gpt.ts"],"sourcesContent":["import type { TModelFamily } from '@midscene/shared/env';\nimport type {\n BuildResponsesParams,\n ChatCompletionCallContext,\n ChatCompletionParamsResult,\n CodexAppServerCallInput,\n CodexAppServerParamsResult,\n ModelAdapterDefinition,\n ReasoningInput,\n ResolveImageDetail,\n} from '../model-adapter/types';\nimport { isLocateIntent } from './utils/intent';\n\nconst originalImageDetailForDefaultIntent: ResolveImageDetail = (input) =>\n isLocateIntent(input.intent) || input.requiresOriginalImageDetail\n ? 'original'\n : (input.imageDetail ?? 'high');\n\nconst resolveGpt5ReasoningEffort = ({\n reasoningEnabled,\n reasoningEffort,\n}: ReasoningInput): string | undefined => {\n if (reasoningEnabled === 'default') return undefined;\n return reasoningEnabled === true ? (reasoningEffort ?? 'medium') : 'none';\n};\n\n// Astra cannot disable reasoning; use its lowest effort when disabled.\nconst resolveGpt6ReasoningEffort = ({\n reasoningEnabled,\n reasoningEffort,\n}: ReasoningInput): string | undefined => {\n if (reasoningEnabled === 'default') return undefined;\n return reasoningEnabled === true ? (reasoningEffort ?? 'medium') : 'low';\n};\n\nconst buildGpt5CodexAppServerParams = (\n input: CodexAppServerCallInput,\n): CodexAppServerParamsResult => ({\n config: { effort: resolveGpt5ReasoningEffort(input.userConfig ?? {}) },\n});\n\nconst buildGpt6CodexAppServerParams = (\n input: CodexAppServerCallInput,\n): CodexAppServerParamsResult => ({\n config: { effort: resolveGpt6ReasoningEffort(input.userConfig ?? {}) },\n});\n\nconst buildGpt5ResponsesParams: BuildResponsesParams = (input) => {\n const { midsceneDefaults, userConfig, expectedJsonObjectResponse } = input;\n const commonOverrideConfig: Record<string, unknown> = {};\n\n if (userConfig.temperature !== undefined) {\n commonOverrideConfig.temperature = userConfig.temperature;\n }\n\n if (userConfig.responseFormat !== 'none' && expectedJsonObjectResponse) {\n commonOverrideConfig.text = { format: { type: 'json_object' } };\n }\n\n const effectiveReasoningEffort = resolveGpt5ReasoningEffort(userConfig);\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n // Use current-turn reasoning only. Switching to all_turns requires\n // responses.replayRawAssistantOutput to preserve reasoning history.\n reasoning: { effort: effectiveReasoningEffort, context: 'current_turn' },\n },\n };\n};\n\nconst buildGpt6ResponsesParams: BuildResponsesParams = (input) => {\n const { midsceneDefaults, userConfig, expectedJsonObjectResponse } = input;\n const { responseFormat } = userConfig;\n const commonOverrideConfig: Record<string, unknown> = {};\n // GPT-6 does not support temperature; omit it from the serialized request.\n commonOverrideConfig.temperature = undefined;\n if (responseFormat !== 'none' && expectedJsonObjectResponse) {\n commonOverrideConfig.text = { format: { type: 'json_object' } };\n }\n\n const effectiveReasoningEffort = resolveGpt6ReasoningEffort(userConfig);\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n // Use current-turn reasoning only. Switching to all_turns requires\n // responses.replayRawAssistantOutput to preserve reasoning history.\n reasoning: { effort: effectiveReasoningEffort, context: 'current_turn' },\n },\n };\n};\n\nconst buildGpt5ChatCompletionParams = (\n input: ChatCompletionCallContext,\n): ChatCompletionParamsResult => {\n const { midsceneDefaults, userConfig } = input;\n const commonOverrideConfig: Record<string, unknown> = {};\n\n if (userConfig.temperature !== undefined) {\n commonOverrideConfig.temperature = userConfig.temperature;\n }\n\n // OpenAI Chat Completions JSON mode:\n // https://platform.openai.com/docs/guides/structured-outputs?api-mode=chat#json-mode\n if (\n input.userConfig.responseFormat !== 'none' &&\n input.expectedJsonObjectResponse\n ) {\n commonOverrideConfig.response_format = { type: 'json_object' };\n }\n\n const effectiveReasoningEffort = resolveGpt5ReasoningEffort(userConfig);\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n reasoning_effort: effectiveReasoningEffort,\n },\n };\n};\n\nconst buildGpt6ChatCompletionParams = (\n input: ChatCompletionCallContext,\n): ChatCompletionParamsResult => {\n const { midsceneDefaults, userConfig, expectedJsonObjectResponse } = input;\n const { responseFormat } = userConfig;\n const commonOverrideConfig: Record<string, unknown> = {};\n // GPT-6 does not support temperature; omit it from the serialized request.\n commonOverrideConfig.temperature = undefined;\n if (responseFormat !== 'none' && expectedJsonObjectResponse) {\n commonOverrideConfig.response_format = { type: 'json_object' };\n }\n\n const effectiveReasoningEffort = resolveGpt6ReasoningEffort(userConfig);\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n reasoning_effort: effectiveReasoningEffort,\n },\n };\n};\n\nexport const gptAdapters = {\n 'gpt-5': {\n supportedProtocols: ['openai-chat', 'openai-responses'],\n resolveImageDetail: originalImageDetailForDefaultIntent,\n responses: {\n replayRawAssistantOutput: false,\n unsupportedUserConfig: ['reasoningBudget'],\n buildResponsesParams: buildGpt5ResponsesParams,\n },\n buildCodexAppServerParams: buildGpt5CodexAppServerParams,\n chatCompletion: {\n unsupportedUserConfig: ['reasoningBudget'],\n buildChatCompletionParams: buildGpt5ChatCompletionParams,\n },\n locate: {\n element: {\n resultFormat: {\n coordinates: { shape: 'bbox', order: 'xy' },\n },\n },\n },\n },\n 'gpt-6': {\n supportedProtocols: ['openai-chat', 'openai-responses'],\n resolveImageDetail: originalImageDetailForDefaultIntent,\n responses: {\n replayRawAssistantOutput: false,\n unsupportedUserConfig: ['temperature', 'reasoningBudget'],\n buildResponsesParams: buildGpt6ResponsesParams,\n },\n buildCodexAppServerParams: buildGpt6CodexAppServerParams,\n chatCompletion: {\n unsupportedUserConfig: ['temperature', 'reasoningBudget'],\n buildChatCompletionParams: buildGpt6ChatCompletionParams,\n },\n locate: {\n element: {\n resultFormat: {\n coordinates: { shape: 'bbox', order: 'xy' },\n },\n },\n },\n },\n} satisfies Pick<\n Record<TModelFamily, ModelAdapterDefinition>,\n 'gpt-5' | 'gpt-6'\n>;\n"],"names":["originalImageDetailForDefaultIntent","input","isLocateIntent","resolveGpt5ReasoningEffort","reasoningEnabled","reasoningEffort","resolveGpt6ReasoningEffort","buildGpt5CodexAppServerParams","buildGpt6CodexAppServerParams","buildGpt5ResponsesParams","midsceneDefaults","userConfig","expectedJsonObjectResponse","commonOverrideConfig","undefined","effectiveReasoningEffort","buildGpt6ResponsesParams","responseFormat","buildGpt5ChatCompletionParams","buildGpt6ChatCompletionParams","gptAdapters"],"mappings":";AAaA,MAAMA,sCAA0D,CAACC,QAC/DC,eAAeD,MAAM,MAAM,KAAKA,MAAM,2BAA2B,GAC7D,aACCA,MAAM,WAAW,IAAI;AAE5B,MAAME,6BAA6B,CAAC,EAClCC,gBAAgB,EAChBC,eAAe,EACA;IACf,IAAID,AAAqB,cAArBA,kBAAgC;IACpC,OAAOA,AAAqB,SAArBA,mBAA6BC,mBAAmB,WAAY;AACrE;AAGA,MAAMC,6BAA6B,CAAC,EAClCF,gBAAgB,EAChBC,eAAe,EACA;IACf,IAAID,AAAqB,cAArBA,kBAAgC;IACpC,OAAOA,AAAqB,SAArBA,mBAA6BC,mBAAmB,WAAY;AACrE;AAEA,MAAME,gCAAgC,CACpCN,QACgC;QAChC,QAAQ;YAAE,QAAQE,2BAA2BF,MAAM,UAAU,IAAI,CAAC;QAAG;IACvE;AAEA,MAAMO,gCAAgC,CACpCP,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2BW;QAC7B;QACA,QAAQ;YACN,SAAS;gBACP,cAAc;oBACZ,aAAa;wBAAE,OAAO;wBAAQ,OAAO;oBAAK;gBAC5C;YACF;QACF;IACF;AACF"}
|
|
@@ -63,7 +63,6 @@ const buildQwen25ChatCompletionParams = (input)=>{
|
|
|
63
63
|
};
|
|
64
64
|
};
|
|
65
65
|
const qwen3Adapter = {
|
|
66
|
-
acceptBbox2dAlias: true,
|
|
67
66
|
chatCompletion: {
|
|
68
67
|
unsupportedUserConfig: [
|
|
69
68
|
'reasoningEffort'
|
|
@@ -81,6 +80,10 @@ const qwen3Adapter = {
|
|
|
81
80
|
locate: {
|
|
82
81
|
element: {
|
|
83
82
|
resultFormat: {
|
|
83
|
+
resultKey: 'bbox_2d',
|
|
84
|
+
resultKeyAliases: [
|
|
85
|
+
'bbox'
|
|
86
|
+
],
|
|
84
87
|
coordinates: qwen3BboxCoordinatesMeta
|
|
85
88
|
}
|
|
86
89
|
}
|
|
@@ -88,7 +91,6 @@ const qwen3Adapter = {
|
|
|
88
91
|
};
|
|
89
92
|
const qwenAdapters = {
|
|
90
93
|
'qwen2.5-vl': {
|
|
91
|
-
acceptBbox2dAlias: true,
|
|
92
94
|
chatCompletion: {
|
|
93
95
|
unsupportedUserConfig: [
|
|
94
96
|
'reasoningEnabled',
|
|
@@ -103,6 +105,10 @@ const qwenAdapters = {
|
|
|
103
105
|
locate: {
|
|
104
106
|
element: {
|
|
105
107
|
resultFormat: {
|
|
108
|
+
resultKey: 'bbox_2d',
|
|
109
|
+
resultKeyAliases: [
|
|
110
|
+
'bbox'
|
|
111
|
+
],
|
|
106
112
|
coordinates: qwen25BboxCoordinatesMeta,
|
|
107
113
|
parseRawLocateValue: parseQwen25RawLocateValue
|
|
108
114
|
}
|