@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
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { privateNetworkPolicyToSsrfGuardOptions } from "../../../media-shared/http/private-network.js";
|
|
2
|
+
import { resolveProviderHttpRequestConfig } from "../../../media-shared/http/resolve-provider-http-request-config.js";
|
|
3
|
+
import { fetchWithTimeoutGuarded } from "../../../media-shared/http/provider-http.js";
|
|
4
|
+
import "../../../media-shared/http/index.js";
|
|
5
|
+
import { getImageProviderSpec } from "../../../../packages/image-providers/src/catalog.js";
|
|
6
|
+
import { executeImageProvider } from "../../../../packages/image-providers/src/execute.js";
|
|
7
|
+
import "../../../../packages/image-providers/src/index.js";
|
|
8
|
+
import { resolveApiKeyForProvider } from "../../../providers/auth-runtime/resolve-api-key.js";
|
|
9
|
+
import { isProviderApiKeyConfigured } from "../../../providers/auth-runtime/is-configured.js";
|
|
10
|
+
import "../../../providers/auth-runtime/index.js";
|
|
11
|
+
//#region src/agent/image/generation/native-provider.ts
|
|
12
|
+
function buildNativeImageProvider(providerId) {
|
|
13
|
+
const spec = getImageProviderSpec(providerId);
|
|
14
|
+
const modelCapabilities = Object.fromEntries(spec.models.map((model) => [model.id, model.capabilities]));
|
|
15
|
+
return {
|
|
16
|
+
id: spec.id,
|
|
17
|
+
label: spec.name,
|
|
18
|
+
documentationUrl: spec.documentationUrl,
|
|
19
|
+
apiKeyUrl: spec.apiKeyUrl,
|
|
20
|
+
defaultModel: spec.models[0].id,
|
|
21
|
+
models: spec.models.map((model) => model.id),
|
|
22
|
+
capabilities: spec.models[0].capabilities,
|
|
23
|
+
modelCapabilities,
|
|
24
|
+
configFields: [...spec.regions ? [{
|
|
25
|
+
key: "region",
|
|
26
|
+
label: "Region",
|
|
27
|
+
type: "select",
|
|
28
|
+
required: true,
|
|
29
|
+
options: [{
|
|
30
|
+
value: "cn",
|
|
31
|
+
label: "China"
|
|
32
|
+
}, {
|
|
33
|
+
value: "intl",
|
|
34
|
+
label: "International"
|
|
35
|
+
}]
|
|
36
|
+
}] : [], {
|
|
37
|
+
key: "baseUrl",
|
|
38
|
+
label: "Base URL",
|
|
39
|
+
type: "url",
|
|
40
|
+
placeholder: spec.baseUrl
|
|
41
|
+
}],
|
|
42
|
+
isConfigured: (ctx) => isProviderApiKeyConfigured({
|
|
43
|
+
providerId,
|
|
44
|
+
cfg: ctx.cfg,
|
|
45
|
+
agentId: ctx.agentId
|
|
46
|
+
}) && (!spec.regions || Boolean(ctx.cfg?.providers?.[providerId]?.region)),
|
|
47
|
+
async generateImage(req) {
|
|
48
|
+
const apiKey = resolveApiKeyForProvider({
|
|
49
|
+
providerId,
|
|
50
|
+
cfg: req.cfg,
|
|
51
|
+
agentId: req.agentId,
|
|
52
|
+
store: req.authStore
|
|
53
|
+
});
|
|
54
|
+
if (!apiKey) throw new Error(`${spec.name} API key missing`);
|
|
55
|
+
const settings = req.cfg?.providers?.[providerId];
|
|
56
|
+
if (settings?.azure) throw new Error("Configure Azure images as an explicit custom image provider");
|
|
57
|
+
const baseUrl = settings?.baseUrl ?? (spec.regions ? spec.regions[settings?.region] : spec.baseUrl);
|
|
58
|
+
if (!baseUrl) throw new Error(`${spec.name} requires region or baseUrl`);
|
|
59
|
+
const http = resolveProviderHttpRequestConfig({
|
|
60
|
+
providerId,
|
|
61
|
+
cfg: req.cfg,
|
|
62
|
+
fallbackTimeoutMs: spec.timeoutMs
|
|
63
|
+
});
|
|
64
|
+
const timeoutMs = req.timeoutMs ?? http.timeoutMs ?? spec.timeoutMs;
|
|
65
|
+
const signal = AbortSignal.any([AbortSignal.timeout(timeoutMs), ...req.signal ? [req.signal] : []]);
|
|
66
|
+
const result = await executeImageProvider({
|
|
67
|
+
providerId,
|
|
68
|
+
baseUrl,
|
|
69
|
+
apiKey,
|
|
70
|
+
signal,
|
|
71
|
+
fetchImpl: ((url, init) => {
|
|
72
|
+
const headers = new Headers(new URL(String(url)).origin === new URL(baseUrl).origin ? http.headers : void 0);
|
|
73
|
+
new Headers(init?.headers).forEach((value, key) => headers.set(key, value));
|
|
74
|
+
return fetchWithTimeoutGuarded(String(url), {
|
|
75
|
+
label: spec.name,
|
|
76
|
+
timeoutMs,
|
|
77
|
+
signal,
|
|
78
|
+
init: {
|
|
79
|
+
...init,
|
|
80
|
+
headers,
|
|
81
|
+
redirect: "error"
|
|
82
|
+
},
|
|
83
|
+
...privateNetworkPolicyToSsrfGuardOptions()
|
|
84
|
+
});
|
|
85
|
+
}),
|
|
86
|
+
request: {
|
|
87
|
+
model: req.model,
|
|
88
|
+
prompt: req.prompt,
|
|
89
|
+
count: req.count,
|
|
90
|
+
size: req.size,
|
|
91
|
+
aspectRatio: req.aspectRatio,
|
|
92
|
+
resolution: req.resolution,
|
|
93
|
+
quality: req.quality,
|
|
94
|
+
outputFormat: req.outputFormat,
|
|
95
|
+
background: req.background ?? req.providerOptions?.openai?.background,
|
|
96
|
+
openai: req.providerOptions?.openai,
|
|
97
|
+
inputImages: req.inputImages?.map((image, index) => ({
|
|
98
|
+
blob: new Blob([new Uint8Array(image.buffer)], { type: image.mimeType }),
|
|
99
|
+
fileName: image.fileName ?? `input-${index}.png`
|
|
100
|
+
}))
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
return {
|
|
104
|
+
model: req.model,
|
|
105
|
+
images: result.images.map((image) => ({
|
|
106
|
+
buffer: Buffer.from(image.bytes),
|
|
107
|
+
mimeType: image.mimeType
|
|
108
|
+
})),
|
|
109
|
+
metadata: {
|
|
110
|
+
requestId: result.requestId,
|
|
111
|
+
usage: result.usage
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
export { buildNativeImageProvider };
|
|
@@ -48,7 +48,7 @@ export interface OpenAiImagesProviderOptions {
|
|
|
48
48
|
resolveEndpoint: (req: ImageGenerationRequest) => OpenAiImagesEndpointResolution;
|
|
49
49
|
/** Default per-call timeout. Combined with provider-level config in provider-http. */
|
|
50
50
|
defaultTimeoutMs?: number;
|
|
51
|
-
/** Default count
|
|
51
|
+
/** Default image count. Provider may also enforce via `capabilities.generate.maxCount`. */
|
|
52
52
|
defaultCount?: number;
|
|
53
53
|
defaultSize?: string;
|
|
54
54
|
}
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { createLogger } from "../../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../../utils/logger.js";
|
|
3
|
-
import {
|
|
3
|
+
import { imageFileExtensionForMimeType } from "./image-assets.js";
|
|
4
4
|
import { pickTimeoutMsOrFallback } from "../../../media-shared/http/deadline.js";
|
|
5
5
|
import { privateNetworkPolicyToSsrfGuardOptions } from "../../../media-shared/http/private-network.js";
|
|
6
6
|
import { resolveProviderHttpRequestConfig } from "../../../media-shared/http/resolve-provider-http-request-config.js";
|
|
7
7
|
import { postJsonRequest, postMultipartRequest, readJsonResponseLimited } from "../../../media-shared/http/provider-http.js";
|
|
8
8
|
import "../../../media-shared/http/index.js";
|
|
9
|
+
import { ImageProviderError, validateImageRequest } from "../../../../packages/image-providers/src/validation.js";
|
|
10
|
+
import { decodeBase64, imageFromBytes } from "../../../../packages/image-providers/src/http.js";
|
|
11
|
+
import "../../../../packages/image-providers/src/index.js";
|
|
9
12
|
//#region src/agent/image/generation/openai-images-provider.ts
|
|
13
|
+
/** Strict implementation of the OpenAI Images REST protocol. */
|
|
10
14
|
init_logger();
|
|
11
15
|
const log = createLogger("ImageGen:OpenAIImages");
|
|
12
|
-
const DEFAULT_OUTPUT_MIME = "image/png";
|
|
13
16
|
const DEFAULT_TIMEOUT_MS = 12e4;
|
|
14
17
|
const MAX_RESPONSE_BYTES = 64 * 1024 * 1024;
|
|
15
|
-
const MAX_IMAGE_BYTES = 32 * 1024 * 1024;
|
|
16
18
|
const MAX_TOTAL_IMAGE_BYTES = 64 * 1024 * 1024;
|
|
17
19
|
function createOpenAiImagesProvider(options) {
|
|
18
|
-
const defaultMaxCount = options.capabilities.generate?.maxCount ?? 4;
|
|
19
20
|
const defaultCount = options.defaultCount ?? 1;
|
|
20
|
-
const defaultSize = options.defaultSize ??
|
|
21
|
+
const defaultSize = options.defaultSize ?? options.capabilities.geometry?.sizes?.[0];
|
|
21
22
|
return {
|
|
22
23
|
id: options.id,
|
|
23
24
|
label: options.label,
|
|
@@ -44,8 +45,20 @@ function createOpenAiImagesProvider(options) {
|
|
|
44
45
|
});
|
|
45
46
|
const ssrfGuardOptions = privateNetworkPolicyToSsrfGuardOptions(endpoint.privateNetworkPolicy);
|
|
46
47
|
const isEdit = (req.inputImages?.length ?? 0) > 0;
|
|
47
|
-
const count =
|
|
48
|
-
const size = req.size?.trim() || defaultSize;
|
|
48
|
+
const count = req.count ?? defaultCount;
|
|
49
|
+
const size = req.size?.trim() || (req.aspectRatio || req.resolution || !options.capabilities.generate?.supportsSize ? void 0 : defaultSize);
|
|
50
|
+
if (!options.models.includes(req.model)) throw new ImageProviderError(`Unsupported image model: ${req.model}`, 400);
|
|
51
|
+
validateImageRequest({
|
|
52
|
+
...req,
|
|
53
|
+
count,
|
|
54
|
+
size,
|
|
55
|
+
background: req.background ?? req.providerOptions?.openai?.background,
|
|
56
|
+
openai: req.providerOptions?.openai,
|
|
57
|
+
inputImages: req.inputImages?.map((image, index) => ({
|
|
58
|
+
blob: new Blob([new Uint8Array(image.buffer)], { type: image.mimeType }),
|
|
59
|
+
fileName: image.fileName ?? `input-${index}`
|
|
60
|
+
}))
|
|
61
|
+
}, options.capabilities);
|
|
49
62
|
const url = isEdit ? joinPath(endpoint.baseUrl, endpoint.editsPath ?? "/images/edits") : joinPath(endpoint.baseUrl, endpoint.generationsPath ?? "/images/generations");
|
|
50
63
|
log.debug({
|
|
51
64
|
providerId: options.id,
|
|
@@ -72,7 +85,11 @@ function createOpenAiImagesProvider(options) {
|
|
|
72
85
|
size,
|
|
73
86
|
httpDefaults,
|
|
74
87
|
ssrfGuardOptions
|
|
75
|
-
}),
|
|
88
|
+
}), {
|
|
89
|
+
...req,
|
|
90
|
+
count
|
|
91
|
+
});
|
|
92
|
+
if (mapped.length > count) throw new ImageProviderError("Provider returned too many images", 502);
|
|
76
93
|
if (mapped.length === 0) throw new Error(`${options.id} returned no images.`);
|
|
77
94
|
return {
|
|
78
95
|
images: mapped,
|
|
@@ -86,10 +103,13 @@ async function postGenerateRequest(params) {
|
|
|
86
103
|
model: params.req.model,
|
|
87
104
|
prompt: params.req.prompt,
|
|
88
105
|
n: params.count,
|
|
89
|
-
size: params.size
|
|
90
|
-
response_format: "b64_json"
|
|
106
|
+
...params.size ? { size: params.size } : {}
|
|
91
107
|
};
|
|
92
108
|
applyOpenAiOptions(body, params.req);
|
|
109
|
+
if (params.req.aspectRatio || params.req.resolution) body.xopc = { image: {
|
|
110
|
+
aspectRatio: params.req.aspectRatio,
|
|
111
|
+
resolution: params.req.resolution
|
|
112
|
+
} };
|
|
93
113
|
const timeoutMs = pickTimeoutMsOrFallback(params.req.timeoutMs, params.httpDefaults.timeoutMs, DEFAULT_TIMEOUT_MS);
|
|
94
114
|
return await readJsonResponseLimited(await postJsonRequest(params.url, {
|
|
95
115
|
label: params.providerId,
|
|
@@ -106,9 +126,15 @@ async function postEditRequest(params) {
|
|
|
106
126
|
model: params.req.model,
|
|
107
127
|
prompt: params.req.prompt,
|
|
108
128
|
n: String(params.count),
|
|
109
|
-
size: params.size
|
|
110
|
-
response_format: "b64_json"
|
|
129
|
+
...params.size ? { size: params.size } : {}
|
|
111
130
|
};
|
|
131
|
+
const options = {};
|
|
132
|
+
applyOpenAiOptions(options, params.req);
|
|
133
|
+
for (const [key, value] of Object.entries(options)) fields[key] = String(value);
|
|
134
|
+
if (params.req.aspectRatio || params.req.resolution) fields.xopc = JSON.stringify({ image: {
|
|
135
|
+
aspectRatio: params.req.aspectRatio,
|
|
136
|
+
resolution: params.req.resolution
|
|
137
|
+
} });
|
|
112
138
|
const form = new FormData();
|
|
113
139
|
for (const [k, v] of Object.entries(fields)) if (typeof v === "string") form.append(k, v);
|
|
114
140
|
for (let idx = 0; idx < inputImages.length; idx++) {
|
|
@@ -117,7 +143,7 @@ async function postEditRequest(params) {
|
|
|
117
143
|
const u8 = img.buffer instanceof Uint8Array ? img.buffer : new Uint8Array(img.buffer);
|
|
118
144
|
const copy = new Uint8Array(u8.byteLength);
|
|
119
145
|
copy.set(u8);
|
|
120
|
-
form.append(field, new Blob([copy], { type: img.mimeType
|
|
146
|
+
form.append(field, new Blob([copy], { type: img.mimeType }), pickEditFileName(img, idx));
|
|
121
147
|
}
|
|
122
148
|
const headers = new Headers(params.headers);
|
|
123
149
|
headers.delete("content-type");
|
|
@@ -135,26 +161,20 @@ function mapOpenAiImagesResponse(raw, req) {
|
|
|
135
161
|
if (!raw || typeof raw !== "object") return [];
|
|
136
162
|
const data = raw.data;
|
|
137
163
|
if (!Array.isArray(data)) return [];
|
|
138
|
-
|
|
164
|
+
if (data.length > (req.count ?? 1)) throw new ImageProviderError("Provider returned too many images", 502);
|
|
139
165
|
const out = [];
|
|
140
166
|
let totalBytes = 0;
|
|
141
|
-
data.
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (estimatedBytes > MAX_IMAGE_BYTES) throw new Error(`OpenAI Images response image exceeds ${MAX_IMAGE_BYTES} bytes.`);
|
|
146
|
-
totalBytes += estimatedBytes;
|
|
147
|
-
if (totalBytes > MAX_TOTAL_IMAGE_BYTES) throw new Error(`OpenAI Images response images exceed ${MAX_TOTAL_IMAGE_BYTES} bytes total.`);
|
|
148
|
-
const asset = imageAssetFromBase64({
|
|
149
|
-
base64: b64,
|
|
150
|
-
mimeType: req.outputFormat ? `image/${req.outputFormat}` : void 0,
|
|
151
|
-
fileName: `image-${index + 1}.${ext}`
|
|
152
|
-
});
|
|
167
|
+
for (const [index, entry] of data.entries()) {
|
|
168
|
+
const image = imageFromBytes(decodeBase64(entry?.b64_json));
|
|
169
|
+
totalBytes += image.bytes.byteLength;
|
|
170
|
+
if (totalBytes > MAX_TOTAL_IMAGE_BYTES) throw new ImageProviderError("Generated images exceed total byte limit", 502);
|
|
153
171
|
out.push({
|
|
154
|
-
|
|
172
|
+
buffer: Buffer.from(image.bytes),
|
|
173
|
+
mimeType: image.mimeType,
|
|
174
|
+
fileName: `image-${index + 1}.${imageFileExtensionForMimeType(image.mimeType)}`,
|
|
155
175
|
...typeof entry.revised_prompt === "string" ? { revisedPrompt: entry.revised_prompt } : {}
|
|
156
176
|
});
|
|
157
|
-
}
|
|
177
|
+
}
|
|
158
178
|
return out;
|
|
159
179
|
}
|
|
160
180
|
function applyAuthorizationHeader(params) {
|
|
@@ -191,10 +211,6 @@ function pickEditFileName(img, idx) {
|
|
|
191
211
|
const ext = imageFileExtensionForMimeType(img.mimeType);
|
|
192
212
|
return `image-${idx + 1}.${ext}`;
|
|
193
213
|
}
|
|
194
|
-
function clampCount(requested, fallback, max) {
|
|
195
|
-
if (typeof requested !== "number" || !Number.isFinite(requested) || requested <= 0) return fallback;
|
|
196
|
-
return Math.min(max, Math.max(1, Math.floor(requested)));
|
|
197
|
-
}
|
|
198
214
|
function joinPath(baseUrl, subPath) {
|
|
199
215
|
return `${baseUrl.replace(/\/+$/, "")}${subPath.startsWith("/") ? subPath : `/${subPath}`}`;
|
|
200
216
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { createLogger } from "../../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../../utils/logger.js";
|
|
3
3
|
import { init_models_json, loadModelsJson } from "../../../config/models-json.js";
|
|
4
|
+
import { listImageProviderSpecs } from "../../../../packages/image-providers/src/catalog.js";
|
|
5
|
+
import "../../../../packages/image-providers/src/index.js";
|
|
4
6
|
import { buildCustomOpenAiImagesProvider } from "./custom-openai-images-provider.js";
|
|
5
|
-
import {
|
|
6
|
-
import { buildFalImageGenerationProvider } from "./providers/fal.js";
|
|
7
|
-
import { buildGoogleImageGenerationProvider } from "./providers/google.js";
|
|
8
|
-
import { buildMinimaxImageGenerationProvider } from "./providers/minimax.js";
|
|
9
|
-
import { buildOpenAIImageGenerationProvider } from "./providers/openai.js";
|
|
7
|
+
import { buildNativeImageProvider } from "./native-provider.js";
|
|
10
8
|
import { buildXopcCloudImageGenerationProvider } from "./providers/xopc-cloud.js";
|
|
11
9
|
//#region src/agent/image/generation/provider-registry.ts
|
|
12
10
|
init_models_json();
|
|
@@ -14,14 +12,7 @@ init_logger();
|
|
|
14
12
|
const log = createLogger("ImageGenerationRegistry");
|
|
15
13
|
function buildBuiltInProviders() {
|
|
16
14
|
const cloud = buildXopcCloudImageGenerationProvider();
|
|
17
|
-
return [
|
|
18
|
-
...cloud ? [cloud] : [],
|
|
19
|
-
buildOpenAIImageGenerationProvider(),
|
|
20
|
-
buildDashScopeImageGenerationProvider(),
|
|
21
|
-
buildMinimaxImageGenerationProvider(),
|
|
22
|
-
buildGoogleImageGenerationProvider(),
|
|
23
|
-
buildFalImageGenerationProvider()
|
|
24
|
-
];
|
|
15
|
+
return [...cloud ? [cloud] : [], ...listImageProviderSpecs().map((spec) => buildNativeImageProvider(spec.id))];
|
|
25
16
|
}
|
|
26
17
|
let providers = buildBuiltInProviders();
|
|
27
18
|
let providersById = new Map(providers.map((provider) => [provider.id, provider]));
|
|
@@ -9,9 +9,9 @@ init_provider_auth_service();
|
|
|
9
9
|
init_xopc_cloud_config();
|
|
10
10
|
function buildXopcCloudImageGenerationProvider() {
|
|
11
11
|
const source = getModelCatalogStore().getSource("xopc-cloud");
|
|
12
|
-
const models = source?.models.filter((model) => model.availability === "available" && model.kind === "image" && model.operations.includes("images.generate")).sort((left, right) => compareCatalogModels(left, right, source.recommended?.["image-generation"])) ?? [];
|
|
12
|
+
const models = source?.models.filter((model) => model.availability === "available" && model.kind === "image" && model.operations.includes("images.generate") && Boolean(model.imageGeneration)).sort((left, right) => compareCatalogModels(left, right, source.recommended?.["image-generation"])) ?? [];
|
|
13
13
|
if (models.length === 0) return void 0;
|
|
14
|
-
const modelCapabilities = Object.fromEntries(models.map((model) => [model.id,
|
|
14
|
+
const modelCapabilities = Object.fromEntries(models.map((model) => [model.id, model.imageGeneration]));
|
|
15
15
|
const defaultModel = models[0].id;
|
|
16
16
|
const baseUrl = source?.baseUrl ?? resolveXopcModelRouterUrl();
|
|
17
17
|
const executors = new Map(models.map((model) => [model.id, createOpenAiImagesProvider({
|
|
@@ -19,11 +19,12 @@ function buildXopcCloudImageGenerationProvider() {
|
|
|
19
19
|
label: "XOPC Model Service",
|
|
20
20
|
defaultModel: model.id,
|
|
21
21
|
models: [model.id],
|
|
22
|
+
defaultTimeoutMs: 6e5,
|
|
22
23
|
capabilities: modelCapabilities[model.id],
|
|
23
24
|
isConfigured: () => true,
|
|
24
25
|
resolveApiKey: (request) => getProviderAuthService().resolveApiKey("xopc-cloud", request.signal),
|
|
25
26
|
resolveEndpoint: () => ({ baseUrl }),
|
|
26
|
-
...model.imageGeneration?.sizes[0] ? { defaultSize: model.imageGeneration.sizes[0] } : {}
|
|
27
|
+
...model.imageGeneration?.geometry?.sizes?.[0] ? { defaultSize: model.imageGeneration.geometry.sizes[0] } : {}
|
|
27
28
|
})]));
|
|
28
29
|
return {
|
|
29
30
|
id: "xopc-cloud",
|
|
@@ -37,37 +38,7 @@ function buildXopcCloudImageGenerationProvider() {
|
|
|
37
38
|
async generateImage(request) {
|
|
38
39
|
const executor = executors.get(request.model);
|
|
39
40
|
if (!executor) throw new Error(`Image model is not available from XOPC Model Service: ${request.model}`);
|
|
40
|
-
|
|
41
|
-
const size = request.size ?? (request.aspectRatio && geometry?.aspectRatios?.includes(request.aspectRatio) ? request.aspectRatio : void 0) ?? (request.resolution && geometry?.resolutions?.includes(request.resolution) ? request.resolution : void 0);
|
|
42
|
-
return executor.generateImage({
|
|
43
|
-
...request,
|
|
44
|
-
...size ? { size } : {}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
function toProviderCapabilities(model) {
|
|
50
|
-
const image = model.imageGeneration;
|
|
51
|
-
return {
|
|
52
|
-
generate: {
|
|
53
|
-
maxCount: image?.maxCount ?? 1,
|
|
54
|
-
supportsSize: Boolean(image?.sizes.length),
|
|
55
|
-
supportsAspectRatio: Boolean(image?.aspectRatios?.length)
|
|
56
|
-
},
|
|
57
|
-
edit: {
|
|
58
|
-
enabled: model.operations.includes("images.edit"),
|
|
59
|
-
maxInputImages: image?.maxInputImages ?? 0,
|
|
60
|
-
supportsSize: Boolean(image?.sizes.length),
|
|
61
|
-
supportsAspectRatio: Boolean(image?.aspectRatios?.length)
|
|
62
|
-
},
|
|
63
|
-
geometry: {
|
|
64
|
-
sizes: image?.sizes ?? [],
|
|
65
|
-
aspectRatios: image?.aspectRatios ?? []
|
|
66
|
-
},
|
|
67
|
-
output: {
|
|
68
|
-
qualities: image?.qualities ?? [],
|
|
69
|
-
formats: image?.formats ?? [],
|
|
70
|
-
backgrounds: image?.backgrounds ?? []
|
|
41
|
+
return executor.generateImage(request);
|
|
71
42
|
}
|
|
72
43
|
};
|
|
73
44
|
}
|
|
@@ -10,9 +10,9 @@ import type { Config } from '../../../config/schema.js';
|
|
|
10
10
|
import type { ToolModelConfig } from '../tool-model-config.js';
|
|
11
11
|
import type { AuthProfileStore } from '../../../providers/auth-runtime/index.js';
|
|
12
12
|
import type { FallbackAttempt } from '../../failover-error.js';
|
|
13
|
-
import type { GeneratedImageAsset, ImageGenerationBackground,
|
|
13
|
+
import type { GeneratedImageAsset, ImageGenerationBackground, ImageGenerationOutputFormat, ImageGenerationProvider, ImageGenerationProviderOptions, ImageGenerationQuality, ImageGenerationResolution, ImageGenerationSourceImage } from './types.js';
|
|
14
14
|
export interface GenerateImageParams {
|
|
15
|
-
/** Active xopc config.
|
|
15
|
+
/** Active xopc config. */
|
|
16
16
|
cfg?: Config;
|
|
17
17
|
prompt: string;
|
|
18
18
|
agentId?: string;
|
|
@@ -41,8 +41,6 @@ export interface GenerateImageRuntimeResult {
|
|
|
41
41
|
provider: string;
|
|
42
42
|
model: string;
|
|
43
43
|
attempts: FallbackAttempt[];
|
|
44
|
-
normalization?: ImageGenerationNormalization;
|
|
45
|
-
ignoredOverrides: ImageGenerationIgnoredOverride[];
|
|
46
44
|
metadata?: Record<string, unknown>;
|
|
47
45
|
}
|
|
48
46
|
/**
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { createLogger } from "../../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../../utils/logger.js";
|
|
3
3
|
import { PROVIDER_ENV_MAP, init_env_keys } from "../../../providers/env-keys.js";
|
|
4
|
+
import { ImageProviderError } from "../../../../packages/image-providers/src/validation.js";
|
|
5
|
+
import "../../../../packages/image-providers/src/index.js";
|
|
4
6
|
import { describeFailoverError, isFailoverError } from "../../failover-error.js";
|
|
5
|
-
import {
|
|
7
|
+
import { buildNoCapabilityModelConfiguredMessage, recordCapabilityCandidateFailure, resolveCapabilityModelCandidates, throwCapabilityGenerationFailure } from "../../media-generation/runtime-shared.js";
|
|
6
8
|
import "../../media-generation/index.js";
|
|
7
9
|
import { parseImageGenerationModelRef } from "./model-ref.js";
|
|
8
|
-
import {
|
|
10
|
+
import { validateImageGenerationRequest } from "./validation.js";
|
|
9
11
|
import { getImageGenerationProvider, listImageGenerationProviders, listImageGenerationProvidersSummary as listImageGenerationProvidersSummary$1 } from "./provider-registry.js";
|
|
10
12
|
//#region src/agent/image/generation/runtime.ts
|
|
11
13
|
init_env_keys();
|
|
@@ -29,9 +31,13 @@ async function generateImage(params, deps = {}) {
|
|
|
29
31
|
autoProviderFallback: params.autoProviderFallback
|
|
30
32
|
});
|
|
31
33
|
if (candidates.length === 0) throw new Error(buildNoImageGenerationModelConfiguredMessage(params.cfg, deps));
|
|
34
|
+
params = {
|
|
35
|
+
...params,
|
|
36
|
+
signal: AbortSignal.any([AbortSignal.timeout(params.timeoutMs ?? 6e5), ...params.signal ? [params.signal] : []])
|
|
37
|
+
};
|
|
32
38
|
const attempts = [];
|
|
33
39
|
let lastError;
|
|
34
|
-
for (const candidate of candidates) {
|
|
40
|
+
for (const candidate of candidates.slice(0, 3)) {
|
|
35
41
|
const startedAt = Date.now();
|
|
36
42
|
const provider = getProvider(candidate.provider, params.cfg);
|
|
37
43
|
if (!provider) {
|
|
@@ -51,13 +57,15 @@ async function generateImage(params, deps = {}) {
|
|
|
51
57
|
continue;
|
|
52
58
|
}
|
|
53
59
|
try {
|
|
60
|
+
if (!provider.models.includes(candidate.model)) throw new ImageProviderError(`Unsupported image model: ${candidate.model}`, 400);
|
|
54
61
|
const modelCapabilities = provider.modelCapabilities?.[candidate.model];
|
|
55
|
-
|
|
62
|
+
validateImageGenerationRequest({
|
|
56
63
|
provider: modelCapabilities ? {
|
|
57
64
|
...provider,
|
|
58
65
|
capabilities: modelCapabilities
|
|
59
66
|
} : provider,
|
|
60
67
|
size: params.size,
|
|
68
|
+
count: params.count,
|
|
61
69
|
aspectRatio: params.aspectRatio,
|
|
62
70
|
resolution: params.resolution,
|
|
63
71
|
quality: params.quality,
|
|
@@ -68,32 +76,29 @@ async function generateImage(params, deps = {}) {
|
|
|
68
76
|
const request = buildProviderRequest({
|
|
69
77
|
provider,
|
|
70
78
|
candidate,
|
|
71
|
-
params
|
|
72
|
-
sanitized
|
|
79
|
+
params
|
|
73
80
|
});
|
|
74
81
|
log.debug({
|
|
75
82
|
provider: candidate.provider,
|
|
76
83
|
model: candidate.model,
|
|
77
|
-
phase: "provider_invoked"
|
|
78
|
-
normalizationCount: sanitized.normalization ? Object.keys(sanitized.normalization).length : 0,
|
|
79
|
-
ignoredCount: sanitized.ignoredOverrides.length
|
|
84
|
+
phase: "provider_invoked"
|
|
80
85
|
}, `image-generation provider invoked: ${candidate.provider}/${candidate.model}`);
|
|
81
86
|
const result = await provider.generateImage(request);
|
|
82
87
|
if (!result.images?.length) throw new Error("Image generation provider returned no images.");
|
|
83
|
-
const normalizationMetadata = buildMediaGenerationNormalizationMetadata({ normalization: sanitized.normalization });
|
|
84
88
|
return {
|
|
85
89
|
images: result.images,
|
|
86
90
|
provider: candidate.provider,
|
|
87
91
|
model: result.model ?? candidate.model,
|
|
88
92
|
attempts,
|
|
89
|
-
|
|
90
|
-
ignoredOverrides: sanitized.ignoredOverrides,
|
|
91
|
-
metadata: {
|
|
92
|
-
...result.metadata ?? {},
|
|
93
|
-
...normalizationMetadata
|
|
94
|
-
}
|
|
93
|
+
metadata: result.metadata
|
|
95
94
|
};
|
|
96
95
|
} catch (err) {
|
|
96
|
+
const status = err && typeof err === "object" && "status" in err ? err.status : void 0;
|
|
97
|
+
if (params.signal?.aborted || err instanceof ImageProviderError && !err.retryable || ![
|
|
98
|
+
401,
|
|
99
|
+
403,
|
|
100
|
+
429
|
|
101
|
+
].includes(Number(status))) throw err;
|
|
97
102
|
lastError = err;
|
|
98
103
|
const durationMs = Date.now() - startedAt;
|
|
99
104
|
recordCapabilityCandidateFailure({
|
|
@@ -127,7 +132,7 @@ function listImageGenerationProvidersSummary() {
|
|
|
127
132
|
return listImageGenerationProvidersSummary$1();
|
|
128
133
|
}
|
|
129
134
|
function buildProviderRequest(input) {
|
|
130
|
-
const { provider, candidate, params
|
|
135
|
+
const { provider, candidate, params } = input;
|
|
131
136
|
const inputImages = params.inputImages ? cloneInputImages(params.inputImages) : void 0;
|
|
132
137
|
return {
|
|
133
138
|
provider: provider.id,
|
|
@@ -140,12 +145,12 @@ function buildProviderRequest(input) {
|
|
|
140
145
|
...typeof params.timeoutMs === "number" ? { timeoutMs: params.timeoutMs } : {},
|
|
141
146
|
...params.signal ? { signal: params.signal } : {},
|
|
142
147
|
...typeof params.count === "number" ? { count: params.count } : {},
|
|
143
|
-
...
|
|
144
|
-
...
|
|
145
|
-
...
|
|
146
|
-
...
|
|
147
|
-
...
|
|
148
|
-
...
|
|
148
|
+
...params.size !== void 0 ? { size: params.size } : {},
|
|
149
|
+
...params.aspectRatio !== void 0 ? { aspectRatio: params.aspectRatio } : {},
|
|
150
|
+
...params.resolution !== void 0 ? { resolution: params.resolution } : {},
|
|
151
|
+
...params.quality !== void 0 ? { quality: params.quality } : {},
|
|
152
|
+
...params.outputFormat !== void 0 ? { outputFormat: params.outputFormat } : {},
|
|
153
|
+
...params.background !== void 0 ? { background: params.background } : {},
|
|
149
154
|
...inputImages ? { inputImages } : {},
|
|
150
155
|
...params.providerOptions ? { providerOptions: params.providerOptions } : {}
|
|
151
156
|
};
|
|
@@ -1,48 +1,11 @@
|
|
|
1
1
|
import type { Config } from '../../../config/schema.js';
|
|
2
2
|
import type { AuthProfileStore } from '../../../providers/auth-runtime/index.js';
|
|
3
|
-
import type { MediaNormalizationEntry } from '../../media-generation/normalization.types.js';
|
|
4
3
|
export type ImageGenerationResolution = '1K' | '2K' | '4K';
|
|
5
|
-
export type ImageGenerationQuality = 'low' | 'medium' | 'high' | 'auto';
|
|
4
|
+
export type ImageGenerationQuality = 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'auto';
|
|
6
5
|
export type ImageGenerationOutputFormat = 'png' | 'jpeg' | 'webp';
|
|
7
6
|
export type ImageGenerationBackground = 'transparent' | 'opaque' | 'auto';
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
/** Maximum images per call (defaults to 1 when omitted). */
|
|
11
|
-
maxCount?: number;
|
|
12
|
-
/** Provider supports an explicit `size` parameter. */
|
|
13
|
-
supportsSize?: boolean;
|
|
14
|
-
/** Provider supports `aspectRatio` parameter. */
|
|
15
|
-
supportsAspectRatio?: boolean;
|
|
16
|
-
/** Provider supports `resolution` parameter. */
|
|
17
|
-
supportsResolution?: boolean;
|
|
18
|
-
}
|
|
19
|
-
/** Edit-mode (image → image) capability slice. */
|
|
20
|
-
export interface ImageGenerationEditCapability {
|
|
21
|
-
enabled: boolean;
|
|
22
|
-
/** Max number of input reference images (1 = single ref). */
|
|
23
|
-
maxInputImages?: number;
|
|
24
|
-
supportsSize?: boolean;
|
|
25
|
-
supportsAspectRatio?: boolean;
|
|
26
|
-
}
|
|
27
|
-
/** Geometry constraints (allowed values for size / aspectRatio / resolution). */
|
|
28
|
-
export interface ImageGenerationGeometryCapability {
|
|
29
|
-
sizes?: string[];
|
|
30
|
-
aspectRatios?: string[];
|
|
31
|
-
resolutions?: ImageGenerationResolution[];
|
|
32
|
-
}
|
|
33
|
-
/** Output / styling capability slice. */
|
|
34
|
-
export interface ImageGenerationOutputCapability {
|
|
35
|
-
qualities?: ImageGenerationQuality[];
|
|
36
|
-
formats?: ImageGenerationOutputFormat[];
|
|
37
|
-
backgrounds?: ImageGenerationBackground[];
|
|
38
|
-
}
|
|
39
|
-
/** New nested capability shape. */
|
|
40
|
-
export interface ImageGenerationProviderCapabilities {
|
|
41
|
-
generate?: ImageGenerationGenerateCapability;
|
|
42
|
-
edit?: ImageGenerationEditCapability;
|
|
43
|
-
geometry?: ImageGenerationGeometryCapability;
|
|
44
|
-
output?: ImageGenerationOutputCapability;
|
|
45
|
-
}
|
|
7
|
+
export type { ImageGeometry as ImageGenerationGeometryCapability } from '../../../../packages/image-providers/src/types.js';
|
|
8
|
+
export type ImageGenerationProviderCapabilities = import('../../../../packages/image-providers/src/types.js').ImageCapabilities;
|
|
46
9
|
export interface ImageGenerationProviderConfiguredContext {
|
|
47
10
|
cfg?: Config;
|
|
48
11
|
agentId?: string;
|
|
@@ -112,16 +75,6 @@ export interface ImageGenerationSourceImage {
|
|
|
112
75
|
fileName?: string;
|
|
113
76
|
metadata?: Record<string, unknown>;
|
|
114
77
|
}
|
|
115
|
-
export type ImageGenerationIgnoredOverrideKey = 'size' | 'aspectRatio' | 'resolution' | 'quality' | 'outputFormat' | 'background';
|
|
116
|
-
export interface ImageGenerationIgnoredOverride {
|
|
117
|
-
key: ImageGenerationIgnoredOverrideKey;
|
|
118
|
-
value: string;
|
|
119
|
-
}
|
|
120
|
-
export interface ImageGenerationNormalization {
|
|
121
|
-
size?: MediaNormalizationEntry<string>;
|
|
122
|
-
aspectRatio?: MediaNormalizationEntry<string>;
|
|
123
|
-
resolution?: MediaNormalizationEntry<ImageGenerationResolution>;
|
|
124
|
-
}
|
|
125
78
|
export interface ImageGenerationRequest {
|
|
126
79
|
provider: string;
|
|
127
80
|
model: string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ImageGenerationProvider, ImageGenerationRequest } from './types.js';
|
|
2
|
+
export interface ImageGenerationValidationParams extends Pick<ImageGenerationRequest, 'size' | 'count' | 'aspectRatio' | 'resolution' | 'quality' | 'outputFormat' | 'background' | 'inputImages'> {
|
|
3
|
+
provider: ImageGenerationProvider;
|
|
4
|
+
}
|
|
5
|
+
export declare function validateImageGenerationRequest(params: ImageGenerationValidationParams): void;
|
|
6
|
+
export type { ImageGenerationProviderCapabilities } from './types.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { validateImageRequest } from "../../../../packages/image-providers/src/validation.js";
|
|
2
|
+
import "../../../../packages/image-providers/src/index.js";
|
|
3
|
+
//#region src/agent/image/generation/validation.ts
|
|
4
|
+
function validateImageGenerationRequest(params) {
|
|
5
|
+
validateImageRequest({
|
|
6
|
+
...params,
|
|
7
|
+
model: params.provider.defaultModel,
|
|
8
|
+
prompt: "validate",
|
|
9
|
+
inputImages: params.inputImages?.map((image, index) => ({
|
|
10
|
+
blob: new Blob([new Uint8Array(image.buffer)], { type: image.mimeType }),
|
|
11
|
+
fileName: image.fileName ?? `image-${index}`
|
|
12
|
+
}))
|
|
13
|
+
}, params.provider.capabilities);
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { validateImageGenerationRequest };
|
|
@@ -11,6 +11,7 @@ import { init_sqlite } from "../../storage/sqlite/index.js";
|
|
|
11
11
|
import { init_agent_scope, resolveDefaultAgentId } from "../agent-scope.js";
|
|
12
12
|
import { resolveEffectiveAgentConfigForAgent, resolveEffectiveAgentConfigForSession } from "../../config/agent-profile.js";
|
|
13
13
|
import { resolveUserContextSessionAccess } from "../../user-context/access-policy.js";
|
|
14
|
+
import { createPersonalAttentionTool } from "./personal-attention-tool.js";
|
|
14
15
|
import "../../../packages/browser-control-contract/src/index.js";
|
|
15
16
|
import { PERSONAL_TOOL_DESCRIPTIONS } from "../../personal-agent/policy.js";
|
|
16
17
|
import { getEmbeddedExecutionRunId, getEmbeddedExecutionSession } from "../embedded/execution-context.js";
|
|
@@ -508,6 +509,10 @@ var AgentToolsFactory = class AgentToolsFactory {
|
|
|
508
509
|
createPersonalTaskTool(productToolDeps),
|
|
509
510
|
createPersonalReadTool(productToolDeps),
|
|
510
511
|
...createPersonalRequestTools(productToolDeps),
|
|
512
|
+
createPersonalAttentionTool({
|
|
513
|
+
getConversationId: () => this.deps.getCurrentContext()?.conversationId,
|
|
514
|
+
getConfig: () => this.deps.getConfig?.()
|
|
515
|
+
}),
|
|
511
516
|
createPersonalPreferenceTool({
|
|
512
517
|
getCurrentConversationId: () => this.deps.getCurrentContext()?.conversationId,
|
|
513
518
|
onAgentCatalogMutate: this.deps.onAgentCatalogMutate
|