@rudderhq/server 0.7.11 → 0.7.13
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/register-api-routes.d.ts.map +1 -1
- package/dist/bootstrap/register-api-routes.js +1 -1
- package/dist/bootstrap/register-api-routes.js.map +1 -1
- package/dist/bootstrap/types.d.ts +12 -0
- package/dist/bootstrap/types.d.ts.map +1 -1
- package/dist/index.js +20 -5
- package/dist/index.js.map +1 -1
- package/dist/routes/agents.management-routes.d.ts.map +1 -1
- package/dist/routes/agents.management-routes.js +10 -2
- package/dist/routes/agents.management-routes.js.map +1 -1
- package/dist/routes/chats.d.ts +2 -1
- package/dist/routes/chats.d.ts.map +1 -1
- package/dist/routes/chats.js +377 -4
- package/dist/routes/chats.js.map +1 -1
- package/dist/routes/chats.stream-routes.d.ts.map +1 -1
- package/dist/routes/chats.stream-routes.js +55 -3
- package/dist/routes/chats.stream-routes.js.map +1 -1
- package/dist/routes/goals.d.ts.map +1 -1
- package/dist/routes/goals.js +34 -3
- package/dist/routes/goals.js.map +1 -1
- package/dist/routes/orgs.d.ts.map +1 -1
- package/dist/routes/orgs.js +22 -1
- package/dist/routes/orgs.js.map +1 -1
- package/dist/routes/run-intelligence.d.ts.map +1 -1
- package/dist/routes/run-intelligence.js +10 -0
- package/dist/routes/run-intelligence.js.map +1 -1
- package/dist/services/agent-instructions.d.ts +1 -0
- package/dist/services/agent-instructions.d.ts.map +1 -1
- package/dist/services/agent-instructions.js +124 -6
- package/dist/services/agent-instructions.js.map +1 -1
- package/dist/services/agent-issue-creation.d.ts +1 -1
- package/dist/services/agent-run-context.d.ts.map +1 -1
- package/dist/services/agent-run-context.js +15 -0
- package/dist/services/agent-run-context.js.map +1 -1
- package/dist/services/agent-startup-context.d.ts +4 -0
- package/dist/services/agent-startup-context.d.ts.map +1 -1
- package/dist/services/agent-startup-context.js +57 -13
- package/dist/services/agent-startup-context.js.map +1 -1
- package/dist/services/agents.d.ts +253 -0
- package/dist/services/agents.d.ts.map +1 -1
- package/dist/services/automations.d.ts.map +1 -1
- package/dist/services/automations.js +3 -0
- package/dist/services/automations.js.map +1 -1
- package/dist/services/chat-agent-runs.d.ts +48 -1
- package/dist/services/chat-agent-runs.d.ts.map +1 -1
- package/dist/services/chat-agent-runs.js +107 -3
- package/dist/services/chat-agent-runs.js.map +1 -1
- package/dist/services/chat-assistant.d.ts.map +1 -1
- package/dist/services/chat-assistant.helpers.d.ts +12 -3
- package/dist/services/chat-assistant.helpers.d.ts.map +1 -1
- package/dist/services/chat-assistant.helpers.js +6 -0
- package/dist/services/chat-assistant.helpers.js.map +1 -1
- package/dist/services/chat-assistant.js +54 -18
- package/dist/services/chat-assistant.js.map +1 -1
- package/dist/services/chat-generation-protocol.d.ts +119 -0
- package/dist/services/chat-generation-protocol.d.ts.map +1 -1
- package/dist/services/chat-generation-protocol.js +65 -0
- package/dist/services/chat-generation-protocol.js.map +1 -1
- package/dist/services/chats.constants.d.ts +1 -1
- package/dist/services/chats.constants.d.ts.map +1 -1
- package/dist/services/chats.constants.js +1 -0
- package/dist/services/chats.constants.js.map +1 -1
- package/dist/services/chats.d.ts +128 -0
- package/dist/services/chats.d.ts.map +1 -1
- package/dist/services/chats.js +10 -0
- package/dist/services/chats.js.map +1 -1
- package/dist/services/finance.d.ts +1 -1
- package/dist/services/goals.d.ts +47 -7
- package/dist/services/goals.d.ts.map +1 -1
- package/dist/services/goals.js +74 -33
- package/dist/services/goals.js.map +1 -1
- package/dist/services/heartbeat-run-reference.d.ts.map +1 -1
- package/dist/services/heartbeat-run-reference.js +11 -5
- package/dist/services/heartbeat-run-reference.js.map +1 -1
- package/dist/services/index.d.ts +2 -1
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +2 -1
- package/dist/services/index.js.map +1 -1
- package/dist/services/integrations/feishu/runtime.d.ts +8 -0
- package/dist/services/integrations/feishu/runtime.d.ts.map +1 -1
- package/dist/services/integrations/feishu/runtime.js +124 -1
- package/dist/services/integrations/feishu/runtime.js.map +1 -1
- package/dist/services/issue-assignment-wakeup.d.ts +1 -0
- package/dist/services/issue-assignment-wakeup.d.ts.map +1 -1
- package/dist/services/issue-assignment-wakeup.js +2 -0
- package/dist/services/issue-assignment-wakeup.js.map +1 -1
- package/dist/services/issues.d.ts +2 -2
- package/dist/services/issues.d.ts.map +1 -1
- package/dist/services/issues.helpers.d.ts +8 -0
- package/dist/services/issues.helpers.d.ts.map +1 -1
- package/dist/services/issues.helpers.js +17 -1
- package/dist/services/issues.helpers.js.map +1 -1
- package/dist/services/issues.js +108 -15
- package/dist/services/issues.js.map +1 -1
- package/dist/services/messenger.d.ts.map +1 -1
- package/dist/services/messenger.js +12 -3
- package/dist/services/messenger.js.map +1 -1
- package/dist/services/organization-members.d.ts +27 -0
- package/dist/services/organization-members.d.ts.map +1 -0
- package/dist/services/organization-members.js +169 -0
- package/dist/services/organization-members.js.map +1 -0
- package/dist/services/organization-workspace-browser.d.ts.map +1 -1
- package/dist/services/organization-workspace-browser.js +44 -10
- package/dist/services/organization-workspace-browser.js.map +1 -1
- package/dist/services/product-intelligence.d.ts.map +1 -1
- package/dist/services/product-intelligence.js +4 -0
- package/dist/services/product-intelligence.js.map +1 -1
- package/dist/services/projects.d.ts +2 -5
- package/dist/services/projects.d.ts.map +1 -1
- package/dist/services/projects.js +27 -2
- package/dist/services/projects.js.map +1 -1
- package/dist/services/rudder-plugin-catalog.d.ts +1 -1
- package/dist/services/rudder-plugin-catalog.d.ts.map +1 -1
- package/dist/services/rudder-plugin-catalog.js +281 -15
- package/dist/services/rudder-plugin-catalog.js.map +1 -1
- package/dist/services/rudder-plugin-catalog.test.js +55 -0
- package/dist/services/rudder-plugin-catalog.test.js.map +1 -1
- package/dist/services/run-intelligence.d.ts +1 -0
- package/dist/services/run-intelligence.d.ts.map +1 -1
- package/dist/services/run-intelligence.js +8 -1
- package/dist/services/run-intelligence.js.map +1 -1
- package/dist/services/run-log-store.d.ts +3 -0
- package/dist/services/run-log-store.d.ts.map +1 -1
- package/dist/services/run-log-store.js +124 -18
- package/dist/services/run-log-store.js.map +1 -1
- package/dist/services/runtime-kernel/assignment-run-guardrail.d.ts +2 -0
- package/dist/services/runtime-kernel/assignment-run-guardrail.d.ts.map +1 -1
- package/dist/services/runtime-kernel/assignment-run-guardrail.js +5 -3
- package/dist/services/runtime-kernel/assignment-run-guardrail.js.map +1 -1
- package/dist/services/runtime-kernel/assignment-run-guardrail.test.js +20 -0
- package/dist/services/runtime-kernel/assignment-run-guardrail.test.js.map +1 -1
- package/dist/services/runtime-kernel/heartbeat-attempt-ledger.d.ts +124 -0
- package/dist/services/runtime-kernel/heartbeat-attempt-ledger.d.ts.map +1 -0
- package/dist/services/runtime-kernel/heartbeat-attempt-ledger.js +108 -0
- package/dist/services/runtime-kernel/heartbeat-attempt-ledger.js.map +1 -0
- package/dist/services/runtime-kernel/heartbeat.core.d.ts +129 -0
- package/dist/services/runtime-kernel/heartbeat.core.d.ts.map +1 -1
- package/dist/services/runtime-kernel/heartbeat.core.js +15 -0
- package/dist/services/runtime-kernel/heartbeat.core.js.map +1 -1
- package/dist/services/runtime-kernel/heartbeat.d.ts +43 -0
- package/dist/services/runtime-kernel/heartbeat.d.ts.map +1 -1
- package/dist/services/runtime-kernel/heartbeat.execute.d.ts.map +1 -1
- package/dist/services/runtime-kernel/heartbeat.execute.js +229 -3
- package/dist/services/runtime-kernel/heartbeat.execute.js.map +1 -1
- package/dist/services/runtime-kernel/heartbeat.js +178 -6
- package/dist/services/runtime-kernel/heartbeat.js.map +1 -1
- package/dist/services/runtime-kernel/heartbeat.recovery.d.ts.map +1 -1
- package/dist/services/runtime-kernel/heartbeat.recovery.js +17 -1
- package/dist/services/runtime-kernel/heartbeat.recovery.js.map +1 -1
- package/dist/services/runtime-kernel/heartbeat.release.d.ts.map +1 -1
- package/dist/services/runtime-kernel/heartbeat.release.js +1 -0
- package/dist/services/runtime-kernel/heartbeat.release.js.map +1 -1
- package/dist/services/runtime-kernel/heartbeat.sessions.d.ts.map +1 -1
- package/dist/services/runtime-kernel/heartbeat.sessions.js +25 -5
- package/dist/services/runtime-kernel/heartbeat.sessions.js.map +1 -1
- package/dist/services/runtime-kernel/heartbeat.terminal.d.ts +56 -0
- package/dist/services/runtime-kernel/heartbeat.terminal.d.ts.map +1 -1
- package/dist/services/runtime-kernel/heartbeat.wakeup.d.ts.map +1 -1
- package/dist/services/runtime-kernel/heartbeat.wakeup.js +28 -0
- package/dist/services/runtime-kernel/heartbeat.wakeup.js.map +1 -1
- package/dist/services/runtime-kernel/model-fallback.d.ts +4 -0
- package/dist/services/runtime-kernel/model-fallback.d.ts.map +1 -1
- package/dist/services/runtime-kernel/model-fallback.js +25 -4
- package/dist/services/runtime-kernel/model-fallback.js.map +1 -1
- package/dist/services/workspace-backup-v2.d.ts +20 -0
- package/dist/services/workspace-backup-v2.d.ts.map +1 -1
- package/dist/services/workspace-backup-v2.js +155 -23
- package/dist/services/workspace-backup-v2.js.map +1 -1
- package/dist/services/workspace-backup-v2.test.js +34 -2
- package/dist/services/workspace-backup-v2.test.js.map +1 -1
- package/dist/services/workspace-backups.d.ts +0 -1
- package/dist/services/workspace-backups.d.ts.map +1 -1
- package/dist/services/workspace-backups.js +18 -19
- package/dist/services/workspace-backups.js.map +1 -1
- package/dist/services/workspace-manifest-native.d.ts +10 -0
- package/dist/services/workspace-manifest-native.d.ts.map +1 -0
- package/dist/services/workspace-manifest-native.js +219 -0
- package/dist/services/workspace-manifest-native.js.map +1 -0
- package/dist/services/workspace-restore-reconciliation.d.ts +11 -0
- package/dist/services/workspace-restore-reconciliation.d.ts.map +1 -0
- package/dist/services/workspace-restore-reconciliation.js +165 -0
- package/dist/services/workspace-restore-reconciliation.js.map +1 -0
- package/package.json +14 -14
- package/resources/bundled-skills/rudder-docs/references/api-reference.md +8 -0
- package/resources/bundled-skills/rudder-docs/references/cli-reference.md +6 -3
- package/skills/rudder-docs/references/api-reference.md +8 -0
- package/skills/rudder-docs/references/cli-reference.md +6 -3
- package/ui-dist/assets/LibraryLiveSurface-l4GUICoP.js +1 -0
- package/ui-dist/assets/{abnfDiagram-VRR7QNED-BggxrEZR.js → abnfDiagram-VRR7QNED-BLBjJ-cq.js} +1 -1
- package/ui-dist/assets/{addon-fit-Cc1gOtSX.js → addon-fit-BJjiE5UX.js} +1 -1
- package/ui-dist/assets/{arc-0kNrc9xt.js → arc-Cc8Cihbb.js} +1 -1
- package/ui-dist/assets/{architectureDiagram-ZJ3FMSHR-BOCa-5ab.js → architectureDiagram-ZJ3FMSHR--xCnNdhe.js} +1 -1
- package/ui-dist/assets/{blockDiagram-677ZJIJ3-CQU5jcsO.js → blockDiagram-677ZJIJ3-DRT2VAhQ.js} +1 -1
- package/ui-dist/assets/{c4Diagram-LMCZKHZV-ChgWIw5O.js → c4Diagram-LMCZKHZV-D88LDng_.js} +1 -1
- package/ui-dist/assets/channel-C5Hipz5u.js +1 -0
- package/ui-dist/assets/{chunk-2Q5K7J3B-B4yrwesI.js → chunk-2Q5K7J3B-Dz_vdT6U.js} +1 -1
- package/ui-dist/assets/{chunk-32BRIVSS-mhAeSMlR.js → chunk-32BRIVSS-DigOixDH.js} +1 -1
- package/ui-dist/assets/{chunk-5VM5RSS4-BmS_u59G.js → chunk-5VM5RSS4-C_1XAVwx.js} +1 -1
- package/ui-dist/assets/{chunk-EX3LRPZG-DXoTKkLG.js → chunk-EX3LRPZG-C6viraTj.js} +1 -1
- package/ui-dist/assets/{chunk-JWPE2WC7-Bj9myT03.js → chunk-JWPE2WC7-BCRBJeuJ.js} +1 -1
- package/ui-dist/assets/{chunk-MOJQB5TN-OAoJna8Y.js → chunk-MOJQB5TN-Cf1ATLhT.js} +1 -1
- package/ui-dist/assets/{chunk-RYQCIY6F-AGLA7TJn.js → chunk-RYQCIY6F-WltrJiTY.js} +1 -1
- package/ui-dist/assets/{chunk-V7JOEXUC-YGM2tDK2.js → chunk-V7JOEXUC-CA5tCSQF.js} +1 -1
- package/ui-dist/assets/{chunk-VR4S4FIN-DqaZn9Ty.js → chunk-VR4S4FIN-CEkOCBXH.js} +1 -1
- package/ui-dist/assets/{chunk-XXDRQBXY-Cpqn_8Bl.js → chunk-XXDRQBXY-CtrnGXIb.js} +1 -1
- package/ui-dist/assets/classDiagram-OUVF2IWQ-ClTHNkOu.js +1 -0
- package/ui-dist/assets/classDiagram-v2-EOCWNBFH-ClTHNkOu.js +1 -0
- package/ui-dist/assets/{cose-bilkent-JH36ORCC-BVe-X26w.js → cose-bilkent-JH36ORCC-CByYAK4l.js} +1 -1
- package/ui-dist/assets/{cynefin-VYW2F7L2-DlDrrBWp.js → cynefin-VYW2F7L2-_sCXFLWX.js} +1 -1
- package/ui-dist/assets/{cynefinDiagram-TSTJHNR4-BSHvFeGh.js → cynefinDiagram-TSTJHNR4-CFeFfsqk.js} +1 -1
- package/ui-dist/assets/{dagre-VKFMJZFB-tUm70k9h.js → dagre-VKFMJZFB-Bqod3KpP.js} +1 -1
- package/ui-dist/assets/{diagram-FQU43EPY-C5kjITq7.js → diagram-FQU43EPY-BfvoZqSk.js} +1 -1
- package/ui-dist/assets/{diagram-G47NLZAW-BrbHgt8r.js → diagram-G47NLZAW-BXbnKoJ9.js} +1 -1
- package/ui-dist/assets/{diagram-NH7WQ7WH-DT7PdghT.js → diagram-NH7WQ7WH-DzyI0L8P.js} +1 -1
- package/ui-dist/assets/{diagram-OA4YK3LP-wOjhRHRo.js → diagram-OA4YK3LP-DTMuvqry.js} +1 -1
- package/ui-dist/assets/{diagram-WEI45ONY-Dz9vtaDT.js → diagram-WEI45ONY-CAzeoFPA.js} +1 -1
- package/ui-dist/assets/{ebnfDiagram-CCIWWBDH-BT5TzIA6.js → ebnfDiagram-CCIWWBDH-CV731d_d.js} +1 -1
- package/ui-dist/assets/{erDiagram-Q63AITRT-DLCpoOEP.js → erDiagram-Q63AITRT-X1TOS4Ka.js} +1 -1
- package/ui-dist/assets/{flowDiagram-23GEKE2U-DfF2COjh.js → flowDiagram-23GEKE2U-DVrBhhZN.js} +1 -1
- package/ui-dist/assets/{ganttDiagram-NO4QXBWP-1d0KDwQs.js → ganttDiagram-NO4QXBWP-Bu2bat7s.js} +1 -1
- package/ui-dist/assets/{gitGraphDiagram-IHSO6WYX-COLjS1ZR.js → gitGraphDiagram-IHSO6WYX-BACGK4uh.js} +1 -1
- package/ui-dist/assets/{graph-B7fcgpw_.js → graph-DBmSffWh.js} +1 -1
- package/ui-dist/assets/{index-DTc5LpTU.js → index-37d7mmQR.js} +1 -1
- package/ui-dist/assets/{index-DttnaNlV.js → index-BJLMZ-lO.js} +542 -543
- package/ui-dist/assets/{index-CTIfCQqR.js → index-BM89NC7H.js} +1 -1
- package/ui-dist/assets/{index-COLwjKBR.js → index-BlzBPtLA.js} +1 -1
- package/ui-dist/assets/{index-CXg1YCeI.js → index-C7oAJP9-.js} +1 -1
- package/ui-dist/assets/index-CPP8apmO.css +32 -0
- package/ui-dist/assets/{index-CZYXpHv4.js → index-CY63mXIN.js} +1 -1
- package/ui-dist/assets/{index-CgkYyYx9.js → index-CqrPtttL.js} +1 -1
- package/ui-dist/assets/{index-CMNULCMJ.js → index-D8VjtybU.js} +1 -1
- package/ui-dist/assets/{index-CH8I9acP.js → index-DsjgdWi0.js} +1 -1
- package/ui-dist/assets/{index-CbqgXGcs.js → index-Qr_boV5N.js} +1 -1
- package/ui-dist/assets/{index-B6zSdXAR.js → index-SBaOrW31.js} +1 -1
- package/ui-dist/assets/{index-D27Bbc-x.js → index-jawM4Mw8.js} +1 -1
- package/ui-dist/assets/{index-BczgTMAn.js → index-juSeEYHt.js} +1 -1
- package/ui-dist/assets/{index-Denv6wuU.js → index-qSO_9tQ4.js} +1 -1
- package/ui-dist/assets/{index-vtghjwab.js → index-sPs1blcu.js} +1 -1
- package/ui-dist/assets/{infoDiagram-FWYZ7A6U-Bg4YQUu2.js → infoDiagram-FWYZ7A6U-DsKiGJG2.js} +1 -1
- package/ui-dist/assets/{ishikawaDiagram-FXEZZL3T-BtgUVI_I.js → ishikawaDiagram-FXEZZL3T-qFWBzEXh.js} +1 -1
- package/ui-dist/assets/{journeyDiagram-5HDEW3XC-BGHGjvN4.js → journeyDiagram-5HDEW3XC-CzXYTAgD.js} +1 -1
- package/ui-dist/assets/{kanban-definition-HUTT4EX6-DekQSNo8.js → kanban-definition-HUTT4EX6-BCz-L1fU.js} +1 -1
- package/ui-dist/assets/{layout-Bsw9hK6u.js → layout-YfTyU1_8.js} +1 -1
- package/ui-dist/assets/{linear-D8D1R-4C.js → linear-Cmr3155j.js} +1 -1
- package/ui-dist/assets/{map-BUIcuf4c.js → map-Cd3zkWna.js} +1 -1
- package/ui-dist/assets/{mermaid.core-CYZMLemV.js → mermaid.core-B0LpeiXb.js} +4 -4
- package/ui-dist/assets/{mindmap-definition-LN4V7U3C-mjS9avIS.js → mindmap-definition-LN4V7U3C-53OklQRn.js} +1 -1
- package/ui-dist/assets/{pegDiagram-2B236MQR-Buziry9m.js → pegDiagram-2B236MQR-Dm_aMKAy.js} +1 -1
- package/ui-dist/assets/{pieDiagram-ENE6RG2P-B_9BmFEg.js → pieDiagram-ENE6RG2P-X7GdM_uO.js} +1 -1
- package/ui-dist/assets/{quadrantDiagram-ABIIQ3AL-BxFdUA8s.js → quadrantDiagram-ABIIQ3AL-CwNrCyye.js} +1 -1
- package/ui-dist/assets/{railroadDiagram-RFXS5EU6-pJh_afC-.js → railroadDiagram-RFXS5EU6-qeA8AyXg.js} +1 -1
- package/ui-dist/assets/{requirementDiagram-TGXJPOKE-BGgk3AxL.js → requirementDiagram-TGXJPOKE-CbTV3-mv.js} +1 -1
- package/ui-dist/assets/{sankeyDiagram-HTMAVEWB-DdPKE4bs.js → sankeyDiagram-HTMAVEWB-Cb2FZniK.js} +1 -1
- package/ui-dist/assets/{sequenceDiagram-DBY2YBRQ-xlik6FjZ.js → sequenceDiagram-DBY2YBRQ-43rfMbK2.js} +1 -1
- package/ui-dist/assets/{sizeCapture-X5ZJPWSS-D_zKAjvf.js → sizeCapture-X5ZJPWSS-kd6mcpBA.js} +1 -1
- package/ui-dist/assets/{stateDiagram-2N3HPSRC-BGQP8giG.js → stateDiagram-2N3HPSRC-DVpqAreh.js} +1 -1
- package/ui-dist/assets/stateDiagram-v2-6OUMAXLB-CD2jPBKH.js +1 -0
- package/ui-dist/assets/{swimlanes-5IMT3BWC-ZhE8oAxR.js → swimlanes-5IMT3BWC-Cpgu2cLX.js} +2 -2
- package/ui-dist/assets/swimlanesDiagram-G3AALYLV-CwSF2io0.js +8 -0
- package/ui-dist/assets/{timeline-definition-FHXFAJF6-CUqfijnL.js → timeline-definition-FHXFAJF6-BXgN1EJb.js} +1 -1
- package/ui-dist/assets/{vennDiagram-L72KCM5P-B_rqTUA0.js → vennDiagram-L72KCM5P-ZFEGgsAk.js} +1 -1
- package/ui-dist/assets/{wardleyDiagram-EHGQE667-BTvjybDi.js → wardleyDiagram-EHGQE667-DrxFJODe.js} +1 -1
- package/ui-dist/assets/{xterm-CRpDYL2s.js → xterm-DeUtt-wP.js} +1 -1
- package/ui-dist/assets/{xychartDiagram-FW5EYKEG-ZBbwueZ5.js → xychartDiagram-FW5EYKEG-BNcvHMPz.js} +1 -1
- package/ui-dist/index.html +2 -2
- package/ui-dist/assets/LibraryLiveSurface-De1p59PK.js +0 -1
- package/ui-dist/assets/channel-eAoWqZqJ.js +0 -1
- package/ui-dist/assets/classDiagram-OUVF2IWQ-c94PI6yY.js +0 -1
- package/ui-dist/assets/classDiagram-v2-EOCWNBFH-c94PI6yY.js +0 -1
- package/ui-dist/assets/index-RSbihTRP.css +0 -32
- package/ui-dist/assets/stateDiagram-v2-6OUMAXLB-BMEtuB93.js +0 -1
- package/ui-dist/assets/swimlanesDiagram-G3AALYLV-Bdh18WfM.js +0 -8
package/dist/routes/chats.js
CHANGED
|
@@ -18,6 +18,7 @@ import { buildChatTitlePromptFromMessages, chatTitleGenerationService, } from ".
|
|
|
18
18
|
import { chatWorkManifestService } from "../services/chat-work-manifest.js";
|
|
19
19
|
import { validateCron } from "../services/cron.js";
|
|
20
20
|
import { accessService, agentService, automationService, chatService, goalService, heartbeatService, issueService, logActivity, operatorProfileService, organizationService, productIntelligenceService, projectService, sideChatService, } from "../services/index.js";
|
|
21
|
+
import { NETWORK_WAIT_EXHAUSTED_ERROR, NETWORK_WAIT_EXHAUSTED_ERROR_CODE, NETWORK_WAIT_UNSAFE_ERROR_CODE, } from "../services/runtime-kernel/heartbeat.core.js";
|
|
21
22
|
import { runtimeResultText, sanitizeGeneratedTitle, } from "../services/title-generation.js";
|
|
22
23
|
import { assertBoard, assertCompanyAccess, getActorInfo, getAuthorizedOrgScope } from "./authz.js";
|
|
23
24
|
import { createChatBackgroundRuntime, } from "./chat-background-runtime.js";
|
|
@@ -33,7 +34,7 @@ function chatVisibleOutputAdmissionClosed(error) {
|
|
|
33
34
|
&& error.status === 409
|
|
34
35
|
&& error.message === "Chat-visible output admission is closed for this generation";
|
|
35
36
|
}
|
|
36
|
-
export function chatRoutes(db, storage, backgroundRuntime = createChatBackgroundRuntime()) {
|
|
37
|
+
export function chatRoutes(db, storage, backgroundRuntime = createChatBackgroundRuntime(), registerNetworkWaitingRunHandler) {
|
|
37
38
|
const router = Router();
|
|
38
39
|
const svc = chatService(db);
|
|
39
40
|
const organizationsSvc = organizationService(db);
|
|
@@ -47,7 +48,14 @@ export function chatRoutes(db, storage, backgroundRuntime = createChatBackground
|
|
|
47
48
|
const chatRunsSvc = chatAgentRunService(db);
|
|
48
49
|
const workManifestSvc = chatWorkManifestService(db);
|
|
49
50
|
const operatorProfiles = operatorProfileService(db);
|
|
50
|
-
|
|
51
|
+
let recoverNetworkWaitingChatRun = null;
|
|
52
|
+
const heartbeat = heartbeatService(db, {
|
|
53
|
+
onNetworkWaitingRun: async (run) => {
|
|
54
|
+
if (!recoverNetworkWaitingChatRun)
|
|
55
|
+
return false;
|
|
56
|
+
return recoverNetworkWaitingChatRun(run);
|
|
57
|
+
},
|
|
58
|
+
});
|
|
51
59
|
const productIntelligence = productIntelligenceService(db);
|
|
52
60
|
const chatTitles = chatTitleGenerationService({ chats: svc, productIntelligence });
|
|
53
61
|
const steerMessages = chatSteerMessageService(db);
|
|
@@ -1107,6 +1115,7 @@ export function chatRoutes(db, storage, backgroundRuntime = createChatBackground
|
|
|
1107
1115
|
userMessageId: userMessage.id,
|
|
1108
1116
|
chatTurnId: turnContext.chatTurnId,
|
|
1109
1117
|
turnVariant: turnContext.turnVariant,
|
|
1118
|
+
runContext: { chatGenerationId: claim.generationId },
|
|
1110
1119
|
stream: false,
|
|
1111
1120
|
abortSignal: abortController.signal,
|
|
1112
1121
|
controlCoordinator: createChatRuntimeControlCoordinator(conversation.id, claim.generationId, {
|
|
@@ -1212,6 +1221,11 @@ export function chatRoutes(db, storage, backgroundRuntime = createChatBackground
|
|
|
1212
1221
|
});
|
|
1213
1222
|
}
|
|
1214
1223
|
}
|
|
1224
|
+
else if (streamed.outcome === "waiting_for_network") {
|
|
1225
|
+
// The durable generation remains open; the background recovery path
|
|
1226
|
+
// will reattach and project the eventual assistant result.
|
|
1227
|
+
return;
|
|
1228
|
+
}
|
|
1215
1229
|
else {
|
|
1216
1230
|
let completionMessageId = null;
|
|
1217
1231
|
try {
|
|
@@ -1323,6 +1337,353 @@ export function chatRoutes(db, storage, backgroundRuntime = createChatBackground
|
|
|
1323
1337
|
managedAbort.release();
|
|
1324
1338
|
}
|
|
1325
1339
|
}
|
|
1340
|
+
/** Resume a Chat generation that the heartbeat coordinator woke from a
|
|
1341
|
+
* durable network wait. This path deliberately shares the existing
|
|
1342
|
+
* generation/run rows instead of creating a second active Chat run. */
|
|
1343
|
+
async function runRecoveredNetworkWaitingChatRun(run) {
|
|
1344
|
+
const context = run.contextSnapshot && typeof run.contextSnapshot === "object"
|
|
1345
|
+
&& !Array.isArray(run.contextSnapshot)
|
|
1346
|
+
? run.contextSnapshot
|
|
1347
|
+
: {};
|
|
1348
|
+
const conversationId = run.chatConversationId
|
|
1349
|
+
?? (typeof context.conversationId === "string" ? context.conversationId : null);
|
|
1350
|
+
const generationId = typeof context.chatGenerationId === "string"
|
|
1351
|
+
? context.chatGenerationId
|
|
1352
|
+
: null;
|
|
1353
|
+
const nonStreamChatRun = context.chatMode === "non_stream";
|
|
1354
|
+
const userMessageId = typeof context.userMessageId === "string"
|
|
1355
|
+
? context.userMessageId
|
|
1356
|
+
: typeof context.messageId === "string"
|
|
1357
|
+
? context.messageId
|
|
1358
|
+
: null;
|
|
1359
|
+
const ownerToken = typeof run.executionOwnerToken === "string" ? run.executionOwnerToken : null;
|
|
1360
|
+
if (!conversationId || (!generationId && !nonStreamChatRun) || !userMessageId || !ownerToken) {
|
|
1361
|
+
logger.error({ runId: run.id }, "network-wait Chat run is missing recovery context");
|
|
1362
|
+
return false;
|
|
1363
|
+
}
|
|
1364
|
+
const conversation = await svc.getById(conversationId);
|
|
1365
|
+
const userMessage = conversation
|
|
1366
|
+
? await svc.getMessage(conversation.id, userMessageId)
|
|
1367
|
+
: null;
|
|
1368
|
+
if (!conversation || !userMessage) {
|
|
1369
|
+
logger.error({ runId: run.id, conversationId, generationId }, "network-wait Chat recovery target is missing");
|
|
1370
|
+
return false;
|
|
1371
|
+
}
|
|
1372
|
+
const abortController = new AbortController();
|
|
1373
|
+
const managedAbort = backgroundRuntime.manageAbortController(abortController);
|
|
1374
|
+
const releaseGeneration = claimChatGeneration(conversation.id, abortController, generationId);
|
|
1375
|
+
if (!releaseGeneration) {
|
|
1376
|
+
managedAbort.release();
|
|
1377
|
+
return true;
|
|
1378
|
+
}
|
|
1379
|
+
const request = requestForQueuedActor({
|
|
1380
|
+
type: "board",
|
|
1381
|
+
source: "local_implicit",
|
|
1382
|
+
userId: "local-board",
|
|
1383
|
+
isInstanceAdmin: true,
|
|
1384
|
+
}, conversation.orgId);
|
|
1385
|
+
const actor = getActorInfo(request);
|
|
1386
|
+
let assistantConversation = conversation;
|
|
1387
|
+
let activeAttemptEpoch = Math.max(1, Number(context.attemptEpoch) || 1);
|
|
1388
|
+
let activeChatRunId = run.id;
|
|
1389
|
+
let partialBody = "";
|
|
1390
|
+
let assistantProjectionMessageId = null;
|
|
1391
|
+
let transcript = [];
|
|
1392
|
+
let terminalStatus = "failed";
|
|
1393
|
+
let terminalReason = null;
|
|
1394
|
+
let waitingAgain = false;
|
|
1395
|
+
const isTerminalGenerationStatus = (status) => [
|
|
1396
|
+
"stop_requested",
|
|
1397
|
+
"stopping",
|
|
1398
|
+
"completed",
|
|
1399
|
+
"failed",
|
|
1400
|
+
"stopped",
|
|
1401
|
+
"aborted",
|
|
1402
|
+
"interrupted_unverified",
|
|
1403
|
+
"control_lost",
|
|
1404
|
+
].includes(status);
|
|
1405
|
+
const finishRecoveryWithoutProvider = async (status, reason) => {
|
|
1406
|
+
terminalStatus = ["stop_requested", "stopping", "stopped"].includes(status)
|
|
1407
|
+
? "stopped"
|
|
1408
|
+
: "failed";
|
|
1409
|
+
terminalReason = reason ?? (terminalStatus === "stopped" ? "operator_stop" : "generation_terminal_before_recovery");
|
|
1410
|
+
await chatRunsSvc.finalizeRun(run.id, {
|
|
1411
|
+
status: "cancelled",
|
|
1412
|
+
error: terminalReason,
|
|
1413
|
+
errorCode: terminalStatus === "stopped" ? "chat_run_cancelled" : "chat_generation_already_terminal",
|
|
1414
|
+
}).catch((error) => {
|
|
1415
|
+
logger.warn({ err: error, runId: run.id }, "failed to finalize Chat run after recovery race");
|
|
1416
|
+
});
|
|
1417
|
+
return true;
|
|
1418
|
+
};
|
|
1419
|
+
try {
|
|
1420
|
+
if (generationId) {
|
|
1421
|
+
const frozen = await svc.generationProtocol.getFrozenVisibleProjection({
|
|
1422
|
+
orgId: conversation.orgId,
|
|
1423
|
+
conversationId: conversation.id,
|
|
1424
|
+
generationId,
|
|
1425
|
+
});
|
|
1426
|
+
partialBody = frozen.projection.body;
|
|
1427
|
+
assistantProjectionMessageId = frozen.projection.assistantMessageId;
|
|
1428
|
+
transcript = [...frozen.projection.transcript];
|
|
1429
|
+
activeAttemptEpoch = Math.max(1, frozen.generation.attemptEpoch);
|
|
1430
|
+
const recoveryFailure = run.networkRecoveryFailure
|
|
1431
|
+
?? (run.networkRecoveryExhausted
|
|
1432
|
+
? {
|
|
1433
|
+
errorCode: NETWORK_WAIT_EXHAUSTED_ERROR_CODE,
|
|
1434
|
+
error: NETWORK_WAIT_EXHAUSTED_ERROR,
|
|
1435
|
+
}
|
|
1436
|
+
: null);
|
|
1437
|
+
if (isTerminalGenerationStatus(frozen.generation.status)) {
|
|
1438
|
+
return finishRecoveryWithoutProvider(frozen.generation.status, frozen.generation.terminalReason);
|
|
1439
|
+
}
|
|
1440
|
+
if (!recoveryFailure) {
|
|
1441
|
+
const resumedGeneration = await svc.generationProtocol.markNetworkResumed({
|
|
1442
|
+
orgId: conversation.orgId,
|
|
1443
|
+
conversationId: conversation.id,
|
|
1444
|
+
generationId,
|
|
1445
|
+
expectedAttemptEpoch: activeAttemptEpoch,
|
|
1446
|
+
});
|
|
1447
|
+
if (isTerminalGenerationStatus(resumedGeneration.status)) {
|
|
1448
|
+
return finishRecoveryWithoutProvider(resumedGeneration.status, resumedGeneration.terminalReason);
|
|
1449
|
+
}
|
|
1450
|
+
const latestGeneration = await svc.getLatestGeneration(conversation.id).catch(() => null);
|
|
1451
|
+
if (latestGeneration?.id === generationId && isTerminalGenerationStatus(latestGeneration.status)) {
|
|
1452
|
+
return finishRecoveryWithoutProvider(latestGeneration.status, latestGeneration.terminalReason);
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
if (recoveryFailure) {
|
|
1456
|
+
throw new ChatAssistantStreamError(recoveryFailure.error, partialBody, [], {
|
|
1457
|
+
errorCode: recoveryFailure.errorCode,
|
|
1458
|
+
userMessage: recoveryFailure.errorCode === NETWORK_WAIT_UNSAFE_ERROR_CODE
|
|
1459
|
+
? "Network recovery could not safely resume this reply. Check connectivity, then retry this reply."
|
|
1460
|
+
: "Network recovery retries were exhausted. Check connectivity, then retry this reply.",
|
|
1461
|
+
retryable: true,
|
|
1462
|
+
failurePhase: "model_generation",
|
|
1463
|
+
action: "retry",
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
const turnContext = turnContextFromUserMessage(userMessage);
|
|
1468
|
+
const assistantInput = await loadAssistantInput(conversation, actor);
|
|
1469
|
+
assistantConversation = assistantInput.conversation;
|
|
1470
|
+
const controlCoordinator = generationId
|
|
1471
|
+
? createChatRuntimeControlCoordinator(conversation.id, generationId, {
|
|
1472
|
+
onAttemptStarted: async ({ generationId: currentGenerationId, attemptEpoch, ownerToken: attemptOwnerToken, attempt }) => {
|
|
1473
|
+
activeAttemptEpoch = attemptEpoch;
|
|
1474
|
+
await svc.beginGenerationControlAttempt({
|
|
1475
|
+
orgId: conversation.orgId,
|
|
1476
|
+
conversationId: conversation.id,
|
|
1477
|
+
generationId: currentGenerationId,
|
|
1478
|
+
attemptEpoch,
|
|
1479
|
+
ownerToken: attemptOwnerToken,
|
|
1480
|
+
runtimeType: attempt.runtimeType,
|
|
1481
|
+
});
|
|
1482
|
+
},
|
|
1483
|
+
onHandleRegistered: async ({ generationId: currentGenerationId, attemptEpoch, ownerToken: attemptOwnerToken, handle }) => {
|
|
1484
|
+
await svc.markGenerationControlReady({
|
|
1485
|
+
generationId: currentGenerationId,
|
|
1486
|
+
attemptEpoch,
|
|
1487
|
+
ownerToken: attemptOwnerToken,
|
|
1488
|
+
runtimeType: handle.runtimeType,
|
|
1489
|
+
providerThreadId: handle.providerThreadId ?? null,
|
|
1490
|
+
providerTurnId: handle.providerTurnId ?? null,
|
|
1491
|
+
});
|
|
1492
|
+
},
|
|
1493
|
+
onAttemptLeaseRenewed: async ({ generationId: currentGenerationId, attemptEpoch, ownerToken: attemptOwnerToken }) => {
|
|
1494
|
+
await svc.renewGenerationControlLease({
|
|
1495
|
+
generationId: currentGenerationId,
|
|
1496
|
+
attemptEpoch,
|
|
1497
|
+
ownerToken: attemptOwnerToken,
|
|
1498
|
+
});
|
|
1499
|
+
},
|
|
1500
|
+
onAttemptCompleted: async ({ generationId: currentGenerationId, attemptEpoch, ownerToken: attemptOwnerToken }) => {
|
|
1501
|
+
await svc.markGenerationControlAttemptCompleted({
|
|
1502
|
+
generationId: currentGenerationId,
|
|
1503
|
+
attemptEpoch,
|
|
1504
|
+
ownerToken: attemptOwnerToken,
|
|
1505
|
+
});
|
|
1506
|
+
},
|
|
1507
|
+
})
|
|
1508
|
+
: undefined;
|
|
1509
|
+
const streamed = await assistantSvc.streamChatAssistantReply({
|
|
1510
|
+
...assistantInput,
|
|
1511
|
+
userMessageId: userMessage.id,
|
|
1512
|
+
chatTurnId: turnContext.chatTurnId,
|
|
1513
|
+
turnVariant: turnContext.turnVariant,
|
|
1514
|
+
runContext: { chatGenerationId: generationId },
|
|
1515
|
+
resumeRunId: run.id,
|
|
1516
|
+
resumeRunOwnerToken: ownerToken,
|
|
1517
|
+
stream: false,
|
|
1518
|
+
abortSignal: abortController.signal,
|
|
1519
|
+
controlCoordinator,
|
|
1520
|
+
onRunCreated: (recoveredRunId) => {
|
|
1521
|
+
activeChatRunId = recoveredRunId;
|
|
1522
|
+
},
|
|
1523
|
+
onWaitingForNetwork: async (suspension) => {
|
|
1524
|
+
if (!generationId) {
|
|
1525
|
+
waitingAgain = true;
|
|
1526
|
+
return;
|
|
1527
|
+
}
|
|
1528
|
+
const marked = await svc.generationProtocol.markWaitingForNetwork({
|
|
1529
|
+
orgId: conversation.orgId,
|
|
1530
|
+
conversationId: conversation.id,
|
|
1531
|
+
generationId,
|
|
1532
|
+
expectedAttemptEpoch: activeAttemptEpoch,
|
|
1533
|
+
suspension: suspension,
|
|
1534
|
+
});
|
|
1535
|
+
if (marked.stopped) {
|
|
1536
|
+
terminalStatus = "stopped";
|
|
1537
|
+
terminalReason = "operator_stop";
|
|
1538
|
+
if (!abortController.signal.aborted)
|
|
1539
|
+
abortController.abort();
|
|
1540
|
+
return;
|
|
1541
|
+
}
|
|
1542
|
+
waitingAgain = true;
|
|
1543
|
+
},
|
|
1544
|
+
onAssistantDelta: async (delta) => {
|
|
1545
|
+
if (abortController.signal.aborted)
|
|
1546
|
+
return;
|
|
1547
|
+
const projectedBody = `${partialBody}${delta}`;
|
|
1548
|
+
if (!generationId) {
|
|
1549
|
+
partialBody = projectedBody;
|
|
1550
|
+
return;
|
|
1551
|
+
}
|
|
1552
|
+
const projection = await svc.generationProtocol.appendVisibleEventAndProject({
|
|
1553
|
+
orgId: conversation.orgId,
|
|
1554
|
+
conversationId: conversation.id,
|
|
1555
|
+
generationId,
|
|
1556
|
+
expectedAttemptEpoch: activeAttemptEpoch,
|
|
1557
|
+
eventKind: "assistant_delta",
|
|
1558
|
+
payload: { delta },
|
|
1559
|
+
bodyOffset: partialBody.length,
|
|
1560
|
+
bodyLength: delta.length,
|
|
1561
|
+
messageId: assistantProjectionMessageId,
|
|
1562
|
+
runId: activeChatRunId,
|
|
1563
|
+
bodyHash: hashChatGenerationBody(projectedBody),
|
|
1564
|
+
body: projectedBody,
|
|
1565
|
+
replyingAgentId: chatReplyingAgentId(assistantConversation),
|
|
1566
|
+
chatTurnId: turnContext.chatTurnId,
|
|
1567
|
+
turnVariant: turnContext.turnVariant,
|
|
1568
|
+
});
|
|
1569
|
+
assistantProjectionMessageId = projection.message.id;
|
|
1570
|
+
partialBody = projectedBody;
|
|
1571
|
+
},
|
|
1572
|
+
onTranscriptEntry: async (entry) => {
|
|
1573
|
+
if (abortController.signal.aborted)
|
|
1574
|
+
return;
|
|
1575
|
+
transcript.push(entry);
|
|
1576
|
+
if (!generationId)
|
|
1577
|
+
return;
|
|
1578
|
+
const projection = await svc.generationProtocol.appendVisibleEventAndProject({
|
|
1579
|
+
orgId: conversation.orgId,
|
|
1580
|
+
conversationId: conversation.id,
|
|
1581
|
+
generationId,
|
|
1582
|
+
expectedAttemptEpoch: activeAttemptEpoch,
|
|
1583
|
+
eventKind: "transcript",
|
|
1584
|
+
payload: { entry },
|
|
1585
|
+
messageId: assistantProjectionMessageId,
|
|
1586
|
+
runId: activeChatRunId,
|
|
1587
|
+
bodyHash: hashChatGenerationBody(partialBody),
|
|
1588
|
+
body: partialBody,
|
|
1589
|
+
replyingAgentId: chatReplyingAgentId(assistantConversation),
|
|
1590
|
+
chatTurnId: turnContext.chatTurnId,
|
|
1591
|
+
turnVariant: turnContext.turnVariant,
|
|
1592
|
+
});
|
|
1593
|
+
assistantProjectionMessageId = projection.message.id;
|
|
1594
|
+
},
|
|
1595
|
+
});
|
|
1596
|
+
partialBody = streamed.partialBody || partialBody;
|
|
1597
|
+
if (waitingAgain || streamed.outcome === "waiting_for_network")
|
|
1598
|
+
return true;
|
|
1599
|
+
if (abortController.signal.aborted || streamed.outcome === "stopped") {
|
|
1600
|
+
terminalStatus = "stopped";
|
|
1601
|
+
terminalReason = "operator_stop";
|
|
1602
|
+
const stoppedMessage = await persistPartialAssistantMessage(assistantConversation, partialBody, "stopped", turnContext, transcript, streamed.replyingAgentId, assistantProjectionMessageId, activeChatRunId, undefined, false);
|
|
1603
|
+
if (stoppedMessage) {
|
|
1604
|
+
await linkChatRunMessages(assistantConversation, activeChatRunId, [stoppedMessage]);
|
|
1605
|
+
await logChatMessagesAdded(assistantConversation, [stoppedMessage], {
|
|
1606
|
+
actorType: "system",
|
|
1607
|
+
actorId: "chat-assistant",
|
|
1608
|
+
agentId: streamed.replyingAgentId,
|
|
1609
|
+
});
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
else {
|
|
1613
|
+
const completionMessageId = generationId
|
|
1614
|
+
? (await svc.generationProtocol.appendVisibleEventAndProject({
|
|
1615
|
+
orgId: conversation.orgId,
|
|
1616
|
+
conversationId: conversation.id,
|
|
1617
|
+
generationId,
|
|
1618
|
+
expectedAttemptEpoch: activeAttemptEpoch,
|
|
1619
|
+
eventKind: "runtime_output",
|
|
1620
|
+
payload: { resultKind: streamed.reply.kind, body: streamed.reply.body },
|
|
1621
|
+
bodyOffset: 0,
|
|
1622
|
+
bodyLength: streamed.reply.body.length,
|
|
1623
|
+
messageId: assistantProjectionMessageId,
|
|
1624
|
+
runId: activeChatRunId,
|
|
1625
|
+
bodyHash: hashChatGenerationBody(streamed.reply.body),
|
|
1626
|
+
body: streamed.reply.body,
|
|
1627
|
+
replyingAgentId: streamed.replyingAgentId,
|
|
1628
|
+
chatTurnId: turnContext.chatTurnId,
|
|
1629
|
+
turnVariant: turnContext.turnVariant,
|
|
1630
|
+
})).message.id
|
|
1631
|
+
: null;
|
|
1632
|
+
const createdMessages = await persistAssistantReply(request, assistantConversation, actor, streamed.reply, turnContext, transcript, streamed.replyingAgentId, completionMessageId, activeChatRunId, false);
|
|
1633
|
+
await linkChatRunMessages(assistantConversation, activeChatRunId, createdMessages);
|
|
1634
|
+
await logChatMessagesAdded(assistantConversation, createdMessages, {
|
|
1635
|
+
actorType: "system",
|
|
1636
|
+
actorId: "chat-assistant",
|
|
1637
|
+
agentId: streamed.replyingAgentId,
|
|
1638
|
+
});
|
|
1639
|
+
terminalStatus = "completed";
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
catch (error) {
|
|
1643
|
+
terminalStatus = abortController.signal.aborted ? "aborted" : "failed";
|
|
1644
|
+
terminalReason = error instanceof Error ? error.message : "network_wait_chat_recovery_failed";
|
|
1645
|
+
const failurePayload = recoverableFailurePayload(error, activeChatRunId);
|
|
1646
|
+
const failureBody = userVisiblePartialBodyFromError(error)
|
|
1647
|
+
|| recoverableFailureBody(failurePayload)
|
|
1648
|
+
|| CHAT_ASSISTANT_USER_ERROR_MESSAGE;
|
|
1649
|
+
const failedMessage = await persistPartialAssistantMessage(assistantConversation, failureBody, "failed", null, transcript, chatReplyingAgentId(assistantConversation), assistantProjectionMessageId, activeChatRunId, failurePayload, false).catch(() => null);
|
|
1650
|
+
if (failedMessage) {
|
|
1651
|
+
await linkChatRunMessages(assistantConversation, activeChatRunId, [failedMessage]).catch(() => undefined);
|
|
1652
|
+
await logChatMessagesAdded(assistantConversation, [failedMessage], {
|
|
1653
|
+
actorType: "system",
|
|
1654
|
+
actorId: "chat-assistant",
|
|
1655
|
+
agentId: chatReplyingAgentId(assistantConversation),
|
|
1656
|
+
}).catch(() => undefined);
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
finally {
|
|
1660
|
+
if (!waitingAgain && generationId) {
|
|
1661
|
+
const latestGeneration = await svc.getLatestGeneration(conversation.id).catch(() => null);
|
|
1662
|
+
if (latestGeneration?.id === generationId) {
|
|
1663
|
+
const terminalEvidence = await svc.generationProtocol.recordRuntimeTerminal({
|
|
1664
|
+
orgId: conversation.orgId,
|
|
1665
|
+
conversationId: conversation.id,
|
|
1666
|
+
generationId,
|
|
1667
|
+
expectedAttemptEpoch: latestGeneration.attemptEpoch,
|
|
1668
|
+
expectedOwnerToken: latestGeneration.controlOwnerToken,
|
|
1669
|
+
finalStatus: terminalStatus,
|
|
1670
|
+
terminalReason: terminalReason ?? terminalStatus,
|
|
1671
|
+
}).catch((error) => {
|
|
1672
|
+
logger.warn({ err: error, generationId }, "failed to record recovered Chat terminal evidence");
|
|
1673
|
+
return null;
|
|
1674
|
+
});
|
|
1675
|
+
if (terminalEvidence)
|
|
1676
|
+
wakeTerminalProjector();
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
chatRunsSvc.releaseOwnedRun(run.id, ownerToken);
|
|
1680
|
+
releaseGeneration();
|
|
1681
|
+
managedAbort.release();
|
|
1682
|
+
}
|
|
1683
|
+
return true;
|
|
1684
|
+
}
|
|
1685
|
+
recoverNetworkWaitingChatRun = runRecoveredNetworkWaitingChatRun;
|
|
1686
|
+
registerNetworkWaitingRunHandler?.(runRecoveredNetworkWaitingChatRun);
|
|
1326
1687
|
async function drainServerQueue() {
|
|
1327
1688
|
await svc.recoverExpiredServerQueueClaims();
|
|
1328
1689
|
while (backgroundRuntime.acceptingWork
|
|
@@ -1779,7 +2140,10 @@ export function chatRoutes(db, storage, backgroundRuntime = createChatBackground
|
|
|
1779
2140
|
return;
|
|
1780
2141
|
}
|
|
1781
2142
|
const active = getActiveChatGeneration(conversation.id);
|
|
1782
|
-
|
|
2143
|
+
const snapshot = active
|
|
2144
|
+
? await svc.getQueueSnapshot(conversation.id, active.generationId)
|
|
2145
|
+
: await svc.getQueueSnapshot(conversation.id);
|
|
2146
|
+
res.json(snapshot);
|
|
1783
2147
|
});
|
|
1784
2148
|
router.post("/chats/:id/queue", async (req, res) => {
|
|
1785
2149
|
const conversation = await assertConversationAccess(req, req.params.id);
|
|
@@ -2503,6 +2867,7 @@ export function chatRoutes(db, storage, backgroundRuntime = createChatBackground
|
|
|
2503
2867
|
}
|
|
2504
2868
|
const turnContext = turnContextFromUserMessage(userMessage);
|
|
2505
2869
|
let activeChatRunId = null;
|
|
2870
|
+
let networkWaiting = false;
|
|
2506
2871
|
const persistedAssistantMessages = await (async () => {
|
|
2507
2872
|
const assistantInput = await loadAssistantInput(conversation, actor);
|
|
2508
2873
|
const transcript = [];
|
|
@@ -2514,6 +2879,7 @@ export function chatRoutes(db, storage, backgroundRuntime = createChatBackground
|
|
|
2514
2879
|
userMessageId: userMessage.id,
|
|
2515
2880
|
chatTurnId: turnContext.chatTurnId,
|
|
2516
2881
|
turnVariant: turnContext.turnVariant,
|
|
2882
|
+
runContext: { chatMode: "non_stream" },
|
|
2517
2883
|
stream: false,
|
|
2518
2884
|
onRunCreated: (runId) => {
|
|
2519
2885
|
activeChatRunId = runId;
|
|
@@ -2523,6 +2889,10 @@ export function chatRoutes(db, storage, backgroundRuntime = createChatBackground
|
|
|
2523
2889
|
},
|
|
2524
2890
|
});
|
|
2525
2891
|
fallbackOutput = streamed.partialBody;
|
|
2892
|
+
if (streamed.outcome === "waiting_for_network") {
|
|
2893
|
+
networkWaiting = true;
|
|
2894
|
+
return [];
|
|
2895
|
+
}
|
|
2526
2896
|
if (streamed.outcome !== "completed") {
|
|
2527
2897
|
throw new Error("Chat assistant reply was stopped before completion");
|
|
2528
2898
|
}
|
|
@@ -2557,7 +2927,10 @@ export function chatRoutes(db, storage, backgroundRuntime = createChatBackground
|
|
|
2557
2927
|
}
|
|
2558
2928
|
})();
|
|
2559
2929
|
const createdMessages = [userMessage, ...persistedAssistantMessages];
|
|
2560
|
-
res.status(201).json({
|
|
2930
|
+
res.status(networkWaiting ? 202 : 201).json({
|
|
2931
|
+
messages: createdMessages,
|
|
2932
|
+
...(networkWaiting ? { waitingForNetwork: true, runId: activeChatRunId } : {}),
|
|
2933
|
+
});
|
|
2561
2934
|
}
|
|
2562
2935
|
catch (err) {
|
|
2563
2936
|
logger.warn({
|