@open-wa/api 5.0.0-alpha.8 ā 5.1.0
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/LICENSE.md +2 -2
- package/README.md +1 -1
- package/dashboard-neo/dist/assets/AgentScalarDrawer.vue-Bq0juj-E.js +25 -0
- package/dashboard-neo/dist/assets/basic-shape-diamond.svg-Bu9cSItR.js +1 -0
- package/dashboard-neo/dist/assets/basic-shape-hexagon.svg-BJoiyAUL.js +1 -0
- package/dashboard-neo/dist/assets/basic-shape-primary-circle-ellipse-round.svg-Daoaje72.js +1 -0
- package/dashboard-neo/dist/assets/basic-shape-primary-square-rectangle.svg-YLGG3FKF.js +1 -0
- package/dashboard-neo/dist/assets/basic-shape-shield.svg-DqNRriX3.js +1 -0
- package/dashboard-neo/dist/assets/browser-J5x-7eFP.js +40 -0
- package/dashboard-neo/dist/assets/browser-plEqmk2G.js +113 -0
- package/dashboard-neo/dist/assets/computer-device-desktop-monitor.svg-WQ9f9Yyd.js +1 -0
- package/dashboard-neo/dist/assets/computer-device-desktop.svg-C1QoHpfb.js +1 -0
- package/dashboard-neo/dist/assets/computer-device-laptop.svg-DftDi_i4.js +1 -0
- package/dashboard-neo/dist/assets/computer-device-mobile-phone-android-samsung-back.svg-CKgWwk-M.js +1 -0
- package/dashboard-neo/dist/assets/computer-device-mobile-phone-android-samsung.svg-ZImmEqwi.js +1 -0
- package/dashboard-neo/dist/assets/computer-device-mobile-phone-iphone-x-back.svg-xBrw0QqX.js +1 -0
- package/dashboard-neo/dist/assets/computer-device-mobile-phone-iphone-x.svg-DDxQeDBi.js +1 -0
- package/dashboard-neo/dist/assets/computer-device-mobile-tablet-touch.svg-DYfniPU8.js +1 -0
- package/dashboard-neo/dist/assets/computer-device-mobile-tablet.svg-Dq0gutQK.js +1 -0
- package/dashboard-neo/dist/assets/computer-device-network-ethernet-cat6.svg-CwHOvloq.js +1 -0
- package/dashboard-neo/dist/assets/computer-device-network-lan-www.svg-C8Bh80nT.js +1 -0
- package/dashboard-neo/dist/assets/computer-device-network-wifi-connection.svg-5hFcG1t3.js +1 -0
- package/dashboard-neo/dist/assets/computer-device-network-wifi-router.svg-BgDGwjhn.js +1 -0
- package/dashboard-neo/dist/assets/ecology-science-erlenmeyer-flask.svg-Bu4pbH8x.js +1 -0
- package/dashboard-neo/dist/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/dashboard-neo/dist/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/dashboard-neo/dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/dashboard-neo/dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/dashboard-neo/dist/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/dashboard-neo/dist/assets/image-flash-lightning.svg-D5m0nHLE.js +1 -0
- package/dashboard-neo/dist/assets/image-picture-flower.svg-DCs_cHUn.js +1 -0
- package/dashboard-neo/dist/assets/index-DM5k7cbF.css +1 -0
- package/dashboard-neo/dist/assets/index-DO9OELB4.js +2149 -0
- package/dashboard-neo/dist/assets/interface-alert-exclamation-diamond.svg-2G3xLwqx.js +1 -0
- package/dashboard-neo/dist/assets/interface-alert-exclamation-triangle-warning.svg-CbZWnWWp.js +1 -0
- package/dashboard-neo/dist/assets/interface-alert-information-circle.svg-D0Rq0ioQ.js +1 -0
- package/dashboard-neo/dist/assets/interface-award-crown.svg-BPfuHoAi.js +1 -0
- package/dashboard-neo/dist/assets/interface-bookmark-tag.svg-CUSjRJiw.js +1 -0
- package/dashboard-neo/dist/assets/interface-bookmark.svg-CUSjRJiw.js +1 -0
- package/dashboard-neo/dist/assets/interface-calendar-date-one.svg-BAvbb3-o.js +1 -0
- package/dashboard-neo/dist/assets/interface-content-book-open-pages.svg-DRedEoaB.js +1 -0
- package/dashboard-neo/dist/assets/interface-content-book-page.svg-bnWYwJAk.js +1 -0
- package/dashboard-neo/dist/assets/interface-content-file.svg-BqNPbXHO.js +1 -0
- package/dashboard-neo/dist/assets/interface-copy-clipboard.svg-Dyphh54o.js +1 -0
- package/dashboard-neo/dist/assets/interface-edit-attachment.svg-BuRbX7t8.js +1 -0
- package/dashboard-neo/dist/assets/interface-edit-binocular.svg-CYYevEGv.js +1 -0
- package/dashboard-neo/dist/assets/interface-edit-magic-wand.svg-DR2BzOMe.js +1 -0
- package/dashboard-neo/dist/assets/interface-edit-tool-paint-roller.svg-BNgZ4_-f.js +1 -0
- package/dashboard-neo/dist/assets/interface-edit-tool-pencil.svg-CTbomxh-.js +1 -0
- package/dashboard-neo/dist/assets/interface-favorite-award.svg-Bw67_iOy.js +1 -0
- package/dashboard-neo/dist/assets/interface-favorite-flag.svg-DaNMlOpZ.js +1 -0
- package/dashboard-neo/dist/assets/interface-favorite-heart.svg-r70vyk7c.js +1 -0
- package/dashboard-neo/dist/assets/interface-favorite-star.svg-DkU3mkcO.js +1 -0
- package/dashboard-neo/dist/assets/interface-favorite-stars-sparkles.svg-BxWiHdGA.js +1 -0
- package/dashboard-neo/dist/assets/interface-hierarchy-flowchart.svg-BPHEXJJS.js +1 -0
- package/dashboard-neo/dist/assets/interface-home-house.svg-B63-LGqz.js +1 -0
- package/dashboard-neo/dist/assets/interface-hyperlink.svg-C_lm0LzO.js +1 -0
- package/dashboard-neo/dist/assets/interface-lighting-brightness.svg-DmqVOdtF.js +1 -0
- package/dashboard-neo/dist/assets/interface-lock-closed.svg-xwC9xUEf.js +1 -0
- package/dashboard-neo/dist/assets/interface-lock-open-unlock.svg-0P7d1Er7.js +1 -0
- package/dashboard-neo/dist/assets/interface-login-key.svg-DSUnFVoR.js +1 -0
- package/dashboard-neo/dist/assets/interface-search.svg-Cki10DmM.js +1 -0
- package/dashboard-neo/dist/assets/interface-setting-cog.svg-B1g7SeN7.js +1 -0
- package/dashboard-neo/dist/assets/interface-share-megaphone-bullhorn.svg-Bn-98V1I.js +1 -0
- package/dashboard-neo/dist/assets/interface-share-rocket.svg-CxDqnOQE.js +1 -0
- package/dashboard-neo/dist/assets/interface-share-satellite.svg-Dr6tbP-H.js +1 -0
- package/dashboard-neo/dist/assets/interface-share-space-ship.svg-BcrSZOha.js +1 -0
- package/dashboard-neo/dist/assets/interface-share.svg-WJStd-hf.js +1 -0
- package/dashboard-neo/dist/assets/interface-signal-square.svg-sR1Jwdkj.js +1 -0
- package/dashboard-neo/dist/assets/interface-time-clock-circle.svg-CI-FR3Z0.js +1 -0
- package/dashboard-neo/dist/assets/interface-time-hour-glass.svg-BCH_wujz.js +1 -0
- package/dashboard-neo/dist/assets/interface-users-multiple.svg-7liAj7tU.js +1 -0
- package/dashboard-neo/dist/assets/interface-weather-moon.svg-CEEqAhxr.js +1 -0
- package/dashboard-neo/dist/assets/mail-chat-bubble-square.svg-DgBmT6at.js +1 -0
- package/dashboard-neo/dist/assets/mail-send-email-paper-airplane.svg-BtW62yNd.js +1 -0
- package/dashboard-neo/dist/assets/mail-send-envelope.svg-B2ofGi0G.js +1 -0
- package/dashboard-neo/dist/assets/markdown-BSj1FMVF.js +68 -0
- package/dashboard-neo/dist/assets/modal-74dUeivw.js +5 -0
- package/dashboard-neo/dist/assets/money-cashier-receipt.svg-oYv7RkCx.js +1 -0
- package/dashboard-neo/dist/assets/money-currency-dollar-pay.svg-BRFYydmz.js +1 -0
- package/dashboard-neo/dist/assets/money-graph-arrow-increase.svg-ChmHgfEP.js +1 -0
- package/dashboard-neo/dist/assets/money-graph-bar-chart-increase.svg-D6G7lFzR.js +1 -0
- package/dashboard-neo/dist/assets/nature-ecology-leaf.svg-C0Sj6pgM.js +1 -0
- package/dashboard-neo/dist/assets/parse-html-description-DHRmA6ou.js +5 -0
- package/dashboard-neo/dist/assets/phone-telephone.svg-2UFzF1dr.js +1 -0
- package/dashboard-neo/dist/assets/preload-helper-CJLUz7BA.js +16 -0
- package/dashboard-neo/dist/assets/programming-bug.svg-22hsMxQO.js +1 -0
- package/dashboard-neo/dist/assets/programming-cloud.svg-CLQxx35l.js +1 -0
- package/dashboard-neo/dist/assets/programming-computer-database-server.svg-DfQW4OzL.js +1 -0
- package/dashboard-neo/dist/assets/programming-computer-database.svg-BA4JjA4C.js +1 -0
- package/dashboard-neo/dist/assets/programming-module-four-layout.svg-ZqZ8jvaZ.js +1 -0
- package/dashboard-neo/dist/assets/programming-module-three.svg-C4IJTyw0.js +1 -0
- package/dashboard-neo/dist/assets/programming-module.svg-iETi-2b0.js +1 -0
- package/dashboard-neo/dist/assets/programming-script-code.svg-rCOsoRKw.js +1 -0
- package/dashboard-neo/dist/assets/reactivity.esm-bundler-BNk6Zv_g.js +1 -0
- package/dashboard-neo/dist/assets/runtime-core.esm-bundler-2tpRQTw-.js +18 -0
- package/dashboard-neo/dist/assets/shopping-cart.svg-Dc4piS12.js +1 -0
- package/dashboard-neo/dist/assets/shopping-gift-present.svg--51cUtCZ.js +1 -0
- package/dashboard-neo/dist/assets/shopping-shipping-box-parcel-package.svg-BDlugNqF.js +1 -0
- package/dashboard-neo/dist/assets/tag-new-circle.svg-IzWjXHZQ.js +1 -0
- package/dashboard-neo/dist/assets/travel-map-earth-globe.svg-BdyEHtN7.js +1 -0
- package/dashboard-neo/dist/assets/workspace-events-eIuzLwDq.js +100 -0
- package/dashboard-neo/dist/index.html +8 -2
- package/dist/index.cjs +43 -32
- package/dist/index.d.cts +11 -13
- package/dist/index.d.cts.map +1 -1
- package/package.json +15 -12
- package/src/auth/api-key.ts +28 -0
- package/src/compat/args.ts +1 -0
- package/src/compat/deprecation.ts +35 -0
- package/src/compat/session-path.ts +19 -0
- package/src/createApiMiddleware.ts +184 -0
- package/src/createApiServer.ts +466 -0
- package/src/dashboard/middleware.ts +94 -0
- package/src/docs/openapi.ts +77 -0
- package/src/docs/postman.ts +42 -0
- package/src/events/EventBridge.ts +4 -0
- package/src/events/EventBroadcaster.ts +126 -0
- package/src/execution/kernel.ts +1 -0
- package/src/health/HealthStore.ts +252 -0
- package/src/index.ts +9 -0
- package/src/invoke-client-method.ts +1 -0
- package/src/middleware/rate-limit.ts +30 -0
- package/src/monitoring/elastic.ts +104 -0
- package/src/routes/agent-discovery.ts +150 -0
- package/src/routes/debug.ts +99 -0
- package/src/routes/meta.ts +512 -0
- package/src/types.ts +31 -0
- package/dashboard-neo/dist/assets/AgentScalarChatInterface.vue-IhMa-3z5.js +0 -18
- package/dashboard-neo/dist/assets/Collection.vue-vsnc4RWv.js +0 -1
- package/dashboard-neo/dist/assets/CollectionAuthentication.vue-ZmqbpvJI.js +0 -1
- package/dashboard-neo/dist/assets/CollectionCookies.vue-iA2EFW6x.js +0 -1
- package/dashboard-neo/dist/assets/CollectionEnvironment.vue-DzSQF28B.js +0 -1
- package/dashboard-neo/dist/assets/CollectionOverview.vue-BMQzT6QD.js +0 -1
- package/dashboard-neo/dist/assets/CollectionScripts.vue-C6MHKuv8.js +0 -1
- package/dashboard-neo/dist/assets/CollectionServers.vue-Be6H5f7W.js +0 -1
- package/dashboard-neo/dist/assets/CollectionSettings.vue-9OvMj2mR.js +0 -1
- package/dashboard-neo/dist/assets/CollectionSync.vue-DF5GF55x.js +0 -1
- package/dashboard-neo/dist/assets/Cookies.vue-BjAXczeM.js +0 -1
- package/dashboard-neo/dist/assets/DataTableInput.vue-3lVVMj0z.js +0 -1
- package/dashboard-neo/dist/assets/DeleteSidebarListElement.vue-CdZK3_A9.js +0 -1
- package/dashboard-neo/dist/assets/EditSidebarListElement.vue-CfCtSnjA.js +0 -1
- package/dashboard-neo/dist/assets/EmptyState.vue-C9x87jvf.js +0 -22
- package/dashboard-neo/dist/assets/Environment.vue-36l5-PEA.js +0 -1
- package/dashboard-neo/dist/assets/EnvironmentModal.vue-CUUBVKgE.js +0 -1
- package/dashboard-neo/dist/assets/Form.vue-CNZe2Nab.js +0 -1
- package/dashboard-neo/dist/assets/IconSelector.vue-B8O9gEB6.js +0 -1
- package/dashboard-neo/dist/assets/Request.vue-BPyTupdg.js +0 -1
- package/dashboard-neo/dist/assets/RequestAuth.vue-Buirvybo.js +0 -1
- package/dashboard-neo/dist/assets/RequestRoot.vue-3wE_aGh5.js +0 -19
- package/dashboard-neo/dist/assets/Settings.vue-BHgUJt8Z.js +0 -1
- package/dashboard-neo/dist/assets/SidebarButton.vue-BqzqREDC.js +0 -1
- package/dashboard-neo/dist/assets/SidebarListElement.vue-BX9S2JrO.js +0 -1
- package/dashboard-neo/dist/assets/basic-shape-diamond.svg-BnAqd4Qb.js +0 -1
- package/dashboard-neo/dist/assets/basic-shape-hexagon.svg-N4HUwYpu.js +0 -1
- package/dashboard-neo/dist/assets/basic-shape-primary-circle-ellipse-round.svg-BRFLE-uL.js +0 -1
- package/dashboard-neo/dist/assets/basic-shape-primary-square-rectangle.svg-gaCLc8WX.js +0 -1
- package/dashboard-neo/dist/assets/basic-shape-shield.svg-D_MZxWhV.js +0 -1
- package/dashboard-neo/dist/assets/build-request-security-CDsXoaGl.js +0 -1
- package/dashboard-neo/dist/assets/computer-device-desktop-monitor.svg-BinQTWmG.js +0 -1
- package/dashboard-neo/dist/assets/computer-device-desktop.svg-C4XWLrGR.js +0 -1
- package/dashboard-neo/dist/assets/computer-device-laptop.svg-B-58K0VA.js +0 -1
- package/dashboard-neo/dist/assets/computer-device-mobile-phone-android-samsung-back.svg-wR9FrcRK.js +0 -1
- package/dashboard-neo/dist/assets/computer-device-mobile-phone-android-samsung.svg-CTpx3CX0.js +0 -1
- package/dashboard-neo/dist/assets/computer-device-mobile-phone-iphone-x-back.svg-DY-7m64q.js +0 -1
- package/dashboard-neo/dist/assets/computer-device-mobile-phone-iphone-x.svg-D0Ge9pbN.js +0 -1
- package/dashboard-neo/dist/assets/computer-device-mobile-tablet-touch.svg-dxrJ79yq.js +0 -1
- package/dashboard-neo/dist/assets/computer-device-mobile-tablet.svg-C-xYgooW.js +0 -1
- package/dashboard-neo/dist/assets/computer-device-network-ethernet-cat6.svg-Bi7ytDmN.js +0 -1
- package/dashboard-neo/dist/assets/computer-device-network-lan-www.svg-DIZnffSf.js +0 -1
- package/dashboard-neo/dist/assets/computer-device-network-wifi-connection.svg-BJdx4QtB.js +0 -1
- package/dashboard-neo/dist/assets/computer-device-network-wifi-router.svg-CEZuX2Uj.js +0 -1
- package/dashboard-neo/dist/assets/dist-BmLg9yXc.js +0 -1
- package/dashboard-neo/dist/assets/ecology-science-erlenmeyer-flask.svg-B22nfI21.js +0 -1
- package/dashboard-neo/dist/assets/geist-cyrillic-wght-normal-CHSlOQsW.woff2 +0 -0
- package/dashboard-neo/dist/assets/geist-latin-ext-wght-normal-DMtmJ5ZE.woff2 +0 -0
- package/dashboard-neo/dist/assets/geist-latin-wght-normal-Dm3htQBi.woff2 +0 -0
- package/dashboard-neo/dist/assets/image-flash-lightning.svg-8jwGfYvi.js +0 -1
- package/dashboard-neo/dist/assets/image-picture-flower.svg-DQBnIqvN.js +0 -1
- package/dashboard-neo/dist/assets/index-DYk4kNI6.js +0 -2355
- package/dashboard-neo/dist/assets/index-Oo2D96Pi.css +0 -1
- package/dashboard-neo/dist/assets/interface-alert-exclamation-diamond.svg-DgRtf5Rc.js +0 -1
- package/dashboard-neo/dist/assets/interface-alert-exclamation-triangle-warning.svg-Dyn4j9mr.js +0 -1
- package/dashboard-neo/dist/assets/interface-alert-information-circle.svg-C9LjBTNm.js +0 -1
- package/dashboard-neo/dist/assets/interface-award-crown.svg-DQeadu4b.js +0 -1
- package/dashboard-neo/dist/assets/interface-bookmark-tag.svg-Dw4A9QP0.js +0 -1
- package/dashboard-neo/dist/assets/interface-bookmark.svg-BYgwvhSS.js +0 -1
- package/dashboard-neo/dist/assets/interface-calendar-date-one.svg-DwmoQPdQ.js +0 -1
- package/dashboard-neo/dist/assets/interface-content-book-open-pages.svg-C9ob_aws.js +0 -1
- package/dashboard-neo/dist/assets/interface-content-book-page.svg-CjiBev76.js +0 -1
- package/dashboard-neo/dist/assets/interface-content-file.svg-CWFq2U8P.js +0 -1
- package/dashboard-neo/dist/assets/interface-content-folder.svg-Bkn67HmI.js +0 -1
- package/dashboard-neo/dist/assets/interface-copy-clipboard.svg-Clc6G5I7.js +0 -1
- package/dashboard-neo/dist/assets/interface-edit-attachment.svg-CNMMsyab.js +0 -1
- package/dashboard-neo/dist/assets/interface-edit-binocular.svg-TGAy1fMT.js +0 -1
- package/dashboard-neo/dist/assets/interface-edit-magic-wand.svg-BLav18Nm.js +0 -1
- package/dashboard-neo/dist/assets/interface-edit-tool-paint-roller.svg-CT8EnzBj.js +0 -1
- package/dashboard-neo/dist/assets/interface-edit-tool-pencil.svg-DpSBkLUs.js +0 -1
- package/dashboard-neo/dist/assets/interface-favorite-award.svg-DfBa9MD6.js +0 -1
- package/dashboard-neo/dist/assets/interface-favorite-flag.svg-C54BHnv1.js +0 -1
- package/dashboard-neo/dist/assets/interface-favorite-heart.svg-Bh_rbKoY.js +0 -1
- package/dashboard-neo/dist/assets/interface-favorite-star.svg-SCjMZVBW.js +0 -1
- package/dashboard-neo/dist/assets/interface-favorite-stars-sparkles.svg-DJqbuWIG.js +0 -1
- package/dashboard-neo/dist/assets/interface-hierarchy-flowchart.svg-Ib8RzCZm.js +0 -1
- package/dashboard-neo/dist/assets/interface-home-house.svg-BLUofUg_.js +0 -1
- package/dashboard-neo/dist/assets/interface-hyperlink.svg-D6ONBTc-.js +0 -1
- package/dashboard-neo/dist/assets/interface-lighting-brightness.svg-vr5Pi6NJ.js +0 -1
- package/dashboard-neo/dist/assets/interface-lock-closed.svg-ChWe_wVK.js +0 -1
- package/dashboard-neo/dist/assets/interface-lock-open-unlock.svg-C0a5Ndh0.js +0 -1
- package/dashboard-neo/dist/assets/interface-login-key.svg-DTV_5JRq.js +0 -1
- package/dashboard-neo/dist/assets/interface-search.svg-kRyqMnuK.js +0 -1
- package/dashboard-neo/dist/assets/interface-setting-cog.svg-CMnJqZqX.js +0 -1
- package/dashboard-neo/dist/assets/interface-share-megaphone-bullhorn.svg-Bu5Cw-Vm.js +0 -1
- package/dashboard-neo/dist/assets/interface-share-rocket.svg-CKf_bxS6.js +0 -1
- package/dashboard-neo/dist/assets/interface-share-satellite.svg-BlzZz1oC.js +0 -1
- package/dashboard-neo/dist/assets/interface-share-space-ship.svg-s8hu33mx.js +0 -1
- package/dashboard-neo/dist/assets/interface-share.svg-B0Ub4b2x.js +0 -1
- package/dashboard-neo/dist/assets/interface-signal-square.svg-5tH005TO.js +0 -1
- package/dashboard-neo/dist/assets/interface-time-clock-circle.svg-CofCX43H.js +0 -1
- package/dashboard-neo/dist/assets/interface-time-hour-glass.svg-BDK7FtcN.js +0 -1
- package/dashboard-neo/dist/assets/interface-users-multiple.svg-C2Ln3ld5.js +0 -1
- package/dashboard-neo/dist/assets/interface-weather-moon.svg-fVygBRng.js +0 -1
- package/dashboard-neo/dist/assets/mail-chat-bubble-square.svg-5FzWjeNp.js +0 -1
- package/dashboard-neo/dist/assets/mail-send-email-paper-airplane.svg-DxrjUhpJ.js +0 -1
- package/dashboard-neo/dist/assets/mail-send-envelope.svg-BuB28niF.js +0 -1
- package/dashboard-neo/dist/assets/money-cashier-receipt.svg-D_GvIulV.js +0 -1
- package/dashboard-neo/dist/assets/money-currency-dollar-pay.svg-lor_qHu1.js +0 -1
- package/dashboard-neo/dist/assets/money-graph-arrow-increase.svg-B4RYHlr3.js +0 -1
- package/dashboard-neo/dist/assets/money-graph-bar-chart-increase.svg-72f8xc7w.js +0 -1
- package/dashboard-neo/dist/assets/nature-ecology-leaf.svg-CEGVsRZv.js +0 -1
- package/dashboard-neo/dist/assets/phone-telephone.svg-DscYURKn.js +0 -1
- package/dashboard-neo/dist/assets/programming-bug.svg-4943T3tI.js +0 -1
- package/dashboard-neo/dist/assets/programming-cloud.svg-BV5nARkP.js +0 -1
- package/dashboard-neo/dist/assets/programming-computer-database-server.svg-CJ9Ij8Ik.js +0 -1
- package/dashboard-neo/dist/assets/programming-computer-database.svg-DzSq_dNJ.js +0 -1
- package/dashboard-neo/dist/assets/programming-module-four-layout.svg-9CEcYueG.js +0 -1
- package/dashboard-neo/dist/assets/programming-module-three.svg-CcJVLuuG.js +0 -1
- package/dashboard-neo/dist/assets/programming-module.svg-DPrCy6FI.js +0 -1
- package/dashboard-neo/dist/assets/programming-script-code.svg-m0VZs3ss.js +0 -1
- package/dashboard-neo/dist/assets/shopping-cart.svg-WKnlnAd8.js +0 -1
- package/dashboard-neo/dist/assets/shopping-gift-present.svg-Ciyb9-h6.js +0 -1
- package/dashboard-neo/dist/assets/shopping-shipping-box-parcel-package.svg-BnWK1YMQ.js +0 -1
- package/dashboard-neo/dist/assets/tag-new-circle.svg-C_SLASqF.js +0 -1
- package/dashboard-neo/dist/assets/travel-map-earth-globe.svg-DnQnavM3.js +0 -1
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import { cors } from 'hono/cors';
|
|
3
|
+
import { logger } from 'hono/logger';
|
|
4
|
+
import { createAdaptorServer, upgradeWebSocket } from '@hono/node-server';
|
|
5
|
+
import { createServer, type Server } from 'node:http';
|
|
6
|
+
import { WebSocketServer } from 'ws';
|
|
7
|
+
import { getHttpMethodDefinitions, type Config } from '@open-wa/schema';
|
|
8
|
+
import '@open-wa/schema';
|
|
9
|
+
import {
|
|
10
|
+
createScreencastRoute,
|
|
11
|
+
ScreencastManager,
|
|
12
|
+
} from '@open-wa/screencaster/server';
|
|
13
|
+
import { createApiMiddleware } from './createApiMiddleware';
|
|
14
|
+
import { createHonoMcpAdapter } from '@open-wa/mcp';
|
|
15
|
+
import { registerMetaRoutes } from './routes/meta';
|
|
16
|
+
import { registerDebugRoutes } from './routes/debug';
|
|
17
|
+
import { registerAgentDiscoveryRoutes } from './routes/agent-discovery';
|
|
18
|
+
import { type EventBridge } from './events/EventBridge';
|
|
19
|
+
import { HealthStore } from './health/HealthStore';
|
|
20
|
+
import { EventBroadcaster } from './events/EventBroadcaster';
|
|
21
|
+
import { ElasticEmitter } from './monitoring/elastic';
|
|
22
|
+
import {
|
|
23
|
+
setupViteDevServer,
|
|
24
|
+
mountDashboardProduction,
|
|
25
|
+
} from './dashboard/middleware';
|
|
26
|
+
import type { ApiServerOptions, ClientMethodMap } from './types';
|
|
27
|
+
import type { IScreencastPage } from '@open-wa/screencaster/server';
|
|
28
|
+
import type { PluginHost } from '@open-wa/core';
|
|
29
|
+
|
|
30
|
+
function parseCorsOrigin(corsConfig: string | string[]): string | string[] {
|
|
31
|
+
if (corsConfig === '*') {
|
|
32
|
+
return '*';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (Array.isArray(corsConfig)) {
|
|
36
|
+
return corsConfig;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (typeof corsConfig === 'string' && corsConfig.includes(',')) {
|
|
40
|
+
return corsConfig.split(',').map((origin) => origin.trim());
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return corsConfig;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export class ApiServer {
|
|
47
|
+
private app: Hono;
|
|
48
|
+
private config: Config;
|
|
49
|
+
private client: ClientMethodMap | undefined;
|
|
50
|
+
private elasticEmitter?: ElasticEmitter;
|
|
51
|
+
private latestQR: string | null = null;
|
|
52
|
+
private screencastManager: ScreencastManager;
|
|
53
|
+
private server?: Server;
|
|
54
|
+
private isDashboardActive: boolean = false;
|
|
55
|
+
private pluginHost?: PluginHost;
|
|
56
|
+
private healthStore: HealthStore = new HealthStore();
|
|
57
|
+
private eventBroadcaster: EventBroadcaster;
|
|
58
|
+
private eventBridge?: EventBridge;
|
|
59
|
+
private eventBridgeListener?: (event: string, payload: any) => void;
|
|
60
|
+
private readinessProvider?: () =>
|
|
61
|
+
| {
|
|
62
|
+
state?: string;
|
|
63
|
+
status?: string;
|
|
64
|
+
ready: boolean;
|
|
65
|
+
exposureSafe?: boolean;
|
|
66
|
+
pending?: string[];
|
|
67
|
+
blockers?: string[];
|
|
68
|
+
}
|
|
69
|
+
| undefined;
|
|
70
|
+
|
|
71
|
+
constructor(options: ApiServerOptions) {
|
|
72
|
+
this.config = options.config;
|
|
73
|
+
|
|
74
|
+
// Validate MCP configuration
|
|
75
|
+
if (this.config.mcp?.enabled && !this.config.apiKey) {
|
|
76
|
+
throw new Error(
|
|
77
|
+
'MCP requires Easy API apiKey. Refusing to start with MCP enabled and no apiKey configured.',
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
this.app = new Hono();
|
|
82
|
+
this.screencastManager = new ScreencastManager();
|
|
83
|
+
this.eventBroadcaster = new EventBroadcaster(this.config.sessionId);
|
|
84
|
+
|
|
85
|
+
if (this.config.elasticUrl) {
|
|
86
|
+
this.elasticEmitter = new ElasticEmitter({
|
|
87
|
+
url: this.config.elasticUrl,
|
|
88
|
+
username: this.config.elasticUsername,
|
|
89
|
+
password: this.config.elasticPassword,
|
|
90
|
+
bufferSize: this.config.elasticBufferSize,
|
|
91
|
+
pipeline: this.config.elasticPipeline,
|
|
92
|
+
indexPrefix: this.config.elasticIndexPrefix,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
this.setupMiddleware();
|
|
97
|
+
this.registerRoutes();
|
|
98
|
+
|
|
99
|
+
// Register screencast WebSocket route
|
|
100
|
+
this.app.get(
|
|
101
|
+
'/screencast',
|
|
102
|
+
createScreencastRoute(upgradeWebSocket, this.screencastManager),
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public setClient(client: ClientMethodMap | undefined) {
|
|
107
|
+
this.client = client;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
public setEventBridge(bridge: EventBridge) {
|
|
111
|
+
if (this.eventBridge && this.eventBridgeListener) {
|
|
112
|
+
this.eventBridge.offAny(this.eventBridgeListener);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
this.eventBridge = bridge;
|
|
116
|
+
this.eventBridgeListener = (event: string, payload: any) => {
|
|
117
|
+
this.healthStore.processEvent(event, payload);
|
|
118
|
+
this.eventBroadcaster.broadcast(event, payload);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// Also wire events into the HealthStore so /health returns accumulated data
|
|
122
|
+
bridge.onAny(this.eventBridgeListener);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public setReadinessProvider(
|
|
126
|
+
provider:
|
|
127
|
+
| (() =>
|
|
128
|
+
| {
|
|
129
|
+
state?: string;
|
|
130
|
+
status?: string;
|
|
131
|
+
ready: boolean;
|
|
132
|
+
exposureSafe?: boolean;
|
|
133
|
+
pending?: string[];
|
|
134
|
+
blockers?: string[];
|
|
135
|
+
}
|
|
136
|
+
| undefined)
|
|
137
|
+
| undefined,
|
|
138
|
+
) {
|
|
139
|
+
this.readinessProvider = provider;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Bind a CDP-capable page for screencasting.
|
|
144
|
+
* Call this once the browser page is ready.
|
|
145
|
+
*/
|
|
146
|
+
public async setPage(page: IScreencastPage): Promise<void> {
|
|
147
|
+
await this.screencastManager.setPage(page);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Unbind the screencaster page (session ended).
|
|
152
|
+
*/
|
|
153
|
+
public async clearPage(): Promise<void> {
|
|
154
|
+
await this.screencastManager.clearPage();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
public setQR(qr: string) {
|
|
158
|
+
this.latestQR = qr;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
public getApp() {
|
|
162
|
+
return this.app;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
public getEventBroadcaster() {
|
|
166
|
+
return this.eventBroadcaster;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Mount plugin routes and manifest endpoint.
|
|
171
|
+
* Call this after the PluginHost has all plugins registered.
|
|
172
|
+
*/
|
|
173
|
+
public mountPlugins(pluginHost: PluginHost): void {
|
|
174
|
+
this.pluginHost = pluginHost;
|
|
175
|
+
|
|
176
|
+
// Mount each plugin's routes at /plugins/<name>/
|
|
177
|
+
for (const { name, router } of pluginHost.getRoutes()) {
|
|
178
|
+
this.app.route(`/plugins/${name}`, router);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
public async start() {
|
|
183
|
+
let viteDevServer: any = null;
|
|
184
|
+
if (this.config.dashboard) {
|
|
185
|
+
viteDevServer = await setupViteDevServer();
|
|
186
|
+
if (!viteDevServer) {
|
|
187
|
+
this.isDashboardActive = await mountDashboardProduction(this.app);
|
|
188
|
+
} else {
|
|
189
|
+
this.isDashboardActive = true;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const server = createAdaptorServer({
|
|
194
|
+
fetch: this.app.fetch,
|
|
195
|
+
websocket: {
|
|
196
|
+
server: new WebSocketServer({ noServer: true }),
|
|
197
|
+
},
|
|
198
|
+
createServer: (options, honoListener) =>
|
|
199
|
+
createServer(options, (request, response) => {
|
|
200
|
+
if (viteDevServer && request.url?.startsWith('/dashboard')) {
|
|
201
|
+
viteDevServer.middlewares(request, response, () => {
|
|
202
|
+
void honoListener(request, response);
|
|
203
|
+
});
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
void honoListener(request, response);
|
|
207
|
+
}),
|
|
208
|
+
});
|
|
209
|
+
this.server = server as Server;
|
|
210
|
+
|
|
211
|
+
await new Promise<void>((resolve, reject) => {
|
|
212
|
+
const onError = (error: Error) => {
|
|
213
|
+
server.off('error', onError);
|
|
214
|
+
reject(error);
|
|
215
|
+
};
|
|
216
|
+
server.once('error', onError);
|
|
217
|
+
server.listen(this.config.port, this.config.host, () => {
|
|
218
|
+
server.off('error', onError);
|
|
219
|
+
console.log(
|
|
220
|
+
`Server running on http://${this.config.host}:${this.config.port}`,
|
|
221
|
+
);
|
|
222
|
+
resolve();
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
if (this.elasticEmitter) {
|
|
227
|
+
await this.elasticEmitter.start();
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
public async stop() {
|
|
232
|
+
const server = this.server;
|
|
233
|
+
this.server = undefined;
|
|
234
|
+
if (server?.listening) {
|
|
235
|
+
await new Promise<void>((resolve, reject) => {
|
|
236
|
+
server.close((error) => (error ? reject(error) : resolve()));
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
await this.screencastManager.destroy();
|
|
240
|
+
if (this.elasticEmitter) {
|
|
241
|
+
await this.elasticEmitter.stop();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
public isDashboardRunning() {
|
|
246
|
+
return this.isDashboardActive;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
private isSessionConnected() {
|
|
250
|
+
const readiness = this.readinessProvider?.();
|
|
251
|
+
if (readiness) {
|
|
252
|
+
return readiness.ready;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (!this.client) {
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
return typeof this.client.isConnected === 'function'
|
|
260
|
+
? this.client.isConnected()
|
|
261
|
+
: false;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
private setupMiddleware() {
|
|
265
|
+
this.app.use(
|
|
266
|
+
'/*',
|
|
267
|
+
cors({
|
|
268
|
+
origin: parseCorsOrigin(this.config.cors),
|
|
269
|
+
credentials: true,
|
|
270
|
+
}),
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
this.app.use('/*', async (c, next) => {
|
|
274
|
+
const path = new URL(c.req.url).pathname;
|
|
275
|
+
if (path === '/' || path.startsWith('/dashboard')) {
|
|
276
|
+
c.header(
|
|
277
|
+
'Link',
|
|
278
|
+
[
|
|
279
|
+
`</.well-known/api-catalog>; rel="api-catalog"`,
|
|
280
|
+
`</.well-known/mcp/server-card.json>; rel="mcp"`,
|
|
281
|
+
`</.well-known/agent-card.json>; rel="describedby"`,
|
|
282
|
+
].join(', '),
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (
|
|
287
|
+
path === '/' &&
|
|
288
|
+
(c.req.header('Accept') || '').includes('text/markdown')
|
|
289
|
+
) {
|
|
290
|
+
const origin = new URL(c.req.url).origin;
|
|
291
|
+
c.header('Content-Type', 'text/markdown');
|
|
292
|
+
return c.text(
|
|
293
|
+
`# Open-WA Easy API\n\nThis is an Agent-Native API endpoint.\n\n## API Catalog\nExplore endpoints at \`${origin}/.well-known/api-catalog\` and docs at \`${origin}/api-docs\`.\n\n## MCP Endpoint\nAn MCP server is running for agents at \`${origin}/mcp\`.\n`,
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
await next();
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
if (this.config.logLevel !== 'silent') {
|
|
300
|
+
this.app.use('*', logger());
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
private registerRoutes() {
|
|
305
|
+
const methodDefinitions = getHttpMethodDefinitions();
|
|
306
|
+
registerAgentDiscoveryRoutes(this.app, {
|
|
307
|
+
config: this.config,
|
|
308
|
+
methodDefinitions,
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
this.app.get('/plugins/manifest', (c) =>
|
|
312
|
+
c.json(this.pluginHost?.getManifest() ?? { plugins: [] }),
|
|
313
|
+
);
|
|
314
|
+
|
|
315
|
+
this.app.get('/health', (c) => {
|
|
316
|
+
const healthSnapshot = this.healthStore.getSnapshot();
|
|
317
|
+
return c.json({
|
|
318
|
+
status: 'ok',
|
|
319
|
+
version: '5.0.0',
|
|
320
|
+
host: {
|
|
321
|
+
available: true,
|
|
322
|
+
api: true,
|
|
323
|
+
dashboard: {
|
|
324
|
+
enabled: this.config.dashboard,
|
|
325
|
+
running: this.isDashboardRunning(),
|
|
326
|
+
port: this.config.dashboardPort,
|
|
327
|
+
},
|
|
328
|
+
mcp: {
|
|
329
|
+
enabled: Boolean(this.config.mcp?.enabled),
|
|
330
|
+
available: Boolean(this.config.apiKey && this.config.mcp?.enabled),
|
|
331
|
+
path: this.config.mcp?.path || '/mcp',
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
capabilities: {
|
|
335
|
+
apiKeyConfigured: Boolean(this.config.apiKey),
|
|
336
|
+
mcpEnabled: Boolean(this.config.mcp?.enabled),
|
|
337
|
+
mcpAvailable: Boolean(this.config.apiKey && this.config.mcp?.enabled),
|
|
338
|
+
mcpPath: this.config.mcp?.path || '/mcp',
|
|
339
|
+
},
|
|
340
|
+
connected: this.isSessionConnected(),
|
|
341
|
+
session: this.readinessProvider?.() ?? {
|
|
342
|
+
ready: false,
|
|
343
|
+
status: this.client ? 'legacy' : 'unavailable',
|
|
344
|
+
state: this.client ? 'UNKNOWN' : 'DISCONNECTED',
|
|
345
|
+
pending: this.client
|
|
346
|
+
? ['session_readiness_unavailable']
|
|
347
|
+
: ['client_not_bound'],
|
|
348
|
+
blockers: [],
|
|
349
|
+
exposureSafe: false,
|
|
350
|
+
},
|
|
351
|
+
// QR code for pre-launch scanning
|
|
352
|
+
qr: this.latestQR ?? null,
|
|
353
|
+
// Accumulated health data for the dashboard
|
|
354
|
+
launchTimeline: healthSnapshot.launchTimeline,
|
|
355
|
+
patches: healthSnapshot.patches,
|
|
356
|
+
license: healthSnapshot.license,
|
|
357
|
+
reconnections: healthSnapshot.reconnections,
|
|
358
|
+
startedAt: healthSnapshot.startedAt,
|
|
359
|
+
lastEventAt: healthSnapshot.lastEventAt,
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
this.app.get('/qr', (c) => {
|
|
364
|
+
if (!this.config.ezqr) {
|
|
365
|
+
return c.json({ error: 'QR endpoint disabled' }, 404);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
if (!this.latestQR) {
|
|
369
|
+
return c.json(
|
|
370
|
+
{
|
|
371
|
+
error: 'QR code not available',
|
|
372
|
+
note: 'Session might be connected or generating QR',
|
|
373
|
+
},
|
|
374
|
+
404,
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
return c.json({
|
|
379
|
+
qr: this.latestQR,
|
|
380
|
+
note: 'Scan this QR code in WhatsApp',
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
this.app.get('/api/events', (c) => {
|
|
385
|
+
// TODO: Unify this inline auth check with the shared apiKeyMiddleware used across Easy API.
|
|
386
|
+
// Note: This intentionally supports query params to preserve legacy Easy API behavior,
|
|
387
|
+
// unlike the MCP adapter which strictly enforces header-only auth (X-API-Key) for security.
|
|
388
|
+
if (this.config.apiKey) {
|
|
389
|
+
const apiKey =
|
|
390
|
+
c.req.header('X-API-Key') ||
|
|
391
|
+
c.req.query('api_key') ||
|
|
392
|
+
c.req.query('key');
|
|
393
|
+
|
|
394
|
+
if (!apiKey || apiKey !== this.config.apiKey) {
|
|
395
|
+
return c.json(
|
|
396
|
+
{ error: 'Unauthorized', details: 'Invalid or missing API key' },
|
|
397
|
+
401,
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const topicsParam = c.req.query('topics');
|
|
403
|
+
const topics = topicsParam
|
|
404
|
+
? topicsParam
|
|
405
|
+
.split(',')
|
|
406
|
+
.map((topic) => topic.trim())
|
|
407
|
+
.filter(Boolean)
|
|
408
|
+
: ['*'];
|
|
409
|
+
|
|
410
|
+
return new Response(
|
|
411
|
+
this.eventBroadcaster.createStream({
|
|
412
|
+
signal: c.req.raw.signal,
|
|
413
|
+
topics,
|
|
414
|
+
}),
|
|
415
|
+
{
|
|
416
|
+
headers: {
|
|
417
|
+
'Cache-Control': 'no-cache, no-transform',
|
|
418
|
+
Connection: 'keep-alive',
|
|
419
|
+
'Content-Type': 'text/event-stream',
|
|
420
|
+
'X-Accel-Buffering': 'no',
|
|
421
|
+
},
|
|
422
|
+
},
|
|
423
|
+
);
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
registerMetaRoutes(this.app, {
|
|
427
|
+
config: this.config,
|
|
428
|
+
methodDefinitions,
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
registerDebugRoutes(this.app, {
|
|
432
|
+
config: this.config,
|
|
433
|
+
getConfig: () => this.config,
|
|
434
|
+
setIntegration: (id, data) => {
|
|
435
|
+
if (!this.config.integrations) {
|
|
436
|
+
this.config.integrations = {};
|
|
437
|
+
}
|
|
438
|
+
this.config.integrations[id] = data;
|
|
439
|
+
},
|
|
440
|
+
});
|
|
441
|
+
this.app.route(
|
|
442
|
+
'/api',
|
|
443
|
+
createApiMiddleware(() => this.client, {
|
|
444
|
+
config: this.config,
|
|
445
|
+
basePath: '/api',
|
|
446
|
+
elasticEmitter: this.elasticEmitter,
|
|
447
|
+
isSessionConnected: () => this.isSessionConnected(),
|
|
448
|
+
}),
|
|
449
|
+
);
|
|
450
|
+
|
|
451
|
+
if (this.config.mcp?.enabled) {
|
|
452
|
+
const mcpAdapter = createHonoMcpAdapter({
|
|
453
|
+
config: this.config,
|
|
454
|
+
clientSource: () => this.client,
|
|
455
|
+
elasticEmitter: this.elasticEmitter,
|
|
456
|
+
basePath: '/api',
|
|
457
|
+
isSessionConnected: () => this.isSessionConnected(),
|
|
458
|
+
});
|
|
459
|
+
mcpAdapter.mount(this.app, this.config.mcp.path || '/mcp');
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
export function createApiServer(config: Config) {
|
|
465
|
+
return new ApiServer({ config });
|
|
466
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { resolve, dirname } from 'path';
|
|
2
|
+
import { existsSync, readFileSync } from 'fs';
|
|
3
|
+
import type { Hono } from 'hono';
|
|
4
|
+
import { serveStatic } from '@hono/node-server/serve-static';
|
|
5
|
+
export function findDashboardDir(): string | null {
|
|
6
|
+
const monorepoCandidates = [
|
|
7
|
+
resolve(__dirname, '../../../apps/dashboard-neo'),
|
|
8
|
+
resolve(__dirname, '../../../../apps/dashboard-neo'),
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
const monorepoPath = monorepoCandidates.find((candidate) => existsSync(resolve(candidate, 'package.json')));
|
|
12
|
+
if (monorepoPath) {
|
|
13
|
+
return monorepoPath;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const embeddedCandidates = [
|
|
17
|
+
resolve(__dirname, '../dashboard-neo'),
|
|
18
|
+
resolve(__dirname, 'dashboard-neo'),
|
|
19
|
+
];
|
|
20
|
+
const embeddedPath = embeddedCandidates.find((candidate) => existsSync(resolve(candidate, 'dist/index.html')));
|
|
21
|
+
if (embeddedPath) {
|
|
22
|
+
return embeddedPath;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
const pkgPath = require.resolve('@open-wa/dashboard-neo/package.json');
|
|
27
|
+
return dirname(pkgPath);
|
|
28
|
+
} catch {
|
|
29
|
+
// Not installed
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
export async function setupViteDevServer(): Promise<any | null> {
|
|
37
|
+
const dashboardDir = findDashboardDir();
|
|
38
|
+
if (!dashboardDir) return null;
|
|
39
|
+
|
|
40
|
+
const isProd = process.env.NODE_ENV === 'production' || !existsSync(resolve(dashboardDir, 'vite.config.ts'));
|
|
41
|
+
if (isProd) return null;
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
const vite = await import('vite');
|
|
45
|
+
const viteServer = await vite.createServer({
|
|
46
|
+
root: dashboardDir,
|
|
47
|
+
server: { middlewareMode: true },
|
|
48
|
+
appType: 'spa',
|
|
49
|
+
base: '/dashboard/',
|
|
50
|
+
});
|
|
51
|
+
console.log(`\nš Dashboard mounted at /dashboard/ (Vite dev middleware)\n`);
|
|
52
|
+
return viteServer;
|
|
53
|
+
} catch (e: any) {
|
|
54
|
+
console.warn(`[dashboard] Failed to mount Vite middleware: ${e.message}`);
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export async function mountDashboardProduction(app: Hono): Promise<boolean> {
|
|
60
|
+
const dashboardDir = findDashboardDir();
|
|
61
|
+
if (!dashboardDir) return false;
|
|
62
|
+
const distPath = resolve(dashboardDir, 'dist');
|
|
63
|
+
if (existsSync(distPath)) {
|
|
64
|
+
// Determine the root for serveStatic relative to process.cwd, or just use absolute?
|
|
65
|
+
// serveStatic usually looks at relative paths from process.cwd() unless configured.
|
|
66
|
+
// wait, @hono/node-server/serve-static `root` defaults to "./".
|
|
67
|
+
// It's safer to use a custom middleware to read the files, or pass absolute path directly if supported.
|
|
68
|
+
app.use('/dashboard/*', serveStatic({
|
|
69
|
+
root: distPath,
|
|
70
|
+
rewriteRequestPath: (path) => path.replace(/^\/dashboard/, '')
|
|
71
|
+
}));
|
|
72
|
+
|
|
73
|
+
// Fallback for SPA
|
|
74
|
+
app.get('/dashboard/*', (c) => {
|
|
75
|
+
const accept = c.req.header('Accept') || '';
|
|
76
|
+
if (accept.includes('text/markdown')) {
|
|
77
|
+
const origin = new URL(c.req.url).origin;
|
|
78
|
+
c.header('Content-Type', 'text/markdown');
|
|
79
|
+
return c.text(`# Open-WA Dashboard\n\nThe dashboard UI is a Single Page Application.\n\n## Developer API\nThe Easy API is available at \`${origin}/api\`.\nRefer to \`${origin}/api-docs\` for more details.\n\n## MCP Server\nThe local MCP server is running and discoverable. Check \`${origin}/.well-known/mcp/server-card.json\` for constraints.`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const indexPath = resolve(distPath, 'index.html');
|
|
83
|
+
if (existsSync(indexPath)) {
|
|
84
|
+
return c.html(readFileSync(indexPath, 'utf-8'));
|
|
85
|
+
}
|
|
86
|
+
return c.notFound();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
console.log(`\nš Dashboard mounted at /dashboard/ (Production static)\n`);
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { HttpMethodDefinition } from '@open-wa/schema';
|
|
2
|
+
|
|
3
|
+
function schemaToOpenApi(schema: { toJSONSchema?: (params?: unknown) => unknown }) {
|
|
4
|
+
if (typeof schema?.toJSONSchema === 'function') {
|
|
5
|
+
return schema.toJSONSchema({ target: 'openapi-3.0' });
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
return { type: 'object', additionalProperties: true };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function buildQueryParameters(def: HttpMethodDefinition) {
|
|
12
|
+
const inputSchema = schemaToOpenApi(def.inputSchema) as {
|
|
13
|
+
properties?: Record<string, Record<string, unknown>>;
|
|
14
|
+
required?: string[];
|
|
15
|
+
};
|
|
16
|
+
const properties = inputSchema.properties ?? {};
|
|
17
|
+
const required = new Set(inputSchema.required ?? []);
|
|
18
|
+
|
|
19
|
+
return def.parameterOrder.map((name) => ({
|
|
20
|
+
name,
|
|
21
|
+
in: 'query',
|
|
22
|
+
required: required.has(name),
|
|
23
|
+
description: properties[name]?.description || `Argument: ${name}`,
|
|
24
|
+
schema: properties[name] || { type: 'string' },
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function createOpenApiDocument(
|
|
29
|
+
methodDefinitions: HttpMethodDefinition[],
|
|
30
|
+
options: { origin: string; basePath?: string; title?: string; version?: string }
|
|
31
|
+
) {
|
|
32
|
+
const paths = Object.fromEntries(
|
|
33
|
+
methodDefinitions.map((def) => [
|
|
34
|
+
def.path,
|
|
35
|
+
{
|
|
36
|
+
[def.httpMethod.toLowerCase()]: {
|
|
37
|
+
summary: def.description,
|
|
38
|
+
operationId: def.functionName,
|
|
39
|
+
tags: [def.namespace],
|
|
40
|
+
...(def.httpMethod === 'GET' || def.httpMethod === 'DELETE'
|
|
41
|
+
? { parameters: buildQueryParameters(def) }
|
|
42
|
+
: {
|
|
43
|
+
requestBody: {
|
|
44
|
+
required: def.parameterOrder.length > 0,
|
|
45
|
+
content: {
|
|
46
|
+
'application/json': {
|
|
47
|
+
schema: schemaToOpenApi(def.inputSchema),
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
}),
|
|
52
|
+
'x-openwa-aliases': def.routeSignatures.filter((signature) => signature !== `${def.httpMethod} ${def.path}`),
|
|
53
|
+
responses: {
|
|
54
|
+
'200': {
|
|
55
|
+
description: 'Successful response',
|
|
56
|
+
content: {
|
|
57
|
+
'application/json': {
|
|
58
|
+
schema: schemaToOpenApi(def.outputSchema),
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
])
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
openapi: '3.0.3',
|
|
70
|
+
info: {
|
|
71
|
+
title: options.title || 'open-wa Easy API',
|
|
72
|
+
version: options.version || '5.0.0',
|
|
73
|
+
},
|
|
74
|
+
servers: [{ url: options.origin }],
|
|
75
|
+
paths,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { HttpMethodDefinition } from '@open-wa/schema';
|
|
2
|
+
|
|
3
|
+
export function createPostmanCollection(
|
|
4
|
+
methodDefinitions: HttpMethodDefinition[],
|
|
5
|
+
options: { origin: string; basePath?: string; name?: string }
|
|
6
|
+
) {
|
|
7
|
+
const basePath = options.basePath || '/api';
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
info: {
|
|
11
|
+
name: options.name || 'open-wa Easy API',
|
|
12
|
+
schema: 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json',
|
|
13
|
+
},
|
|
14
|
+
variable: [
|
|
15
|
+
{
|
|
16
|
+
key: 'baseUrl',
|
|
17
|
+
value: `${options.origin}${basePath}`.replace(/\/api\/api$/, '/api'),
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
item: methodDefinitions.map((def) => ({
|
|
21
|
+
name: def.functionName,
|
|
22
|
+
request: {
|
|
23
|
+
method: 'POST',
|
|
24
|
+
header: [{ key: 'Content-Type', value: 'application/json' }],
|
|
25
|
+
url: {
|
|
26
|
+
raw: `{{baseUrl}}/${def.functionName}`,
|
|
27
|
+
host: ['{{baseUrl}}'],
|
|
28
|
+
path: [def.functionName],
|
|
29
|
+
},
|
|
30
|
+
body: {
|
|
31
|
+
mode: 'raw',
|
|
32
|
+
raw: JSON.stringify(
|
|
33
|
+
Object.fromEntries(def.parameterOrder.map((name) => [name, `<${name}>`])),
|
|
34
|
+
null,
|
|
35
|
+
2
|
|
36
|
+
),
|
|
37
|
+
},
|
|
38
|
+
description: def.description,
|
|
39
|
+
},
|
|
40
|
+
})),
|
|
41
|
+
};
|
|
42
|
+
}
|