@xopcai/xopc 0.0.120 → 0.0.122
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/README.md +23 -3
- package/README.zh-CN.md +23 -3
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/dashscope/src/image-generation-provider.d.ts +6 -5
- package/dist/extensions/dashscope/src/image-generation-provider.js +40 -64
- package/dist/extensions/dashscope/src/image-generation-provider.js.map +1 -1
- package/dist/extensions/dashscope/src/index.d.ts +1 -1
- package/dist/extensions/dashscope/src/index.js +2 -2
- package/dist/extensions/dashscope/xopc.extension.json +3 -2
- package/dist/extensions/minimax/src/image-generation-provider.d.ts +7 -5
- package/dist/extensions/minimax/src/image-generation-provider.js +43 -37
- package/dist/extensions/minimax/src/image-generation-provider.js.map +1 -1
- package/dist/extensions/minimax/src/index.d.ts +1 -1
- package/dist/extensions/minimax/src/index.js +2 -2
- package/dist/extensions/minimax/xopc.extension.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/Combination-HAlzriaz.js +41 -0
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-APTlX9Sq.js → agent-avatar-dicebear-CK3s5cJo.js} +1 -1
- package/dist/gateway/static/root/assets/agents-SsQrj9B-.js +2 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-DTKc5HHT.js → app-management-settings-panel-CWsNHtTs.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BTciFrE9.js → appearance-settings-C4b8y6iZ.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-CYb6fame.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-CiHaUMII.js → archive-plugin-DAtNW3Ia.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-t4gSrNjL.js → attachment-load-Dm-RY54y.js} +1 -1
- package/dist/gateway/static/root/assets/automation-suggestion-card-BKHewSVT.js +1 -0
- package/dist/gateway/static/root/assets/automations-page-DpOOq1nk.js +1 -0
- package/dist/gateway/static/root/assets/{binary-plugins-BAbSldW5.js → binary-plugins-BG6Xnk71.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-BNr_82xl.js → block-editor-DfndiO3h.js} +28 -28
- package/dist/gateway/static/root/assets/browser-settings-page-9nXxgh4u.js +8 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-tzD702Gg.js → capability-presets-api-Cx93GLdw.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-AGhTueAc.js → capability-presets-settings-panel-D528_YFy.js} +1 -1
- package/dist/gateway/static/root/assets/{channel-recipient-api-DL_KzwGE.js → channel-recipient-api-DdPTtEs8.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-Ck-3h5lI.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-DL-fAqE_.js +2 -0
- package/dist/gateway/static/root/assets/directory-picker-path-field-D835EHJd.js +1 -0
- package/dist/gateway/static/root/assets/dist-Mys7eFJ5.js +1 -0
- package/dist/gateway/static/root/assets/dist-wO9a2_ID.js +1 -0
- package/dist/gateway/static/root/assets/dreaming-settings-CCa1F7Fg.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-Dl2kO0Sf.js → extension-debug-page-W2ITCPSA.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DmbLPsx_.js → extension-page-DrvUytvn.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-qM8aLT5u.js +1 -0
- package/dist/gateway/static/root/assets/{fetch-B3ME5Eri.js → fetch-ovkvM8KQ.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-DI9_BBTo.js → gateway-config-api-BB3biuD0.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-mmmnIH27.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CSZQTz6K.js → gateway-startup-retry-CanQ8UcR.js} +1 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-CNqNdEkQ.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-Ceu5zrN6.js +1 -0
- package/dist/gateway/static/root/assets/{goals-config-api-Bhzqrp2w.js → goals-config-api-BBOX6mUl.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-BP1kfvWv.js +2 -0
- package/dist/gateway/static/root/assets/goals-settings-Bh3A7OZV.js +1 -0
- package/dist/gateway/static/root/assets/heartbeat-settings-YoYgKlfX.js +1 -0
- package/dist/gateway/static/root/assets/index-DdqSO9R2.js +191 -0
- package/dist/gateway/static/root/assets/index-jGB-2nI-.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-kMp08SlX.js → keyboard-shortcuts-settings-B4TKJHla.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-BgVk5DvZ.js +2 -0
- package/dist/gateway/static/root/assets/{markdown-split-Bc0w40vz.js → markdown-split-DcFtdLci.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-DJ_HvgIy.js → media-plugins-B6SmeLVB.js} +1 -1
- package/dist/gateway/static/root/assets/messages-B5O4OIEo.js +3 -0
- package/dist/gateway/static/root/assets/models-hub-panel-BU0x8PGP.js +2 -0
- package/dist/gateway/static/root/assets/notes-page-D6JYVP4I.js +1 -0
- package/dist/gateway/static/root/assets/notes-workbench-mqRJYnJS.js +2 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BbA7sRd_.js → preview-open-alternatives-C29O19s7.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-DOTgzoeh.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-DGUIb4y5.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-DVKKUj3u.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-Dividh61.js → save-bar-controls-B4ad9GfB.js} +1 -1
- package/dist/gateway/static/root/assets/schedule-field-DdYncfLR.js +1 -0
- package/dist/gateway/static/root/assets/schema-form-BMTrDE-7.js +1 -0
- package/dist/gateway/static/root/assets/segmented-styles-BL8oLBEp.js +1 -0
- package/dist/gateway/static/root/assets/sessions-page-BVbzUWxW.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-DrNNoSqE.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-BMCOfuE_.js → settings-collapsible-section-MwTW2eK4.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-DBkGwpIN.js → settings-form-section-Dg6LBbcr.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-CMDqgeMR.js +1 -0
- package/dist/gateway/static/root/assets/settings-page-layout-BX4T-OLF.js +1 -0
- package/dist/gateway/static/root/assets/setup-status-panel-Ce1pcFtR.js +1 -0
- package/dist/gateway/static/root/assets/share-preview-page-DWE-dUFh.js +2 -0
- package/dist/gateway/static/root/assets/shares-settings-aKSraR8l.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-CS-FU_B-.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-BaF3u0LA.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-CrmEnyX4.js → system-settings-panel-Dd6Y35Cm.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-BAsGn25g.js → typed-models-lib-Cx6XV5A2.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-C7vcAoGb.js → use-channel-catalog-D4sMbmy7.js} +1 -1
- package/dist/gateway/static/root/assets/user-profile-settings-panel-Bx-hjMQc.js +1 -0
- package/dist/gateway/static/root/assets/{utils-Dl9efgnV.js → utils-D7b_vZnv.js} +1 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-CkhbRt1q.js +1 -0
- package/dist/gateway/static/root/assets/workflow-run-setup-panel--TdohF5N.js +3 -0
- package/dist/gateway/static/root/assets/workflow-start-dialog-B0lavx_o.js +1 -0
- package/dist/gateway/static/root/assets/workflows-page-CZR05Bu_.js +18 -0
- package/dist/gateway/static/root/index.html +7 -8
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.d.ts +2 -0
- package/dist/src/agent/agent-manager.js +47 -7
- package/dist/src/agent/agent-manager.js.map +1 -1
- package/dist/src/agent/context/project-context.d.ts +19 -0
- package/dist/src/agent/context/project-context.js +90 -0
- package/dist/src/agent/context/project-context.js.map +1 -0
- package/dist/src/agent/embedded/xopc-auth-storage.d.ts +1 -5
- package/dist/src/agent/embedded/xopc-auth-storage.js +2 -8
- package/dist/src/agent/embedded/xopc-auth-storage.js.map +1 -1
- package/dist/src/agent/embedded/xopc-tools-bridge.js +23 -0
- package/dist/src/agent/embedded/xopc-tools-bridge.js.map +1 -1
- package/dist/src/agent/goals/checklist-judge.js +1 -1
- package/dist/src/agent/goals/checklist-judge.js.map +1 -1
- package/dist/src/agent/goals/goal-locale.js +2 -2
- package/dist/src/agent/goals/judge.js +1 -1
- package/dist/src/agent/goals/judge.js.map +1 -1
- package/dist/src/agent/image/tool-model-config.d.ts +2 -0
- package/dist/src/agent/image/tool-model-config.js +2 -2
- package/dist/src/agent/image/tool-model-config.js.map +1 -1
- package/dist/src/agent/image/understanding/pi-ai-provider.js +1 -1
- package/dist/src/agent/image/understanding/pi-ai-provider.js.map +1 -1
- package/dist/src/agent/memory/compaction.d.ts +1 -1
- package/dist/src/agent/memory/compaction.js +1 -1
- package/dist/src/agent/memory/compaction.js.map +1 -1
- package/dist/src/agent/memory/types.d.ts +1 -0
- package/dist/src/agent/middleware/self-verify.d.ts +3 -0
- package/dist/src/agent/middleware/self-verify.js +18 -0
- package/dist/src/agent/middleware/self-verify.js.map +1 -1
- package/dist/src/agent/orchestration/agent-event-handler.js +28 -3
- package/dist/src/agent/orchestration/agent-event-handler.js.map +1 -1
- package/dist/src/agent/prompt/sections/tooling.js +21 -5
- package/dist/src/agent/prompt/sections/tooling.js.map +1 -1
- package/dist/src/agent/prompt/service-prompt-builder.d.ts +1 -0
- package/dist/src/agent/prompt/service-prompt-builder.js +3 -0
- package/dist/src/agent/prompt/service-prompt-builder.js.map +1 -1
- package/dist/src/agent/prompt/system-prompt-params.d.ts +2 -0
- package/dist/src/agent/prompt/system-prompt-params.js +1 -0
- package/dist/src/agent/prompt/system-prompt-params.js.map +1 -1
- package/dist/src/agent/prompt/system-prompt.d.ts +2 -0
- package/dist/src/agent/prompt/system-prompt.js +14 -1
- package/dist/src/agent/prompt/system-prompt.js.map +1 -1
- package/dist/src/agent/sandbox/path-policy.js +30 -6
- package/dist/src/agent/sandbox/path-policy.js.map +1 -1
- package/dist/src/agent/service/btw-query.js +1 -1
- package/dist/src/agent/service/btw-query.js.map +1 -1
- package/dist/src/agent/service.js +4 -3
- package/dist/src/agent/service.js.map +1 -1
- package/dist/src/agent/session/session-config-service.js +6 -1
- package/dist/src/agent/session/session-config-service.js.map +1 -1
- package/dist/src/agent/session/session-hydrator.js +7 -3
- package/dist/src/agent/session/session-hydrator.js.map +1 -1
- package/dist/src/agent/session/session-inspector.js +9 -5
- package/dist/src/agent/session/session-inspector.js.map +1 -1
- package/dist/src/agent/starter-agents.js +18 -47
- package/dist/src/agent/starter-agents.js.map +1 -1
- package/dist/src/agent/tools/image-generate-tool.js +12 -1
- package/dist/src/agent/tools/image-generate-tool.js.map +1 -1
- package/dist/src/agent/tools/session-search-tool.js +1 -1
- package/dist/src/agent/tools/session-search-tool.js.map +1 -1
- package/dist/src/agent/tools/web-extract.js +1 -1
- package/dist/src/agent/tools/web-extract.js.map +1 -1
- package/dist/src/agent/workflow/index.js +2 -2
- package/dist/src/agent/workflow/runtime.js +1 -1
- package/dist/src/agent-manifest/index.js +2 -2
- package/dist/src/agent-manifest/schema.d.ts +66 -0
- package/dist/src/agent-manifest/schema.js +28 -2
- package/dist/src/agent-manifest/schema.js.map +1 -1
- package/dist/src/automations/api/routes.js +13 -2
- package/dist/src/automations/api/routes.js.map +1 -1
- package/dist/src/automations/domain/types.d.ts +2 -0
- package/dist/src/automations/domain/validation.d.ts +3 -0
- package/dist/src/automations/domain/validation.js +1 -0
- package/dist/src/automations/domain/validation.js.map +1 -1
- package/dist/src/automations/draft/automation-draft-service.js +1 -1
- package/dist/src/automations/draft/automation-draft-service.js.map +1 -1
- package/dist/src/automations/draft/automation-draft-validator.d.ts +1 -0
- package/dist/src/automations/service/action-executor.js +3 -1
- package/dist/src/automations/service/action-executor.js.map +1 -1
- package/dist/src/automations/service/automation-service.d.ts +4 -1
- package/dist/src/automations/service/automation-service.js +2 -2
- package/dist/src/automations/service/automation-service.js.map +1 -1
- package/dist/src/automations/storage/automation-repository.d.ts +3 -1
- package/dist/src/automations/storage/automation-repository.js +7 -5
- package/dist/src/automations/storage/automation-repository.js.map +1 -1
- package/dist/src/automations/storage/automation-run-repository.d.ts +1 -0
- package/dist/src/automations/storage/automation-run-repository.js +12 -1
- package/dist/src/automations/storage/automation-run-repository.js.map +1 -1
- package/dist/src/chat-commands/context.js +2 -1
- package/dist/src/chat-commands/context.js.map +1 -1
- package/dist/src/cli/command-loaders.js +1 -0
- package/dist/src/cli/command-loaders.js.map +1 -1
- package/dist/src/cli/command-manifest.js +4 -0
- package/dist/src/cli/command-manifest.js.map +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/goal.js +27 -4
- package/dist/src/cli/commands/goal.js.map +1 -1
- package/dist/src/cli/commands/onboard/model.js +161 -11
- package/dist/src/cli/commands/onboard/model.js.map +1 -1
- package/dist/src/cli/commands/project.d.ts +4 -0
- package/dist/src/cli/commands/project.js +239 -0
- package/dist/src/cli/commands/project.js.map +1 -0
- package/dist/src/config/default-model.d.ts +11 -0
- package/dist/src/config/default-model.js +19 -0
- package/dist/src/config/default-model.js.map +1 -0
- package/dist/src/config/index.js +2 -2
- package/dist/src/config/schema.d.ts +71 -11
- package/dist/src/config/schema.js +57 -22
- package/dist/src/config/schema.js.map +1 -1
- package/dist/src/connectors/registries/smithery.js +10 -9
- package/dist/src/connectors/registries/smithery.js.map +1 -1
- package/dist/src/daemon/install-plan.js +2 -1
- package/dist/src/daemon/install-plan.js.map +1 -1
- package/dist/src/gateway/global-defaults-admin.js +6 -16
- package/dist/src/gateway/global-defaults-admin.js.map +1 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +24 -0
- package/dist/src/gateway/hono/routes/agents.js +1 -79
- package/dist/src/gateway/hono/routes/agents.js.map +1 -1
- package/dist/src/gateway/hono/routes/goals.js +51 -4
- package/dist/src/gateway/hono/routes/goals.js.map +1 -1
- package/dist/src/gateway/hono/routes/index.js +2 -0
- package/dist/src/gateway/hono/routes/index.js.map +1 -1
- package/dist/src/gateway/hono/routes/memory.js +5 -1
- package/dist/src/gateway/hono/routes/memory.js.map +1 -1
- package/dist/src/gateway/hono/routes/models.js +132 -14
- package/dist/src/gateway/hono/routes/models.js.map +1 -1
- package/dist/src/gateway/hono/routes/notes.js +5 -0
- package/dist/src/gateway/hono/routes/notes.js.map +1 -1
- package/dist/src/gateway/hono/routes/projects.d.ts +3 -0
- package/dist/src/gateway/hono/routes/projects.js +578 -0
- package/dist/src/gateway/hono/routes/projects.js.map +1 -0
- package/dist/src/gateway/hono/routes/sessions.js +47 -7
- package/dist/src/gateway/hono/routes/sessions.js.map +1 -1
- package/dist/src/gateway/hono/routes/voice.js +1 -1
- package/dist/src/gateway/hono/routes/voice.js.map +1 -1
- package/dist/src/gateway/hono/routes/workflows.js +27 -4
- package/dist/src/gateway/hono/routes/workflows.js.map +1 -1
- package/dist/src/gateway/image-capabilities.d.ts +11 -1
- package/dist/src/gateway/image-capabilities.js +32 -43
- package/dist/src/gateway/image-capabilities.js.map +1 -1
- package/dist/src/gateway/service.d.ts +3 -0
- package/dist/src/gateway/service.js +10 -3
- package/dist/src/gateway/service.js.map +1 -1
- package/dist/src/gateway/workspace-editor-path.js +9 -1
- package/dist/src/gateway/workspace-editor-path.js.map +1 -1
- package/dist/src/generated/bundled-image-generation-providers.d.ts +4 -2
- package/dist/src/generated/bundled-image-generation-providers.js +6 -4
- package/dist/src/generated/bundled-image-generation-providers.js.map +1 -1
- package/dist/src/goals/goal-service.d.ts +1 -1
- package/dist/src/goals/goal-service.js +2 -1
- package/dist/src/goals/goal-service.js.map +1 -1
- package/dist/src/goals/goal-store.d.ts +1 -1
- package/dist/src/goals/goal-store.js +12 -6
- package/dist/src/goals/goal-store.js.map +1 -1
- package/dist/src/goals/goal-workflow-judge.js +1 -1
- package/dist/src/goals/types.d.ts +3 -0
- package/dist/src/i18n/goals-bundle.js +1 -1
- package/dist/src/i18n/index.js +1 -1
- package/dist/src/i18n/share-tool-bundle.js +2 -2
- package/dist/src/media/paths.js +3 -4
- package/dist/src/media/paths.js.map +1 -1
- package/dist/src/notes/agent-context.js +2 -2
- package/dist/src/notes/service.js +1 -1
- package/dist/src/notes/service.js.map +1 -1
- package/dist/src/projects/automation-bind.d.ts +1 -0
- package/dist/src/projects/automation-bind.js +16 -0
- package/dist/src/projects/automation-bind.js.map +1 -0
- package/dist/src/projects/goal-bind.d.ts +4 -0
- package/dist/src/projects/goal-bind.js +40 -0
- package/dist/src/projects/goal-bind.js.map +1 -0
- package/dist/src/projects/index.d.ts +11 -0
- package/dist/src/projects/index.js +11 -0
- package/dist/src/projects/memory-bind.d.ts +1 -0
- package/dist/src/projects/memory-bind.js +16 -0
- package/dist/src/projects/memory-bind.js.map +1 -0
- package/dist/src/projects/project-agent.d.ts +10 -0
- package/dist/src/projects/project-agent.js +27 -0
- package/dist/src/projects/project-agent.js.map +1 -0
- package/dist/src/projects/project-loop.d.ts +58 -0
- package/dist/src/projects/project-loop.js +118 -0
- package/dist/src/projects/project-loop.js.map +1 -0
- package/dist/src/projects/project-service.d.ts +26 -0
- package/dist/src/projects/project-service.js +94 -0
- package/dist/src/projects/project-service.js.map +1 -0
- package/dist/src/projects/project-store.d.ts +31 -0
- package/dist/src/projects/project-store.js +193 -0
- package/dist/src/projects/project-store.js.map +1 -0
- package/dist/src/projects/session-bind.d.ts +5 -0
- package/dist/src/projects/session-bind.js +46 -0
- package/dist/src/projects/session-bind.js.map +1 -0
- package/dist/src/projects/types.d.ts +60 -0
- package/dist/src/projects/types.js +1 -0
- package/dist/src/projects/workflow-bind.d.ts +1 -0
- package/dist/src/projects/workflow-bind.js +16 -0
- package/dist/src/projects/workflow-bind.js.map +1 -0
- package/dist/src/projects/workspace.d.ts +5 -0
- package/dist/src/projects/workspace.js +25 -0
- package/dist/src/projects/workspace.js.map +1 -0
- package/dist/src/providers/domestic-presets.d.ts +615 -0
- package/dist/src/providers/domestic-presets.js +834 -0
- package/dist/src/providers/domestic-presets.js.map +1 -0
- package/dist/src/providers/env-keys.js +29 -5
- package/dist/src/providers/env-keys.js.map +1 -1
- package/dist/src/providers/extension-stream-bridge.js +1 -1
- package/dist/src/providers/extension-stream-bridge.js.map +1 -1
- package/dist/src/providers/index.d.ts +5 -5
- package/dist/src/providers/index.js +101 -21
- package/dist/src/providers/index.js.map +1 -1
- package/dist/src/providers/model-discovery.d.ts +17 -0
- package/dist/src/providers/model-discovery.js +61 -0
- package/dist/src/providers/model-discovery.js.map +1 -0
- package/dist/src/providers/model-registry.d.ts +1 -1
- package/dist/src/providers/model-registry.js +1 -1
- package/dist/src/providers/model-registry.js.map +1 -1
- package/dist/src/providers/presentation.js +185 -14
- package/dist/src/providers/presentation.js.map +1 -1
- package/dist/src/session/index.d.ts +1 -1
- package/dist/src/session/index.js +3 -3
- package/dist/src/session/session-title.js +1 -1
- package/dist/src/session/session-title.js.map +1 -1
- package/dist/src/session/session-workspace.d.ts +4 -2
- package/dist/src/session/session-workspace.js +10 -3
- package/dist/src/session/session-workspace.js.map +1 -1
- package/dist/src/session/types.d.ts +3 -0
- package/dist/src/session/types.js.map +1 -1
- package/dist/src/storage/sqlite/memory-records-repository.d.ts +3 -0
- package/dist/src/storage/sqlite/memory-records-repository.js +16 -5
- package/dist/src/storage/sqlite/memory-records-repository.js.map +1 -1
- package/dist/src/storage/sqlite/migrations/019_projects.sql +40 -0
- package/dist/src/storage/sqlite/migrations/020_project_default_agent.sql +1 -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/migrations/runner.js.map +1 -1
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/notes-repository.js +20 -4
- package/dist/src/storage/sqlite/notes-repository.js.map +1 -1
- package/dist/src/storage/sqlite/row-mappers.d.ts +2 -0
- package/dist/src/storage/sqlite/row-mappers.js +2 -0
- package/dist/src/storage/sqlite/row-mappers.js.map +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/session-repository.js +10 -5
- package/dist/src/storage/sqlite/session-repository.js.map +1 -1
- package/dist/src/storage/sqlite/transcript-repository.js +8 -0
- package/dist/src/storage/sqlite/transcript-repository.js.map +1 -1
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/tui/tui-commands.js +145 -0
- package/dist/src/tui/tui-commands.js.map +1 -1
- package/dist/src/tui/xopc-tui-keybindings.d.ts +1 -1
- package/dist/src/voice/tts/summarize.js +1 -1
- package/dist/src/voice/tts/summarize.js.map +1 -1
- package/dist/src/workflows/domain/run.d.ts +1 -0
- package/dist/src/workflows/domain/run.js.map +1 -1
- package/dist/src/workflows/draft/workflow-draft-service.js +1 -1
- package/dist/src/workflows/draft/workflow-draft-service.js.map +1 -1
- package/dist/src/workflows/index.js +1 -1
- package/dist/src/workflows/service/workflow-run-service.d.ts +1 -0
- package/dist/src/workflows/service/workflow-run-service.js +18 -4
- package/dist/src/workflows/service/workflow-run-service.js.map +1 -1
- package/dist/src/workflows/service/workflow-run-service.types.d.ts +2 -0
- package/dist/src/workflows/service/workflow-session-bridge.d.ts +1 -0
- package/dist/src/workflows/service/workflow-session-bridge.js +3 -0
- package/dist/src/workflows/service/workflow-session-bridge.js.map +1 -1
- package/dist/src/workflows/store/run-index-store.d.ts +1 -0
- package/dist/src/workflows/store/run-index-store.js +13 -3
- package/dist/src/workflows/store/run-index-store.js.map +1 -1
- package/dist/src/workflows/store/run-store.d.ts +3 -1
- package/dist/src/workflows/store/run-store.js +5 -2
- package/dist/src/workflows/store/run-store.js.map +1 -1
- package/package.json +15 -6
- package/dist/gateway/static/root/assets/Combination-BzaXOLd9.js +0 -41
- package/dist/gateway/static/root/assets/agents-CFW_FS_V.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-DT52OrbM.js +0 -1
- package/dist/gateway/static/root/assets/automation-suggestion-card-CtysjSoQ.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-B2YvT3ES.js +0 -1
- package/dist/gateway/static/root/assets/browser-settings-page-BQEXPhDU.js +0 -8
- package/dist/gateway/static/root/assets/channels-settings-DRTutLlN.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-DneJVuge.js +0 -2
- package/dist/gateway/static/root/assets/dist-By6Rh2ee.js +0 -1
- package/dist/gateway/static/root/assets/dist-CkobR7mk.js +0 -1
- package/dist/gateway/static/root/assets/dist-DokQNVMQ.js +0 -1
- package/dist/gateway/static/root/assets/dreaming-settings-BEwWA1yf.js +0 -1
- package/dist/gateway/static/root/assets/extension-settings-page-BS2rx40e.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-DAFI_T0W.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-DLuz4jC9.js +0 -1
- package/dist/gateway/static/root/assets/goals-page-DTAfv9Ft.js +0 -2
- package/dist/gateway/static/root/assets/goals-settings-CWN2iirQ.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-CkkkHvOi.js +0 -1
- package/dist/gateway/static/root/assets/index-CnjzMw5i.js +0 -191
- package/dist/gateway/static/root/assets/index-E1QinYKp.css +0 -1
- package/dist/gateway/static/root/assets/logs-page-CDXDlS_W.js +0 -2
- package/dist/gateway/static/root/assets/messages-CISb1HLv.js +0 -3
- package/dist/gateway/static/root/assets/models-hub-panel-BTwxMIgZ.js +0 -2
- package/dist/gateway/static/root/assets/note-detail-page-BBfOeB0m.js +0 -2
- package/dist/gateway/static/root/assets/note-image-lightbox-4zntqpZq.js +0 -1
- package/dist/gateway/static/root/assets/note-time-hm6JO_Wi.js +0 -1
- package/dist/gateway/static/root/assets/notes-page-VocWOjoK.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CXwjuD_Q.js +0 -1
- package/dist/gateway/static/root/assets/schedule-field-pRheF2CO.js +0 -1
- package/dist/gateway/static/root/assets/schema-form-D6PiPxfr.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-CpcVySQK.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BVy_TawT.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-CZpNyCWn.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-layout-NxoW5Y57.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-MVHLLu_a.js +0 -1
- package/dist/gateway/static/root/assets/share-preview-page-B0suFCfj.js +0 -2
- package/dist/gateway/static/root/assets/shares-settings-C6DBbQGo.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-6hJmhwSn.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-Im1MA0Iw.js +0 -2
- package/dist/gateway/static/root/assets/user-profile-settings-panel-QAQWGelF.js +0 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-D-6XueTv.js +0 -1
- package/dist/gateway/static/root/assets/voice-player-store-CMC5NOJp.js +0 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-DVPllR4k.js +0 -3
- package/dist/gateway/static/root/assets/workflows-page-B94WISTW.js +0 -18
package/README.md
CHANGED
|
@@ -39,6 +39,13 @@
|
|
|
39
39
|
- **One-person companies and solo builders** — use the same assistant from CLI, TUI, Web, Desktop, Telegram, WeChat, and Feishu/Lark.
|
|
40
40
|
- **Local-first AI workflows** — bring your own keys, mix cloud/local models, add skills/extensions, and keep data under **`~/.xopc/`**.
|
|
41
41
|
|
|
42
|
+
## What you can do after install
|
|
43
|
+
|
|
44
|
+
- Keep a side project moving with remembered goals, blockers, next actions, and feedback.
|
|
45
|
+
- Use the same assistant from terminal, desktop, browser, mobile, Telegram, WeChat, or Feishu/Lark.
|
|
46
|
+
- Bring your own API keys or local models while keeping config and state under **`~/.xopc/`**.
|
|
47
|
+
- Schedule reviews, reminders, summaries, and workflow runs so important work keeps resurfacing.
|
|
48
|
+
|
|
42
49
|
---
|
|
43
50
|
|
|
44
51
|
<a id="get-started"></a>
|
|
@@ -141,10 +148,23 @@ Windows git install: `& ([scriptblock]::Create((irm https://xopc.ai/install.ps1)
|
|
|
141
148
|
|
|
142
149
|
- 🏠 **Your machine** — Data and config under **`~/.xopc/`**. No mandatory cloud or surprise bills.
|
|
143
150
|
- 🔑 **Bring your own keys** — OpenAI, Anthropic, Google, DeepSeek, Ollama, LM Studio, vLLM, and **20+** providers. Mix cloud and local; switch catalog models in one config line. See **[Models](https://xopcai.github.io/xopc/models)**.
|
|
144
|
-
- 📱 **One brain, every screen** — Same assistant in terminal, browser, desktop, [mobile app](
|
|
151
|
+
- 📱 **One brain, every screen** — Same assistant in terminal, browser, desktop, [mobile app](./apps/mobile-expo), and IM. No sync layer — one system.
|
|
145
152
|
- 🧩 **Grows with you** — **`xopc skills install`** · **`xopc extensions install`** for tools, channels, and UI panels; multi-agent routing per context.
|
|
146
153
|
- ⏰ **Proactive** — **Automations** for scheduled summaries, reminders, and workflow runs; **workflows** for fan-out subagent tasks; **multi-agent** routing with isolated workspaces, tools, and prompts.
|
|
147
154
|
|
|
155
|
+
## How xopc compares
|
|
156
|
+
|
|
157
|
+
xopc is not trying to replace every coding agent or office agent. It is the local-first system layer for people who want one assistant to remember goals, keep state, run automations, and stay reachable across surfaces.
|
|
158
|
+
|
|
159
|
+
| Product | Best at | Why use xopc too |
|
|
160
|
+
| --- | --- | --- |
|
|
161
|
+
| **Codex** | Software development in terminal, IDE, and cloud tasks | xopc is broader than repo work: long-running goals, BYOK/local models, scheduled loops, gateway APIs, desktop/web/mobile, and messengers share one local state. |
|
|
162
|
+
| **Claude Code** | Project-level coding: codebase navigation, edits, tests, git workflows | xopc is a personal Agent OS for coding plus life/work loops; it can coordinate models, channels, skills, workflows, and automations outside one codebase. |
|
|
163
|
+
| **Qoder / QoderWork** | Agentic coding platform plus local-first office work companion | xopc is open-source and hackable, with explicit local state under **`~/.xopc/`**, configurable providers, self-hosted gateway, and extension points. |
|
|
164
|
+
| **WorkBuddy** | Office deliverables such as reports, decks, spreadsheets, research, and data analysis | xopc is for users who want to own the runtime: bring your own keys, mix local/cloud models, wire channels, and keep long-term project context locally. |
|
|
165
|
+
|
|
166
|
+
Choose xopc when you want a **self-hosted, long-term AI assistant** that is not locked to one vendor, one IDE, one chat surface, or one task type. See the full comparison in **[Comparison](https://xopcai.github.io/xopc/comparison)**.
|
|
167
|
+
|
|
148
168
|
---
|
|
149
169
|
|
|
150
170
|
## Where to chat
|
|
@@ -155,7 +175,7 @@ Windows git install: `& ([scriptblock]::Create((irm https://xopc.ai/install.ps1)
|
|
|
155
175
|
| **TUI** | `xopc` or `xopc tui` (remote: `xopc tui --url …`) | Full keyboard, streaming, fastest terminal path |
|
|
156
176
|
| **CLI** | `xopc agent -i` / `xopc agent -m "…"` | Scripts and minimal TTY |
|
|
157
177
|
| **Web** | `xopc gateway` → open console URL | Chat, settings, logs in the browser |
|
|
158
|
-
| **Mobile** | [
|
|
178
|
+
| **Mobile** | [mobile app](./apps/mobile-expo) + gateway pairing ([mobile app](https://xopcai.github.io/xopc/mobile-app), [remote access](https://xopcai.github.io/xopc/remote-access)) | Continue your loop on iOS/Android |
|
|
159
179
|
| **Messengers** | `channels.*` + gateway | Telegram, WeChat, Feishu/Lark |
|
|
160
180
|
|
|
161
181
|
---
|
|
@@ -256,7 +276,7 @@ For most users, install the **PC desktop app** from GitHub Releases and complete
|
|
|
256
276
|
xopc is organized around goal loops: direction, next action, feedback, and recalibration across multiple surfaces.
|
|
257
277
|
|
|
258
278
|
**Can I use it from my phone or messengers?**
|
|
259
|
-
Yes. Start with local TUI first; when ready, run the gateway and use [
|
|
279
|
+
Yes. Start with local TUI first; when ready, run the gateway and use the [mobile app](./apps/mobile-expo) on iOS/Android, or configure Telegram, WeChat, or Feishu/Lark.
|
|
260
280
|
|
|
261
281
|
<a id="desktop-app"></a>
|
|
262
282
|
<a id="electron-desktop"></a>
|
package/README.zh-CN.md
CHANGED
|
@@ -39,6 +39,13 @@
|
|
|
39
39
|
- **独立开发者 / 一人公司** —— 同一个助手覆盖 CLI、TUI、网页、桌面、Telegram、微信和飞书/Lark。
|
|
40
40
|
- **本地优先 AI 工作流** —— 使用你自己的 API Key,云端/本地模型混用,支持技能和扩展,数据默认保存在 **`~/.xopc/`**。
|
|
41
41
|
|
|
42
|
+
## 安装后你能立刻做什么
|
|
43
|
+
|
|
44
|
+
- 让一个 side project 持续向前:记录目标、阻碍、下一步行动和反馈。
|
|
45
|
+
- 在终端、桌面、浏览器、手机、Telegram、微信或飞书/Lark 中使用同一个助手。
|
|
46
|
+
- 使用自己的 API Key 或本地模型,同时把配置和状态保存在 **`~/.xopc/`**。
|
|
47
|
+
- 设置复盘、提醒、摘要和工作流运行,让重要事项定期回到视野里。
|
|
48
|
+
|
|
42
49
|
---
|
|
43
50
|
|
|
44
51
|
<a id="get-started"></a>
|
|
@@ -141,10 +148,23 @@ Windows 源码安装:`& ([scriptblock]::Create((irm https://xopc.ai/install.ps
|
|
|
141
148
|
|
|
142
149
|
- 🏠 **你的机器** — 配置与数据在 **`~/.xopc/`**,无强制云端、无意外账单。
|
|
143
150
|
- 🔑 **使用自己的密钥** — OpenAI、Anthropic、Google、DeepSeek、Ollama、LM Studio、vLLM 等 **20+** 厂商;云端和本地模型可混用,一行配置即可切换模型。详见 **[模型](https://xopcai.github.io/xopc/zh/models)**。
|
|
144
|
-
- 📱 **多个入口,同一个助手** — 终端、浏览器、桌面、[移动端 App](
|
|
151
|
+
- 📱 **多个入口,同一个助手** — 终端、浏览器、桌面、[移动端 App](./apps/mobile-expo)、即时通讯共用同一套上下文,无需额外同步。
|
|
145
152
|
- 🧩 **可按需扩展** — 通过 **`xopc skills install`** 和 **`xopc extensions install`** 扩展工具、频道与 UI;多 Agent 可按场景隔离。
|
|
146
153
|
- ⏰ **支持主动任务** — 用 **自动化** 做定时摘要、提醒与工作流运行;用 **工作流**扇出多子 Agent 任务;用 **多 Agent** 管理不同工作区、工具与系统提示词。
|
|
147
154
|
|
|
155
|
+
## 和 Codex / Claude Code / QoderWork / WorkBuddy 的区别
|
|
156
|
+
|
|
157
|
+
xopc 不是要替代所有编程 Agent 或办公 Agent。它更像一个本地优先的系统层:让同一个助手记住长期目标、保留状态、运行自动化,并在多个入口中持续可用。
|
|
158
|
+
|
|
159
|
+
| 产品 | 更擅长 | 为什么还需要 xopc |
|
|
160
|
+
| --- | --- | --- |
|
|
161
|
+
| **Codex** | 终端、IDE 和云端的软件开发任务 | xopc 不只服务一个代码仓库:长期目标、BYOK/本地模型、定时循环、Gateway API、桌面/网页/手机和 IM 都共享同一套本地状态。 |
|
|
162
|
+
| **Claude Code** | 项目级编码:读代码、改文件、跑测试、处理 git 工作流 | xopc 是面向个人长期工作的 Agent OS:既能服务 coding,也能协调模型、频道、技能、工作流和自动化。 |
|
|
163
|
+
| **Qoder / QoderWork** | Agentic coding 平台与本地优先办公助手 | xopc 开源、可自托管、可改造,状态明确放在 **`~/.xopc/`**,支持自选 provider、自托管 gateway 和扩展机制。 |
|
|
164
|
+
| **WorkBuddy** | 办公交付物:报告、PPT、表格、调研、数据分析 | xopc 更适合想掌控运行环境的人:使用自己的 key,混用本地/云端模型,接入 IM,并把长期项目上下文留在本地。 |
|
|
165
|
+
|
|
166
|
+
如果你想要的是一个**自托管、长期运行、不绑定单一厂商/IDE/聊天入口/任务类型**的 AI 助手,xopc 更适合。完整对比见 **[产品对比](https://xopcai.github.io/xopc/zh/comparison)**。
|
|
167
|
+
|
|
148
168
|
---
|
|
149
169
|
|
|
150
170
|
## 在哪里聊
|
|
@@ -155,7 +175,7 @@ Windows 源码安装:`& ([scriptblock]::Create((irm https://xopc.ai/install.ps
|
|
|
155
175
|
| **TUI** | `xopc` 或 `xopc tui`(远程:`xopc tui --url …`) | 全键盘、流式输出,最快终端路径 |
|
|
156
176
|
| **CLI** | `xopc agent -i` / `xopc agent -m "…"` | 脚本、最小终端环境 |
|
|
157
177
|
| **网页** | `xopc gateway` → 打开控制台地址 | 聊天、设置、日志 |
|
|
158
|
-
| **手机** | [
|
|
178
|
+
| **手机** | [移动端 App](./apps/mobile-expo) + 网关配对([移动端 App](https://xopcai.github.io/xopc/zh/mobile-app)、[远程访问](https://xopcai.github.io/xopc/zh/remote-access)) | 在 iOS/Android 上继续推进循环 |
|
|
159
179
|
| **即时通讯** | 配置 `channels.*` 并启动网关 | Telegram、微信、飞书/Lark |
|
|
160
180
|
|
|
161
181
|
---
|
|
@@ -256,7 +276,7 @@ xopc extensions dev ./my-extension
|
|
|
256
276
|
xopc 围绕目标循环组织:方向、下一步、反馈、重新校准,并且同一个助手可以跨多个入口继续工作。
|
|
257
277
|
|
|
258
278
|
**能在手机或即时通讯里用吗?**
|
|
259
|
-
可以。建议先用本地 TUI 试用;确认方向后,再启动 gateway,用 [
|
|
279
|
+
可以。建议先用本地 TUI 试用;确认方向后,再启动 gateway,用 [移动端 App](./apps/mobile-expo) 连接 iOS/Android,或配置 Telegram、微信、飞书/Lark。
|
|
260
280
|
|
|
261
281
|
---
|
|
262
282
|
|
|
@@ -2,7 +2,7 @@ import type { ImageGenerationProvider, ImageGenerationRequest, ImageGenerationRe
|
|
|
2
2
|
/**
|
|
3
3
|
* Wan image model ids for **HTTP synchronous** `multimodal-generation/generation`.
|
|
4
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`):
|
|
5
|
+
* - **2.6** (`wan2.6-t2i`): Wan 2.6 T2I (`prompt_extend`, pixel `宽*高`, …).
|
|
6
6
|
* Wan 2.5 and earlier async-only models are not listed here.
|
|
7
7
|
* @see https://www.alibabacloud.com/help/en/model-studio/wan-image-generation-and-editing-api-reference
|
|
8
8
|
* @see https://www.alibabacloud.com/help/en/model-studio/text-to-image-v2-api-reference
|
|
@@ -17,11 +17,9 @@ export declare const DASHSCOPE_DEFAULT_IMAGE_MODEL: string;
|
|
|
17
17
|
export declare const DASHSCOPE_IMAGE_ENDPOINTS: {
|
|
18
18
|
readonly beijing: "https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation";
|
|
19
19
|
readonly singapore: "https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation";
|
|
20
|
-
readonly us: "https://dashscope-us.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation";
|
|
21
20
|
};
|
|
22
21
|
export type DashScopeImageRegion = keyof typeof DASHSCOPE_IMAGE_ENDPOINTS;
|
|
23
|
-
export declare function
|
|
24
|
-
export declare function resolveDashScopeImageGenerationUrl(req?: ImageGenerationRequest): string;
|
|
22
|
+
export declare function resolveDashScopeImageGenerationUrl(req?: ImageGenerationRequest, defaultRegion?: DashScopeImageRegion): string;
|
|
25
23
|
/** Map tool size (e.g. `1024x1024`) to DashScope `宽*高` format. */
|
|
26
24
|
export declare function mapSizeToDashScopeFormat(size?: string): string;
|
|
27
25
|
export declare function isWan27ImageModel(model: string): boolean;
|
|
@@ -33,5 +31,8 @@ export declare function mapSizeToWan27Format(size: string | undefined, modelId:
|
|
|
33
31
|
export declare function generateDashScopeImages(params: {
|
|
34
32
|
req: ImageGenerationRequest;
|
|
35
33
|
apiKey: string;
|
|
34
|
+
providerId?: string;
|
|
35
|
+
defaultRegion?: DashScopeImageRegion;
|
|
36
36
|
}): Promise<ImageGenerationResult>;
|
|
37
|
-
export declare function
|
|
37
|
+
export declare function buildDashScopeCnImageGenerationProvider(): ImageGenerationProvider;
|
|
38
|
+
export declare function buildDashScopeIntlImageGenerationProvider(): ImageGenerationProvider;
|
|
@@ -22,7 +22,7 @@ const log = createLogger("ImageGen:DashScope");
|
|
|
22
22
|
/**
|
|
23
23
|
* Wan image model ids for **HTTP synchronous** `multimodal-generation/generation`.
|
|
24
24
|
* - **2.7** (`wan2.7-image-pro` / `wan2.7-image`): see Wan 2.7 image API (size presets 1K/2K/4K, `thinking_mode`, …).
|
|
25
|
-
* - **2.6** (`wan2.6-t2i`):
|
|
25
|
+
* - **2.6** (`wan2.6-t2i`): Wan 2.6 T2I (`prompt_extend`, pixel `宽*高`, …).
|
|
26
26
|
* Wan 2.5 and earlier async-only models are not listed here.
|
|
27
27
|
* @see https://www.alibabacloud.com/help/en/model-studio/wan-image-generation-and-editing-api-reference
|
|
28
28
|
* @see https://www.alibabacloud.com/help/en/model-studio/text-to-image-v2-api-reference
|
|
@@ -64,66 +64,26 @@ const DASHSCOPE_CAPABILITIES = {
|
|
|
64
64
|
*/
|
|
65
65
|
const DASHSCOPE_IMAGE_ENDPOINTS = {
|
|
66
66
|
beijing: "https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation",
|
|
67
|
-
singapore: "https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation"
|
|
68
|
-
us: "https://dashscope-us.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation"
|
|
67
|
+
singapore: "https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation"
|
|
69
68
|
};
|
|
70
|
-
/** Gateway console region presets (must match {@link DASHSCOPE_IMAGE_ENDPOINTS}). */
|
|
71
|
-
const DASHSCOPE_IMAGE_UI = { regions: [
|
|
72
|
-
{
|
|
73
|
-
value: "beijing",
|
|
74
|
-
label: "China (Beijing)",
|
|
75
|
-
imageBaseUrl: DASHSCOPE_IMAGE_ENDPOINTS.beijing
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
value: "singapore",
|
|
79
|
-
label: "International (Singapore)",
|
|
80
|
-
imageBaseUrl: DASHSCOPE_IMAGE_ENDPOINTS.singapore
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
value: "us",
|
|
84
|
-
label: "United States (Virginia)",
|
|
85
|
-
imageBaseUrl: DASHSCOPE_IMAGE_ENDPOINTS.us
|
|
86
|
-
}
|
|
87
|
-
] };
|
|
88
69
|
const DEFAULT_OUTPUT_MIME = "image/png";
|
|
89
|
-
function
|
|
90
|
-
|
|
91
|
-
if (!raw) return "beijing";
|
|
92
|
-
if ([
|
|
93
|
-
"beijing",
|
|
94
|
-
"cn",
|
|
95
|
-
"china",
|
|
96
|
-
"bj"
|
|
97
|
-
].includes(raw)) return "beijing";
|
|
98
|
-
if ([
|
|
99
|
-
"singapore",
|
|
100
|
-
"sg",
|
|
101
|
-
"intl",
|
|
102
|
-
"international",
|
|
103
|
-
"sea",
|
|
104
|
-
"ap-southeast-1"
|
|
105
|
-
].includes(raw)) return "singapore";
|
|
106
|
-
if ([
|
|
107
|
-
"us",
|
|
108
|
-
"virginia",
|
|
109
|
-
"va",
|
|
110
|
-
"us-east-1"
|
|
111
|
-
].includes(raw)) return "us";
|
|
112
|
-
return "beijing";
|
|
70
|
+
function providerConfigId(req, fallback = "dashscope-cn") {
|
|
71
|
+
return req?.provider?.trim() || fallback;
|
|
113
72
|
}
|
|
114
|
-
function resolveDashScopeImageGenerationUrl(req) {
|
|
115
|
-
const
|
|
73
|
+
function resolveDashScopeImageGenerationUrl(req, defaultRegion = "beijing") {
|
|
74
|
+
const id = providerConfigId(req);
|
|
75
|
+
const cfgImageBase = readDashScopeCfgString(req?.cfg, id, "imageBaseUrl");
|
|
116
76
|
if (cfgImageBase) return cfgImageBase.replace(/\/+$/, "");
|
|
117
|
-
const cfgBase = readDashScopeCfgString(req?.cfg, "baseUrl");
|
|
77
|
+
const cfgBase = readDashScopeCfgString(req?.cfg, id, "baseUrl");
|
|
118
78
|
if (cfgBase) return cfgBase.replace(/\/+$/, "");
|
|
119
79
|
const trimmed = process.env.DASHSCOPE_IMAGE_BASE_URL?.trim();
|
|
120
80
|
if (trimmed) return trimmed.replace(/\/+$/, "");
|
|
121
|
-
return DASHSCOPE_IMAGE_ENDPOINTS[
|
|
81
|
+
return DASHSCOPE_IMAGE_ENDPOINTS[defaultRegion];
|
|
122
82
|
}
|
|
123
|
-
function readDashScopeCfgString(cfg, key) {
|
|
83
|
+
function readDashScopeCfgString(cfg, providerId, key) {
|
|
124
84
|
const providers = cfg?.providers;
|
|
125
85
|
if (!providers || typeof providers !== "object") return void 0;
|
|
126
|
-
const entry = providers[
|
|
86
|
+
const entry = providers[providerId];
|
|
127
87
|
if (!entry || typeof entry !== "object") return void 0;
|
|
128
88
|
const v = entry[key];
|
|
129
89
|
return typeof v === "string" && v.trim() ? v.trim() : void 0;
|
|
@@ -190,6 +150,7 @@ async function fetchImageBuffers(urls, signal) {
|
|
|
190
150
|
}
|
|
191
151
|
async function generateDashScopeImages(params) {
|
|
192
152
|
const { req, apiKey } = params;
|
|
153
|
+
const providerId = params.providerId ?? req.provider ?? "dashscope-cn";
|
|
193
154
|
if (req.inputImages && req.inputImages.length > 0) throw new Error("Image-to-image is not supported for Qwen/DashScope in this build");
|
|
194
155
|
const n = Math.min(4, Math.max(1, req.count ?? 1));
|
|
195
156
|
const model = req.model?.trim() || DASHSCOPE_DEFAULT_IMAGE_MODEL;
|
|
@@ -213,21 +174,21 @@ async function generateDashScopeImages(params) {
|
|
|
213
174
|
}] },
|
|
214
175
|
parameters
|
|
215
176
|
};
|
|
216
|
-
const url = resolveDashScopeImageGenerationUrl(req);
|
|
177
|
+
const url = resolveDashScopeImageGenerationUrl(req, params.defaultRegion);
|
|
217
178
|
const httpDefaults = resolveProviderHttpRequestConfig({
|
|
218
|
-
providerId
|
|
179
|
+
providerId,
|
|
219
180
|
cfg: req.cfg,
|
|
220
181
|
fallbackTimeoutMs: DEFAULT_TIMEOUT_MS
|
|
221
182
|
});
|
|
222
183
|
log.debug({
|
|
223
|
-
providerId
|
|
184
|
+
providerId,
|
|
224
185
|
model,
|
|
225
186
|
url,
|
|
226
187
|
count: n,
|
|
227
188
|
phase: "request"
|
|
228
189
|
}, "DashScope image generation request");
|
|
229
190
|
const response = await postJsonRequest(url, {
|
|
230
|
-
label:
|
|
191
|
+
label: providerId,
|
|
231
192
|
timeoutMs: pickTimeoutMsOrFallback(req.timeoutMs, httpDefaults.timeoutMs, DEFAULT_TIMEOUT_MS),
|
|
232
193
|
signal: req.signal,
|
|
233
194
|
body,
|
|
@@ -255,32 +216,47 @@ async function generateDashScopeImages(params) {
|
|
|
255
216
|
model
|
|
256
217
|
};
|
|
257
218
|
}
|
|
258
|
-
function
|
|
219
|
+
function createDashScopeImageGenerationProvider(options) {
|
|
259
220
|
return {
|
|
260
|
-
id:
|
|
261
|
-
label:
|
|
221
|
+
id: options.id,
|
|
222
|
+
label: options.label,
|
|
262
223
|
defaultModel: DASHSCOPE_DEFAULT_IMAGE_MODEL,
|
|
263
224
|
models: [...DASHSCOPE_IMAGE_MODELS],
|
|
264
225
|
capabilities: DASHSCOPE_CAPABILITIES,
|
|
265
|
-
ui: DASHSCOPE_IMAGE_UI,
|
|
266
226
|
isConfigured: (ctx) => isProviderApiKeyConfigured({
|
|
267
|
-
providerId:
|
|
227
|
+
providerId: options.id,
|
|
268
228
|
cfg: ctx.cfg
|
|
269
229
|
}),
|
|
270
230
|
async generateImage(req) {
|
|
271
231
|
const apiKey = resolveApiKeyForProvider({
|
|
272
|
-
providerId:
|
|
232
|
+
providerId: options.id,
|
|
273
233
|
cfg: req.cfg
|
|
274
234
|
});
|
|
275
|
-
if (!apiKey) throw new Error(
|
|
235
|
+
if (!apiKey) throw new Error(`DashScope API key missing (set DASHSCOPE_API_KEY or providers.${options.id}.apiKey)`);
|
|
276
236
|
return generateDashScopeImages({
|
|
277
237
|
req,
|
|
278
|
-
apiKey
|
|
238
|
+
apiKey,
|
|
239
|
+
providerId: options.id,
|
|
240
|
+
defaultRegion: options.defaultRegion
|
|
279
241
|
});
|
|
280
242
|
}
|
|
281
243
|
};
|
|
282
244
|
}
|
|
245
|
+
function buildDashScopeCnImageGenerationProvider() {
|
|
246
|
+
return createDashScopeImageGenerationProvider({
|
|
247
|
+
id: "dashscope-cn",
|
|
248
|
+
label: "DashScope (Alibaba · China)",
|
|
249
|
+
defaultRegion: "beijing"
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
function buildDashScopeIntlImageGenerationProvider() {
|
|
253
|
+
return createDashScopeImageGenerationProvider({
|
|
254
|
+
id: "dashscope-intl",
|
|
255
|
+
label: "DashScope (Alibaba · International)",
|
|
256
|
+
defaultRegion: "singapore"
|
|
257
|
+
});
|
|
258
|
+
}
|
|
283
259
|
//#endregion
|
|
284
|
-
export { DASHSCOPE_DEFAULT_IMAGE_MODEL, DASHSCOPE_IMAGE_ENDPOINTS, DASHSCOPE_IMAGE_MODELS,
|
|
260
|
+
export { DASHSCOPE_DEFAULT_IMAGE_MODEL, DASHSCOPE_IMAGE_ENDPOINTS, DASHSCOPE_IMAGE_MODELS, buildDashScopeCnImageGenerationProvider, buildDashScopeIntlImageGenerationProvider, generateDashScopeImages, isWan27ImageModel, mapSizeToDashScopeFormat, mapSizeToWan27Format, resolveDashScopeImageGenerationUrl };
|
|
285
261
|
|
|
286
262
|
//# sourceMappingURL=image-generation-provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-generation-provider.js","names":[],"sources":["../../../../extensions/dashscope/src/image-generation-provider.ts"],"sourcesContent":["/**\n * Bundled DashScope (Alibaba) image-generation provider.\n *\n * Migrated from src/agent/image/generation/dashscope-generate.ts. Logic stays\n * identical; the only change is registration is now driven by the bundled\n * provider generator.\n */\nimport {\n isProviderApiKeyConfigured,\n resolveApiKeyForProvider,\n} from '@xopcai/xopc/providers/auth-runtime/index.js';\nimport {\n pickTimeoutMsOrFallback,\n postJsonRequest,\n privateNetworkPolicyToSsrfGuardOptions,\n resolveProviderHttpRequestConfig,\n} from '@xopcai/xopc/media-shared/http/index.js';\nimport { createLogger } from '@xopcai/xopc/utils/logger.js';\nimport { imageFileExtensionForMimeType } from '@xopcai/xopc/agent/image/generation/image-assets.js';\nimport type {\n ImageGenerationProvider,\n ImageGenerationProviderCapabilities,\n ImageGenerationRequest,\n ImageGenerationResult,\n ImageProviderUiMetadata,\n} from '@xopcai/xopc/agent/image/generation/types.js';\n\nconst log = createLogger('ImageGen:DashScope');\n\n/**\n * Wan image model ids for **HTTP synchronous** `multimodal-generation/generation`.\n * - **2.7** (`wan2.7-image-pro` / `wan2.7-image`): see Wan 2.7 image API (size presets 1K/2K/4K, `thinking_mode`, …).\n * - **2.6** (`wan2.6-t2i`): legacy Wan 2.6 T2I (`prompt_extend`, pixel `宽*高`, …).\n * Wan 2.5 and earlier async-only models are not listed here.\n * @see https://www.alibabacloud.com/help/en/model-studio/wan-image-generation-and-editing-api-reference\n * @see https://www.alibabacloud.com/help/en/model-studio/text-to-image-v2-api-reference\n * @see https://www.alibabacloud.com/help/en/model-studio/model-pricing\n */\nexport const DASHSCOPE_IMAGE_MODELS: readonly string[] = [\n 'wan2.7-image-pro',\n 'wan2.7-image',\n 'wan2.6-t2i',\n];\nexport const DASHSCOPE_DEFAULT_IMAGE_MODEL = DASHSCOPE_IMAGE_MODELS[0]!;\n\nconst DEFAULT_TIMEOUT_MS = 180_000;\n\nconst DASHSCOPE_CAPABILITIES: ImageGenerationProviderCapabilities = {\n generate: { maxCount: 4, supportsSize: true },\n edit: { enabled: false },\n geometry: {\n sizes: ['2K', '1K', '4K', '1280x1280', '1024x1024', '1280x720', '720x1280', '1024x1536', '1536x1024'],\n },\n output: {\n formats: ['png', 'jpeg', 'webp'],\n },\n};\n\n/**\n * Official synchronous wan2.6 text-to-image endpoints. Each region uses its own API key.\n * @see https://www.alibabacloud.com/help/zh/model-studio/text-to-image-v2-api-reference\n */\nexport const DASHSCOPE_IMAGE_ENDPOINTS = {\n beijing: 'https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation',\n singapore: 'https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation',\n us: 'https://dashscope-us.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation',\n} as const;\n\n/** Gateway console region presets (must match {@link DASHSCOPE_IMAGE_ENDPOINTS}). */\nconst DASHSCOPE_IMAGE_UI: ImageProviderUiMetadata = {\n regions: [\n { value: 'beijing', label: 'China (Beijing)', imageBaseUrl: DASHSCOPE_IMAGE_ENDPOINTS.beijing },\n {\n value: 'singapore',\n label: 'International (Singapore)',\n imageBaseUrl: DASHSCOPE_IMAGE_ENDPOINTS.singapore,\n },\n { value: 'us', label: 'United States (Virginia)', imageBaseUrl: DASHSCOPE_IMAGE_ENDPOINTS.us },\n ],\n};\n\nexport type DashScopeImageRegion = keyof typeof DASHSCOPE_IMAGE_ENDPOINTS;\n\nconst DEFAULT_OUTPUT_MIME = 'image/png';\n\nexport function resolveDashScopeImageRegion(req?: ImageGenerationRequest): DashScopeImageRegion {\n const cfgRegion = readDashScopeCfgString(req?.cfg, 'region');\n const raw = (cfgRegion ?? process.env.DASHSCOPE_REGION ?? process.env.DASHSCOPE_IMAGE_REGION ?? '')\n .trim()\n .toLowerCase();\n if (!raw) {\n return 'beijing';\n }\n if (['beijing', 'cn', 'china', 'bj'].includes(raw)) {\n return 'beijing';\n }\n if (['singapore', 'sg', 'intl', 'international', 'sea', 'ap-southeast-1'].includes(raw)) {\n return 'singapore';\n }\n if (['us', 'virginia', 'va', 'us-east-1'].includes(raw)) {\n return 'us';\n }\n return 'beijing';\n}\n\nexport function resolveDashScopeImageGenerationUrl(req?: ImageGenerationRequest): string {\n const cfgImageBase = readDashScopeCfgString(req?.cfg, 'imageBaseUrl');\n if (cfgImageBase) return cfgImageBase.replace(/\\/+$/, '');\n const cfgBase = readDashScopeCfgString(req?.cfg, 'baseUrl');\n if (cfgBase) return cfgBase.replace(/\\/+$/, '');\n const trimmed = process.env.DASHSCOPE_IMAGE_BASE_URL?.trim();\n if (trimmed) {\n return trimmed.replace(/\\/+$/, '');\n }\n const region = resolveDashScopeImageRegion(req);\n return DASHSCOPE_IMAGE_ENDPOINTS[region];\n}\n\nfunction readDashScopeCfgString(\n cfg: ImageGenerationRequest['cfg'],\n key: string,\n): string | undefined {\n const providers = (cfg as unknown as { providers?: Record<string, unknown> } | undefined)?.providers;\n if (!providers || typeof providers !== 'object') return undefined;\n const entry = (providers as Record<string, unknown>)['dashscope'];\n if (!entry || typeof entry !== 'object') return undefined;\n const v = (entry as Record<string, unknown>)[key];\n return typeof v === 'string' && v.trim() ? v.trim() : undefined;\n}\n\n/** Map tool size (e.g. `1024x1024`) to DashScope `宽*高` format. */\nexport function mapSizeToDashScopeFormat(size?: string): string {\n if (!size?.trim()) {\n return '1280*1280';\n }\n const s = size.trim();\n if (s.includes('*')) {\n return s.replace(/\\s/g, '');\n }\n const m = /^(\\d+)\\s*[xX]\\s*(\\d+)$/.exec(s);\n if (m) {\n return `${m[1]}*${m[2]}`;\n }\n return '1280*1280';\n}\n\nexport function isWan27ImageModel(model: string): boolean {\n const m = model.trim().toLowerCase();\n return m === 'wan2.7-image-pro' || m === 'wan2.7-image';\n}\n\n/**\n * Map tool `size` to Wan 2.7 `parameters.size` (1K / 2K / 4K presets or `宽*高` pixels).\n * `wan2.7-image` does not support 4K — falls back to 2K.\n */\nexport function mapSizeToWan27Format(size: string | undefined, modelId: string): string {\n const id = modelId.trim().toLowerCase();\n if (!size?.trim()) return '2K';\n const s = size.trim();\n const preset = s.toUpperCase();\n if (preset === '1K' || preset === '2K' || preset === '4K') {\n if (preset === '4K' && id === 'wan2.7-image') return '2K';\n return preset;\n }\n if (s.includes('*')) return s.replace(/\\s/g, '');\n const dim = /^(\\d+)\\s*[xX]\\s*(\\d+)$/.exec(s);\n if (dim) return `${dim[1]}*${dim[2]}`;\n return '2K';\n}\n\ntype DashScopeT2IResponse = {\n code?: string;\n message?: string;\n output?: {\n choices?: Array<{\n message?: {\n content?: Array<{ type?: string; image?: string; text?: string }>;\n };\n }>;\n };\n};\n\nfunction collectImageUrls(data: DashScopeT2IResponse): string[] {\n const urls: string[] = [];\n for (const choice of data.output?.choices ?? []) {\n for (const item of choice.message?.content ?? []) {\n if (item.type === 'image' && typeof item.image === 'string' && item.image.length > 0) {\n urls.push(item.image);\n }\n }\n }\n return urls;\n}\n\nasync function fetchImageBuffers(\n urls: string[],\n signal: AbortSignal | undefined,\n): Promise<Array<{ buffer: Buffer; mimeType: string; fileName: string }>> {\n const out: Array<{ buffer: Buffer; mimeType: string; fileName: string }> = [];\n let index = 0;\n for (const url of urls) {\n index += 1;\n const res = await fetch(url, { redirect: 'follow', signal });\n if (!res.ok) {\n const t = await res.text().catch(() => '');\n throw new Error(`Failed to download generated image (${res.status}): ${t || res.statusText}`);\n }\n const buf = Buffer.from(await res.arrayBuffer());\n const ct = res.headers.get('content-type') || '';\n const mimeType = ct.split(';')[0]?.trim() || DEFAULT_OUTPUT_MIME;\n const ext = imageFileExtensionForMimeType(mimeType);\n out.push({\n buffer: buf,\n mimeType,\n fileName: `image-${index}.${ext}`,\n });\n }\n return out;\n}\n\nexport async function generateDashScopeImages(params: {\n req: ImageGenerationRequest;\n apiKey: string;\n}): Promise<ImageGenerationResult> {\n const { req, apiKey } = params;\n if (req.inputImages && req.inputImages.length > 0) {\n throw new Error('Image-to-image is not supported for Qwen/DashScope in this build');\n }\n\n const n = Math.min(4, Math.max(1, req.count ?? 1));\n const model = req.model?.trim() || DASHSCOPE_DEFAULT_IMAGE_MODEL;\n const parameters = isWan27ImageModel(model)\n ? {\n size: mapSizeToWan27Format(req.size, model),\n n,\n watermark: false,\n thinking_mode: true,\n }\n : {\n prompt_extend: true,\n watermark: false,\n n,\n negative_prompt: '',\n size: mapSizeToDashScopeFormat(req.size),\n };\n\n const body = {\n model,\n input: {\n messages: [\n {\n role: 'user' as const,\n content: [{ text: req.prompt }],\n },\n ],\n },\n parameters,\n };\n\n const url = resolveDashScopeImageGenerationUrl(req);\n const httpDefaults = resolveProviderHttpRequestConfig({\n providerId: 'dashscope',\n cfg: req.cfg,\n fallbackTimeoutMs: DEFAULT_TIMEOUT_MS,\n });\n\n log.debug(\n { providerId: 'dashscope', model, url, count: n, phase: 'request' },\n 'DashScope image generation request',\n );\n\n const timeoutMs = pickTimeoutMsOrFallback(req.timeoutMs, httpDefaults.timeoutMs, DEFAULT_TIMEOUT_MS);\n const response = await postJsonRequest(url, {\n label: 'dashscope',\n timeoutMs,\n signal: req.signal,\n body,\n headers: {\n ...httpDefaults.headers,\n authorization: `Bearer ${apiKey}`,\n },\n ...privateNetworkPolicyToSsrfGuardOptions(),\n });\n\n let data: DashScopeT2IResponse;\n const rawText = await response.text();\n try {\n data = JSON.parse(rawText) as DashScopeT2IResponse;\n } catch {\n throw new Error(`DashScope returned non-JSON: ${rawText.slice(0, 240)}`);\n }\n\n if (!data.output?.choices?.length) {\n if (data.message || data.code) {\n throw new Error(\n data.code\n ? `DashScope: ${data.code}: ${data.message ?? ''}`\n : `DashScope: ${data.message ?? 'unknown error'}`,\n );\n }\n throw new Error('DashScope returned no output');\n }\n\n const urls = collectImageUrls(data);\n if (urls.length === 0) {\n throw new Error('DashScope returned no image URLs in response');\n }\n\n const assets = await fetchImageBuffers(urls, req.signal);\n return {\n images: assets,\n model,\n };\n}\n\nexport function buildDashScopeImageGenerationProvider(): ImageGenerationProvider {\n return {\n id: 'dashscope',\n label: 'DashScope (Alibaba)',\n defaultModel: DASHSCOPE_DEFAULT_IMAGE_MODEL,\n models: [...DASHSCOPE_IMAGE_MODELS],\n capabilities: DASHSCOPE_CAPABILITIES,\n ui: DASHSCOPE_IMAGE_UI,\n isConfigured: (ctx) =>\n isProviderApiKeyConfigured({ providerId: 'dashscope', cfg: ctx.cfg }),\n async generateImage(req) {\n const apiKey = resolveApiKeyForProvider({ providerId: 'dashscope', cfg: req.cfg });\n if (!apiKey) {\n throw new Error(\n 'DashScope API key missing (set DASHSCOPE_API_KEY or providers.dashscope.apiKey)',\n );\n }\n return generateDashScopeImages({ req, apiKey });\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;aAiB4D;AAU5D,MAAM,MAAM,aAAa,qBAAqB;;;;;;;;;;AAW9C,MAAa,yBAA4C;CACvD;CACA;CACA;CACD;AACD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wCAAiE;AAC/E,QAAO;EACL,IAAI;EACJ,OAAO;EACP,cAAc;EACd,QAAQ,CAAC,GAAG,uBAAuB;EACnC,cAAc;EACd,IAAI;EACJ,eAAe,QACb,2BAA2B;GAAE,YAAY;GAAa,KAAK,IAAI;GAAK,CAAC;EACvE,MAAM,cAAc,KAAK;GACvB,MAAM,SAAS,yBAAyB;IAAE,YAAY;IAAa,KAAK,IAAI;IAAK,CAAC;AAClF,OAAI,CAAC,OACH,OAAM,IAAI,MACR,kFACD;AAEH,UAAO,wBAAwB;IAAE;IAAK;IAAQ,CAAC;;EAElD"}
|
|
1
|
+
{"version":3,"file":"image-generation-provider.js","names":[],"sources":["../../../../extensions/dashscope/src/image-generation-provider.ts"],"sourcesContent":["/**\n * Bundled DashScope (Alibaba) image-generation provider.\n *\n * Migrated from src/agent/image/generation/dashscope-generate.ts. Logic stays\n * identical; the only change is registration is now driven by the bundled\n * provider generator.\n */\nimport {\n isProviderApiKeyConfigured,\n resolveApiKeyForProvider,\n} from '@xopcai/xopc/providers/auth-runtime/index.js';\nimport {\n pickTimeoutMsOrFallback,\n postJsonRequest,\n privateNetworkPolicyToSsrfGuardOptions,\n resolveProviderHttpRequestConfig,\n} from '@xopcai/xopc/media-shared/http/index.js';\nimport { createLogger } from '@xopcai/xopc/utils/logger.js';\nimport { imageFileExtensionForMimeType } from '@xopcai/xopc/agent/image/generation/image-assets.js';\nimport type {\n ImageGenerationProvider,\n ImageGenerationProviderCapabilities,\n ImageGenerationRequest,\n ImageGenerationResult,\n} from '@xopcai/xopc/agent/image/generation/types.js';\n\nconst log = createLogger('ImageGen:DashScope');\n\n/**\n * Wan image model ids for **HTTP synchronous** `multimodal-generation/generation`.\n * - **2.7** (`wan2.7-image-pro` / `wan2.7-image`): see Wan 2.7 image API (size presets 1K/2K/4K, `thinking_mode`, …).\n * - **2.6** (`wan2.6-t2i`): Wan 2.6 T2I (`prompt_extend`, pixel `宽*高`, …).\n * Wan 2.5 and earlier async-only models are not listed here.\n * @see https://www.alibabacloud.com/help/en/model-studio/wan-image-generation-and-editing-api-reference\n * @see https://www.alibabacloud.com/help/en/model-studio/text-to-image-v2-api-reference\n * @see https://www.alibabacloud.com/help/en/model-studio/model-pricing\n */\nexport const DASHSCOPE_IMAGE_MODELS: readonly string[] = [\n 'wan2.7-image-pro',\n 'wan2.7-image',\n 'wan2.6-t2i',\n];\nexport const DASHSCOPE_DEFAULT_IMAGE_MODEL = DASHSCOPE_IMAGE_MODELS[0]!;\n\nconst DEFAULT_TIMEOUT_MS = 180_000;\n\nconst DASHSCOPE_CAPABILITIES: ImageGenerationProviderCapabilities = {\n generate: { maxCount: 4, supportsSize: true },\n edit: { enabled: false },\n geometry: {\n sizes: ['2K', '1K', '4K', '1280x1280', '1024x1024', '1280x720', '720x1280', '1024x1536', '1536x1024'],\n },\n output: {\n formats: ['png', 'jpeg', 'webp'],\n },\n};\n\n/**\n * Official synchronous wan2.6 text-to-image endpoints. Each region uses its own API key.\n * @see https://www.alibabacloud.com/help/zh/model-studio/text-to-image-v2-api-reference\n */\nexport const DASHSCOPE_IMAGE_ENDPOINTS = {\n beijing: 'https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation',\n singapore: 'https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation',\n} as const;\n\nexport type DashScopeImageRegion = keyof typeof DASHSCOPE_IMAGE_ENDPOINTS;\n\nconst DEFAULT_OUTPUT_MIME = 'image/png';\n\nfunction providerConfigId(req?: ImageGenerationRequest, fallback = 'dashscope-cn'): string {\n return req?.provider?.trim() || fallback;\n}\n\nexport function resolveDashScopeImageGenerationUrl(\n req?: ImageGenerationRequest,\n defaultRegion: DashScopeImageRegion = 'beijing',\n): string {\n const id = providerConfigId(req);\n const cfgImageBase = readDashScopeCfgString(req?.cfg, id, 'imageBaseUrl');\n if (cfgImageBase) return cfgImageBase.replace(/\\/+$/, '');\n const cfgBase = readDashScopeCfgString(req?.cfg, id, 'baseUrl');\n if (cfgBase) return cfgBase.replace(/\\/+$/, '');\n const trimmed = process.env.DASHSCOPE_IMAGE_BASE_URL?.trim();\n if (trimmed) {\n return trimmed.replace(/\\/+$/, '');\n }\n return DASHSCOPE_IMAGE_ENDPOINTS[defaultRegion];\n}\n\nfunction readDashScopeCfgString(\n cfg: ImageGenerationRequest['cfg'],\n providerId: string,\n key: string,\n): string | undefined {\n const providers = (cfg as unknown as { providers?: Record<string, unknown> } | undefined)?.providers;\n if (!providers || typeof providers !== 'object') return undefined;\n const entry = (providers as Record<string, unknown>)[providerId];\n if (!entry || typeof entry !== 'object') return undefined;\n const v = (entry as Record<string, unknown>)[key];\n return typeof v === 'string' && v.trim() ? v.trim() : undefined;\n}\n\n/** Map tool size (e.g. `1024x1024`) to DashScope `宽*高` format. */\nexport function mapSizeToDashScopeFormat(size?: string): string {\n if (!size?.trim()) {\n return '1280*1280';\n }\n const s = size.trim();\n if (s.includes('*')) {\n return s.replace(/\\s/g, '');\n }\n const m = /^(\\d+)\\s*[xX]\\s*(\\d+)$/.exec(s);\n if (m) {\n return `${m[1]}*${m[2]}`;\n }\n return '1280*1280';\n}\n\nexport function isWan27ImageModel(model: string): boolean {\n const m = model.trim().toLowerCase();\n return m === 'wan2.7-image-pro' || m === 'wan2.7-image';\n}\n\n/**\n * Map tool `size` to Wan 2.7 `parameters.size` (1K / 2K / 4K presets or `宽*高` pixels).\n * `wan2.7-image` does not support 4K — falls back to 2K.\n */\nexport function mapSizeToWan27Format(size: string | undefined, modelId: string): string {\n const id = modelId.trim().toLowerCase();\n if (!size?.trim()) return '2K';\n const s = size.trim();\n const preset = s.toUpperCase();\n if (preset === '1K' || preset === '2K' || preset === '4K') {\n if (preset === '4K' && id === 'wan2.7-image') return '2K';\n return preset;\n }\n if (s.includes('*')) return s.replace(/\\s/g, '');\n const dim = /^(\\d+)\\s*[xX]\\s*(\\d+)$/.exec(s);\n if (dim) return `${dim[1]}*${dim[2]}`;\n return '2K';\n}\n\ntype DashScopeT2IResponse = {\n code?: string;\n message?: string;\n output?: {\n choices?: Array<{\n message?: {\n content?: Array<{ type?: string; image?: string; text?: string }>;\n };\n }>;\n };\n};\n\nfunction collectImageUrls(data: DashScopeT2IResponse): string[] {\n const urls: string[] = [];\n for (const choice of data.output?.choices ?? []) {\n for (const item of choice.message?.content ?? []) {\n if (item.type === 'image' && typeof item.image === 'string' && item.image.length > 0) {\n urls.push(item.image);\n }\n }\n }\n return urls;\n}\n\nasync function fetchImageBuffers(\n urls: string[],\n signal: AbortSignal | undefined,\n): Promise<Array<{ buffer: Buffer; mimeType: string; fileName: string }>> {\n const out: Array<{ buffer: Buffer; mimeType: string; fileName: string }> = [];\n let index = 0;\n for (const url of urls) {\n index += 1;\n const res = await fetch(url, { redirect: 'follow', signal });\n if (!res.ok) {\n const t = await res.text().catch(() => '');\n throw new Error(`Failed to download generated image (${res.status}): ${t || res.statusText}`);\n }\n const buf = Buffer.from(await res.arrayBuffer());\n const ct = res.headers.get('content-type') || '';\n const mimeType = ct.split(';')[0]?.trim() || DEFAULT_OUTPUT_MIME;\n const ext = imageFileExtensionForMimeType(mimeType);\n out.push({\n buffer: buf,\n mimeType,\n fileName: `image-${index}.${ext}`,\n });\n }\n return out;\n}\n\nexport async function generateDashScopeImages(params: {\n req: ImageGenerationRequest;\n apiKey: string;\n providerId?: string;\n defaultRegion?: DashScopeImageRegion;\n}): Promise<ImageGenerationResult> {\n const { req, apiKey } = params;\n const providerId = params.providerId ?? req.provider ?? 'dashscope-cn';\n if (req.inputImages && req.inputImages.length > 0) {\n throw new Error('Image-to-image is not supported for Qwen/DashScope in this build');\n }\n\n const n = Math.min(4, Math.max(1, req.count ?? 1));\n const model = req.model?.trim() || DASHSCOPE_DEFAULT_IMAGE_MODEL;\n const parameters = isWan27ImageModel(model)\n ? {\n size: mapSizeToWan27Format(req.size, model),\n n,\n watermark: false,\n thinking_mode: true,\n }\n : {\n prompt_extend: true,\n watermark: false,\n n,\n negative_prompt: '',\n size: mapSizeToDashScopeFormat(req.size),\n };\n\n const body = {\n model,\n input: {\n messages: [\n {\n role: 'user' as const,\n content: [{ text: req.prompt }],\n },\n ],\n },\n parameters,\n };\n\n const url = resolveDashScopeImageGenerationUrl(req, params.defaultRegion);\n const httpDefaults = resolveProviderHttpRequestConfig({\n providerId,\n cfg: req.cfg,\n fallbackTimeoutMs: DEFAULT_TIMEOUT_MS,\n });\n\n log.debug(\n { providerId, model, url, count: n, phase: 'request' },\n 'DashScope image generation request',\n );\n\n const timeoutMs = pickTimeoutMsOrFallback(req.timeoutMs, httpDefaults.timeoutMs, DEFAULT_TIMEOUT_MS);\n const response = await postJsonRequest(url, {\n label: providerId,\n timeoutMs,\n signal: req.signal,\n body,\n headers: {\n ...httpDefaults.headers,\n authorization: `Bearer ${apiKey}`,\n },\n ...privateNetworkPolicyToSsrfGuardOptions(),\n });\n\n let data: DashScopeT2IResponse;\n const rawText = await response.text();\n try {\n data = JSON.parse(rawText) as DashScopeT2IResponse;\n } catch {\n throw new Error(`DashScope returned non-JSON: ${rawText.slice(0, 240)}`);\n }\n\n if (!data.output?.choices?.length) {\n if (data.message || data.code) {\n throw new Error(\n data.code\n ? `DashScope: ${data.code}: ${data.message ?? ''}`\n : `DashScope: ${data.message ?? 'unknown error'}`,\n );\n }\n throw new Error('DashScope returned no output');\n }\n\n const urls = collectImageUrls(data);\n if (urls.length === 0) {\n throw new Error('DashScope returned no image URLs in response');\n }\n\n const assets = await fetchImageBuffers(urls, req.signal);\n return {\n images: assets,\n model,\n };\n}\n\nfunction createDashScopeImageGenerationProvider(options: {\n id: string;\n label: string;\n defaultRegion: DashScopeImageRegion;\n}): ImageGenerationProvider {\n return {\n id: options.id,\n label: options.label,\n defaultModel: DASHSCOPE_DEFAULT_IMAGE_MODEL,\n models: [...DASHSCOPE_IMAGE_MODELS],\n capabilities: DASHSCOPE_CAPABILITIES,\n isConfigured: (ctx) =>\n isProviderApiKeyConfigured({ providerId: options.id, cfg: ctx.cfg }),\n async generateImage(req) {\n const apiKey = resolveApiKeyForProvider({ providerId: options.id, cfg: req.cfg });\n if (!apiKey) {\n throw new Error(\n `DashScope API key missing (set DASHSCOPE_API_KEY or providers.${options.id}.apiKey)`,\n );\n }\n return generateDashScopeImages({\n req,\n apiKey,\n providerId: options.id,\n defaultRegion: options.defaultRegion,\n });\n },\n };\n}\n\nexport function buildDashScopeCnImageGenerationProvider(): ImageGenerationProvider {\n return createDashScopeImageGenerationProvider({\n id: 'dashscope-cn',\n label: 'DashScope (Alibaba · China)',\n defaultRegion: 'beijing',\n });\n}\n\nexport function buildDashScopeIntlImageGenerationProvider(): ImageGenerationProvider {\n return createDashScopeImageGenerationProvider({\n id: 'dashscope-intl',\n label: 'DashScope (Alibaba · International)',\n defaultRegion: 'singapore',\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;aAiB4D;AAS5D,MAAM,MAAM,aAAa,qBAAqB;;;;;;;;;;AAW9C,MAAa,yBAA4C;CACvD;CACA;CACA;CACD;AACD,MAAa,gCAAgC,uBAAuB;AAEpE,MAAM,qBAAqB;AAE3B,MAAM,yBAA8D;CAClE,UAAU;EAAE,UAAU;EAAG,cAAc;EAAM;CAC7C,MAAM,EAAE,SAAS,OAAO;CACxB,UAAU,EACR,OAAO;EAAC;EAAM;EAAM;EAAM;EAAa;EAAa;EAAY;EAAY;EAAa;EAAY,EACtG;CACD,QAAQ,EACN,SAAS;EAAC;EAAO;EAAQ;EAAO,EACjC;CACF;;;;;AAMD,MAAa,4BAA4B;CACvC,SAAS;CACT,WAAW;CACZ;AAID,MAAM,sBAAsB;AAE5B,SAAS,iBAAiB,KAA8B,WAAW,gBAAwB;AACzF,QAAO,KAAK,UAAU,MAAM,IAAI;;AAGlC,SAAgB,mCACd,KACA,gBAAsC,WAC9B;CACR,MAAM,KAAK,iBAAiB,IAAI;CAChC,MAAM,eAAe,uBAAuB,KAAK,KAAK,IAAI,eAAe;AACzE,KAAI,aAAc,QAAO,aAAa,QAAQ,QAAQ,GAAG;CACzD,MAAM,UAAU,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K,WAAW,EAClB,OAAM,IAAI,MAAM,+CAA+C;AAIjE,QAAO;EACL,QAAQ,MAFW,kBAAkB,MAAM,IAAI,OAAO;EAGtD;EACD;;AAGH,SAAS,uCAAuC,SAIpB;AAC1B,QAAO;EACL,IAAI,QAAQ;EACZ,OAAO,QAAQ;EACf,cAAc;EACd,QAAQ,CAAC,GAAG,uBAAuB;EACnC,cAAc;EACd,eAAe,QACb,2BAA2B;GAAE,YAAY,QAAQ;GAAI,KAAK,IAAI;GAAK,CAAC;EACtE,MAAM,cAAc,KAAK;GACvB,MAAM,SAAS,yBAAyB;IAAE,YAAY,QAAQ;IAAI,KAAK,IAAI;IAAK,CAAC;AACjF,OAAI,CAAC,OACH,OAAM,IAAI,MACR,iEAAiE,QAAQ,GAAG,UAC7E;AAEH,UAAO,wBAAwB;IAC7B;IACA;IACA,YAAY,QAAQ;IACpB,eAAe,QAAQ;IACxB,CAAC;;EAEL;;AAGH,SAAgB,0CAAmE;AACjF,QAAO,uCAAuC;EAC5C,IAAI;EACJ,OAAO;EACP,eAAe;EAChB,CAAC;;AAGJ,SAAgB,4CAAqE;AACnF,QAAO,uCAAuC;EAC5C,IAAI;EACJ,OAAO;EACP,eAAe;EAChB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Bundled DashScope (Alibaba) image-generation extension entry.
|
|
3
3
|
*/
|
|
4
|
-
export {
|
|
4
|
+
export { buildDashScopeCnImageGenerationProvider, buildDashScopeIntlImageGenerationProvider, generateDashScopeImages, resolveDashScopeImageGenerationUrl, mapSizeToDashScopeFormat, mapSizeToWan27Format, isWan27ImageModel, DASHSCOPE_IMAGE_ENDPOINTS, DASHSCOPE_DEFAULT_IMAGE_MODEL, DASHSCOPE_IMAGE_MODELS, type DashScopeImageRegion, } from './image-generation-provider.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DASHSCOPE_DEFAULT_IMAGE_MODEL, DASHSCOPE_IMAGE_ENDPOINTS, DASHSCOPE_IMAGE_MODELS,
|
|
2
|
-
export { DASHSCOPE_DEFAULT_IMAGE_MODEL, DASHSCOPE_IMAGE_ENDPOINTS, DASHSCOPE_IMAGE_MODELS,
|
|
1
|
+
import { DASHSCOPE_DEFAULT_IMAGE_MODEL, DASHSCOPE_IMAGE_ENDPOINTS, DASHSCOPE_IMAGE_MODELS, buildDashScopeCnImageGenerationProvider, buildDashScopeIntlImageGenerationProvider, generateDashScopeImages, isWan27ImageModel, mapSizeToDashScopeFormat, mapSizeToWan27Format, resolveDashScopeImageGenerationUrl } from "./image-generation-provider.js";
|
|
2
|
+
export { DASHSCOPE_DEFAULT_IMAGE_MODEL, DASHSCOPE_IMAGE_ENDPOINTS, DASHSCOPE_IMAGE_MODELS, buildDashScopeCnImageGenerationProvider, buildDashScopeIntlImageGenerationProvider, generateDashScopeImages, isWan27ImageModel, mapSizeToDashScopeFormat, mapSizeToWan27Format, resolveDashScopeImageGenerationUrl };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "dashscope",
|
|
3
3
|
"name": "DashScope (Alibaba)",
|
|
4
|
-
"description": "Image generation via Alibaba Model Studio (DashScope). Configure
|
|
4
|
+
"description": "Image generation via Alibaba Model Studio (DashScope). Configure the China or international provider under Settings → Images.",
|
|
5
5
|
"version": "1.0.0",
|
|
6
6
|
"kind": "image-generation",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"autoEnableWhenConfiguredProviders": [
|
|
9
|
-
"dashscope"
|
|
9
|
+
"dashscope-cn",
|
|
10
|
+
"dashscope-intl"
|
|
10
11
|
],
|
|
11
12
|
"engines": {
|
|
12
13
|
"xopc": ">=0.0.106 <1.0.0"
|
|
@@ -7,18 +7,20 @@ import type { ImageGenerationProvider, ImageGenerationRequest, ImageGenerationRe
|
|
|
7
7
|
export declare const MINIMAX_IMAGE_MODELS: readonly string[];
|
|
8
8
|
export declare const MINIMAX_DEFAULT_IMAGE_MODEL: string;
|
|
9
9
|
/**
|
|
10
|
-
* Resolve MiniMax base URL
|
|
11
|
-
* 1. cfg.providers.
|
|
10
|
+
* Resolve MiniMax base URL:
|
|
11
|
+
* 1. cfg.providers[providerId].baseUrl
|
|
12
12
|
* 2. MINIMAX_BASE_URL env
|
|
13
|
-
* 3.
|
|
14
|
-
* otherwise CN.
|
|
13
|
+
* 3. Provider default base URL
|
|
15
14
|
*/
|
|
16
|
-
export declare function resolveMinimaxBaseUrl(req: ImageGenerationRequest): string;
|
|
15
|
+
export declare function resolveMinimaxBaseUrl(req: ImageGenerationRequest, defaultBaseUrl?: string): string;
|
|
17
16
|
export type MinimaxAspectRatio = '1:1' | '16:9' | '9:16' | '4:3' | '3:4';
|
|
18
17
|
/** Map tool size (e.g. `1024x1024`) to the closest MiniMax-supported aspect ratio. */
|
|
19
18
|
export declare function mapSizeToMinimaxAspectRatio(size?: string): MinimaxAspectRatio;
|
|
20
19
|
export declare function generateMinimaxImages(params: {
|
|
21
20
|
req: ImageGenerationRequest;
|
|
22
21
|
apiKey: string;
|
|
22
|
+
providerId?: string;
|
|
23
|
+
defaultBaseUrl?: string;
|
|
23
24
|
}): Promise<ImageGenerationResult>;
|
|
25
|
+
export declare function buildMinimaxCnImageGenerationProvider(): ImageGenerationProvider;
|
|
24
26
|
export declare function buildMinimaxImageGenerationProvider(): ImageGenerationProvider;
|
|
@@ -24,20 +24,10 @@ const log = createLogger("ImageGen:MiniMax");
|
|
|
24
24
|
*/
|
|
25
25
|
const MINIMAX_IMAGE_MODELS = ["image-01", "image-01-live"];
|
|
26
26
|
const MINIMAX_DEFAULT_IMAGE_MODEL = MINIMAX_IMAGE_MODELS[0];
|
|
27
|
-
/** CN region
|
|
27
|
+
/** CN region. */
|
|
28
28
|
const MINIMAX_CN_BASE_URL = "https://api.minimaxi.com";
|
|
29
|
-
/** International region
|
|
29
|
+
/** International region. */
|
|
30
30
|
const MINIMAX_INTL_BASE_URL = "https://api.minimax.io";
|
|
31
|
-
const MINIMAX_IMAGE_UI = {
|
|
32
|
-
baseUrlPresets: [{
|
|
33
|
-
value: MINIMAX_CN_BASE_URL,
|
|
34
|
-
label: "China (api.minimaxi.com)"
|
|
35
|
-
}, {
|
|
36
|
-
value: MINIMAX_INTL_BASE_URL,
|
|
37
|
-
label: "International (api.minimax.io)"
|
|
38
|
-
}],
|
|
39
|
-
baseUrlPresetKind: "minimax"
|
|
40
|
-
};
|
|
41
31
|
const DEFAULT_TIMEOUT_MS = 12e4;
|
|
42
32
|
const MINIMAX_CAPABILITIES = {
|
|
43
33
|
generate: {
|
|
@@ -55,31 +45,31 @@ const MINIMAX_CAPABILITIES = {
|
|
|
55
45
|
] },
|
|
56
46
|
output: { formats: ["jpeg"] }
|
|
57
47
|
};
|
|
58
|
-
function readMinimaxCfgString(cfg, key) {
|
|
48
|
+
function readMinimaxCfgString(cfg, providerId, key) {
|
|
59
49
|
const providers = cfg?.providers;
|
|
60
50
|
if (!providers || typeof providers !== "object") return void 0;
|
|
61
|
-
const entry = providers[
|
|
51
|
+
const entry = providers[providerId];
|
|
62
52
|
if (!entry || typeof entry !== "object") return void 0;
|
|
63
53
|
const v = entry[key];
|
|
64
54
|
return typeof v === "string" && v.trim() ? v.trim() : void 0;
|
|
65
55
|
}
|
|
66
56
|
/**
|
|
67
|
-
* Resolve MiniMax base URL
|
|
68
|
-
* 1. cfg.providers.
|
|
57
|
+
* Resolve MiniMax base URL:
|
|
58
|
+
* 1. cfg.providers[providerId].baseUrl
|
|
69
59
|
* 2. MINIMAX_BASE_URL env
|
|
70
|
-
* 3.
|
|
71
|
-
* otherwise CN.
|
|
60
|
+
* 3. Provider default base URL
|
|
72
61
|
*/
|
|
73
|
-
function resolveMinimaxBaseUrl(req) {
|
|
74
|
-
const
|
|
62
|
+
function resolveMinimaxBaseUrl(req, defaultBaseUrl) {
|
|
63
|
+
const providerId = req.provider?.trim() || "minimax";
|
|
64
|
+
const fromCfg = readMinimaxCfgString(req.cfg, providerId, "baseUrl");
|
|
75
65
|
if (fromCfg) return fromCfg.replace(/\/+$/, "");
|
|
76
66
|
const fromEnv = process.env.MINIMAX_BASE_URL?.trim();
|
|
77
67
|
if (fromEnv) return fromEnv.replace(/\/+$/, "");
|
|
78
|
-
if (
|
|
79
|
-
return MINIMAX_CN_BASE_URL;
|
|
68
|
+
if (defaultBaseUrl) return defaultBaseUrl;
|
|
69
|
+
return providerId === "minimax" ? MINIMAX_INTL_BASE_URL : MINIMAX_CN_BASE_URL;
|
|
80
70
|
}
|
|
81
|
-
function resolveMinimaxImageUrl(req) {
|
|
82
|
-
return `${resolveMinimaxBaseUrl(req)}/v1/image_generation`;
|
|
71
|
+
function resolveMinimaxImageUrl(req, defaultBaseUrl) {
|
|
72
|
+
return `${resolveMinimaxBaseUrl(req, defaultBaseUrl)}/v1/image_generation`;
|
|
83
73
|
}
|
|
84
74
|
/** Map tool size (e.g. `1024x1024`) to the closest MiniMax-supported aspect ratio. */
|
|
85
75
|
function mapSizeToMinimaxAspectRatio(size) {
|
|
@@ -125,24 +115,25 @@ function mapSizeToMinimaxAspectRatio(size) {
|
|
|
125
115
|
}
|
|
126
116
|
async function generateMinimaxImages(params) {
|
|
127
117
|
const { req, apiKey } = params;
|
|
118
|
+
const providerId = params.providerId ?? req.provider ?? "minimax-cn";
|
|
128
119
|
if (req.inputImages && req.inputImages.length > 0) throw new Error("Image-to-image is not supported for MiniMax in this build");
|
|
129
120
|
const model = req.model?.trim() || MINIMAX_DEFAULT_IMAGE_MODEL;
|
|
130
121
|
const aspectRatio = req.aspectRatio?.trim() || mapSizeToMinimaxAspectRatio(req.size);
|
|
131
|
-
const url = resolveMinimaxImageUrl(req);
|
|
122
|
+
const url = resolveMinimaxImageUrl(req, params.defaultBaseUrl);
|
|
132
123
|
const httpDefaults = resolveProviderHttpRequestConfig({
|
|
133
|
-
providerId
|
|
124
|
+
providerId,
|
|
134
125
|
cfg: req.cfg,
|
|
135
126
|
fallbackTimeoutMs: DEFAULT_TIMEOUT_MS
|
|
136
127
|
});
|
|
137
128
|
log.debug({
|
|
138
|
-
providerId
|
|
129
|
+
providerId,
|
|
139
130
|
model,
|
|
140
131
|
url,
|
|
141
132
|
aspectRatio,
|
|
142
133
|
phase: "request"
|
|
143
134
|
}, "MiniMax image generation request");
|
|
144
135
|
const rawText = await (await postJsonRequest(url, {
|
|
145
|
-
label:
|
|
136
|
+
label: providerId,
|
|
146
137
|
timeoutMs: pickTimeoutMsOrFallback(req.timeoutMs, httpDefaults.timeoutMs, DEFAULT_TIMEOUT_MS),
|
|
147
138
|
signal: req.signal,
|
|
148
139
|
body: {
|
|
@@ -176,32 +167,47 @@ async function generateMinimaxImages(params) {
|
|
|
176
167
|
model
|
|
177
168
|
};
|
|
178
169
|
}
|
|
179
|
-
function
|
|
170
|
+
function createMinimaxImageGenerationProvider(options) {
|
|
180
171
|
return {
|
|
181
|
-
id:
|
|
182
|
-
label:
|
|
172
|
+
id: options.id,
|
|
173
|
+
label: options.label,
|
|
183
174
|
defaultModel: MINIMAX_DEFAULT_IMAGE_MODEL,
|
|
184
175
|
models: [...MINIMAX_IMAGE_MODELS],
|
|
185
176
|
capabilities: MINIMAX_CAPABILITIES,
|
|
186
|
-
ui: MINIMAX_IMAGE_UI,
|
|
187
177
|
isConfigured: (ctx) => isProviderApiKeyConfigured({
|
|
188
|
-
providerId:
|
|
178
|
+
providerId: options.id,
|
|
189
179
|
cfg: ctx.cfg
|
|
190
180
|
}),
|
|
191
181
|
async generateImage(req) {
|
|
192
182
|
const apiKey = resolveApiKeyForProvider({
|
|
193
|
-
providerId:
|
|
183
|
+
providerId: options.id,
|
|
194
184
|
cfg: req.cfg
|
|
195
185
|
});
|
|
196
|
-
if (!apiKey) throw new Error(
|
|
186
|
+
if (!apiKey) throw new Error(`MiniMax API key missing (MINIMAX_API_KEY or providers.${options.id}.apiKey)`);
|
|
197
187
|
return generateMinimaxImages({
|
|
198
188
|
req,
|
|
199
|
-
apiKey
|
|
189
|
+
apiKey,
|
|
190
|
+
providerId: options.id,
|
|
191
|
+
defaultBaseUrl: options.defaultBaseUrl
|
|
200
192
|
});
|
|
201
193
|
}
|
|
202
194
|
};
|
|
203
195
|
}
|
|
196
|
+
function buildMinimaxCnImageGenerationProvider() {
|
|
197
|
+
return createMinimaxImageGenerationProvider({
|
|
198
|
+
id: "minimax-cn",
|
|
199
|
+
label: "MiniMax CN",
|
|
200
|
+
defaultBaseUrl: MINIMAX_CN_BASE_URL
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
function buildMinimaxImageGenerationProvider() {
|
|
204
|
+
return createMinimaxImageGenerationProvider({
|
|
205
|
+
id: "minimax",
|
|
206
|
+
label: "MiniMax International",
|
|
207
|
+
defaultBaseUrl: MINIMAX_INTL_BASE_URL
|
|
208
|
+
});
|
|
209
|
+
}
|
|
204
210
|
//#endregion
|
|
205
|
-
export { MINIMAX_DEFAULT_IMAGE_MODEL, MINIMAX_IMAGE_MODELS, buildMinimaxImageGenerationProvider, generateMinimaxImages, mapSizeToMinimaxAspectRatio, resolveMinimaxBaseUrl };
|
|
211
|
+
export { MINIMAX_DEFAULT_IMAGE_MODEL, MINIMAX_IMAGE_MODELS, buildMinimaxCnImageGenerationProvider, buildMinimaxImageGenerationProvider, generateMinimaxImages, mapSizeToMinimaxAspectRatio, resolveMinimaxBaseUrl };
|
|
206
212
|
|
|
207
213
|
//# sourceMappingURL=image-generation-provider.js.map
|