@rudderhq/server 0.2.5-canary.9 → 0.2.5
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/bootstrap/plugin-host-runtime.d.ts +39 -39
- package/dist/bundled-plugins/plugin-linear/dist/worker.js +101 -147
- package/dist/bundled-plugins/plugin-linear/dist/worker.js.map +2 -2
- package/dist/bundled-plugins/plugin-linear/package.json +1 -1
- package/dist/routes/access-onboarding.helpers.d.ts +142 -0
- package/dist/routes/access-onboarding.helpers.d.ts.map +1 -0
- package/dist/routes/access-onboarding.helpers.js +762 -0
- package/dist/routes/access-onboarding.helpers.js.map +1 -0
- package/dist/routes/access.d.ts +2 -48
- package/dist/routes/access.d.ts.map +1 -1
- package/dist/routes/access.helpers.d.ts +109 -0
- package/dist/routes/access.helpers.d.ts.map +1 -0
- package/dist/routes/access.helpers.js +460 -0
- package/dist/routes/access.helpers.js.map +1 -0
- package/dist/routes/access.js +6 -1218
- package/dist/routes/access.js.map +1 -1
- package/dist/routes/agents.d.ts.map +1 -1
- package/dist/routes/agents.js +55 -1057
- package/dist/routes/agents.js.map +1 -1
- package/dist/routes/agents.management-routes.d.ts +12 -0
- package/dist/routes/agents.management-routes.d.ts.map +1 -0
- package/dist/routes/agents.management-routes.js +1067 -0
- package/dist/routes/agents.management-routes.js.map +1 -0
- package/dist/routes/chats.d.ts.map +1 -1
- package/dist/routes/chats.js +42 -652
- package/dist/routes/chats.js.map +1 -1
- package/dist/routes/chats.stream-routes.d.ts +12 -0
- package/dist/routes/chats.stream-routes.d.ts.map +1 -0
- package/dist/routes/chats.stream-routes.js +666 -0
- package/dist/routes/chats.stream-routes.js.map +1 -0
- package/dist/routes/issues.comments-attachments.d.ts +12 -0
- package/dist/routes/issues.comments-attachments.d.ts.map +1 -0
- package/dist/routes/issues.comments-attachments.js +511 -0
- package/dist/routes/issues.comments-attachments.js.map +1 -0
- package/dist/routes/issues.d.ts.map +1 -1
- package/dist/routes/issues.js +43 -1128
- package/dist/routes/issues.js.map +1 -1
- package/dist/routes/issues.mutations.d.ts +12 -0
- package/dist/routes/issues.mutations.d.ts.map +1 -0
- package/dist/routes/issues.mutations.js +635 -0
- package/dist/routes/issues.mutations.js.map +1 -0
- package/dist/routes/plugins.d.ts.map +1 -1
- package/dist/routes/plugins.js +14 -694
- package/dist/routes/plugins.js.map +1 -1
- package/dist/routes/plugins.operations-routes.d.ts +28 -0
- package/dist/routes/plugins.operations-routes.d.ts.map +1 -0
- package/dist/routes/plugins.operations-routes.js +720 -0
- package/dist/routes/plugins.operations-routes.js.map +1 -0
- package/dist/services/access.d.ts +21 -21
- package/dist/services/activity.d.ts +19 -19
- package/dist/services/agents.d.ts +158 -158
- package/dist/services/approvals.d.ts +29 -29
- package/dist/services/assets.d.ts +8 -8
- package/dist/services/automations.d.ts +41 -27
- package/dist/services/automations.d.ts.map +1 -1
- package/dist/services/automations.js +287 -110
- package/dist/services/automations.js.map +1 -1
- package/dist/services/automations.scheduler.d.ts +9 -0
- package/dist/services/automations.scheduler.d.ts.map +1 -0
- package/dist/services/automations.scheduler.js +101 -0
- package/dist/services/automations.scheduler.js.map +1 -0
- package/dist/services/board-auth.d.ts +32 -32
- package/dist/services/calendar.d.ts +26 -26
- package/dist/services/chat-assistant.d.ts +3 -47
- package/dist/services/chat-assistant.d.ts.map +1 -1
- package/dist/services/chat-assistant.helpers.d.ts +156 -0
- package/dist/services/chat-assistant.helpers.d.ts.map +1 -0
- package/dist/services/chat-assistant.helpers.js +862 -0
- package/dist/services/chat-assistant.helpers.js.map +1 -0
- package/dist/services/chat-assistant.js +2 -861
- package/dist/services/chat-assistant.js.map +1 -1
- package/dist/services/chats.d.ts +149 -247
- package/dist/services/chats.d.ts.map +1 -1
- package/dist/services/chats.helpers.d.ts +117 -0
- package/dist/services/chats.helpers.d.ts.map +1 -0
- package/dist/services/chats.helpers.js +285 -0
- package/dist/services/chats.helpers.js.map +1 -0
- package/dist/services/chats.js +6 -286
- package/dist/services/chats.js.map +1 -1
- package/dist/services/costs.d.ts +8 -8
- package/dist/services/finance.d.ts +18 -18
- package/dist/services/goals.d.ts +30 -30
- package/dist/services/heartbeat.d.ts +3 -1
- package/dist/services/heartbeat.d.ts.map +1 -1
- package/dist/services/heartbeat.js +3 -1
- package/dist/services/heartbeat.js.map +1 -1
- package/dist/services/issue-approvals.d.ts +4 -4
- package/dist/services/issue-review-wakeup.d.ts +3 -3
- package/dist/services/issues.comments-attachments.d.ts +141 -0
- package/dist/services/issues.comments-attachments.d.ts.map +1 -0
- package/dist/services/issues.comments-attachments.js +313 -0
- package/dist/services/issues.comments-attachments.js.map +1 -0
- package/dist/services/issues.d.ts +205 -256
- package/dist/services/issues.d.ts.map +1 -1
- package/dist/services/issues.helpers.d.ts +87 -0
- package/dist/services/issues.helpers.d.ts.map +1 -0
- package/dist/services/issues.helpers.js +270 -0
- package/dist/services/issues.helpers.js.map +1 -0
- package/dist/services/issues.js +5 -569
- package/dist/services/issues.js.map +1 -1
- package/dist/services/knowledge-portability/organization-portability.core.d.ts +210 -0
- package/dist/services/knowledge-portability/organization-portability.core.d.ts.map +1 -0
- package/dist/services/knowledge-portability/organization-portability.core.js +997 -0
- package/dist/services/knowledge-portability/organization-portability.core.js.map +1 -0
- package/dist/services/knowledge-portability/organization-portability.d.ts +6 -28
- package/dist/services/knowledge-portability/organization-portability.d.ts.map +1 -1
- package/dist/services/knowledge-portability/organization-portability.export.d.ts +24 -0
- package/dist/services/knowledge-portability/organization-portability.export.d.ts.map +1 -0
- package/dist/services/knowledge-portability/organization-portability.export.js +607 -0
- package/dist/services/knowledge-portability/organization-portability.export.js.map +1 -0
- package/dist/services/knowledge-portability/organization-portability.files.d.ts +69 -0
- package/dist/services/knowledge-portability/organization-portability.files.d.ts.map +1 -0
- package/dist/services/knowledge-portability/organization-portability.files.js +597 -0
- package/dist/services/knowledge-portability/organization-portability.files.js.map +1 -0
- package/dist/services/knowledge-portability/organization-portability.import.d.ts +31 -0
- package/dist/services/knowledge-portability/organization-portability.import.d.ts.map +1 -0
- package/dist/services/knowledge-portability/organization-portability.import.js +575 -0
- package/dist/services/knowledge-portability/organization-portability.import.js.map +1 -0
- package/dist/services/knowledge-portability/organization-portability.js +37 -3848
- package/dist/services/knowledge-portability/organization-portability.js.map +1 -1
- package/dist/services/knowledge-portability/organization-portability.package.d.ts +72 -0
- package/dist/services/knowledge-portability/organization-portability.package.d.ts.map +1 -0
- package/dist/services/knowledge-portability/organization-portability.package.js +749 -0
- package/dist/services/knowledge-portability/organization-portability.package.js.map +1 -0
- package/dist/services/knowledge-portability/organization-portability.preview.d.ts +18 -0
- package/dist/services/knowledge-portability/organization-portability.preview.d.ts.map +1 -0
- package/dist/services/knowledge-portability/organization-portability.preview.js +333 -0
- package/dist/services/knowledge-portability/organization-portability.preview.js.map +1 -0
- package/dist/services/knowledge-portability/organization-portability.resolve-source.d.ts +4 -0
- package/dist/services/knowledge-portability/organization-portability.resolve-source.d.ts.map +1 -0
- package/dist/services/knowledge-portability/organization-portability.resolve-source.js +86 -0
- package/dist/services/knowledge-portability/organization-portability.resolve-source.js.map +1 -0
- package/dist/services/knowledge-portability/organization-skills.catalog.d.ts +221 -0
- package/dist/services/knowledge-portability/organization-skills.catalog.d.ts.map +1 -0
- package/dist/services/knowledge-portability/organization-skills.catalog.js +999 -0
- package/dist/services/knowledge-portability/organization-skills.catalog.js.map +1 -0
- package/dist/services/knowledge-portability/organization-skills.d.ts +4 -75
- package/dist/services/knowledge-portability/organization-skills.d.ts.map +1 -1
- package/dist/services/knowledge-portability/organization-skills.js +11 -2008
- package/dist/services/knowledge-portability/organization-skills.js.map +1 -1
- package/dist/services/knowledge-portability/organization-skills.scans.d.ts +16 -0
- package/dist/services/knowledge-portability/organization-skills.scans.d.ts.map +1 -0
- package/dist/services/knowledge-portability/organization-skills.scans.js +300 -0
- package/dist/services/knowledge-portability/organization-skills.scans.js.map +1 -0
- package/dist/services/knowledge-portability/organization-skills.sources.d.ts +68 -0
- package/dist/services/knowledge-portability/organization-skills.sources.d.ts.map +1 -0
- package/dist/services/knowledge-portability/organization-skills.sources.js +728 -0
- package/dist/services/knowledge-portability/organization-skills.sources.js.map +1 -0
- package/dist/services/messenger.d.ts +2 -2
- package/dist/services/messenger.js +2 -2
- package/dist/services/messenger.js.map +1 -1
- package/dist/services/organization-skills.d.ts +3 -1
- package/dist/services/organization-skills.d.ts.map +1 -1
- package/dist/services/organization-skills.js +3 -1
- package/dist/services/organization-skills.js.map +1 -1
- package/dist/services/orgs.d.ts +9 -9
- package/dist/services/plugin-loader.core.d.ts +14 -0
- package/dist/services/plugin-loader.core.d.ts.map +1 -0
- package/dist/services/plugin-loader.core.js +905 -0
- package/dist/services/plugin-loader.core.js.map +1 -0
- package/dist/services/plugin-loader.d.ts +3 -440
- package/dist/services/plugin-loader.d.ts.map +1 -1
- package/dist/services/plugin-loader.helpers.d.ts +468 -0
- package/dist/services/plugin-loader.helpers.d.ts.map +1 -0
- package/dist/services/plugin-loader.helpers.js +263 -0
- package/dist/services/plugin-loader.helpers.js.map +1 -0
- package/dist/services/plugin-loader.js +3 -1191
- package/dist/services/plugin-loader.js.map +1 -1
- package/dist/services/plugin-loader.worker-paths.d.ts +7 -0
- package/dist/services/plugin-loader.worker-paths.d.ts.map +1 -0
- package/dist/services/plugin-loader.worker-paths.js +85 -0
- package/dist/services/plugin-loader.worker-paths.js.map +1 -0
- package/dist/services/plugin-registry.d.ts +123 -123
- package/dist/services/projects.d.ts +8 -8
- package/dist/services/runtime-kernel/heartbeat.core.d.ts +725 -0
- package/dist/services/runtime-kernel/heartbeat.core.d.ts.map +1 -0
- package/dist/services/runtime-kernel/heartbeat.core.js +525 -0
- package/dist/services/runtime-kernel/heartbeat.core.js.map +1 -0
- package/dist/services/runtime-kernel/heartbeat.d.ts +38 -259
- package/dist/services/runtime-kernel/heartbeat.d.ts.map +1 -1
- package/dist/services/runtime-kernel/heartbeat.execute.d.ts +5 -0
- package/dist/services/runtime-kernel/heartbeat.execute.d.ts.map +1 -0
- package/dist/services/runtime-kernel/heartbeat.execute.js +1052 -0
- package/dist/services/runtime-kernel/heartbeat.execute.js.map +1 -0
- package/dist/services/runtime-kernel/heartbeat.js +50 -4142
- package/dist/services/runtime-kernel/heartbeat.js.map +1 -1
- package/dist/services/runtime-kernel/heartbeat.misc.d.ts +30 -0
- package/dist/services/runtime-kernel/heartbeat.misc.d.ts.map +1 -0
- package/dist/services/runtime-kernel/heartbeat.misc.js +483 -0
- package/dist/services/runtime-kernel/heartbeat.misc.js.map +1 -0
- package/dist/services/runtime-kernel/heartbeat.recovery.d.ts +38 -0
- package/dist/services/runtime-kernel/heartbeat.recovery.d.ts.map +1 -0
- package/dist/services/runtime-kernel/heartbeat.recovery.js +605 -0
- package/dist/services/runtime-kernel/heartbeat.recovery.js.map +1 -0
- package/dist/services/runtime-kernel/heartbeat.release.d.ts +6 -0
- package/dist/services/runtime-kernel/heartbeat.release.d.ts.map +1 -0
- package/dist/services/runtime-kernel/heartbeat.release.js +398 -0
- package/dist/services/runtime-kernel/heartbeat.release.js.map +1 -0
- package/dist/services/runtime-kernel/heartbeat.sessions.d.ts +229 -0
- package/dist/services/runtime-kernel/heartbeat.sessions.d.ts.map +1 -0
- package/dist/services/runtime-kernel/heartbeat.sessions.js +708 -0
- package/dist/services/runtime-kernel/heartbeat.sessions.js.map +1 -0
- package/dist/services/runtime-kernel/heartbeat.wakeup.d.ts +5 -0
- package/dist/services/runtime-kernel/heartbeat.wakeup.d.ts.map +1 -0
- package/dist/services/runtime-kernel/heartbeat.wakeup.js +552 -0
- package/dist/services/runtime-kernel/heartbeat.wakeup.js.map +1 -0
- package/dist/services/secrets.d.ts +25 -25
- package/dist/services/sidebar-badges.js +1 -1
- package/dist/services/sidebar-badges.js.map +1 -1
- package/dist/services/workspace-runtime.comments.d.ts +6 -0
- package/dist/services/workspace-runtime.comments.d.ts.map +1 -0
- package/dist/services/workspace-runtime.comments.js +17 -0
- package/dist/services/workspace-runtime.comments.js.map +1 -0
- package/dist/services/workspace-runtime.d.ts +4 -163
- package/dist/services/workspace-runtime.d.ts.map +1 -1
- package/dist/services/workspace-runtime.helpers.d.ts +163 -0
- package/dist/services/workspace-runtime.helpers.d.ts.map +1 -0
- package/dist/services/workspace-runtime.helpers.js +360 -0
- package/dist/services/workspace-runtime.helpers.js.map +1 -0
- package/dist/services/workspace-runtime.js +4 -1236
- package/dist/services/workspace-runtime.js.map +1 -1
- package/dist/services/workspace-runtime.lifecycle.d.ts +35 -0
- package/dist/services/workspace-runtime.lifecycle.d.ts.map +1 -0
- package/dist/services/workspace-runtime.lifecycle.js +266 -0
- package/dist/services/workspace-runtime.lifecycle.js.map +1 -0
- package/dist/services/workspace-runtime.services.d.ts +140 -0
- package/dist/services/workspace-runtime.services.d.ts.map +1 -0
- package/dist/services/workspace-runtime.services.js +606 -0
- package/dist/services/workspace-runtime.services.js.map +1 -0
- package/package.json +21 -15
- package/ui-dist/assets/{_basePickBy-B5mJzzqZ.js → _basePickBy-N8I9ml5Y.js} +1 -1
- package/ui-dist/assets/{_baseUniq-B10Ec09o.js → _baseUniq-BuSlpRSQ.js} +1 -1
- package/ui-dist/assets/{arc-Bw7wimOa.js → arc-qX-dPyA1.js} +1 -1
- package/ui-dist/assets/{architectureDiagram-2XIMDMQ5-DZr0XEvv.js → architectureDiagram-2XIMDMQ5-DhjkbXsp.js} +1 -1
- package/ui-dist/assets/{blockDiagram-WCTKOSBZ-D0jl0LgB.js → blockDiagram-WCTKOSBZ-JS-tTu3J.js} +1 -1
- package/ui-dist/assets/{c4Diagram-IC4MRINW-BEFxBnEm.js → c4Diagram-IC4MRINW-4DqwCWIx.js} +1 -1
- package/ui-dist/assets/channel-CccCW5_a.js +1 -0
- package/ui-dist/assets/{chunk-4BX2VUAB-Cbul1GoA.js → chunk-4BX2VUAB-T37SqBpp.js} +1 -1
- package/ui-dist/assets/{chunk-55IACEB6-DuouC3bT.js → chunk-55IACEB6-BSj9hdqK.js} +1 -1
- package/ui-dist/assets/{chunk-FMBD7UC4-bN1jF9xw.js → chunk-FMBD7UC4-Dkrlh0Wk.js} +1 -1
- package/ui-dist/assets/{chunk-JSJVCQXG-B0-Ij6ZF.js → chunk-JSJVCQXG-C0ZE3QdB.js} +1 -1
- package/ui-dist/assets/{chunk-KX2RTZJC-BjI3IEjI.js → chunk-KX2RTZJC-DOZQM9gW.js} +1 -1
- package/ui-dist/assets/{chunk-NQ4KR5QH-MUoGr46n.js → chunk-NQ4KR5QH-5Yr3U2k8.js} +1 -1
- package/ui-dist/assets/{chunk-QZHKN3VN-CQoI9Ouy.js → chunk-QZHKN3VN-CvKTufwF.js} +1 -1
- package/ui-dist/assets/{chunk-WL4C6EOR-DSJh3iDp.js → chunk-WL4C6EOR-IoEM0jyx.js} +1 -1
- package/ui-dist/assets/classDiagram-VBA2DB6C-JKk4tCW2.js +1 -0
- package/ui-dist/assets/classDiagram-v2-RAHNMMFH-JKk4tCW2.js +1 -0
- package/ui-dist/assets/clone-Onaweg8D.js +1 -0
- package/ui-dist/assets/{cose-bilkent-S5V4N54A-BPepglgB.js → cose-bilkent-S5V4N54A-CTvr1OFj.js} +1 -1
- package/ui-dist/assets/{dagre-KLK3FWXG-DhnHVZkt.js → dagre-KLK3FWXG-UZ-SNjVK.js} +1 -1
- package/ui-dist/assets/{diagram-E7M64L7V-DNvXtoOO.js → diagram-E7M64L7V-D7RAN0Hr.js} +1 -1
- package/ui-dist/assets/{diagram-IFDJBPK2-DhGlDTgn.js → diagram-IFDJBPK2-B4LViaFR.js} +1 -1
- package/ui-dist/assets/{diagram-P4PSJMXO-BmXEloWS.js → diagram-P4PSJMXO-CY1be7ak.js} +1 -1
- package/ui-dist/assets/{erDiagram-INFDFZHY-BTYVzaLM.js → erDiagram-INFDFZHY-Dca0KkvJ.js} +1 -1
- package/ui-dist/assets/{flowDiagram-PKNHOUZH-CqMNQUVv.js → flowDiagram-PKNHOUZH-i-qMvfwg.js} +1 -1
- package/ui-dist/assets/{ganttDiagram-A5KZAMGK-B2le_64a.js → ganttDiagram-A5KZAMGK-Wxq2lhbh.js} +1 -1
- package/ui-dist/assets/{gitGraphDiagram-K3NZZRJ6-BtxOBq5A.js → gitGraphDiagram-K3NZZRJ6-DwzgPlAY.js} +1 -1
- package/ui-dist/assets/{graph-C5E6qFfm.js → graph-BAqf89Tz.js} +1 -1
- package/ui-dist/assets/{index-Piq-IPXt.js → index-4eCzaLuY.js} +1 -1
- package/ui-dist/assets/{index-DT6UN2ec.js → index-8uu-nKqK.js} +1 -1
- package/ui-dist/assets/{index-T5NVZ3nR.js → index-B-1NEcI_.js} +1 -1
- package/ui-dist/assets/{index-D-MoarxG.js → index-B0b_3Eu5.js} +1 -1
- package/ui-dist/assets/{index-CZiP3FBQ.js → index-B8v0eZjP.js} +1 -1
- package/ui-dist/assets/{index-C1Ga66FM.js → index-BN7Moj3u.js} +1 -1
- package/ui-dist/assets/{index-xBUfBdQn.js → index-BSpxh3cY.js} +1 -1
- package/ui-dist/assets/{index-CQcMWp51.js → index-BY44RIi9.js} +1 -1
- package/ui-dist/assets/{index-3a93sZNI.js → index-BhyQJhdZ.js} +1 -1
- package/ui-dist/assets/{index-BsVDit5y.js → index-BkPL_iGU.js} +1 -1
- package/ui-dist/assets/{index-88lBSTsW.js → index-BsPfoHXS.js} +1 -1
- package/ui-dist/assets/{index-CyJtcUF0.js → index-BstW7nmv.js} +1 -1
- package/ui-dist/assets/{index-BvZ0Ptfl.js → index-BwB67Zyz.js} +1 -1
- package/ui-dist/assets/index-C2peSkmT.css +1 -0
- package/ui-dist/assets/{index-vkCrQLeX.js → index-C3ktOsS_.js} +1 -1
- package/ui-dist/assets/{index-D2hZpQJT.js → index-CMyABlS-.js} +1 -1
- package/ui-dist/assets/{index-C4WCPEY4.js → index-CyBJ8ujC.js} +1 -1
- package/ui-dist/assets/{index-Bf7NB_lK.js → index-DAxM2W3O.js} +1 -1
- package/ui-dist/assets/{index-Dq7H6-Lm.js → index-DVZXPmhk.js} +1 -1
- package/ui-dist/assets/{index-CskDu6A3.js → index-Dc19uAyw.js} +1 -1
- package/ui-dist/assets/index-DzHrwZu1.js +1511 -0
- package/ui-dist/assets/{index-B20JneLK.js → index-LJuf53Ye.js} +1 -1
- package/ui-dist/assets/{index-D6McTDMQ.js → index-Ugw5VWWz.js} +1 -1
- package/ui-dist/assets/{index-CcVGS6HJ.js → index-YGraEFR7.js} +1 -1
- package/ui-dist/assets/{infoDiagram-LFFYTUFH-BiCCZcIW.js → infoDiagram-LFFYTUFH-jLmDtFVR.js} +1 -1
- package/ui-dist/assets/{ishikawaDiagram-PHBUUO56-BiwBemM5.js → ishikawaDiagram-PHBUUO56-6OGMyLT8.js} +1 -1
- package/ui-dist/assets/{journeyDiagram-4ABVD52K-D8RGr2xl.js → journeyDiagram-4ABVD52K-yQjl6E0t.js} +1 -1
- package/ui-dist/assets/{kanban-definition-K7BYSVSG-C733Fj-E.js → kanban-definition-K7BYSVSG-DkdCeQlS.js} +1 -1
- package/ui-dist/assets/{layout-CM4c3NA_.js → layout-CqSYvZ_w.js} +1 -1
- package/ui-dist/assets/{linear-DzH21Xsf.js → linear-B8xGZaoi.js} +1 -1
- package/ui-dist/assets/{mermaid.core-Z2rpoVP2.js → mermaid.core-AKL_cdyk.js} +4 -4
- package/ui-dist/assets/{mindmap-definition-YRQLILUH-DylLLj9w.js → mindmap-definition-YRQLILUH-Zr-dXC0x.js} +1 -1
- package/ui-dist/assets/{pieDiagram-SKSYHLDU-617wI_rr.js → pieDiagram-SKSYHLDU-BvDAU-Nk.js} +1 -1
- package/ui-dist/assets/{quadrantDiagram-337W2JSQ-lxoCPJIL.js → quadrantDiagram-337W2JSQ-Dn9kM62o.js} +1 -1
- package/ui-dist/assets/{requirementDiagram-Z7DCOOCP-C5XydQ9-.js → requirementDiagram-Z7DCOOCP-GIsIh7Sd.js} +1 -1
- package/ui-dist/assets/{sankeyDiagram-WA2Y5GQK--grmq-Q8.js → sankeyDiagram-WA2Y5GQK-CUCuBkuf.js} +1 -1
- package/ui-dist/assets/{sequenceDiagram-2WXFIKYE-BS2PeYH-.js → sequenceDiagram-2WXFIKYE-MDpUY2HM.js} +1 -1
- package/ui-dist/assets/{stateDiagram-RAJIS63D-CeuZtj2z.js → stateDiagram-RAJIS63D-BymMpuUU.js} +1 -1
- package/ui-dist/assets/stateDiagram-v2-FVOUBMTO-Bi2oCU6d.js +1 -0
- package/ui-dist/assets/{timeline-definition-YZTLITO2-DxHdMpRr.js → timeline-definition-YZTLITO2-B6ofPhhy.js} +1 -1
- package/ui-dist/assets/{treemap-KZPCXAKY-Bv1ZlC5h.js → treemap-KZPCXAKY-DnLO6w1l.js} +1 -1
- package/ui-dist/assets/{vennDiagram-LZ73GAT5-DvpZSXY2.js → vennDiagram-LZ73GAT5-D0MyZIDl.js} +1 -1
- package/ui-dist/assets/{xychartDiagram-JWTSCODW-DttOu1GC.js → xychartDiagram-JWTSCODW-rADY1iUG.js} +1 -1
- package/ui-dist/index.html +2 -2
- package/ui-dist/assets/channel-DGUh6rEi.js +0 -1
- package/ui-dist/assets/classDiagram-VBA2DB6C-1ntk2IOV.js +0 -1
- package/ui-dist/assets/classDiagram-v2-RAHNMMFH-1ntk2IOV.js +0 -1
- package/ui-dist/assets/clone-BpddY88c.js +0 -1
- package/ui-dist/assets/index-C8AD6s7S.js +0 -1510
- package/ui-dist/assets/index-Ded0dPwB.css +0 -1
- package/ui-dist/assets/stateDiagram-v2-FVOUBMTO-DXq0yC5C.js +0 -1
|
@@ -0,0 +1,666 @@
|
|
|
1
|
+
import multer from "multer";
|
|
2
|
+
import { addChatMessageSchema, updateChatConversationUserStateSchema, convertChatToIssueSchema, createChatAttachmentMetadataSchema, createChatContextLinkSchema, resolveChatOperationProposalSchema, setChatProjectContextSchema, } from "@rudderhq/shared";
|
|
3
|
+
import { isAllowedContentType, MAX_ATTACHMENT_BYTES } from "../attachment-types.js";
|
|
4
|
+
import { updateExecutionObservation, updateExecutionTraceIO, } from "../langfuse.js";
|
|
5
|
+
import { emitExecutionTranscriptTree } from "../langfuse-transcript.js";
|
|
6
|
+
import { validate } from "../middleware/validate.js";
|
|
7
|
+
import { logger } from "../middleware/logger.js";
|
|
8
|
+
import { ChatAssistantStreamError, } from "../services/chat-assistant.js";
|
|
9
|
+
import { cancelActiveChatGeneration, claimChatGeneration } from "../services/chat-generation-locks.js";
|
|
10
|
+
import { logActivity, } from "../services/index.js";
|
|
11
|
+
import { assertCompanyAccess, getActorInfo } from "./authz.js";
|
|
12
|
+
export function registerChatStreamRoutes(ctx) {
|
|
13
|
+
const { router, db, storage, svc, assistantSvc, agentsSvc, issuesSvc, projectsSvc, goalsSvc, access, operatorProfiles, assertConversationAccess, boardUserId, assertCanAssignTasks, runSingleFileUpload, runMessageFileUpload, isMultipartRequest, uploadedMessageFiles, validateUploadedMessageFiles, buildChatObservabilityContext, withChatObservation, emitChatObservationEvent, summarizeChatObservationMessages, modelTurnInputFromInvocationMeta, buildChatTraceInput, mergeChatInvocationTraceMetadata, logChatMessagesAdded, assertContextLinksBelongToCompany, turnContextFromUserMessage, addUserMessage, attachFilesToUserMessage, loadAssistantInput, chatReplyingAgentId, assertCanConvertIssueProposal, persistAssistantReply, attachGeneratedFilesToPartialMessage, persistPartialAssistantMessage, writeStreamEvent, } = ctx;
|
|
14
|
+
router.post("/chats/:id/messages/stream", async (req, res) => {
|
|
15
|
+
if (isMultipartRequest(req)) {
|
|
16
|
+
try {
|
|
17
|
+
await runMessageFileUpload(req, res);
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
if (err instanceof multer.MulterError) {
|
|
21
|
+
if (err.code === "LIMIT_FILE_SIZE") {
|
|
22
|
+
res.status(422).json({ error: `Attachment exceeds ${MAX_ATTACHMENT_BYTES} bytes` });
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
res.status(400).json({ error: err.message });
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
throw err;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const parsedBody = addChatMessageSchema.safeParse(req.body ?? {});
|
|
32
|
+
if (!parsedBody.success) {
|
|
33
|
+
res.status(400).json({ error: "Invalid chat message", details: parsedBody.error.issues });
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const messageFiles = uploadedMessageFiles(req);
|
|
37
|
+
const attachmentValidationError = validateUploadedMessageFiles(messageFiles);
|
|
38
|
+
if (attachmentValidationError) {
|
|
39
|
+
res.status(422).json({ error: attachmentValidationError });
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const conversation = await assertConversationAccess(req, req.params.id);
|
|
43
|
+
if (!conversation) {
|
|
44
|
+
res.status(404).json({ error: "Chat conversation not found" });
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const assistantAvailability = await assistantSvc.getChatAssistantAvailability(conversation);
|
|
48
|
+
if (!assistantAvailability.available) {
|
|
49
|
+
res.status(503).json({ error: assistantAvailability.error });
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const abortController = new AbortController();
|
|
53
|
+
const releaseGeneration = claimChatGeneration(conversation.id, abortController);
|
|
54
|
+
if (!releaseGeneration) {
|
|
55
|
+
res.status(409).json({ error: "A chat reply is already being generated for this conversation" });
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const actor = getActorInfo(req);
|
|
59
|
+
let assistantConversationForPartial = null;
|
|
60
|
+
let turnContextForPartial = null;
|
|
61
|
+
let chatObservation = null;
|
|
62
|
+
const transcript = [];
|
|
63
|
+
const observedTranscript = [];
|
|
64
|
+
let modelTurnInput;
|
|
65
|
+
let assistantProgressMessage = null;
|
|
66
|
+
let assistantProgressMessageId = null;
|
|
67
|
+
let assistantDraftBody = "";
|
|
68
|
+
const persistStreamProgress = async (progressConversation, replyingAgentId = chatReplyingAgentId(progressConversation)) => {
|
|
69
|
+
if (!turnContextForPartial)
|
|
70
|
+
return null;
|
|
71
|
+
const input = {
|
|
72
|
+
kind: "message",
|
|
73
|
+
status: "streaming",
|
|
74
|
+
body: assistantDraftBody,
|
|
75
|
+
transcript,
|
|
76
|
+
replyingAgentId,
|
|
77
|
+
};
|
|
78
|
+
if (assistantProgressMessage) {
|
|
79
|
+
const updated = await svc.updateMessage(progressConversation.id, assistantProgressMessage.id, input);
|
|
80
|
+
if (updated) {
|
|
81
|
+
assistantProgressMessage = updated;
|
|
82
|
+
assistantProgressMessageId = assistantProgressMessage.id;
|
|
83
|
+
return assistantProgressMessage;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
assistantProgressMessage = await svc.addMessage(progressConversation.id, {
|
|
87
|
+
orgId: progressConversation.orgId,
|
|
88
|
+
role: "assistant",
|
|
89
|
+
kind: "message",
|
|
90
|
+
status: "streaming",
|
|
91
|
+
body: assistantDraftBody,
|
|
92
|
+
transcript,
|
|
93
|
+
replyingAgentId,
|
|
94
|
+
chatTurnId: turnContextForPartial.chatTurnId,
|
|
95
|
+
turnVariant: turnContextForPartial.turnVariant,
|
|
96
|
+
});
|
|
97
|
+
assistantProgressMessageId = assistantProgressMessage.id;
|
|
98
|
+
return assistantProgressMessage;
|
|
99
|
+
};
|
|
100
|
+
let clientClosed = false;
|
|
101
|
+
const handleClosed = () => {
|
|
102
|
+
if (clientClosed || res.writableEnded)
|
|
103
|
+
return;
|
|
104
|
+
clientClosed = true;
|
|
105
|
+
};
|
|
106
|
+
req.on("aborted", handleClosed);
|
|
107
|
+
res.on("close", handleClosed);
|
|
108
|
+
res.status(201);
|
|
109
|
+
res.setHeader("Content-Type", "application/x-ndjson; charset=utf-8");
|
|
110
|
+
res.setHeader("Cache-Control", "no-cache, no-transform");
|
|
111
|
+
res.setHeader("X-Accel-Buffering", "no");
|
|
112
|
+
res.flushHeaders();
|
|
113
|
+
try {
|
|
114
|
+
const userMessage = await addUserMessage(conversation, parsedBody.data.body, actor, parsedBody.data.editUserMessageId ?? null);
|
|
115
|
+
const userAttachments = await attachFilesToUserMessage(conversation, userMessage.id, messageFiles, actor);
|
|
116
|
+
const hydratedUserMessage = {
|
|
117
|
+
...userMessage,
|
|
118
|
+
attachments: userAttachments,
|
|
119
|
+
};
|
|
120
|
+
turnContextForPartial = turnContextFromUserMessage(userMessage);
|
|
121
|
+
chatObservation = buildChatObservabilityContext(conversation, {
|
|
122
|
+
surface: "chat_turn",
|
|
123
|
+
rootExecutionId: turnContextForPartial.chatTurnId,
|
|
124
|
+
trigger: "assistant_reply_stream",
|
|
125
|
+
runtime: assistantAvailability.agentRuntimeType ?? null,
|
|
126
|
+
metadata: {
|
|
127
|
+
stream: true,
|
|
128
|
+
userMessageId: userMessage.id,
|
|
129
|
+
editUserMessageId: parsedBody.data.editUserMessageId ?? null,
|
|
130
|
+
attachmentCount: userAttachments.length,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
const traceInputBase = {
|
|
134
|
+
conversationId: conversation.id,
|
|
135
|
+
body: parsedBody.data.body,
|
|
136
|
+
userMessageId: userMessage.id,
|
|
137
|
+
};
|
|
138
|
+
let currentChatTraceInput = buildChatTraceInput(traceInputBase);
|
|
139
|
+
writeStreamEvent(res, {
|
|
140
|
+
type: "ack",
|
|
141
|
+
userMessage: hydratedUserMessage,
|
|
142
|
+
});
|
|
143
|
+
await withChatObservation(chatObservation, {
|
|
144
|
+
name: "chat_turn",
|
|
145
|
+
asType: "agent",
|
|
146
|
+
input: currentChatTraceInput,
|
|
147
|
+
}, async (observation) => {
|
|
148
|
+
const assistantInput = await loadAssistantInput(conversation, actor);
|
|
149
|
+
assistantConversationForPartial = assistantInput.conversation;
|
|
150
|
+
let finalChatOutput = null;
|
|
151
|
+
let finalChatStatus = "completed";
|
|
152
|
+
try {
|
|
153
|
+
const streamed = await assistantSvc.streamChatAssistantReply({
|
|
154
|
+
...assistantInput,
|
|
155
|
+
abortSignal: abortController.signal,
|
|
156
|
+
onInvocationMeta: async (meta) => {
|
|
157
|
+
modelTurnInput = modelTurnInputFromInvocationMeta(meta);
|
|
158
|
+
currentChatTraceInput = buildChatTraceInput(traceInputBase, meta);
|
|
159
|
+
mergeChatInvocationTraceMetadata(chatObservation, meta);
|
|
160
|
+
updateExecutionObservation(observation, chatObservation, {
|
|
161
|
+
input: currentChatTraceInput,
|
|
162
|
+
});
|
|
163
|
+
updateExecutionTraceIO(observation, { input: currentChatTraceInput });
|
|
164
|
+
},
|
|
165
|
+
onAssistantDelta: async (delta) => {
|
|
166
|
+
assistantDraftBody = `${assistantDraftBody}${delta}`;
|
|
167
|
+
await persistStreamProgress(assistantInput.conversation);
|
|
168
|
+
if (clientClosed)
|
|
169
|
+
return;
|
|
170
|
+
writeStreamEvent(res, {
|
|
171
|
+
type: "assistant_delta",
|
|
172
|
+
delta,
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
onAssistantState: async (state) => {
|
|
176
|
+
await persistStreamProgress(assistantInput.conversation);
|
|
177
|
+
if (clientClosed)
|
|
178
|
+
return;
|
|
179
|
+
writeStreamEvent(res, {
|
|
180
|
+
type: "assistant_state",
|
|
181
|
+
state,
|
|
182
|
+
});
|
|
183
|
+
},
|
|
184
|
+
onTranscriptEntry: async (entry) => {
|
|
185
|
+
transcript.push(entry);
|
|
186
|
+
await persistStreamProgress(assistantInput.conversation);
|
|
187
|
+
if (clientClosed)
|
|
188
|
+
return;
|
|
189
|
+
writeStreamEvent(res, {
|
|
190
|
+
type: "transcript_entry",
|
|
191
|
+
entry,
|
|
192
|
+
});
|
|
193
|
+
},
|
|
194
|
+
onObservedTranscriptEntry: async (entry) => {
|
|
195
|
+
observedTranscript.push(entry);
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
if (streamed.outcome === "stopped") {
|
|
199
|
+
finalChatStatus = "stopped";
|
|
200
|
+
finalChatOutput = streamed.partialBody;
|
|
201
|
+
const stoppedMessage = await persistPartialAssistantMessage(assistantInput.conversation, streamed.partialBody, "stopped", turnContextForPartial, transcript, streamed.replyingAgentId, assistantProgressMessageId);
|
|
202
|
+
if (stoppedMessage) {
|
|
203
|
+
await logChatMessagesAdded(assistantInput.conversation, [stoppedMessage], {
|
|
204
|
+
actorType: "system",
|
|
205
|
+
actorId: "chat-assistant",
|
|
206
|
+
agentId: streamed.replyingAgentId,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
await emitChatObservationEvent(chatObservation, {
|
|
210
|
+
name: "chat.reply.stopped",
|
|
211
|
+
level: "WARNING",
|
|
212
|
+
metadata: {
|
|
213
|
+
stoppedMessageId: stoppedMessage?.id ?? null,
|
|
214
|
+
transcriptEntries: transcript.length,
|
|
215
|
+
observedTranscriptEntries: observedTranscript.length,
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
if (!clientClosed) {
|
|
219
|
+
writeStreamEvent(res, {
|
|
220
|
+
type: "final",
|
|
221
|
+
messages: stoppedMessage ? [stoppedMessage] : [],
|
|
222
|
+
});
|
|
223
|
+
res.end();
|
|
224
|
+
}
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const createdMessages = await persistAssistantReply(req, assistantInput.conversation, actor, streamed.reply, turnContextForPartial, transcript, streamed.replyingAgentId, assistantProgressMessageId);
|
|
228
|
+
finalChatOutput = streamed.reply.body;
|
|
229
|
+
await logChatMessagesAdded(assistantInput.conversation, createdMessages, {
|
|
230
|
+
actorType: "system",
|
|
231
|
+
actorId: "chat-assistant",
|
|
232
|
+
agentId: streamed.replyingAgentId,
|
|
233
|
+
});
|
|
234
|
+
await emitChatObservationEvent(chatObservation, {
|
|
235
|
+
name: "chat.reply.persisted",
|
|
236
|
+
metadata: {
|
|
237
|
+
transcriptEntries: transcript.length,
|
|
238
|
+
observedTranscriptEntries: observedTranscript.length,
|
|
239
|
+
...summarizeChatObservationMessages(createdMessages),
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
if (!clientClosed) {
|
|
243
|
+
writeStreamEvent(res, {
|
|
244
|
+
type: "final",
|
|
245
|
+
messages: createdMessages,
|
|
246
|
+
});
|
|
247
|
+
res.end();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
finalChatStatus = "failed";
|
|
252
|
+
if (error instanceof ChatAssistantStreamError) {
|
|
253
|
+
finalChatOutput = error.partialBody;
|
|
254
|
+
}
|
|
255
|
+
throw error;
|
|
256
|
+
}
|
|
257
|
+
finally {
|
|
258
|
+
try {
|
|
259
|
+
const transcriptStats = emitExecutionTranscriptTree({
|
|
260
|
+
context: chatObservation,
|
|
261
|
+
parentObservation: observation,
|
|
262
|
+
transcript: observedTranscript,
|
|
263
|
+
initialTurnInput: modelTurnInput,
|
|
264
|
+
fallbackResult: finalChatOutput
|
|
265
|
+
? {
|
|
266
|
+
output: finalChatOutput,
|
|
267
|
+
subtype: finalChatStatus,
|
|
268
|
+
isError: finalChatStatus === "failed",
|
|
269
|
+
}
|
|
270
|
+
: null,
|
|
271
|
+
});
|
|
272
|
+
finalChatOutput = finalChatOutput ?? transcriptStats.finalOutput ?? null;
|
|
273
|
+
}
|
|
274
|
+
catch (error) {
|
|
275
|
+
logger.warn({
|
|
276
|
+
rootExecutionId: chatObservation.rootExecutionId,
|
|
277
|
+
err: error instanceof Error ? error.message : String(error),
|
|
278
|
+
}, "Failed to export chat transcript tree to Langfuse");
|
|
279
|
+
}
|
|
280
|
+
updateExecutionObservation(observation, {
|
|
281
|
+
...chatObservation,
|
|
282
|
+
status: finalChatStatus,
|
|
283
|
+
}, {
|
|
284
|
+
input: currentChatTraceInput,
|
|
285
|
+
output: finalChatOutput,
|
|
286
|
+
level: finalChatStatus === "failed" ? "ERROR" : "DEFAULT",
|
|
287
|
+
statusMessage: finalChatStatus,
|
|
288
|
+
});
|
|
289
|
+
updateExecutionTraceIO(observation, {
|
|
290
|
+
input: currentChatTraceInput,
|
|
291
|
+
output: finalChatOutput,
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
catch (err) {
|
|
297
|
+
const partialBody = err instanceof ChatAssistantStreamError ? err.partialBody : "";
|
|
298
|
+
const generatedAttachments = err instanceof ChatAssistantStreamError ? err.generatedAttachments : [];
|
|
299
|
+
const failedReplyingAgentId = chatReplyingAgentId(assistantConversationForPartial);
|
|
300
|
+
let failedMessage = await persistPartialAssistantMessage(assistantConversationForPartial ?? conversation, partialBody, "failed", turnContextForPartial, transcript, failedReplyingAgentId, assistantProgressMessageId).catch(() => null);
|
|
301
|
+
failedMessage = await attachGeneratedFilesToPartialMessage(assistantConversationForPartial ?? conversation, failedMessage, generatedAttachments, failedReplyingAgentId).catch(() => failedMessage);
|
|
302
|
+
if (failedMessage && assistantConversationForPartial) {
|
|
303
|
+
await logChatMessagesAdded(assistantConversationForPartial, [failedMessage], {
|
|
304
|
+
actorType: "system",
|
|
305
|
+
actorId: "chat-assistant",
|
|
306
|
+
agentId: failedReplyingAgentId,
|
|
307
|
+
}).catch(() => { });
|
|
308
|
+
}
|
|
309
|
+
if (chatObservation) {
|
|
310
|
+
await emitChatObservationEvent(chatObservation, {
|
|
311
|
+
name: "chat.reply.failed",
|
|
312
|
+
level: "ERROR",
|
|
313
|
+
metadata: {
|
|
314
|
+
failedMessageId: failedMessage?.id ?? null,
|
|
315
|
+
transcriptEntries: transcript.length,
|
|
316
|
+
observedTranscriptEntries: observedTranscript.length,
|
|
317
|
+
error: err instanceof Error ? err.message : String(err),
|
|
318
|
+
},
|
|
319
|
+
statusMessage: err instanceof Error ? err.message : "chat_reply_failed",
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
logger.warn({ err, conversationId: conversation.id }, "chat assistant stream failed");
|
|
323
|
+
if (!clientClosed) {
|
|
324
|
+
writeStreamEvent(res, {
|
|
325
|
+
type: "error",
|
|
326
|
+
error: err instanceof Error ? err.message : "Chat assistant failed to respond",
|
|
327
|
+
messageId: failedMessage?.id ?? null,
|
|
328
|
+
});
|
|
329
|
+
res.end();
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
finally {
|
|
333
|
+
req.off("aborted", handleClosed);
|
|
334
|
+
res.off("close", handleClosed);
|
|
335
|
+
releaseGeneration();
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
router.post("/chats/:id/messages/stream/stop", async (req, res) => {
|
|
339
|
+
const conversation = await assertConversationAccess(req, req.params.id);
|
|
340
|
+
if (!conversation) {
|
|
341
|
+
res.status(404).json({ error: "Chat conversation not found" });
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
res.json({ stopped: cancelActiveChatGeneration(conversation.id) });
|
|
345
|
+
});
|
|
346
|
+
router.post("/orgs/:orgId/chats/:chatId/attachments", async (req, res) => {
|
|
347
|
+
const orgId = req.params.orgId;
|
|
348
|
+
const chatId = req.params.chatId;
|
|
349
|
+
assertCompanyAccess(req, orgId);
|
|
350
|
+
const conversation = await svc.getById(chatId);
|
|
351
|
+
if (!conversation) {
|
|
352
|
+
res.status(404).json({ error: "Chat conversation not found" });
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
if (conversation.orgId !== orgId) {
|
|
356
|
+
res.status(422).json({ error: "Chat conversation does not belong to organization" });
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
try {
|
|
360
|
+
await runSingleFileUpload(req, res);
|
|
361
|
+
}
|
|
362
|
+
catch (err) {
|
|
363
|
+
if (err instanceof multer.MulterError) {
|
|
364
|
+
if (err.code === "LIMIT_FILE_SIZE") {
|
|
365
|
+
res.status(422).json({ error: `Attachment exceeds ${MAX_ATTACHMENT_BYTES} bytes` });
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
res.status(400).json({ error: err.message });
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
throw err;
|
|
372
|
+
}
|
|
373
|
+
const file = req.file;
|
|
374
|
+
if (!file) {
|
|
375
|
+
res.status(400).json({ error: "Missing file field 'file'" });
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
const contentType = (file.mimetype || "").toLowerCase();
|
|
379
|
+
if (!isAllowedContentType(contentType)) {
|
|
380
|
+
res.status(422).json({ error: `Unsupported attachment type: ${contentType || "unknown"}` });
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
if (file.buffer.length <= 0) {
|
|
384
|
+
res.status(422).json({ error: "Attachment is empty" });
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
const parsedMeta = createChatAttachmentMetadataSchema.safeParse(req.body ?? {});
|
|
388
|
+
if (!parsedMeta.success) {
|
|
389
|
+
res.status(400).json({ error: "Invalid attachment metadata", details: parsedMeta.error.issues });
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
const actor = getActorInfo(req);
|
|
393
|
+
const stored = await storage.putFile({
|
|
394
|
+
orgId,
|
|
395
|
+
namespace: `chats/${chatId}`,
|
|
396
|
+
originalFilename: file.originalname || null,
|
|
397
|
+
contentType,
|
|
398
|
+
body: file.buffer,
|
|
399
|
+
});
|
|
400
|
+
const attachment = await svc.createAttachment({
|
|
401
|
+
orgId,
|
|
402
|
+
conversationId: chatId,
|
|
403
|
+
messageId: parsedMeta.data.messageId,
|
|
404
|
+
provider: stored.provider,
|
|
405
|
+
objectKey: stored.objectKey,
|
|
406
|
+
contentType: stored.contentType,
|
|
407
|
+
byteSize: stored.byteSize,
|
|
408
|
+
sha256: stored.sha256,
|
|
409
|
+
originalFilename: stored.originalFilename,
|
|
410
|
+
createdByAgentId: actor.agentId,
|
|
411
|
+
createdByUserId: actor.actorType === "user" ? actor.actorId : null,
|
|
412
|
+
});
|
|
413
|
+
await logActivity(db, {
|
|
414
|
+
orgId,
|
|
415
|
+
actorType: actor.actorType,
|
|
416
|
+
actorId: actor.actorId,
|
|
417
|
+
agentId: actor.agentId,
|
|
418
|
+
runId: actor.runId,
|
|
419
|
+
action: "chat.attachment_added",
|
|
420
|
+
entityType: "chat",
|
|
421
|
+
entityId: chatId,
|
|
422
|
+
details: {
|
|
423
|
+
attachmentId: attachment.id,
|
|
424
|
+
messageId: attachment.messageId,
|
|
425
|
+
originalFilename: attachment.originalFilename,
|
|
426
|
+
contentType: attachment.contentType,
|
|
427
|
+
},
|
|
428
|
+
});
|
|
429
|
+
res.status(201).json(attachment);
|
|
430
|
+
});
|
|
431
|
+
router.post("/chats/:id/context-links", validate(createChatContextLinkSchema), async (req, res) => {
|
|
432
|
+
const conversation = await assertConversationAccess(req, req.params.id);
|
|
433
|
+
if (!conversation) {
|
|
434
|
+
res.status(404).json({ error: "Chat conversation not found" });
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
await assertContextLinksBelongToCompany(conversation.orgId, [req.body]);
|
|
438
|
+
const linked = await svc.addContextLink(conversation.id, conversation.orgId, req.body);
|
|
439
|
+
const actor = getActorInfo(req);
|
|
440
|
+
await logActivity(db, {
|
|
441
|
+
orgId: conversation.orgId,
|
|
442
|
+
actorType: actor.actorType,
|
|
443
|
+
actorId: actor.actorId,
|
|
444
|
+
agentId: actor.agentId,
|
|
445
|
+
runId: actor.runId,
|
|
446
|
+
action: "chat.context_linked",
|
|
447
|
+
entityType: "chat",
|
|
448
|
+
entityId: conversation.id,
|
|
449
|
+
details: req.body,
|
|
450
|
+
});
|
|
451
|
+
res.status(201).json(linked);
|
|
452
|
+
});
|
|
453
|
+
router.post("/chats/:id/project-context", validate(setChatProjectContextSchema), async (req, res) => {
|
|
454
|
+
const conversation = await assertConversationAccess(req, req.params.id);
|
|
455
|
+
if (!conversation) {
|
|
456
|
+
res.status(404).json({ error: "Chat conversation not found" });
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
const projectId = req.body.projectId ?? null;
|
|
460
|
+
if (projectId) {
|
|
461
|
+
await assertContextLinksBelongToCompany(conversation.orgId, [{
|
|
462
|
+
entityType: "project",
|
|
463
|
+
entityId: projectId,
|
|
464
|
+
}]);
|
|
465
|
+
}
|
|
466
|
+
const messages = await svc.listMessages(conversation.id);
|
|
467
|
+
if (messages.length > 0) {
|
|
468
|
+
res.status(409).json({ error: "Project context is locked after conversation starts" });
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
const updated = await svc.setProjectContextLink(conversation.id, conversation.orgId, projectId);
|
|
472
|
+
if (!updated) {
|
|
473
|
+
res.status(404).json({ error: "Chat conversation not found" });
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
const actor = getActorInfo(req);
|
|
477
|
+
await logActivity(db, {
|
|
478
|
+
orgId: conversation.orgId,
|
|
479
|
+
actorType: actor.actorType,
|
|
480
|
+
actorId: actor.actorId,
|
|
481
|
+
agentId: actor.agentId,
|
|
482
|
+
runId: actor.runId,
|
|
483
|
+
action: "chat.project_context_updated",
|
|
484
|
+
entityType: "chat",
|
|
485
|
+
entityId: conversation.id,
|
|
486
|
+
details: { projectId },
|
|
487
|
+
});
|
|
488
|
+
res.json(updated);
|
|
489
|
+
});
|
|
490
|
+
router.post("/chats/:id/convert-to-issue", validate(convertChatToIssueSchema), async (req, res) => {
|
|
491
|
+
const conversation = await assertConversationAccess(req, req.params.id);
|
|
492
|
+
if (!conversation) {
|
|
493
|
+
res.status(404).json({ error: "Chat conversation not found" });
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
const actor = getActorInfo(req);
|
|
497
|
+
if (req.body.proposal?.goalId) {
|
|
498
|
+
const goal = await goalsSvc.getById(req.body.proposal.goalId);
|
|
499
|
+
if (!goal || goal.orgId !== conversation.orgId) {
|
|
500
|
+
res.status(422).json({ error: "Goal must belong to the same organization" });
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
await assertCanConvertIssueProposal(req, conversation, {
|
|
505
|
+
messageId: req.body.messageId ?? null,
|
|
506
|
+
proposal: req.body.proposal ?? null,
|
|
507
|
+
});
|
|
508
|
+
const chatObservation = buildChatObservabilityContext(conversation, {
|
|
509
|
+
rootExecutionId: req.body.messageId ?? `chat-convert:${conversation.id}`,
|
|
510
|
+
trigger: "convert_to_issue",
|
|
511
|
+
metadata: {
|
|
512
|
+
source: "chat_route",
|
|
513
|
+
messageId: req.body.messageId ?? null,
|
|
514
|
+
},
|
|
515
|
+
});
|
|
516
|
+
const result = await withChatObservation(chatObservation, {
|
|
517
|
+
name: "chat:convert_to_issue",
|
|
518
|
+
asType: "tool",
|
|
519
|
+
input: {
|
|
520
|
+
conversationId: conversation.id,
|
|
521
|
+
messageId: req.body.messageId ?? null,
|
|
522
|
+
proposal: req.body.proposal ?? null,
|
|
523
|
+
},
|
|
524
|
+
}, async () => {
|
|
525
|
+
const issue = await svc.convertToIssue(conversation.id, {
|
|
526
|
+
actorUserId: actor.actorType === "user" ? actor.actorId : null,
|
|
527
|
+
messageId: req.body.messageId ?? null,
|
|
528
|
+
proposal: req.body.proposal ?? null,
|
|
529
|
+
});
|
|
530
|
+
const systemMessage = await svc.addMessage(conversation.id, {
|
|
531
|
+
orgId: conversation.orgId,
|
|
532
|
+
role: "system",
|
|
533
|
+
kind: "system_event",
|
|
534
|
+
body: `Created issue ${issue.identifier ?? issue.id} from this chat conversation.`,
|
|
535
|
+
structuredPayload: {
|
|
536
|
+
eventType: "issue_created",
|
|
537
|
+
issueId: issue.id,
|
|
538
|
+
issueIdentifier: issue.identifier,
|
|
539
|
+
},
|
|
540
|
+
});
|
|
541
|
+
await logActivity(db, {
|
|
542
|
+
orgId: conversation.orgId,
|
|
543
|
+
actorType: actor.actorType,
|
|
544
|
+
actorId: actor.actorId,
|
|
545
|
+
agentId: actor.agentId,
|
|
546
|
+
runId: actor.runId,
|
|
547
|
+
action: "chat.issue_converted",
|
|
548
|
+
entityType: "chat",
|
|
549
|
+
entityId: conversation.id,
|
|
550
|
+
details: {
|
|
551
|
+
issueId: issue.id,
|
|
552
|
+
issueIdentifier: issue.identifier,
|
|
553
|
+
messageId: req.body.messageId ?? null,
|
|
554
|
+
systemMessageId: systemMessage.id,
|
|
555
|
+
},
|
|
556
|
+
});
|
|
557
|
+
await emitChatObservationEvent(chatObservation, {
|
|
558
|
+
name: "chat.issue.created",
|
|
559
|
+
metadata: {
|
|
560
|
+
issueId: issue.id,
|
|
561
|
+
issueIdentifier: issue.identifier,
|
|
562
|
+
systemMessageId: systemMessage.id,
|
|
563
|
+
},
|
|
564
|
+
});
|
|
565
|
+
return { issue, systemMessage };
|
|
566
|
+
});
|
|
567
|
+
res.status(201).json(result);
|
|
568
|
+
});
|
|
569
|
+
router.post("/chats/:id/messages/:messageId/operation-proposal/resolve", validate(resolveChatOperationProposalSchema), async (req, res) => {
|
|
570
|
+
const conversation = await assertConversationAccess(req, req.params.id);
|
|
571
|
+
if (!conversation) {
|
|
572
|
+
res.status(404).json({ error: "Chat conversation not found" });
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
const actor = getActorInfo(req);
|
|
576
|
+
const messageId = req.params.messageId;
|
|
577
|
+
const chatObservation = buildChatObservabilityContext(conversation, {
|
|
578
|
+
rootExecutionId: messageId,
|
|
579
|
+
trigger: "resolve_operation_proposal",
|
|
580
|
+
metadata: {
|
|
581
|
+
action: req.body.action,
|
|
582
|
+
decisionNote: req.body.decisionNote ?? null,
|
|
583
|
+
},
|
|
584
|
+
});
|
|
585
|
+
const result = await withChatObservation(chatObservation, {
|
|
586
|
+
name: "chat:resolve_operation_proposal",
|
|
587
|
+
asType: "tool",
|
|
588
|
+
input: {
|
|
589
|
+
conversationId: conversation.id,
|
|
590
|
+
messageId,
|
|
591
|
+
action: req.body.action,
|
|
592
|
+
},
|
|
593
|
+
}, async () => {
|
|
594
|
+
const resolved = await svc.resolveOperationProposal(conversation.id, messageId, {
|
|
595
|
+
action: req.body.action,
|
|
596
|
+
actorUserId: actor.actorType === "user" ? actor.actorId : null,
|
|
597
|
+
decisionNote: req.body.decisionNote ?? null,
|
|
598
|
+
});
|
|
599
|
+
await emitChatObservationEvent(chatObservation, {
|
|
600
|
+
name: "chat.operation_proposal.resolved",
|
|
601
|
+
metadata: {
|
|
602
|
+
action: req.body.action,
|
|
603
|
+
messageId: resolved.message.id,
|
|
604
|
+
systemMessageId: resolved.systemMessage.id,
|
|
605
|
+
},
|
|
606
|
+
});
|
|
607
|
+
return resolved;
|
|
608
|
+
});
|
|
609
|
+
res.status(201).json(result);
|
|
610
|
+
});
|
|
611
|
+
router.post("/chats/:id/resolve", async (req, res) => {
|
|
612
|
+
const conversation = await assertConversationAccess(req, req.params.id);
|
|
613
|
+
if (!conversation) {
|
|
614
|
+
res.status(404).json({ error: "Chat conversation not found" });
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
const resolved = await svc.resolve(conversation.id);
|
|
618
|
+
const actor = getActorInfo(req);
|
|
619
|
+
await logActivity(db, {
|
|
620
|
+
orgId: conversation.orgId,
|
|
621
|
+
actorType: actor.actorType,
|
|
622
|
+
actorId: actor.actorId,
|
|
623
|
+
agentId: actor.agentId,
|
|
624
|
+
runId: actor.runId,
|
|
625
|
+
action: "chat.resolved",
|
|
626
|
+
entityType: "chat",
|
|
627
|
+
entityId: conversation.id,
|
|
628
|
+
});
|
|
629
|
+
res.json(resolved ? await assistantSvc.enrichConversation(resolved) : null);
|
|
630
|
+
});
|
|
631
|
+
router.post("/chats/:id/read", async (req, res) => {
|
|
632
|
+
const conversation = await assertConversationAccess(req, req.params.id);
|
|
633
|
+
if (!conversation) {
|
|
634
|
+
res.status(404).json({ error: "Chat conversation not found" });
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
const userId = boardUserId(req);
|
|
638
|
+
const state = await svc.markRead(conversation.id, conversation.orgId, userId);
|
|
639
|
+
res.status(201).json({
|
|
640
|
+
conversationId: conversation.id,
|
|
641
|
+
lastReadAt: state.lastReadAt,
|
|
642
|
+
});
|
|
643
|
+
});
|
|
644
|
+
router.post("/chats/:id/user-state", validate(updateChatConversationUserStateSchema), async (req, res) => {
|
|
645
|
+
const conversation = await assertConversationAccess(req, req.params.id);
|
|
646
|
+
if (!conversation) {
|
|
647
|
+
res.status(404).json({ error: "Chat conversation not found" });
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
const userId = boardUserId(req);
|
|
651
|
+
if (typeof req.body.pinned === "boolean") {
|
|
652
|
+
await svc.setPinned(conversation.id, conversation.orgId, userId, req.body.pinned);
|
|
653
|
+
}
|
|
654
|
+
if (typeof req.body.unread === "boolean") {
|
|
655
|
+
if (req.body.unread) {
|
|
656
|
+
await svc.markUnread(conversation.id, conversation.orgId, userId);
|
|
657
|
+
}
|
|
658
|
+
else {
|
|
659
|
+
await svc.markRead(conversation.id, conversation.orgId, userId);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
const refreshed = await svc.getById(conversation.id, userId);
|
|
663
|
+
res.json(await assistantSvc.enrichConversation(refreshed));
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
//# sourceMappingURL=chats.stream-routes.js.map
|