@rubytech/create-maxy-code 0.1.158 → 0.1.159
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/package.json +1 -1
- package/payload/platform/lib/admin-conversation-purge/dist/index.d.ts +1 -1
- package/payload/platform/lib/admin-conversation-purge/dist/index.d.ts.map +1 -1
- package/payload/platform/lib/admin-conversation-purge/dist/index.js +4 -4
- package/payload/platform/lib/admin-conversation-purge/dist/index.js.map +1 -1
- package/payload/platform/lib/admin-conversation-purge/src/index.ts +5 -5
- package/payload/platform/lib/graph-style/dist/index.js +2 -2
- package/payload/platform/lib/graph-style/dist/index.js.map +1 -1
- package/payload/platform/lib/graph-style/src/__tests__/parity.test.ts +1 -1
- package/payload/platform/lib/graph-style/src/index.ts +2 -2
- package/payload/platform/lib/graph-trash/dist/index.js +1 -1
- package/payload/platform/lib/graph-trash/dist/index.js.map +1 -1
- package/payload/platform/lib/graph-trash/src/index.ts +1 -1
- package/payload/platform/lib/graph-write/dist/__tests__/action-provenance-gate.test.js +1 -1
- package/payload/platform/lib/graph-write/dist/__tests__/action-provenance-gate.test.js.map +1 -1
- package/payload/platform/lib/graph-write/dist/conversation-provenance.d.ts +3 -3
- package/payload/platform/lib/graph-write/dist/conversation-provenance.js +5 -5
- package/payload/platform/lib/graph-write/dist/conversation-provenance.js.map +1 -1
- package/payload/platform/lib/graph-write/dist/index.js +1 -1
- package/payload/platform/lib/graph-write/dist/index.js.map +1 -1
- package/payload/platform/lib/graph-write/src/__tests__/action-provenance-gate.test.ts +1 -1
- package/payload/platform/lib/graph-write/src/conversation-provenance.ts +8 -8
- package/payload/platform/lib/graph-write/src/index.ts +1 -1
- package/payload/platform/neo4j/schema.cypher +30 -13
- package/payload/platform/plugins/admin/.claude-plugin/plugin.json +1 -1
- package/payload/platform/plugins/admin/PLUGIN.md +8 -4
- package/payload/platform/plugins/admin/hooks/__tests__/archive-ingest-surface-gate.test.sh +1 -1
- package/payload/platform/plugins/admin/hooks/__tests__/per-turn-graph-pass-gate.test.sh +361 -0
- package/payload/platform/plugins/admin/hooks/__tests__/pre-turn-graph-pass.test.sh +13 -13
- package/payload/platform/plugins/admin/hooks/__tests__/turn-completed-graph-write.test.sh +1 -1
- package/payload/platform/plugins/admin/hooks/lib/admin-graph-pass-common.sh +102 -0
- package/payload/platform/plugins/admin/hooks/per-turn-graph-pass-gate.sh +106 -0
- package/payload/platform/plugins/admin/hooks/pre-turn-graph-pass.sh +15 -8
- package/payload/platform/plugins/admin/hooks/turn-completed-graph-write.sh +4 -4
- package/payload/platform/plugins/admin/mcp/dist/index.js +65 -24
- package/payload/platform/plugins/admin/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/admin/skills/session-management/SKILL.md +2 -2
- package/payload/platform/plugins/admin/skills/stream-log-review/SKILL.md +5 -5
- package/payload/platform/plugins/admin/skills/stream-log-review/references/analysis-patterns.md +6 -6
- package/payload/platform/plugins/business-assistant/references/profiling.md +1 -1
- package/payload/platform/plugins/contacts/PLUGIN.md +1 -1
- package/payload/platform/plugins/contacts/mcp/dist/tools/contact-create.js +2 -2
- package/payload/platform/plugins/contacts/mcp/dist/tools/contact-create.js.map +1 -1
- package/payload/platform/plugins/contacts/mcp/dist/tools/contact-erase.js +3 -3
- package/payload/platform/plugins/contacts/mcp/dist/tools/contact-export.d.ts +1 -1
- package/payload/platform/plugins/contacts/mcp/dist/tools/contact-export.js +2 -2
- package/payload/platform/plugins/contacts/mcp/dist/tools/group-create.d.ts +1 -1
- package/payload/platform/plugins/contacts/mcp/dist/tools/group-create.d.ts.map +1 -1
- package/payload/platform/plugins/contacts/mcp/dist/tools/group-create.js +4 -4
- package/payload/platform/plugins/contacts/mcp/dist/tools/group-create.js.map +1 -1
- package/payload/platform/plugins/contacts/mcp/dist/tools/group-manage.js +10 -10
- package/payload/platform/plugins/contacts/mcp/dist/tools/group-manage.js.map +1 -1
- package/payload/platform/plugins/docs/references/admin-session.md +6 -6
- package/payload/platform/plugins/docs/references/admin-ui.md +1 -1
- package/payload/platform/plugins/docs/references/internals.md +5 -5
- package/payload/platform/plugins/docs/references/plugins-guide.md +3 -3
- package/payload/platform/plugins/docs/references/troubleshooting.md +1 -1
- package/payload/platform/plugins/email/.claude-plugin/plugin.json +1 -1
- package/payload/platform/plugins/email/PLUGIN.md +15 -2
- package/payload/platform/plugins/email/mcp/dist/index.js +53 -0
- package/payload/platform/plugins/email/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/lib/embedding.js +2 -2
- package/payload/platform/plugins/email/mcp/dist/lib/embedding.js.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/lib/graph.js +1 -1
- package/payload/platform/plugins/email/mcp/dist/lib/graph.js.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/lib/imap.d.ts +1 -1
- package/payload/platform/plugins/email/mcp/dist/lib/ingest-batch.d.ts +23 -0
- package/payload/platform/plugins/email/mcp/dist/lib/ingest-batch.d.ts.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/lib/ingest-batch.js +15 -0
- package/payload/platform/plugins/email/mcp/dist/lib/ingest-batch.js.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/tools/email-fetch.d.ts +15 -0
- package/payload/platform/plugins/email/mcp/dist/tools/email-fetch.d.ts.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/tools/email-fetch.js +49 -0
- package/payload/platform/plugins/email/mcp/dist/tools/email-fetch.js.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/tools/email-ingest.d.ts +20 -0
- package/payload/platform/plugins/email/mcp/dist/tools/email-ingest.d.ts.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/tools/email-ingest.js +86 -0
- package/payload/platform/plugins/email/mcp/dist/tools/email-ingest.js.map +1 -0
- package/payload/platform/plugins/email/mcp/dist/tools/email-setup.d.ts.map +1 -1
- package/payload/platform/plugins/email/mcp/dist/tools/email-setup.js +32 -52
- package/payload/platform/plugins/email/mcp/dist/tools/email-setup.js.map +1 -1
- package/payload/platform/plugins/email/references/email-reference.md +19 -83
- package/payload/platform/plugins/email/skills/email-ingest/SKILL.md +87 -0
- package/payload/platform/plugins/memory/PLUGIN.md +1 -1
- package/payload/platform/plugins/memory/mcp/dist/index.js +29 -29
- package/payload/platform/plugins/memory/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/conversation-normalisers/x-dm.js +2 -2
- package/payload/platform/plugins/memory/mcp/dist/lib/conversation-normalisers/x-dm.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/graph-prune.d.ts +3 -3
- package/payload/platform/plugins/memory/mcp/dist/lib/graph-prune.d.ts.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/graph-prune.js +6 -6
- package/payload/platform/plugins/memory/mcp/dist/lib/graph-prune.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/log-ingest.js +1 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/log-ingest.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/neo4j.d.ts +2 -2
- package/payload/platform/plugins/memory/mcp/dist/lib/neo4j.js +2 -2
- package/payload/platform/plugins/memory/mcp/dist/lib/typed-edge-pass.d.ts +1 -1
- package/payload/platform/plugins/memory/mcp/dist/lib/typed-edge-pass.d.ts.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/conversation-memory-expunge-emit.test.js +3 -3
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/conversation-memory-expunge-emit.test.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/log-ingest.test.js +2 -2
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/log-ingest.test.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-empty-trash-admin-conversation.test.js +8 -8
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-empty-trash-admin-conversation.test.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-report-tools.test.js +2 -2
- package/payload/platform/plugins/memory/mcp/dist/tools/__tests__/memory-report-tools.test.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/conversation-memory-expunge.d.ts +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/conversation-memory-expunge.d.ts.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/conversation-memory-expunge.js +2 -2
- package/payload/platform/plugins/memory/mcp/dist/tools/conversation-memory-expunge.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-brain-capture-recent.d.ts +2 -2
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-brain-capture-recent.d.ts.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-brain-capture-recent.js +4 -4
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-brain-capture-recent.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-empty-trash.d.ts +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-empty-trash.js +8 -8
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-empty-trash.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-find-candidates.d.ts +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-find-candidates.d.ts.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-find-candidates.js +2 -2
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-find-candidates.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-report-write.d.ts +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-report-write.js +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-typed-edge-pass.d.ts +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-typed-edge-pass.d.ts.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-typed-edge-pass.js +2 -2
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-typed-edge-pass.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-write.js +2 -2
- package/payload/platform/plugins/memory/mcp/dist/tools/memory-write.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/profile-update.d.ts +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/profile-update.d.ts.map +1 -1
- package/payload/platform/plugins/memory/mcp/dist/tools/profile-update.js +11 -11
- package/payload/platform/plugins/memory/mcp/dist/tools/profile-update.js.map +1 -1
- package/payload/platform/plugins/memory/mcp/scripts/backfill-typed-edges.ts +1 -1
- package/payload/platform/plugins/memory/mcp/scripts/graph/fixture.cypher +1 -1
- package/payload/platform/plugins/memory/references/graph-primitives.md +1 -1
- package/payload/platform/plugins/memory/references/schema-base.md +4 -4
- package/payload/platform/plugins/memory/skills/conversational-memory/SKILL.md +1 -1
- package/payload/platform/plugins/whatsapp/PLUGIN.md +1 -1
- package/payload/platform/plugins/whatsapp/mcp/dist/index.js +2 -2
- package/payload/platform/plugins/whatsapp/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/work/mcp/dist/index.js +2 -2
- package/payload/platform/plugins/work/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/work/mcp/dist/tools/project-create.js +6 -6
- package/payload/platform/plugins/work/mcp/dist/tools/project-create.js.map +1 -1
- package/payload/platform/plugins/work/mcp/dist/tools/session-list.d.ts +1 -1
- package/payload/platform/plugins/work/mcp/dist/tools/session-list.d.ts.map +1 -1
- package/payload/platform/plugins/work/mcp/dist/tools/session-list.js +1 -1
- package/payload/platform/plugins/work/mcp/dist/tools/session-list.js.map +1 -1
- package/payload/platform/plugins/x-import/references/archive-shape.md +2 -2
- package/payload/platform/plugins/x-import/skills/x-import/SKILL.md +3 -3
- package/payload/platform/scripts/admin-persist-audit.ts +18 -18
- package/payload/platform/scripts/identity-forbidden-token-check.mjs +2 -0
- package/payload/platform/scripts/seed-neo4j.sh +1 -0
- package/payload/platform/services/claude-session-manager/dist/http-server.js +3 -3
- package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.d.ts +3 -3
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.js +4 -4
- package/payload/platform/services/claude-session-manager/dist/pty-spawner.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/system-prompt.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/system-prompt.js +2 -0
- package/payload/platform/services/claude-session-manager/dist/system-prompt.js.map +1 -1
- package/payload/platform/templates/specialists/agents/personal-assistant.md +1 -1
- package/payload/server/{chunk-AXOL2PPG.js → chunk-3TRIXQSJ.js} +101 -101
- package/payload/server/maxy-edge.js +1 -1
- package/payload/server/public/assets/{admin-3fLFD5h_.js → admin-Dal5FWaD.js} +2 -2
- package/payload/server/public/assets/{architectureDiagram-Q4EWVU46-Breg9-99.js → architectureDiagram-Q4EWVU46-Do2zYONG.js} +1 -1
- package/payload/server/public/assets/{blockDiagram-DXYQGD6D-DXf1_673.js → blockDiagram-DXYQGD6D-DpIX_bRu.js} +1 -1
- package/payload/server/public/assets/{c4Diagram-AHTNJAMY-CSZ36W4-.js → c4Diagram-AHTNJAMY-Cz335ZSY.js} +1 -1
- package/payload/server/public/assets/channel-PC4_IjI1.js +1 -0
- package/payload/server/public/assets/{chunk-336JU56O-DsrLk2eK.js → chunk-336JU56O-Dmknn3Wo.js} +2 -2
- package/payload/server/public/assets/{chunk-426QAEUC-JpNfNf81.js → chunk-426QAEUC-ClfGjizN.js} +1 -1
- package/payload/server/public/assets/{chunk-4TB4RGXK-DmClEAD0.js → chunk-4TB4RGXK-BPKctJ5c.js} +1 -1
- package/payload/server/public/assets/{chunk-5FUZZQ4R-BI9blW3N.js → chunk-5FUZZQ4R-BWDCO9zw.js} +1 -1
- package/payload/server/public/assets/{chunk-5PVQY5BW-BbgttEFO.js → chunk-5PVQY5BW-BE34_Db0.js} +1 -1
- package/payload/server/public/assets/{chunk-EDXVE4YY-BX_LCFOx.js → chunk-EDXVE4YY-BysA-_6v.js} +1 -1
- package/payload/server/public/assets/{chunk-ENJZ2VHE-Bb7EoD0w.js → chunk-ENJZ2VHE-BMVyMsqA.js} +1 -1
- package/payload/server/public/assets/{chunk-ICPOFSXX-DH8uQk-s.js → chunk-ICPOFSXX-C5KRdLV4.js} +1 -1
- package/payload/server/public/assets/{chunk-OYMX7WX6-FH5kgXsw.js → chunk-OYMX7WX6-DVZD-AVc.js} +1 -1
- package/payload/server/public/assets/{chunk-U2HBQHQK-D_ljlkHr.js → chunk-U2HBQHQK-DYmQdx8x.js} +1 -1
- package/payload/server/public/assets/{chunk-X2U36JSP-BX3EmZvm.js → chunk-X2U36JSP-DrZenIl3.js} +1 -1
- package/payload/server/public/assets/{chunk-YZCP3GAM-Vu7-E93h.js → chunk-YZCP3GAM-CDuGbvMq.js} +1 -1
- package/payload/server/public/assets/{chunk-ZZ45TVLE-CwjhNPX5.js → chunk-ZZ45TVLE-COztbiu5.js} +1 -1
- package/payload/server/public/assets/classDiagram-6PBFFD2Q-B_pMa-SX.js +1 -0
- package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-BdBAgF20.js +1 -0
- package/payload/server/public/assets/clone-CkNt9L9r.js +1 -0
- package/payload/server/public/assets/{dagre-Ce6gsj0C.js → dagre-Cv9Ib2OM.js} +1 -1
- package/payload/server/public/assets/{dagre-KV5264BT-BaMGpsoy.js → dagre-KV5264BT-CoEd61KZ.js} +1 -1
- package/payload/server/public/assets/{data-BHASh0_Y.js → data-DbSORCl4.js} +1 -1
- package/payload/server/public/assets/{diagram-5BDNPKRD-CHEE9rjq.js → diagram-5BDNPKRD-WXNzw3uW.js} +1 -1
- package/payload/server/public/assets/{diagram-G4DWMVQ6-C98sZLW1.js → diagram-G4DWMVQ6-C6IuQ2VV.js} +1 -1
- package/payload/server/public/assets/{diagram-MMDJMWI5-DNvMGsTZ.js → diagram-MMDJMWI5-CdJdir5A.js} +1 -1
- package/payload/server/public/assets/{diagram-TYMM5635-Cdte4IBa.js → diagram-TYMM5635-DxWKQH5T.js} +1 -1
- package/payload/server/public/assets/{erDiagram-SMLLAGMA-C9VZsWXK.js → erDiagram-SMLLAGMA-C9fvs33K.js} +1 -1
- package/payload/server/public/assets/{flowDiagram-DWJPFMVM-tuP5fzzR.js → flowDiagram-DWJPFMVM-BO7Yrbqv.js} +1 -1
- package/payload/server/public/assets/{ganttDiagram-T4ZO3ILL-SJgRPUwx.js → ganttDiagram-T4ZO3ILL-CQJyWBZq.js} +1 -1
- package/payload/server/public/assets/{gitGraphDiagram-UUTBAWPF-DU_cI_50.js → gitGraphDiagram-UUTBAWPF-DZfQHrYw.js} +1 -1
- package/payload/server/public/assets/{graph-labels-DXlmm1og.js → graph-labels-BBB5jsZk.js} +1 -1
- package/payload/server/public/assets/{graph-BhEI09tF.js → graph-ys_joP2o.js} +1 -1
- package/payload/server/public/assets/{graphlib-D_nAsvmx.js → graphlib-C40H-Q5E.js} +1 -1
- package/payload/server/public/assets/{infoDiagram-42DDH7IO-Cj2Y19m6.js → infoDiagram-42DDH7IO-CakfV5f9.js} +1 -1
- package/payload/server/public/assets/{ishikawaDiagram-UXIWVN3A-DMc1xq1y.js → ishikawaDiagram-UXIWVN3A-CPuBPyfa.js} +1 -1
- package/payload/server/public/assets/{journeyDiagram-VCZTEJTY-C4CRAQma.js → journeyDiagram-VCZTEJTY-zpZm2Mmo.js} +1 -1
- package/payload/server/public/assets/{kanban-definition-6JOO6SKY-CTr4AldU.js → kanban-definition-6JOO6SKY-DfJduQCo.js} +1 -1
- package/payload/server/public/assets/{line-Btlm_IAl.js → line-BpYQqO5R.js} +1 -1
- package/payload/server/public/assets/{mermaid-parser.core-DXFdj_y1.js → mermaid-parser.core-C5Mwi14D.js} +1 -1
- package/payload/server/public/assets/{mermaid.core-DFBhoCr5.js → mermaid.core-D8qBtvvT.js} +3 -3
- package/payload/server/public/assets/{mindmap-definition-QFDTVHPH-r9gVQybo.js → mindmap-definition-QFDTVHPH-Bli9JhIN.js} +1 -1
- package/payload/server/public/assets/{page-CDWu1Aft.js → page--bl5Y7ZI.js} +2 -2
- package/payload/server/public/assets/page-CwmZ76U7.js +1 -0
- package/payload/server/public/assets/{pieDiagram-DEJITSTG-CHKZjSaH.js → pieDiagram-DEJITSTG-MsLXTSLg.js} +1 -1
- package/payload/server/public/assets/{public-DyGWgfaZ.js → public-DltgEfA9.js} +2 -2
- package/payload/server/public/assets/{quadrantDiagram-34T5L4WZ-CSGR1HJr.js → quadrantDiagram-34T5L4WZ-De1sh2K0.js} +1 -1
- package/payload/server/public/assets/{requirementDiagram-MS252O5E-DZ6hX9D6.js → requirementDiagram-MS252O5E-D5Sfg1t_.js} +1 -1
- package/payload/server/public/assets/{sankeyDiagram-XADWPNL6-DbZBKh0m.js → sankeyDiagram-XADWPNL6-DHA3LIbv.js} +1 -1
- package/payload/server/public/assets/{sequenceDiagram-FGHM5R23-BHHpb8dt.js → sequenceDiagram-FGHM5R23-BE_QlG1B.js} +1 -1
- package/payload/server/public/assets/{stateDiagram-FHFEXIEX-DQ1jiLB4.js → stateDiagram-FHFEXIEX-NIwp3F4u.js} +1 -1
- package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-pfk2F6st.js +1 -0
- package/payload/server/public/assets/{timeline-definition-GMOUNBTQ-BlGiEU7p.js → timeline-definition-GMOUNBTQ-CPE9jyDF.js} +1 -1
- package/payload/server/public/assets/{vennDiagram-DHZGUBPP-DmEH-hsB.js → vennDiagram-DHZGUBPP-CKfoyYmH.js} +1 -1
- package/payload/server/public/assets/{wardleyDiagram-NUSXRM2D-C7KJJ40d.js → wardleyDiagram-NUSXRM2D-B9yJek-o.js} +1 -1
- package/payload/server/public/assets/{xychartDiagram-5P7HB3ND-JDnusCaa.js → xychartDiagram-5P7HB3ND-DuCcSLqX.js} +1 -1
- package/payload/server/public/data.html +3 -3
- package/payload/server/public/graph.html +3 -3
- package/payload/server/public/index.html +4 -4
- package/payload/server/public/public.html +1 -1
- package/payload/server/server.js +133 -133
- package/payload/server/public/assets/channel-BmZnt3PP.js +0 -1
- package/payload/server/public/assets/classDiagram-6PBFFD2Q-kmMLFUpV.js +0 -1
- package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-BV7Ae8ct.js +0 -1
- package/payload/server/public/assets/clone-B5eqoN9I.js +0 -1
- package/payload/server/public/assets/page-cyvshX4Z.js +0 -1
- package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-CByT2RzF.js +0 -1
package/payload/server/server.js
CHANGED
|
@@ -35,12 +35,12 @@ import {
|
|
|
35
35
|
getAccountIdForSession,
|
|
36
36
|
getAgentSessionIdForConversation,
|
|
37
37
|
getConversationClaudeSessionIds,
|
|
38
|
-
getConversationIdByClaudeSessionId,
|
|
39
|
-
getConversationIdForSession,
|
|
40
38
|
getRecentMessages,
|
|
41
39
|
getRoleForSession,
|
|
42
40
|
getSession,
|
|
43
|
-
|
|
41
|
+
getSessionIdByClaudeSessionId,
|
|
42
|
+
getSessionIdForSession,
|
|
43
|
+
getSessionKeyBySessionId,
|
|
44
44
|
getUserIdForSession,
|
|
45
45
|
getUserNameForSession,
|
|
46
46
|
getUserTimezone,
|
|
@@ -70,8 +70,8 @@ import {
|
|
|
70
70
|
safeJson,
|
|
71
71
|
sanitizeClientCorrId,
|
|
72
72
|
serve,
|
|
73
|
-
setConversationIdForSession,
|
|
74
73
|
setRemotePassword,
|
|
74
|
+
setSessionIdForSession,
|
|
75
75
|
setWantsPriorConversation,
|
|
76
76
|
stripAttachmentMetaSuffix,
|
|
77
77
|
tryCookieBridgeForConversation,
|
|
@@ -84,7 +84,7 @@ import {
|
|
|
84
84
|
vncLog,
|
|
85
85
|
walkPremiumBundles,
|
|
86
86
|
writeAdminUserAndPerson
|
|
87
|
-
} from "./chunk-
|
|
87
|
+
} from "./chunk-3TRIXQSJ.js";
|
|
88
88
|
import {
|
|
89
89
|
__commonJS,
|
|
90
90
|
__toESM
|
|
@@ -114,7 +114,7 @@ var require_dist = __commonJS({
|
|
|
114
114
|
KnowledgeDocument: ["attachmentId"],
|
|
115
115
|
ConversationArchive: ["conversationIdentity"],
|
|
116
116
|
DigitalDocument: ["attachmentId"],
|
|
117
|
-
Conversation: ["
|
|
117
|
+
Conversation: ["sessionId"],
|
|
118
118
|
Message: ["messageId"],
|
|
119
119
|
Workflow: ["workflowId"],
|
|
120
120
|
WorkflowStep: ["stepId"],
|
|
@@ -541,7 +541,7 @@ var require_dist2 = __commonJS({
|
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
543
|
if (primaryLabel === "Conversation") {
|
|
544
|
-
const id = typeof props.
|
|
544
|
+
const id = typeof props.sessionId === "string" ? props.sessionId : null;
|
|
545
545
|
if (id)
|
|
546
546
|
return `Conv ${id.slice(0, 8)}`;
|
|
547
547
|
}
|
|
@@ -584,7 +584,7 @@ var require_dist2 = __commonJS({
|
|
|
584
584
|
return v;
|
|
585
585
|
}
|
|
586
586
|
if (primaryLabel === "Conversation") {
|
|
587
|
-
const id = typeof props.
|
|
587
|
+
const id = typeof props.sessionId === "string" ? props.sessionId : null;
|
|
588
588
|
if (id)
|
|
589
589
|
return `Conv ${id.slice(0, 8)}`;
|
|
590
590
|
}
|
|
@@ -2074,7 +2074,7 @@ async function persistWhatsAppMessage(input) {
|
|
|
2074
2074
|
try {
|
|
2075
2075
|
session = getSession();
|
|
2076
2076
|
const cypher = `
|
|
2077
|
-
MATCH (c:Conversation {
|
|
2077
|
+
MATCH (c:Conversation {sessionId: $sessionId})
|
|
2078
2078
|
OPTIONAL MATCH (existingS:Person {telephone: $senderTelephone})
|
|
2079
2079
|
OPTIONAL MATCH (existingM:Message {messageId: $messageId})
|
|
2080
2080
|
WITH c,
|
|
@@ -2095,7 +2095,7 @@ async function persistWhatsAppMessage(input) {
|
|
|
2095
2095
|
ON CREATE SET
|
|
2096
2096
|
m:WhatsAppMessage,
|
|
2097
2097
|
m.accountId = $platformAccountId,
|
|
2098
|
-
m.
|
|
2098
|
+
m.sessionId = c.sessionId,
|
|
2099
2099
|
m.source = 'whatsapp',
|
|
2100
2100
|
m.createdByAgent = 'whatsapp-live',
|
|
2101
2101
|
m.createdBySource = 'whatsapp-live',
|
|
@@ -2138,7 +2138,7 @@ async function persistWhatsAppMessage(input) {
|
|
|
2138
2138
|
senderReused AS senderReused
|
|
2139
2139
|
`;
|
|
2140
2140
|
const params = {
|
|
2141
|
-
|
|
2141
|
+
sessionId: input.sessionId,
|
|
2142
2142
|
messageId,
|
|
2143
2143
|
platformAccountId: input.platformAccountId,
|
|
2144
2144
|
senderTelephone,
|
|
@@ -2228,16 +2228,16 @@ async function ensureWhatsAppConversation(input) {
|
|
|
2228
2228
|
input.cacheKey
|
|
2229
2229
|
);
|
|
2230
2230
|
const ms = Date.now() - t0;
|
|
2231
|
-
if (!result.
|
|
2231
|
+
if (!result.sessionId) {
|
|
2232
2232
|
console.error(
|
|
2233
|
-
`${TAG7} conversation-merged FAIL cacheKey=${input.cacheKey} reason=null-
|
|
2233
|
+
`${TAG7} conversation-merged FAIL cacheKey=${input.cacheKey} reason=null-sessionId ms=${ms}`
|
|
2234
2234
|
);
|
|
2235
2235
|
return null;
|
|
2236
2236
|
}
|
|
2237
2237
|
console.error(
|
|
2238
2238
|
`${TAG7} conversation-merged cacheKey=${input.cacheKey} agentType=${input.agentType} channel=whatsapp created=${result.created} ms=${ms}`
|
|
2239
2239
|
);
|
|
2240
|
-
return {
|
|
2240
|
+
return { sessionId: result.sessionId, created: result.created };
|
|
2241
2241
|
} catch (err) {
|
|
2242
2242
|
const ms = Date.now() - t0;
|
|
2243
2243
|
const reason = err instanceof Error ? `${err.name}:${err.message.slice(0, 200)}` : String(err).slice(0, 200);
|
|
@@ -3266,7 +3266,7 @@ function monitorInbound(conn) {
|
|
|
3266
3266
|
platformAccountId: conn.platformAccountId,
|
|
3267
3267
|
remoteJid,
|
|
3268
3268
|
cacheKey,
|
|
3269
|
-
|
|
3269
|
+
sessionId: merged.sessionId,
|
|
3270
3270
|
msgKeyId: msg.key.id,
|
|
3271
3271
|
fromMe,
|
|
3272
3272
|
senderPhone,
|
|
@@ -5662,7 +5662,7 @@ app3.get("/conversation-graph-state", async (c) => {
|
|
|
5662
5662
|
MATCH (c:Conversation {accountId: $accountId, channel: 'whatsapp', channelAddress: $channelAddress})
|
|
5663
5663
|
OPTIONAL MATCH (m:Message:WhatsAppMessage)-[:PART_OF]->(c)
|
|
5664
5664
|
RETURN
|
|
5665
|
-
c.
|
|
5665
|
+
c.sessionId AS sessionId,
|
|
5666
5666
|
m.messageId AS messageId,
|
|
5667
5667
|
m.dateSent AS dateSent,
|
|
5668
5668
|
m.fromMe AS fromMe,
|
|
@@ -5672,14 +5672,14 @@ app3.get("/conversation-graph-state", async (c) => {
|
|
|
5672
5672
|
`;
|
|
5673
5673
|
let session = null;
|
|
5674
5674
|
const t0 = Date.now();
|
|
5675
|
-
let
|
|
5675
|
+
let sessionId = null;
|
|
5676
5676
|
const rows = [];
|
|
5677
5677
|
try {
|
|
5678
5678
|
session = getSession();
|
|
5679
5679
|
const result = await session.run(cypher, { accountId, channelAddress });
|
|
5680
5680
|
for (const rec of result.records) {
|
|
5681
|
-
if (
|
|
5682
|
-
|
|
5681
|
+
if (sessionId === null) {
|
|
5682
|
+
sessionId = rec.get("sessionId") ?? null;
|
|
5683
5683
|
}
|
|
5684
5684
|
const messageId = rec.get("messageId");
|
|
5685
5685
|
if (!messageId) continue;
|
|
@@ -5698,10 +5698,10 @@ app3.get("/conversation-graph-state", async (c) => {
|
|
|
5698
5698
|
return c.json({ error: `Graph query failed: ${msg}`, cacheKey, cypher: cypher.trim() }, 500);
|
|
5699
5699
|
}
|
|
5700
5700
|
const ms = Date.now() - t0;
|
|
5701
|
-
console.error(`[mcp:whatsapp] tool=whatsapp-conversation-graph-state cacheKey=${cacheKey} graphRows=${rows.length}
|
|
5701
|
+
console.error(`[mcp:whatsapp] tool=whatsapp-conversation-graph-state cacheKey=${cacheKey} graphRows=${rows.length} sessionId=${sessionId ?? "null"} ms=${ms}`);
|
|
5702
5702
|
return c.json({
|
|
5703
5703
|
cacheKey,
|
|
5704
|
-
|
|
5704
|
+
sessionId,
|
|
5705
5705
|
graphRows: rows,
|
|
5706
5706
|
cypher: cypher.trim(),
|
|
5707
5707
|
ms
|
|
@@ -6353,7 +6353,7 @@ async function createAdminSession(accountId, thinkingView, userId, userName, rol
|
|
|
6353
6353
|
businessName = branding?.name || void 0;
|
|
6354
6354
|
} catch {
|
|
6355
6355
|
}
|
|
6356
|
-
let
|
|
6356
|
+
let initialSessionId = null;
|
|
6357
6357
|
try {
|
|
6358
6358
|
const ensured = await ensureConversation(
|
|
6359
6359
|
accountId,
|
|
@@ -6363,15 +6363,15 @@ async function createAdminSession(accountId, thinkingView, userId, userName, rol
|
|
|
6363
6363
|
void 0,
|
|
6364
6364
|
userId
|
|
6365
6365
|
);
|
|
6366
|
-
if (ensured.
|
|
6367
|
-
|
|
6368
|
-
|
|
6366
|
+
if (ensured.sessionId) {
|
|
6367
|
+
initialSessionId = ensured.sessionId;
|
|
6368
|
+
setSessionIdForSession(cacheKey, ensured.sessionId);
|
|
6369
6369
|
}
|
|
6370
6370
|
} catch (err) {
|
|
6371
6371
|
console.error(`[session] eager-ensureConversation FAILED at boot: ${err instanceof Error ? err.message : String(err)}`);
|
|
6372
6372
|
}
|
|
6373
|
-
console.log(`[session] ${(/* @__PURE__ */ new Date()).toISOString()} admin session created: userId=${userId ?? "\u2013"} userName=${userName ?? "\u2013"} accountId=${accountId}
|
|
6374
|
-
console.log(`[admin-session] role=${role ?? "null"} cacheKey=${cacheKey.slice(0, 8)} phase=create eager-ensured=${
|
|
6373
|
+
console.log(`[session] ${(/* @__PURE__ */ new Date()).toISOString()} admin session created: userId=${userId ?? "\u2013"} userName=${userName ?? "\u2013"} accountId=${accountId} sessionId=${initialSessionId ?? "unbound"} cacheKey=${cacheKey.slice(0, 8)}`);
|
|
6374
|
+
console.log(`[admin-session] role=${role ?? "null"} cacheKey=${cacheKey.slice(0, 8)} phase=create eager-ensured=${initialSessionId ? "true" : "false"}`);
|
|
6375
6375
|
return {
|
|
6376
6376
|
session_key: signedSessionToken,
|
|
6377
6377
|
agent_id: "admin",
|
|
@@ -6381,7 +6381,7 @@ async function createAdminSession(accountId, thinkingView, userId, userName, rol
|
|
|
6381
6381
|
role: role ?? null,
|
|
6382
6382
|
thinkingView: effectiveThinkingView,
|
|
6383
6383
|
businessName,
|
|
6384
|
-
|
|
6384
|
+
sessionId: initialSessionId
|
|
6385
6385
|
};
|
|
6386
6386
|
}
|
|
6387
6387
|
var app6 = new Hono();
|
|
@@ -6428,7 +6428,7 @@ app6.get("/", async (c) => {
|
|
|
6428
6428
|
role: role ?? null,
|
|
6429
6429
|
thinkingView,
|
|
6430
6430
|
businessName,
|
|
6431
|
-
|
|
6431
|
+
sessionId: getSessionIdForSession(cacheKey) ?? null
|
|
6432
6432
|
});
|
|
6433
6433
|
});
|
|
6434
6434
|
app6.post("/", async (c) => {
|
|
@@ -6578,7 +6578,7 @@ var app9 = new Hono();
|
|
|
6578
6578
|
app9.get("/", async (c) => {
|
|
6579
6579
|
const fileParam = c.req.query("file");
|
|
6580
6580
|
const typeParam = c.req.query("type");
|
|
6581
|
-
const
|
|
6581
|
+
const sessionIdParam = c.req.query("sessionId");
|
|
6582
6582
|
const cacheKeyParam = c.req.query("cacheKey");
|
|
6583
6583
|
const download = c.req.query("download") === "1";
|
|
6584
6584
|
const account = resolveAccount();
|
|
@@ -6626,18 +6626,18 @@ app9.get("/", async (c) => {
|
|
|
6626
6626
|
400
|
|
6627
6627
|
);
|
|
6628
6628
|
}
|
|
6629
|
-
if (!
|
|
6629
|
+
if (!sessionIdParam && !cacheKeyParam) {
|
|
6630
6630
|
console.warn(`[admin/logs] rejected type=${typeParam} reason=no-id`);
|
|
6631
6631
|
return c.json(
|
|
6632
|
-
{ error: `type=${typeParam} requires
|
|
6632
|
+
{ error: `type=${typeParam} requires sessionId or cacheKey`, code: "ID_REQUIRED" },
|
|
6633
6633
|
400
|
|
6634
6634
|
);
|
|
6635
6635
|
}
|
|
6636
6636
|
const cacheKey = cacheKeyParam ?? null;
|
|
6637
|
-
const
|
|
6638
|
-
const sessionKeyFromConv =
|
|
6639
|
-
const primaryId = cacheKey ?? sessionKeyFromConv ??
|
|
6640
|
-
const fallbackId = primaryId !==
|
|
6637
|
+
const sessionId = sessionIdParam ?? null;
|
|
6638
|
+
const sessionKeyFromConv = sessionId ? getSessionKeyBySessionId(sessionId) ?? null : null;
|
|
6639
|
+
const primaryId = cacheKey ?? sessionKeyFromConv ?? sessionId;
|
|
6640
|
+
const fallbackId = primaryId !== sessionId && sessionId ? sessionId : null;
|
|
6641
6641
|
const tried = [];
|
|
6642
6642
|
let hit = null;
|
|
6643
6643
|
if (primaryId) {
|
|
@@ -6653,9 +6653,9 @@ app9.get("/", async (c) => {
|
|
|
6653
6653
|
if (result.hits.length > 0) hit = result.hits[0];
|
|
6654
6654
|
}
|
|
6655
6655
|
const cacheKeySlice = cacheKey ? cacheKey.slice(0, 12) : "none";
|
|
6656
|
-
const
|
|
6656
|
+
const sessionIdSlice = sessionId ? sessionId.slice(0, 12) : "none";
|
|
6657
6657
|
if (hit) {
|
|
6658
|
-
console.info(`[admin/logs] resolved cacheKey=${cacheKeySlice}
|
|
6658
|
+
console.info(`[admin/logs] resolved cacheKey=${cacheKeySlice} sessionId=${sessionIdSlice} via=${primaryId === cacheKey ? "cacheKey" : primaryId === sessionKeyFromConv ? "reverse-lookup" : "sessionId-fallback"}`);
|
|
6659
6659
|
try {
|
|
6660
6660
|
const filename = basename3(hit.path);
|
|
6661
6661
|
const buffer = readFileSync10(hit.path);
|
|
@@ -6678,14 +6678,14 @@ app9.get("/", async (c) => {
|
|
|
6678
6678
|
}
|
|
6679
6679
|
const reason = "no log file on disk for the given identifier(s)";
|
|
6680
6680
|
if (primaryId) emitMissingOnResolve(primaryId, "admin-logs-route", reason);
|
|
6681
|
-
console.warn(`[admin/logs] not-found tried=[${tried.join(",")}] cacheKey=${cacheKeySlice}
|
|
6681
|
+
console.warn(`[admin/logs] not-found tried=[${tried.join(",")}] cacheKey=${cacheKeySlice} sessionId=${sessionIdSlice} reason=${JSON.stringify(reason)}`);
|
|
6682
6682
|
return c.json(
|
|
6683
6683
|
{
|
|
6684
6684
|
error: reason,
|
|
6685
6685
|
code: "NOT_FOUND",
|
|
6686
6686
|
reason,
|
|
6687
6687
|
cacheKey: cacheKey ?? null,
|
|
6688
|
-
|
|
6688
|
+
sessionId: sessionId ?? null
|
|
6689
6689
|
},
|
|
6690
6690
|
404
|
|
6691
6691
|
);
|
|
@@ -6926,7 +6926,7 @@ import { existsSync as existsSync14, mkdirSync as mkdirSync3, createWriteStream
|
|
|
6926
6926
|
async function purgeAdminConversationJsonls(args) {
|
|
6927
6927
|
const fetchImpl = args.fetchImpl ?? fetch;
|
|
6928
6928
|
const log = args.logger ?? ((line) => console.log(line));
|
|
6929
|
-
const id8 = args.
|
|
6929
|
+
const id8 = args.sessionId.slice(0, 8);
|
|
6930
6930
|
const purged = [];
|
|
6931
6931
|
for (const sessionId of args.claudeSessionIds) {
|
|
6932
6932
|
const url = `${args.managerBase}/${encodeURIComponent(sessionId)}`;
|
|
@@ -6936,7 +6936,7 @@ async function purgeAdminConversationJsonls(args) {
|
|
|
6936
6936
|
} catch (err) {
|
|
6937
6937
|
const message2 = err instanceof Error ? err.message : String(err);
|
|
6938
6938
|
log(
|
|
6939
|
-
`[admin-conversation-delete]
|
|
6939
|
+
`[admin-conversation-delete] sessionId=${id8} reason=jsonl-purge-failed claudeSessionId=${sessionId.slice(0, 8)} message=${message2}`
|
|
6940
6940
|
);
|
|
6941
6941
|
return {
|
|
6942
6942
|
ok: false,
|
|
@@ -6953,7 +6953,7 @@ async function purgeAdminConversationJsonls(args) {
|
|
|
6953
6953
|
}
|
|
6954
6954
|
if (res.status === 409) {
|
|
6955
6955
|
log(
|
|
6956
|
-
`[admin-conversation-delete]
|
|
6956
|
+
`[admin-conversation-delete] sessionId=${id8} reason=pty-still-alive claudeSessionId=${sessionId.slice(0, 8)}`
|
|
6957
6957
|
);
|
|
6958
6958
|
return {
|
|
6959
6959
|
ok: false,
|
|
@@ -6970,7 +6970,7 @@ async function purgeAdminConversationJsonls(args) {
|
|
|
6970
6970
|
} catch {
|
|
6971
6971
|
}
|
|
6972
6972
|
log(
|
|
6973
|
-
`[admin-conversation-delete]
|
|
6973
|
+
`[admin-conversation-delete] sessionId=${id8} reason=jsonl-purge-failed claudeSessionId=${sessionId.slice(0, 8)} message=${message}`
|
|
6974
6974
|
);
|
|
6975
6975
|
return {
|
|
6976
6976
|
ok: false,
|
|
@@ -6989,17 +6989,17 @@ async function cascadeAdminConversationDelete(args) {
|
|
|
6989
6989
|
const started = Date.now();
|
|
6990
6990
|
const fetchImpl = args.fetchImpl ?? fetch;
|
|
6991
6991
|
const log = args.logger ?? ((line) => console.log(line));
|
|
6992
|
-
const id8 = args.
|
|
6992
|
+
const id8 = args.sessionId.slice(0, 8);
|
|
6993
6993
|
let claudeSessionIds;
|
|
6994
6994
|
try {
|
|
6995
|
-
claudeSessionIds = args.claudeSessionIds ?? await getConversationClaudeSessionIds(args.
|
|
6995
|
+
claudeSessionIds = args.claudeSessionIds ?? await getConversationClaudeSessionIds(args.sessionId, args.accountId);
|
|
6996
6996
|
} catch (err) {
|
|
6997
6997
|
const message = err instanceof Error ? err.message : String(err);
|
|
6998
|
-
log(`[admin-conversation-delete]
|
|
6998
|
+
log(`[admin-conversation-delete] sessionId=${id8} reason=graph-delete-failed claudeSessionIds-purged= message=transcript-resolve:${message}`);
|
|
6999
6999
|
return { ok: false, reason: "graph-delete-failed", claudeSessionIdsPurged: [], message };
|
|
7000
7000
|
}
|
|
7001
7001
|
const purgeOutcome = await purgeAdminConversationJsonls({
|
|
7002
|
-
|
|
7002
|
+
sessionId: args.sessionId,
|
|
7003
7003
|
accountId: args.accountId,
|
|
7004
7004
|
managerBase: args.managerBase,
|
|
7005
7005
|
claudeSessionIds,
|
|
@@ -7022,11 +7022,11 @@ async function cascadeAdminConversationDelete(args) {
|
|
|
7022
7022
|
const purged = purgeOutcome.claudeSessionIdsPurged;
|
|
7023
7023
|
let found;
|
|
7024
7024
|
try {
|
|
7025
|
-
({ found } = await deleteConversation(args.
|
|
7025
|
+
({ found } = await deleteConversation(args.sessionId));
|
|
7026
7026
|
} catch (err) {
|
|
7027
7027
|
const message = err instanceof Error ? err.message : String(err);
|
|
7028
7028
|
const csv2 = purged.map((s) => s.slice(0, 8)).join(",");
|
|
7029
|
-
log(`[admin-conversation-delete]
|
|
7029
|
+
log(`[admin-conversation-delete] sessionId=${id8} reason=graph-delete-failed claudeSessionIds-purged=${csv2} message=${message}`);
|
|
7030
7030
|
return {
|
|
7031
7031
|
ok: false,
|
|
7032
7032
|
reason: "graph-delete-failed",
|
|
@@ -7039,7 +7039,7 @@ async function cascadeAdminConversationDelete(args) {
|
|
|
7039
7039
|
}
|
|
7040
7040
|
const ms = Date.now() - started;
|
|
7041
7041
|
const csv = purged.map((s) => s.slice(0, 8)).join(",");
|
|
7042
|
-
log(`[admin-conversation-delete]
|
|
7042
|
+
log(`[admin-conversation-delete] sessionId=${id8} claudeSessionIds=${csv} ms=${ms}`);
|
|
7043
7043
|
return { ok: true, claudeSessionIds: purged, ms };
|
|
7044
7044
|
}
|
|
7045
7045
|
|
|
@@ -7064,13 +7064,13 @@ import { homedir as homedir2 } from "os";
|
|
|
7064
7064
|
var pickComponentBytes = (..._args) => null;
|
|
7065
7065
|
|
|
7066
7066
|
// server/routes/admin/sessions.ts
|
|
7067
|
-
function openResumeStreamLog(accountId,
|
|
7067
|
+
function openResumeStreamLog(accountId, sessionId) {
|
|
7068
7068
|
const dir = resolvePath(ACCOUNTS_DIR, accountId, "resume-logs");
|
|
7069
7069
|
try {
|
|
7070
7070
|
mkdirSync3(dir, { recursive: true });
|
|
7071
7071
|
} catch {
|
|
7072
7072
|
}
|
|
7073
|
-
return createWriteStream(resolvePath(dir, `${
|
|
7073
|
+
return createWriteStream(resolvePath(dir, `${sessionId}.log`), { flags: "a" });
|
|
7074
7074
|
}
|
|
7075
7075
|
var healPending = /* @__PURE__ */ new Map();
|
|
7076
7076
|
function markHealPending(accountId, attachmentId) {
|
|
@@ -7090,7 +7090,7 @@ function clearHealPending(accountId, attachmentId) {
|
|
|
7090
7090
|
function isHealPending(accountId, attachmentId) {
|
|
7091
7091
|
return healPending.get(accountId)?.has(attachmentId) ?? false;
|
|
7092
7092
|
}
|
|
7093
|
-
function validateAndShapeAttachments(raws, conversationAccountId,
|
|
7093
|
+
function validateAndShapeAttachments(raws, conversationAccountId, sessionId, messageId, streamLogPath) {
|
|
7094
7094
|
const chips = [];
|
|
7095
7095
|
let valid = 0;
|
|
7096
7096
|
let invalid = 0;
|
|
@@ -7102,7 +7102,7 @@ function validateAndShapeAttachments(raws, conversationAccountId, conversationId
|
|
|
7102
7102
|
if (reason) {
|
|
7103
7103
|
invalid++;
|
|
7104
7104
|
try {
|
|
7105
|
-
streamLogPath.write(`[${(/* @__PURE__ */ new Date()).toISOString()}] [attachment-rehydrate-invalid]
|
|
7105
|
+
streamLogPath.write(`[${(/* @__PURE__ */ new Date()).toISOString()}] [attachment-rehydrate-invalid] sessionId=${sessionId.slice(0, 8)} messageId=${messageId.slice(0, 8)} attachmentId=${(a.attachmentId || "").slice(0, 8)} reason=${reason}
|
|
7106
7106
|
`);
|
|
7107
7107
|
} catch {
|
|
7108
7108
|
}
|
|
@@ -7118,7 +7118,7 @@ function validateAndShapeAttachments(raws, conversationAccountId, conversationId
|
|
|
7118
7118
|
}
|
|
7119
7119
|
return { chips, valid, invalid };
|
|
7120
7120
|
}
|
|
7121
|
-
function reconstructAssistantEvents(content, components,
|
|
7121
|
+
function reconstructAssistantEvents(content, components, sessionId, messageId, streamLogPath) {
|
|
7122
7122
|
if (components.length === 0) {
|
|
7123
7123
|
return {
|
|
7124
7124
|
events: content.length > 0 ? [{ type: "text", content }] : [],
|
|
@@ -7162,7 +7162,7 @@ function reconstructAssistantEvents(content, components, conversationId, message
|
|
|
7162
7162
|
invalid += 1;
|
|
7163
7163
|
const notice = `[component-rehydrate-invalid] ${c.name || "<unnamed>"} could not be restored (reason=${invalidReason})`;
|
|
7164
7164
|
events.push({ type: "text", content: notice, _invalid: true });
|
|
7165
|
-
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] [component-rehydrate-invalid]
|
|
7165
|
+
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] [component-rehydrate-invalid] sessionId=${sessionId.slice(0, 8)} messageId=${messageId.slice(0, 8)} name=${c.name || "<unnamed>"} reason=${invalidReason}
|
|
7166
7166
|
`;
|
|
7167
7167
|
try {
|
|
7168
7168
|
streamLogPath.write(line);
|
|
@@ -7215,7 +7215,7 @@ app14.get("/", requireAdminSession, async (c) => {
|
|
|
7215
7215
|
try {
|
|
7216
7216
|
const flushed = await listAdminSessions(accountId, userId, 20);
|
|
7217
7217
|
const sessions = flushed.map((r) => ({
|
|
7218
|
-
|
|
7218
|
+
sessionId: r.sessionId,
|
|
7219
7219
|
cacheKey: null,
|
|
7220
7220
|
name: r.name,
|
|
7221
7221
|
updatedAt: r.updatedAt,
|
|
@@ -7251,7 +7251,7 @@ app14.post("/new", requireAdminSession, async (c) => {
|
|
|
7251
7251
|
registerSession(newCacheKey, "admin", accountId, void 0, userId, userName);
|
|
7252
7252
|
unregisterSession(oldCacheKey);
|
|
7253
7253
|
console.log(`[admin-chat] new-conversation outcome=ok oldKey=${oldCacheKey.slice(0, 8)} newKey=${newCacheKey.slice(0, 8)}`);
|
|
7254
|
-
return c.json({ session_key: newSignedSessionToken,
|
|
7254
|
+
return c.json({ session_key: newSignedSessionToken, sessionId: null });
|
|
7255
7255
|
});
|
|
7256
7256
|
app14.post("/switch", requireAdminSession, async (c) => {
|
|
7257
7257
|
const cacheKey = c.var.cacheKey;
|
|
@@ -7277,21 +7277,21 @@ app14.post("/switch", requireAdminSession, async (c) => {
|
|
|
7277
7277
|
console.error(`[session-switch] reject reason=ownership-mismatch from=${cacheKey.slice(0, 8)} target=${targetCacheKey.slice(0, 8)} accountMatch=${targetAccountId === accountId} userMatch=${targetUserId === userId}`);
|
|
7278
7278
|
return c.json({ error: "Target session not owned by current operator" }, 403);
|
|
7279
7279
|
}
|
|
7280
|
-
const
|
|
7281
|
-
console.log(`[session-switch] from=${cacheKey.slice(0, 8)} to=${targetCacheKey.slice(0, 8)} targetConvId=${
|
|
7282
|
-
return c.json({ session_key: targetSignedSessionToken,
|
|
7280
|
+
const targetSessionId = getSessionIdForSession(targetCacheKey) ?? null;
|
|
7281
|
+
console.log(`[session-switch] from=${cacheKey.slice(0, 8)} to=${targetCacheKey.slice(0, 8)} targetConvId=${targetSessionId?.slice(0, 8) ?? "none"} accountId=${accountId.slice(0, 8)}`);
|
|
7282
|
+
return c.json({ session_key: targetSignedSessionToken, sessionId: targetSessionId });
|
|
7283
7283
|
});
|
|
7284
7284
|
app14.delete("/:id", requireAdminSession, async (c) => {
|
|
7285
|
-
const
|
|
7285
|
+
const sessionId = c.req.param("id");
|
|
7286
7286
|
const cacheKey = c.var.cacheKey;
|
|
7287
7287
|
const accountId = getAccountIdForSession(cacheKey);
|
|
7288
7288
|
if (!accountId) return c.json({ error: "Account not found for session" }, 401);
|
|
7289
|
-
const owned = await verifyConversationOwnership(
|
|
7289
|
+
const owned = await verifyConversationOwnership(sessionId, accountId);
|
|
7290
7290
|
if (!owned) return c.json({ error: "Conversation not found" }, 404);
|
|
7291
7291
|
const managerPort = requirePortEnv("CLAUDE_SESSION_MANAGER_PORT", { tag: "admin-conversation-delete" });
|
|
7292
7292
|
const managerBase3 = `http://127.0.0.1:${managerPort}`;
|
|
7293
7293
|
const outcome = await cascadeAdminConversationDelete({
|
|
7294
|
-
|
|
7294
|
+
sessionId,
|
|
7295
7295
|
accountId,
|
|
7296
7296
|
managerBase: managerBase3
|
|
7297
7297
|
});
|
|
@@ -7311,7 +7311,7 @@ app14.delete("/:id", requireAdminSession, async (c) => {
|
|
|
7311
7311
|
error: "jsonl-purge-failed",
|
|
7312
7312
|
detail: outcome.message,
|
|
7313
7313
|
claudeSessionId: outcome.claudeSessionId,
|
|
7314
|
-
|
|
7314
|
+
sessionId,
|
|
7315
7315
|
claudeSessionIdsPurged: outcome.claudeSessionIdsPurged
|
|
7316
7316
|
},
|
|
7317
7317
|
outcome.status >= 400 && outcome.status < 600 ? outcome.status : 502
|
|
@@ -7321,14 +7321,14 @@ app14.delete("/:id", requireAdminSession, async (c) => {
|
|
|
7321
7321
|
{
|
|
7322
7322
|
error: "graph-delete-failed",
|
|
7323
7323
|
detail: outcome.message,
|
|
7324
|
-
|
|
7324
|
+
sessionId,
|
|
7325
7325
|
claudeSessionIdsPurged: outcome.claudeSessionIdsPurged
|
|
7326
7326
|
},
|
|
7327
7327
|
500
|
|
7328
7328
|
);
|
|
7329
7329
|
});
|
|
7330
7330
|
app14.post("/:id/resume", async (c) => {
|
|
7331
|
-
const
|
|
7331
|
+
const sessionId = c.req.param("id");
|
|
7332
7332
|
const t0 = Date.now();
|
|
7333
7333
|
const signedSessionToken = c.req.query("session_key") ?? "";
|
|
7334
7334
|
if (!signedSessionToken) {
|
|
@@ -7340,7 +7340,7 @@ app14.post("/:id/resume", async (c) => {
|
|
|
7340
7340
|
let result = validateSession(cacheKey, "admin", signedSessionToken);
|
|
7341
7341
|
if (!result.ok) {
|
|
7342
7342
|
if (result.reason === "session-not-registered") {
|
|
7343
|
-
const bridge = await tryCookieBridgeForConversation(c, cacheKey,
|
|
7343
|
+
const bridge = await tryCookieBridgeForConversation(c, cacheKey, sessionId);
|
|
7344
7344
|
if (!bridge.ok) {
|
|
7345
7345
|
if (bridge.reason === "conversation-not-found") {
|
|
7346
7346
|
return c.json({ error: "Conversation not found" }, 404);
|
|
@@ -7371,11 +7371,11 @@ app14.post("/:id/resume", async (c) => {
|
|
|
7371
7371
|
if (!userId && !bridged) {
|
|
7372
7372
|
return c.json({ error: "Session missing user context" }, 400);
|
|
7373
7373
|
}
|
|
7374
|
-
const updatedAt = await verifyAndGetConversationUpdatedAt(
|
|
7374
|
+
const updatedAt = await verifyAndGetConversationUpdatedAt(sessionId, accountId);
|
|
7375
7375
|
if (updatedAt === null) return c.json({ error: "Conversation not found" }, 404);
|
|
7376
|
-
const persistedAgentSessionId = await getAgentSessionIdForConversation(
|
|
7377
|
-
|
|
7378
|
-
const streamLogPath = openResumeStreamLog(accountId,
|
|
7376
|
+
const persistedAgentSessionId = await getAgentSessionIdForConversation(sessionId);
|
|
7377
|
+
setSessionIdForSession(cacheKey, sessionId);
|
|
7378
|
+
const streamLogPath = openResumeStreamLog(accountId, sessionId);
|
|
7379
7379
|
const tag = persistedAgentSessionId ? `agentSessionId=${persistedAgentSessionId.slice(0, 8)}\u2026` : "agentSessionId=missing";
|
|
7380
7380
|
let messages = [];
|
|
7381
7381
|
let neo4jMessages = [];
|
|
@@ -7386,9 +7386,9 @@ app14.post("/:id/resume", async (c) => {
|
|
|
7386
7386
|
let jsonlHealOk = 0;
|
|
7387
7387
|
let jsonlHealFail = 0;
|
|
7388
7388
|
try {
|
|
7389
|
-
neo4jMessages = await getRecentMessages(
|
|
7389
|
+
neo4jMessages = await getRecentMessages(sessionId);
|
|
7390
7390
|
} catch (err) {
|
|
7391
|
-
console.error(`[admin-resume] ${(/* @__PURE__ */ new Date()).toISOString()} getRecentMessages failed:
|
|
7391
|
+
console.error(`[admin-resume] ${(/* @__PURE__ */ new Date()).toISOString()} getRecentMessages failed: sessionId=${sessionId.slice(0, 8)}\u2026 error=${err instanceof Error ? err.message : String(err)}`);
|
|
7392
7392
|
return c.json({ error: "Failed to load conversation messages" }, 500);
|
|
7393
7393
|
}
|
|
7394
7394
|
if (persistedAgentSessionId) {
|
|
@@ -7398,7 +7398,7 @@ app14.post("/:id/resume", async (c) => {
|
|
|
7398
7398
|
jsonlMalformedLines = replay.malformedLines;
|
|
7399
7399
|
jsonlReplayMessages = replay.messages;
|
|
7400
7400
|
if (replay.jsonlMissing) {
|
|
7401
|
-
console.error(`[jsonl-resume-miss] cacheKey=${cacheKey.slice(0, 8)}\u2026
|
|
7401
|
+
console.error(`[jsonl-resume-miss] cacheKey=${cacheKey.slice(0, 8)}\u2026 sessionId=${sessionId.slice(0, 8)}\u2026 agentSessionId=${persistedAgentSessionId.slice(0, 8)}\u2026 expectedPath=${jsonlPath} configDir=${process.env.CLAUDE_CONFIG_DIR ?? "<unset>"}`);
|
|
7402
7402
|
}
|
|
7403
7403
|
} else {
|
|
7404
7404
|
jsonlMissing = true;
|
|
@@ -7499,7 +7499,7 @@ app14.post("/:id/resume", async (c) => {
|
|
|
7499
7499
|
}
|
|
7500
7500
|
}));
|
|
7501
7501
|
const messageId = await persistMessage(
|
|
7502
|
-
|
|
7502
|
+
sessionId,
|
|
7503
7503
|
q.role,
|
|
7504
7504
|
q.content,
|
|
7505
7505
|
accountId,
|
|
@@ -7511,14 +7511,14 @@ app14.post("/:id/resume", async (c) => {
|
|
|
7511
7511
|
);
|
|
7512
7512
|
jsonlHealOk += 1;
|
|
7513
7513
|
try {
|
|
7514
|
-
streamLogPath.write(`[${(/* @__PURE__ */ new Date()).toISOString()}] [admin-persist-heal] convId=${
|
|
7514
|
+
streamLogPath.write(`[${(/* @__PURE__ */ new Date()).toISOString()}] [admin-persist-heal] convId=${sessionId.slice(0, 8)} turnIndex=${i} role=${q.role} outcome=ok messageId=${(messageId ?? "").slice(0, 8)}
|
|
7515
7515
|
`);
|
|
7516
7516
|
} catch {
|
|
7517
7517
|
}
|
|
7518
7518
|
} catch (err) {
|
|
7519
7519
|
jsonlHealFail += 1;
|
|
7520
7520
|
try {
|
|
7521
|
-
streamLogPath.write(`[${(/* @__PURE__ */ new Date()).toISOString()}] [admin-persist-heal] convId=${
|
|
7521
|
+
streamLogPath.write(`[${(/* @__PURE__ */ new Date()).toISOString()}] [admin-persist-heal] convId=${sessionId.slice(0, 8)} turnIndex=${i} role=${q.role} outcome=fail reason=${JSON.stringify((err instanceof Error ? err.message : String(err)).slice(0, 200))}
|
|
7522
7522
|
`);
|
|
7523
7523
|
} catch {
|
|
7524
7524
|
}
|
|
@@ -7537,7 +7537,7 @@ app14.post("/:id/resume", async (c) => {
|
|
|
7537
7537
|
const components = m.components ?? [];
|
|
7538
7538
|
const rawAttachments = m.attachments ?? [];
|
|
7539
7539
|
if (m.role !== "assistant") {
|
|
7540
|
-
const { chips, valid: valid2, invalid: invalid2 } = validateAndShapeAttachments(rawAttachments, accountId,
|
|
7540
|
+
const { chips, valid: valid2, invalid: invalid2 } = validateAndShapeAttachments(rawAttachments, accountId, sessionId, m.messageId, streamLogPath);
|
|
7541
7541
|
totalAttachments += valid2;
|
|
7542
7542
|
totalAttachmentInvalid += invalid2;
|
|
7543
7543
|
const cleanedContent = chips.length > 0 ? stripAttachmentMetaSuffix(m.content) : m.content;
|
|
@@ -7550,7 +7550,7 @@ app14.post("/:id/resume", async (c) => {
|
|
|
7550
7550
|
...chips.length > 0 ? { attachments: chips } : {}
|
|
7551
7551
|
};
|
|
7552
7552
|
}
|
|
7553
|
-
const { events, valid, invalid, submittedEventIndices } = reconstructAssistantEvents(m.content, components,
|
|
7553
|
+
const { events, valid, invalid, submittedEventIndices } = reconstructAssistantEvents(m.content, components, sessionId, m.messageId, streamLogPath);
|
|
7554
7554
|
totalValid += valid;
|
|
7555
7555
|
totalInvalid += invalid;
|
|
7556
7556
|
totalComponents += components.length;
|
|
@@ -7569,27 +7569,27 @@ app14.post("/:id/resume", async (c) => {
|
|
|
7569
7569
|
const reason = bridged ? "post-restart" : "page-refresh";
|
|
7570
7570
|
try {
|
|
7571
7571
|
const source = jsonlMissing ? persistedAgentSessionId ? "jsonl-missing" : "neo4j-only" : "jsonl";
|
|
7572
|
-
streamLogPath.write(`[${(/* @__PURE__ */ new Date()).toISOString()}] [admin-resume] reason=${reason} source=${source} cacheKey=${cacheKey.slice(0, 8)}
|
|
7572
|
+
streamLogPath.write(`[${(/* @__PURE__ */ new Date()).toISOString()}] [admin-resume] reason=${reason} source=${source} cacheKey=${cacheKey.slice(0, 8)} sessionId=${sessionId.slice(0, 8)} ${tag} loadedMessages=${messages.length} jsonlReplayMessages=${jsonlReplayMessages.length} neo4jMessages=${neo4jMessages.length} jsonlMalformed=${jsonlMalformedLines} componentCount=${totalComponents} userAttachmentCount=${totalAttachments} syntheticHidden=${syntheticHidden}
|
|
7573
7573
|
`);
|
|
7574
7574
|
if (totalComponents > 0) {
|
|
7575
|
-
streamLogPath.write(`[${(/* @__PURE__ */ new Date()).toISOString()}] [component-rehydrate]
|
|
7575
|
+
streamLogPath.write(`[${(/* @__PURE__ */ new Date()).toISOString()}] [component-rehydrate] sessionId=${sessionId.slice(0, 8)} count=${totalComponents} valid=${totalValid} invalid=${totalInvalid} textRuns=${textRuns}
|
|
7576
7576
|
`);
|
|
7577
7577
|
}
|
|
7578
7578
|
if (totalAttachments > 0 || totalAttachmentInvalid > 0) {
|
|
7579
|
-
streamLogPath.write(`[${(/* @__PURE__ */ new Date()).toISOString()}] [attachment-rehydrate]
|
|
7579
|
+
streamLogPath.write(`[${(/* @__PURE__ */ new Date()).toISOString()}] [attachment-rehydrate] sessionId=${sessionId.slice(0, 8)} userMessages=${userMessageCount} attachments=${totalAttachments} invalid=${totalAttachmentInvalid}
|
|
7580
7580
|
`);
|
|
7581
7581
|
}
|
|
7582
7582
|
if (jsonlHealMissing > 0) {
|
|
7583
|
-
streamLogPath.write(`[${(/* @__PURE__ */ new Date()).toISOString()}] [admin-resume-heal]
|
|
7583
|
+
streamLogPath.write(`[${(/* @__PURE__ */ new Date()).toISOString()}] [admin-resume-heal] sessionId=${sessionId.slice(0, 8)} missingTurns=${jsonlHealMissing} healOk=${jsonlHealOk} healFail=${jsonlHealFail} note=async-writes-may-still-be-in-flight
|
|
7584
7584
|
`);
|
|
7585
7585
|
}
|
|
7586
7586
|
} catch {
|
|
7587
7587
|
}
|
|
7588
7588
|
const age = formatAge(updatedAt);
|
|
7589
|
-
console.log(`[admin-resume] ${(/* @__PURE__ */ new Date()).toISOString()} reason=${reason}
|
|
7590
|
-
console.log(`[admin-session-restore] cacheKey=${cacheKey.slice(0, 8)}
|
|
7589
|
+
console.log(`[admin-resume] ${(/* @__PURE__ */ new Date()).toISOString()} reason=${reason} sessionId=${sessionId.slice(0, 8)}\u2026 age=${age} loaded=${messages.length} messages ${tag} components=${totalComponents} attachments=${totalAttachments} syntheticHidden=${syntheticHidden} jsonlMissing=${jsonlMissing} healMissing=${jsonlHealMissing} cacheKey=${cacheKey.slice(0, 8)}\u2026`);
|
|
7590
|
+
console.log(`[admin-session-restore] cacheKey=${cacheKey.slice(0, 8)} sessionId=${sessionId.slice(0, 8)} messageCount=${rehydrated.length} ms=${Date.now() - t0}`);
|
|
7591
7591
|
return c.json({
|
|
7592
|
-
|
|
7592
|
+
sessionId,
|
|
7593
7593
|
messages: rehydrated,
|
|
7594
7594
|
resumeHeal: {
|
|
7595
7595
|
missingTurns: jsonlHealMissing,
|
|
@@ -7601,7 +7601,7 @@ app14.post("/:id/resume", async (c) => {
|
|
|
7601
7601
|
});
|
|
7602
7602
|
});
|
|
7603
7603
|
app14.put("/:id/label", requireAdminSession, async (c) => {
|
|
7604
|
-
const
|
|
7604
|
+
const sessionId = c.req.param("id");
|
|
7605
7605
|
const cacheKey = c.var.cacheKey;
|
|
7606
7606
|
let body;
|
|
7607
7607
|
try {
|
|
@@ -7611,7 +7611,7 @@ app14.put("/:id/label", requireAdminSession, async (c) => {
|
|
|
7611
7611
|
}
|
|
7612
7612
|
const accountId = getAccountIdForSession(cacheKey);
|
|
7613
7613
|
if (!accountId) return c.json({ error: "Account not found for session" }, 401);
|
|
7614
|
-
const owned = await verifyConversationOwnership(
|
|
7614
|
+
const owned = await verifyConversationOwnership(sessionId, accountId);
|
|
7615
7615
|
if (!owned) return c.json({ error: "Conversation not found" }, 404);
|
|
7616
7616
|
const label = typeof body.label === "string" ? body.label.trim() : "";
|
|
7617
7617
|
if (!label) return c.json({ error: "label is required and must be non-empty" }, 400);
|
|
@@ -7619,10 +7619,10 @@ app14.put("/:id/label", requireAdminSession, async (c) => {
|
|
|
7619
7619
|
return c.json({ error: `label must be ${LABEL_MAX_LENGTH} characters or fewer` }, 400);
|
|
7620
7620
|
}
|
|
7621
7621
|
try {
|
|
7622
|
-
await renameConversation(
|
|
7622
|
+
await renameConversation(sessionId, label);
|
|
7623
7623
|
return c.json({ ok: true });
|
|
7624
7624
|
} catch (err) {
|
|
7625
|
-
console.error(`[persist] manual-label: failed to rename ${
|
|
7625
|
+
console.error(`[persist] manual-label: failed to rename ${sessionId} \u2014 ${err instanceof Error ? err.message : String(err)}`);
|
|
7626
7626
|
return c.json({ error: "Failed to rename session" }, 500);
|
|
7627
7627
|
}
|
|
7628
7628
|
});
|
|
@@ -7978,7 +7978,7 @@ async function performSpawnWithInitialMessage(args) {
|
|
|
7978
7978
|
specialistDomains,
|
|
7979
7979
|
tunnelUrl,
|
|
7980
7980
|
// Task 382 — thread the active conversation's UUID through to the
|
|
7981
|
-
// manager so the PTY env carries
|
|
7981
|
+
// manager so the PTY env carries SESSION_NODE_ID. Undefined is
|
|
7982
7982
|
// legitimate (autonomous spawns); the manager's UUID gate filters
|
|
7983
7983
|
// unshapely values.
|
|
7984
7984
|
conversationNodeId: args.conversationNodeId
|
|
@@ -8018,9 +8018,9 @@ async function performSpawnWithInitialMessage(args) {
|
|
|
8018
8018
|
claudeSessionId
|
|
8019
8019
|
};
|
|
8020
8020
|
}
|
|
8021
|
-
function mintTranscriptEdge(
|
|
8022
|
-
if (!
|
|
8023
|
-
void linkConversationTranscript(
|
|
8021
|
+
function mintTranscriptEdge(sessionId, claudeSessionId, accountId) {
|
|
8022
|
+
if (!sessionId || !claudeSessionId) return;
|
|
8023
|
+
void linkConversationTranscript(sessionId, claudeSessionId, accountId);
|
|
8024
8024
|
}
|
|
8025
8025
|
var requireAdminSessionUnlessLoopbackSpawn = async (c, next) => {
|
|
8026
8026
|
const remoteAddr = c.env?.incoming?.socket?.remoteAddress ?? "";
|
|
@@ -8076,7 +8076,7 @@ app15.post("/", async (c) => {
|
|
|
8076
8076
|
const specialist = typeof body.specialist === "string" && /^[A-Za-z0-9_-]{1,64}$/.test(body.specialist) ? body.specialist : void 0;
|
|
8077
8077
|
const model = typeof body.model === "string" && /^[A-Za-z0-9._-]{1,64}$/.test(body.model) ? body.model : void 0;
|
|
8078
8078
|
console.log(`${TAG17} spawn-request-in surface=${authSurface} accountId=${senderId.slice(0, 8)} userId=${userId ? userId.slice(0, 8) : "absent"} channel=${channel} permissionMode=${permissionMode ?? "default"} specialist=${specialist ?? "none"} model=${model ?? "default"} initialMessage=${initialMessage ? "yes" : "no"}`);
|
|
8079
|
-
const conversationNodeId = cacheKey ?
|
|
8079
|
+
const conversationNodeId = cacheKey ? getSessionIdForSession(cacheKey) : void 0;
|
|
8080
8080
|
const { response, claudeSessionId } = await performSpawnWithInitialMessage({
|
|
8081
8081
|
senderId,
|
|
8082
8082
|
userId,
|
|
@@ -8090,7 +8090,7 @@ app15.post("/", async (c) => {
|
|
|
8090
8090
|
conversationNodeId
|
|
8091
8091
|
});
|
|
8092
8092
|
mintTranscriptEdge(
|
|
8093
|
-
cacheKey ?
|
|
8093
|
+
cacheKey ? getSessionIdForSession(cacheKey) : void 0,
|
|
8094
8094
|
claudeSessionId,
|
|
8095
8095
|
senderId
|
|
8096
8096
|
);
|
|
@@ -8167,11 +8167,11 @@ app15.post("/resume", async (c) => {
|
|
|
8167
8167
|
specialistDomains,
|
|
8168
8168
|
tunnelUrl,
|
|
8169
8169
|
// Task 382 — resume parity with /spawn: thread the active
|
|
8170
|
-
//
|
|
8171
|
-
//
|
|
8170
|
+
// sessionId so the re-spawned PTY's MCP env carries
|
|
8171
|
+
// SESSION_NODE_ID. Undefined when no active conversation is
|
|
8172
8172
|
// bound to this cacheKey (rare for resume — the user is by
|
|
8173
8173
|
// definition continuing a known conversation).
|
|
8174
|
-
conversationNodeId:
|
|
8174
|
+
conversationNodeId: getSessionIdForSession(cacheKey)
|
|
8175
8175
|
})
|
|
8176
8176
|
}).catch((err) => {
|
|
8177
8177
|
console.error(`${TAG17} fetch-failed op=resume message=${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -8190,7 +8190,7 @@ app15.post("/resume", async (c) => {
|
|
|
8190
8190
|
}
|
|
8191
8191
|
}
|
|
8192
8192
|
mintTranscriptEdge(
|
|
8193
|
-
|
|
8193
|
+
getSessionIdForSession(cacheKey),
|
|
8194
8194
|
claudeSessionIdFromResume,
|
|
8195
8195
|
senderId
|
|
8196
8196
|
);
|
|
@@ -8226,15 +8226,15 @@ app15.post("/:sessionId/rename", async (c) => {
|
|
|
8226
8226
|
return new Response(upstream.body, { status: upstream.status, headers: upstream.headers });
|
|
8227
8227
|
});
|
|
8228
8228
|
app15.delete("/:sessionId", async (c) => {
|
|
8229
|
-
const
|
|
8229
|
+
const claudeSessionId = c.req.param("sessionId");
|
|
8230
8230
|
const cacheKey = c.get("cacheKey") ?? "";
|
|
8231
8231
|
const accountId = getAccountIdForSession(cacheKey) ?? "";
|
|
8232
8232
|
if (!accountId) return c.json({ error: "admin-account-not-resolved" }, 500);
|
|
8233
|
-
const
|
|
8234
|
-
if (!
|
|
8235
|
-
console.log(`[admin-conversation-delete] reason=no-conversation-mapping claudeSessionId=${
|
|
8233
|
+
const sessionId = await getSessionIdByClaudeSessionId(claudeSessionId, accountId);
|
|
8234
|
+
if (!sessionId) {
|
|
8235
|
+
console.log(`[admin-conversation-delete] reason=no-conversation-mapping claudeSessionId=${claudeSessionId.slice(0, 8)}`);
|
|
8236
8236
|
const upstream = await fetch(
|
|
8237
|
-
`${managerBase2()}/${encodeURIComponent(
|
|
8237
|
+
`${managerBase2()}/${encodeURIComponent(claudeSessionId)}`,
|
|
8238
8238
|
{ method: "DELETE" }
|
|
8239
8239
|
).catch((err) => {
|
|
8240
8240
|
console.error(`${TAG17} fetch-failed op=delete message=${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -8245,13 +8245,13 @@ app15.delete("/:sessionId", async (c) => {
|
|
|
8245
8245
|
}
|
|
8246
8246
|
let siblings;
|
|
8247
8247
|
try {
|
|
8248
|
-
siblings = await getConversationClaudeSessionIds(
|
|
8248
|
+
siblings = await getConversationClaudeSessionIds(sessionId, accountId);
|
|
8249
8249
|
} catch {
|
|
8250
|
-
siblings = [
|
|
8250
|
+
siblings = [claudeSessionId];
|
|
8251
8251
|
}
|
|
8252
|
-
const all = [
|
|
8252
|
+
const all = [claudeSessionId, ...siblings.filter((s) => s !== claudeSessionId)];
|
|
8253
8253
|
const outcome = await cascadeAdminConversationDelete({
|
|
8254
|
-
|
|
8254
|
+
sessionId,
|
|
8255
8255
|
accountId,
|
|
8256
8256
|
managerBase: managerBase2(),
|
|
8257
8257
|
claudeSessionIds: all
|
|
@@ -8272,7 +8272,7 @@ app15.delete("/:sessionId", async (c) => {
|
|
|
8272
8272
|
error: "jsonl-purge-failed",
|
|
8273
8273
|
detail: outcome.message,
|
|
8274
8274
|
claudeSessionId: outcome.claudeSessionId,
|
|
8275
|
-
|
|
8275
|
+
sessionId,
|
|
8276
8276
|
claudeSessionIdsPurged: outcome.claudeSessionIdsPurged
|
|
8277
8277
|
},
|
|
8278
8278
|
outcome.status >= 400 && outcome.status < 600 ? outcome.status : 502
|
|
@@ -8282,7 +8282,7 @@ app15.delete("/:sessionId", async (c) => {
|
|
|
8282
8282
|
{
|
|
8283
8283
|
error: "graph-delete-failed",
|
|
8284
8284
|
detail: outcome.message,
|
|
8285
|
-
|
|
8285
|
+
sessionId,
|
|
8286
8286
|
claudeSessionIdsPurged: outcome.claudeSessionIdsPurged
|
|
8287
8287
|
},
|
|
8288
8288
|
500
|
|
@@ -8508,7 +8508,7 @@ var UNIQUE_KEYS_BY_LABEL = {
|
|
|
8508
8508
|
KnowledgeDocument: ["attachmentId"],
|
|
8509
8509
|
ConversationArchive: ["conversationIdentity"],
|
|
8510
8510
|
DigitalDocument: ["attachmentId"],
|
|
8511
|
-
Conversation: ["
|
|
8511
|
+
Conversation: ["sessionId"],
|
|
8512
8512
|
Message: ["messageId"],
|
|
8513
8513
|
Workflow: ["workflowId"],
|
|
8514
8514
|
WorkflowStep: ["stepId"],
|
|
@@ -10275,7 +10275,7 @@ async function handleNeighbourhood(c, accountId) {
|
|
|
10275
10275
|
const messageCount = nodes.filter((n) => n.labels.includes("Message")).length;
|
|
10276
10276
|
if (conversationNode && messageCount >= 2) {
|
|
10277
10277
|
console.error(
|
|
10278
|
-
`[graph] cluster-expand kind=conversation
|
|
10278
|
+
`[graph] cluster-expand kind=conversation sessionId=${conversationNode.id} messageCount=${messageCount} reason=click-target-is-${nodes[0]?.labels.includes("Message") ? "message" : "conversation"}`
|
|
10279
10279
|
);
|
|
10280
10280
|
}
|
|
10281
10281
|
}
|
|
@@ -10686,7 +10686,7 @@ app21.post("/", requireAdminSession, async (c) => {
|
|
|
10686
10686
|
const lookup = await session.run(
|
|
10687
10687
|
`MATCH (n)
|
|
10688
10688
|
WHERE elementId(n) = $elementId AND n.accountId = $accountId
|
|
10689
|
-
RETURN labels(n) AS labels, n.
|
|
10689
|
+
RETURN labels(n) AS labels, n.sessionId AS sessionId LIMIT 1`,
|
|
10690
10690
|
{ elementId, accountId }
|
|
10691
10691
|
);
|
|
10692
10692
|
if (lookup.records.length === 0) {
|
|
@@ -10697,14 +10697,14 @@ app21.post("/", requireAdminSession, async (c) => {
|
|
|
10697
10697
|
return c.json({ error: "Node not found" }, 404);
|
|
10698
10698
|
}
|
|
10699
10699
|
const preflightLabels = lookup.records[0].get("labels") ?? [];
|
|
10700
|
-
const
|
|
10700
|
+
const sessionId = lookup.records[0].get("sessionId");
|
|
10701
10701
|
if (preflightLabels.includes("AdminConversation")) {
|
|
10702
|
-
if (!
|
|
10702
|
+
if (!sessionId) {
|
|
10703
10703
|
const elapsed3 = Date.now() - started;
|
|
10704
10704
|
console.error(
|
|
10705
|
-
`[graph-page] delete account=${accountId} elementId=${elementId} by=${by} labels=${preflightLabels.join(",")} route=cascade result=error ms=${elapsed3} err="AdminConversation node has no
|
|
10705
|
+
`[graph-page] delete account=${accountId} elementId=${elementId} by=${by} labels=${preflightLabels.join(",")} route=cascade result=error ms=${elapsed3} err="AdminConversation node has no sessionId"`
|
|
10706
10706
|
);
|
|
10707
|
-
return c.json({ error: "AdminConversation node is missing
|
|
10707
|
+
return c.json({ error: "AdminConversation node is missing sessionId" }, 500);
|
|
10708
10708
|
}
|
|
10709
10709
|
const managerPort = requirePortEnv("CLAUDE_SESSION_MANAGER_PORT", { tag: "graph-page-cascade" });
|
|
10710
10710
|
const managerBase3 = `http://127.0.0.1:${managerPort}`;
|
|
@@ -10713,7 +10713,7 @@ app21.post("/", requireAdminSession, async (c) => {
|
|
|
10713
10713
|
} catch {
|
|
10714
10714
|
}
|
|
10715
10715
|
const outcome = await cascadeAdminConversationDelete({
|
|
10716
|
-
|
|
10716
|
+
sessionId,
|
|
10717
10717
|
accountId,
|
|
10718
10718
|
managerBase: managerBase3
|
|
10719
10719
|
});
|
|
@@ -10726,7 +10726,7 @@ app21.post("/", requireAdminSession, async (c) => {
|
|
|
10726
10726
|
const response2 = {
|
|
10727
10727
|
route: "cascade",
|
|
10728
10728
|
elementId,
|
|
10729
|
-
|
|
10729
|
+
sessionId,
|
|
10730
10730
|
labels: preflightLabels,
|
|
10731
10731
|
claudeSessionIds: outcome.claudeSessionIds
|
|
10732
10732
|
};
|
|
@@ -10741,7 +10741,7 @@ app21.post("/", requireAdminSession, async (c) => {
|
|
|
10741
10741
|
error: "pty-still-alive",
|
|
10742
10742
|
detail: "stop the session before deleting",
|
|
10743
10743
|
claudeSessionId: outcome.claudeSessionId,
|
|
10744
|
-
|
|
10744
|
+
sessionId
|
|
10745
10745
|
},
|
|
10746
10746
|
409
|
|
10747
10747
|
);
|
|
@@ -10753,7 +10753,7 @@ app21.post("/", requireAdminSession, async (c) => {
|
|
|
10753
10753
|
const response2 = {
|
|
10754
10754
|
route: "cascade",
|
|
10755
10755
|
elementId,
|
|
10756
|
-
|
|
10756
|
+
sessionId,
|
|
10757
10757
|
labels: preflightLabels,
|
|
10758
10758
|
claudeSessionIds: []
|
|
10759
10759
|
};
|
|
@@ -10769,7 +10769,7 @@ app21.post("/", requireAdminSession, async (c) => {
|
|
|
10769
10769
|
error: "jsonl-purge-failed",
|
|
10770
10770
|
detail: outcome.message,
|
|
10771
10771
|
claudeSessionId: outcome.claudeSessionId,
|
|
10772
|
-
|
|
10772
|
+
sessionId,
|
|
10773
10773
|
claudeSessionIdsPurged: outcome.claudeSessionIdsPurged
|
|
10774
10774
|
},
|
|
10775
10775
|
status
|
|
@@ -10782,7 +10782,7 @@ app21.post("/", requireAdminSession, async (c) => {
|
|
|
10782
10782
|
{
|
|
10783
10783
|
error: "graph-delete-failed",
|
|
10784
10784
|
detail: outcome.message,
|
|
10785
|
-
|
|
10785
|
+
sessionId,
|
|
10786
10786
|
claudeSessionIdsPurged: outcome.claudeSessionIdsPurged
|
|
10787
10787
|
},
|
|
10788
10788
|
500
|
|
@@ -12031,24 +12031,24 @@ app33.get("/", async (c) => {
|
|
|
12031
12031
|
return c.json({ error: "post-turn-context-loopback-only" }, 403);
|
|
12032
12032
|
}
|
|
12033
12033
|
}
|
|
12034
|
-
const
|
|
12034
|
+
const sessionId = (c.req.query("sessionId") ?? "").trim();
|
|
12035
12035
|
const accountId = (c.req.query("accountId") ?? "").trim();
|
|
12036
|
-
if (!
|
|
12036
|
+
if (!sessionId) return c.json({ error: "sessionId required" }, 400);
|
|
12037
12037
|
if (!accountId) return c.json({ error: "accountId required" }, 400);
|
|
12038
12038
|
const session = getSession();
|
|
12039
12039
|
const started = Date.now();
|
|
12040
12040
|
try {
|
|
12041
12041
|
const cypher = `
|
|
12042
|
-
MATCH (c:Conversation {
|
|
12042
|
+
MATCH (c:Conversation {sessionId: $sessionId, accountId: $accountId})
|
|
12043
12043
|
MATCH (c)<-[:PRODUCED]-(n)
|
|
12044
12044
|
WHERE coalesce(n.accountId, $accountId) = $accountId
|
|
12045
12045
|
RETURN elementId(n) AS elementId, labels(n) AS labels, properties(n) AS properties, coalesce(n.createdAt, n.observedAt, '') AS sortKey
|
|
12046
12046
|
UNION
|
|
12047
|
-
MATCH (n) WHERE n.
|
|
12047
|
+
MATCH (n) WHERE n.sessionId = $sessionId AND n.accountId = $accountId
|
|
12048
12048
|
RETURN elementId(n) AS elementId, labels(n) AS labels, properties(n) AS properties, coalesce(n.createdAt, n.observedAt, '') AS sortKey
|
|
12049
12049
|
`;
|
|
12050
12050
|
const res = await session.executeRead(
|
|
12051
|
-
(tx) => tx.run(cypher, {
|
|
12051
|
+
(tx) => tx.run(cypher, { sessionId, accountId })
|
|
12052
12052
|
);
|
|
12053
12053
|
const writes = res.records.map((r) => ({
|
|
12054
12054
|
elementId: r.get("elementId"),
|
|
@@ -12059,7 +12059,7 @@ app33.get("/", async (c) => {
|
|
|
12059
12059
|
writes.sort((a, b) => a.sortKey.localeCompare(b.sortKey));
|
|
12060
12060
|
const total = Date.now() - started;
|
|
12061
12061
|
console.log(
|
|
12062
|
-
`${TAG20}
|
|
12062
|
+
`${TAG20} sessionId=${sessionId} accountId=${accountId} writes=${writes.length} ms=${total}`
|
|
12063
12063
|
);
|
|
12064
12064
|
return c.json({
|
|
12065
12065
|
writes: writes.map(({ elementId, labels, properties }) => ({ elementId, labels, properties }))
|
|
@@ -12068,7 +12068,7 @@ app33.get("/", async (c) => {
|
|
|
12068
12068
|
const elapsed = Date.now() - started;
|
|
12069
12069
|
const message = err instanceof Error ? err.message : String(err);
|
|
12070
12070
|
console.error(
|
|
12071
|
-
`${TAG20} neo4j-unreachable
|
|
12071
|
+
`${TAG20} neo4j-unreachable sessionId=${sessionId} ms=${elapsed} err="${message}"`
|
|
12072
12072
|
);
|
|
12073
12073
|
return c.json({ error: `post-turn-context unavailable: ${message}` }, 503);
|
|
12074
12074
|
} finally {
|