@xopcai/xopc 0.0.465 → 0.0.467
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/dingtalk/src/index.d.ts +8 -0
- package/dist/extensions/dingtalk/src/index.js +159 -0
- package/dist/extensions/dingtalk/xopc.extension.json +131 -0
- package/dist/extensions/discord/src/gateway.d.ts +13 -0
- package/dist/extensions/discord/src/gateway.js +186 -0
- package/dist/extensions/discord/src/index.d.ts +8 -0
- package/dist/extensions/discord/src/index.js +184 -0
- package/dist/extensions/discord/xopc.extension.json +113 -0
- package/dist/extensions/feishu/src/adapters/gateway-setup.js +33 -26
- package/dist/extensions/slack/src/index.d.ts +8 -0
- package/dist/extensions/slack/src/index.js +169 -0
- package/dist/extensions/slack/src/manifest.d.ts +33 -0
- package/dist/extensions/slack/src/manifest.js +32 -0
- package/dist/extensions/slack/xopc.extension.json +124 -0
- package/dist/extensions/telegram/src/adapters/gateway-setup.js +4 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/extensions/wecom/src/index.d.ts +8 -0
- package/dist/extensions/wecom/src/index.js +188 -0
- package/dist/extensions/wecom/xopc.extension.json +131 -0
- package/dist/gateway/static/root/assets/{activity-store-B9heFbtJ.js → activity-store-CdEua6PR.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-nzhB7Xjk.js → agent-avatar-dicebear-l8GQ4I9J.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-display-DBzgoHMD.js → agent-avatar-display-BO1bqKlR.js} +2 -2
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-BJrNV93g.js → agent-defaults-settings-panel-Dj_H2kDD.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-DLbTHALG.js → agent-plugin-dialog-BQA2brAU.js} +1 -1
- package/dist/gateway/static/root/assets/agents-C5C5l13A.js +77 -0
- package/dist/gateway/static/root/assets/{agents-admin-api-CqQbYIiY.js → agents-admin-api-DZ1lLnrj.js} +1 -1
- package/dist/gateway/static/root/assets/{api-BGodd--L.js → api-DDWYNF7I.js} +1 -1
- package/dist/gateway/static/root/assets/{api-8tNOT72p.js → api-DVXcGKP-.js} +1 -1
- package/dist/gateway/static/root/assets/{app-link-DImAfVs5.js → app-link-BkEO3eBe.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-Q7apF7KE.js → app-management-settings-panel-B5-7E03Z.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-ClVZeUmo.js → appearance-settings-E_BcjEDM.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-BsJJwpKj.js → apps-page-BjB_mjXu.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-Bl_M0WJp.js → archive-plugin-MvSiDvxK.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-api-BOnIc_vw.js → automation-api-24NjW7qG.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-result-state-BwDSJs05.js → automation-result-state-C94Q3OEL.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-run-list-CqlIq4BG.js → automation-run-list-BShRirWV.js} +1 -1
- package/dist/gateway/static/root/assets/automation-task-card-Bgq5Plux.js +2 -0
- package/dist/gateway/static/root/assets/{automations-page-Bimqx5Pc.js → automations-page-3WGWLdiW.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-CH9gYqIK.js +9 -0
- package/dist/gateway/static/root/assets/{binary-plugins-DDNKe1Io.js → binary-plugins-MFVtTdvy.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-BQ3amsRP.js → block-editor-DAWXPErA.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-CHf1_RVl.js → browser-settings-page-DI2PYAPC.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-C5oWMC-Z.js → capabilities-CFWTer_v.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-Cj8vl1ZY.js → capabilities-Dyw8xW90.js} +1 -1
- package/dist/gateway/static/root/assets/capabilities-page-C2RB9fzC.js +2 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BjaLTd6i.js +8 -0
- package/dist/gateway/static/root/assets/{capability-navigation-QtHJxxW2.js → capability-navigation-CZbCI5C2.js} +1 -1
- package/dist/gateway/static/root/assets/channels-DiDfjON8.js +1 -0
- package/dist/gateway/static/root/assets/{chat-agents-api-C3JChTsh.js → chat-agents-api-BksS0CNy.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-chart-block-DrtmYOIo.js → chat-chart-block-aZIklMNN.js} +1 -1
- package/dist/gateway/static/root/assets/chat-page-BtMkdtxJ.js +71 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-B0D220I-.js → chat-terminal-dock-B4HoRIzf.js} +1 -1
- package/dist/gateway/static/root/assets/{command-palette-api-CkJ6_Yf3.js → command-palette-api-VhBEUFmw.js} +1 -1
- package/dist/gateway/static/root/assets/{composer-handoff-params-GKGdXjMZ.js → composer-handoff-params-DBpzHuNo.js} +1 -1
- package/dist/gateway/static/root/assets/{composer-model-config-control-DQCOWHzJ.js → composer-model-config-control-BhRAbdPW.js} +1 -1
- package/dist/gateway/static/root/assets/{composer-notifications-D__OU_xx.js → composer-notifications-nT-U6jcc.js} +1 -1
- package/dist/gateway/static/root/assets/{composer-payload-handoff-BBTbJ1bO.js → composer-payload-handoff-xEFHDnLo.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-DGRUCkOt.js → computer-settings-page-DXlH96m6.js} +1 -1
- package/dist/gateway/static/root/assets/{connected-providers-grid-BoDipD2g.js → connected-providers-grid-D8vBFsbY.js} +1 -1
- package/dist/gateway/static/root/assets/{connection-usage-guide-B1VUqibv.js → connection-usage-guide-C8jPm7QO.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-bwQ1PekA.js → connector-service-page-B42yWHxS.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-api-BvYGL65q.js → connectors-api-so2a7xrD.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-BX6Jt6w5.js → connectors-page-yhOZIiUZ.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-ClRDaNBJ.js → date-picker-UEh3JM7r.js} +1 -1
- package/dist/gateway/static/root/assets/{date-time-picker-CA6H47M6.js → date-time-picker-Dci0LfAU.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-Bi8Hgf-x.js → desktop-pet-BAU_GuBe.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CQ6qE8lf.js → desktop-pet-settings-CYE2eTTf.js} +1 -1
- package/dist/gateway/static/root/assets/{dev-view-store-UCqQeWa2.js → dev-view-store-C7v4CIlF.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-gC-XZxt2.js → device-pairing-wizard-7NDkYmiZ.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-Y8snl5Xl.js → directory-picker-path-field-DmRZY8kg.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-authoritative-grants-D2abOXTl.js → extension-authoritative-grants-DIeg1mg8.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-OOlRCInL.js → extension-debug-page-D8TAJgZ_.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-iframe-host-D_WXBf6a.js → extension-iframe-host-CjfRKtQ4.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-marketplace-api-Bmtm6-L1.js → extension-marketplace-api-V1oFBxVi.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-message-router-xqjjSxcp.js → extension-message-router-DZahH1Hd.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-bpQnyNz-.js → extension-page-DMuHBIHa.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-l7SvHEK1.js → extension-provider-lqJ1zIkA.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BvUtZGLT.js → extension-settings-page-D5IfKVff.js} +1 -1
- package/dist/gateway/static/root/assets/{file-preview-surface-B-r2ZnCV.js → file-preview-surface-B7B9qXm9.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-DOwezeL2.js → gateway-config-swr-Dk3FtNv1.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-Br7dErHY.js → gateway-realtime-DMvo4pAc.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-CJf-qaHZ.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-restart-B3Xro3qd.js → gateway-restart-C2h5R1eP.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-DCnP-HPj.js → gateway-settings-DGPaikv5.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-vteSIhYI.js → gateway-startup-retry-yZn7ShiP.js} +1 -1
- package/dist/gateway/static/root/assets/{global-defaults-api-Bpje9rVk.js → global-defaults-api-gsAa0Kj9.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-CNEgNWEQ.js → home-page-BBTtXpDD.js} +3 -3
- package/dist/gateway/static/root/assets/{image-generation-api-BvpAa3Lj.js → image-generation-api-DPn1SBMH.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-Dx5T5pqw.js → imports-page-Cc48Uq20.js} +1 -1
- package/dist/gateway/static/root/assets/index-BJj-uZNl.js +11 -0
- package/dist/gateway/static/root/assets/index-DiWUK4sJ.css +1 -0
- package/dist/gateway/static/root/assets/{install-connector-dialog-Cb4ufypG.js → install-connector-dialog-QkJMw_uW.js} +1 -1
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BEuXrnv0.js → keyboard-shortcuts-settings-BZXqXuI4.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-CPFIbEbv.js → local-app-workbench-page-wekatwet.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-DxHcRSxc.js → local-apps-page-D-bRvlZY.js} +1 -1
- package/dist/gateway/static/root/assets/{local-session-drafts-Cmc-GCVa.js → local-session-drafts-CZ19DRRK.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-tI9VX7dp.js → locale-store-DIBIYLnI.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-BcibwftP.js → logs-page-CukseY3k.js} +1 -1
- package/dist/gateway/static/root/assets/{management-api-C9tFjLcE.js → management-api-EG5duPec.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-DbnAlXoB.js → management-settings-B7RWHrwo.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-CSpQhSka.js → markdown-view-C30KvTaE.js} +1 -1
- package/dist/gateway/static/root/assets/{mcp-conversation-setup-page-DedbjJbF.js → mcp-conversation-setup-page-BZ1PDTYY.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-BYnP_orq.js → media-plugins-CW5UoTx6.js} +1 -1
- package/dist/gateway/static/root/assets/messages-BDBGlBKh.js +3 -0
- package/dist/gateway/static/root/assets/{model-selector-B4oTiJI6.js → model-selector-COGICRIG.js} +1 -1
- package/dist/gateway/static/root/assets/{models-hub-cache-DpEClnsE.js → models-hub-cache-aRYHi2dh.js} +1 -1
- package/dist/gateway/static/root/assets/new-chat-navigation-DXYDldT_.js +1 -0
- package/dist/gateway/static/root/assets/{note-detail-panel-D8asMfBm.js → note-detail-panel-D5BtgBxy.js} +3 -3
- package/dist/gateway/static/root/assets/note-image-lightbox-CxXu_Tkh.js +1 -0
- package/dist/gateway/static/root/assets/{notes-api-pVC1amyp.js → notes-api-BXevQivV.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-CG1_6PLz.js → notes-page-DyM-3O_9.js} +1 -1
- package/dist/gateway/static/root/assets/{oauth-api-BsVPwufr.js → oauth-api-enDU_32p.js} +1 -1
- package/dist/gateway/static/root/assets/{oauth-provider-connect-Bu20kmPq.js → oauth-provider-connect-C2pfvPOI.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-CDsnNXjS.js → page-context-capture-button-BaSooYGv.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-draft-D6tu8c_9.js → page-context-draft-4-3RtO0q.js} +1 -1
- package/dist/gateway/static/root/assets/page-header-store-C2ydtnXa.js +1 -0
- package/dist/gateway/static/root/assets/{personal-avatar-BboNc6e2.js → personal-avatar-BPQpvC34.js} +1 -1
- package/dist/gateway/static/root/assets/personal-page-BB4Sv68K.js +1 -0
- package/dist/gateway/static/root/assets/{personal-profile-settings-Cd4QyseL.js → personal-profile-settings-DwMdjQ6H.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-settings-panel-CtBY_Uk1.js → personal-settings-panel-DiNpP_g3.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-dependencies-card-BgH1LluB.js → phone-dependencies-card-DUT-qRLZ.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-model-connection-DkdKU5Kv.js → phone-model-connection-pvOciDNo.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-model-picker-0g1z4RPL.js → phone-model-picker-CD97E6C5.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-settings-page-DlIUajBY.js → phone-settings-page-BUZ1dh7s.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-workspace-store-DW2sZtkh.js → phone-workspace-store-BwilERgv.js} +1 -1
- package/dist/gateway/static/root/assets/{plugin-details-dialog-9KUkZk_t.js → plugin-details-dialog-C_uOVmJv.js} +1 -1
- package/dist/gateway/static/root/assets/{preference-select-fields-DH5QZhIc.js → preference-select-fields-BSUgcO7-.js} +1 -1
- package/dist/gateway/static/root/assets/{product-automation-feedback-a1thJ0M9.js → product-automation-feedback-BlwtlUY7.js} +1 -1
- package/dist/gateway/static/root/assets/product-delivery-CnvCn9L-.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-DCzQh7tr.js → product-open-page-Dy6D5exJ.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-C5TLcagj.js → product-preview-content-DEUPAilo.js} +1 -1
- package/dist/gateway/static/root/assets/product-preview-modal-C4TV9RUd.js +2 -0
- package/dist/gateway/static/root/assets/project-detail-page-BG2nDt98.js +7 -0
- package/dist/gateway/static/root/assets/{project-understanding-CoPBvlqf.js → project-understanding-lOJ5Tz2V.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-k1v8Fry8.js → projects-page-B3aGdPHy.js} +1 -1
- package/dist/gateway/static/root/assets/{providers-api-BSJZyO8n.js → providers-api-C26HgxZY.js} +1 -1
- package/dist/gateway/static/root/assets/{recording-upload-CExCePtr.js → recording-upload-BJkXktA-.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-CqcJj60w.js → registry-api-pQ0eInzG.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-BLFkNl1y.js → remote-access-hub-CjWrYzjf.js} +1 -1
- package/dist/gateway/static/root/assets/{resource-unavailable-B_BXTQa7.js → resource-unavailable-Y9WRHOnz.js} +1 -1
- package/dist/gateway/static/root/assets/{right-workspace-store-OceFhUjM.js → right-workspace-store-DHHyicqQ.js} +1 -1
- package/dist/gateway/static/root/assets/route-preload-BYqg1BYz.js +2 -0
- package/dist/gateway/static/root/assets/{routine-panel-BsE9o9uu.js → routine-panel-Coh2B0j7.js} +2 -2
- package/dist/gateway/static/root/assets/{runtime-tools-api-aAZChVm4.js → runtime-tools-api-BoJQ3u5o.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-Bn9HTrK5.js → runtime-tools-settings-panel-DB7cfLrX.js} +1 -1
- package/dist/gateway/static/root/assets/schema-form-DXHzZPMr.js +1 -0
- package/dist/gateway/static/root/assets/send-1f1Ntw6E.js +1 -0
- package/dist/gateway/static/root/assets/{service-recommendation-list-BNIVRGDf.js → service-recommendation-list-_rFmwIwY.js} +1 -1
- package/dist/gateway/static/root/assets/{session-api-DdW7Wix2.js → session-api-a6wb0_Gf.js} +1 -1
- package/dist/gateway/static/root/assets/{session-channel-icon-DUJbB-Km.js → session-channel-icon-COynhpeK.js} +1 -1
- package/dist/gateway/static/root/assets/{session-identity-label-DjhlQ6LU.js → session-identity-label-DCIZvqbN.js} +1 -1
- package/dist/gateway/static/root/assets/session-manager-D5g6LOU-.js +25 -0
- package/dist/gateway/static/root/assets/{sessions-page-CfhKeUkZ.js → sessions-page-dEupc-3A.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DjyibJZ1.js +1 -0
- package/dist/gateway/static/root/assets/{settings-advanced-section-BOoJfJuB.js → settings-advanced-section-CnGJr2xp.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-mode-store-BMh_BQ9a.js → settings-mode-store-DWRhupcY.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-M6XwzIyu.js → settings-page-D9A2DdJ_.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-header-Bfu4cuQd.js → settings-page-header-wL2jvs-y.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-BnZa1qHH.js → settings-page-layout-BkUQVmyY.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-interaction-page-CVlrVNrm.js → setup-interaction-page-D238tuw-.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-FFyDODEx.js → setup-status-panel-DXvYjIu3.js} +1 -1
- package/dist/gateway/static/root/assets/{share-link-dialog-Cv-eDEw_.js → share-link-dialog-DFDJyl3N.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-BctH6eFs.js → share-preview-page-CyCv69rh.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-api-cLTEcQLE.js → shares-api-CfFiW03g.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-DcetAN8K.js → shares-settings-B85XIDFv.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-CgEZJoy9.js → skill-api-CWRhFSkA.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-list-api-BWVr2PL5.js → skill-list-api-CmPp2czp.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-BLhHNvaK.js → skill-reload-api-BGsSq3dj.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-DIjcAvA0.js → skills-page-DqD0FPeH.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-C7LAPaN_.js → system-settings-panel-aw9C86I8.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-DgsLOz6h.js +3 -0
- package/dist/gateway/static/root/assets/{task-result-evidence-BsBn3n_l.js → task-result-evidence-C-zIBpzi.js} +1 -1
- package/dist/gateway/static/root/assets/{terminal-panel-store-DJbLuUku.js → terminal-panel-store-CgPqgrm7.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-QGcjV6pN.js → theme-store-DxF7S6I2.js} +1 -1
- package/dist/gateway/static/root/assets/{tracing-settings-page-BKCiPwYL.js → tracing-settings-page-Dvlunx28.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-S7J5Lpzt.js → tunnel-api-CIte6n0U.js} +1 -1
- package/dist/gateway/static/root/assets/{understanding-activity-store-BNVhtJkn.js → understanding-activity-store-C2RHmRo8.js} +1 -1
- package/dist/gateway/static/root/assets/{understanding-refresh-store-CM6bUcaJ.js → understanding-refresh-store-CPeQIXS_.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-D-AqzjIx.js → usage-page-DPUjEj39.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-CqZbhhCc.js → use-autosave-xX2KrbXw.js} +1 -1
- package/dist/gateway/static/root/assets/{use-composer-attachments-BfLhIb2_.js → use-composer-attachments-C9GpCJQR.js} +1 -1
- package/dist/gateway/static/root/assets/{use-file-preview-expanded-DufxDues.js → use-file-preview-expanded-Daf-LmiF.js} +3 -3
- package/dist/gateway/static/root/assets/{use-personal-profile-RnjxZnLa.js → use-personal-profile-BJgaheR4.js} +1 -1
- package/dist/gateway/static/root/assets/{use-realtime-voice-w3aHR2dr.js → use-realtime-voice-RQW5KnIN.js} +1 -1
- package/dist/gateway/static/root/assets/{use-workspace-tree-2Ck-ql5c.js → use-workspace-tree-B6QFV5gR.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-CBcGMhrR.js → user-model-page-hKnsTcMk.js} +1 -1
- package/dist/gateway/static/root/assets/video-generation-D08uZbsu.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-C4rhpgco.js → voice-api-key-field-BeEF7Thh.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-7AHN-ns6.js → voice-config-api-vbBoKnqd.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-input-shortcut-events-BbRrj833.js → voice-input-shortcut-events-CKn6X3qL.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-settings-wamtp0lg.js → voice-settings-BUrk4mwV.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-fVofN7aP.js → work-discovery-overlay-Ddvqu02U.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-DcQG5GWy.js → work-discovery-page-BdBpri6P.js} +1 -1
- package/dist/gateway/static/root/assets/{working-directory-picker-modal-D8Stwszr.js → working-directory-picker-modal-DStgfCzQ.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-api-D3iuTdNK.js → workspace-api-CscTRODe.js} +2 -2
- package/dist/gateway/static/root/assets/workspace-editor-agent-store-CyPjTDSx.js +1 -0
- package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-BXbL5Y1h.js → workspace-file-preview-dialog-JSGIA79T.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-open-location-menu-1gFO_BdL.js → workspace-open-location-menu-CBHFZ2iQ.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-preview-store-adwmi4nx.js → workspace-preview-store-DNLnuHlf.js} +1 -1
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-DhGh4rm7.js → xopc-cloud-account-card-Cm0Saa8B.js} +1 -1
- package/dist/gateway/static/root/index.html +97 -96
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/index.js +4 -0
- package/dist/packages/gateway-contract/src/music-generation.js +6 -0
- package/dist/packages/gateway-contract/src/product-delivery.js +2 -0
- package/dist/packages/gateway-contract/src/video-generation.js +75 -0
- package/dist/src/agent/embedded/runs.d.ts +1 -0
- package/dist/src/agent/embedded/runs.js +5 -2
- package/dist/src/agent/inbound/attachment-pipeline.d.ts +2 -1
- package/dist/src/agent/inbound/attachment-pipeline.js +21 -11
- package/dist/src/agent/inbound/turn-dispatcher.d.ts +2 -0
- package/dist/src/agent/inbound/turn-dispatcher.js +31 -13
- package/dist/src/agent/messaging/outbound-coordinator.js +1 -0
- package/dist/src/agent/prompt/sections/tooling.js +4 -0
- package/dist/src/agent/prompt/service-prompt-builder.js +1 -1
- package/dist/src/agent/tools/factory.js +14 -1
- package/dist/src/agent/tools/music-generation-tool.d.ts +11 -0
- package/dist/src/agent/tools/music-generation-tool.js +70 -0
- package/dist/src/agent/tools/toolExposure.js +2 -0
- package/dist/src/agent/tools/video-draft-tool.d.ts +12 -0
- package/dist/src/agent/tools/video-draft-tool.js +75 -0
- package/dist/src/agent/tools/xopc-use-tool.js +12 -1
- package/dist/src/channels/bundled-channel-extensions.d.ts +1 -0
- package/dist/src/channels/bundled-channel-extensions.js +15 -0
- package/dist/src/channels/enterprise/config-surface.d.ts +1 -0
- package/dist/src/channels/enterprise/config-surface.js +19 -0
- package/dist/src/channels/enterprise/plugin.d.ts +39 -0
- package/dist/src/channels/enterprise/plugin.js +219 -0
- package/dist/src/channels/enterprise/setup.d.ts +34 -0
- package/dist/src/channels/enterprise/setup.js +262 -0
- package/dist/src/channels/enterprise/socket.d.ts +12 -0
- package/dist/src/channels/enterprise/socket.js +107 -0
- package/dist/src/channels/lifecycle-supervisor.js +11 -1
- package/dist/src/channels/plugin-types.d.ts +9 -0
- package/dist/src/channels/plugins/types.adapters.d.ts +12 -0
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/extensions/activation-planner.js +8 -2
- package/dist/src/extensions/bundled-extension-activation.js +9 -0
- package/dist/src/gateway/hono/app.js +6 -2
- package/dist/src/gateway/hono/lib/config-payload.d.ts +1 -1
- package/dist/src/gateway/hono/lib/config-payload.js +2 -1
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +2 -1
- package/dist/src/gateway/hono/routes/channels.js +2 -1
- package/dist/src/gateway/hono/routes/home.js +1 -1
- package/dist/src/gateway/hono/routes/lazy-bundles.js +16 -0
- package/dist/src/gateway/hono/routes/media.js +1 -20
- package/dist/src/gateway/hono/routes/music-generation.d.ts +3 -0
- package/dist/src/gateway/hono/routes/music-generation.js +59 -0
- package/dist/src/gateway/hono/routes/video-generation.d.ts +3 -0
- package/dist/src/gateway/hono/routes/video-generation.js +191 -0
- package/dist/src/gateway/security/gateway-scopes.js +2 -0
- package/dist/src/gateway/service/session-input-coordinator.d.ts +2 -0
- package/dist/src/gateway/service/session-input-coordinator.js +11 -3
- package/dist/src/gateway/service.d.ts +2 -0
- package/dist/src/gateway/service.js +11 -4
- package/dist/src/home-intelligence/host.js +5 -5
- package/dist/src/media-shared/http/byte-range.d.ts +6 -0
- package/dist/src/media-shared/http/byte-range.js +23 -0
- package/dist/src/music-generation/artifact.d.ts +5 -0
- package/dist/src/music-generation/artifact.js +105 -0
- package/dist/src/music-generation/mureka.d.ts +3 -0
- package/dist/src/music-generation/mureka.js +96 -0
- package/dist/src/music-generation/provider.d.ts +31 -0
- package/dist/src/music-generation/provider.js +4 -0
- package/dist/src/music-generation/providers.d.ts +26 -0
- package/dist/src/music-generation/providers.js +56 -0
- package/dist/src/music-generation/repository.d.ts +50 -0
- package/dist/src/music-generation/repository.js +104 -0
- package/dist/src/music-generation/settings.d.ts +7 -0
- package/dist/src/music-generation/settings.js +24 -0
- package/dist/src/music-generation/worker.d.ts +8 -0
- package/dist/src/music-generation/worker.js +115 -0
- package/dist/src/personal-agent/policy.d.ts +1 -1
- package/dist/src/personal-agent/policy.js +3 -1
- package/dist/src/personal-agent/prompts.js +2 -0
- package/dist/src/session/client-history.d.ts +1 -0
- package/dist/src/session/client-history.js +5 -6
- package/dist/src/session/store.js +10 -0
- package/dist/src/storage/sqlite/schema.d.ts +2 -2
- package/dist/src/storage/sqlite/schema.js +7 -7
- package/dist/src/storage/sqlite/schema.sql +62 -0
- package/dist/src/storage/sqlite/session-input-repository.js +5 -2
- package/dist/src/storage/sqlite/transcript-repository.d.ts +1 -0
- package/dist/src/storage/sqlite/transcript-repository.js +20 -1
- package/dist/src/storage/sqlite/upgrades/275_video_generation.sql +28 -0
- package/dist/src/storage/sqlite/upgrades/276_video_provider_selection.sql +11 -0
- package/dist/src/storage/sqlite/upgrades/277_music_generation.sql +30 -0
- package/dist/src/video-generation/artifact.d.ts +5 -0
- package/dist/src/video-generation/artifact.js +91 -0
- package/dist/src/video-generation/drafts.d.ts +17 -0
- package/dist/src/video-generation/drafts.js +89 -0
- package/dist/src/video-generation/provider-types.d.ts +21 -0
- package/dist/src/video-generation/provider-types.js +14 -0
- package/dist/src/video-generation/providers.d.ts +15 -0
- package/dist/src/video-generation/providers.js +72 -0
- package/dist/src/video-generation/repository.d.ts +58 -0
- package/dist/src/video-generation/repository.js +91 -0
- package/dist/src/video-generation/seedance.d.ts +4 -0
- package/dist/src/video-generation/seedance.js +72 -0
- package/dist/src/video-generation/settings.d.ts +5 -0
- package/dist/src/video-generation/settings.js +25 -0
- package/dist/src/video-generation/wan.d.ts +9 -0
- package/dist/src/video-generation/wan.js +59 -0
- package/dist/src/video-generation/worker.d.ts +8 -0
- package/dist/src/video-generation/worker.js +98 -0
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agents-C2xG8f56.js +0 -77
- package/dist/gateway/static/root/assets/arrow-up-right-T72JbQ1Q.js +0 -1
- package/dist/gateway/static/root/assets/automation-task-card-D3WXVKRs.js +0 -2
- package/dist/gateway/static/root/assets/automations-workspace-2SOvmw-f.js +0 -9
- package/dist/gateway/static/root/assets/capabilities-page-U_hQx5ou.js +0 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-k5CcwhXN.js +0 -8
- package/dist/gateway/static/root/assets/channels-BUzno8Pi.js +0 -1
- package/dist/gateway/static/root/assets/chat-page-qnsMsF_s.js +0 -71
- package/dist/gateway/static/root/assets/gateway-realtime-store-OaEqjNTb.js +0 -1
- package/dist/gateway/static/root/assets/index-Cdo4_zon.js +0 -11
- package/dist/gateway/static/root/assets/index-DYTktubl.css +0 -1
- package/dist/gateway/static/root/assets/messages-e5MhDONm.js +0 -3
- package/dist/gateway/static/root/assets/new-chat-navigation-B6NPQ4h4.js +0 -1
- package/dist/gateway/static/root/assets/note-image-lightbox-DcDw5kp4.js +0 -1
- package/dist/gateway/static/root/assets/page-header-store-DeaRqZgV.js +0 -1
- package/dist/gateway/static/root/assets/personal-page-gMRmLCWG.js +0 -1
- package/dist/gateway/static/root/assets/product-delivery-BFfqdKLe.js +0 -1
- package/dist/gateway/static/root/assets/product-preview-modal-D9f-7kcI.js +0 -2
- package/dist/gateway/static/root/assets/project-detail-page-C4Z2HTRZ.js +0 -7
- package/dist/gateway/static/root/assets/route-preload-ClsAFFQc.js +0 -2
- package/dist/gateway/static/root/assets/schema-form-BxBDgLrg.js +0 -1
- package/dist/gateway/static/root/assets/session-manager-XgtApqIh.js +0 -25
- package/dist/gateway/static/root/assets/settings-advanced-gate-BBG8dTIY.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-DmNEMg-l.js +0 -3
- package/dist/gateway/static/root/assets/workspace-editor-agent-store-C-J7vr2o.js +0 -1
|
@@ -184,6 +184,22 @@ const AUTHENTICATED_LAZY_ROUTE_BUNDLES = [
|
|
|
184
184
|
return { register: registerRuntimeToolsRoutes };
|
|
185
185
|
}
|
|
186
186
|
},
|
|
187
|
+
{
|
|
188
|
+
id: "music-generation",
|
|
189
|
+
match: (path) => /^\/api\/music-generation\/settings(?:\/credentials\/[^/]+)?$/.test(path) || /^\/api\/music-generation\/sessions\/[^/]+\/jobs(?:\/[0-9a-f]{64}\/audio)?$/.test(path),
|
|
190
|
+
load: async () => {
|
|
191
|
+
const { registerMusicGenerationRoutes } = await import("./music-generation.js");
|
|
192
|
+
return { register: registerMusicGenerationRoutes };
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
id: "video-generation",
|
|
197
|
+
match: (path) => path === "/api/video-generation/settings" || /^\/api\/video-generation\/sessions\/[^/]+\/jobs(?:\/confirm-draft|\/[^/]+\/video)?$/.test(path),
|
|
198
|
+
load: async () => {
|
|
199
|
+
const { registerVideoGenerationRoutes } = await import("./video-generation.js");
|
|
200
|
+
return { register: registerVideoGenerationRoutes };
|
|
201
|
+
}
|
|
202
|
+
},
|
|
187
203
|
{
|
|
188
204
|
id: "media",
|
|
189
205
|
match: (path) => startsWithAny(path, ["/api/media"]),
|
|
@@ -1,30 +1,11 @@
|
|
|
1
1
|
import { MEDIA_ARTIFACT_MAX_BYTES, mimeTypeFromMediaPath, saveMediaBuffer } from "../../../media/store.js";
|
|
2
2
|
import { readMediaReference } from "../../../media/media-reference.js";
|
|
3
3
|
import { MAX_WEBCHAT_ATTACHMENT_FILE_BYTES } from "../../chat-limits.js";
|
|
4
|
+
import { parseByteRange } from "../../../media-shared/http/byte-range.js";
|
|
4
5
|
import { createGatewayRouteLogger } from "../lib/route-logger.js";
|
|
5
6
|
import { resolveScopedMediaReference } from "../../media-access.js";
|
|
6
7
|
//#region src/gateway/hono/routes/media.ts
|
|
7
8
|
const log = createGatewayRouteLogger("Media");
|
|
8
|
-
function parseByteRange(header, size) {
|
|
9
|
-
if (!header) return null;
|
|
10
|
-
const match = /^bytes=(\d*)-(\d*)$/i.exec(header.trim());
|
|
11
|
-
if (!match || !match[1] && !match[2] || size <= 0) return "invalid";
|
|
12
|
-
if (!match[1]) {
|
|
13
|
-
const suffixLength = Number(match[2]);
|
|
14
|
-
if (!Number.isSafeInteger(suffixLength) || suffixLength <= 0) return "invalid";
|
|
15
|
-
return {
|
|
16
|
-
start: Math.max(0, size - suffixLength),
|
|
17
|
-
end: size - 1
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
const start = Number(match[1]);
|
|
21
|
-
const requestedEnd = match[2] ? Number(match[2]) : size - 1;
|
|
22
|
-
if (!Number.isSafeInteger(start) || !Number.isSafeInteger(requestedEnd) || start < 0 || start >= size || requestedEnd < start) return "invalid";
|
|
23
|
-
return {
|
|
24
|
-
start,
|
|
25
|
-
end: Math.min(requestedEnd, size - 1)
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
9
|
function registerMediaRoutes(authenticated, deps) {
|
|
29
10
|
authenticated.post("/api/media", deps.strictRateLimitMiddleware, async (c) => {
|
|
30
11
|
const file = (await c.req.formData().catch(() => null))?.get("file");
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { musicCredentials, saveMusicDefaults, saveMusicModel } from "../../../music-generation/settings.js";
|
|
2
|
+
import { configuredMusicModel, hasMusicProvider, readMusicModelSettings, resolveMusicModel } from "../../../music-generation/providers.js";
|
|
3
|
+
import { getMusicJob, listMusicJobs } from "../../../music-generation/repository.js";
|
|
4
|
+
import { readMusicArtifact } from "../../../music-generation/artifact.js";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
//#region src/gateway/hono/routes/music-generation.ts
|
|
7
|
+
function registerMusicGenerationRoutes(app, deps) {
|
|
8
|
+
const settings = "/api/music-generation/settings";
|
|
9
|
+
const path = "/api/music-generation/sessions/:conversationId/jobs";
|
|
10
|
+
app.get(settings, async (c) => c.json(await readMusicModelSettings()));
|
|
11
|
+
app.put(settings, deps.strictRateLimitMiddleware, async (c) => {
|
|
12
|
+
const input = z.object({ modelRef: z.string().max(200) }).safeParse(await c.req.json().catch(() => null));
|
|
13
|
+
if (!input.success || !resolveMusicModel(input.data.modelRef)) return c.json({ error: "Unknown music model" }, 400);
|
|
14
|
+
saveMusicModel(input.data.modelRef);
|
|
15
|
+
return c.json(await readMusicModelSettings());
|
|
16
|
+
});
|
|
17
|
+
app.patch(settings, deps.strictRateLimitMiddleware, async (c) => {
|
|
18
|
+
const input = z.object({
|
|
19
|
+
modelRef: z.string().max(200),
|
|
20
|
+
mode: z.enum(["song", "instrumental"])
|
|
21
|
+
}).safeParse(await c.req.json().catch(() => null));
|
|
22
|
+
if (!input.success) return c.json({ error: "Invalid music defaults" }, 400);
|
|
23
|
+
const { modelRef, mode } = input.data;
|
|
24
|
+
if (!resolveMusicModel(modelRef)?.capabilities.modes.includes(mode)) return c.json({ error: "The selected model does not support this music mode" }, 400);
|
|
25
|
+
saveMusicDefaults(modelRef, { mode });
|
|
26
|
+
return c.json(await readMusicModelSettings());
|
|
27
|
+
});
|
|
28
|
+
app.put(`${settings}/credentials/:providerId`, deps.strictRateLimitMiddleware, async (c) => {
|
|
29
|
+
const providerId = c.req.param("providerId");
|
|
30
|
+
const input = z.object({ apiKey: z.string().trim().min(1).max(4096).regex(/^[!-~]+$/) }).safeParse(await c.req.json().catch(() => null));
|
|
31
|
+
if (!hasMusicProvider(providerId) || !input.success) return c.json({ error: "Invalid music provider or API key" }, 400);
|
|
32
|
+
await musicCredentials().saveApiKey(providerId, input.data.apiKey);
|
|
33
|
+
return c.json(await readMusicModelSettings());
|
|
34
|
+
});
|
|
35
|
+
app.delete(`${settings}/credentials/:providerId`, deps.strictRateLimitMiddleware, async (c) => {
|
|
36
|
+
const providerId = c.req.param("providerId");
|
|
37
|
+
if (!hasMusicProvider(providerId)) return c.json({ error: "Unknown music provider" }, 400);
|
|
38
|
+
await musicCredentials().deleteProfile(`${providerId}:default`);
|
|
39
|
+
return c.json(await readMusicModelSettings());
|
|
40
|
+
});
|
|
41
|
+
app.get(path, async (c) => {
|
|
42
|
+
const conversationId = c.req.param("conversationId");
|
|
43
|
+
const session = await deps.service.sessionIndexInstance.getSessionMetadata(conversationId);
|
|
44
|
+
if (!session?.transcriptId || session.sourceChannel !== "webchat" || session.sessionType !== "chat") return c.json({ error: "Conversation not found" }, 404);
|
|
45
|
+
return c.json({
|
|
46
|
+
configured: Boolean(await configuredMusicModel()),
|
|
47
|
+
jobs: listMusicJobs(conversationId, session.transcriptId)
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
app.get(`${path}/:jobId/audio`, async (c) => {
|
|
51
|
+
const conversationId = c.req.param("conversationId");
|
|
52
|
+
const session = await deps.service.sessionIndexInstance.getSessionMetadata(conversationId);
|
|
53
|
+
const job = getMusicJob(conversationId, c.req.param("jobId"));
|
|
54
|
+
if (!session?.transcriptId || job?.transcript_id !== session.transcriptId || job.state !== "completed") return c.json({ error: "Audio not found" }, 404);
|
|
55
|
+
return readMusicArtifact(job.id, c.req.header("Range"), c.req.query("download") === "1");
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
export { registerMusicGenerationRoutes };
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { init_transaction, runSqliteWriteTransaction } from "../../../storage/sqlite/transaction.js";
|
|
2
|
+
import { VIDEO_IMAGE_MAX_BYTES, VIDEO_MODELS, VIDEO_MODEL_REFS, VIDEO_RESOLUTIONS, WAN_VIDEO_MODEL_REF, isVideoDurationSupported } from "../../../../packages/gateway-contract/src/video-generation.js";
|
|
3
|
+
import { init_src } from "../../../../packages/gateway-contract/src/index.js";
|
|
4
|
+
import { readMediaReference } from "../../../media/media-reference.js";
|
|
5
|
+
import { getVideoDefaults, getVideoModel, setVideoDefaults, setVideoModel } from "../../../video-generation/settings.js";
|
|
6
|
+
import { enqueueVideoJob, getVideoJob, listVideoJobs } from "../../../video-generation/repository.js";
|
|
7
|
+
import { getVideoDraft } from "../../../video-generation/drafts.js";
|
|
8
|
+
import { readVideoArtifact } from "../../../video-generation/artifact.js";
|
|
9
|
+
import { getConfiguredVideoProviders, getVideoProvider } from "../../../video-generation/providers.js";
|
|
10
|
+
import { resolveScopedMediaReference } from "../../media-access.js";
|
|
11
|
+
import { createHash } from "node:crypto";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
//#region src/gateway/hono/routes/video-generation.ts
|
|
14
|
+
init_src();
|
|
15
|
+
init_transaction();
|
|
16
|
+
const settingsPath = "/api/video-generation/settings";
|
|
17
|
+
const modelSchema = z.enum(VIDEO_MODEL_REFS);
|
|
18
|
+
const path = "/api/video-generation/sessions/:conversationId/jobs";
|
|
19
|
+
const confirmationSchema = z.object({
|
|
20
|
+
id: z.string().uuid(),
|
|
21
|
+
revision: z.number().int().positive()
|
|
22
|
+
});
|
|
23
|
+
const requestSchema = z.object({
|
|
24
|
+
id: z.string().uuid(),
|
|
25
|
+
modelRef: modelSchema.default(WAN_VIDEO_MODEL_REF),
|
|
26
|
+
transcriptId: z.string().min(1).max(128),
|
|
27
|
+
prompt: z.string().trim().min(1).max(1e3),
|
|
28
|
+
duration: z.coerce.number().int(),
|
|
29
|
+
ratio: z.enum([
|
|
30
|
+
"16:9",
|
|
31
|
+
"9:16",
|
|
32
|
+
"adaptive"
|
|
33
|
+
]),
|
|
34
|
+
resolution: z.enum(VIDEO_RESOLUTIONS),
|
|
35
|
+
imageUri: z.string().startsWith("media://").max(512).nullable()
|
|
36
|
+
});
|
|
37
|
+
function imageMime(bytes) {
|
|
38
|
+
if (bytes.subarray(0, 8).equals(Buffer.from([
|
|
39
|
+
137,
|
|
40
|
+
80,
|
|
41
|
+
78,
|
|
42
|
+
71,
|
|
43
|
+
13,
|
|
44
|
+
10,
|
|
45
|
+
26,
|
|
46
|
+
10
|
|
47
|
+
]))) return "image/png";
|
|
48
|
+
if (bytes.subarray(0, 3).equals(Buffer.from([
|
|
49
|
+
255,
|
|
50
|
+
216,
|
|
51
|
+
255
|
|
52
|
+
]))) return "image/jpeg";
|
|
53
|
+
if (bytes.toString("ascii", 0, 4) === "RIFF" && bytes.toString("ascii", 8, 12) === "WEBP") return "image/webp";
|
|
54
|
+
}
|
|
55
|
+
async function videoSettings() {
|
|
56
|
+
const configured = await getConfiguredVideoProviders();
|
|
57
|
+
const modelRef = getVideoModel();
|
|
58
|
+
return {
|
|
59
|
+
modelRef,
|
|
60
|
+
defaults: getVideoDefaults(modelRef),
|
|
61
|
+
configured
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function registerVideoGenerationRoutes(app, deps) {
|
|
65
|
+
app.get(settingsPath, async (c) => c.json(await videoSettings()));
|
|
66
|
+
app.put(settingsPath, deps.strictRateLimitMiddleware, async (c) => {
|
|
67
|
+
const parsed = z.object({ modelRef: modelSchema }).safeParse(await c.req.json().catch(() => null));
|
|
68
|
+
if (!parsed.success) return c.json({ error: "Unknown video generation model" }, 400);
|
|
69
|
+
setVideoModel(parsed.data.modelRef);
|
|
70
|
+
return c.json(await videoSettings());
|
|
71
|
+
});
|
|
72
|
+
app.patch(settingsPath, deps.strictRateLimitMiddleware, async (c) => {
|
|
73
|
+
const parsed = z.object({
|
|
74
|
+
modelRef: modelSchema,
|
|
75
|
+
duration: z.number().int(),
|
|
76
|
+
resolution: z.enum(VIDEO_RESOLUTIONS)
|
|
77
|
+
}).safeParse(await c.req.json().catch(() => null));
|
|
78
|
+
if (!parsed.success) return c.json({ error: "Invalid video defaults" }, 400);
|
|
79
|
+
const { modelRef, duration, resolution } = parsed.data;
|
|
80
|
+
const model = VIDEO_MODELS[modelRef];
|
|
81
|
+
if (!isVideoDurationSupported(model, duration) || !model.resolutions.includes(resolution)) return c.json({ error: "The selected model does not support these video defaults" }, 400);
|
|
82
|
+
setVideoDefaults(modelRef, {
|
|
83
|
+
duration,
|
|
84
|
+
resolution
|
|
85
|
+
});
|
|
86
|
+
return c.json(await videoSettings());
|
|
87
|
+
});
|
|
88
|
+
app.get(path, async (c) => {
|
|
89
|
+
const conversationId = c.req.param("conversationId");
|
|
90
|
+
const session = await deps.service.sessionIndexInstance.getSessionMetadata(conversationId);
|
|
91
|
+
if (!session?.transcriptId) return c.json({ error: "Conversation not found" }, 404);
|
|
92
|
+
const modelRef = getVideoModel();
|
|
93
|
+
const configured = Boolean(await getVideoProvider(modelRef).resolveKey().catch(() => void 0));
|
|
94
|
+
const jobs = listVideoJobs(conversationId);
|
|
95
|
+
const draft = getVideoDraft(conversationId, session.transcriptId);
|
|
96
|
+
return c.json({
|
|
97
|
+
transcriptId: session.transcriptId,
|
|
98
|
+
modelRef,
|
|
99
|
+
configured,
|
|
100
|
+
defaults: getVideoDefaults(modelRef),
|
|
101
|
+
jobs,
|
|
102
|
+
...draft && !jobs.some((job) => job.id === draft.id) ? { draft } : {}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
app.post(path, deps.strictRateLimitMiddleware, (c) => submit(c, false));
|
|
106
|
+
app.post(`${path}/confirm-draft`, deps.strictRateLimitMiddleware, (c) => submit(c, true));
|
|
107
|
+
async function submit(c, confirming) {
|
|
108
|
+
const conversationId = c.req.param("conversationId");
|
|
109
|
+
const transcriptId = (await deps.service.sessionIndexInstance.getSessionMetadata(conversationId))?.transcriptId;
|
|
110
|
+
if (!transcriptId) return c.json({ error: "Conversation not found" }, 404);
|
|
111
|
+
const confirmation = confirming ? confirmationSchema.safeParse(await c.req.json().catch(() => null)) : void 0;
|
|
112
|
+
if (confirmation && !confirmation.success) return c.json({ error: "Invalid draft confirmation" }, 400);
|
|
113
|
+
const draft = confirmation?.success ? getVideoDraft(conversationId, transcriptId) : void 0;
|
|
114
|
+
if (confirmation?.success && (draft?.id !== confirmation.data.id || draft.revision !== confirmation.data.revision)) return c.json({ error: "The video draft changed. Review the current version before generating." }, 409);
|
|
115
|
+
const form = confirming ? null : await c.req.formData().catch(() => null);
|
|
116
|
+
if (!draft && !form) return c.json({ error: "Invalid video request" }, 400);
|
|
117
|
+
const parsed = requestSchema.safeParse(draft ?? {
|
|
118
|
+
id: form?.get("id"),
|
|
119
|
+
modelRef: form?.get("modelRef") ?? void 0,
|
|
120
|
+
transcriptId: form?.get("transcriptId"),
|
|
121
|
+
prompt: form?.get("prompt"),
|
|
122
|
+
duration: form?.get("duration"),
|
|
123
|
+
ratio: form?.get("ratio"),
|
|
124
|
+
resolution: form?.get("resolution"),
|
|
125
|
+
imageUri: form?.get("imageUri")
|
|
126
|
+
});
|
|
127
|
+
if (!parsed.success) return c.json({ error: "Invalid video settings" }, 400);
|
|
128
|
+
const { imageUri, modelRef, ...request } = parsed.data;
|
|
129
|
+
const upload = form?.get("image") ?? null;
|
|
130
|
+
if (upload !== null && (!(upload instanceof File) || imageUri || !upload.size || upload.size > 5242880)) return c.json({ error: "Provide one PNG, JPEG or WebP image up to 5 MiB" }, 400);
|
|
131
|
+
const model = VIDEO_MODELS[modelRef];
|
|
132
|
+
const hasImage = Boolean(upload || imageUri);
|
|
133
|
+
if (!isVideoDurationSupported(model, request.duration) || !model.resolutions.includes(request.resolution) || hasImage && !model.imageRatios.includes(request.ratio)) return c.json({ error: "The selected model does not support these video settings" }, 400);
|
|
134
|
+
let bytes;
|
|
135
|
+
let imageName = null;
|
|
136
|
+
if (upload instanceof File) {
|
|
137
|
+
bytes = Buffer.from(await upload.arrayBuffer());
|
|
138
|
+
imageName = upload.name.slice(0, 160);
|
|
139
|
+
} else if (imageUri) try {
|
|
140
|
+
const media = await resolveScopedMediaReference(deps.service, imageUri, { conversationId });
|
|
141
|
+
bytes = (await readMediaReference(media.uri, VIDEO_IMAGE_MAX_BYTES)).buffer;
|
|
142
|
+
imageName = media.id;
|
|
143
|
+
} catch {
|
|
144
|
+
return c.json({ error: "Reference image is unavailable in this conversation or exceeds 5 MiB" }, 400);
|
|
145
|
+
}
|
|
146
|
+
const mime = bytes && imageMime(bytes);
|
|
147
|
+
if (bytes && !mime) return c.json({ error: "Reference image must be PNG, JPEG or WebP" }, 400);
|
|
148
|
+
if (bytes && model.provider === "volcengine-ark") {
|
|
149
|
+
const { default: sharp } = await import("sharp");
|
|
150
|
+
const size = await sharp(bytes, { limitInputPixels: 36e6 }).metadata().catch(() => void 0);
|
|
151
|
+
const width = size?.autoOrient.width ?? 0;
|
|
152
|
+
const height = size?.autoOrient.height ?? 0;
|
|
153
|
+
if (width < 300 || height < 300 || width > 6e3 || height > 6e3 || width / height < .4 || width / height > 2.5) return c.json({ error: "Seedance requires a readable image with sides of 300–6000 px and an aspect ratio of 0.4–2.5" }, 400);
|
|
154
|
+
}
|
|
155
|
+
const provider = getVideoProvider(modelRef);
|
|
156
|
+
if (!await provider.resolveKey().catch(() => void 0)) return c.json({ error: `Configure a ${provider.name} API key on the Gateway` }, 503);
|
|
157
|
+
const hash = createHash("sha256").update(JSON.stringify({
|
|
158
|
+
...request,
|
|
159
|
+
imageName
|
|
160
|
+
}));
|
|
161
|
+
if (bytes) hash.update(bytes);
|
|
162
|
+
const requestHash = hash.digest("hex");
|
|
163
|
+
const result = runSqliteWriteTransaction(() => {
|
|
164
|
+
if (draft) {
|
|
165
|
+
const latest = getVideoDraft(conversationId, transcriptId);
|
|
166
|
+
if (latest?.id !== draft.id || latest.revision !== draft.revision) return { error: "draft_changed" };
|
|
167
|
+
}
|
|
168
|
+
return enqueueVideoJob(conversationId, {
|
|
169
|
+
...request,
|
|
170
|
+
modelRef,
|
|
171
|
+
imageName
|
|
172
|
+
}, requestHash, bytes && mime ? {
|
|
173
|
+
bytes,
|
|
174
|
+
mime
|
|
175
|
+
} : void 0);
|
|
176
|
+
});
|
|
177
|
+
if (result.error === "draft_changed") return c.json({ error: "The video draft changed. Review the current version before generating." }, 409);
|
|
178
|
+
if (result.error === "budget_exhausted") return c.json({ error: "The Gateway video generation budget for today has been reached." }, 429);
|
|
179
|
+
if (result.error === "queue_full") return c.json({ error: "The video queue is full. Try again after a task completes." }, 429);
|
|
180
|
+
if (result.error === "model_changed") return c.json({ error: "The video model changed. Review the updated model before submitting." }, 409);
|
|
181
|
+
if (result.error) return c.json({ error: "The conversation or video request changed. Review the current request and try again." }, 409);
|
|
182
|
+
return c.json(result.job, 202);
|
|
183
|
+
}
|
|
184
|
+
app.get(`${path}/:jobId/video`, async (c) => {
|
|
185
|
+
const job = getVideoJob(c.req.param("conversationId"), c.req.param("jobId"));
|
|
186
|
+
if (job?.state !== "completed") return c.json({ error: "Video not found" }, 404);
|
|
187
|
+
return readVideoArtifact(job.id, c.req.header("Range"), c.req.query("download") === "1");
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
//#endregion
|
|
191
|
+
export { registerVideoGenerationRoutes };
|
|
@@ -44,6 +44,8 @@ function requiredGatewayScope(method, path) {
|
|
|
44
44
|
if (path === "/api/observability" || path.startsWith("/api/observability/")) return "gateway.admin";
|
|
45
45
|
if (path.startsWith("/api/usage")) return "gateway.admin";
|
|
46
46
|
if (path.startsWith("/api/agents") || path.startsWith("/api/models")) return methodScope(method, "agents.read", "gateway.admin");
|
|
47
|
+
if (path === "/api/video-generation/settings") return "gateway.admin";
|
|
48
|
+
if (path.startsWith("/api/video-generation/")) return methodScope(method, "sessions.read", "sessions.write");
|
|
47
49
|
if (path.startsWith("/api/sessions") || path.startsWith("/api/side-chats")) return methodScope(method, "sessions.read", "sessions.write");
|
|
48
50
|
if (path.startsWith("/api/tasks")) return methodScope(method, "tasks.read", "tasks.write");
|
|
49
51
|
if (path === "/api/task-runs" || path.startsWith("/api/task-runs/")) return methodScope(method, "tasks.read", "tasks.write");
|
|
@@ -65,6 +65,8 @@ export declare class SessionInputCoordinator {
|
|
|
65
65
|
attachments?: UserTurnAttachment[];
|
|
66
66
|
sourceContexts?: AgentSourceContext[];
|
|
67
67
|
voiceAgentInstruction?: boolean;
|
|
68
|
+
clientMessageId?: string;
|
|
69
|
+
onHandled?: () => void;
|
|
68
70
|
}) => Promise<boolean>;
|
|
69
71
|
emit: (type: string, payload: unknown) => void;
|
|
70
72
|
});
|
|
@@ -108,7 +108,6 @@ var SessionInputCoordinator = class {
|
|
|
108
108
|
const row = command.inputId ? getSessionInputById(conversationId, command.inputId) : void 0;
|
|
109
109
|
if (!replay && command.action === "steer" && (!row || !canSteerContexts(this.snapshot(conversationId), row.origin, row.contextSnapshots))) throw new SessionInputControlConflict("This input cannot steer the active reply");
|
|
110
110
|
const accepted = acceptSessionInputControl(conversationId, command);
|
|
111
|
-
this.publish(conversationId);
|
|
112
111
|
if (command.action === "steer") {
|
|
113
112
|
if (!accepted.replay && row) try {
|
|
114
113
|
if (!await this.steerInput(row, accepted.runId)) setSessionInputStatus(row.id, "interrupted", {
|
|
@@ -125,6 +124,7 @@ var SessionInputCoordinator = class {
|
|
|
125
124
|
}
|
|
126
125
|
return this.publish(conversationId);
|
|
127
126
|
}
|
|
127
|
+
this.publish(conversationId);
|
|
128
128
|
if (accepted.runId) await this.deps.interrupt?.(conversationId, accepted.runId, "user_stop");
|
|
129
129
|
if ((command.action === "resume" || command.action === "send") && !accepted.replay) this.drain(conversationId);
|
|
130
130
|
return this.publish(conversationId);
|
|
@@ -507,11 +507,19 @@ var SessionInputCoordinator = class {
|
|
|
507
507
|
steerInput(row, runId) {
|
|
508
508
|
const text = steeringText(row.content, row.contextSnapshots);
|
|
509
509
|
const voiceAgentInstruction = isNaturalVoiceDelegation(row);
|
|
510
|
-
|
|
510
|
+
const trackDelivery = row.origin.type === "endpoint";
|
|
511
|
+
if (!trackDelivery && !voiceAgentInstruction && !row.attachments?.length && !row.contextSnapshots?.length) return this.deps.steer(row.conversationId, text, runId);
|
|
511
512
|
return this.deps.steer(row.conversationId, text, runId, {
|
|
512
513
|
attachments: row.attachments,
|
|
513
514
|
sourceContexts: row.contextSnapshots,
|
|
514
|
-
...voiceAgentInstruction ? { voiceAgentInstruction: true } : {}
|
|
515
|
+
...voiceAgentInstruction ? { voiceAgentInstruction: true } : {},
|
|
516
|
+
...trackDelivery ? {
|
|
517
|
+
clientMessageId: row.clientMessageId,
|
|
518
|
+
onHandled: () => {
|
|
519
|
+
const current = getSessionInputById(row.conversationId, row.id);
|
|
520
|
+
if (current?.status === "injecting" && current.targetRunId === runId) setSessionInputStatus(row.id, "completed");
|
|
521
|
+
}
|
|
522
|
+
} : {}
|
|
515
523
|
});
|
|
516
524
|
}
|
|
517
525
|
async drain(conversationId) {
|
|
@@ -222,6 +222,8 @@ export declare class GatewayService {
|
|
|
222
222
|
private loadDeferredExtensions;
|
|
223
223
|
private schedulePostReadySidecars;
|
|
224
224
|
private runPostReadySidecars;
|
|
225
|
+
private readonly musicGenerationWorker;
|
|
226
|
+
private readonly videoGenerationWorker;
|
|
225
227
|
start(): Promise<void>;
|
|
226
228
|
private startRuntime;
|
|
227
229
|
/** Called when the HTTP listener is bound (before deferred channel work). */
|
|
@@ -107,10 +107,6 @@ import { DiscussionSealer } from "../discussions/sealer.js";
|
|
|
107
107
|
import "../discussions/index.js";
|
|
108
108
|
import { EndpointToolRuntime } from "../endpoint-tools/runtime.js";
|
|
109
109
|
import "../endpoint-tools/index.js";
|
|
110
|
-
import { HomeCapabilityPreflightService } from "../home-intelligence/capability-preflight.js";
|
|
111
|
-
import { HomeAdviceGenerator } from "../home-intelligence/generator.js";
|
|
112
|
-
import { HomeIntelligenceHost } from "../home-intelligence/host.js";
|
|
113
|
-
import { HomeSnapshotBuilder } from "../home-intelligence/snapshot.js";
|
|
114
110
|
import { assertGatewayAuthConfigured, extractToken, resolveGatewayAuth, validateToken } from "./auth.js";
|
|
115
111
|
import { prepareAutomationAgentSession } from "./automation-agent-session.js";
|
|
116
112
|
import { deliverAutomationCompletion } from "./automation-completion-delivery.js";
|
|
@@ -150,6 +146,8 @@ import { NotificationService } from "../notifications/service.js";
|
|
|
150
146
|
import "../local-apps/index.js";
|
|
151
147
|
import { TaskAllocationDispatcher } from "../tasks/task-allocation-service.js";
|
|
152
148
|
import { TaskResultDeliveryService } from "../tasks/task-result-delivery-service.js";
|
|
149
|
+
import { MusicGenerationWorker } from "../music-generation/worker.js";
|
|
150
|
+
import { VideoGenerationWorker } from "../video-generation/worker.js";
|
|
153
151
|
import { scheduleGatewayUpdateCheck } from "../infra/update-startup.js";
|
|
154
152
|
import { resolveChannelConnectDeferSet } from "./resolve-channel-connect-defer.js";
|
|
155
153
|
import { restartGatewayProcessWithFreshPid } from "./respawn.js";
|
|
@@ -174,6 +172,10 @@ import { TaskMainUpdateDecisionService } from "../tasks/task-main-update-decisio
|
|
|
174
172
|
import { selectTaskMainUpdateAttempt, submitAndConfirmTaskMainUpdate } from "../tasks/task-main-update-input.js";
|
|
175
173
|
import { checkAppContextAccess, prepareAppContext } from "./service/app-context-access.js";
|
|
176
174
|
import { applyAutomaticVoiceLanguage, inferProductLanguageFromEnvironment, initializeVoiceDefaults } from "../voice/language-profile.js";
|
|
175
|
+
import { HomeAdviceGenerator } from "../home-intelligence/generator.js";
|
|
176
|
+
import { HomeIntelligenceHost } from "../home-intelligence/host.js";
|
|
177
|
+
import { HomeSnapshotBuilder } from "../home-intelligence/snapshot.js";
|
|
178
|
+
import { HomeCapabilityPreflightService } from "../home-intelligence/capability-preflight.js";
|
|
177
179
|
import crypto from "node:crypto";
|
|
178
180
|
//#region src/gateway/service.ts
|
|
179
181
|
init_session_repository();
|
|
@@ -1346,6 +1348,8 @@ var GatewayService = class {
|
|
|
1346
1348
|
}, `Deferred extension load failed: ${em}`);
|
|
1347
1349
|
}
|
|
1348
1350
|
}
|
|
1351
|
+
musicGenerationWorker = new MusicGenerationWorker();
|
|
1352
|
+
videoGenerationWorker = new VideoGenerationWorker();
|
|
1349
1353
|
async start() {
|
|
1350
1354
|
try {
|
|
1351
1355
|
await this.startRuntime();
|
|
@@ -1587,6 +1591,8 @@ var GatewayService = class {
|
|
|
1587
1591
|
await this.notesService.initialize();
|
|
1588
1592
|
this.discussionLiveWorker.start();
|
|
1589
1593
|
this.discussionSealer.start();
|
|
1594
|
+
this.videoGenerationWorker.start();
|
|
1595
|
+
this.musicGenerationWorker.start();
|
|
1590
1596
|
this.discussionWorker.start();
|
|
1591
1597
|
this.connectorSupervisor = startConnectorSupervisor({
|
|
1592
1598
|
getConfig: () => this.config,
|
|
@@ -1752,6 +1758,7 @@ var GatewayService = class {
|
|
|
1752
1758
|
this.homeIntelligenceHost = null;
|
|
1753
1759
|
this.realtime.close();
|
|
1754
1760
|
this.voiceRealtime.close();
|
|
1761
|
+
await Promise.all([this.videoGenerationWorker.stop(), this.musicGenerationWorker.stop()]);
|
|
1755
1762
|
await this.discussionWorker.stop();
|
|
1756
1763
|
await this.discussionSealer.stop();
|
|
1757
1764
|
await this.discussionLiveWorker.stop();
|
|
@@ -7,14 +7,14 @@ import { TaskRepository, init_task_repository } from "../tasks/task-repository.j
|
|
|
7
7
|
import { appendTranscriptEntry } from "../storage/sqlite/transcript-repository.js";
|
|
8
8
|
import { createConversation, init_conversation_repository } from "../storage/sqlite/conversation-repository.js";
|
|
9
9
|
import { TaskApplicationService } from "../tasks/task-application-service.js";
|
|
10
|
-
import { homePatternKey } from "./strategy.js";
|
|
11
|
-
import { HomeIntelligenceRepository } from "./repository.js";
|
|
12
|
-
import { HomeOpportunityApplicationService } from "./application-service.js";
|
|
13
|
-
import { HomeAdvicePolicy } from "./policy.js";
|
|
14
10
|
import { HomeObservation, ObservationConflictError } from "./observation.js";
|
|
15
11
|
import { HomeFollowUps } from "./follow-ups.js";
|
|
16
|
-
import { HomeAdviceBudgetExceededError, isHomeProseLocalized } from "./generator.js";
|
|
17
12
|
import { observationStarters } from "./observation-starters.js";
|
|
13
|
+
import { HomeAdviceBudgetExceededError, isHomeProseLocalized } from "./generator.js";
|
|
14
|
+
import { homePatternKey } from "./strategy.js";
|
|
15
|
+
import { HomeAdvicePolicy } from "./policy.js";
|
|
16
|
+
import { HomeIntelligenceRepository } from "./repository.js";
|
|
17
|
+
import { HomeOpportunityApplicationService } from "./application-service.js";
|
|
18
18
|
import { buildHomeOpportunityNotification } from "./notification.js";
|
|
19
19
|
import { ObservationRoutines } from "./routines.js";
|
|
20
20
|
import { createHash } from "node:crypto";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/media-shared/http/byte-range.ts
|
|
2
|
+
function parseByteRange(header, size) {
|
|
3
|
+
if (!header) return null;
|
|
4
|
+
const match = /^bytes=(\d*)-(\d*)$/i.exec(header.trim());
|
|
5
|
+
if (!match || !match[1] && !match[2] || size <= 0) return "invalid";
|
|
6
|
+
if (!match[1]) {
|
|
7
|
+
const suffixLength = Number(match[2]);
|
|
8
|
+
if (!Number.isSafeInteger(suffixLength) || suffixLength <= 0) return "invalid";
|
|
9
|
+
return {
|
|
10
|
+
start: Math.max(0, size - suffixLength),
|
|
11
|
+
end: size - 1
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
const start = Number(match[1]);
|
|
15
|
+
const requestedEnd = match[2] ? Number(match[2]) : size - 1;
|
|
16
|
+
if (!Number.isSafeInteger(start) || !Number.isSafeInteger(requestedEnd) || start < 0 || start >= size || requestedEnd < start) return "invalid";
|
|
17
|
+
return {
|
|
18
|
+
start,
|
|
19
|
+
end: Math.min(requestedEnd, size - 1)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { parseByteRange };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { MusicProvider } from './provider.js';
|
|
2
|
+
export declare function musicArtifactExists(id: string): Promise<boolean>;
|
|
3
|
+
export declare function deleteMusicArtifact(id: string): Promise<void>;
|
|
4
|
+
export declare function saveMusicArtifact(id: string, provider: MusicProvider, source: string, canPublish: () => boolean): Promise<void>;
|
|
5
|
+
export declare function readMusicArtifact(id: string, rangeHeader?: string, download?: boolean): Promise<Response>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { resolveMediaBufferPath } from "../media/store.js";
|
|
2
|
+
import { assertSafeUrl } from "../media-shared/http/ssrf-guard.js";
|
|
3
|
+
import { parseByteRange } from "../media-shared/http/byte-range.js";
|
|
4
|
+
import { dirname } from "node:path";
|
|
5
|
+
import { createReadStream, createWriteStream } from "node:fs";
|
|
6
|
+
import { randomUUID } from "node:crypto";
|
|
7
|
+
import { link, mkdir, open, rm, stat } from "node:fs/promises";
|
|
8
|
+
import { pipeline } from "node:stream/promises";
|
|
9
|
+
import { Readable, Transform } from "node:stream";
|
|
10
|
+
//#region src/music-generation/artifact.ts
|
|
11
|
+
const MAX_AUDIO_BYTES = 24 * 1024 * 1024;
|
|
12
|
+
function artifactPath(id) {
|
|
13
|
+
return resolveMediaBufferPath(`music-${id}.mp3`, "outbound");
|
|
14
|
+
}
|
|
15
|
+
async function musicArtifactExists(id) {
|
|
16
|
+
const file = await stat(artifactPath(id)).catch(() => null);
|
|
17
|
+
return Boolean(file?.isFile() && file.size > 0 && file.size <= MAX_AUDIO_BYTES);
|
|
18
|
+
}
|
|
19
|
+
async function deleteMusicArtifact(id) {
|
|
20
|
+
await rm(artifactPath(id), { force: true });
|
|
21
|
+
}
|
|
22
|
+
async function saveMusicArtifact(id, provider, source, canPublish) {
|
|
23
|
+
const url = new URL(source);
|
|
24
|
+
if (url.protocol !== "https:" || url.username || url.password || url.port || !provider.allowsAudioHost(url.hostname)) throw new Error("Music provider returned an untrusted audio URL.");
|
|
25
|
+
await assertSafeUrl(url);
|
|
26
|
+
const path = artifactPath(id);
|
|
27
|
+
const temporary = `${path}.${randomUUID()}.part`;
|
|
28
|
+
await mkdir(dirname(path), {
|
|
29
|
+
recursive: true,
|
|
30
|
+
mode: 448
|
|
31
|
+
});
|
|
32
|
+
const response = await fetch(url, {
|
|
33
|
+
signal: AbortSignal.timeout(45e3),
|
|
34
|
+
redirect: "error"
|
|
35
|
+
});
|
|
36
|
+
if (!response.ok || !response.body || Number(response.headers.get("content-length")) > MAX_AUDIO_BYTES) {
|
|
37
|
+
await response.body?.cancel().catch(() => void 0);
|
|
38
|
+
throw new Error("Music download failed or exceeded the size limit.");
|
|
39
|
+
}
|
|
40
|
+
let size = 0;
|
|
41
|
+
const limit = new Transform({ transform(chunk, _encoding, callback) {
|
|
42
|
+
size += chunk.length;
|
|
43
|
+
if (size > MAX_AUDIO_BYTES) return callback(/* @__PURE__ */ new Error("Generated music exceeds the size limit."));
|
|
44
|
+
callback(null, chunk);
|
|
45
|
+
} });
|
|
46
|
+
try {
|
|
47
|
+
await pipeline(Readable.fromWeb(response.body), limit, createWriteStream(temporary, {
|
|
48
|
+
flags: "wx",
|
|
49
|
+
mode: 384
|
|
50
|
+
}));
|
|
51
|
+
const file = await open(temporary, "r");
|
|
52
|
+
try {
|
|
53
|
+
const header = Buffer.alloc(10);
|
|
54
|
+
const { bytesRead } = await file.read(header);
|
|
55
|
+
if (bytesRead !== header.length) throw new Error("Music provider returned incomplete MP3 audio.");
|
|
56
|
+
let frameOffset = 0;
|
|
57
|
+
if (header.subarray(0, 3).toString("ascii") === "ID3") {
|
|
58
|
+
const tagSize = header.subarray(6, 10);
|
|
59
|
+
if (tagSize.some((byte) => byte > 127)) throw new Error("Music provider returned an invalid ID3 tag.");
|
|
60
|
+
const footerSize = header[3] === 4 && (header[5] & 16) !== 0 ? 10 : 0;
|
|
61
|
+
frameOffset = tagSize.reduce((length, byte) => length << 7 | byte, 0) + 10 + footerSize;
|
|
62
|
+
}
|
|
63
|
+
const frame = Buffer.alloc(4);
|
|
64
|
+
if ((await file.read(frame, 0, frame.length, frameOffset)).bytesRead !== frame.length || size <= frameOffset + frame.length || frame[0] !== 255 || (frame[1] & 230) !== 226 || (frame[1] & 24) === 8 || (frame[2] & 240) === 240 || (frame[2] & 12) === 12) throw new Error("Music provider returned invalid MP3 audio.");
|
|
65
|
+
await file.sync();
|
|
66
|
+
} finally {
|
|
67
|
+
await file.close();
|
|
68
|
+
}
|
|
69
|
+
if (!canPublish()) return;
|
|
70
|
+
await link(temporary, path).catch((error) => {
|
|
71
|
+
if (error.code !== "EEXIST") throw error;
|
|
72
|
+
});
|
|
73
|
+
} finally {
|
|
74
|
+
await rm(temporary, { force: true });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async function readMusicArtifact(id, rangeHeader, download = false) {
|
|
78
|
+
const path = artifactPath(id);
|
|
79
|
+
const file = await stat(path).catch(() => null);
|
|
80
|
+
if (!file?.isFile() || !file.size || file.size > MAX_AUDIO_BYTES) return new Response(null, { status: 404 });
|
|
81
|
+
const headers = new Headers({
|
|
82
|
+
"Accept-Ranges": "bytes",
|
|
83
|
+
"Content-Type": "audio/mpeg",
|
|
84
|
+
"Cache-Control": "private, no-store",
|
|
85
|
+
"X-Content-Type-Options": "nosniff"
|
|
86
|
+
});
|
|
87
|
+
if (download) headers.set("Content-Disposition", "attachment; filename=\"music.mp3\"");
|
|
88
|
+
const range = parseByteRange(rangeHeader, file.size);
|
|
89
|
+
if (range === "invalid") {
|
|
90
|
+
headers.set("Content-Range", `bytes */${file.size}`);
|
|
91
|
+
return new Response(null, {
|
|
92
|
+
status: 416,
|
|
93
|
+
headers
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
if (range) headers.set("Content-Range", `bytes ${range.start}-${range.end}/${file.size}`);
|
|
97
|
+
headers.set("Content-Length", String(range ? range.end - range.start + 1 : file.size));
|
|
98
|
+
const stream = createReadStream(path, range ?? void 0);
|
|
99
|
+
return new Response(Readable.toWeb(stream), {
|
|
100
|
+
status: range ? 206 : 200,
|
|
101
|
+
headers
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
export { deleteMusicArtifact, musicArtifactExists, readMusicArtifact, saveMusicArtifact };
|