@xopcai/xopc 0.0.364 → 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/dist/sidepanel.js +16 -4
- 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-GvR2gZ0T.js → activity-store-Cuf3JFFJ.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-7Ct-ZlfL.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-BkXb7VEZ.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-CjfsIn9A.js → app-management-settings-panel-CoIFxQKH.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-qqHZ15GU.js → appearance-settings-DQr0o6Lm.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-Ba2VkQk6.js → apps-page-CltMV4Xp.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-CKe3qAaL.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-Bt8Q58ut.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-ClRFbHP7.js → block-editor-BFPUlxJ6.js} +28 -28
- package/dist/gateway/static/root/assets/{browser-automation-inputs-5B3qAdmb.js → browser-automation-inputs-BUAIKIX0.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-BjMub7JM.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-BKu9BqPe.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-gZ8auLwa.js → capabilities-settings-panel-BUblBMZC.js} +4 -4
- package/dist/gateway/static/root/assets/{capability-header-actions-L1NvoOUG.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-DsCpKPBe.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-mtH9mEBf.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-B_fPQBTM.js → dependency-picker-DYm96PDu.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-CJrO9Vd_.js → desktop-pet-D90OzgeR.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DYAfri9w.js → desktop-pet-settings-CmdCecjm.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-CqRys2R8.js → device-pairing-wizard-s2ogSa4l.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-D7_qSxNZ.js → directory-picker-path-field-DZpaoeNa.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-BGyJpRv4.js → extension-debug-page-Bv6QE8kC.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-D1zBmd8F.js → extension-page-CEsq71Cm.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-F9JzOWZ3.js → extension-provider-CX-sK0Tw.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-CTR8AjCG.js → extension-settings-page-UyOHF39P.js} +1 -1
- package/dist/gateway/static/root/assets/{fallback-models-Chhv4Nfv.js → fallback-models-CKv_Wqg8.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-CoRoOG1l.js → gateway-config-swr-Cjnkle5J.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-D0ygm6bc.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-FDS6S6qa.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-BPd76jW5.js → image-generation-api-NLHzm4Nc.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-9EnECtcl.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-MC7mG2h2.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-c3HncHZ3.js → local-apps-page-TpUAfOn2.js} +1 -1
- package/dist/gateway/static/root/assets/local-session-drafts-Cvv7I0fw.js +1 -0
- package/dist/gateway/static/root/assets/{locale-store-DId6-v2R.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-XLewwq2q.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-B9SKjidc.js → models-hub-cache-B1C86nRp.js} +1 -1
- package/dist/gateway/static/root/assets/note-detail-panel-DL__qP6U.js +5 -0
- package/dist/gateway/static/root/assets/{notes-api-Byt65v3r.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-BYsCbyGZ.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-RBp1QK0F.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-7F2WNEZC.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-B0c120iI.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-DQpQc9tH.js → schema-form-CxrMGsT9.js} +1 -1
- package/dist/gateway/static/root/assets/secret-input-D93UrW4C.js +1 -0
- package/dist/gateway/static/root/assets/{send-session-input-D1oc6BC6.js → send-session-input-CgOzhDZ0.js} +1 -1
- package/dist/gateway/static/root/assets/{session-api-N3N37MrR.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-GgBEp6O7.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-TBBGJPfT.js → share-link-dialog-Dg5os066.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-DyRLPsPv.js → share-preview-page-DMvohAyr.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-api-DU0fHP2G.js → shares-api-C96IO4qJ.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-DJ1ME-XM.js → shares-settings-CsDATuCw.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-1Puv6wOz.js → skill-api-C10ML0CH.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-ClyFqHk7.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--yV67a8L.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-OhcbFEUR.js → theme-store-DQ6KJa4l.js} +1 -1
- package/dist/gateway/static/root/assets/tracing-settings-page-Ed8_GYUT.js +1 -0
- package/dist/gateway/static/root/assets/{tunnel-api-COLdiP_E.js → tunnel-api-D3X8jDwo.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-CtM5IfrL.js → usage-page-BqzRyyb9.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-veoM0dHn.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-Bope6MW6.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-CwD6a3KQ.js → voice-api-key-field-R9zNWYR_.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-Daexehmc.js → voice-config-api-DLudE9Rc.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-C9u7tuEc.js → work-discovery-overlay-DVmQrolV.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BMOBbf33.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 +33 -31
- 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/gateway-contract/src/session-input-command.js +1 -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/agent-manager.d.ts +1 -0
- package/dist/src/agent/agent-manager.js +35 -3
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/commands/command-registry.js +1 -1
- package/dist/src/agent/context/execution-context.js +1 -1
- package/dist/src/agent/context/project-context.js +4 -4
- package/dist/src/agent/embedded/run-for-session.js +1 -1
- package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
- 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/inbound/attachment-pipeline.js +1 -1
- package/dist/src/agent/prompt/voice-presentation.d.ts +1 -1
- package/dist/src/agent/prompt/voice-presentation.js +1 -1
- package/dist/src/agent/service/direct-turn-helpers.js +17 -1
- package/dist/src/agent/service.js +3 -3
- package/dist/src/agent/skills/index.js +1 -1
- package/dist/src/agent/skills/managed-store.js +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +1 -1
- package/dist/src/agent/tools/delegation-parent-policy.js +2 -0
- package/dist/src/agent/tools/delegation-policy.js +2 -0
- package/dist/src/agent/tools/factory.d.ts +2 -0
- package/dist/src/agent/tools/factory.js +31 -4
- package/dist/src/agent/tools/image-generate-tool.js +5 -19
- package/dist/src/agent/tools/index.d.ts +2 -2
- package/dist/src/agent/tools/index.js +3 -3
- package/dist/src/agent/tools/knowledge-memory-tool.d.ts +2 -0
- package/dist/src/agent/tools/knowledge-memory-tool.js +60 -1
- 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/agent/tools/personal-task-tool.d.ts +12 -8
- package/dist/src/agent/tools/personal-task-tool.js +35 -41
- package/dist/src/agent/tools/user-context-tool.d.ts +2 -0
- package/dist/src/agent/tools/user-context-tool.js +61 -2
- package/dist/src/agent/tools/xopc-use-tool.js +2 -2
- package/dist/src/agent-catalog/capabilities.js +2 -2
- package/dist/src/agent-catalog/migrations/legacy-config-cutover.js +1 -1
- package/dist/src/agent-catalog/repository.d.ts +1 -0
- package/dist/src/agent-catalog/repository.js +4 -1
- package/dist/src/automations/capabilities/drafts.js +1 -1
- 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/bootstrap/application-state.js +1 -1
- package/dist/src/capabilities/runtime/dispatcher.js +1 -1
- package/dist/src/capabilities/runtime/product.js +1 -1
- package/dist/src/chat-commands/personal-command-policy.d.ts +2 -0
- package/dist/src/chat-commands/personal-command-policy.js +9 -0
- package/dist/src/chat-commands/registry.js +6 -0
- package/dist/src/cli/commands/agents.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/models.js +4 -9
- package/dist/src/cli/commands/onboard/model.js +2 -2
- package/dist/src/cli/utils/init-workspace-core.js +1 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/config/models-json.d.ts +170 -0
- package/dist/src/config/models-json.js +23 -8
- package/dist/src/extensions/agent-plugins/validation.js +1 -1
- package/dist/src/files/file-service.d.ts +6 -0
- package/dist/src/files/file-service.js +38 -1
- package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
- package/dist/src/gateway/agents-admin.js +2 -2
- 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/agents.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
- package/dist/src/gateway/hono/routes/files.js +13 -2
- package/dist/src/gateway/hono/routes/notes.js +2 -2
- package/dist/src/gateway/hono/routes/observability.js +8 -0
- package/dist/src/gateway/hono/routes/personal-agent.js +41 -0
- package/dist/src/gateway/hono/routes/projects.js +3 -3
- package/dist/src/gateway/hono/routes/session-input-handler.d.ts +2 -0
- package/dist/src/gateway/hono/routes/session-input-handler.js +9 -1
- package/dist/src/gateway/hono/routes/sessions.js +1 -1
- package/dist/src/gateway/hono/routes/tasks.js +1 -1
- package/dist/src/gateway/hono/routes/voice.js +1 -1
- package/dist/src/gateway/image-generation-setup.js +1 -1
- package/dist/src/gateway/service/agent-runner.d.ts +1 -0
- package/dist/src/gateway/service/agent-runner.js +12 -1
- package/dist/src/gateway/service/run-gateway-agent.d.ts +1 -0
- package/dist/src/gateway/service/run-gateway-agent.js +15 -0
- package/dist/src/gateway/service/session-command-service.js +5 -3
- package/dist/src/gateway/service/session-input-coordinator.d.ts +12 -0
- package/dist/src/gateway/service/session-input-coordinator.js +63 -5
- package/dist/src/gateway/service/sessions-api.js +1 -1
- package/dist/src/gateway/service.d.ts +3 -0
- package/dist/src/gateway/service.js +54 -9
- package/dist/src/gateway/session-context-summary.js +1 -1
- package/dist/src/gateway/session-reset-service.js +1 -1
- package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
- package/dist/src/home-intelligence/host.js +2 -2
- package/dist/src/local-apps/service.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/capability-service.js +3 -2
- package/dist/src/personal-agent/communication.d.ts +3 -2
- package/dist/src/personal-agent/communication.js +4 -3
- package/dist/src/personal-agent/conversation-state.d.ts +5 -0
- package/dist/src/personal-agent/conversation-state.js +17 -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/persona.d.ts +6 -0
- package/dist/src/personal-agent/persona.js +16 -0
- package/dist/src/personal-agent/policy.d.ts +3 -1
- package/dist/src/personal-agent/policy.js +28 -6
- 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/prompt-context.d.ts +10 -0
- package/dist/src/personal-agent/prompt-context.js +119 -0
- package/dist/src/personal-agent/prompts.d.ts +7 -0
- package/dist/src/personal-agent/prompts.js +135 -0
- package/dist/src/personal-agent/reply-composer.d.ts +1 -1
- package/dist/src/personal-agent/reply-composer.js +41 -13
- package/dist/src/personal-agent/repository.d.ts +1 -1
- package/dist/src/personal-agent/repository.js +1 -1
- package/dist/src/personal-agent/request-delivery.js +1 -1
- package/dist/src/personal-agent/request-service.js +2 -2
- package/dist/src/personal-agent/service.d.ts +1 -2
- package/dist/src/personal-agent/service.js +5 -93
- package/dist/src/personal-agent/specialist-capabilities.d.ts +9 -0
- package/dist/src/personal-agent/specialist-capabilities.js +37 -0
- 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/init-session-turn.js +10 -0
- package/dist/src/session/session-context-for-llm.js +28 -0
- package/dist/src/session/store.js +1 -1
- package/dist/src/storage/sqlite/migrations/235_personal_conversation_priority.sql +3 -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/storage/sqlite/session-input-repository.d.ts +2 -0
- package/dist/src/storage/sqlite/session-input-repository.js +18 -5
- package/dist/src/tasks/capabilities/read.js +2 -2
- package/dist/src/tasks/execution-context.js +1 -1
- package/dist/src/tasks/home-query-service.js +27 -1
- package/dist/src/tasks/task-main-update-decision-service.js +1 -1
- package/dist/src/tasks/task-result-delivery-service.js +1 -1
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/voice/platform-catalog.d.ts +1 -9
- package/dist/src/voice/realtime/agentEngine.js +32 -7
- package/dist/src/voice/realtime/engine.d.ts +1 -0
- package/dist/src/voice/realtime/omniEngine.d.ts +1 -0
- package/dist/src/voice/realtime/omniEngine.js +10 -0
- package/dist/src/voice/realtime/persona-context.js +1 -1
- package/dist/src/voice/realtime/runtime.d.ts +1 -0
- package/dist/src/voice/realtime/runtime.js +5 -0
- package/dist/src/voice/realtime/runtime.types.d.ts +2 -0
- package/dist/src/work-discovery/service.js +1 -1
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/package.json +4 -3
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-wYj-iyqv.js +0 -1
- package/dist/gateway/static/root/assets/agent-plugin-dialog-C9HYMhnJ.js +0 -1
- package/dist/gateway/static/root/assets/agents-hPkFQ81z.js +0 -66
- package/dist/gateway/static/root/assets/app-link-DRL0YnPs.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-Ch0ViAJW.js +0 -7
- package/dist/gateway/static/root/assets/binary-plugins-J51oS7-D.js +0 -2
- package/dist/gateway/static/root/assets/browser-settings-page-CYrPA-Fp.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-CT_ZW9fT.js +0 -1
- package/dist/gateway/static/root/assets/capabilities-page-dW6FXtOy.js +0 -2
- package/dist/gateway/static/root/assets/channels-Dx5T2G73.js +0 -1
- package/dist/gateway/static/root/assets/computer-settings-page-6FWwxYLe.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-DgDLaws0.js +0 -2
- package/dist/gateway/static/root/assets/date-picker-BDcwEaIx.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-DBvCRclh.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-BVfz4Tla.js +0 -1
- package/dist/gateway/static/root/assets/home-page-BF_9C9yW.js +0 -1
- package/dist/gateway/static/root/assets/index-BpXej9jJ.js +0 -106
- package/dist/gateway/static/root/assets/index-CbJNcWAn.css +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CytNu0-_.js +0 -1
- package/dist/gateway/static/root/assets/local-session-drafts-gbemPamv.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-D4aXtitd.js +0 -2
- package/dist/gateway/static/root/assets/management-settings-CRzWi_iJ.js +0 -1
- package/dist/gateway/static/root/assets/markdown-view-DQZ51j9e.js +0 -201
- package/dist/gateway/static/root/assets/messages-BHvpZNe9.js +0 -3
- package/dist/gateway/static/root/assets/note-detail-panel-BgbByI-4.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-R2BX5XCE.js +0 -8
- package/dist/gateway/static/root/assets/personal-page-F0jTBWva.js +0 -1
- package/dist/gateway/static/root/assets/product-open-page-BtDK68qb.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-DmQEm0yH.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-CrLQvkHX.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-C25_hQAd.js +0 -1
- package/dist/gateway/static/root/assets/scenes-page-DM64yMnx.js +0 -2
- package/dist/gateway/static/root/assets/secret-input-DPl3VYM8.js +0 -1
- package/dist/gateway/static/root/assets/session-manager-CMGUwtbN.js +0 -16
- package/dist/gateway/static/root/assets/sessions-page-DvDO8LtA.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BNhgbmcX.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-10bMi6yL.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-D52pEr5x.js +0 -2
- package/dist/gateway/static/root/assets/task-detail-page-D-tcS2bS.js +0 -2
- package/dist/gateway/static/root/assets/tracing-settings-page-DoBJ0TYY.js +0 -1
- package/dist/gateway/static/root/assets/use-composer-attachments-DB0bBGzZ.js +0 -2
- package/dist/gateway/static/root/assets/user-model-page-CSh61kZ5.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-BrD9vXqO.js +0 -6
- package/dist/gateway/static/root/assets/workspace-api-Cs4sjV2A.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,372 @@
|
|
|
1
|
+
import { getImageProviderSpec } from "./catalog.js";
|
|
2
|
+
import { ImageProviderError, validateImageRequest } from "./validation.js";
|
|
3
|
+
import { MAX_IMAGE_BYTES, assertImageResponseOk, authenticatedJobUrl, decodeBase64, encodeBase64, imageFromBytes, readBytesLimited, readImageJson, waitForImagePoll } from "./http.js";
|
|
4
|
+
//#region packages/image-providers/src/execute.ts
|
|
5
|
+
const object = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
6
|
+
const array = (value) => Array.isArray(value) ? value : [];
|
|
7
|
+
var ImageTransport = class {
|
|
8
|
+
constructor(execution) {
|
|
9
|
+
this.execution = execution;
|
|
10
|
+
}
|
|
11
|
+
endpoint(path) {
|
|
12
|
+
return `${this.execution.baseUrl.replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`;
|
|
13
|
+
}
|
|
14
|
+
async json(url, body, headers = {}) {
|
|
15
|
+
return readImageJson(await this.execution.fetchImpl(url, {
|
|
16
|
+
method: body ? "POST" : "GET",
|
|
17
|
+
headers: {
|
|
18
|
+
...body ? { "content-type": "application/json" } : {},
|
|
19
|
+
...headers
|
|
20
|
+
},
|
|
21
|
+
...body ? { body: JSON.stringify(body) } : {},
|
|
22
|
+
signal: this.execution.signal,
|
|
23
|
+
redirect: "error"
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
async form(url, form, headers) {
|
|
27
|
+
return readImageJson(await this.execution.fetchImpl(url, {
|
|
28
|
+
method: "POST",
|
|
29
|
+
headers,
|
|
30
|
+
body: form,
|
|
31
|
+
signal: this.execution.signal,
|
|
32
|
+
redirect: "error"
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
async image(url) {
|
|
36
|
+
if (typeof url !== "string" || !/^https?:\/\//.test(url)) throw new ImageProviderError("Missing generated image URL", 502);
|
|
37
|
+
const response = await this.execution.fetchImpl(url, {
|
|
38
|
+
signal: this.execution.signal,
|
|
39
|
+
redirect: "error"
|
|
40
|
+
});
|
|
41
|
+
try {
|
|
42
|
+
await assertImageResponseOk(response);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
if (error instanceof ImageProviderError) throw new ImageProviderError(error.message, error.status);
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
return imageFromBytes(await readBytesLimited(response, MAX_IMAGE_BYTES));
|
|
48
|
+
}
|
|
49
|
+
bearer() {
|
|
50
|
+
return { authorization: `Bearer ${this.execution.apiKey}` };
|
|
51
|
+
}
|
|
52
|
+
async dataImages(data) {
|
|
53
|
+
const entries = array(data);
|
|
54
|
+
if (entries.length > (this.execution.request.count ?? 1)) throw new ImageProviderError("Provider returned too many images", 502);
|
|
55
|
+
const images = [];
|
|
56
|
+
let total = 0;
|
|
57
|
+
for (const value of entries) {
|
|
58
|
+
const entry = object(value);
|
|
59
|
+
const image = entry.b64_json ? imageFromBytes(decodeBase64(entry.b64_json)) : await this.image(entry.url);
|
|
60
|
+
total += image.bytes.byteLength;
|
|
61
|
+
if (total > 67108864) throw new ImageProviderError("Generated images exceed total byte limit", 502);
|
|
62
|
+
images.push(image);
|
|
63
|
+
}
|
|
64
|
+
return images;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
async function jobJson(http, url, headers) {
|
|
68
|
+
try {
|
|
69
|
+
return await http.json(url, void 0, headers);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
if (error instanceof ImageProviderError) throw new ImageProviderError(error.message, error.status);
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async function inputUris(execution) {
|
|
76
|
+
return Promise.all((execution.request.inputImages ?? []).map(async (image) => `data:${image.blob.type};base64,${encodeBase64(new Uint8Array(await image.blob.arrayBuffer()))}`));
|
|
77
|
+
}
|
|
78
|
+
async function openai(http) {
|
|
79
|
+
const { request: req } = http.execution;
|
|
80
|
+
const body = {
|
|
81
|
+
model: req.model,
|
|
82
|
+
prompt: req.prompt,
|
|
83
|
+
n: req.count ?? 1
|
|
84
|
+
};
|
|
85
|
+
if (req.size) body.size = req.size;
|
|
86
|
+
if (req.quality) body.quality = req.quality;
|
|
87
|
+
if (req.outputFormat) body.output_format = req.outputFormat;
|
|
88
|
+
if (req.background) body.background = req.background;
|
|
89
|
+
if (req.openai?.moderation) body.moderation = req.openai.moderation;
|
|
90
|
+
if (req.openai?.outputCompression !== void 0) body.output_compression = req.openai.outputCompression;
|
|
91
|
+
if (req.openai?.user) body.user = req.openai.user;
|
|
92
|
+
let data;
|
|
93
|
+
if (req.inputImages?.length) {
|
|
94
|
+
const form = new FormData();
|
|
95
|
+
for (const [key, value] of Object.entries(body)) form.append(key, String(value));
|
|
96
|
+
for (const image of req.inputImages) form.append("image[]", image.blob, image.fileName);
|
|
97
|
+
data = await http.form(http.endpoint("/images/edits"), form, http.bearer());
|
|
98
|
+
} else data = await http.json(http.endpoint("/images/generations"), body, http.bearer());
|
|
99
|
+
return {
|
|
100
|
+
images: await http.dataImages(data.data),
|
|
101
|
+
usage: data.usage
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
async function dashscope(http) {
|
|
105
|
+
const { request: req } = http.execution;
|
|
106
|
+
const content = [{ text: req.prompt }, ...(await inputUris(http.execution)).map((image) => ({ image }))];
|
|
107
|
+
const parameters = {
|
|
108
|
+
n: req.count ?? 1,
|
|
109
|
+
watermark: false
|
|
110
|
+
};
|
|
111
|
+
if (req.size) parameters.size = req.size.replace("x", "*");
|
|
112
|
+
const data = await http.json(http.endpoint("/api/v1/services/aigc/multimodal-generation/generation"), {
|
|
113
|
+
model: req.model,
|
|
114
|
+
input: { messages: [{
|
|
115
|
+
role: "user",
|
|
116
|
+
content
|
|
117
|
+
}] },
|
|
118
|
+
parameters
|
|
119
|
+
}, http.bearer());
|
|
120
|
+
if (data.code) throw new ImageProviderError("DashScope image request rejected", 400);
|
|
121
|
+
const urls = array(object(data.output).choices).flatMap((choice) => array(object(object(choice).message).content)).map((item) => object(item).image).filter((url) => typeof url === "string");
|
|
122
|
+
return {
|
|
123
|
+
images: await http.dataImages(urls.map((url) => ({ url }))),
|
|
124
|
+
usage: data.usage,
|
|
125
|
+
requestId: typeof data.request_id === "string" ? data.request_id : void 0
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
async function google(http) {
|
|
129
|
+
const { request: req, apiKey } = http.execution;
|
|
130
|
+
const input = [{
|
|
131
|
+
type: "text",
|
|
132
|
+
text: req.prompt
|
|
133
|
+
}];
|
|
134
|
+
for (const image of req.inputImages ?? []) input.push({
|
|
135
|
+
type: "image",
|
|
136
|
+
mime_type: image.blob.type,
|
|
137
|
+
data: encodeBase64(new Uint8Array(await image.blob.arrayBuffer()))
|
|
138
|
+
});
|
|
139
|
+
const responseFormat = { type: "image" };
|
|
140
|
+
if (req.aspectRatio) responseFormat.aspect_ratio = req.aspectRatio;
|
|
141
|
+
if (req.resolution) responseFormat.image_size = req.resolution;
|
|
142
|
+
if (req.outputFormat) responseFormat.mime_type = `image/${req.outputFormat}`;
|
|
143
|
+
const data = await http.json(http.endpoint("/v1beta/interactions"), {
|
|
144
|
+
model: req.model,
|
|
145
|
+
input,
|
|
146
|
+
store: false,
|
|
147
|
+
response_format: responseFormat
|
|
148
|
+
}, { "x-goog-api-key": apiKey });
|
|
149
|
+
if (data.status !== "completed") throw new ImageProviderError("Google image interaction did not complete", 502);
|
|
150
|
+
const parts = array(object(array(data.steps).filter((step) => object(step).type === "model_output").at(-1)).content).filter((part) => object(part).type === "image");
|
|
151
|
+
return {
|
|
152
|
+
images: await http.dataImages(parts.map((part) => ({
|
|
153
|
+
b64_json: object(part).data,
|
|
154
|
+
url: object(part).uri
|
|
155
|
+
}))),
|
|
156
|
+
usage: data.usage,
|
|
157
|
+
requestId: typeof data.id === "string" ? data.id : void 0
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
async function fal(http, model) {
|
|
161
|
+
const { request: req, apiKey, signal, baseUrl } = http.execution;
|
|
162
|
+
const editing = Boolean(req.inputImages?.length);
|
|
163
|
+
const path = editing ? model.editPath : req.model;
|
|
164
|
+
const body = { prompt: req.prompt };
|
|
165
|
+
if (req.model.startsWith("google/")) {
|
|
166
|
+
body.num_images = req.count ?? 1;
|
|
167
|
+
if (req.aspectRatio) body.aspect_ratio = req.aspectRatio;
|
|
168
|
+
if (req.resolution) body.resolution = req.resolution;
|
|
169
|
+
} else if (req.size) {
|
|
170
|
+
const [width, height] = req.size.split("x").map(Number);
|
|
171
|
+
body.image_size = {
|
|
172
|
+
width,
|
|
173
|
+
height
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
if (req.outputFormat) body.output_format = req.outputFormat;
|
|
177
|
+
if (editing) body.image_urls = await inputUris(http.execution);
|
|
178
|
+
const headers = { authorization: `Key ${apiKey}` };
|
|
179
|
+
const submit = await http.json(http.endpoint(path), body, headers);
|
|
180
|
+
const statusUrl = authenticatedJobUrl(submit.status_url, baseUrl);
|
|
181
|
+
const resultUrl = authenticatedJobUrl(submit.response_url, baseUrl);
|
|
182
|
+
for (;;) {
|
|
183
|
+
signal.throwIfAborted();
|
|
184
|
+
const status = await jobJson(http, statusUrl, headers);
|
|
185
|
+
if (status.status === "COMPLETED") break;
|
|
186
|
+
if (status.status !== "IN_QUEUE" && status.status !== "IN_PROGRESS") throw new ImageProviderError("fal image job failed", 502);
|
|
187
|
+
await waitForImagePoll(signal);
|
|
188
|
+
}
|
|
189
|
+
const result = await jobJson(http, resultUrl, headers);
|
|
190
|
+
return {
|
|
191
|
+
images: await http.dataImages(result.images),
|
|
192
|
+
requestId: typeof submit.request_id === "string" ? submit.request_id : void 0
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
async function seedream(http) {
|
|
196
|
+
const { request: req } = http.execution;
|
|
197
|
+
const images = await inputUris(http.execution);
|
|
198
|
+
const body = {
|
|
199
|
+
model: req.model,
|
|
200
|
+
prompt: req.prompt,
|
|
201
|
+
response_format: "b64_json",
|
|
202
|
+
watermark: false
|
|
203
|
+
};
|
|
204
|
+
if (images.length) body.image = images.length === 1 ? images[0] : images;
|
|
205
|
+
if (req.size) body.size = req.size;
|
|
206
|
+
if (req.outputFormat) body.output_format = req.outputFormat;
|
|
207
|
+
const data = await http.json(http.endpoint("/images/generations"), body, http.bearer());
|
|
208
|
+
if (data.error) throw new ImageProviderError("Seedream image request rejected", 400);
|
|
209
|
+
return {
|
|
210
|
+
images: await http.dataImages(data.data),
|
|
211
|
+
usage: data.usage
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
async function ideogram(http) {
|
|
215
|
+
const { request: req, apiKey } = http.execution;
|
|
216
|
+
const headers = { "Api-Key": apiKey };
|
|
217
|
+
let data;
|
|
218
|
+
if (req.inputImages?.length) {
|
|
219
|
+
const form = new FormData();
|
|
220
|
+
form.append("prompt", req.prompt);
|
|
221
|
+
form.append("num_images", String(req.count ?? 1));
|
|
222
|
+
if (req.quality) form.append("quality", req.quality);
|
|
223
|
+
req.inputImages.forEach((image, index) => form.append(index === 0 ? "image" : "reference_images", image.blob, image.fileName));
|
|
224
|
+
data = await http.form(http.endpoint(`/v2/image/precise-edit/${req.model}`), form, headers);
|
|
225
|
+
} else {
|
|
226
|
+
const body = {
|
|
227
|
+
prompt: req.prompt,
|
|
228
|
+
num_images: req.count ?? 1
|
|
229
|
+
};
|
|
230
|
+
if (req.size) body.resolution = req.size;
|
|
231
|
+
if (req.quality) body.quality = req.quality;
|
|
232
|
+
data = await http.json(http.endpoint(`/v2/image/generate/${req.model}`), body, headers);
|
|
233
|
+
}
|
|
234
|
+
return {
|
|
235
|
+
images: await http.dataImages(data.data),
|
|
236
|
+
requestId: typeof data.generation_id === "string" ? data.generation_id : void 0
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
async function bfl(http) {
|
|
240
|
+
const { request: req, apiKey, baseUrl, signal } = http.execution;
|
|
241
|
+
const body = { prompt: req.prompt };
|
|
242
|
+
if (req.size) {
|
|
243
|
+
const [width, height] = req.size.split("x").map(Number);
|
|
244
|
+
body.width = width;
|
|
245
|
+
body.height = height;
|
|
246
|
+
}
|
|
247
|
+
if (req.outputFormat) body.output_format = req.outputFormat;
|
|
248
|
+
(await inputUris(http.execution)).forEach((image, index) => {
|
|
249
|
+
body[index === 0 ? "input_image" : `input_image_${index + 1}`] = image;
|
|
250
|
+
});
|
|
251
|
+
const headers = { "x-key": apiKey };
|
|
252
|
+
const submit = await http.json(http.endpoint(req.model), body, headers);
|
|
253
|
+
const pollUrl = authenticatedJobUrl(submit.polling_url, baseUrl, true);
|
|
254
|
+
for (;;) {
|
|
255
|
+
signal.throwIfAborted();
|
|
256
|
+
const result = await jobJson(http, pollUrl, headers);
|
|
257
|
+
if (result.status === "Ready") return {
|
|
258
|
+
images: [await http.image(object(result.result).sample)],
|
|
259
|
+
requestId: typeof submit.id === "string" ? submit.id : void 0
|
|
260
|
+
};
|
|
261
|
+
if (!["Pending", "Processing"].includes(String(result.status))) throw new ImageProviderError("BFL image job failed", 502);
|
|
262
|
+
await waitForImagePoll(signal);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
async function minimax(http) {
|
|
266
|
+
const { request: req } = http.execution;
|
|
267
|
+
const data = await http.json(http.endpoint("/v1/image_generation"), {
|
|
268
|
+
model: req.model,
|
|
269
|
+
prompt: req.prompt,
|
|
270
|
+
aspect_ratio: req.aspectRatio ?? "1:1",
|
|
271
|
+
response_format: "base64",
|
|
272
|
+
n: req.count ?? 1
|
|
273
|
+
}, http.bearer());
|
|
274
|
+
if (object(data.base_resp).status_code) throw new ImageProviderError("MiniMax image request rejected", 400);
|
|
275
|
+
return { images: await http.dataImages(array(object(data.data).image_base64).map((b64_json) => ({ b64_json }))) };
|
|
276
|
+
}
|
|
277
|
+
async function zhipu(http) {
|
|
278
|
+
const { request: req } = http.execution;
|
|
279
|
+
const data = await http.json(http.endpoint("/images/generations"), {
|
|
280
|
+
model: req.model,
|
|
281
|
+
prompt: req.prompt,
|
|
282
|
+
...req.size ? { size: req.size } : {}
|
|
283
|
+
}, http.bearer());
|
|
284
|
+
if (data.error) throw new ImageProviderError("Zhipu image request rejected", 400);
|
|
285
|
+
return { images: await http.dataImages(data.data) };
|
|
286
|
+
}
|
|
287
|
+
async function tokenhub(http) {
|
|
288
|
+
const { request: req } = http.execution;
|
|
289
|
+
const images = await inputUris(http.execution);
|
|
290
|
+
if (req.model === "hy-image-v3.5-preview") {
|
|
291
|
+
const data = await http.json(http.endpoint("/v1/wand/hunyuan-image/v35-generation"), {
|
|
292
|
+
model: req.model,
|
|
293
|
+
...req.size ? { size: req.size } : {},
|
|
294
|
+
messages: [{
|
|
295
|
+
role: "user",
|
|
296
|
+
content: [{
|
|
297
|
+
type: "text",
|
|
298
|
+
text: req.prompt
|
|
299
|
+
}, ...images.map((url) => ({
|
|
300
|
+
type: "image_url",
|
|
301
|
+
image_url: { url }
|
|
302
|
+
}))]
|
|
303
|
+
}]
|
|
304
|
+
}, http.bearer());
|
|
305
|
+
if (data.error) throw new ImageProviderError("TokenHub image request rejected", 400);
|
|
306
|
+
const urls = array(data.choices).map((choice) => object(object(object(choice).delta).image).url).filter((url) => typeof url === "string");
|
|
307
|
+
return {
|
|
308
|
+
images: await http.dataImages(urls.map((url) => ({ url }))),
|
|
309
|
+
usage: data.tokenhub_usage,
|
|
310
|
+
requestId: typeof data.request_id === "string" ? data.request_id : void 0
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
const data = await http.json(http.endpoint("/v1/wand/hunyuan-image/v3-generation"), {
|
|
314
|
+
model: req.model,
|
|
315
|
+
prompt: req.prompt,
|
|
316
|
+
...req.size ? { size: req.size } : {},
|
|
317
|
+
...images.length ? { images: images.map((image) => image.slice(image.indexOf(",") + 1)) } : {}
|
|
318
|
+
}, http.bearer());
|
|
319
|
+
if (data.error) throw new ImageProviderError("TokenHub image request rejected", 400);
|
|
320
|
+
return {
|
|
321
|
+
images: await http.dataImages(data.data),
|
|
322
|
+
usage: data.tokenhub_usage,
|
|
323
|
+
requestId: typeof data.request_id === "string" ? data.request_id : void 0
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
async function stability(http) {
|
|
327
|
+
const { request: req, signal, fetchImpl } = http.execution;
|
|
328
|
+
const form = new FormData();
|
|
329
|
+
form.append("prompt", req.prompt);
|
|
330
|
+
if (req.aspectRatio) form.append("aspect_ratio", req.aspectRatio);
|
|
331
|
+
if (req.outputFormat) form.append("output_format", req.outputFormat);
|
|
332
|
+
const response = await fetchImpl(http.endpoint(`/v2beta/stable-image/generate/${req.model === "stable-image-ultra" ? "ultra" : "core"}`), {
|
|
333
|
+
method: "POST",
|
|
334
|
+
headers: {
|
|
335
|
+
...http.bearer(),
|
|
336
|
+
accept: "image/*"
|
|
337
|
+
},
|
|
338
|
+
body: form,
|
|
339
|
+
signal,
|
|
340
|
+
redirect: "error"
|
|
341
|
+
});
|
|
342
|
+
await assertImageResponseOk(response);
|
|
343
|
+
return { images: [imageFromBytes(await readBytesLimited(response, MAX_IMAGE_BYTES))] };
|
|
344
|
+
}
|
|
345
|
+
const adapters = {
|
|
346
|
+
openai,
|
|
347
|
+
dashscope,
|
|
348
|
+
google,
|
|
349
|
+
seedream,
|
|
350
|
+
ideogram,
|
|
351
|
+
bfl,
|
|
352
|
+
minimax,
|
|
353
|
+
zhipu,
|
|
354
|
+
tokenhub,
|
|
355
|
+
stability,
|
|
356
|
+
fal
|
|
357
|
+
};
|
|
358
|
+
async function executeImageProvider(execution) {
|
|
359
|
+
const spec = getImageProviderSpec(execution.providerId);
|
|
360
|
+
const model = spec.models.find((item) => item.id === execution.request.model);
|
|
361
|
+
if (!model) throw new ImageProviderError(`Unsupported image model: ${execution.request.model}`, 400);
|
|
362
|
+
validateImageRequest(execution.request, model.capabilities);
|
|
363
|
+
const maxPrompt = spec.protocol === "zhipu" ? 1e3 : spec.protocol === "tokenhub" && model.id === "hy-image-v3" ? 8192 : spec.protocol === "dashscope" && model.id.startsWith("wan") ? 5e3 : Infinity;
|
|
364
|
+
if ([...execution.request.prompt].length > maxPrompt) throw new ImageProviderError("Image prompt exceeds model limit", 400);
|
|
365
|
+
if (execution.request.openai && spec.protocol !== "openai") throw new ImageProviderError("OpenAI options require an OpenAI image provider", 400);
|
|
366
|
+
execution.signal.throwIfAborted();
|
|
367
|
+
const result = await adapters[spec.protocol](new ImageTransport(execution), model);
|
|
368
|
+
if (!result.images.length || result.images.length > (execution.request.count ?? 1)) throw new ImageProviderError("Provider returned an invalid image count", 502);
|
|
369
|
+
return result;
|
|
370
|
+
}
|
|
371
|
+
//#endregion
|
|
372
|
+
export { executeImageProvider };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { ImageProviderError } from "./validation.js";
|
|
2
|
+
//#region packages/image-providers/src/http.ts
|
|
3
|
+
const MAX_IMAGE_BYTES = 32 * 1024 * 1024;
|
|
4
|
+
const MAX_RESPONSE_BYTES = 64 * 1024 * 1024;
|
|
5
|
+
async function readBytesLimited(response, limit = MAX_RESPONSE_BYTES) {
|
|
6
|
+
if (Number(response.headers.get("content-length")) > limit) {
|
|
7
|
+
await response.body?.cancel();
|
|
8
|
+
throw new ImageProviderError("Image response exceeds byte limit", 502);
|
|
9
|
+
}
|
|
10
|
+
const reader = response.body?.getReader();
|
|
11
|
+
if (!reader) throw new ImageProviderError("Empty image response", 502);
|
|
12
|
+
const chunks = [];
|
|
13
|
+
let length = 0;
|
|
14
|
+
try {
|
|
15
|
+
for (;;) {
|
|
16
|
+
const { done, value } = await reader.read();
|
|
17
|
+
if (done) break;
|
|
18
|
+
length += value.byteLength;
|
|
19
|
+
if (length > limit) throw new ImageProviderError("Image response exceeds byte limit", 502);
|
|
20
|
+
chunks.push(value);
|
|
21
|
+
}
|
|
22
|
+
} catch (error) {
|
|
23
|
+
await reader.cancel().catch(() => {});
|
|
24
|
+
throw error;
|
|
25
|
+
} finally {
|
|
26
|
+
reader.releaseLock();
|
|
27
|
+
}
|
|
28
|
+
const result = new Uint8Array(length);
|
|
29
|
+
let offset = 0;
|
|
30
|
+
for (const chunk of chunks) {
|
|
31
|
+
result.set(chunk, offset);
|
|
32
|
+
offset += chunk.byteLength;
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
async function assertImageResponseOk(response) {
|
|
37
|
+
if (response.ok) return;
|
|
38
|
+
await response.body?.cancel();
|
|
39
|
+
throw new ImageProviderError(`Image provider HTTP ${response.status}`, response.status, [
|
|
40
|
+
401,
|
|
41
|
+
403,
|
|
42
|
+
429
|
|
43
|
+
].includes(response.status));
|
|
44
|
+
}
|
|
45
|
+
async function readImageJson(response) {
|
|
46
|
+
await assertImageResponseOk(response);
|
|
47
|
+
try {
|
|
48
|
+
const data = JSON.parse(new TextDecoder().decode(await readBytesLimited(response)));
|
|
49
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) throw new Error("Invalid object");
|
|
50
|
+
return data;
|
|
51
|
+
} catch (error) {
|
|
52
|
+
if (error instanceof ImageProviderError) throw error;
|
|
53
|
+
throw new ImageProviderError("Invalid image provider JSON", 502);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function encodeBase64(bytes) {
|
|
57
|
+
let binary = "";
|
|
58
|
+
for (let offset = 0; offset < bytes.length; offset += 8192) binary += String.fromCharCode(...bytes.subarray(offset, offset + 8192));
|
|
59
|
+
return btoa(binary);
|
|
60
|
+
}
|
|
61
|
+
function decodeBase64(value) {
|
|
62
|
+
if (typeof value !== "string" || !value || value.length > Math.ceil(33554432 / 3) * 4 || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value)) throw new ImageProviderError("Invalid image base64", 502);
|
|
63
|
+
return Uint8Array.from(atob(value), (char) => char.charCodeAt(0));
|
|
64
|
+
}
|
|
65
|
+
function imageFromBytes(bytes) {
|
|
66
|
+
const mimeType = bytes[0] === 137 && bytes[1] === 80 && bytes[2] === 78 && bytes[3] === 71 && bytes[4] === 13 && bytes[5] === 10 && bytes[6] === 26 && bytes[7] === 10 ? "image/png" : bytes[0] === 255 && bytes[1] === 216 && bytes[2] === 255 ? "image/jpeg" : new TextDecoder().decode(bytes.subarray(0, 4)) === "RIFF" && new TextDecoder().decode(bytes.subarray(8, 12)) === "WEBP" ? "image/webp" : null;
|
|
67
|
+
if (!mimeType || bytes.length > 33554432) throw new ImageProviderError("Invalid generated image bytes", 502);
|
|
68
|
+
return {
|
|
69
|
+
bytes,
|
|
70
|
+
mimeType
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function authenticatedJobUrl(value, baseUrl, allowBflHost = false) {
|
|
74
|
+
if (typeof value !== "string") throw new ImageProviderError("Missing provider job URL", 502);
|
|
75
|
+
const url = new URL(value), base = new URL(baseUrl);
|
|
76
|
+
if (url.username || url.password || url.hash || url.protocol !== "https:" && url.origin !== base.origin || url.origin !== base.origin && !(allowBflHost && (base.hostname === "api.bfl.ai" || base.hostname.endsWith(".bfl.ai")) && url.protocol === "https:" && url.hostname.endsWith(".bfl.ai") && !url.port)) throw new ImageProviderError("Untrusted provider job URL", 502);
|
|
77
|
+
return url.toString();
|
|
78
|
+
}
|
|
79
|
+
async function waitForImagePoll(signal, delayMs = 1500) {
|
|
80
|
+
signal.throwIfAborted();
|
|
81
|
+
await new Promise((resolve, reject) => {
|
|
82
|
+
const aborted = () => {
|
|
83
|
+
clearTimeout(timer);
|
|
84
|
+
reject(signal.reason);
|
|
85
|
+
};
|
|
86
|
+
const timer = setTimeout(() => {
|
|
87
|
+
signal.removeEventListener("abort", aborted);
|
|
88
|
+
resolve();
|
|
89
|
+
}, delayMs);
|
|
90
|
+
signal.addEventListener("abort", aborted, { once: true });
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
94
|
+
export { MAX_IMAGE_BYTES, MAX_RESPONSE_BYTES, assertImageResponseOk, authenticatedJobUrl, decodeBase64, encodeBase64, imageFromBytes, readBytesLimited, readImageJson, waitForImagePoll };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export type ImageQuality = 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'auto';
|
|
2
|
+
export type ImageFormat = 'png' | 'jpeg' | 'webp';
|
|
3
|
+
export type ImageResolution = '1K' | '2K' | '4K';
|
|
4
|
+
export type ImageBackground = 'transparent' | 'opaque' | 'auto';
|
|
5
|
+
export type ImageProtocol = 'openai' | 'minimax' | 'dashscope' | 'google' | 'fal' | 'seedream' | 'ideogram' | 'bfl' | 'zhipu' | 'tokenhub' | 'stability';
|
|
6
|
+
export interface ImageGeometry {
|
|
7
|
+
sizes?: string[];
|
|
8
|
+
aspectRatios?: string[];
|
|
9
|
+
resolutions?: ImageResolution[];
|
|
10
|
+
pixels?: {
|
|
11
|
+
minPixels: number;
|
|
12
|
+
maxPixels: number;
|
|
13
|
+
maxEdge: number;
|
|
14
|
+
minEdge: number;
|
|
15
|
+
step: number;
|
|
16
|
+
maxRatio: number;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface ImageCapabilities {
|
|
20
|
+
generate?: {
|
|
21
|
+
maxCount?: number;
|
|
22
|
+
supportsSize?: boolean;
|
|
23
|
+
supportsAspectRatio?: boolean;
|
|
24
|
+
supportsResolution?: boolean;
|
|
25
|
+
};
|
|
26
|
+
edit?: {
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
maxInputImages?: number;
|
|
29
|
+
inputFormats?: ImageFormat[];
|
|
30
|
+
maxInputBytes?: number;
|
|
31
|
+
supportsSize?: boolean;
|
|
32
|
+
supportsAspectRatio?: boolean;
|
|
33
|
+
supportsResolution?: boolean;
|
|
34
|
+
geometry?: ImageGeometry;
|
|
35
|
+
};
|
|
36
|
+
geometry?: ImageGeometry;
|
|
37
|
+
output?: {
|
|
38
|
+
qualities?: ImageQuality[];
|
|
39
|
+
formats?: ImageFormat[];
|
|
40
|
+
backgrounds?: ImageBackground[];
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface ImageModel {
|
|
44
|
+
id: string;
|
|
45
|
+
name: string;
|
|
46
|
+
capabilities: ImageCapabilities;
|
|
47
|
+
editPath?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface ImageProviderSpec {
|
|
50
|
+
id: string;
|
|
51
|
+
name: string;
|
|
52
|
+
protocol: ImageProtocol;
|
|
53
|
+
baseUrl: string;
|
|
54
|
+
regions?: Record<'cn' | 'intl', string>;
|
|
55
|
+
documentationUrl: string;
|
|
56
|
+
apiKeyUrl: string;
|
|
57
|
+
timeoutMs: number;
|
|
58
|
+
models: ImageModel[];
|
|
59
|
+
}
|
|
60
|
+
export interface ImageRequest {
|
|
61
|
+
model: string;
|
|
62
|
+
prompt: string;
|
|
63
|
+
count?: number;
|
|
64
|
+
size?: string;
|
|
65
|
+
aspectRatio?: string;
|
|
66
|
+
resolution?: ImageResolution;
|
|
67
|
+
quality?: ImageQuality;
|
|
68
|
+
outputFormat?: ImageFormat;
|
|
69
|
+
background?: ImageBackground;
|
|
70
|
+
openai?: {
|
|
71
|
+
moderation?: 'low' | 'auto';
|
|
72
|
+
outputCompression?: number;
|
|
73
|
+
user?: string;
|
|
74
|
+
};
|
|
75
|
+
inputImages?: Array<{
|
|
76
|
+
blob: Blob;
|
|
77
|
+
fileName: string;
|
|
78
|
+
}>;
|
|
79
|
+
}
|
|
80
|
+
export interface ImageResult {
|
|
81
|
+
images: Array<{
|
|
82
|
+
bytes: Uint8Array;
|
|
83
|
+
mimeType: string;
|
|
84
|
+
}>;
|
|
85
|
+
requestId?: string;
|
|
86
|
+
usage?: unknown;
|
|
87
|
+
}
|
|
88
|
+
export interface ImageExecution {
|
|
89
|
+
providerId: string;
|
|
90
|
+
baseUrl: string;
|
|
91
|
+
apiKey: string;
|
|
92
|
+
request: ImageRequest;
|
|
93
|
+
signal: AbortSignal;
|
|
94
|
+
fetchImpl: typeof fetch;
|
|
95
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//#region packages/image-providers/src/validation.ts
|
|
2
|
+
var ImageProviderError = class extends Error {
|
|
3
|
+
constructor(message, status, retryable = false) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.status = status;
|
|
6
|
+
this.retryable = retryable;
|
|
7
|
+
this.name = "ImageProviderError";
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
function validateImageRequest(request, caps) {
|
|
11
|
+
const fail = (message) => {
|
|
12
|
+
throw new ImageProviderError(message, 400);
|
|
13
|
+
};
|
|
14
|
+
if (request.openai?.outputCompression !== void 0 && (!Number.isInteger(request.openai.outputCompression) || request.openai.outputCompression < 0 || request.openai.outputCompression > 100)) fail("Invalid output compression");
|
|
15
|
+
if (request.openai?.moderation && !["low", "auto"].includes(request.openai.moderation)) fail("Invalid moderation");
|
|
16
|
+
if (!request.prompt?.trim()) fail("Image prompt is required");
|
|
17
|
+
const count = request.count ?? 1;
|
|
18
|
+
if (!Number.isSafeInteger(count) || count < 1 || count > (caps.generate?.maxCount ?? 1)) fail(`Unsupported image count: ${count}`);
|
|
19
|
+
const inputs = request.inputImages ?? [];
|
|
20
|
+
const editing = inputs.length > 0;
|
|
21
|
+
if (editing && (!caps.edit?.enabled || inputs.length > (caps.edit.maxInputImages ?? 0))) fail("Unsupported image editing or reference image count");
|
|
22
|
+
let bytes = 0;
|
|
23
|
+
for (const image of inputs) {
|
|
24
|
+
bytes += image.blob.size;
|
|
25
|
+
if (!(caps.edit?.inputFormats ?? [
|
|
26
|
+
"png",
|
|
27
|
+
"jpeg",
|
|
28
|
+
"webp"
|
|
29
|
+
]).map((format) => `image/${format}`).includes(image.blob.type) || image.blob.size === 0 || image.blob.size > (caps.edit?.maxInputBytes ?? 25 * 1024 * 1024)) fail("Invalid input image format or size");
|
|
30
|
+
}
|
|
31
|
+
if (bytes > 64 * 1024 * 1024) fail("Input images exceed total byte limit");
|
|
32
|
+
const mode = editing ? caps.edit : caps.generate;
|
|
33
|
+
const geometry = editing && caps.edit?.geometry ? caps.edit.geometry : caps.geometry;
|
|
34
|
+
if (request.size && (!mode?.supportsSize || !isSupportedImageSize(request.size, geometry))) fail(`Unsupported image size: ${request.size}`);
|
|
35
|
+
if (request.aspectRatio && (!mode?.supportsAspectRatio || !geometry?.aspectRatios?.includes(request.aspectRatio))) fail(`Unsupported aspect ratio: ${request.aspectRatio}`);
|
|
36
|
+
if (request.resolution && (!mode?.supportsResolution || !geometry?.resolutions?.includes(request.resolution))) fail(`Unsupported resolution: ${request.resolution}`);
|
|
37
|
+
if (request.size && (request.aspectRatio || request.resolution)) fail("size cannot be combined with aspectRatio or resolution");
|
|
38
|
+
if (request.quality && !caps.output?.qualities?.includes(request.quality)) fail(`Unsupported image quality: ${request.quality}`);
|
|
39
|
+
if (request.outputFormat && !caps.output?.formats?.includes(request.outputFormat)) fail(`Unsupported image format: ${request.outputFormat}`);
|
|
40
|
+
if (request.background && !caps.output?.backgrounds?.includes(request.background)) fail(`Unsupported image background: ${request.background}`);
|
|
41
|
+
if (request.background === "transparent" && request.outputFormat === "jpeg") fail("Transparent images require PNG or WebP");
|
|
42
|
+
}
|
|
43
|
+
function isSupportedImageSize(size, geometry) {
|
|
44
|
+
if (geometry?.sizes?.includes(size)) return true;
|
|
45
|
+
const match = /^(\d+)x(\d+)$/.exec(size);
|
|
46
|
+
const bounds = geometry?.pixels;
|
|
47
|
+
if (!match || !bounds) return false;
|
|
48
|
+
const width = Number(match[1]), height = Number(match[2]), pixels = width * height;
|
|
49
|
+
return width >= bounds.minEdge && height >= bounds.minEdge && width <= bounds.maxEdge && height <= bounds.maxEdge && width % bounds.step === 0 && height % bounds.step === 0 && pixels >= bounds.minPixels && pixels <= bounds.maxPixels && Math.max(width / height, height / width) <= bounds.maxRatio;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { ImageProviderError, isSupportedImageSize, validateImageRequest };
|
|
@@ -288,6 +288,7 @@ export declare class AgentManager implements AgentInstanceGateway {
|
|
|
288
288
|
refreshCredentials(): Promise<void>;
|
|
289
289
|
private resolveApiKeyWithCache;
|
|
290
290
|
private composeDynamicProjectContext;
|
|
291
|
+
private readonly personalPromptContext;
|
|
291
292
|
private buildExecutionScopeContext;
|
|
292
293
|
private getInteractionStateVersion;
|
|
293
294
|
private getUserContextAccessVersion;
|