@xopcai/xopc 0.0.366 → 0.0.367
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/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-SVmnh__i.js → activity-store-Cuf3JFFJ.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CS9lg5h2.js → agent-avatar-dicebear-DyATPNTe.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-gT9_j4tr.js +1 -0
- package/dist/gateway/static/root/assets/agent-plugin-dialog-CLXCJ6JN.js +1 -0
- package/dist/gateway/static/root/assets/agents-BAUfOMsq.js +66 -0
- package/dist/gateway/static/root/assets/{agents-admin-api-CVdFV-cU.js → agents-admin-api-D842OcNo.js} +1 -1
- package/dist/gateway/static/root/assets/app-link-4gpFbdsr.js +1 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-CaxnUxvy.js → app-management-settings-panel-CoIFxQKH.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-6NKquG3v.js → appearance-settings-DQr0o6Lm.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-BoB3MbsB.js → apps-page-CltMV4Xp.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-BWtLZtK1.js → archive-plugin-DT8Nio-r.js} +1 -1
- package/dist/gateway/static/root/assets/automation-display-DCkjVzA0.js +2 -0
- package/dist/gateway/static/root/assets/{automations-page-CNngHw2c.js → automations-page-BIfWS_3Y.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-BCGPjsdU.js +6 -0
- package/dist/gateway/static/root/assets/binary-plugins-7qs3qcW9.js +2 -0
- package/dist/gateway/static/root/assets/{block-editor-BhstSZNE.js → block-editor-BFPUlxJ6.js} +28 -28
- package/dist/gateway/static/root/assets/{browser-automation-inputs-B6sOBxVA.js → browser-automation-inputs-BUAIKIX0.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-HZAKkVVt.js → browser-automations-page-CSwu1U1F.js} +2 -2
- package/dist/gateway/static/root/assets/browser-settings-page-C1ReMNqX.js +3 -0
- package/dist/gateway/static/root/assets/capabilities-BzWFO_x_.js +1 -0
- package/dist/gateway/static/root/assets/{capabilities-CAIQmCrH.js → capabilities-K0Zb_lH0.js} +1 -1
- package/dist/gateway/static/root/assets/capabilities-page-BdTSqloI.js +2 -0
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-BP2roWcM.js → capabilities-settings-panel-BUblBMZC.js} +4 -4
- package/dist/gateway/static/root/assets/{capability-header-actions-BA1M7RRP.js → capability-header-actions-AMn_vTNv.js} +1 -1
- package/dist/gateway/static/root/assets/channels-CXCf5qO6.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-KS_yk1H7.js → chat-terminal-dock-C7nAROhF.js} +2 -2
- package/dist/gateway/static/root/assets/chevron-left-DqFhpbvK.js +1 -0
- package/dist/gateway/static/root/assets/computer-settings-page-B5SuSZ3G.js +1 -0
- package/dist/gateway/static/root/assets/{connector-service-page-CY_3H_l9.js → connector-service-page-CTx1B8wx.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-DfnK1crf.js +2 -0
- package/dist/gateway/static/root/assets/date-formatters-CUZAyDEg.js +1 -0
- package/dist/gateway/static/root/assets/date-picker-Cx_xIKvN.js +1 -0
- package/dist/gateway/static/root/assets/{dependency-picker-CyNH4m20.js → dependency-picker-DYm96PDu.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-BsZQsQ2_.js → desktop-pet-D90OzgeR.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DMgkUy6g.js → desktop-pet-settings-CmdCecjm.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-JjbUN8y-.js → device-pairing-wizard-s2ogSa4l.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-CBTI3tKh.js → directory-picker-path-field-DZpaoeNa.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-C7nSpOKj.js → extension-debug-page-Bv6QE8kC.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BYUjAvsZ.js → extension-page-CEsq71Cm.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-DaLt3bC-.js → extension-provider-CX-sK0Tw.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-CRasspq0.js → extension-settings-page-UyOHF39P.js} +1 -1
- package/dist/gateway/static/root/assets/{fallback-models-BLJFYASE.js → fallback-models-CKv_Wqg8.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-DIIzvDLQ.js → gateway-config-swr-Cjnkle5J.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-DD70L42G.js → gateway-realtime-DCCLdyQD.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-C_Th8kGg.js +1 -0
- package/dist/gateway/static/root/assets/gateway-settings-CZ73IpbP.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-D_EwU7-6.js → gateway-startup-retry-CXKmdVzN.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-BQWq4kYi.js +2 -0
- package/dist/gateway/static/root/assets/{image-generation-api-BkK22JsL.js → image-generation-api-NLHzm4Nc.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-YJKcTKKr.js → imports-page-C7qvlBTQ.js} +1 -1
- package/dist/gateway/static/root/assets/index-BQgqzhQj.js +106 -0
- package/dist/gateway/static/root/assets/index-COB4QIJp.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BG_kM_Rm.js → keyboard-shortcuts-settings-pkgFWJb-.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-dMDhZXAi.js +1 -0
- package/dist/gateway/static/root/assets/{local-apps-page-jqthjcQO.js → local-apps-page-TpUAfOn2.js} +1 -1
- package/dist/gateway/static/root/assets/{local-session-drafts-C4et6msJ.js → local-session-drafts-Cvv7I0fw.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-CvNO-hbt.js → locale-store-C8TMD2gn.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-B-Y9oZLh.js +2 -0
- package/dist/gateway/static/root/assets/management-settings-B2lzsw6X.js +1 -0
- package/dist/gateway/static/root/assets/markdown-view-Dse7rkio.js +201 -0
- package/dist/gateway/static/root/assets/{media-plugins-C25mOgs2.js → media-plugins-BZrnzaBM.js} +1 -1
- package/dist/gateway/static/root/assets/messages-Dy26npMy.js +3 -0
- package/dist/gateway/static/root/assets/models-hub-cache-B1C86nRp.js +1 -0
- package/dist/gateway/static/root/assets/note-detail-panel-DL__qP6U.js +5 -0
- package/dist/gateway/static/root/assets/{notes-api-CKLw9vjk.js → notes-api-DKiVeQKG.js} +1 -1
- package/dist/gateway/static/root/assets/notes-page-DTBbg9Hs.js +8 -0
- package/dist/gateway/static/root/assets/{oauth-api-CC5KkSgG.js → oauth-api-BwpzpRwC.js} +1 -1
- package/dist/gateway/static/root/assets/open-route-MyZ2sB9C.js +1 -0
- package/dist/gateway/static/root/assets/{page-context-capture-button-KX9mrcJW.js → page-context-capture-button-Cxzd4QPB.js} +1 -1
- package/dist/gateway/static/root/assets/personal-page-CzaTnHeD.js +1 -0
- package/dist/gateway/static/root/assets/product-open-page-D4hoEWiu.js +1 -0
- package/dist/gateway/static/root/assets/product-preview-content-aR38El2E.js +1 -0
- package/dist/gateway/static/root/assets/project-detail-page-D20QH4YB.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-Bf3BIcT6.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-CiN49wvk.js → registry-api-AdnxowbH.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CKxqncqW.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-wZjlSBiM.js → runtime-tools-settings-panel-CBN3raz1.js} +1 -1
- package/dist/gateway/static/root/assets/scenes-page-Cv_5ozfX.js +2 -0
- package/dist/gateway/static/root/assets/{schema-form-CMB61TV1.js → schema-form-CxrMGsT9.js} +1 -1
- package/dist/gateway/static/root/assets/{send-session-input-jH6MQwdZ.js → send-session-input-CgOzhDZ0.js} +1 -1
- package/dist/gateway/static/root/assets/{session-api-CW2X7g_U.js → session-api-_HIN8or3.js} +1 -1
- package/dist/gateway/static/root/assets/session-manager-CzCto5zT.js +16 -0
- package/dist/gateway/static/root/assets/sessions-page-DZcu6NLJ.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-DazqeDQ7.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-Ch71KQjb.js → settings-page-D8Q3H3-o.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-DvLMMiuS.js +1 -0
- package/dist/gateway/static/root/assets/{share-link-dialog-DCSmx-Rl.js → share-link-dialog-Dg5os066.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-C93IM3QK.js → share-preview-page-DMvohAyr.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-api-B4rLfG3l.js → shares-api-C96IO4qJ.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-C_6idV8e.js → shares-settings-CsDATuCw.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-sKX8SSlQ.js → skill-api-C10ML0CH.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-Ro-s69NW.js → skill-reload-api-DNbJzSfB.js} +1 -1
- package/dist/gateway/static/root/assets/skills-page-DObMKvA6.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-DIjaUlla.js → system-settings-panel-Bn3khdzb.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-BR2L1L8l.js +2 -0
- package/dist/gateway/static/root/assets/task-expandable-content-DL2Q2gre.js +1 -0
- package/dist/gateway/static/root/assets/{tasks-CH6KoBeY.js → tasks-DwKXgZ-I.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-DbRLBHVY.js → theme-store-DQ6KJa4l.js} +1 -1
- package/dist/gateway/static/root/assets/{tracing-settings-page-IgY26AYH.js → tracing-settings-page-Ed8_GYUT.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-CgARwbus.js → tunnel-api-D3X8jDwo.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-CKju62Cm.js → usage-page-BqzRyyb9.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-C889OTsP.js → use-autosave-CRFefpzO.js} +1 -1
- package/dist/gateway/static/root/assets/use-composer-attachments-OLrvSjn5.js +2 -0
- package/dist/gateway/static/root/assets/{use-file-preview-expanded-BOpcSApw.js → use-file-preview-expanded-CJvzfQvw.js} +2 -2
- package/dist/gateway/static/root/assets/user-model-page-CG6wqIKP.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-evWflGY6.js → voice-api-key-field-R9zNWYR_.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-CZoV2Lt4.js → voice-config-api-DLudE9Rc.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-B2-2F39_.js → work-discovery-overlay-DVmQrolV.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-cOGM8Nug.js → workflow-run-setup-panel-DEkmuD3T.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-pqCB3sh4.js +6 -0
- package/dist/gateway/static/root/assets/workspace-api-CdVUhyPo.js +2 -0
- package/dist/gateway/static/root/index.html +32 -30
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/automations.js +1 -0
- package/dist/packages/gateway-contract/src/home.js +14 -0
- package/dist/packages/gateway-contract/src/index.js +2 -0
- package/dist/packages/gateway-contract/src/notifications.js +2 -1
- package/dist/packages/gateway-contract/src/personal-proactivity.js +139 -0
- package/dist/packages/image-providers/src/catalog.js +373 -0
- package/dist/packages/image-providers/src/execute.js +372 -0
- package/dist/packages/image-providers/src/http.js +94 -0
- package/dist/packages/image-providers/src/index.js +5 -0
- package/dist/packages/image-providers/src/types.d.ts +95 -0
- package/dist/packages/image-providers/src/validation.js +52 -0
- package/dist/src/agent/commands/command-registry.js +1 -1
- package/dist/src/agent/failover-error.d.ts +1 -1
- package/dist/src/agent/failover-error.js +7 -0
- package/dist/src/agent/image/generation/native-provider.d.ts +2 -0
- package/dist/src/agent/image/generation/native-provider.js +118 -0
- package/dist/src/agent/image/generation/openai-images-provider.d.ts +1 -1
- package/dist/src/agent/image/generation/openai-images-provider.js +48 -32
- package/dist/src/agent/image/generation/provider-registry.js +4 -13
- package/dist/src/agent/image/generation/providers/xopc-cloud.js +5 -34
- package/dist/src/agent/image/generation/runtime-types.d.ts +2 -4
- package/dist/src/agent/image/generation/runtime.js +28 -23
- package/dist/src/agent/image/generation/types.d.ts +3 -50
- package/dist/src/agent/image/generation/validation.d.ts +6 -0
- package/dist/src/agent/image/generation/validation.js +16 -0
- package/dist/src/agent/tools/factory.js +5 -0
- package/dist/src/agent/tools/image-generate-tool.js +5 -19
- package/dist/src/agent/tools/personal-attention-tool.d.ts +21 -0
- package/dist/src/agent/tools/personal-attention-tool.js +191 -0
- package/dist/src/automations/capabilities/write.d.ts +2 -0
- package/dist/src/automations/domain/types.d.ts +1 -1
- package/dist/src/automations/domain/validation.d.ts +4 -0
- package/dist/src/automations/domain/validation.js +1 -0
- package/dist/src/automations/draft/automation-draft-validator.d.ts +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/models.js +3 -8
- package/dist/src/config/models-json.d.ts +170 -0
- package/dist/src/config/models-json.js +23 -8
- package/dist/src/files/file-service.d.ts +6 -0
- package/dist/src/files/file-service.js +38 -1
- package/dist/src/gateway/custom-image-providers.d.ts +34 -0
- package/dist/src/gateway/file-path-classifier.js +12 -3
- package/dist/src/gateway/hono/routes/files.js +13 -2
- package/dist/src/gateway/hono/routes/personal-agent.js +41 -0
- package/dist/src/gateway/service.d.ts +1 -0
- package/dist/src/gateway/service.js +50 -11
- package/dist/src/home-intelligence/host.js +2 -2
- package/dist/src/notifications/planner.js +32 -0
- package/dist/src/notifications/service.d.ts +2 -0
- package/dist/src/personal-agent/notifications.d.ts +4 -0
- package/dist/src/personal-agent/notifications.js +40 -0
- package/dist/src/personal-agent/policy.d.ts +1 -1
- package/dist/src/personal-agent/policy.js +2 -0
- package/dist/src/personal-agent/proactivity/automation.d.ts +3 -0
- package/dist/src/personal-agent/proactivity/automation.js +41 -0
- package/dist/src/personal-agent/proactivity/follow-up-request.d.ts +5 -0
- package/dist/src/personal-agent/proactivity/follow-up-request.js +44 -0
- package/dist/src/personal-agent/proactivity/repository.d.ts +128 -0
- package/dist/src/personal-agent/proactivity/repository.js +403 -0
- package/dist/src/personal-agent/proactivity/routes.d.ts +3 -0
- package/dist/src/personal-agent/proactivity/routes.js +182 -0
- package/dist/src/personal-agent/proactivity/service.d.ts +32 -0
- package/dist/src/personal-agent/proactivity/service.js +496 -0
- package/dist/src/personal-agent/prompts.js +13 -2
- package/dist/src/personal-agent/reply-composer.js +2 -2
- package/dist/src/personal-agent/unread.d.ts +10 -0
- package/dist/src/personal-agent/unread.js +43 -0
- package/dist/src/providers/env-keys.js +6 -0
- package/dist/src/providers/model-catalog-persistence.js +3 -22
- package/dist/src/providers/model-catalog-store.js +1 -8
- package/dist/src/providers/model-catalog-types.d.ts +1 -9
- package/dist/src/providers/xopc-cloud-model-source.js +4 -25
- package/dist/src/session/client-history.d.ts +2 -0
- package/dist/src/session/client-history.js +26 -0
- package/dist/src/session/session-context-for-llm.js +28 -0
- package/dist/src/storage/sqlite/migrations/236_personal_proactivity.sql +53 -0
- package/dist/src/storage/sqlite/migrations/237_personal_strategy_versions.sql +18 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/tasks/home-query-service.js +27 -1
- package/dist/src/voice/platform-catalog.d.ts +1 -9
- package/package.json +4 -3
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CvUPtxS4.js +0 -1
- package/dist/gateway/static/root/assets/agent-plugin-dialog-1tRxDfjI.js +0 -1
- package/dist/gateway/static/root/assets/agents-gdT0whx9.js +0 -66
- package/dist/gateway/static/root/assets/app-link-DRL0YnPs.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-BKHsdiQ8.js +0 -7
- package/dist/gateway/static/root/assets/binary-plugins-fIhH-wg6.js +0 -2
- package/dist/gateway/static/root/assets/browser-settings-page-D8IpVQI6.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-C4grvUkw.js +0 -1
- package/dist/gateway/static/root/assets/capabilities-page-DK8FJRW4.js +0 -2
- package/dist/gateway/static/root/assets/channels-EQGCxr8W.js +0 -1
- package/dist/gateway/static/root/assets/computer-settings-page-CGBR0KFw.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-CUOL6JX0.js +0 -2
- package/dist/gateway/static/root/assets/date-picker-CDSZ-PWV.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-DeUVEPPE.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-B9n5naCr.js +0 -1
- package/dist/gateway/static/root/assets/home-page-BP6qAgBt.js +0 -1
- package/dist/gateway/static/root/assets/index-6JNNrzCq.js +0 -106
- package/dist/gateway/static/root/assets/index-CbJNcWAn.css +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-lHi21M1T.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-CH7W-dm5.js +0 -2
- package/dist/gateway/static/root/assets/management-settings-DVgI_KNm.js +0 -1
- package/dist/gateway/static/root/assets/markdown-view-DDJlD5jR.js +0 -201
- package/dist/gateway/static/root/assets/messages-pGa2qMzG.js +0 -3
- package/dist/gateway/static/root/assets/models-hub-cache-DzFiL4xV.js +0 -1
- package/dist/gateway/static/root/assets/note-detail-panel-kyX-n1db.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-CLZygZlm.js +0 -8
- package/dist/gateway/static/root/assets/personal-page-DnXlcJNJ.js +0 -1
- package/dist/gateway/static/root/assets/product-open-page-D7pknlCh.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-DhV9DPj8.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-D181xkFw.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CQnBARQW.js +0 -1
- package/dist/gateway/static/root/assets/scenes-page-DWt54veq.js +0 -2
- package/dist/gateway/static/root/assets/session-manager-BDpdi3lF.js +0 -16
- package/dist/gateway/static/root/assets/sessions-page-DPEdjUdR.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-B6WGnTLY.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-C7sLy8Hl.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-TsrjLYcI.js +0 -2
- package/dist/gateway/static/root/assets/task-detail-page-B4Lby289.js +0 -2
- package/dist/gateway/static/root/assets/use-composer-attachments-Dlm9EFTO.js +0 -2
- package/dist/gateway/static/root/assets/user-model-page-CTkCLRhE.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-Csk8xrRk.js +0 -6
- package/dist/gateway/static/root/assets/workspace-api-B9M9ECTB.js +0 -2
- package/dist/src/agent/image/generation/normalization.d.ts +0 -38
- package/dist/src/agent/image/generation/normalization.js +0 -181
- package/dist/src/agent/image/generation/providers/dashscope.d.ts +0 -35
- package/dist/src/agent/image/generation/providers/dashscope.js +0 -257
- package/dist/src/agent/image/generation/providers/fal.d.ts +0 -15
- package/dist/src/agent/image/generation/providers/fal.js +0 -323
- package/dist/src/agent/image/generation/providers/google.d.ts +0 -16
- package/dist/src/agent/image/generation/providers/google.js +0 -244
- package/dist/src/agent/image/generation/providers/minimax.d.ts +0 -23
- package/dist/src/agent/image/generation/providers/minimax.js +0 -215
- package/dist/src/agent/image/generation/providers/openai.d.ts +0 -5
- package/dist/src/agent/image/generation/providers/openai.js +0 -134
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import { resolveClosestAspectRatio, resolveClosestResolution, resolveClosestSize } from "../../media-generation/runtime-shared.js";
|
|
2
|
-
import "../../media-generation/index.js";
|
|
3
|
-
//#region src/agent/image/generation/normalization.ts
|
|
4
|
-
/**
|
|
5
|
-
* Image-generation parameter normalization.
|
|
6
|
-
*
|
|
7
|
-
* Reconciles user-supplied geometry / output overrides against the active
|
|
8
|
-
* provider's declared {@link ImageGenerationProviderCapabilities}. Returns:
|
|
9
|
-
* - the actually-applied values to forward to the provider
|
|
10
|
-
* - per-field {@link MediaNormalizationEntry} (requested / applied / derivedFrom)
|
|
11
|
-
* - a list of {@link ImageGenerationIgnoredOverride} entries for unsupported
|
|
12
|
-
* soft fields (so the LLM / UI can surface a Note)
|
|
13
|
-
*
|
|
14
|
-
* Hard errors (unsupported edit, too many input images) are thrown so the
|
|
15
|
-
* caller can fail fast — they are NOT downgraded to ignored overrides.
|
|
16
|
-
*
|
|
17
|
-
* Decision table — see docs/image-generation-rearchitecture.md §6.3
|
|
18
|
-
*/
|
|
19
|
-
function resolveImageGenerationOverrides(params) {
|
|
20
|
-
const provider = params.provider;
|
|
21
|
-
const caps = provider.capabilities ?? {};
|
|
22
|
-
const isEdit = (params.inputImages?.length ?? 0) > 0;
|
|
23
|
-
assertEditSupported(provider, isEdit, params.inputImages);
|
|
24
|
-
const modeCaps = isEdit ? caps.edit : caps.generate;
|
|
25
|
-
const supportsSize = modeCaps?.supportsSize === true;
|
|
26
|
-
const supportsAspectRatio = modeCaps?.supportsAspectRatio === true;
|
|
27
|
-
const supportsResolution = caps.generate?.supportsResolution === true && !isEdit;
|
|
28
|
-
const ignoredOverrides = [];
|
|
29
|
-
const normalization = {};
|
|
30
|
-
const { size, aspectRatio, resolution } = resolveGeometry({
|
|
31
|
-
requestedSize: params.size,
|
|
32
|
-
requestedAspectRatio: params.aspectRatio,
|
|
33
|
-
requestedResolution: params.resolution,
|
|
34
|
-
supportsSize,
|
|
35
|
-
supportsAspectRatio,
|
|
36
|
-
supportsResolution,
|
|
37
|
-
geometry: caps.geometry,
|
|
38
|
-
ignoredOverrides,
|
|
39
|
-
normalization
|
|
40
|
-
});
|
|
41
|
-
const quality = filterEnumOverride({
|
|
42
|
-
key: "quality",
|
|
43
|
-
requested: params.quality,
|
|
44
|
-
supported: caps.output?.qualities,
|
|
45
|
-
ignoredOverrides
|
|
46
|
-
});
|
|
47
|
-
const outputFormat = filterEnumOverride({
|
|
48
|
-
key: "outputFormat",
|
|
49
|
-
requested: params.outputFormat,
|
|
50
|
-
supported: caps.output?.formats,
|
|
51
|
-
ignoredOverrides
|
|
52
|
-
});
|
|
53
|
-
const background = filterEnumOverride({
|
|
54
|
-
key: "background",
|
|
55
|
-
requested: params.background,
|
|
56
|
-
supported: caps.output?.backgrounds,
|
|
57
|
-
ignoredOverrides
|
|
58
|
-
});
|
|
59
|
-
return {
|
|
60
|
-
...size !== void 0 ? { size } : {},
|
|
61
|
-
...aspectRatio !== void 0 ? { aspectRatio } : {},
|
|
62
|
-
...resolution !== void 0 ? { resolution } : {},
|
|
63
|
-
...quality !== void 0 ? { quality } : {},
|
|
64
|
-
...outputFormat !== void 0 ? { outputFormat } : {},
|
|
65
|
-
...background !== void 0 ? { background } : {},
|
|
66
|
-
ignoredOverrides,
|
|
67
|
-
...hasAnyEntry(normalization) ? { normalization } : {}
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
function resolveGeometry(params) {
|
|
71
|
-
const supportedSizes = params.geometry?.sizes;
|
|
72
|
-
const supportedAspectRatios = params.geometry?.aspectRatios;
|
|
73
|
-
const supportedResolutions = params.geometry?.resolutions;
|
|
74
|
-
let size;
|
|
75
|
-
let aspectRatio;
|
|
76
|
-
let resolution;
|
|
77
|
-
if (params.requestedSize) if (params.supportsSize) {
|
|
78
|
-
const applied = resolveClosestSize({
|
|
79
|
-
requestedSize: params.requestedSize,
|
|
80
|
-
supportedSizes
|
|
81
|
-
});
|
|
82
|
-
if (applied) {
|
|
83
|
-
size = applied;
|
|
84
|
-
params.normalization.size = entry({
|
|
85
|
-
requested: params.requestedSize,
|
|
86
|
-
applied,
|
|
87
|
-
supportedValues: supportedSizes
|
|
88
|
-
});
|
|
89
|
-
} else size = params.requestedSize;
|
|
90
|
-
} else if (params.supportsAspectRatio) {
|
|
91
|
-
const derived = resolveClosestAspectRatio({
|
|
92
|
-
requestedSize: params.requestedSize,
|
|
93
|
-
supportedAspectRatios
|
|
94
|
-
});
|
|
95
|
-
if (derived) {
|
|
96
|
-
aspectRatio = derived;
|
|
97
|
-
params.normalization.aspectRatio = entry({
|
|
98
|
-
applied: derived,
|
|
99
|
-
derivedFrom: "size",
|
|
100
|
-
supportedValues: supportedAspectRatios
|
|
101
|
-
});
|
|
102
|
-
} else ignored(params.ignoredOverrides, "size", params.requestedSize);
|
|
103
|
-
} else ignored(params.ignoredOverrides, "size", params.requestedSize);
|
|
104
|
-
if (params.requestedAspectRatio) {
|
|
105
|
-
if (params.supportsAspectRatio) {
|
|
106
|
-
const finalApplied = resolveClosestAspectRatio({
|
|
107
|
-
requestedAspectRatio: params.requestedAspectRatio,
|
|
108
|
-
supportedAspectRatios
|
|
109
|
-
}) ?? params.requestedAspectRatio;
|
|
110
|
-
aspectRatio = finalApplied;
|
|
111
|
-
params.normalization.aspectRatio = entry({
|
|
112
|
-
requested: params.requestedAspectRatio,
|
|
113
|
-
applied: finalApplied,
|
|
114
|
-
supportedValues: supportedAspectRatios
|
|
115
|
-
});
|
|
116
|
-
} else if (params.supportsSize && size === void 0) {
|
|
117
|
-
const derived = resolveClosestSize({
|
|
118
|
-
requestedAspectRatio: params.requestedAspectRatio,
|
|
119
|
-
supportedSizes
|
|
120
|
-
});
|
|
121
|
-
if (derived) {
|
|
122
|
-
size = derived;
|
|
123
|
-
params.normalization.size = entry({
|
|
124
|
-
applied: derived,
|
|
125
|
-
derivedFrom: "aspectRatio",
|
|
126
|
-
supportedValues: supportedSizes
|
|
127
|
-
});
|
|
128
|
-
} else ignored(params.ignoredOverrides, "aspectRatio", params.requestedAspectRatio);
|
|
129
|
-
} else if (!params.supportsSize) ignored(params.ignoredOverrides, "aspectRatio", params.requestedAspectRatio);
|
|
130
|
-
if (!params.supportsAspectRatio && params.supportsSize && size !== void 0 && params.normalization.size?.derivedFrom !== "aspectRatio") ignored(params.ignoredOverrides, "aspectRatio", params.requestedAspectRatio);
|
|
131
|
-
}
|
|
132
|
-
if (params.requestedResolution) if (params.supportsResolution) {
|
|
133
|
-
const finalApplied = resolveClosestResolution({
|
|
134
|
-
requestedResolution: params.requestedResolution,
|
|
135
|
-
supportedResolutions
|
|
136
|
-
}) ?? params.requestedResolution;
|
|
137
|
-
resolution = finalApplied;
|
|
138
|
-
params.normalization.resolution = entry({
|
|
139
|
-
requested: params.requestedResolution,
|
|
140
|
-
applied: finalApplied,
|
|
141
|
-
supportedValues: supportedResolutions
|
|
142
|
-
});
|
|
143
|
-
} else ignored(params.ignoredOverrides, "resolution", params.requestedResolution);
|
|
144
|
-
return {
|
|
145
|
-
size,
|
|
146
|
-
aspectRatio,
|
|
147
|
-
resolution
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
function assertEditSupported(provider, isEdit, inputImages) {
|
|
151
|
-
if (!isEdit) return;
|
|
152
|
-
const editCap = (provider.capabilities ?? {}).edit;
|
|
153
|
-
if (!(editCap?.enabled === true)) throw new Error(`${provider.id} image editing is not supported.`);
|
|
154
|
-
const max = editCap.maxInputImages;
|
|
155
|
-
if (typeof max === "number" && (inputImages?.length ?? 0) > max) throw new Error(`${provider.id} accepts at most ${max} input image(s); got ${inputImages?.length ?? 0}.`);
|
|
156
|
-
}
|
|
157
|
-
function filterEnumOverride(params) {
|
|
158
|
-
if (params.requested === void 0) return void 0;
|
|
159
|
-
if (!params.supported || params.supported.length === 0) return params.requested;
|
|
160
|
-
if (params.supported.includes(params.requested)) return params.requested;
|
|
161
|
-
ignored(params.ignoredOverrides, params.key, params.requested);
|
|
162
|
-
}
|
|
163
|
-
function ignored(list, key, value) {
|
|
164
|
-
list.push({
|
|
165
|
-
key,
|
|
166
|
-
value
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
function entry(init) {
|
|
170
|
-
return {
|
|
171
|
-
...init.requested !== void 0 ? { requested: init.requested } : {},
|
|
172
|
-
...init.applied !== void 0 ? { applied: init.applied } : {},
|
|
173
|
-
...init.derivedFrom !== void 0 ? { derivedFrom: init.derivedFrom } : {},
|
|
174
|
-
...init.supportedValues ? { supportedValues: [...init.supportedValues] } : {}
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
function hasAnyEntry(n) {
|
|
178
|
-
return n.size !== void 0 || n.aspectRatio !== void 0 || n.resolution !== void 0;
|
|
179
|
-
}
|
|
180
|
-
//#endregion
|
|
181
|
-
export { resolveImageGenerationOverrides };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { ImageGenerationProvider, ImageGenerationRequest, ImageGenerationResult } from '../types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Wan image model ids for **HTTP synchronous** `multimodal-generation/generation`.
|
|
4
|
-
* - **2.7** (`wan2.7-image-pro` / `wan2.7-image`): see Wan 2.7 image API (size presets 1K/2K/4K, `thinking_mode`, …).
|
|
5
|
-
* - **2.6** (`wan2.6-t2i`): Wan 2.6 T2I (`prompt_extend`, pixel `宽*高`, …).
|
|
6
|
-
* Wan 2.5 and earlier async-only models are not listed here.
|
|
7
|
-
* @see https://www.alibabacloud.com/help/en/model-studio/wan-image-generation-and-editing-api-reference
|
|
8
|
-
* @see https://www.alibabacloud.com/help/en/model-studio/text-to-image-v2-api-reference
|
|
9
|
-
* @see https://www.alibabacloud.com/help/en/model-studio/model-pricing
|
|
10
|
-
*/
|
|
11
|
-
export declare const DASHSCOPE_IMAGE_MODELS: readonly string[];
|
|
12
|
-
export declare const DASHSCOPE_DEFAULT_IMAGE_MODEL: string;
|
|
13
|
-
/**
|
|
14
|
-
* Official synchronous wan2.6 text-to-image endpoints. Each region uses its own API key.
|
|
15
|
-
* @see https://www.alibabacloud.com/help/zh/model-studio/text-to-image-v2-api-reference
|
|
16
|
-
*/
|
|
17
|
-
export declare const DASHSCOPE_IMAGE_ENDPOINTS: {
|
|
18
|
-
readonly beijing: "https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation";
|
|
19
|
-
readonly singapore: "https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation";
|
|
20
|
-
};
|
|
21
|
-
export type DashScopeImageRegion = keyof typeof DASHSCOPE_IMAGE_ENDPOINTS;
|
|
22
|
-
export declare function resolveDashScopeImageGenerationUrl(req: ImageGenerationRequest): string;
|
|
23
|
-
/** Map tool size (e.g. `1024x1024`) to DashScope `宽*高` format. */
|
|
24
|
-
export declare function mapSizeToDashScopeFormat(size?: string): string;
|
|
25
|
-
export declare function isWan27ImageModel(model: string): boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Map tool `size` to Wan 2.7 `parameters.size` (1K / 2K / 4K presets or `宽*高` pixels).
|
|
28
|
-
* `wan2.7-image` does not support 4K — falls back to 2K.
|
|
29
|
-
*/
|
|
30
|
-
export declare function mapSizeToWan27Format(size: string | undefined, modelId: string): string;
|
|
31
|
-
export declare function generateDashScopeImages(params: {
|
|
32
|
-
req: ImageGenerationRequest;
|
|
33
|
-
apiKey: string;
|
|
34
|
-
}): Promise<ImageGenerationResult>;
|
|
35
|
-
export declare function buildDashScopeImageGenerationProvider(): ImageGenerationProvider;
|
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
import { createLogger } from "../../../../utils/logger/index.js";
|
|
2
|
-
import { init_logger } from "../../../../utils/logger.js";
|
|
3
|
-
import { imageFileExtensionForMimeType } from "../image-assets.js";
|
|
4
|
-
import { pickTimeoutMsOrFallback } from "../../../../media-shared/http/deadline.js";
|
|
5
|
-
import { privateNetworkPolicyToSsrfGuardOptions } from "../../../../media-shared/http/private-network.js";
|
|
6
|
-
import { resolveProviderHttpRequestConfig } from "../../../../media-shared/http/resolve-provider-http-request-config.js";
|
|
7
|
-
import { postJsonRequest } from "../../../../media-shared/http/provider-http.js";
|
|
8
|
-
import "../../../../media-shared/http/index.js";
|
|
9
|
-
import { resolveApiKeyForProvider } from "../../../../providers/auth-runtime/resolve-api-key.js";
|
|
10
|
-
import { isProviderApiKeyConfigured } from "../../../../providers/auth-runtime/is-configured.js";
|
|
11
|
-
import "../../../../providers/auth-runtime/index.js";
|
|
12
|
-
//#region src/agent/image/generation/providers/dashscope.ts
|
|
13
|
-
/**
|
|
14
|
-
* Built-in DashScope (Alibaba Model Studio) image-generation provider.
|
|
15
|
-
*/
|
|
16
|
-
init_logger();
|
|
17
|
-
const log = createLogger("ImageGen:DashScope");
|
|
18
|
-
/**
|
|
19
|
-
* Wan image model ids for **HTTP synchronous** `multimodal-generation/generation`.
|
|
20
|
-
* - **2.7** (`wan2.7-image-pro` / `wan2.7-image`): see Wan 2.7 image API (size presets 1K/2K/4K, `thinking_mode`, …).
|
|
21
|
-
* - **2.6** (`wan2.6-t2i`): Wan 2.6 T2I (`prompt_extend`, pixel `宽*高`, …).
|
|
22
|
-
* Wan 2.5 and earlier async-only models are not listed here.
|
|
23
|
-
* @see https://www.alibabacloud.com/help/en/model-studio/wan-image-generation-and-editing-api-reference
|
|
24
|
-
* @see https://www.alibabacloud.com/help/en/model-studio/text-to-image-v2-api-reference
|
|
25
|
-
* @see https://www.alibabacloud.com/help/en/model-studio/model-pricing
|
|
26
|
-
*/
|
|
27
|
-
const DASHSCOPE_IMAGE_MODELS = [
|
|
28
|
-
"wan2.7-image-pro",
|
|
29
|
-
"wan2.7-image",
|
|
30
|
-
"wan2.6-t2i"
|
|
31
|
-
];
|
|
32
|
-
const DASHSCOPE_DEFAULT_IMAGE_MODEL = DASHSCOPE_IMAGE_MODELS[0];
|
|
33
|
-
const DEFAULT_TIMEOUT_MS = 18e4;
|
|
34
|
-
const DASHSCOPE_CAPABILITIES = {
|
|
35
|
-
generate: {
|
|
36
|
-
maxCount: 4,
|
|
37
|
-
supportsSize: true
|
|
38
|
-
},
|
|
39
|
-
edit: { enabled: false },
|
|
40
|
-
geometry: { sizes: [
|
|
41
|
-
"2K",
|
|
42
|
-
"1K",
|
|
43
|
-
"4K",
|
|
44
|
-
"1280x1280",
|
|
45
|
-
"1024x1024",
|
|
46
|
-
"1280x720",
|
|
47
|
-
"720x1280",
|
|
48
|
-
"1024x1536",
|
|
49
|
-
"1536x1024"
|
|
50
|
-
] },
|
|
51
|
-
output: { formats: [
|
|
52
|
-
"png",
|
|
53
|
-
"jpeg",
|
|
54
|
-
"webp"
|
|
55
|
-
] }
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Official synchronous wan2.6 text-to-image endpoints. Each region uses its own API key.
|
|
59
|
-
* @see https://www.alibabacloud.com/help/zh/model-studio/text-to-image-v2-api-reference
|
|
60
|
-
*/
|
|
61
|
-
const DASHSCOPE_IMAGE_ENDPOINTS = {
|
|
62
|
-
beijing: "https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation",
|
|
63
|
-
singapore: "https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation"
|
|
64
|
-
};
|
|
65
|
-
const DEFAULT_OUTPUT_MIME = "image/png";
|
|
66
|
-
function resolveDashScopeImageGenerationUrl(req) {
|
|
67
|
-
const cfgBase = readDashScopeCfgString(req.cfg, "baseUrl");
|
|
68
|
-
if (cfgBase) return cfgBase.replace(/\/+$/, "");
|
|
69
|
-
const region = readDashScopeCfgString(req.cfg, "region");
|
|
70
|
-
if (region === "cn") return DASHSCOPE_IMAGE_ENDPOINTS.beijing;
|
|
71
|
-
if (region === "intl") return DASHSCOPE_IMAGE_ENDPOINTS.singapore;
|
|
72
|
-
throw new Error("DashScope image generation requires providers.dashscope.region (cn or intl)");
|
|
73
|
-
}
|
|
74
|
-
function readDashScopeCfgString(cfg, key) {
|
|
75
|
-
const providers = cfg?.providers;
|
|
76
|
-
if (!providers || typeof providers !== "object") return void 0;
|
|
77
|
-
const entry = providers.dashscope;
|
|
78
|
-
if (!entry || typeof entry !== "object") return void 0;
|
|
79
|
-
const v = entry[key];
|
|
80
|
-
return typeof v === "string" && v.trim() ? v.trim() : void 0;
|
|
81
|
-
}
|
|
82
|
-
/** Map tool size (e.g. `1024x1024`) to DashScope `宽*高` format. */
|
|
83
|
-
function mapSizeToDashScopeFormat(size) {
|
|
84
|
-
if (!size?.trim()) return "1280*1280";
|
|
85
|
-
const s = size.trim();
|
|
86
|
-
if (s.includes("*")) return s.replace(/\s/g, "");
|
|
87
|
-
const m = /^(\d+)\s*[xX]\s*(\d+)$/.exec(s);
|
|
88
|
-
if (m) return `${m[1]}*${m[2]}`;
|
|
89
|
-
return "1280*1280";
|
|
90
|
-
}
|
|
91
|
-
function isWan27ImageModel(model) {
|
|
92
|
-
const m = model.trim().toLowerCase();
|
|
93
|
-
return m === "wan2.7-image-pro" || m === "wan2.7-image";
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Map tool `size` to Wan 2.7 `parameters.size` (1K / 2K / 4K presets or `宽*高` pixels).
|
|
97
|
-
* `wan2.7-image` does not support 4K — falls back to 2K.
|
|
98
|
-
*/
|
|
99
|
-
function mapSizeToWan27Format(size, modelId) {
|
|
100
|
-
const id = modelId.trim().toLowerCase();
|
|
101
|
-
if (!size?.trim()) return "2K";
|
|
102
|
-
const s = size.trim();
|
|
103
|
-
const preset = s.toUpperCase();
|
|
104
|
-
if (preset === "1K" || preset === "2K" || preset === "4K") {
|
|
105
|
-
if (preset === "4K" && id === "wan2.7-image") return "2K";
|
|
106
|
-
return preset;
|
|
107
|
-
}
|
|
108
|
-
if (s.includes("*")) return s.replace(/\s/g, "");
|
|
109
|
-
const dim = /^(\d+)\s*[xX]\s*(\d+)$/.exec(s);
|
|
110
|
-
if (dim) return `${dim[1]}*${dim[2]}`;
|
|
111
|
-
return "2K";
|
|
112
|
-
}
|
|
113
|
-
function collectImageUrls(data) {
|
|
114
|
-
const urls = [];
|
|
115
|
-
for (const choice of data.output?.choices ?? []) for (const item of choice.message?.content ?? []) if (item.type === "image" && typeof item.image === "string" && item.image.length > 0) urls.push(item.image);
|
|
116
|
-
return urls;
|
|
117
|
-
}
|
|
118
|
-
async function fetchImageBuffers(urls, signal) {
|
|
119
|
-
const out = [];
|
|
120
|
-
let index = 0;
|
|
121
|
-
for (const url of urls) {
|
|
122
|
-
index += 1;
|
|
123
|
-
const res = await fetch(url, {
|
|
124
|
-
redirect: "follow",
|
|
125
|
-
signal
|
|
126
|
-
});
|
|
127
|
-
if (!res.ok) {
|
|
128
|
-
const t = await res.text().catch(() => "");
|
|
129
|
-
throw new Error(`Failed to download generated image (${res.status}): ${t || res.statusText}`);
|
|
130
|
-
}
|
|
131
|
-
const buf = Buffer.from(await res.arrayBuffer());
|
|
132
|
-
const mimeType = (res.headers.get("content-type") || "").split(";")[0]?.trim() || DEFAULT_OUTPUT_MIME;
|
|
133
|
-
const ext = imageFileExtensionForMimeType(mimeType);
|
|
134
|
-
out.push({
|
|
135
|
-
buffer: buf,
|
|
136
|
-
mimeType,
|
|
137
|
-
fileName: `image-${index}.${ext}`
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
return out;
|
|
141
|
-
}
|
|
142
|
-
async function generateDashScopeImages(params) {
|
|
143
|
-
const { req, apiKey } = params;
|
|
144
|
-
const providerId = "dashscope";
|
|
145
|
-
if (req.inputImages && req.inputImages.length > 0) throw new Error("Image-to-image is not supported for Qwen/DashScope in this build");
|
|
146
|
-
const n = Math.min(4, Math.max(1, req.count ?? 1));
|
|
147
|
-
const model = req.model?.trim() || DASHSCOPE_DEFAULT_IMAGE_MODEL;
|
|
148
|
-
const parameters = isWan27ImageModel(model) ? {
|
|
149
|
-
size: mapSizeToWan27Format(req.size, model),
|
|
150
|
-
n,
|
|
151
|
-
watermark: false,
|
|
152
|
-
thinking_mode: true
|
|
153
|
-
} : {
|
|
154
|
-
prompt_extend: true,
|
|
155
|
-
watermark: false,
|
|
156
|
-
n,
|
|
157
|
-
negative_prompt: "",
|
|
158
|
-
size: mapSizeToDashScopeFormat(req.size)
|
|
159
|
-
};
|
|
160
|
-
const body = {
|
|
161
|
-
model,
|
|
162
|
-
input: { messages: [{
|
|
163
|
-
role: "user",
|
|
164
|
-
content: [{ text: req.prompt }]
|
|
165
|
-
}] },
|
|
166
|
-
parameters
|
|
167
|
-
};
|
|
168
|
-
const url = resolveDashScopeImageGenerationUrl(req);
|
|
169
|
-
const httpDefaults = resolveProviderHttpRequestConfig({
|
|
170
|
-
providerId,
|
|
171
|
-
cfg: req.cfg,
|
|
172
|
-
fallbackTimeoutMs: DEFAULT_TIMEOUT_MS
|
|
173
|
-
});
|
|
174
|
-
log.debug({
|
|
175
|
-
providerId,
|
|
176
|
-
model,
|
|
177
|
-
url,
|
|
178
|
-
count: n,
|
|
179
|
-
phase: "request"
|
|
180
|
-
}, "DashScope image generation request");
|
|
181
|
-
const response = await postJsonRequest(url, {
|
|
182
|
-
label: providerId,
|
|
183
|
-
timeoutMs: pickTimeoutMsOrFallback(req.timeoutMs, httpDefaults.timeoutMs, DEFAULT_TIMEOUT_MS),
|
|
184
|
-
signal: req.signal,
|
|
185
|
-
body,
|
|
186
|
-
headers: {
|
|
187
|
-
...httpDefaults.headers,
|
|
188
|
-
authorization: `Bearer ${apiKey}`
|
|
189
|
-
},
|
|
190
|
-
...privateNetworkPolicyToSsrfGuardOptions()
|
|
191
|
-
});
|
|
192
|
-
let data;
|
|
193
|
-
const rawText = await response.text();
|
|
194
|
-
try {
|
|
195
|
-
data = JSON.parse(rawText);
|
|
196
|
-
} catch {
|
|
197
|
-
throw new Error(`DashScope returned non-JSON: ${rawText.slice(0, 240)}`);
|
|
198
|
-
}
|
|
199
|
-
if (!data.output?.choices?.length) {
|
|
200
|
-
if (data.message || data.code) throw new Error(data.code ? `DashScope: ${data.code}: ${data.message ?? ""}` : `DashScope: ${data.message ?? "unknown error"}`);
|
|
201
|
-
throw new Error("DashScope returned no output");
|
|
202
|
-
}
|
|
203
|
-
const urls = collectImageUrls(data);
|
|
204
|
-
if (urls.length === 0) throw new Error("DashScope returned no image URLs in response");
|
|
205
|
-
return {
|
|
206
|
-
images: await fetchImageBuffers(urls, req.signal),
|
|
207
|
-
model
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
function buildDashScopeImageGenerationProvider() {
|
|
211
|
-
return {
|
|
212
|
-
id: "dashscope",
|
|
213
|
-
label: "Alibaba Model Studio",
|
|
214
|
-
documentationUrl: "https://www.alibabacloud.com/help/en/model-studio/wan-image-generation-and-editing-api-reference",
|
|
215
|
-
apiKeyUrl: "https://dashscope.console.aliyun.com/apiKey",
|
|
216
|
-
configFields: [{
|
|
217
|
-
key: "region",
|
|
218
|
-
label: "Service region",
|
|
219
|
-
type: "select",
|
|
220
|
-
required: true,
|
|
221
|
-
options: [{
|
|
222
|
-
value: "cn",
|
|
223
|
-
label: "China"
|
|
224
|
-
}, {
|
|
225
|
-
value: "intl",
|
|
226
|
-
label: "International"
|
|
227
|
-
}]
|
|
228
|
-
}, {
|
|
229
|
-
key: "baseUrl",
|
|
230
|
-
label: "Base URL",
|
|
231
|
-
type: "url",
|
|
232
|
-
placeholder: "https://…"
|
|
233
|
-
}],
|
|
234
|
-
defaultModel: DASHSCOPE_DEFAULT_IMAGE_MODEL,
|
|
235
|
-
models: [...DASHSCOPE_IMAGE_MODELS],
|
|
236
|
-
capabilities: DASHSCOPE_CAPABILITIES,
|
|
237
|
-
isConfigured: (ctx) => isProviderApiKeyConfigured({
|
|
238
|
-
providerId: "dashscope",
|
|
239
|
-
cfg: ctx.cfg,
|
|
240
|
-
agentId: ctx.agentId
|
|
241
|
-
}) && ["cn", "intl"].includes(readDashScopeCfgString(ctx.cfg, "region") ?? ""),
|
|
242
|
-
async generateImage(req) {
|
|
243
|
-
const apiKey = resolveApiKeyForProvider({
|
|
244
|
-
providerId: "dashscope",
|
|
245
|
-
cfg: req.cfg,
|
|
246
|
-
agentId: req.agentId
|
|
247
|
-
});
|
|
248
|
-
if (!apiKey) throw new Error("DashScope API key missing (set DASHSCOPE_API_KEY or save a credential)");
|
|
249
|
-
return generateDashScopeImages({
|
|
250
|
-
req,
|
|
251
|
-
apiKey
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
//#endregion
|
|
257
|
-
export { DASHSCOPE_DEFAULT_IMAGE_MODEL, DASHSCOPE_IMAGE_ENDPOINTS, DASHSCOPE_IMAGE_MODELS, buildDashScopeImageGenerationProvider, generateDashScopeImages, isWan27ImageModel, mapSizeToDashScopeFormat, mapSizeToWan27Format, resolveDashScopeImageGenerationUrl };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ImageGenerationProvider, ImageGenerationRequest, ImageGenerationResult } from '../types.js';
|
|
2
|
-
export declare const FAL_DEFAULT_IMAGE_MODEL = "fal-ai/flux-2";
|
|
3
|
-
export declare const FAL_IMAGE_MODELS: readonly string[];
|
|
4
|
-
/**
|
|
5
|
-
* Resolve Fal queue base URL precedence:
|
|
6
|
-
* 1. cfg.providers.fal.baseUrl
|
|
7
|
-
* 2. FAL_QUEUE_BASE_URL / FAL_BASE_URL env
|
|
8
|
-
* 3. Default https://queue.fal.run
|
|
9
|
-
*/
|
|
10
|
-
export declare function resolveFalBaseUrl(req: ImageGenerationRequest): string;
|
|
11
|
-
export declare function generateFalImages(params: {
|
|
12
|
-
req: ImageGenerationRequest;
|
|
13
|
-
apiKey: string;
|
|
14
|
-
}): Promise<ImageGenerationResult>;
|
|
15
|
-
export declare function buildFalImageGenerationProvider(): ImageGenerationProvider;
|