@sentry/mcp-server 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/{agent-0WAnUgat.js → agent-9s0S2VUD.js} +2 -2
- package/dist/{agent-0WAnUgat.js.map → agent-9s0S2VUD.js.map} +1 -1
- package/dist/{agent-Cu85yHYm.d.ts → agent-BI-VWYjJ.d.ts} +14 -14
- package/dist/agent-BI-VWYjJ.d.ts.map +1 -0
- package/dist/{agent-DYfi9MFV.d.cts → agent-BmPRmM9x.d.cts} +6 -6
- package/dist/{agent-DYfi9MFV.d.cts.map → agent-BmPRmM9x.d.cts.map} +1 -1
- package/dist/{agent-Dkgkv7Iz.js → agent-BsCC60AU.js} +2 -2
- package/dist/{agent-Dkgkv7Iz.js.map → agent-BsCC60AU.js.map} +1 -1
- package/dist/{agent-CyyRLYbF.cjs → agent-CirZFiaJ.cjs} +2 -2
- package/dist/{agent-CyyRLYbF.cjs.map → agent-CirZFiaJ.cjs.map} +1 -1
- package/dist/{agent-Cm9hEq5d.cjs → agent-CnHO6uyy.cjs} +2 -2
- package/dist/{agent-Cm9hEq5d.cjs.map → agent-CnHO6uyy.cjs.map} +1 -1
- package/dist/{agent-TEZG63ug.d.cts → agent-D8Mz9ung.d.cts} +2 -2
- package/dist/{agent-TEZG63ug.d.cts.map → agent-D8Mz9ung.d.cts.map} +1 -1
- package/dist/{agent-C1Ros3Xx.js → agent-DD0p64Dq.js} +2 -2
- package/dist/{agent-C1Ros3Xx.js.map → agent-DD0p64Dq.js.map} +1 -1
- package/dist/{agent-BeTXxskw.d.ts → agent-DQdvMLcG.d.ts} +4 -4
- package/dist/{agent-BeTXxskw.d.ts.map → agent-DQdvMLcG.d.ts.map} +1 -1
- package/dist/{agent-DtCRTWPZ.cjs → agent-DaUNg6Ut.cjs} +2 -2
- package/dist/{agent-DtCRTWPZ.cjs.map → agent-DaUNg6Ut.cjs.map} +1 -1
- package/dist/{analyze-issue-with-seer-Ji3KDm0O.js → analyze-issue-with-seer-6OwT1RJP.js} +3 -3
- package/dist/analyze-issue-with-seer-6OwT1RJP.js.map +1 -0
- package/dist/{analyze-issue-with-seer-B90r4g5J.cjs → analyze-issue-with-seer-wsCEFdZs.cjs} +3 -3
- package/dist/{analyze-issue-with-seer-Ji3KDm0O.js.map → analyze-issue-with-seer-wsCEFdZs.cjs.map} +1 -1
- package/dist/{api-CBHyxA3Q.js → api-BCICbJoI.js} +2 -2
- package/dist/{api-CBHyxA3Q.js.map → api-BCICbJoI.js.map} +1 -1
- package/dist/{api-CHgBJOv9.cjs → api-CfzBwheo.cjs} +2 -2
- package/dist/{api-CHgBJOv9.cjs.map → api-CfzBwheo.cjs.map} +1 -1
- package/dist/api-client/client.cjs +3 -3
- package/dist/api-client/client.d.cts +3 -3
- package/dist/api-client/client.d.ts +3 -3
- package/dist/api-client/client.js +3 -3
- package/dist/api-client/index.cjs +6 -3
- package/dist/api-client/index.d.cts +4 -4
- package/dist/api-client/index.d.ts +4 -4
- package/dist/api-client/index.js +4 -4
- package/dist/api-client/schema.cjs +4 -1
- package/dist/api-client/schema.d.cts +2 -2
- package/dist/api-client/schema.d.ts +2 -2
- package/dist/api-client/schema.js +2 -2
- package/dist/api-client/types.d.cts +3 -3
- package/dist/api-client/types.d.ts +3 -3
- package/dist/{callEmbeddedAgent-BPS472yg.cjs → callEmbeddedAgent-COB8Jrcn.cjs} +3 -2
- package/dist/{callEmbeddedAgent-BPS472yg.cjs.map → callEmbeddedAgent-COB8Jrcn.cjs.map} +1 -1
- package/dist/{callEmbeddedAgent-DavTx3Qo.js → callEmbeddedAgent-rEUWAl2g.js} +3 -2
- package/dist/{callEmbeddedAgent-DavTx3Qo.js.map → callEmbeddedAgent-rEUWAl2g.js.map} +1 -1
- package/dist/{client-0n2-4zOO.d.cts → client-8_aKE-B-.d.cts} +25 -18
- package/dist/client-8_aKE-B-.d.cts.map +1 -0
- package/dist/{client-ByOC8aCf.d.ts → client-BGVY6gBL.d.ts} +24 -17
- package/dist/client-BGVY6gBL.d.ts.map +1 -0
- package/dist/{client-B7hvqupZ.js → client-Be1DR1al.js} +33 -16
- package/dist/client-Be1DR1al.js.map +1 -0
- package/dist/{client-cC79LUJ5.cjs → client-DSxCsnqO.cjs} +32 -15
- package/dist/client-DSxCsnqO.cjs.map +1 -0
- package/dist/{create-dsn-9yIHr10B.cjs → create-dsn-C5vd9Btg.cjs} +5 -5
- package/dist/create-dsn-C5vd9Btg.cjs.map +1 -0
- package/dist/{create-dsn-p2Ep6zDn.js → create-dsn-DBqCDM_6.js} +5 -5
- package/dist/create-dsn-DBqCDM_6.js.map +1 -0
- package/dist/{create-project-CN0UneBm.js → create-project-BsN4Q0cl.js} +6 -6
- package/dist/create-project-BsN4Q0cl.js.map +1 -0
- package/dist/{create-project-BQQx1iLm.cjs → create-project-D4W66CxU.cjs} +6 -6
- package/dist/create-project-D4W66CxU.cjs.map +1 -0
- package/dist/{create-team-CzFrsVdw.js → create-team-DUBAEGGr.js} +4 -4
- package/dist/create-team-DUBAEGGr.js.map +1 -0
- package/dist/{create-team-DFSriKVL.cjs → create-team-DV6XmZkb.cjs} +4 -4
- package/dist/create-team-DV6XmZkb.cjs.map +1 -0
- package/dist/{find-dsns-DhHHtvpj.cjs → find-dsns-BabAfVEt.cjs} +3 -3
- package/dist/find-dsns-BabAfVEt.cjs.map +1 -0
- package/dist/{find-dsns-BzfYjE06.js → find-dsns-C-Q6yJT5.js} +3 -3
- package/dist/find-dsns-C-Q6yJT5.js.map +1 -0
- package/dist/{find-organizations-BJFAElbh.js → find-organizations-Bo-JdU-R.js} +3 -3
- package/dist/{find-organizations-7ooGnnmP.cjs.map → find-organizations-Bo-JdU-R.js.map} +1 -1
- package/dist/{find-organizations-7ooGnnmP.cjs → find-organizations-CEEqa1an.cjs} +3 -3
- package/dist/find-organizations-CEEqa1an.cjs.map +1 -0
- package/dist/{find-projects-BpEGRZya.cjs → find-projects-BWyvosHM.cjs} +4 -4
- package/dist/find-projects-BWyvosHM.cjs.map +1 -0
- package/dist/{find-projects-E5CMFbwU.js → find-projects-zM4CM_xX.js} +4 -4
- package/dist/find-projects-zM4CM_xX.js.map +1 -0
- package/dist/{find-releases-Du5euXKS.cjs → find-releases-DMJrj5wz.cjs} +5 -5
- package/dist/find-releases-DMJrj5wz.cjs.map +1 -0
- package/dist/{find-releases-DWWonhlV.js → find-releases-DzdGLPSN.js} +5 -5
- package/dist/find-releases-DzdGLPSN.js.map +1 -0
- package/dist/{find-teams-BM4yWKe_.js → find-teams-CR_hdlun.js} +4 -4
- package/dist/find-teams-CR_hdlun.js.map +1 -0
- package/dist/{find-teams-Bp6-Iu62.cjs → find-teams-lOqS_719.cjs} +4 -4
- package/dist/find-teams-lOqS_719.cjs.map +1 -0
- package/dist/{formatting-5u-ZFz8H.cjs → formatting-BatGC-29.cjs} +89 -2
- package/dist/formatting-BatGC-29.cjs.map +1 -0
- package/dist/{formatting-ClM7RU4L.d.ts → formatting-Bm1GxhEu.d.ts} +4 -4
- package/dist/formatting-Bm1GxhEu.d.ts.map +1 -0
- package/dist/{formatting-BEgp4WO_.js → formatting-DUODx6N5.js} +89 -2
- package/dist/formatting-DUODx6N5.js.map +1 -0
- package/dist/{formatting-Bw0FWiCH.d.cts → formatting-GZdM57wq.d.cts} +4 -4
- package/dist/formatting-GZdM57wq.d.cts.map +1 -0
- package/dist/{get-doc-DsOaSMIe.cjs → get-doc-CbVw4ada.cjs} +2 -2
- package/dist/{get-doc-DsOaSMIe.cjs.map → get-doc-CbVw4ada.cjs.map} +1 -1
- package/dist/{get-doc-CWhlUoJe.js → get-doc-FuILofQP.js} +2 -2
- package/dist/{get-doc-CWhlUoJe.js.map → get-doc-FuILofQP.js.map} +1 -1
- package/dist/{get-event-attachment-CTF-k6op.cjs → get-event-attachment-DuyBT68p.cjs} +4 -4
- package/dist/get-event-attachment-DuyBT68p.cjs.map +1 -0
- package/dist/{get-event-attachment-DDvsu6IQ.js → get-event-attachment-Dzg2R7ng.js} +4 -4
- package/dist/get-event-attachment-Dzg2R7ng.js.map +1 -0
- package/dist/{get-issue-details-CIZSksmd.cjs → get-issue-details-BY7S1YyX.cjs} +6 -6
- package/dist/get-issue-details-BY7S1YyX.cjs.map +1 -0
- package/dist/{get-issue-details-Bsax2jTY.js → get-issue-details-BxJzOzFQ.js} +6 -6
- package/dist/get-issue-details-BxJzOzFQ.js.map +1 -0
- package/dist/{get-trace-details-Bc9GgkSs.cjs → get-trace-details-DD0p3apU.cjs} +5 -5
- package/dist/get-trace-details-DD0p3apU.cjs.map +1 -0
- package/dist/{get-trace-details-Bkilw5oH.js → get-trace-details-Dv2FB534.js} +5 -5
- package/dist/get-trace-details-Dv2FB534.js.map +1 -0
- package/dist/{handler-D6OGs2Ok.d.cts → handler-0iIvlYwy.d.cts} +2 -2
- package/dist/handler-0iIvlYwy.d.cts.map +1 -0
- package/dist/{handler-CZEMKP9p.d.cts → handler-8JzODzam.d.cts} +3 -3
- package/dist/handler-8JzODzam.d.cts.map +1 -0
- package/dist/{handler-Cs5DcdpF.d.ts → handler-9UUkphzv.d.ts} +3 -3
- package/dist/handler-9UUkphzv.d.ts.map +1 -0
- package/dist/{handler-y6EMhG0y.js → handler-BfTAwyrq.js} +9 -9
- package/dist/handler-BfTAwyrq.js.map +1 -0
- package/dist/{handler-bf2qu8DQ.js → handler-BhjeSo2N.js} +8 -8
- package/dist/handler-BhjeSo2N.js.map +1 -0
- package/dist/{handler-DQbc5eAJ.cjs → handler-BjTPOR8v.cjs} +8 -8
- package/dist/handler-BjTPOR8v.cjs.map +1 -0
- package/dist/{handler-ChOaafS-.cjs → handler-C5Tgh1wj.cjs} +9 -9
- package/dist/handler-C5Tgh1wj.cjs.map +1 -0
- package/dist/{handler-CmTBmIt9.d.cts → handler-ClZBIn0B.d.cts} +3 -3
- package/dist/handler-ClZBIn0B.d.cts.map +1 -0
- package/dist/{handler-CASDrJ7z.d.ts → handler-CmAbLcaV.d.ts} +3 -3
- package/dist/handler-CmAbLcaV.d.ts.map +1 -0
- package/dist/{handler-CXY05zhR.d.ts → handler-DbUy8Z54.d.ts} +2 -2
- package/dist/handler-DbUy8Z54.d.ts.map +1 -0
- package/dist/index.cjs +32 -32
- package/dist/index.js +32 -32
- package/dist/internal/agents/callEmbeddedAgent.cjs +3 -3
- package/dist/internal/agents/callEmbeddedAgent.js +3 -3
- package/dist/internal/agents/openai-provider.cjs +2 -2
- package/dist/internal/agents/openai-provider.js +2 -2
- package/dist/internal/agents/tools/dataset-fields.cjs +3 -3
- package/dist/internal/agents/tools/dataset-fields.d.cts +7 -7
- package/dist/internal/agents/tools/dataset-fields.d.ts +7 -7
- package/dist/internal/agents/tools/dataset-fields.d.ts.map +1 -1
- package/dist/internal/agents/tools/dataset-fields.js +3 -3
- package/dist/internal/agents/tools/otel-semantics.cjs +3 -3
- package/dist/internal/agents/tools/otel-semantics.d.cts +10 -10
- package/dist/internal/agents/tools/otel-semantics.d.cts.map +1 -1
- package/dist/internal/agents/tools/otel-semantics.d.ts +10 -10
- package/dist/internal/agents/tools/otel-semantics.d.ts.map +1 -1
- package/dist/internal/agents/tools/otel-semantics.js +3 -3
- package/dist/internal/agents/tools/utils.cjs +3 -3
- package/dist/internal/agents/tools/utils.d.cts +1 -1
- package/dist/internal/agents/tools/utils.d.ts +1 -1
- package/dist/internal/agents/tools/utils.js +3 -3
- package/dist/internal/agents/tools/whoami.cjs +3 -3
- package/dist/internal/agents/tools/whoami.d.cts +7 -7
- package/dist/internal/agents/tools/whoami.d.ts +7 -7
- package/dist/internal/agents/tools/whoami.d.ts.map +1 -1
- package/dist/internal/agents/tools/whoami.js +3 -3
- package/dist/internal/error-handling.cjs +3 -3
- package/dist/internal/error-handling.d.cts +3 -3
- package/dist/internal/error-handling.d.ts +3 -3
- package/dist/internal/error-handling.js +3 -3
- package/dist/internal/formatting.cjs +2 -1
- package/dist/internal/formatting.d.cts +4 -4
- package/dist/internal/formatting.d.ts +4 -4
- package/dist/internal/formatting.js +2 -1
- package/dist/internal/test-fixtures.d.cts +2 -2
- package/dist/internal/test-fixtures.d.ts +2 -2
- package/dist/internal/tool-helpers/api.cjs +4 -4
- package/dist/internal/tool-helpers/api.d.cts +3 -3
- package/dist/internal/tool-helpers/api.d.ts +3 -3
- package/dist/internal/tool-helpers/api.js +4 -4
- package/dist/internal/tool-helpers/enhance-error.cjs +3 -3
- package/dist/internal/tool-helpers/enhance-error.d.cts +3 -3
- package/dist/internal/tool-helpers/enhance-error.d.ts +3 -3
- package/dist/internal/tool-helpers/enhance-error.js +3 -3
- package/dist/internal/tool-helpers/formatting.d.cts +3 -3
- package/dist/internal/tool-helpers/formatting.d.ts +3 -3
- package/dist/internal/tool-helpers/issue.cjs +2 -1
- package/dist/internal/tool-helpers/issue.d.cts +4 -4
- package/dist/internal/tool-helpers/issue.d.ts +4 -4
- package/dist/internal/tool-helpers/issue.js +2 -1
- package/dist/internal/tool-helpers/seer.d.cts +3 -3
- package/dist/internal/tool-helpers/seer.d.ts +3 -3
- package/dist/{openai-provider-DphaqrmX.js → openai-provider-BsMAb6zY.js} +2 -2
- package/dist/{openai-provider-DphaqrmX.js.map → openai-provider-BsMAb6zY.js.map} +1 -1
- package/dist/{openai-provider-B7uvGxoI.cjs → openai-provider-BycgrQgi.cjs} +2 -2
- package/dist/{openai-provider-B7uvGxoI.cjs.map → openai-provider-BycgrQgi.cjs.map} +1 -1
- package/dist/{schema-DE4JpUSi.cjs → schema-1xQ4asuW.cjs} +64 -7
- package/dist/schema-1xQ4asuW.cjs.map +1 -0
- package/dist/{schema-Cp8XI7-D.d.ts → schema-CZXkkfj-.d.cts} +3374 -803
- package/dist/schema-CZXkkfj-.d.cts.map +1 -0
- package/dist/{schema-D5oT-Zi7.d.cts → schema-Cfvy5rTy.d.ts} +3287 -716
- package/dist/schema-Cfvy5rTy.d.ts.map +1 -0
- package/dist/{schema-DkZXVCQJ.js → schema-oeFNxyo_.js} +47 -8
- package/dist/schema-oeFNxyo_.js.map +1 -0
- package/dist/{search-docs-DdOFZY3t.cjs → search-docs-C5x-ZRhd.cjs} +3 -3
- package/dist/{search-docs-DdOFZY3t.cjs.map → search-docs-C5x-ZRhd.cjs.map} +1 -1
- package/dist/{search-docs-YYBTOWY5.js → search-docs-UCe9oXQt.js} +3 -3
- package/dist/{search-docs-YYBTOWY5.js.map → search-docs-UCe9oXQt.js.map} +1 -1
- package/dist/{server-BVqPcPfx.js → server-BbJwtfJr.js} +24 -23
- package/dist/server-BbJwtfJr.js.map +1 -0
- package/dist/{server-BQBA0VNe.cjs → server-OW--pQOQ.cjs} +24 -23
- package/dist/server-OW--pQOQ.cjs.map +1 -0
- package/dist/server.cjs +30 -30
- package/dist/server.js +30 -30
- package/dist/skillDefinitions.cjs +210 -5
- package/dist/skillDefinitions.cjs.map +1 -1
- package/dist/skillDefinitions.d.cts +5 -0
- package/dist/skillDefinitions.d.cts.map +1 -1
- package/dist/skillDefinitions.d.ts +5 -0
- package/dist/skillDefinitions.d.ts.map +1 -1
- package/dist/skillDefinitions.js +210 -5
- package/dist/skillDefinitions.js.map +1 -1
- package/dist/{stdio-YKMCj_QV.js → stdio-2BaHF2h-.js} +2 -2
- package/dist/{stdio-YKMCj_QV.js.map → stdio-2BaHF2h-.js.map} +1 -1
- package/dist/{stdio-DPvrKLnJ.cjs → stdio-DL-ID7Q4.cjs} +2 -2
- package/dist/{stdio-DPvrKLnJ.cjs.map → stdio-DL-ID7Q4.cjs.map} +1 -1
- package/dist/toolDefinitions.cjs +307 -193
- package/dist/toolDefinitions.cjs.map +1 -1
- package/dist/toolDefinitions.js +307 -193
- package/dist/toolDefinitions.js.map +1 -1
- package/dist/tools/analyze-issue-with-seer.cjs +6 -6
- package/dist/tools/analyze-issue-with-seer.d.cts +1 -1
- package/dist/tools/analyze-issue-with-seer.d.ts +1 -1
- package/dist/tools/analyze-issue-with-seer.js +6 -6
- package/dist/tools/create-dsn.cjs +5 -5
- package/dist/tools/create-dsn.d.cts +1 -1
- package/dist/tools/create-dsn.d.ts +1 -1
- package/dist/tools/create-dsn.js +5 -5
- package/dist/tools/create-project.cjs +5 -5
- package/dist/tools/create-project.d.cts +2 -2
- package/dist/tools/create-project.d.ts +2 -2
- package/dist/tools/create-project.js +5 -5
- package/dist/tools/create-team.cjs +5 -5
- package/dist/tools/create-team.d.cts +1 -1
- package/dist/tools/create-team.d.ts +1 -1
- package/dist/tools/create-team.js +5 -5
- package/dist/tools/find-dsns.cjs +5 -5
- package/dist/tools/find-dsns.d.cts +4 -4
- package/dist/tools/find-dsns.d.ts +4 -4
- package/dist/tools/find-dsns.js +5 -5
- package/dist/tools/find-organizations.cjs +5 -5
- package/dist/tools/find-organizations.d.cts +2 -2
- package/dist/tools/find-organizations.d.ts +2 -2
- package/dist/tools/find-organizations.js +5 -5
- package/dist/tools/find-projects.cjs +5 -5
- package/dist/tools/find-projects.d.cts +4 -4
- package/dist/tools/find-projects.d.ts +4 -4
- package/dist/tools/find-projects.js +5 -5
- package/dist/tools/find-releases.cjs +5 -5
- package/dist/tools/find-releases.d.cts +3 -3
- package/dist/tools/find-releases.d.ts +3 -3
- package/dist/tools/find-releases.js +5 -5
- package/dist/tools/find-teams.cjs +5 -5
- package/dist/tools/find-teams.d.cts +4 -4
- package/dist/tools/find-teams.d.ts +4 -4
- package/dist/tools/find-teams.js +5 -5
- package/dist/tools/get-doc.cjs +4 -4
- package/dist/tools/get-doc.js +4 -4
- package/dist/tools/get-event-attachment.cjs +5 -5
- package/dist/tools/get-event-attachment.d.cts +6 -6
- package/dist/tools/get-event-attachment.d.ts +6 -6
- package/dist/tools/get-event-attachment.js +5 -5
- package/dist/tools/get-issue-details.cjs +6 -6
- package/dist/tools/get-issue-details.d.cts +1 -1
- package/dist/tools/get-issue-details.d.ts +1 -1
- package/dist/tools/get-issue-details.js +6 -6
- package/dist/tools/get-trace-details.cjs +5 -5
- package/dist/tools/get-trace-details.d.cts +4 -4
- package/dist/tools/get-trace-details.d.ts +4 -4
- package/dist/tools/get-trace-details.js +5 -5
- package/dist/tools/index.cjs +30 -30
- package/dist/tools/index.d.cts +76 -76
- package/dist/tools/index.d.cts.map +1 -1
- package/dist/tools/index.d.ts +76 -76
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +30 -30
- package/dist/tools/search-docs.cjs +4 -4
- package/dist/tools/search-docs.d.cts +2 -2
- package/dist/tools/search-docs.d.ts +2 -2
- package/dist/tools/search-docs.js +4 -4
- package/dist/tools/search-events/agent.cjs +6 -6
- package/dist/tools/search-events/agent.d.cts +4 -4
- package/dist/tools/search-events/agent.d.ts +4 -4
- package/dist/tools/search-events/agent.js +6 -6
- package/dist/tools/search-events/formatters.cjs +3 -3
- package/dist/tools/search-events/formatters.d.cts +5 -5
- package/dist/tools/search-events/formatters.d.ts +5 -5
- package/dist/tools/search-events/formatters.js +3 -3
- package/dist/tools/search-events/handler.cjs +8 -8
- package/dist/tools/search-events/handler.d.cts +1 -1
- package/dist/tools/search-events/handler.d.ts +1 -1
- package/dist/tools/search-events/handler.js +8 -8
- package/dist/tools/search-events/index.cjs +8 -8
- package/dist/tools/search-events/index.d.cts +5 -5
- package/dist/tools/search-events/index.d.ts +5 -5
- package/dist/tools/search-events/index.js +8 -8
- package/dist/tools/search-events/utils.cjs +3 -3
- package/dist/tools/search-events/utils.d.cts +5 -5
- package/dist/tools/search-events/utils.d.ts +5 -5
- package/dist/tools/search-events/utils.js +3 -3
- package/dist/tools/search-issues/agent.cjs +6 -6
- package/dist/tools/search-issues/agent.d.cts +4 -4
- package/dist/tools/search-issues/agent.d.ts +4 -4
- package/dist/tools/search-issues/agent.js +6 -6
- package/dist/tools/search-issues/formatters.d.cts +3 -3
- package/dist/tools/search-issues/formatters.d.ts +3 -3
- package/dist/tools/search-issues/handler.cjs +8 -8
- package/dist/tools/search-issues/handler.d.cts +1 -1
- package/dist/tools/search-issues/handler.d.ts +1 -1
- package/dist/tools/search-issues/handler.js +8 -8
- package/dist/tools/search-issues/index.cjs +8 -8
- package/dist/tools/search-issues/index.d.cts +5 -5
- package/dist/tools/search-issues/index.d.ts +5 -5
- package/dist/tools/search-issues/index.js +8 -8
- package/dist/tools/update-issue.cjs +6 -6
- package/dist/tools/update-issue.d.cts +7 -7
- package/dist/tools/update-issue.d.ts +7 -7
- package/dist/tools/update-issue.js +6 -6
- package/dist/tools/update-project.cjs +5 -5
- package/dist/tools/update-project.d.cts +5 -5
- package/dist/tools/update-project.d.cts.map +1 -1
- package/dist/tools/update-project.d.ts +5 -5
- package/dist/tools/update-project.d.ts.map +1 -1
- package/dist/tools/update-project.js +5 -5
- package/dist/tools/use-sentry/agent.cjs +4 -4
- package/dist/tools/use-sentry/agent.js +4 -4
- package/dist/tools/use-sentry/handler.cjs +30 -30
- package/dist/tools/use-sentry/handler.d.cts +1 -1
- package/dist/tools/use-sentry/handler.d.ts +1 -1
- package/dist/tools/use-sentry/handler.js +30 -30
- package/dist/tools/use-sentry/index.cjs +30 -30
- package/dist/tools/use-sentry/index.d.cts +1 -1
- package/dist/tools/use-sentry/index.d.ts +1 -1
- package/dist/tools/use-sentry/index.js +30 -30
- package/dist/tools/use-sentry/tool-wrapper.cjs +3 -3
- package/dist/tools/use-sentry/tool-wrapper.d.cts +4 -4
- package/dist/tools/use-sentry/tool-wrapper.d.cts.map +1 -1
- package/dist/tools/use-sentry/tool-wrapper.d.ts +4 -4
- package/dist/tools/use-sentry/tool-wrapper.d.ts.map +1 -1
- package/dist/tools/use-sentry/tool-wrapper.js +3 -3
- package/dist/tools/whoami.cjs +5 -5
- package/dist/tools/whoami.js +5 -5
- package/dist/transports/stdio.cjs +2 -2
- package/dist/transports/stdio.js +2 -2
- package/dist/{types-CZI-5yyV.d.cts → types-Cet6uyS6.d.ts} +5 -4
- package/dist/types-Cet6uyS6.d.ts.map +1 -0
- package/dist/{types-WcBA7ZSQ.d.ts → types-D1CEiyup.d.cts} +5 -4
- package/dist/types-D1CEiyup.d.cts.map +1 -0
- package/dist/{update-issue-B35n8MDT.js → update-issue-BGm8g4G0.js} +3 -3
- package/dist/update-issue-BGm8g4G0.js.map +1 -0
- package/dist/{update-issue-DOVD2zXD.cjs → update-issue-Dx2EZ5pY.cjs} +3 -3
- package/dist/update-issue-Dx2EZ5pY.cjs.map +1 -0
- package/dist/{update-project-D361nWlU.js → update-project-B0clXxii.js} +7 -7
- package/dist/update-project-B0clXxii.js.map +1 -0
- package/dist/{update-project-DG3bwhNA.cjs → update-project-BJkzcapF.cjs} +7 -7
- package/dist/update-project-BJkzcapF.cjs.map +1 -0
- package/dist/{utils-CrKFhSC3.d.ts → utils-C7sQWgE3.d.cts} +9 -9
- package/dist/{utils-C5oiuqkh.d.cts.map → utils-C7sQWgE3.d.cts.map} +1 -1
- package/dist/{utils-C5oiuqkh.d.cts → utils-CmH2wxA_.d.ts} +9 -9
- package/dist/{utils-CrKFhSC3.d.ts.map → utils-CmH2wxA_.d.ts.map} +1 -1
- package/dist/{utils-CAWsA9Cl.d.cts → utils-R15EJutP.d.ts} +4 -4
- package/dist/utils-R15EJutP.d.ts.map +1 -0
- package/dist/{utils-Bzaer0D1.d.ts → utils-RPc9DHgJ.d.cts} +4 -4
- package/dist/{utils-CAWsA9Cl.d.cts.map → utils-RPc9DHgJ.d.cts.map} +1 -1
- package/dist/{version-CPcX-30c.cjs → version-CaFsr_xb.cjs} +2 -2
- package/dist/{version-CPcX-30c.cjs.map → version-CaFsr_xb.cjs.map} +1 -1
- package/dist/{version-CCICHYna.js → version-DY1nl1TZ.js} +2 -2
- package/dist/{version-CCICHYna.js.map → version-DY1nl1TZ.js.map} +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.js +1 -1
- package/dist/{whoami-CRF9Ws25.cjs → whoami-DRDjyhDL.cjs} +2 -2
- package/dist/{whoami-CRF9Ws25.cjs.map → whoami-DRDjyhDL.cjs.map} +1 -1
- package/dist/{whoami-DCZN-m7R.js → whoami-FliA3IrX.js} +2 -2
- package/dist/{whoami-DCZN-m7R.js.map → whoami-FliA3IrX.js.map} +1 -1
- package/package.json +3 -3
- package/dist/agent-Cu85yHYm.d.ts.map +0 -1
- package/dist/analyze-issue-with-seer-B90r4g5J.cjs.map +0 -1
- package/dist/client-0n2-4zOO.d.cts.map +0 -1
- package/dist/client-B7hvqupZ.js.map +0 -1
- package/dist/client-ByOC8aCf.d.ts.map +0 -1
- package/dist/client-cC79LUJ5.cjs.map +0 -1
- package/dist/create-dsn-9yIHr10B.cjs.map +0 -1
- package/dist/create-dsn-p2Ep6zDn.js.map +0 -1
- package/dist/create-project-BQQx1iLm.cjs.map +0 -1
- package/dist/create-project-CN0UneBm.js.map +0 -1
- package/dist/create-team-CzFrsVdw.js.map +0 -1
- package/dist/create-team-DFSriKVL.cjs.map +0 -1
- package/dist/find-dsns-BzfYjE06.js.map +0 -1
- package/dist/find-dsns-DhHHtvpj.cjs.map +0 -1
- package/dist/find-organizations-BJFAElbh.js.map +0 -1
- package/dist/find-projects-BpEGRZya.cjs.map +0 -1
- package/dist/find-projects-E5CMFbwU.js.map +0 -1
- package/dist/find-releases-DWWonhlV.js.map +0 -1
- package/dist/find-releases-Du5euXKS.cjs.map +0 -1
- package/dist/find-teams-BM4yWKe_.js.map +0 -1
- package/dist/find-teams-Bp6-Iu62.cjs.map +0 -1
- package/dist/formatting-5u-ZFz8H.cjs.map +0 -1
- package/dist/formatting-BEgp4WO_.js.map +0 -1
- package/dist/formatting-Bw0FWiCH.d.cts.map +0 -1
- package/dist/formatting-ClM7RU4L.d.ts.map +0 -1
- package/dist/get-event-attachment-CTF-k6op.cjs.map +0 -1
- package/dist/get-event-attachment-DDvsu6IQ.js.map +0 -1
- package/dist/get-issue-details-Bsax2jTY.js.map +0 -1
- package/dist/get-issue-details-CIZSksmd.cjs.map +0 -1
- package/dist/get-trace-details-Bc9GgkSs.cjs.map +0 -1
- package/dist/get-trace-details-Bkilw5oH.js.map +0 -1
- package/dist/handler-CASDrJ7z.d.ts.map +0 -1
- package/dist/handler-CXY05zhR.d.ts.map +0 -1
- package/dist/handler-CZEMKP9p.d.cts.map +0 -1
- package/dist/handler-ChOaafS-.cjs.map +0 -1
- package/dist/handler-CmTBmIt9.d.cts.map +0 -1
- package/dist/handler-Cs5DcdpF.d.ts.map +0 -1
- package/dist/handler-D6OGs2Ok.d.cts.map +0 -1
- package/dist/handler-DQbc5eAJ.cjs.map +0 -1
- package/dist/handler-bf2qu8DQ.js.map +0 -1
- package/dist/handler-y6EMhG0y.js.map +0 -1
- package/dist/schema-Cp8XI7-D.d.ts.map +0 -1
- package/dist/schema-D5oT-Zi7.d.cts.map +0 -1
- package/dist/schema-DE4JpUSi.cjs.map +0 -1
- package/dist/schema-DkZXVCQJ.js.map +0 -1
- package/dist/server-BQBA0VNe.cjs.map +0 -1
- package/dist/server-BVqPcPfx.js.map +0 -1
- package/dist/types-CZI-5yyV.d.cts.map +0 -1
- package/dist/types-WcBA7ZSQ.d.ts.map +0 -1
- package/dist/update-issue-B35n8MDT.js.map +0 -1
- package/dist/update-issue-DOVD2zXD.cjs.map +0 -1
- package/dist/update-project-D361nWlU.js.map +0 -1
- package/dist/update-project-DG3bwhNA.cjs.map +0 -1
- package/dist/utils-Bzaer0D1.d.ts.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-dsns-DhHHtvpj.cjs","names":["ParamOrganizationSlug","ParamProjectSlug","context: ServerContext"],"sources":["../src/tools/find-dsns.ts"],"sourcesContent":["import { setTag } from \"@sentry/core\";\nimport { defineTool } from \"../internal/tool-helpers/define\";\nimport { apiServiceFromContext } from \"../internal/tool-helpers/api\";\nimport type { ServerContext } from \"../types\";\nimport {\n ParamOrganizationSlug,\n ParamRegionUrl,\n ParamProjectSlug,\n} from \"../schema\";\n\nexport default defineTool({\n name: \"find_dsns\",\n requiredSkills: [\"project-management\"], // DSN management is part of project setup\n requiredScopes: [\"project:read\"],\n description: [\n \"List all Sentry DSNs for a specific project.\",\n \"\",\n \"Use this tool when you need to:\",\n \"- Retrieve a SENTRY_DSN for a specific project\",\n \"\",\n \"<hints>\",\n \"- If the user passes a parameter in the form of name/otherName, its likely in the format of <organizationSlug>/<projectSlug>.\",\n \"- If only one parameter is provided, and it could be either `organizationSlug` or `projectSlug`, its probably `organizationSlug`, but if you're really uncertain you might want to call `find_organizations()` first.\",\n \"</hints>\",\n ].join(\"\\n\"),\n inputSchema: {\n organizationSlug: ParamOrganizationSlug,\n regionUrl: ParamRegionUrl.optional(),\n projectSlug: ParamProjectSlug,\n },\n annotations: {\n readOnlyHint: true,\n openWorldHint: true,\n },\n async handler(params, context: ServerContext) {\n const apiService = apiServiceFromContext(context, {\n regionUrl: params.regionUrl,\n });\n const organizationSlug = params.organizationSlug;\n\n setTag(\"organization.slug\", organizationSlug);\n setTag(\"project.slug\", params.projectSlug);\n\n const clientKeys = await apiService.listClientKeys({\n organizationSlug,\n projectSlug: params.projectSlug,\n });\n let output = `# DSNs in **${organizationSlug}/${params.projectSlug}**\\n\\n`;\n if (clientKeys.length === 0) {\n output +=\n \"No DSNs were found.\\n\\nYou can create new one using the `create_dsn` tool.\";\n return output;\n }\n for (const clientKey of clientKeys) {\n output += `## ${clientKey.name}\\n`;\n output += `**ID**: ${clientKey.id}\\n`;\n output += `**DSN**: ${clientKey.dsn.public}\\n\\n`;\n }\n output += \"# Using this information\\n\\n\";\n output +=\n \"- The `SENTRY_DSN` value is a URL that you can use to initialize Sentry's SDKs.\\n\";\n return output;\n },\n});\n"],"mappings":";;;;;;;AAUA,wBAAe,0BAAW;CACxB,MAAM;CACN,gBAAgB,CAAC,oBAAqB;CACtC,gBAAgB,CAAC,cAAe;CAChC,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,EAAC,KAAK,KAAK;CACZ,aAAa;EACX,kBAAkBA;EAClB,WAAW,8BAAe,UAAU;EACpC,aAAaC;CACd;CACD,aAAa;EACX,cAAc;EACd,eAAe;CAChB;CACD,MAAM,QAAQ,QAAQC,SAAwB;EAC5C,MAAM,aAAa,kCAAsB,SAAS,EAChD,WAAW,OAAO,UACnB,EAAC;EACF,MAAM,mBAAmB,OAAO;AAEhC,4BAAO,qBAAqB,iBAAiB;AAC7C,4BAAO,gBAAgB,OAAO,YAAY;EAE1C,MAAM,aAAa,MAAM,WAAW,eAAe;GACjD;GACA,aAAa,OAAO;EACrB,EAAC;EACF,IAAI,UAAU,cAAc,iBAAiB,GAAG,OAAO,YAAY;AACnE,MAAI,WAAW,WAAW,GAAG;AAC3B,aACE;AACF,UAAO;EACR;AACD,OAAK,MAAM,aAAa,YAAY;AAClC,cAAW,KAAK,UAAU,KAAK;AAC/B,cAAW,UAAU,UAAU,GAAG;AAClC,cAAW,WAAW,UAAU,IAAI,OAAO;EAC5C;AACD,YAAU;AACV,YACE;AACF,SAAO;CACR;AACF,EAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-organizations-BJFAElbh.js","names":["context: ServerContext"],"sources":["../src/tools/find-organizations.ts"],"sourcesContent":["import { defineTool } from \"../internal/tool-helpers/define\";\nimport { apiServiceFromContext } from \"../internal/tool-helpers/api\";\nimport type { ServerContext } from \"../types\";\nimport { ParamSearchQuery } from \"../schema\";\nimport { ALL_SKILLS } from \"../skills\";\n\nconst RESULT_LIMIT = 25;\n\nexport default defineTool({\n name: \"find_organizations\",\n requiredSkills: ALL_SKILLS, // Foundational tool - available to all skills\n requiredScopes: [\"org:read\"],\n description: [\n \"Find organizations that the user has access to in Sentry.\",\n \"\",\n \"Use this tool when you need to:\",\n \"- View organizations in Sentry\",\n \"- Find an organization's slug to aid other tool requests\",\n \"- Search for specific organizations by name or slug\",\n \"\",\n `Returns up to ${RESULT_LIMIT} results. If you hit this limit, use the query parameter to narrow down results.`,\n ].join(\"\\n\"),\n inputSchema: {\n query: ParamSearchQuery.optional(),\n },\n annotations: {\n readOnlyHint: true,\n openWorldHint: true,\n },\n async handler(params, context: ServerContext) {\n // User data endpoints (like /users/me/regions/) should never use regionUrl\n // as they must always query the main API server, not region-specific servers\n const apiService = apiServiceFromContext(context);\n const organizations = await apiService.listOrganizations({\n query: params.query,\n });\n\n let output = \"# Organizations\\n\\n\";\n\n if (params.query) {\n output += `**Search query:** \"${params.query}\"\\n\\n`;\n }\n\n if (organizations.length === 0) {\n output += params.query\n ? `No organizations found matching \"${params.query}\".\\n`\n : \"You don't appear to be a member of any organizations.\\n\";\n return output;\n }\n\n output += organizations\n .map((org) =>\n [\n `## **${org.slug}**`,\n \"\",\n `**Web URL:** ${org.links?.organizationUrl || \"Not available\"}`,\n `**Region URL:** ${org.links?.regionUrl || \"\"}`,\n ].join(\"\\n\"),\n )\n .join(\"\\n\\n\");\n\n if (organizations.length === RESULT_LIMIT) {\n output += `\\n\\n---\\n\\n**Note:** Showing ${RESULT_LIMIT} results (maximum). There may be more organizations available. Use the \\`query\\` parameter to search for specific organizations.`;\n }\n\n output += \"\\n\\n# Using this information\\n\\n\";\n output += `- The organization's name is the identifier for the organization, and is used in many tools for \\`organizationSlug\\`.\\n`;\n\n const hasValidRegionUrls = organizations.some((org) =>\n org.links?.regionUrl?.trim(),\n );\n\n if (hasValidRegionUrls) {\n output += `- If a tool supports passing in the \\`regionUrl\\`, you MUST pass in the correct value shown above for each organization.\\n`;\n output += `- For Sentry's Cloud Service (sentry.io), always use the regionUrl to ensure requests go to the correct region.\\n`;\n } else {\n output += `- This appears to be a self-hosted Sentry installation. You can omit the \\`regionUrl\\` parameter when using other tools.\\n`;\n output += `- For self-hosted Sentry, the regionUrl is typically empty and not needed for API calls.\\n`;\n }\n\n return output;\n },\n});\n"],"mappings":";;;;;;AAMA,MAAM,eAAe;AAErB,iCAAe,WAAW;CACxB,MAAM;CACN,gBAAgB;CAChB,gBAAgB,CAAC,UAAW;CAC5B,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;GACC,gBAAgB,aAAa;CAC/B,EAAC,KAAK,KAAK;CACZ,aAAa,EACX,OAAO,iBAAiB,UAAU,CACnC;CACD,aAAa;EACX,cAAc;EACd,eAAe;CAChB;CACD,MAAM,QAAQ,QAAQA,SAAwB;EAG5C,MAAM,aAAa,sBAAsB,QAAQ;EACjD,MAAM,gBAAgB,MAAM,WAAW,kBAAkB,EACvD,OAAO,OAAO,MACf,EAAC;EAEF,IAAI,SAAS;AAEb,MAAI,OAAO,MACT,YAAW,qBAAqB,OAAO,MAAM;AAG/C,MAAI,cAAc,WAAW,GAAG;AAC9B,aAAU,OAAO,SACZ,mCAAmC,OAAO,MAAM,QACjD;AACJ,UAAO;EACR;AAED,YAAU,cACP,IAAI,CAAC,QACJ;IACG,OAAO,IAAI,KAAK;GACjB;IACC,eAAe,IAAI,OAAO,mBAAmB;IAC7C,kBAAkB,IAAI,OAAO,aAAa;EAC5C,EAAC,KAAK,KAAK,CACb,CACA,KAAK,OAAO;AAEf,MAAI,cAAc,WAAW,aAC3B,YAAW,+BAA+B,aAAa;AAGzD,YAAU;AACV,aAAW;EAEX,MAAM,qBAAqB,cAAc,KAAK,CAAC,QAC7C,IAAI,OAAO,WAAW,MAAM,CAC7B;AAED,MAAI,oBAAoB;AACtB,cAAW;AACX,cAAW;EACZ,OAAM;AACL,cAAW;AACX,cAAW;EACZ;AAED,SAAO;CACR;AACF,EAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-projects-BpEGRZya.cjs","names":["ALL_SKILLS","ParamOrganizationSlug","context: ServerContext","UserInputError"],"sources":["../src/tools/find-projects.ts"],"sourcesContent":["import { setTag } from \"@sentry/core\";\nimport { defineTool } from \"../internal/tool-helpers/define\";\nimport { apiServiceFromContext } from \"../internal/tool-helpers/api\";\nimport { UserInputError } from \"../errors\";\nimport type { ServerContext } from \"../types\";\nimport {\n ParamOrganizationSlug,\n ParamRegionUrl,\n ParamSearchQuery,\n} from \"../schema\";\nimport { ALL_SKILLS } from \"../skills\";\n\nconst RESULT_LIMIT = 25;\n\nexport default defineTool({\n name: \"find_projects\",\n requiredSkills: ALL_SKILLS, // Foundational tool - available to all skills\n requiredScopes: [\"project:read\"],\n description: [\n \"Find projects in Sentry.\",\n \"\",\n \"Use this tool when you need to:\",\n \"- View projects in a Sentry organization\",\n \"- Find a project's slug to aid other tool requests\",\n \"- Search for specific projects by name or slug\",\n \"\",\n `Returns up to ${RESULT_LIMIT} results. If you hit this limit, use the query parameter to narrow down results.`,\n ].join(\"\\n\"),\n inputSchema: {\n organizationSlug: ParamOrganizationSlug,\n regionUrl: ParamRegionUrl.optional(),\n query: ParamSearchQuery.optional(),\n },\n annotations: {\n readOnlyHint: true,\n openWorldHint: true,\n },\n async handler(params, context: ServerContext) {\n const apiService = apiServiceFromContext(context, {\n regionUrl: params.regionUrl,\n });\n const organizationSlug = params.organizationSlug;\n\n if (!organizationSlug) {\n throw new UserInputError(\n \"Organization slug is required. Please provide an organizationSlug parameter.\",\n );\n }\n\n setTag(\"organization.slug\", organizationSlug);\n\n const projects = await apiService.listProjects(organizationSlug, {\n query: params.query,\n });\n\n let output = `# Projects in **${organizationSlug}**\\n\\n`;\n\n if (params.query) {\n output += `**Search query:** \"${params.query}\"\\n\\n`;\n }\n\n if (projects.length === 0) {\n output += params.query\n ? `No projects found matching \"${params.query}\".\\n`\n : \"No projects found.\\n\";\n return output;\n }\n\n output += projects.map((project) => `- **${project.slug}**\\n`).join(\"\");\n\n if (projects.length === RESULT_LIMIT) {\n output += `\\n---\\n\\n**Note:** Showing ${RESULT_LIMIT} results (maximum). There may be more projects available. Use the \\`query\\` parameter to search for specific projects.`;\n }\n\n return output;\n },\n});\n"],"mappings":";;;;;;;;;AAYA,MAAM,eAAe;AAErB,4BAAe,0BAAW;CACxB,MAAM;CACN,gBAAgBA;CAChB,gBAAgB,CAAC,cAAe;CAChC,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;GACC,gBAAgB,aAAa;CAC/B,EAAC,KAAK,KAAK;CACZ,aAAa;EACX,kBAAkBC;EAClB,WAAW,8BAAe,UAAU;EACpC,OAAO,gCAAiB,UAAU;CACnC;CACD,aAAa;EACX,cAAc;EACd,eAAe;CAChB;CACD,MAAM,QAAQ,QAAQC,SAAwB;EAC5C,MAAM,aAAa,kCAAsB,SAAS,EAChD,WAAW,OAAO,UACnB,EAAC;EACF,MAAM,mBAAmB,OAAO;AAEhC,OAAK,iBACH,OAAM,IAAIC,8BACR;AAIJ,4BAAO,qBAAqB,iBAAiB;EAE7C,MAAM,WAAW,MAAM,WAAW,aAAa,kBAAkB,EAC/D,OAAO,OAAO,MACf,EAAC;EAEF,IAAI,UAAU,kBAAkB,iBAAiB;AAEjD,MAAI,OAAO,MACT,YAAW,qBAAqB,OAAO,MAAM;AAG/C,MAAI,SAAS,WAAW,GAAG;AACzB,aAAU,OAAO,SACZ,8BAA8B,OAAO,MAAM,QAC5C;AACJ,UAAO;EACR;AAED,YAAU,SAAS,IAAI,CAAC,aAAa,MAAM,QAAQ,KAAK,MAAM,CAAC,KAAK,GAAG;AAEvE,MAAI,SAAS,WAAW,aACtB,YAAW,6BAA6B,aAAa;AAGvD,SAAO;CACR;AACF,EAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-projects-E5CMFbwU.js","names":["context: ServerContext"],"sources":["../src/tools/find-projects.ts"],"sourcesContent":["import { setTag } from \"@sentry/core\";\nimport { defineTool } from \"../internal/tool-helpers/define\";\nimport { apiServiceFromContext } from \"../internal/tool-helpers/api\";\nimport { UserInputError } from \"../errors\";\nimport type { ServerContext } from \"../types\";\nimport {\n ParamOrganizationSlug,\n ParamRegionUrl,\n ParamSearchQuery,\n} from \"../schema\";\nimport { ALL_SKILLS } from \"../skills\";\n\nconst RESULT_LIMIT = 25;\n\nexport default defineTool({\n name: \"find_projects\",\n requiredSkills: ALL_SKILLS, // Foundational tool - available to all skills\n requiredScopes: [\"project:read\"],\n description: [\n \"Find projects in Sentry.\",\n \"\",\n \"Use this tool when you need to:\",\n \"- View projects in a Sentry organization\",\n \"- Find a project's slug to aid other tool requests\",\n \"- Search for specific projects by name or slug\",\n \"\",\n `Returns up to ${RESULT_LIMIT} results. If you hit this limit, use the query parameter to narrow down results.`,\n ].join(\"\\n\"),\n inputSchema: {\n organizationSlug: ParamOrganizationSlug,\n regionUrl: ParamRegionUrl.optional(),\n query: ParamSearchQuery.optional(),\n },\n annotations: {\n readOnlyHint: true,\n openWorldHint: true,\n },\n async handler(params, context: ServerContext) {\n const apiService = apiServiceFromContext(context, {\n regionUrl: params.regionUrl,\n });\n const organizationSlug = params.organizationSlug;\n\n if (!organizationSlug) {\n throw new UserInputError(\n \"Organization slug is required. Please provide an organizationSlug parameter.\",\n );\n }\n\n setTag(\"organization.slug\", organizationSlug);\n\n const projects = await apiService.listProjects(organizationSlug, {\n query: params.query,\n });\n\n let output = `# Projects in **${organizationSlug}**\\n\\n`;\n\n if (params.query) {\n output += `**Search query:** \"${params.query}\"\\n\\n`;\n }\n\n if (projects.length === 0) {\n output += params.query\n ? `No projects found matching \"${params.query}\".\\n`\n : \"No projects found.\\n\";\n return output;\n }\n\n output += projects.map((project) => `- **${project.slug}**\\n`).join(\"\");\n\n if (projects.length === RESULT_LIMIT) {\n output += `\\n---\\n\\n**Note:** Showing ${RESULT_LIMIT} results (maximum). There may be more projects available. Use the \\`query\\` parameter to search for specific projects.`;\n }\n\n return output;\n },\n});\n"],"mappings":";;;;;;;;AAYA,MAAM,eAAe;AAErB,4BAAe,WAAW;CACxB,MAAM;CACN,gBAAgB;CAChB,gBAAgB,CAAC,cAAe;CAChC,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;GACC,gBAAgB,aAAa;CAC/B,EAAC,KAAK,KAAK;CACZ,aAAa;EACX,kBAAkB;EAClB,WAAW,eAAe,UAAU;EACpC,OAAO,iBAAiB,UAAU;CACnC;CACD,aAAa;EACX,cAAc;EACd,eAAe;CAChB;CACD,MAAM,QAAQ,QAAQA,SAAwB;EAC5C,MAAM,aAAa,sBAAsB,SAAS,EAChD,WAAW,OAAO,UACnB,EAAC;EACF,MAAM,mBAAmB,OAAO;AAEhC,OAAK,iBACH,OAAM,IAAI,eACR;AAIJ,SAAO,qBAAqB,iBAAiB;EAE7C,MAAM,WAAW,MAAM,WAAW,aAAa,kBAAkB,EAC/D,OAAO,OAAO,MACf,EAAC;EAEF,IAAI,UAAU,kBAAkB,iBAAiB;AAEjD,MAAI,OAAO,MACT,YAAW,qBAAqB,OAAO,MAAM;AAG/C,MAAI,SAAS,WAAW,GAAG;AACzB,aAAU,OAAO,SACZ,8BAA8B,OAAO,MAAM,QAC5C;AACJ,UAAO;EACR;AAED,YAAU,SAAS,IAAI,CAAC,aAAa,MAAM,QAAQ,KAAK,MAAM,CAAC,KAAK,GAAG;AAEvE,MAAI,SAAS,WAAW,aACtB,YAAW,6BAA6B,aAAa;AAGvD,SAAO;CACR;AACF,EAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-releases-DWWonhlV.js","names":["context: ServerContext"],"sources":["../src/tools/find-releases.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { setTag } from \"@sentry/core\";\nimport { defineTool } from \"../internal/tool-helpers/define\";\nimport { apiServiceFromContext } from \"../internal/tool-helpers/api\";\nimport type { ServerContext } from \"../types\";\nimport {\n ParamOrganizationSlug,\n ParamRegionUrl,\n ParamProjectSlugOrAll,\n} from \"../schema\";\n\nexport default defineTool({\n name: \"find_releases\",\n requiredSkills: [\"inspect\"], // Only available in inspect skill\n requiredScopes: [\"project:read\"],\n description: [\n \"Find releases in Sentry.\",\n \"\",\n \"Use this tool when you need to:\",\n \"- Find recent releases in a Sentry organization\",\n \"- Find the most recent version released of a specific project\",\n \"- Determine when a release was deployed to an environment\",\n \"\",\n \"<examples>\",\n \"### Find the most recent releases in the 'my-organization' organization\",\n \"\",\n \"```\",\n \"find_releases(organizationSlug='my-organization')\",\n \"```\",\n \"\",\n \"### Find releases matching '2ce6a27' in the 'my-organization' organization\",\n \"\",\n \"```\",\n \"find_releases(organizationSlug='my-organization', query='2ce6a27')\",\n \"```\",\n \"</examples>\",\n \"\",\n \"<hints>\",\n \"- If the user passes a parameter in the form of name/otherName, its likely in the format of <organizationSlug>/<projectSlug>.\",\n \"</hints>\",\n ].join(\"\\n\"),\n inputSchema: {\n organizationSlug: ParamOrganizationSlug,\n regionUrl: ParamRegionUrl.optional(),\n projectSlug: ParamProjectSlugOrAll.optional(),\n query: z\n .string()\n .trim()\n .describe(\"Search for versions which contain the provided string.\")\n .optional(),\n },\n annotations: {\n readOnlyHint: true,\n openWorldHint: true,\n },\n async handler(params, context: ServerContext) {\n const apiService = apiServiceFromContext(context, {\n regionUrl: params.regionUrl,\n });\n const organizationSlug = params.organizationSlug;\n\n setTag(\"organization.slug\", organizationSlug);\n\n const releases = await apiService.listReleases({\n organizationSlug,\n projectSlug: params.projectSlug,\n query: params.query,\n });\n let output = `# Releases in **${organizationSlug}${params.projectSlug ? `/${params.projectSlug}` : \"\"}**\\n\\n`;\n if (releases.length === 0) {\n output += \"No releases found.\\n\";\n return output;\n }\n output += releases\n .map((release) => {\n const releaseInfo = [\n `## ${release.shortVersion}`,\n \"\",\n `**Created**: ${new Date(release.dateCreated).toISOString()}`,\n ];\n if (release.dateReleased) {\n releaseInfo.push(\n `**Released**: ${new Date(release.dateReleased).toISOString()}`,\n );\n }\n if (release.firstEvent) {\n releaseInfo.push(\n `**First Event**: ${new Date(release.firstEvent).toISOString()}`,\n );\n }\n if (release.lastEvent) {\n releaseInfo.push(\n `**Last Event**: ${new Date(release.lastEvent).toISOString()}`,\n );\n }\n if (release.newGroups !== undefined) {\n releaseInfo.push(`**New Issues**: ${release.newGroups}`);\n }\n if (release.projects && release.projects.length > 0) {\n releaseInfo.push(\n `**Projects**: ${release.projects.map((p) => p.name).join(\", \")}`,\n );\n }\n if (release.lastCommit) {\n releaseInfo.push(\"\", `### Last Commit`, \"\");\n releaseInfo.push(`**Commit ID**: ${release.lastCommit.id}`);\n releaseInfo.push(`**Commit Message**: ${release.lastCommit.message}`);\n releaseInfo.push(\n `**Commit Author**: ${release.lastCommit.author.name}`,\n );\n releaseInfo.push(\n `**Commit Date**: ${new Date(release.lastCommit.dateCreated).toISOString()}`,\n );\n }\n if (release.lastDeploy) {\n releaseInfo.push(\"\", `### Last Deploy`, \"\");\n releaseInfo.push(`**Deploy ID**: ${release.lastDeploy.id}`);\n releaseInfo.push(\n `**Environment**: ${release.lastDeploy.environment}`,\n );\n if (release.lastDeploy.dateStarted) {\n releaseInfo.push(\n `**Deploy Started**: ${new Date(release.lastDeploy.dateStarted).toISOString()}`,\n );\n }\n if (release.lastDeploy.dateFinished) {\n releaseInfo.push(\n `**Deploy Finished**: ${new Date(release.lastDeploy.dateFinished).toISOString()}`,\n );\n }\n }\n return releaseInfo.join(\"\\n\");\n })\n .join(\"\\n\\n\");\n output += \"\\n\\n\";\n output += \"# Using this information\\n\\n\";\n output += `- You can reference the Release version in commit messages or documentation.\\n`;\n output += `- You can search for issues in a specific release using the \\`find_errors()\\` tool with the query \\`release:${releases.length ? releases[0]!.shortVersion : \"VERSION\"}\\`.\\n`;\n return output;\n },\n});\n"],"mappings":";;;;;;;AAWA,4BAAe,WAAW;CACxB,MAAM;CACN,gBAAgB,CAAC,SAAU;CAC3B,gBAAgB,CAAC,cAAe;CAChC,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,EAAC,KAAK,KAAK;CACZ,aAAa;EACX,kBAAkB;EAClB,WAAW,eAAe,UAAU;EACpC,aAAa,sBAAsB,UAAU;EAC7C,OAAO,EACJ,QAAQ,CACR,MAAM,CACN,SAAS,yDAAyD,CAClE,UAAU;CACd;CACD,aAAa;EACX,cAAc;EACd,eAAe;CAChB;CACD,MAAM,QAAQ,QAAQA,SAAwB;EAC5C,MAAM,aAAa,sBAAsB,SAAS,EAChD,WAAW,OAAO,UACnB,EAAC;EACF,MAAM,mBAAmB,OAAO;AAEhC,SAAO,qBAAqB,iBAAiB;EAE7C,MAAM,WAAW,MAAM,WAAW,aAA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Y,MACT,sBAAsB,IAAI,KAAK,QAAQ,WAAW,aAAa,aAAa,GAC9E;AAEH,QAAI,QAAQ,WAAW,aACrB,aAAY,MACT,uBAAuB,IAAI,KAAK,QAAQ,WAAW,cAAc,aAAa,GAChF;GAEJ;AACD,UAAO,YAAY,KAAK,KAAK;EAC9B,EAAC,CACD,KAAK,OAAO;AACf,YAAU;AACV,YAAU;AACV,aAAW;AACX,aAAW,8GAA8G,SAAS,SAAS,SAAS,GAAI,eAAe,UAAU;AACjL,SAAO;CACR;AACF,EAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-releases-Du5euXKS.cjs","names":["ParamOrganizationSlug","context: ServerContext"],"sources":["../src/tools/find-releases.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { setTag } from \"@sentry/core\";\nimport { defineTool } from \"../internal/tool-helpers/define\";\nimport { apiServiceFromContext } from \"../internal/tool-helpers/api\";\nimport type { ServerContext } from \"../types\";\nimport {\n ParamOrganizationSlug,\n ParamRegionUrl,\n ParamProjectSlugOrAll,\n} from \"../schema\";\n\nexport default defineTool({\n name: \"find_releases\",\n requiredSkills: [\"inspect\"], // Only available in inspect skill\n requiredScopes: [\"project:read\"],\n description: [\n \"Find releases in Sentry.\",\n \"\",\n \"Use this tool when you need to:\",\n \"- Find recent releases in a Sentry organization\",\n \"- Find the most recent version released of a specific project\",\n \"- Determine when a release was deployed to an environment\",\n \"\",\n \"<examples>\",\n \"### Find the most recent releases in the 'my-organization' organization\",\n \"\",\n \"```\",\n \"find_releases(organizationSlug='my-organization')\",\n \"```\",\n \"\",\n \"### Find releases matching '2ce6a27' in the 'my-organization' organization\",\n \"\",\n \"```\",\n \"find_releases(organizationSlug='my-organization', query='2ce6a27')\",\n \"```\",\n \"</examples>\",\n \"\",\n \"<hints>\",\n \"- If the user passes a parameter in the form of name/otherName, its likely in the format of <organizationSlug>/<projectSlug>.\",\n \"</hints>\",\n ].join(\"\\n\"),\n inputSchema: {\n organizationSlug: ParamOrganizationSlug,\n regionUrl: ParamRegionUrl.optional(),\n projectSlug: ParamProjectSlugOrAll.optional(),\n query: z\n .string()\n .trim()\n .describe(\"Search for versions which contain the provided string.\")\n .optional(),\n },\n annotations: {\n readOnlyHint: true,\n openWorldHint: true,\n },\n async handler(params, context: ServerContext) {\n const apiService = apiServiceFromContext(context, {\n regionUrl: params.regionUrl,\n });\n const organizationSlug = params.organizationSlug;\n\n setTag(\"organization.slug\", organizationSlug);\n\n const releases = await apiService.listReleases({\n organizationSlug,\n projectSlug: params.projectSlug,\n query: params.query,\n });\n let output = `# Releases in **${organizationSlug}${params.projectSlug ? `/${params.projectSlug}` : \"\"}**\\n\\n`;\n if (releases.length === 0) {\n output += \"No releases found.\\n\";\n return output;\n }\n output += releases\n .map((release) => {\n const releaseInfo = [\n `## ${release.shortVersion}`,\n \"\",\n `**Created**: ${new Date(release.dateCreated).toISOString()}`,\n ];\n if (release.dateReleased) {\n releaseInfo.push(\n `**Released**: ${new Date(release.dateReleased).toISOString()}`,\n );\n }\n if (release.firstEvent) {\n releaseInfo.push(\n `**First Event**: ${new Date(release.firstEvent).toISOString()}`,\n );\n }\n if (release.lastEvent) {\n releaseInfo.push(\n `**Last Event**: ${new Date(release.lastEvent).toISOString()}`,\n );\n }\n if (release.newGroups !== undefined) {\n releaseInfo.push(`**New Issues**: ${release.newGroups}`);\n }\n if (release.projects && release.projects.length > 0) {\n releaseInfo.push(\n `**Projects**: ${release.projects.map((p) => p.name).join(\", \")}`,\n );\n }\n if (release.lastCommit) {\n releaseInfo.push(\"\", `### Last Commit`, \"\");\n releaseInfo.push(`**Commit ID**: ${release.lastCommit.id}`);\n releaseInfo.push(`**Commit Message**: ${release.lastCommit.message}`);\n releaseInfo.push(\n `**Commit Author**: ${release.lastCommit.author.name}`,\n );\n releaseInfo.push(\n `**Commit Date**: ${new Date(release.lastCommit.dateCreated).toISOString()}`,\n );\n }\n if (release.lastDeploy) {\n releaseInfo.push(\"\", `### Last Deploy`, \"\");\n releaseInfo.push(`**Deploy ID**: ${release.lastDeploy.id}`);\n releaseInfo.push(\n `**Environment**: ${release.lastDeploy.environment}`,\n );\n if (release.lastDeploy.dateStarted) {\n releaseInfo.push(\n `**Deploy Started**: ${new Date(release.lastDeploy.dateStarted).toISOString()}`,\n );\n }\n if (release.lastDeploy.dateFinished) {\n releaseInfo.push(\n `**Deploy Finished**: ${new Date(release.lastDeploy.dateFinished).toISOString()}`,\n );\n }\n }\n return releaseInfo.join(\"\\n\");\n })\n .join(\"\\n\\n\");\n output += \"\\n\\n\";\n output += \"# Using this information\\n\\n\";\n output += `- You can reference the Release version in commit messages or documentation.\\n`;\n output += `- You can search for issues in a specific release using the \\`find_errors()\\` tool with the query \\`release:${releases.length ? releases[0]!.shortVersion : \"VERSION\"}\\`.\\n`;\n return output;\n },\n});\n"],"mappings":";;;;;;;;AAWA,4BAAe,0BAAW;CACxB,MAAM;CACN,gBAAgB,CAAC,SAAU;CAC3B,gBAAgB,CAAC,cAAe;CAChC,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,EAAC,KAAK,KAAK;CACZ,aAAa;EACX,kBAAkBA;EAClB,WAAW,8BAAe,UAAU;EACpC,aAAa,qCAAsB,UAAU;EAC7C,OAAO,MACJ,QAAQ,CACR,MAAM,CACN,SAAS,yDAAyD,CAClE,UAAU;CACd;CACD,aAAa;EACX,cAAc;EACd,eAAe;CAChB;CACD,MAAM,QAAQ,QAAQC,SAAwB;EAC5C,MAAM,aAAa,kCAAsB,SAAS,EAChD,WAAW,OAAO,UACnB,EAAC;EACF,MAAM,mBAAmB,OAAO;AAEhC,4BAAO,qBAAqB,iBAAiB;EAE7C,MAAM,WAAW,MAAM,WAAW,aAAa;GAC7C;GACA,aAAa,OAAO;GACpB,OAAO,OAAO;EACf,EAAC;EACF,IAAI,UAAU,kBAAkB,mBAAm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ACrB,aAAY,MACT,uBAAuB,IAAI,KAAK,QAAQ,WAAW,cAAc,aAAa,GAChF;GAEJ;AACD,UAAO,YAAY,KAAK,KAAK;EAC9B,EAAC,CACD,KAAK,OAAO;AACf,YAAU;AACV,YAAU;AACV,aAAW;AACX,aAAW,8GAA8G,SAAS,SAAS,SAAS,GAAI,eAAe,UAAU;AACjL,SAAO;CACR;AACF,EAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-teams-BM4yWKe_.js","names":["context: ServerContext"],"sources":["../src/tools/find-teams.ts"],"sourcesContent":["import { setTag } from \"@sentry/core\";\nimport { defineTool } from \"../internal/tool-helpers/define\";\nimport { apiServiceFromContext } from \"../internal/tool-helpers/api\";\nimport { UserInputError } from \"../errors\";\nimport type { ServerContext } from \"../types\";\nimport {\n ParamOrganizationSlug,\n ParamRegionUrl,\n ParamSearchQuery,\n} from \"../schema\";\n\nconst RESULT_LIMIT = 25;\n\nexport default defineTool({\n name: \"find_teams\",\n requiredSkills: [\"inspect\", \"triage\", \"project-management\"], // Team viewing and management\n requiredScopes: [\"team:read\"],\n description: [\n \"Find teams in an organization in Sentry.\",\n \"\",\n \"Use this tool when you need to:\",\n \"- View teams in a Sentry organization\",\n \"- Find a team's slug to aid other tool requests\",\n \"- Search for specific teams by name or slug\",\n \"\",\n `Returns up to ${RESULT_LIMIT} results. If you hit this limit, use the query parameter to narrow down results.`,\n ].join(\"\\n\"),\n inputSchema: {\n organizationSlug: ParamOrganizationSlug,\n regionUrl: ParamRegionUrl.optional(),\n query: ParamSearchQuery.optional(),\n },\n annotations: {\n readOnlyHint: true,\n openWorldHint: true,\n },\n async handler(params, context: ServerContext) {\n const apiService = apiServiceFromContext(context, {\n regionUrl: params.regionUrl,\n });\n const organizationSlug = params.organizationSlug;\n\n if (!organizationSlug) {\n throw new UserInputError(\n \"Organization slug is required. Please provide an organizationSlug parameter.\",\n );\n }\n\n setTag(\"organization.slug\", organizationSlug);\n\n const teams = await apiService.listTeams(organizationSlug, {\n query: params.query,\n });\n\n let output = `# Teams in **${organizationSlug}**\\n\\n`;\n\n if (params.query) {\n output += `**Search query:** \"${params.query}\"\\n\\n`;\n }\n\n if (teams.length === 0) {\n output += params.query\n ? `No teams found matching \"${params.query}\".\\n`\n : \"No teams found.\\n\";\n return output;\n }\n\n output += teams.map((team) => `- ${team.slug}\\n`).join(\"\");\n\n if (teams.length === RESULT_LIMIT) {\n output += `\\n---\\n\\n**Note:** Showing ${RESULT_LIMIT} results (maximum). There may be more teams available. Use the \\`query\\` parameter to search for specific teams.`;\n }\n\n return output;\n },\n});\n"],"mappings":";;;;;;;AAWA,MAAM,eAAe;AAErB,yBAAe,WAAW;CACxB,MAAM;CACN,gBAAgB;EAAC;EAAW;EAAU;CAAqB;CAC3D,gBAAgB,CAAC,WAAY;CAC7B,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;GACC,gBAAgB,aAAa;CAC/B,EAAC,KAAK,KAAK;CACZ,aAAa;EACX,kBAAkB;EAClB,WAAW,eAAe,UAAU;EACpC,OAAO,iBAAiB,UAAU;CACnC;CACD,aAAa;EACX,cAAc;EACd,eAAe;CAChB;CACD,MAAM,QAAQ,QAAQA,SAAwB;EAC5C,MAAM,aAAa,sBAAsB,SAAS,EAChD,WAAW,OAAO,UACnB,EAAC;EACF,MAAM,mBAAmB,OAAO;AAEhC,OAAK,iBACH,OAAM,IAAI,eACR;AAIJ,SAAO,qBAAqB,iBAAiB;EAE7C,MAAM,QAAQ,MAAM,WAAW,UAAU,kBAAkB,EACzD,OAAO,OAAO,MACf,EAAC;EAEF,IAAI,UAAU,eAAe,iBAAiB;AAE9C,MAAI,OAAO,MACT,YAAW,qBAAqB,OAAO,MAAM;AAG/C,MAAI,MAAM,WAAW,GAAG;AACtB,aAAU,OAAO,SACZ,2BAA2B,OAAO,MAAM,QACzC;AACJ,UAAO;EACR;AAED,YAAU,MAAM,IAAI,CAAC,UAAU,IAAI,KAAK,KAAK,IAAI,CAAC,KAAK,GAAG;AAE1D,MAAI,MAAM,WAAW,aACnB,YAAW,6BAA6B,aAAa;AAGvD,SAAO;CACR;AACF,EAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-teams-Bp6-Iu62.cjs","names":["ParamOrganizationSlug","context: ServerContext","UserInputError"],"sources":["../src/tools/find-teams.ts"],"sourcesContent":["import { setTag } from \"@sentry/core\";\nimport { defineTool } from \"../internal/tool-helpers/define\";\nimport { apiServiceFromContext } from \"../internal/tool-helpers/api\";\nimport { UserInputError } from \"../errors\";\nimport type { ServerContext } from \"../types\";\nimport {\n ParamOrganizationSlug,\n ParamRegionUrl,\n ParamSearchQuery,\n} from \"../schema\";\n\nconst RESULT_LIMIT = 25;\n\nexport default defineTool({\n name: \"find_teams\",\n requiredSkills: [\"inspect\", \"triage\", \"project-management\"], // Team viewing and management\n requiredScopes: [\"team:read\"],\n description: [\n \"Find teams in an organization in Sentry.\",\n \"\",\n \"Use this tool when you need to:\",\n \"- View teams in a Sentry organization\",\n \"- Find a team's slug to aid other tool requests\",\n \"- Search for specific teams by name or slug\",\n \"\",\n `Returns up to ${RESULT_LIMIT} results. If you hit this limit, use the query parameter to narrow down results.`,\n ].join(\"\\n\"),\n inputSchema: {\n organizationSlug: ParamOrganizationSlug,\n regionUrl: ParamRegionUrl.optional(),\n query: ParamSearchQuery.optional(),\n },\n annotations: {\n readOnlyHint: true,\n openWorldHint: true,\n },\n async handler(params, context: ServerContext) {\n const apiService = apiServiceFromContext(context, {\n regionUrl: params.regionUrl,\n });\n const organizationSlug = params.organizationSlug;\n\n if (!organizationSlug) {\n throw new UserInputError(\n \"Organization slug is required. Please provide an organizationSlug parameter.\",\n );\n }\n\n setTag(\"organization.slug\", organizationSlug);\n\n const teams = await apiService.listTeams(organizationSlug, {\n query: params.query,\n });\n\n let output = `# Teams in **${organizationSlug}**\\n\\n`;\n\n if (params.query) {\n output += `**Search query:** \"${params.query}\"\\n\\n`;\n }\n\n if (teams.length === 0) {\n output += params.query\n ? `No teams found matching \"${params.query}\".\\n`\n : \"No teams found.\\n\";\n return output;\n }\n\n output += teams.map((team) => `- ${team.slug}\\n`).join(\"\");\n\n if (teams.length === RESULT_LIMIT) {\n output += `\\n---\\n\\n**Note:** Showing ${RESULT_LIMIT} results (maximum). There may be more teams available. Use the \\`query\\` parameter to search for specific teams.`;\n }\n\n return output;\n },\n});\n"],"mappings":";;;;;;;;AAWA,MAAM,eAAe;AAErB,yBAAe,0BAAW;CACxB,MAAM;CACN,gBAAgB;EAAC;EAAW;EAAU;CAAqB;CAC3D,gBAAgB,CAAC,WAAY;CAC7B,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;GACC,gBAAgB,aAAa;CAC/B,EAAC,KAAK,KAAK;CACZ,aAAa;EACX,kBAAkBA;EAClB,WAAW,8BAAe,UAAU;EACpC,OAAO,gCAAiB,UAAU;CACnC;CACD,aAAa;EACX,cAAc;EACd,eAAe;CAChB;CACD,MAAM,QAAQ,QAAQC,SAAwB;EAC5C,MAAM,aAAa,kCAAsB,SAAS,EAChD,WAAW,OAAO,UACnB,EAAC;EACF,MAAM,mBAAmB,OAAO;AAEhC,OAAK,iBACH,OAAM,IAAIC,8BACR;AAIJ,4BAAO,qBAAqB,iBAAiB;EAE7C,MAAM,QAAQ,MAAM,WAAW,UAAU,kBAAkB,EACzD,OAAO,OAAO,MACf,EAAC;EAEF,IAAI,UAAU,eAAe,iBAAiB;AAE9C,MAAI,OAAO,MACT,YAAW,qBAAqB,OAAO,MAAM;AAG/C,MAAI,MAAM,WAAW,GAAG;AACtB,aAAU,OAAO,SACZ,2BAA2B,OAAO,MAAM,QACzC;AACJ,UAAO;EACR;AAED,YAAU,MAAM,IAAI,CAAC,UAAU,IAAI,KAAK,KAAK,IAAI,CAAC,KAAK,GAAG;AAE1D,MAAI,MAAM,WAAW,aACnB,YAAW,6BAA6B,aAAa;AAGvD,SAAO;CACR;AACF,EAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatting-5u-ZFz8H.cjs","names":["LANGUAGE_EXTENSIONS: Record<string, string>","LANGUAGE_MODULE_PATTERNS: Array<[RegExp, string]>","frame: z.infer<typeof FrameInterface>","platform?: string | null","frameIndex?: number","event: Event","options?: {\n performanceTrace?: Trace;\n }","parts: string[]","data: z.infer<typeof ErrorEntrySchema>","platform: string | null","index: number","totalExceptions: number","data: z.infer<typeof RequestEntrySchema>","data: z.infer<typeof MessageEntrySchema>","data: z.infer<typeof ThreadsEntrySchema>","lines: string[]","value: unknown","vars: Record<string, unknown>","frames: z.infer<typeof FrameInterface>[]","defaultValue: number","span: RawSpan","values: unknown","evidenceData: N1EvidenceData","node: unknown","trace: Trace","parentSpanIds: string[]","offenderSpanIds: string[]","maxSpans: number","span: TraceSpan","roots: PerformanceSpan[]","offenderSet: Set<string>","budget: { count: number; limit: number }","level: number","performanceSpan: PerformanceSpan","spans: RawSpan[]","summaries: string[]","spans: PerformanceSpan[]","span: PerformanceSpan","metadataParts: string[]","evidence: N1EvidenceData","selected: PerformanceSpan[]","parentSpan: PerformanceSpan | null","perfSpan: PerformanceSpan","OCCURRENCE_TYPE_TO_ISSUE_TYPE: Record<number, string>","spansData: unknown","performanceTrace?: Trace","evidenceData: SlowDbEvidenceData","issueType: string | undefined","tags: z.infer<typeof EventSchema>[\"tags\"]","context: z.infer<typeof EventSchema>[\"context\"]","contexts: z.infer<typeof EventSchema>[\"contexts\"]","autofixState: AutofixRunState | undefined","organizationSlug: string","issueId: string"],"sources":["../src/internal/formatting.ts"],"sourcesContent":["/**\n * LLM response formatting utilities for Sentry data.\n *\n * Converts Sentry API responses into structured markdown format optimized\n * for LLM consumption. Handles stacktraces, event details, issue summaries,\n * and contextual information with consistent formatting patterns.\n */\nimport type { z } from \"zod\";\nimport type {\n Event,\n Issue,\n AutofixRunState,\n Trace,\n TraceSpan,\n} from \"../api-client/types\";\nimport type {\n ErrorEntrySchema,\n ErrorEventSchema,\n EventSchema,\n FrameInterface,\n RequestEntrySchema,\n MessageEntrySchema,\n ThreadsEntrySchema,\n SentryApiService,\n AutofixRunStepRootCauseAnalysisSchema,\n} from \"../api-client\";\nimport {\n getOutputForAutofixStep,\n isTerminalStatus,\n getStatusDisplayName,\n} from \"./tool-helpers/seer\";\n\n// Language detection mappings\nconst LANGUAGE_EXTENSIONS: Record<string, string> = {\n \".java\": \"java\",\n \".py\": \"python\",\n \".js\": \"javascript\",\n \".jsx\": \"javascript\",\n \".ts\": \"javascript\",\n \".tsx\": \"javascript\",\n \".rb\": \"ruby\",\n \".php\": \"php\",\n};\n\nconst LANGUAGE_MODULE_PATTERNS: Array<[RegExp, string]> = [\n [/^(java\\.|com\\.|org\\.)/, \"java\"],\n];\n\n/**\n * Detects the programming language of a stack frame based on the file extension.\n * Falls back to the platform parameter if no filename is available or extension is unrecognized.\n *\n * @param frame - The stack frame containing file and location information\n * @param platform - Optional platform hint to use as fallback\n * @returns The detected language or platform fallback or \"unknown\"\n */\nfunction detectLanguage(\n frame: z.infer<typeof FrameInterface>,\n platform?: string | null,\n): string {\n // Check filename extensions\n if (frame.filename) {\n const ext = frame.filename.toLowerCase().match(/\\.[^.]+$/)?.[0];\n if (ext && LANGUAGE_EXTENSIONS[ext]) {\n return LANGUAGE_EXTENSIONS[ext];\n }\n }\n\n // Check module patterns\n if (frame.module) {\n for (const [pattern, language] of LANGUAGE_MODULE_PATTERNS) {\n if (pattern.test(frame.module)) {\n return language;\n }\n }\n }\n\n // Fallback to platform or unknown\n return platform || \"unknown\";\n}\n\n/**\n * Formats a stack frame into a language-specific string representation.\n * Different languages have different conventions for displaying stack traces.\n *\n * @param frame - The stack frame to format\n * @param frameIndex - Optional frame index for languages that display frame numbers\n * @param platform - Optional platform hint for language detection fallback\n * @returns Formatted stack frame string\n */\nexport function formatFrameHeader(\n frame: z.infer<typeof FrameInterface>,\n frameIndex?: number,\n platform?: string | null,\n) {\n const language = detectLanguage(frame, platform);\n\n switch (language) {\n case \"java\": {\n // at com.example.ClassName.methodName(FileName.java:123)\n const className = frame.module || \"UnknownClass\";\n const method = frame.function || \"<unknown>\";\n const source = frame.filename || \"Unknown Source\";\n const location = frame.lineNo ? `:${frame.lineNo}` : \"\";\n return `at ${className}.${method}(${source}${location})`;\n }\n\n case \"python\": {\n // File \"/path/to/file.py\", line 42, in function_name\n const file =\n frame.filename || frame.absPath || frame.module || \"<unknown>\";\n const func = frame.function || \"<module>\";\n const line = frame.lineNo ? `, line ${frame.lineNo}` : \"\";\n return ` File \"${file}\"${line}, in ${func}`;\n }\n\n case \"javascript\": {\n // Original compact format: filename:line:col (function)\n // This preserves backward compatibility\n return `${[frame.filename, frame.lineNo, frame.colNo]\n .filter((i) => !!i)\n .join(\":\")}${frame.function ? ` (${frame.function})` : \"\"}`;\n }\n\n case \"ruby\": {\n // from /path/to/file.rb:42:in `method_name'\n const file = frame.filename || frame.module || \"<unknown>\";\n const func = frame.function ? ` \\`${frame.function}\\`` : \"\";\n const line = frame.lineNo ? `:${frame.lineNo}:in` : \"\";\n return ` from ${file}${line}${func}`;\n }\n\n case \"php\": {\n // #0 /path/to/file.php(42): functionName()\n const file = frame.filename || \"<unknown>\";\n const line = frame.lineNo ? `(${frame.lineNo})` : \"\";\n const func = frame.function || \"<unknown>\";\n const prefix = frameIndex !== undefined ? `#${frameIndex} ` : \"\";\n return `${prefix}${file}${line}: ${func}()`;\n }\n\n default: {\n // Generic format for unknown languages\n const func = frame.function || \"<unknown>\";\n const location = frame.filename || frame.module || \"<unknown>\";\n const line = frame.lineNo ? `:${frame.lineNo}` : \"\";\n const col = frame.colNo != null ? `:${frame.colNo}` : \"\";\n return ` at ${func} (${location}${line}${col})`;\n }\n }\n}\n\n/**\n * Formats a Sentry event into a structured markdown output.\n * Includes error messages, stack traces, request info, and contextual data.\n *\n * @param event - The Sentry event to format\n * @param options - Additional formatting context\n * @returns Formatted markdown string\n */\nexport function formatEventOutput(\n event: Event,\n options?: {\n performanceTrace?: Trace;\n },\n) {\n let output = \"\";\n\n // Look for the primary error information\n const messageEntry = event.entries.find((e) => e.type === \"message\");\n const exceptionEntry = event.entries.find((e) => e.type === \"exception\");\n const threadsEntry = event.entries.find((e) => e.type === \"threads\");\n const requestEntry = event.entries.find((e) => e.type === \"request\");\n const spansEntry = event.entries.find((e) => e.type === \"spans\");\n\n // Error message (if present)\n if (messageEntry) {\n output += formatMessageInterfaceOutput(\n event,\n messageEntry.data as z.infer<typeof MessageEntrySchema>,\n );\n }\n\n // Stack trace (from exception or threads)\n if (exceptionEntry) {\n output += formatExceptionInterfaceOutput(\n event,\n exceptionEntry.data as z.infer<typeof ErrorEntrySchema>,\n );\n } else if (threadsEntry) {\n output += formatThreadsInterfaceOutput(\n event,\n threadsEntry.data as z.infer<typeof ThreadsEntrySchema>,\n );\n }\n\n // Request info (if HTTP error)\n if (requestEntry) {\n output += formatRequestInterfaceOutput(\n event,\n requestEntry.data as z.infer<typeof RequestEntrySchema>,\n );\n }\n\n // Performance issue details (N+1 queries, etc.)\n // Pass spans data for additional context even if we have evidence\n if (event.type === \"transaction\") {\n output += formatPerformanceIssueOutput(event, spansEntry?.data, options);\n }\n\n output += formatTags(event.tags);\n output += formatContext(event.context);\n output += formatContexts(event.contexts);\n return output;\n}\n\n/**\n * Extracts the context line matching the frame's line number for inline display.\n * This is used in the full stacktrace view to show the actual line of code\n * that caused the error inline with the stack frame.\n *\n * @param frame - The stack frame containing context lines\n * @returns The line of code at the frame's line number, or empty string if not available\n */\nfunction renderInlineContext(frame: z.infer<typeof FrameInterface>): string {\n if (!frame.context?.length || !frame.lineNo) {\n return \"\";\n }\n\n const contextLine = frame.context.find(([lineNo]) => lineNo === frame.lineNo);\n return contextLine ? `\\n${contextLine[1]}` : \"\";\n}\n\n/**\n * Renders an enhanced view of a stack frame with context lines and variables.\n * Used for the \"Most Relevant Frame\" section to provide detailed information\n * about the most relevant application frame where the error occurred.\n *\n * @param frame - The stack frame to render with enhanced information\n * @param event - The Sentry event containing platform information for language detection\n * @returns Formatted string with frame header, context lines, and variables table\n */\nfunction renderEnhancedFrame(\n frame: z.infer<typeof FrameInterface>,\n event: Event,\n): string {\n const parts: string[] = [];\n\n parts.push(\"**Most Relevant Frame:**\");\n parts.push(\"─────────────────────\");\n parts.push(formatFrameHeader(frame, undefined, event.platform));\n\n // Add context lines if available\n if (frame.context?.length) {\n const contextLines = renderContextLines(frame);\n if (contextLines) {\n parts.push(\"\");\n parts.push(contextLines);\n }\n }\n\n // Add variables table if available\n if (frame.vars && Object.keys(frame.vars).length > 0) {\n parts.push(\"\");\n parts.push(renderVariablesTable(frame.vars));\n }\n\n return parts.join(\"\\n\");\n}\n\nfunction formatExceptionInterfaceOutput(\n event: Event,\n data: z.infer<typeof ErrorEntrySchema>,\n) {\n const parts: string[] = [];\n\n // Handle both single exception (value) and chained exceptions (values)\n const exceptions = data.values || (data.value ? [data.value] : []);\n\n if (exceptions.length === 0) {\n return \"\";\n }\n\n // For chained exceptions, they are typically ordered from innermost to outermost\n // We'll render them in reverse order (outermost first) to match how they occurred\n const isChained = exceptions.length > 1;\n\n // Create a copy before reversing to avoid mutating the original array\n [...exceptions].reverse().forEach((exception, index) => {\n if (!exception) return;\n\n // Add language-specific chain indicator for multiple exceptions\n if (isChained && index > 0) {\n parts.push(\"\");\n parts.push(\n getExceptionChainMessage(\n event.platform || null,\n index,\n exceptions.length,\n ),\n );\n parts.push(\"\");\n }\n\n // Use the actual exception type and value as the heading\n const exceptionTitle = `${exception.type}${exception.value ? `: ${exception.value}` : \"\"}`;\n\n parts.push(index === 0 ? \"### Error\" : `### ${exceptionTitle}`);\n parts.push(\"\");\n\n // Add the error details in a code block for the first exception\n // to maintain backward compatibility\n if (index === 0) {\n parts.push(\"```\");\n parts.push(exceptionTitle);\n parts.push(\"```\");\n parts.push(\"\");\n }\n\n if (!exception.stacktrace || !exception.stacktrace.frames) {\n parts.push(\"**Stacktrace:**\");\n parts.push(\"```\");\n parts.push(\"No stacktrace available\");\n parts.push(\"```\");\n return;\n }\n\n const frames = exception.stacktrace.frames;\n\n // Only show enhanced frame for the first (outermost) exception to avoid overwhelming output\n if (index === 0) {\n const firstInAppFrame = findFirstInAppFrame(frames);\n if (\n firstInAppFrame &&\n (firstInAppFrame.context?.length || firstInAppFrame.vars)\n ) {\n parts.push(renderEnhancedFrame(firstInAppFrame, event));\n parts.push(\"\");\n parts.push(\"**Full Stacktrace:**\");\n parts.push(\"────────────────\");\n } else {\n parts.push(\"**Stacktrace:**\");\n }\n } else {\n parts.push(\"**Stacktrace:**\");\n }\n\n parts.push(\"```\");\n parts.push(\n frames\n .map((frame) => {\n const header = formatFrameHeader(frame, undefined, event.platform);\n const context = renderInlineContext(frame);\n return `${header}${context}`;\n })\n .join(\"\\n\"),\n );\n parts.push(\"```\");\n });\n\n parts.push(\"\");\n parts.push(\"\");\n\n return parts.join(\"\\n\");\n}\n\n/**\n * Get the appropriate exception chain message based on the platform\n */\nfunction getExceptionChainMessage(\n platform: string | null,\n index: number,\n totalExceptions: number,\n): string {\n // Default message for unknown platforms\n const defaultMessage =\n \"**During handling of the above exception, another exception occurred:**\";\n\n if (!platform) {\n return defaultMessage;\n }\n\n switch (platform.toLowerCase()) {\n case \"python\":\n // Python has two distinct messages, but without additional metadata\n // we default to the implicit chaining message\n return \"**During handling of the above exception, another exception occurred:**\";\n\n case \"java\":\n return \"**Caused by:**\";\n\n case \"csharp\":\n case \"dotnet\":\n return \"**---> Inner Exception:**\";\n\n case \"ruby\":\n return \"**Caused by:**\";\n\n case \"go\":\n return \"**Wrapped error:**\";\n\n case \"rust\":\n return `**Caused by (${index}):**`;\n\n default:\n return defaultMessage;\n }\n}\n\nfunction formatRequestInterfaceOutput(\n event: Event,\n data: z.infer<typeof RequestEntrySchema>,\n) {\n if (!data.method || !data.url) {\n return \"\";\n }\n return `### HTTP Request\\n\\n**Method:** ${data.method}\\n**URL:** ${data.url}\\n\\n`;\n}\n\nfunction formatMessageInterfaceOutput(\n event: Event,\n data: z.infer<typeof MessageEntrySchema>,\n) {\n if (!data.formatted && !data.message) {\n return \"\";\n }\n const message = data.formatted || data.message || \"\";\n return `### Error\\n\\n${\"```\"}\\n${message}\\n${\"```\"}\\n\\n`;\n}\n\nfunction formatThreadsInterfaceOutput(\n event: Event,\n data: z.infer<typeof ThreadsEntrySchema>,\n) {\n if (!data.values || data.values.length === 0) {\n return \"\";\n }\n\n // Find the crashed thread only\n const crashedThread = data.values.find((t) => t.crashed);\n\n if (!crashedThread?.stacktrace?.frames) {\n return \"\";\n }\n\n const parts: string[] = [];\n\n // Include thread name if available\n if (crashedThread.name) {\n parts.push(`**Thread** (${crashedThread.name})`);\n parts.push(\"\");\n }\n\n const frames = crashedThread.stacktrace.frames;\n\n // Find and format the first in-app frame with enhanced view\n const firstInAppFrame = findFirstInAppFrame(frames);\n if (\n firstInAppFrame &&\n (firstInAppFrame.context?.length || firstInAppFrame.vars)\n ) {\n parts.push(renderEnhancedFrame(firstInAppFrame, event));\n parts.push(\"\");\n parts.push(\"**Full Stacktrace:**\");\n parts.push(\"────────────────\");\n } else {\n parts.push(\"**Stacktrace:**\");\n }\n\n parts.push(\"```\");\n parts.push(\n frames\n .map((frame) => {\n const header = formatFrameHeader(frame, undefined, event.platform);\n const context = renderInlineContext(frame);\n return `${header}${context}`;\n })\n .join(\"\\n\"),\n );\n parts.push(\"```\");\n parts.push(\"\");\n\n return parts.join(\"\\n\");\n}\n\n/**\n * Renders surrounding source code context for a stack frame.\n * Shows a window of code lines around the error line with visual indicators.\n *\n * @param frame - The stack frame containing context lines\n * @param contextSize - Number of lines to show before and after the error line (default: 3)\n * @returns Formatted context lines with line numbers and arrow indicator for the error line\n */\nfunction renderContextLines(\n frame: z.infer<typeof FrameInterface>,\n contextSize = 3,\n): string {\n if (!frame.context || frame.context.length === 0 || !frame.lineNo) {\n return \"\";\n }\n\n const lines: string[] = [];\n const errorLine = frame.lineNo;\n const maxLineNoWidth = Math.max(\n ...frame.context.map(([lineNo]) => lineNo.toString().length),\n );\n\n for (const [lineNo, code] of frame.context) {\n const isErrorLine = lineNo === errorLine;\n const lineNoStr = lineNo.toString().padStart(maxLineNoWidth, \" \");\n\n if (Math.abs(lineNo - errorLine) <= contextSize) {\n if (isErrorLine) {\n lines.push(` → ${lineNoStr} │ ${code}`);\n } else {\n lines.push(` ${lineNoStr} │ ${code}`);\n }\n }\n }\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Formats a variable value for display in the variables table.\n * Handles different types appropriately and safely, converting complex objects\n * to readable representations and handling edge cases like circular references.\n *\n * @param value - The variable value to format (can be any type)\n * @param maxLength - Maximum length for stringified objects/arrays (default: 80)\n * @returns Human-readable string representation of the value\n */\nfunction formatVariableValue(value: unknown, maxLength = 80): string {\n try {\n if (typeof value === \"string\") {\n return `\"${value}\"`;\n }\n if (value === null) {\n return \"null\";\n }\n if (value === undefined) {\n return \"undefined\";\n }\n if (typeof value === \"object\") {\n const stringified = JSON.stringify(value);\n if (stringified.length > maxLength) {\n // Leave room for \", ...]\" or \", ...}\"\n const truncateAt = maxLength - 6;\n let truncated = stringified.substring(0, truncateAt);\n\n // Find the last complete element by looking for the last comma\n const lastComma = truncated.lastIndexOf(\",\");\n if (lastComma > 0) {\n truncated = truncated.substring(0, lastComma);\n }\n\n // Add the appropriate ending\n if (Array.isArray(value)) {\n return `${truncated}, ...]`;\n }\n return `${truncated}, ...}`;\n }\n return stringified;\n }\n return String(value);\n } catch {\n // Handle circular references or other stringify errors\n return `<${typeof value}>`;\n }\n}\n\n/**\n * Renders a table of local variables in a tree-like format.\n * Uses box-drawing characters to create a visual hierarchy of variables\n * and their values at the point where the error occurred.\n *\n * @param vars - Object containing variable names as keys and their values\n * @returns Formatted variables table with tree-style prefix characters\n */\nfunction renderVariablesTable(vars: Record<string, unknown>): string {\n const entries = Object.entries(vars);\n if (entries.length === 0) {\n return \"\";\n }\n\n const lines: string[] = [\"Local Variables:\"];\n const lastIndex = entries.length - 1;\n\n entries.forEach(([key, value], index) => {\n const prefix = index === lastIndex ? \"└─\" : \"├─\";\n const valueStr = formatVariableValue(value);\n lines.push(`${prefix} ${key}: ${valueStr}`);\n });\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Finds the first application frame (in_app) in a stack trace.\n * Searches from the bottom of the stack (oldest frame) to find the first\n * frame that belongs to the user's application code rather than libraries.\n *\n * @param frames - Array of stack frames, typically in reverse chronological order\n * @returns The first in-app frame found, or undefined if none exist\n */\nfunction findFirstInAppFrame(\n frames: z.infer<typeof FrameInterface>[],\n): z.infer<typeof FrameInterface> | undefined {\n // Frames are usually in reverse order (most recent first)\n // We want the first in-app frame from the bottom\n for (let i = frames.length - 1; i >= 0; i--) {\n if (frames[i].inApp === true) {\n return frames[i];\n }\n }\n return undefined;\n}\n\n/**\n * Constants for performance issue formatting\n */\nconst MAX_SPANS_IN_TREE = 10;\n\n/**\n * Safely parse a number from a string, returning a default if invalid\n */\nfunction safeParseInt(value: unknown, defaultValue: number): number {\n if (typeof value === \"number\") return value;\n if (typeof value === \"string\") {\n const parsed = Number.parseInt(value, 10);\n return Number.isNaN(parsed) ? defaultValue : parsed;\n }\n return defaultValue;\n}\n\n/**\n * Simplified span structure for rendering span trees in performance issues.\n * This is a subset of the full span data focused on visualization needs.\n */\ninterface PerformanceSpan {\n span_id: string;\n op: string; // Operation type (e.g., \"db.query\", \"http.client\")\n description: string; // Human-readable description of what the span did\n duration: number; // Duration in milliseconds\n is_n1_query: boolean; // Whether this span is part of the N+1 pattern\n children: PerformanceSpan[];\n level: number; // Nesting level for tree rendering\n}\n\ninterface RawSpan {\n span_id?: string;\n id?: string;\n op?: string;\n description?: string;\n timestamp?: number;\n start_timestamp?: number;\n duration?: number;\n}\n\ninterface N1EvidenceData {\n parentSpan?: string;\n parentSpanIds?: string[];\n repeatingSpansCompact?: string[];\n repeatingSpans?: string[];\n numberRepeatingSpans?: string; // API returns string even though it's a number\n numPatternRepetitions?: number;\n offenderSpanIds?: string[];\n transactionName?: string;\n [key: string]: unknown;\n}\n\ninterface SlowDbEvidenceData {\n parentSpan?: string;\n [key: string]: unknown;\n}\n\nfunction normalizeSpanId(value: unknown): string | undefined {\n if (typeof value === \"string\" && value) {\n return value;\n }\n return undefined;\n}\n\nfunction getSpanIdentifier(span: RawSpan): string | undefined {\n if (span.span_id !== undefined) {\n return normalizeSpanId(span.span_id);\n }\n if (span.id !== undefined) {\n return normalizeSpanId(span.id);\n }\n return undefined;\n}\n\nfunction getSpanDurationMs(span: RawSpan): number {\n if (\n typeof span.timestamp === \"number\" &&\n typeof span.start_timestamp === \"number\"\n ) {\n const deltaSeconds = span.timestamp - span.start_timestamp;\n if (Number.isFinite(deltaSeconds) && deltaSeconds >= 0) {\n return deltaSeconds * 1000;\n }\n }\n\n // Trace APIs expose `duration` in milliseconds. Preserve fractional values.\n if (typeof span.duration === \"number\" && Number.isFinite(span.duration)) {\n return span.duration >= 0 ? span.duration : 0;\n }\n\n return 0;\n}\n\nfunction normalizeIdArray(values: unknown): string[] {\n if (!Array.isArray(values)) {\n return [];\n }\n\n return values\n .map((value) => normalizeSpanId(value))\n .filter((value): value is string => value !== undefined);\n}\n\nfunction isValidSpanArray(value: unknown): value is RawSpan[] {\n return Array.isArray(value);\n}\n\n/**\n * Get the repeating span descriptions from evidence data.\n * Prefers repeatingSpansCompact (more concise) over repeatingSpans (verbose).\n */\nfunction getRepeatingSpanLines(evidenceData: N1EvidenceData): string[] {\n // Try compact version first (preferred for display)\n if (\n Array.isArray(evidenceData.repeatingSpansCompact) &&\n evidenceData.repeatingSpansCompact.length > 0\n ) {\n return evidenceData.repeatingSpansCompact\n .map((s) => (typeof s === \"string\" ? s.trim() : \"\"))\n .filter((s): s is string => s.length > 0);\n }\n\n // Fall back to full version\n if (\n Array.isArray(evidenceData.repeatingSpans) &&\n evidenceData.repeatingSpans.length > 0\n ) {\n return evidenceData.repeatingSpans\n .map((s) => (typeof s === \"string\" ? s.trim() : \"\"))\n .filter((s): s is string => s.length > 0);\n }\n\n return [];\n}\n\nfunction isTraceSpan(node: unknown): node is TraceSpan {\n if (node === null || typeof node !== \"object\") {\n return false;\n }\n const candidate = node as { event_type?: unknown; event_id?: unknown };\n // Trace API returns spans with event_type: \"span\"\n return (\n candidate.event_type === \"span\" && typeof candidate.event_id === \"string\"\n );\n}\n\nfunction buildTraceSpanTree(\n trace: Trace,\n parentSpanIds: string[],\n offenderSpanIds: string[],\n maxSpans: number,\n): string[] {\n const offenderSet = new Set(offenderSpanIds);\n const spanMap = new Map<string, TraceSpan>();\n\n function indexSpan(span: TraceSpan): void {\n // Try to get span_id from additional_attributes, fall back to event_id\n const spanId =\n normalizeSpanId(span.additional_attributes?.span_id) || span.event_id;\n if (spanId && spanId.length > 0) {\n spanMap.set(spanId, span);\n }\n for (const child of span.children ?? []) {\n if (isTraceSpan(child)) {\n indexSpan(child);\n }\n }\n }\n\n for (const node of trace) {\n if (isTraceSpan(node)) {\n indexSpan(node);\n }\n }\n\n const roots: PerformanceSpan[] = [];\n const budget = { count: 0, limit: maxSpans };\n\n // First, try to find parent spans\n for (const parentId of parentSpanIds) {\n const span = spanMap.get(parentId);\n if (!span) {\n continue;\n }\n const perfSpan = convertTraceSpanToPerformanceSpan(\n span,\n offenderSet,\n budget,\n 0,\n );\n if (perfSpan) {\n roots.push(perfSpan);\n }\n if (budget.count >= budget.limit) {\n break;\n }\n }\n\n // If no parent spans found, try to find offender spans directly\n if (roots.length === 0 && offenderSpanIds.length > 0) {\n for (const offenderId of offenderSpanIds) {\n const span = spanMap.get(offenderId);\n if (!span) {\n continue;\n }\n const perfSpan = convertTraceSpanToPerformanceSpan(\n span,\n offenderSet,\n budget,\n 0,\n );\n if (perfSpan) {\n roots.push(perfSpan);\n }\n if (budget.count >= budget.limit) {\n break;\n }\n }\n }\n\n if (roots.length === 0) {\n return [];\n }\n\n return renderPerformanceSpanTree(roots);\n}\n\nfunction convertTraceSpanToPerformanceSpan(\n span: TraceSpan,\n offenderSet: Set<string>,\n budget: { count: number; limit: number },\n level: number,\n): PerformanceSpan | null {\n if (budget.count >= budget.limit) {\n return null;\n }\n\n budget.count += 1;\n\n // Get span ID from additional_attributes or fall back to event_id\n const spanId =\n normalizeSpanId(span.additional_attributes?.span_id) || span.event_id;\n\n const performanceSpan: PerformanceSpan = {\n span_id: spanId,\n op: span.op || \"unknown\",\n description: formatTraceSpanDescription(span),\n duration: getTraceSpanDurationMs(span),\n is_n1_query: offenderSet.has(spanId),\n children: [],\n level,\n };\n\n for (const child of span.children ?? []) {\n if (!isTraceSpan(child)) {\n continue;\n }\n if (budget.count >= budget.limit) {\n break;\n }\n const childSpan = convertTraceSpanToPerformanceSpan(\n child,\n offenderSet,\n budget,\n level + 1,\n );\n if (childSpan) {\n performanceSpan.children.push(childSpan);\n }\n if (budget.count >= budget.limit) {\n break;\n }\n }\n\n return performanceSpan;\n}\n\nfunction formatTraceSpanDescription(span: TraceSpan): string {\n if (span.name && span.name.trim().length > 0) {\n return span.name.trim();\n }\n if (span.description && span.description.trim().length > 0) {\n return span.description.trim();\n }\n if (span.op && span.op.trim().length > 0) {\n return span.op.trim();\n }\n return \"unnamed\";\n}\n\nfunction getTraceSpanDurationMs(span: TraceSpan): number {\n if (typeof span.duration === \"number\" && span.duration >= 0) {\n return span.duration;\n }\n if (\n typeof (span as { end_timestamp?: number }).end_timestamp === \"number\" &&\n typeof span.start_timestamp === \"number\"\n ) {\n const deltaSeconds =\n (span as { end_timestamp: number }).end_timestamp - span.start_timestamp;\n if (Number.isFinite(deltaSeconds) && deltaSeconds >= 0) {\n return deltaSeconds * 1000;\n }\n }\n return 0;\n}\n\nfunction buildOffenderSummaries(\n spans: RawSpan[],\n offenderSpanIds: string[],\n): string[] {\n if (offenderSpanIds.length === 0) {\n return [];\n }\n\n const spanMap = new Map<string, RawSpan>();\n for (const span of spans) {\n const identifier = getSpanIdentifier(span);\n if (identifier) {\n spanMap.set(identifier, span);\n }\n }\n\n const summaries: string[] = [];\n for (const offenderId of offenderSpanIds) {\n const span = spanMap.get(offenderId);\n if (span) {\n const description = span.description || span.op || `Span ${offenderId}`;\n const duration = getSpanDurationMs(span);\n const durationLabel = duration > 0 ? ` (${Math.round(duration)}ms)` : \"\";\n summaries.push(`${description}${durationLabel} [${offenderId}] [N+1]`);\n } else {\n summaries.push(`Span ${offenderId} [N+1]`);\n }\n }\n\n return summaries;\n}\n\n/**\n * Renders a hierarchical tree of performance spans using box-drawing characters.\n * Highlights N+1 queries with a special indicator.\n *\n * @param spans - Array of selected performance spans\n * @returns Array of formatted strings representing the tree\n */\nfunction renderPerformanceSpanTree(spans: PerformanceSpan[]): string[] {\n const lines: string[] = [];\n\n function renderSpan(span: PerformanceSpan, prefix = \"\", isLast = true): void {\n const connector = prefix === \"\" ? \"\" : isLast ? \"└─ \" : \"├─ \";\n\n const displayName = span.description?.trim() || span.op || \"unnamed\";\n const shortId = span.span_id ? span.span_id.substring(0, 8) : \"unknown\";\n const durationDisplay =\n span.duration > 0 ? `${Math.round(span.duration)}ms` : \"unknown\";\n\n const metadataParts: string[] = [shortId];\n if (span.op && span.op !== \"default\") {\n metadataParts.push(span.op);\n }\n metadataParts.push(durationDisplay);\n\n const line = `${prefix}${connector}${displayName} [${metadataParts.join(\n \" · \",\n )}]${span.is_n1_query ? \" [N+1]\" : \"\"}`;\n lines.push(line);\n\n // Render children\n for (let i = 0; i < span.children.length; i++) {\n const child = span.children[i];\n const isLastChild = i === span.children.length - 1;\n const childPrefix = prefix + (isLast ? \" \" : \"│ \");\n renderSpan(child, childPrefix, isLastChild);\n }\n }\n\n for (let i = 0; i < spans.length; i++) {\n const span = spans[i];\n const isLastRoot = i === spans.length - 1;\n renderSpan(span, \"\", isLastRoot);\n }\n\n return lines;\n}\n\nfunction selectN1QuerySpans(\n spans: RawSpan[],\n evidence: N1EvidenceData,\n maxSpans = MAX_SPANS_IN_TREE,\n): PerformanceSpan[] {\n const selected: PerformanceSpan[] = [];\n let spanCount = 0;\n\n const offenderSpanIds = normalizeIdArray(evidence.offenderSpanIds);\n const parentSpanIds = normalizeIdArray(evidence.parentSpanIds);\n\n let parentSpan: PerformanceSpan | null = null;\n if (parentSpanIds.length > 0) {\n const parent = spans.find((span) => {\n const identifier = getSpanIdentifier(span);\n return identifier ? parentSpanIds.includes(identifier) : false;\n });\n\n if (parent) {\n parentSpan = {\n span_id: getSpanIdentifier(parent) ?? \"unknown\",\n op: parent.op || \"unknown\",\n description:\n parent.description || evidence.parentSpan || \"Parent Operation\",\n duration: getSpanDurationMs(parent),\n is_n1_query: false,\n children: [],\n level: 0,\n };\n selected.push(parentSpan);\n spanCount += 1;\n }\n }\n\n if (offenderSpanIds.length > 0) {\n const offenderSet = new Set(offenderSpanIds);\n const offenderSpans = spans\n .filter((span) => {\n const identifier = getSpanIdentifier(span);\n return identifier ? offenderSet.has(identifier) : false;\n })\n .slice(0, Math.max(0, maxSpans - spanCount));\n\n for (const span of offenderSpans) {\n const perfSpan: PerformanceSpan = {\n span_id: getSpanIdentifier(span) ?? \"unknown\",\n op: span.op || \"db.query\",\n description: span.description || \"Database Query\",\n duration: getSpanDurationMs(span),\n is_n1_query: true,\n children: [],\n level: parentSpan ? 1 : 0,\n };\n\n if (parentSpan) {\n parentSpan.children.push(perfSpan);\n } else {\n selected.push(perfSpan);\n }\n\n spanCount += 1;\n if (spanCount >= maxSpans) {\n break;\n }\n }\n }\n\n return selected;\n}\n\n/**\n * Known Sentry performance issue types that we handle.\n *\n * NOTE: We intentionally only implement formatters for high-value performance issues\n * that provide complex insights. Not all issue types need custom formatting - many\n * can rely on the generic evidenceDisplay fields that Sentry provides.\n *\n * Currently fully implemented:\n * - N+1 query detection (DB and API)\n *\n * Partially implemented:\n * - Slow DB queries (shows parent span only)\n *\n * Not implemented (lower priority):\n * - Asset-related issues (render blocking, uncompressed, large payloads)\n * - File I/O issues\n * - Consecutive queries\n */\nconst KNOWN_PERFORMANCE_ISSUE_TYPES = {\n N_PLUS_ONE_DB_QUERIES: \"performance_n_plus_one_db_queries\",\n N_PLUS_ONE_API_CALLS: \"performance_n_plus_one_api_calls\",\n SLOW_DB_QUERY: \"performance_slow_db_query\",\n RENDER_BLOCKING_ASSET: \"performance_render_blocking_asset\",\n CONSECUTIVE_DB_QUERIES: \"performance_consecutive_db_queries\",\n FILE_IO_MAIN_THREAD: \"performance_file_io_main_thread\",\n M_N_PLUS_ONE_DB_QUERIES: \"performance_m_n_plus_one_db_queries\",\n UNCOMPRESSED_ASSET: \"performance_uncompressed_asset\",\n LARGE_HTTP_PAYLOAD: \"performance_large_http_payload\",\n} as const;\n\n/**\n * Map numeric occurrence types to issue types (from Sentry's codebase).\n *\n * Sentry uses numeric type IDs internally in the occurrence data structure,\n * but string issue types in the UI and other APIs. This mapping converts\n * between them.\n *\n * Source: sentry/static/app/types/group.tsx in Sentry's codebase\n * Range: 1xxx = transaction-based performance issues\n * 2xxx = profile-based performance issues\n */\nconst OCCURRENCE_TYPE_TO_ISSUE_TYPE: Record<number, string> = {\n 1001: KNOWN_PERFORMANCE_ISSUE_TYPES.SLOW_DB_QUERY,\n 1004: KNOWN_PERFORMANCE_ISSUE_TYPES.RENDER_BLOCKING_ASSET,\n 1006: KNOWN_PERFORMANCE_ISSUE_TYPES.N_PLUS_ONE_DB_QUERIES,\n 1906: KNOWN_PERFORMANCE_ISSUE_TYPES.N_PLUS_ONE_DB_QUERIES, // Alternative ID for N+1 DB\n 1007: KNOWN_PERFORMANCE_ISSUE_TYPES.CONSECUTIVE_DB_QUERIES,\n 1008: KNOWN_PERFORMANCE_ISSUE_TYPES.FILE_IO_MAIN_THREAD,\n 1009: \"performance_consecutive_http\",\n 1010: KNOWN_PERFORMANCE_ISSUE_TYPES.N_PLUS_ONE_API_CALLS,\n 1910: KNOWN_PERFORMANCE_ISSUE_TYPES.N_PLUS_ONE_API_CALLS, // Alternative ID for N+1 API\n 1012: KNOWN_PERFORMANCE_ISSUE_TYPES.UNCOMPRESSED_ASSET,\n 1013: \"performance_db_main_thread\",\n 1015: KNOWN_PERFORMANCE_ISSUE_TYPES.LARGE_HTTP_PAYLOAD,\n 1016: \"performance_http_overhead\",\n};\n\n// Type alias currently unused but kept for potential future type safety\n// type PerformanceIssueType = typeof KNOWN_PERFORMANCE_ISSUE_TYPES[keyof typeof KNOWN_PERFORMANCE_ISSUE_TYPES];\n\n/**\n * Formats N+1 query issue evidence data.\n *\n * N+1 queries are a common performance anti-pattern where code executes\n * 1 query to get a list of items, then N additional queries (one per item)\n * instead of using a single JOIN or batch query.\n *\n * Evidence fields we use:\n * - parentSpan: The operation that triggered the N+1 queries\n * - repeatingSpansCompact/repeatingSpans: The query pattern being repeated\n * - numberRepeatingSpans: How many times the query was executed\n * - offenderSpanIds: IDs of the actual span instances\n * - parentSpanIds: IDs of parent spans for tree visualization\n */\nfunction formatN1QueryEvidence(\n evidenceData: N1EvidenceData,\n spansData: unknown,\n performanceTrace?: Trace,\n): string {\n const parts: string[] = [];\n\n // Format parent span info if available\n if (evidenceData.parentSpan) {\n parts.push(\"**Parent Operation:**\");\n parts.push(`${evidenceData.parentSpan}`);\n parts.push(\"\");\n }\n\n // Format repeating spans (the N+1 queries)\n const repeatingLines = getRepeatingSpanLines(evidenceData);\n if (repeatingLines.length > 0) {\n parts.push(\"### Repeated Database Queries\");\n parts.push(\"\");\n\n const queryCount = evidenceData.numberRepeatingSpans\n ? safeParseInt(evidenceData.numberRepeatingSpans, 0)\n : evidenceData.numPatternRepetitions ||\n evidenceData.offenderSpanIds?.length ||\n 0;\n\n if (queryCount > 0) {\n parts.push(`**Query executed ${queryCount} times:**`);\n }\n\n // Show the query pattern - if single line, render as SQL block; if multiple, as list\n if (repeatingLines.length === 1) {\n parts.push(\"```sql\");\n parts.push(repeatingLines[0]);\n parts.push(\"```\");\n parts.push(\"\");\n } else {\n parts.push(\"**Repeated operations:**\");\n for (const line of repeatingLines) {\n parts.push(`- ${line}`);\n }\n parts.push(\"\");\n }\n }\n\n const parentSpanIds = normalizeIdArray(evidenceData.parentSpanIds);\n const offenderSpanIds = normalizeIdArray(evidenceData.offenderSpanIds);\n\n const traceLines = performanceTrace\n ? buildTraceSpanTree(\n performanceTrace,\n parentSpanIds,\n offenderSpanIds,\n MAX_SPANS_IN_TREE,\n )\n : [];\n\n if (traceLines.length > 0) {\n parts.push(`### Span Tree (Limited to ${MAX_SPANS_IN_TREE} spans)`);\n parts.push(\"\");\n parts.push(\"```\");\n parts.push(...traceLines);\n parts.push(\"```\");\n parts.push(\"\");\n } else {\n const spanTree = isValidSpanArray(spansData)\n ? selectN1QuerySpans(spansData, evidenceData, MAX_SPANS_IN_TREE)\n : [];\n\n if (spanTree.length > 0) {\n parts.push(`### Span Tree (Limited to ${MAX_SPANS_IN_TREE} spans)`);\n parts.push(\"\");\n parts.push(\"```\");\n parts.push(...renderPerformanceSpanTree(spanTree));\n parts.push(\"```\");\n parts.push(\"\");\n } else if (isValidSpanArray(spansData)) {\n // Only show offender summaries if we have spans data but couldn't build a tree\n const offenderSummaries = buildOffenderSummaries(\n spansData as RawSpan[],\n offenderSpanIds,\n );\n\n if (offenderSummaries.length > 0) {\n parts.push(\"### Offending Spans\");\n parts.push(\"\");\n for (const summary of offenderSummaries) {\n parts.push(`- ${summary}`);\n }\n }\n }\n }\n\n return parts.join(\"\\n\");\n}\n\n/**\n * Formats slow DB query issue evidence data.\n *\n * Currently only partially implemented - shows parent span information.\n * Full implementation would show query duration, explain plan, etc.\n *\n * This is lower priority as the generic evidenceDisplay fields usually\n * provide sufficient information for slow query issues.\n */\nfunction formatSlowDbQueryEvidence(\n evidenceData: SlowDbEvidenceData,\n spansData: unknown,\n): string {\n const parts: string[] = [];\n\n // Show parent span if available (generic field that applies to slow queries)\n if (evidenceData.parentSpan) {\n parts.push(\"**Parent Operation:**\");\n parts.push(`${evidenceData.parentSpan}`);\n parts.push(\"\");\n }\n\n // TODO: Implement slow query specific fields when we know the structure\n // Potential fields: query duration, database name, query plan\n console.warn(\n \"[formatSlowDbQueryEvidence] Evidence data rendering not yet fully implemented\",\n );\n\n return parts.join(\"\\n\");\n}\n\n/**\n * Formats performance issue details from transaction events based on the issue type.\n *\n * This is the main dispatcher for performance issue formatting. It:\n * 1. Detects the issue type from occurrence data (numeric or string)\n * 2. Calls the appropriate type-specific formatter if implemented\n * 3. Falls back to generic evidenceDisplay fields for unimplemented types\n * 4. Provides span analysis fallback for events without occurrence data\n *\n * The occurrence data structure comes from Sentry's performance issue detection\n * and contains evidence about what triggered the issue.\n *\n * @param event - The transaction event containing performance issue data\n * @param spansData - The spans data from the event entries\n * @returns Formatted markdown string with performance issue details\n */\nfunction formatPerformanceIssueOutput(\n event: Event,\n spansData: unknown,\n options?: {\n performanceTrace?: Trace;\n },\n): string {\n const parts: string[] = [];\n\n // Check if we have occurrence data\n const occurrence = (event as any).occurrence;\n if (!occurrence) {\n return \"\";\n }\n\n // Get issue type - occurrence.type is numeric, issueType may be a string\n let issueType: string | undefined;\n if (typeof occurrence.type === \"number\") {\n issueType = OCCURRENCE_TYPE_TO_ISSUE_TYPE[occurrence.type];\n } else {\n issueType = occurrence.issueType || occurrence.type;\n }\n\n const evidenceData = occurrence.evidenceData;\n\n // Process evidence data based on known performance issue types\n if (evidenceData) {\n switch (issueType) {\n case KNOWN_PERFORMANCE_ISSUE_TYPES.N_PLUS_ONE_DB_QUERIES:\n case KNOWN_PERFORMANCE_ISSUE_TYPES.N_PLUS_ONE_API_CALLS:\n case KNOWN_PERFORMANCE_ISSUE_TYPES.M_N_PLUS_ONE_DB_QUERIES: {\n const result = formatN1QueryEvidence(\n evidenceData,\n spansData,\n options?.performanceTrace,\n );\n if (result) parts.push(result);\n break;\n }\n\n case KNOWN_PERFORMANCE_ISSUE_TYPES.SLOW_DB_QUERY: {\n const result = formatSlowDbQueryEvidence(evidenceData, spansData);\n if (result) parts.push(result);\n break;\n }\n\n default:\n // We don't implement formatters for all performance issue types.\n // Many lower-priority issues (consecutive queries, asset issues, file I/O)\n // work fine with just the generic evidenceDisplay fields below.\n // Only high-value, complex issues like N+1 queries need custom formatting.\n if (issueType) {\n console.warn(\n `[formatPerformanceIssueOutput] No custom formatter for issue type: ${issueType}`,\n );\n }\n // Fall through to show generic evidence display below\n }\n }\n\n // Show transaction name if available for any performance issue (generic field)\n if (evidenceData?.transactionName) {\n parts.push(\"**Transaction:**\");\n parts.push(`${evidenceData.transactionName}`);\n parts.push(\"\");\n }\n\n // Always show evidence display if available (this is generic and doesn't require type knowledge)\n if (occurrence.evidenceDisplay?.length > 0) {\n for (const display of occurrence.evidenceDisplay) {\n if (display.important) {\n parts.push(`**${display.name}:**`);\n parts.push(`${display.value}`);\n parts.push(\"\");\n }\n }\n }\n\n return parts.length > 0 ? `${parts.join(\"\\n\")}\\n` : \"\";\n}\n\nfunction formatTags(tags: z.infer<typeof EventSchema>[\"tags\"]) {\n if (!tags || tags.length === 0) {\n return \"\";\n }\n return `### Tags\\n\\n${tags\n .map((tag) => `**${tag.key}**: ${tag.value}`)\n .join(\"\\n\")}\\n\\n`;\n}\n\nfunction formatContext(context: z.infer<typeof EventSchema>[\"context\"]) {\n if (!context || Object.keys(context).length === 0) {\n return \"\";\n }\n return `### Extra Data\\n\\nAdditional data attached to this event.\\n\\n${Object.entries(\n context,\n )\n .map(([key, value]) => {\n return `**${key}**: ${JSON.stringify(value, undefined, 2)}`;\n })\n .join(\"\\n\")}\\n\\n`;\n}\n\nfunction formatContexts(contexts: z.infer<typeof EventSchema>[\"contexts\"]) {\n if (!contexts || Object.keys(contexts).length === 0) {\n return \"\";\n }\n return `### Additional Context\\n\\nThese are additional context provided by the user when they're instrumenting their application.\\n\\n${Object.entries(\n contexts,\n )\n .map(\n ([name, data]) =>\n `**${name}**\\n${Object.entries(data)\n .filter(([key, _]) => key !== \"type\")\n .map(([key, value]) => {\n return `${key}: ${JSON.stringify(value, undefined, 2)}`;\n })\n .join(\"\\n\")}`,\n )\n .join(\"\\n\\n\")}\\n\\n`;\n}\n\n/**\n * Formats a brief Seer analysis summary for inclusion in issue details.\n * Shows current status and high-level insights, prompting to use analyze_issue_with_seer for full details.\n *\n * @param autofixState - The autofix state containing Seer analysis data\n * @param organizationSlug - The organization slug for the issue\n * @param issueId - The issue ID (shortId)\n * @returns Formatted markdown string with Seer summary, or empty string if no analysis exists\n */\nfunction formatSeerSummary(\n autofixState: AutofixRunState | undefined,\n organizationSlug: string,\n issueId: string,\n): string {\n if (!autofixState || !autofixState.autofix) {\n return \"\";\n }\n\n const { autofix } = autofixState;\n const parts: string[] = [];\n\n parts.push(\"## Seer Analysis\");\n parts.push(\"\");\n\n // Show status first\n const statusDisplay = getStatusDisplayName(autofix.status);\n if (!isTerminalStatus(autofix.status)) {\n parts.push(`**Status:** ${statusDisplay}`);\n parts.push(\"\");\n }\n\n // Show summary of what we have so far\n if (autofix.steps.length > 0) {\n const completedSteps = autofix.steps.filter(\n (step) => step.status === \"COMPLETED\",\n );\n\n // Find the solution step if available\n const solutionStep = completedSteps.find(\n (step) => step.type === \"solution\",\n );\n\n if (solutionStep) {\n // For solution steps, use the description directly\n const solutionDescription = solutionStep.description;\n if (\n solutionDescription &&\n typeof solutionDescription === \"string\" &&\n solutionDescription.trim()\n ) {\n parts.push(\"**Summary:**\");\n parts.push(solutionDescription.trim());\n } else {\n // Fallback to extracting from output if no description\n const solutionOutput = getOutputForAutofixStep(solutionStep);\n const lines = solutionOutput.split(\"\\n\");\n const firstParagraph = lines.find(\n (line) =>\n line.trim().length > 50 &&\n !line.startsWith(\"#\") &&\n !line.startsWith(\"*\"),\n );\n if (firstParagraph) {\n parts.push(\"**Summary:**\");\n parts.push(firstParagraph.trim());\n }\n }\n } else if (completedSteps.length > 0) {\n // Show what steps have been completed so far\n const rootCauseStep = completedSteps.find(\n (step) => step.type === \"root_cause_analysis\",\n );\n\n if (rootCauseStep) {\n const typedStep = rootCauseStep as z.infer<\n typeof AutofixRunStepRootCauseAnalysisSchema\n >;\n if (\n typedStep.causes &&\n typedStep.causes.length > 0 &&\n typedStep.causes[0].description\n ) {\n parts.push(\"**Root Cause Identified:**\");\n parts.push(typedStep.causes[0].description.trim());\n }\n } else {\n // Show generic progress\n parts.push(\n `**Progress:** ${completedSteps.length} of ${autofix.steps.length} steps completed`,\n );\n }\n }\n } else {\n // No steps yet - check for terminal states first\n if (isTerminalStatus(autofix.status)) {\n if (autofix.status === \"FAILED\" || autofix.status === \"ERROR\") {\n parts.push(\"**Status:** Analysis failed.\");\n } else if (autofix.status === \"CANCELLED\") {\n parts.push(\"**Status:** Analysis was cancelled.\");\n } else if (\n autofix.status === \"NEED_MORE_INFORMATION\" ||\n autofix.status === \"WAITING_FOR_USER_RESPONSE\"\n ) {\n parts.push(\n \"**Status:** Analysis paused - additional information needed.\",\n );\n }\n } else {\n parts.push(\"Analysis has started but no results yet.\");\n }\n }\n\n // Add specific messages for terminal states when steps exist\n if (autofix.steps.length > 0 && isTerminalStatus(autofix.status)) {\n if (autofix.status === \"FAILED\" || autofix.status === \"ERROR\") {\n parts.push(\"\");\n parts.push(\"**Status:** Analysis failed.\");\n } else if (autofix.status === \"CANCELLED\") {\n parts.push(\"\");\n parts.push(\"**Status:** Analysis was cancelled.\");\n } else if (\n autofix.status === \"NEED_MORE_INFORMATION\" ||\n autofix.status === \"WAITING_FOR_USER_RESPONSE\"\n ) {\n parts.push(\"\");\n parts.push(\n \"**Status:** Analysis paused - additional information needed.\",\n );\n }\n }\n\n // Always suggest using analyze_issue_with_seer for more details\n parts.push(\"\");\n parts.push(\n `**Note:** For detailed root cause analysis and solutions, call \\`analyze_issue_with_seer(organizationSlug='${organizationSlug}', issueId='${issueId}')\\``,\n );\n\n return `${parts.join(\"\\n\")}\\n\\n`;\n}\n\n/**\n * Formats a Sentry issue with its latest event into comprehensive markdown output.\n * Includes issue metadata, event details, and usage instructions.\n *\n * @param params - Object containing organization slug, issue, event, and API service\n * @returns Formatted markdown string with complete issue information\n */\nexport function formatIssueOutput({\n organizationSlug,\n issue,\n event,\n apiService,\n autofixState,\n performanceTrace,\n}: {\n organizationSlug: string;\n issue: Issue;\n event: Event;\n apiService: SentryApiService;\n autofixState?: AutofixRunState;\n performanceTrace?: Trace;\n}) {\n let output = `# Issue ${issue.shortId} in **${organizationSlug}**\\n\\n`;\n\n // Check if this is a performance issue based on issueCategory or issueType\n // Performance issues can have various categories like 'db_query' but issueType starts with 'performance_'\n const isPerformanceIssue =\n issue.issueType?.startsWith(\"performance_\") ||\n issue.issueCategory === \"performance\";\n\n if (isPerformanceIssue && issue.metadata) {\n // For performance issues, use metadata for better context\n const issueTitle = issue.metadata.title || issue.title;\n output += `**Description**: ${issueTitle}\\n`;\n\n if (issue.metadata.location) {\n output += `**Location**: ${issue.metadata.location}\\n`;\n }\n if (issue.metadata.value) {\n output += `**Query Pattern**: \\`${issue.metadata.value}\\`\\n`;\n }\n } else {\n // For regular errors and other issues\n output += `**Description**: ${issue.title}\\n`;\n output += `**Culprit**: ${issue.culprit}\\n`;\n }\n\n output += `**First Seen**: ${new Date(issue.firstSeen).toISOString()}\\n`;\n output += `**Last Seen**: ${new Date(issue.lastSeen).toISOString()}\\n`;\n output += `**Occurrences**: ${issue.count}\\n`;\n output += `**Users Impacted**: ${issue.userCount}\\n`;\n output += `**Status**: ${issue.status}\\n`;\n output += `**Platform**: ${issue.platform}\\n`;\n output += `**Project**: ${issue.project.name}\\n`;\n output += `**URL**: ${apiService.getIssueUrl(organizationSlug, issue.shortId)}\\n`;\n output += \"\\n\";\n output += \"## Event Details\\n\\n\";\n output += `**Event ID**: ${event.id}\\n`;\n // \"default\" type represents error events without exception data\n if (event.type === \"error\" || event.type === \"default\") {\n output += `**Occurred At**: ${new Date((event as z.infer<typeof ErrorEventSchema>).dateCreated).toISOString()}\\n`;\n }\n if (event.message) {\n output += `**Message**:\\n${event.message}\\n`;\n }\n output += \"\\n\";\n output += formatEventOutput(event, { performanceTrace });\n\n // Add Seer context if available\n if (autofixState) {\n output += formatSeerSummary(autofixState, organizationSlug, issue.shortId);\n }\n\n output += \"# Using this information\\n\\n\";\n output += `- You can reference the IssueID in commit messages (e.g. \\`Fixes ${issue.shortId}\\`) to automatically close the issue when the commit is merged.\\n`;\n output +=\n \"- The stacktrace includes both first-party application code as well as third-party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Interface>","platform?: string | null","frameIndex?: number","event: Event","options?: {\n performanceTrace?: Trace;\n }","parts: string[]","data: z.infer<typeof ErrorEntrySchema>","platform: string | null","index: number","totalExceptions: number","data: z.infer<typeof RequestEntrySchema>","data: z.infer<typeof MessageEntrySchema>","data: z.infer<typeof ThreadsEntrySchema>","lines: string[]","value: unknown","vars: Record<string, unknown>","frames: z.infer<typeof FrameInterface>[]","defaultValue: number","span: RawSpan","values: unknown","evidenceData: N1EvidenceData","node: unknown","trace: Trace","parentSpanIds: string[]","offenderSpanIds: string[]","maxSpans: number","span: TraceSpan","roots: PerformanceSpan[]","offenderSet: Set<string>","budget: { count: number; limit: number }","level: number","performanceSpan: PerformanceSpan","spans: RawSpan[]","summaries: string[]","spans: PerformanceSpan[]","span: PerformanceSpan","metadataParts: string[]","evidence: N1EvidenceData","selected: PerformanceSpan[]","parentSpan: PerformanceSpan | null","perfSpan: PerformanceSpan","OCCURRENCE_TYPE_TO_ISSUE_TYPE: Record<number, string>","spansData: unknown","performanceTrace?: Trace","evidenceData: SlowDbEvidenceData","issueType: string | undefined","tags: z.infer<typeof EventSchema>[\"tags\"]","context: z.infer<typeof EventSchema>[\"context\"]","contexts: z.infer<typeof EventSchema>[\"contexts\"]","autofixState: AutofixRunState | undefined","organizationSlug: string","issueId: string"],"sources":["../src/internal/formatting.ts"],"sourcesContent":["/**\n * LLM response formatting utilities for Sentry data.\n *\n * Converts Sentry API responses into structured markdown format optimized\n * for LLM consumption. Handles stacktraces, event details, issue summaries,\n * and contextual information with consistent formatting patterns.\n */\nimport type { z } from \"zod\";\nimport type {\n Event,\n Issue,\n AutofixRunState,\n Trace,\n TraceSpan,\n} from \"../api-client/types\";\nimport type {\n ErrorEntrySchema,\n ErrorEventSchema,\n EventSchema,\n FrameInterface,\n RequestEntrySchema,\n MessageEntrySchema,\n ThreadsEntrySchema,\n SentryApiService,\n AutofixRunStepRootCauseAnalysisSchema,\n} from \"../api-client\";\nimport {\n getOutputForAutofixStep,\n isTerminalStatus,\n getStatusDisplayName,\n} from \"./tool-helpers/seer\";\n\n// Language detection mappings\nconst LANGUAGE_EXTENSIONS: Record<string, string> = {\n \".java\": \"java\",\n \".py\": \"python\",\n \".js\": \"javascript\",\n \".jsx\": \"javascript\",\n \".ts\": \"javascript\",\n \".tsx\": \"javascript\",\n \".rb\": \"ruby\",\n \".php\": \"php\",\n};\n\nconst LANGUAGE_MODULE_PATTERNS: Array<[RegExp, string]> = [\n [/^(java\\.|com\\.|org\\.)/, \"java\"],\n];\n\n/**\n * Detects the programming language of a stack frame based on the file extension.\n * Falls back to the platform parameter if no filename is available or extension is unrecognized.\n *\n * @param frame - The stack frame containing file and location information\n * @param platform - Optional platform hint to use as fallback\n * @returns The detected language or platform fallback or \"unknown\"\n */\nfunction detectLanguage(\n frame: z.infer<typeof FrameInterface>,\n platform?: string | null,\n): string {\n // Check filename extensions\n if (frame.filename) {\n const ext = frame.filename.toLowerCase().match(/\\.[^.]+$/)?.[0];\n if (ext && LANGUAGE_EXTENSIONS[ext]) {\n return LANGUAGE_EXTENSIONS[ext];\n }\n }\n\n // Check module patterns\n if (frame.module) {\n for (const [pattern, language] of LANGUAGE_MODULE_PATTERNS) {\n if (pattern.test(frame.module)) {\n return language;\n }\n }\n }\n\n // Fallback to platform or unknown\n return platform || \"unknown\";\n}\n\n/**\n * Formats a stack frame into a language-specific string representation.\n * Different languages have different conventions for displaying stack traces.\n *\n * @param frame - The stack frame to format\n * @param frameIndex - Optional frame index for languages that display frame numbers\n * @param platform - Optional platform hint for language detection fallback\n * @returns Formatted stack frame string\n */\nexport function formatFrameHeader(\n frame: z.infer<typeof FrameInterface>,\n frameIndex?: number,\n platform?: string | null,\n) {\n const language = detectLanguage(frame, platform);\n\n switch (language) {\n case \"java\": {\n // at com.example.ClassName.methodName(FileName.java:123)\n const className = frame.module || \"UnknownClass\";\n const method = frame.function || \"<unknown>\";\n const source = frame.filename || \"Unknown Source\";\n const location = frame.lineNo ? `:${frame.lineNo}` : \"\";\n return `at ${className}.${method}(${source}${location})`;\n }\n\n case \"python\": {\n // File \"/path/to/file.py\", line 42, in function_name\n const file =\n frame.filename || frame.absPath || frame.module || \"<unknown>\";\n const func = frame.function || \"<module>\";\n const line = frame.lineNo ? `, line ${frame.lineNo}` : \"\";\n return ` File \"${file}\"${line}, in ${func}`;\n }\n\n case \"javascript\": {\n // Original compact format: filename:line:col (function)\n // This preserves backward compatibility\n return `${[frame.filename, frame.lineNo, frame.colNo]\n .filter((i) => !!i)\n .join(\":\")}${frame.function ? ` (${frame.function})` : \"\"}`;\n }\n\n case \"ruby\": {\n // from /path/to/file.rb:42:in `method_name'\n const file = frame.filename || frame.module || \"<unknown>\";\n const func = frame.function ? ` \\`${frame.function}\\`` : \"\";\n const line = frame.lineNo ? `:${frame.lineNo}:in` : \"\";\n return ` from ${file}${line}${func}`;\n }\n\n case \"php\": {\n // #0 /path/to/file.php(42): functionName()\n const file = frame.filename || \"<unknown>\";\n const line = frame.lineNo ? `(${frame.lineNo})` : \"\";\n const func = frame.function || \"<unknown>\";\n const prefix = frameIndex !== undefined ? `#${frameIndex} ` : \"\";\n return `${prefix}${file}${line}: ${func}()`;\n }\n\n default: {\n // Generic format for unknown languages\n const func = frame.function || \"<unknown>\";\n const location = frame.filename || frame.module || \"<unknown>\";\n const line = frame.lineNo ? `:${frame.lineNo}` : \"\";\n const col = frame.colNo != null ? `:${frame.colNo}` : \"\";\n return ` at ${func} (${location}${line}${col})`;\n }\n }\n}\n\n/**\n * Formats a Sentry event into a structured markdown output.\n * Includes error messages, stack traces, request info, and contextual data.\n *\n * @param event - The Sentry event to format\n * @param options - Additional formatting context\n * @returns Formatted markdown string\n */\nexport function formatEventOutput(\n event: Event,\n options?: {\n performanceTrace?: Trace;\n },\n) {\n let output = \"\";\n\n // Look for the primary error information\n const messageEntry = event.entries.find((e) => e.type === \"message\");\n const exceptionEntry = event.entries.find((e) => e.type === \"exception\");\n const threadsEntry = event.entries.find((e) => e.type === \"threads\");\n const requestEntry = event.entries.find((e) => e.type === \"request\");\n const spansEntry = event.entries.find((e) => e.type === \"spans\");\n\n // Error message (if present)\n if (messageEntry) {\n output += formatMessageInterfaceOutput(\n event,\n messageEntry.data as z.infer<typeof MessageEntrySchema>,\n );\n }\n\n // Stack trace (from exception or threads)\n if (exceptionEntry) {\n output += formatExceptionInterfaceOutput(\n event,\n exceptionEntry.data as z.infer<typeof ErrorEntrySchema>,\n );\n } else if (threadsEntry) {\n output += formatThreadsInterfaceOutput(\n event,\n threadsEntry.data as z.infer<typeof ThreadsEntrySchema>,\n );\n }\n\n // Request info (if HTTP error)\n if (requestEntry) {\n output += formatRequestInterfaceOutput(\n event,\n requestEntry.data as z.infer<typeof RequestEntrySchema>,\n );\n }\n\n // Performance issue details (N+1 queries, etc.)\n // Pass spans data for additional context even if we have evidence\n if (event.type === \"transaction\") {\n output += formatPerformanceIssueOutput(event, spansEntry?.data, options);\n }\n\n output += formatTags(event.tags);\n output += formatContext(event.context);\n output += formatContexts(event.contexts);\n return output;\n}\n\n/**\n * Extracts the context line matching the frame's line number for inline display.\n * This is used in the full stacktrace view to show the actual line of code\n * that caused the error inline with the stack frame.\n *\n * @param frame - The stack frame containing context lines\n * @returns The line of code at the frame's line number, or empty string if not available\n */\nfunction renderInlineContext(frame: z.infer<typeof FrameInterface>): string {\n if (!frame.context?.length || !frame.lineNo) {\n return \"\";\n }\n\n const contextLine = frame.context.find(([lineNo]) => lineNo === frame.lineNo);\n return contextLine ? `\\n${contextLine[1]}` : \"\";\n}\n\n/**\n * Renders an enhanced view of a stack frame with context lines and variables.\n * Used for the \"Most Relevant Frame\" section to provide detailed information\n * about the most relevant application frame where the error occurred.\n *\n * @param frame - The stack frame to render with enhanced information\n * @param event - The Sentry event containing platform information for language detection\n * @returns Formatted string with frame header, context lines, and variables table\n */\nfunction renderEnhancedFrame(\n frame: z.infer<typeof FrameInterface>,\n event: Event,\n): string {\n const parts: string[] = [];\n\n parts.push(\"**Most Relevant Frame:**\");\n parts.push(\"─────────────────────\");\n parts.push(formatFrameHeader(frame, undefined, event.platform));\n\n // Add context lines if available\n if (frame.context?.length) {\n const contextLines = renderContextLines(frame);\n if (contextLines) {\n parts.push(\"\");\n parts.push(contextLines);\n }\n }\n\n // Add variables table if available\n if (frame.vars && Object.keys(frame.vars).length > 0) {\n parts.push(\"\");\n parts.push(renderVariablesTable(frame.vars));\n }\n\n return parts.join(\"\\n\");\n}\n\nfunction formatExceptionInterfaceOutput(\n event: Event,\n data: z.infer<typeof ErrorEntrySchema>,\n) {\n const parts: string[] = [];\n\n // Handle both single exception (value) and chained exceptions (values)\n const exceptions = data.values || (data.value ? [data.value] : []);\n\n if (exceptions.length === 0) {\n return \"\";\n }\n\n // For chained exceptions, they are typically ordered from innermost to outermost\n // We'll render them in reverse order (outermost first) to match how they occurred\n const isChained = exceptions.length > 1;\n\n // Create a copy before reversing to avoid mutating the original array\n [...exceptions].reverse().forEach((exception, index) => {\n if (!exception) return;\n\n // Add language-specific chain indicator for multiple exceptions\n if (isChained && index > 0) {\n parts.push(\"\");\n parts.push(\n getExceptionChainMessage(\n event.platform || null,\n index,\n exceptions.length,\n ),\n );\n parts.push(\"\");\n }\n\n // Use the actual exception type and value as the heading\n const exceptionTitle = `${exception.type}${exception.value ? `: ${exception.value}` : \"\"}`;\n\n parts.push(index === 0 ? \"### Error\" : `### ${exceptionTitle}`);\n parts.push(\"\");\n\n // Add the error details in a code block for the first exception\n // to maintain backward compatibility\n if (index === 0) {\n parts.push(\"```\");\n parts.push(exceptionTitle);\n parts.push(\"```\");\n parts.push(\"\");\n }\n\n if (!exception.stacktrace || !exception.stacktrace.frames) {\n parts.push(\"**Stacktrace:**\");\n parts.push(\"```\");\n parts.push(\"No stacktrace available\");\n parts.push(\"```\");\n return;\n }\n\n const frames = exception.stacktrace.frames;\n\n // Only show enhanced frame for the first (outermost) exception to avoid overwhelming output\n if (index === 0) {\n const firstInAppFrame = findFirstInAppFrame(frames);\n if (\n firstInAppFrame &&\n (firstInAppFrame.context?.length || firstInAppFrame.vars)\n ) {\n parts.push(renderEnhancedFrame(firstInAppFrame, event));\n parts.push(\"\");\n parts.push(\"**Full Stacktrace:**\");\n parts.push(\"────────────────\");\n } else {\n parts.push(\"**Stacktrace:**\");\n }\n } else {\n parts.push(\"**Stacktrace:**\");\n }\n\n parts.push(\"```\");\n parts.push(\n frames\n .map((frame) => {\n const header = formatFrameHeader(frame, undefined, event.platform);\n const context = renderInlineContext(frame);\n return `${header}${context}`;\n })\n .join(\"\\n\"),\n );\n parts.push(\"```\");\n });\n\n parts.push(\"\");\n parts.push(\"\");\n\n return parts.join(\"\\n\");\n}\n\n/**\n * Get the appropriate exception chain message based on the platform\n */\nfunction getExceptionChainMessage(\n platform: string | null,\n index: number,\n totalExceptions: number,\n): string {\n // Default message for unknown platforms\n const defaultMessage =\n \"**During handling of the above exception, another exception occurred:**\";\n\n if (!platform) {\n return defaultMessage;\n }\n\n switch (platform.toLowerCase()) {\n case \"python\":\n // Python has two distinct messages, but without additional metadata\n // we default to the implicit chaining message\n return \"**During handling of the above exception, another exception occurred:**\";\n\n case \"java\":\n return \"**Caused by:**\";\n\n case \"csharp\":\n case \"dotnet\":\n return \"**---> Inner Exception:**\";\n\n case \"ruby\":\n return \"**Caused by:**\";\n\n case \"go\":\n return \"**Wrapped error:**\";\n\n case \"rust\":\n return `**Caused by (${index}):**`;\n\n default:\n return defaultMessage;\n }\n}\n\nfunction formatRequestInterfaceOutput(\n event: Event,\n data: z.infer<typeof RequestEntrySchema>,\n) {\n if (!data.method || !data.url) {\n return \"\";\n }\n return `### HTTP Request\\n\\n**Method:** ${data.method}\\n**URL:** ${data.url}\\n\\n`;\n}\n\nfunction formatMessageInterfaceOutput(\n event: Event,\n data: z.infer<typeof MessageEntrySchema>,\n) {\n if (!data.formatted && !data.message) {\n return \"\";\n }\n const message = data.formatted || data.message || \"\";\n return `### Error\\n\\n${\"```\"}\\n${message}\\n${\"```\"}\\n\\n`;\n}\n\nfunction formatThreadsInterfaceOutput(\n event: Event,\n data: z.infer<typeof ThreadsEntrySchema>,\n) {\n if (!data.values || data.values.length === 0) {\n return \"\";\n }\n\n // Find the crashed thread only\n const crashedThread = data.values.find((t) => t.crashed);\n\n if (!crashedThread?.stacktrace?.frames) {\n return \"\";\n }\n\n const parts: string[] = [];\n\n // Include thread name if available\n if (crashedThread.name) {\n parts.push(`**Thread** (${crashedThread.name})`);\n parts.push(\"\");\n }\n\n const frames = crashedThread.stacktrace.frames;\n\n // Find and format the first in-app frame with enhanced view\n const firstInAppFrame = findFirstInAppFrame(frames);\n if (\n firstInAppFrame &&\n (firstInAppFrame.context?.length || firstInAppFrame.vars)\n ) {\n parts.push(renderEnhancedFrame(firstInAppFrame, event));\n parts.push(\"\");\n parts.push(\"**Full Stacktrace:**\");\n parts.push(\"────────────────\");\n } else {\n parts.push(\"**Stacktrace:**\");\n }\n\n parts.push(\"```\");\n parts.push(\n frames\n .map((frame) => {\n const header = formatFrameHeader(frame, undefined, event.platform);\n const context = renderInlineContext(frame);\n return `${header}${context}`;\n })\n .join(\"\\n\"),\n );\n parts.push(\"```\");\n parts.push(\"\");\n\n return parts.join(\"\\n\");\n}\n\n/**\n * Renders surrounding source code context for a stack frame.\n * Shows a window of code lines around the error line with visual indicators.\n *\n * @param frame - The stack frame containing context lines\n * @param contextSize - Number of lines to show before and after the error line (default: 3)\n * @returns Formatted context lines with line numbers and arrow indicator for the error line\n */\nfunction renderContextLines(\n frame: z.infer<typeof FrameInterface>,\n contextSize = 3,\n): string {\n if (!frame.context || frame.context.length === 0 || !frame.lineNo) {\n return \"\";\n }\n\n const lines: string[] = [];\n const errorLine = frame.lineNo;\n const maxLineNoWidth = Math.max(\n ...frame.context.map(([lineNo]) => lineNo.toString().length),\n );\n\n for (const [lineNo, code] of frame.context) {\n const isErrorLine = lineNo === errorLine;\n const lineNoStr = lineNo.toString().padStart(maxLineNoWidth, \" \");\n\n if (Math.abs(lineNo - errorLine) <= contextSize) {\n if (isErrorLine) {\n lines.push(` → ${lineNoStr} │ ${code}`);\n } else {\n lines.push(` ${lineNoStr} │ ${code}`);\n }\n }\n }\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Formats a variable value for display in the variables table.\n * Handles different types appropriately and safely, converting complex objects\n * to readable representations and handling edge cases like circular references.\n *\n * @param value - The variable value to format (can be any type)\n * @param maxLength - Maximum length for stringified objects/arrays (default: 80)\n * @returns Human-readable string representation of the value\n */\nfunction formatVariableValue(value: unknown, maxLength = 80): string {\n try {\n if (typeof value === \"string\") {\n return `\"${value}\"`;\n }\n if (value === null) {\n return \"null\";\n }\n if (value === undefined) {\n return \"undefined\";\n }\n if (typeof value === \"object\") {\n const stringified = JSON.stringify(value);\n if (stringified.length > maxLength) {\n // Leave room for \", ...]\" or \", ...}\"\n const truncateAt = maxLength - 6;\n let truncated = stringified.substring(0, truncateAt);\n\n // Find the last complete element by looking for the last comma\n const lastComma = truncated.lastIndexOf(\",\");\n if (lastComma > 0) {\n truncated = truncated.substring(0, lastComma);\n }\n\n // Add the appropriate ending\n if (Array.isArray(value)) {\n return `${truncated}, ...]`;\n }\n return `${truncated}, ...}`;\n }\n return stringified;\n }\n return String(value);\n } catch {\n // Handle circular references or other stringify errors\n return `<${typeof value}>`;\n }\n}\n\n/**\n * Renders a table of local variables in a tree-like format.\n * Uses box-drawing characters to create a visual hierarchy of variables\n * and their values at the point where the error occurred.\n *\n * @param vars - Object containing variable names as keys and their values\n * @returns Formatted variables table with tree-style prefix characters\n */\nfunction renderVariablesTable(vars: Record<string, unknown>): string {\n const entries = Object.entries(vars);\n if (entries.length === 0) {\n return \"\";\n }\n\n const lines: string[] = [\"Local Variables:\"];\n const lastIndex = entries.length - 1;\n\n entries.forEach(([key, value], index) => {\n const prefix = index === lastIndex ? \"└─\" : \"├─\";\n const valueStr = formatVariableValue(value);\n lines.push(`${prefix} ${key}: ${valueStr}`);\n });\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Finds the first application frame (in_app) in a stack trace.\n * Searches from the bottom of the stack (oldest frame) to find the first\n * frame that belongs to the user's application code rather than libraries.\n *\n * @param frames - Array of stack frames, typically in reverse chronological order\n * @returns The first in-app frame found, or undefined if none exist\n */\nfunction findFirstInAppFrame(\n frames: z.infer<typeof FrameInterface>[],\n): z.infer<typeof FrameInterface> | undefined {\n // Frames are usually in reverse order (most recent first)\n // We want the first in-app frame from the bottom\n for (let i = frames.length - 1; i >= 0; i--) {\n if (frames[i].inApp === true) {\n return frames[i];\n }\n }\n return undefined;\n}\n\n/**\n * Constants for performance issue formatting\n */\nconst MAX_SPANS_IN_TREE = 10;\n\n/**\n * Safely parse a number from a string, returning a default if invalid\n */\nfunction safeParseInt(value: unknown, defaultValue: number): number {\n if (typeof value === \"number\") return value;\n if (typeof value === \"string\") {\n const parsed = Number.parseInt(value, 10);\n return Number.isNaN(parsed) ? defaultValue : parsed;\n }\n return defaultValue;\n}\n\n/**\n * Simplified span structure for rendering span trees in performance issues.\n * This is a subset of the full span data focused on visualization needs.\n */\ninterface PerformanceSpan {\n span_id: string;\n op: string; // Operation type (e.g., \"db.query\", \"http.client\")\n description: string; // Human-readable description of what the span did\n duration: number; // Duration in milliseconds\n is_n1_query: boolean; // Whether this span is part of the N+1 pattern\n children: PerformanceSpan[];\n level: number; // Nesting level for tree rendering\n}\n\ninterface RawSpan {\n span_id?: string;\n id?: string;\n op?: string;\n description?: string;\n timestamp?: number;\n start_timestamp?: number;\n duration?: number;\n}\n\ninterface N1EvidenceData {\n parentSpan?: string;\n parentSpanIds?: string[];\n repeatingSpansCompact?: string[];\n repeatingSpans?: string[];\n numberRepeatingSpans?: string; // API returns string even though it's a number\n numPatternRepetitions?: number;\n offenderSpanIds?: string[];\n transactionName?: string;\n [key: string]: unknown;\n}\n\ninterface SlowDbEvidenceData {\n parentSpan?: string;\n [key: string]: unknown;\n}\n\nfunction normalizeSpanId(value: unknown): string | undefined {\n if (typeof value === \"string\" && value) {\n return value;\n }\n return undefined;\n}\n\nfunction getSpanIdentifier(span: RawSpan): string | undefined {\n if (span.span_id !== undefined) {\n return normalizeSpanId(span.span_id);\n }\n if (span.id !== undefined) {\n return normalizeSpanId(span.id);\n }\n return undefined;\n}\n\nfunction getSpanDurationMs(span: RawSpan): number {\n if (\n typeof span.timestamp === \"number\" &&\n typeof span.start_timestamp === \"number\"\n ) {\n const deltaSeconds = span.timestamp - span.start_timestamp;\n if (Number.isFinite(deltaSeconds) && deltaSeconds >= 0) {\n return deltaSeconds * 1000;\n }\n }\n\n // Trace APIs expose `duration` in milliseconds. Preserve fractional values.\n if (typeof span.duration === \"number\" && Number.isFinite(span.duration)) {\n return span.duration >= 0 ? span.duration : 0;\n }\n\n return 0;\n}\n\nfunction normalizeIdArray(values: unknown): string[] {\n if (!Array.isArray(values)) {\n return [];\n }\n\n return values\n .map((value) => normalizeSpanId(value))\n .filter((value): value is string => value !== undefined);\n}\n\nfunction isValidSpanArray(value: unknown): value is RawSpan[] {\n return Array.isArray(value);\n}\n\n/**\n * Get the repeating span descriptions from evidence data.\n * Prefers repeatingSpansCompact (more concise) over repeatingSpans (verbose).\n */\nfunction getRepeatingSpanLines(evidenceData: N1EvidenceData): string[] {\n // Try compact version first (preferred for display)\n if (\n Array.isArray(evidenceData.repeatingSpansCompact) &&\n evidenceData.repeatingSpansCompact.length > 0\n ) {\n return evidenceData.repeatingSpansCompact\n .map((s) => (typeof s === \"string\" ? s.trim() : \"\"))\n .filter((s): s is string => s.length > 0);\n }\n\n // Fall back to full version\n if (\n Array.isArray(evidenceData.repeatingSpans) &&\n evidenceData.repeatingSpans.length > 0\n ) {\n return evidenceData.repeatingSpans\n .map((s) => (typeof s === \"string\" ? s.trim() : \"\"))\n .filter((s): s is string => s.length > 0);\n }\n\n return [];\n}\n\nfunction isTraceSpan(node: unknown): node is TraceSpan {\n if (node === null || typeof node !== \"object\") {\n return false;\n }\n const candidate = node as { event_type?: unknown; event_id?: unknown };\n // Trace API returns spans with event_type: \"span\"\n return (\n candidate.event_type === \"span\" && typeof candidate.event_id === \"string\"\n );\n}\n\nfunction buildTraceSpanTree(\n trace: Trace,\n parentSpanIds: string[],\n offenderSpanIds: string[],\n maxSpans: number,\n): string[] {\n const offenderSet = new Set(offenderSpanIds);\n const spanMap = new Map<string, TraceSpan>();\n\n function indexSpan(span: TraceSpan): void {\n // Try to get span_id from additional_attributes, fall back to event_id\n const spanId =\n normalizeSpanId(span.additional_attributes?.span_id) || span.event_id;\n if (spanId && spanId.length > 0) {\n spanMap.set(spanId, span);\n }\n for (const child of span.children ?? []) {\n if (isTraceSpan(child)) {\n indexSpan(child);\n }\n }\n }\n\n for (const node of trace) {\n if (isTraceSpan(node)) {\n indexSpan(node);\n }\n }\n\n const roots: PerformanceSpan[] = [];\n const budget = { count: 0, limit: maxSpans };\n\n // First, try to find parent spans\n for (const parentId of parentSpanIds) {\n const span = spanMap.get(parentId);\n if (!span) {\n continue;\n }\n const perfSpan = convertTraceSpanToPerformanceSpan(\n span,\n offenderSet,\n budget,\n 0,\n );\n if (perfSpan) {\n roots.push(perfSpan);\n }\n if (budget.count >= budget.limit) {\n break;\n }\n }\n\n // If no parent spans found, try to find offender spans directly\n if (roots.length === 0 && offenderSpanIds.length > 0) {\n for (const offenderId of offenderSpanIds) {\n const span = spanMap.get(offenderId);\n if (!span) {\n continue;\n }\n const perfSpan = convertTraceSpanToPerformanceSpan(\n span,\n offenderSet,\n budget,\n 0,\n );\n if (perfSpan) {\n roots.push(perfSpan);\n }\n if (budget.count >= budget.limit) {\n break;\n }\n }\n }\n\n if (roots.length === 0) {\n return [];\n }\n\n return renderPerformanceSpanTree(roots);\n}\n\nfunction convertTraceSpanToPerformanceSpan(\n span: TraceSpan,\n offenderSet: Set<string>,\n budget: { count: number; limit: number },\n level: number,\n): PerformanceSpan | null {\n if (budget.count >= budget.limit) {\n return null;\n }\n\n budget.count += 1;\n\n // Get span ID from additional_attributes or fall back to event_id\n const spanId =\n normalizeSpanId(span.additional_attributes?.span_id) || span.event_id;\n\n const performanceSpan: PerformanceSpan = {\n span_id: spanId,\n op: span.op || \"unknown\",\n description: formatTraceSpanDescription(span),\n duration: getTraceSpanDurationMs(span),\n is_n1_query: offenderSet.has(spanId),\n children: [],\n level,\n };\n\n for (const child of span.children ?? []) {\n if (!isTraceSpan(child)) {\n continue;\n }\n if (budget.count >= budget.limit) {\n break;\n }\n const childSpan = convertTraceSpanToPerformanceSpan(\n child,\n offenderSet,\n budget,\n level + 1,\n );\n if (childSpan) {\n performanceSpan.children.push(childSpan);\n }\n if (budget.count >= budget.limit) {\n break;\n }\n }\n\n return performanceSpan;\n}\n\nfunction formatTraceSpanDescription(span: TraceSpan): string {\n if (span.name && span.name.trim().length > 0) {\n return span.name.trim();\n }\n if (span.description && span.description.trim().length > 0) {\n return span.description.trim();\n }\n if (span.op && span.op.trim().length > 0) {\n return span.op.trim();\n }\n return \"unnamed\";\n}\n\nfunction getTraceSpanDurationMs(span: TraceSpan): number {\n if (typeof span.duration === \"number\" && span.duration >= 0) {\n return span.duration;\n }\n if (\n typeof (span as { end_timestamp?: number }).end_timestamp === \"number\" &&\n typeof span.start_timestamp === \"number\"\n ) {\n const deltaSeconds =\n (span as { end_timestamp: number }).end_timestamp - span.start_timestamp;\n if (Number.isFinite(deltaSeconds) && deltaSeconds >= 0) {\n return deltaSeconds * 1000;\n }\n }\n return 0;\n}\n\nfunction buildOffenderSummaries(\n spans: RawSpan[],\n offenderSpanIds: string[],\n): string[] {\n if (offenderSpanIds.length === 0) {\n return [];\n }\n\n const spanMap = new Map<string, RawSpan>();\n for (const span of spans) {\n const identifier = getSpanIdentifier(span);\n if (identifier) {\n spanMap.set(identifier, span);\n }\n }\n\n const summaries: string[] = [];\n for (const offenderId of offenderSpanIds) {\n const span = spanMap.get(offenderId);\n if (span) {\n const description = span.description || span.op || `Span ${offenderId}`;\n const duration = getSpanDurationMs(span);\n const durationLabel = duration > 0 ? ` (${Math.round(duration)}ms)` : \"\";\n summaries.push(`${description}${durationLabel} [${offenderId}] [N+1]`);\n } else {\n summaries.push(`Span ${offenderId} [N+1]`);\n }\n }\n\n return summaries;\n}\n\n/**\n * Renders a hierarchical tree of performance spans using box-drawing characters.\n * Highlights N+1 queries with a special indicator.\n *\n * @param spans - Array of selected performance spans\n * @returns Array of formatted strings representing the tree\n */\nfunction renderPerformanceSpanTree(spans: PerformanceSpan[]): string[] {\n const lines: string[] = [];\n\n function renderSpan(span: PerformanceSpan, prefix = \"\", isLast = true): void {\n const connector = prefix === \"\" ? \"\" : isLast ? \"└─ \" : \"├─ \";\n\n const displayName = span.description?.trim() || span.op || \"unnamed\";\n const shortId = span.span_id ? span.span_id.substring(0, 8) : \"unknown\";\n const durationDisplay =\n span.duration > 0 ? `${Math.round(span.duration)}ms` : \"unknown\";\n\n const metadataParts: string[] = [shortId];\n if (span.op && span.op !== \"default\") {\n metadataParts.push(span.op);\n }\n metadataParts.push(durationDisplay);\n\n const line = `${prefix}${connector}${displayName} [${metadataParts.join(\n \" · \",\n )}]${span.is_n1_query ? \" [N+1]\" : \"\"}`;\n lines.push(line);\n\n // Render children\n for (let i = 0; i < span.children.length; i++) {\n const child = span.children[i];\n const isLastChild = i === span.children.length - 1;\n const childPrefix = prefix + (isLast ? \" \" : \"│ \");\n renderSpan(child, childPrefix, isLastChild);\n }\n }\n\n for (let i = 0; i < spans.length; i++) {\n const span = spans[i];\n const isLastRoot = i === spans.length - 1;\n renderSpan(span, \"\", isLastRoot);\n }\n\n return lines;\n}\n\nfunction selectN1QuerySpans(\n spans: RawSpan[],\n evidence: N1EvidenceData,\n maxSpans = MAX_SPANS_IN_TREE,\n): PerformanceSpan[] {\n const selected: PerformanceSpan[] = [];\n let spanCount = 0;\n\n const offenderSpanIds = normalizeIdArray(evidence.offenderSpanIds);\n const parentSpanIds = normalizeIdArray(evidence.parentSpanIds);\n\n let parentSpan: PerformanceSpan | null = null;\n if (parentSpanIds.length > 0) {\n const parent = spans.find((span) => {\n const identifier = getSpanIdentifier(span);\n return identifier ? parentSpanIds.includes(identifier) : false;\n });\n\n if (parent) {\n parentSpan = {\n span_id: getSpanIdentifier(parent) ?? \"unknown\",\n op: parent.op || \"unknown\",\n description:\n parent.description || evidence.parentSpan || \"Parent Operation\",\n duration: getSpanDurationMs(parent),\n is_n1_query: false,\n children: [],\n level: 0,\n };\n selected.push(parentSpan);\n spanCount += 1;\n }\n }\n\n if (offenderSpanIds.length > 0) {\n const offenderSet = new Set(offenderSpanIds);\n const offenderSpans = spans\n .filter((span) => {\n const identifier = getSpanIdentifier(span);\n return identifier ? offenderSet.has(identifier) : false;\n })\n .slice(0, Math.max(0, maxSpans - spanCount));\n\n for (const span of offenderSpans) {\n const perfSpan: PerformanceSpan = {\n span_id: getSpanIdentifier(span) ?? \"unknown\",\n op: span.op || \"db.query\",\n description: span.description || \"Database Query\",\n duration: getSpanDurationMs(span),\n is_n1_query: true,\n children: [],\n level: parentSpan ? 1 : 0,\n };\n\n if (parentSpan) {\n parentSpan.children.push(perfSpan);\n } else {\n selected.push(perfSpan);\n }\n\n spanCount += 1;\n if (spanCount >= maxSpans) {\n break;\n }\n }\n }\n\n return selected;\n}\n\n/**\n * Known Sentry performance issue types that we handle.\n *\n * NOTE: We intentionally only implement formatters for high-value performance issues\n * that provide complex insights. Not all issue types need custom formatting - many\n * can rely on the generic evidenceDisplay fields that Sentry provides.\n *\n * Currently fully implemented:\n * - N+1 query detection (DB and API)\n *\n * Partially implemented:\n * - Slow DB queries (shows parent span only)\n *\n * Not implemented (lower priority):\n * - Asset-related issues (render blocking, uncompressed, large payloads)\n * - File I/O issues\n * - Consecutive queries\n */\nconst KNOWN_PERFORMANCE_ISSUE_TYPES = {\n N_PLUS_ONE_DB_QUERIES: \"performance_n_plus_one_db_queries\",\n N_PLUS_ONE_API_CALLS: \"performance_n_plus_one_api_calls\",\n SLOW_DB_QUERY: \"performance_slow_db_query\",\n RENDER_BLOCKING_ASSET: \"performance_render_blocking_asset\",\n CONSECUTIVE_DB_QUERIES: \"performance_consecutive_db_queries\",\n FILE_IO_MAIN_THREAD: \"performance_file_io_main_thread\",\n M_N_PLUS_ONE_DB_QUERIES: \"performance_m_n_plus_one_db_queries\",\n UNCOMPRESSED_ASSET: \"performance_uncompressed_asset\",\n LARGE_HTTP_PAYLOAD: \"performance_large_http_payload\",\n} as const;\n\n/**\n * Map numeric occurrence types to issue types (from Sentry's codebase).\n *\n * Sentry uses numeric type IDs internally in the occurrence data structure,\n * but string issue types in the UI and other APIs. This mapping converts\n * between them.\n *\n * Source: sentry/static/app/types/group.tsx in Sentry's codebase\n * Range: 1xxx = transaction-based performance issues\n * 2xxx = profile-based performance issues\n */\nconst OCCURRENCE_TYPE_TO_ISSUE_TYPE: Record<number, string> = {\n 1001: KNOWN_PERFORMANCE_ISSUE_TYPES.SLOW_DB_QUERY,\n 1004: KNOWN_PERFORMANCE_ISSUE_TYPES.RENDER_BLOCKING_ASSET,\n 1006: KNOWN_PERFORMANCE_ISSUE_TYPES.N_PLUS_ONE_DB_QUERIES,\n 1906: KNOWN_PERFORMANCE_ISSUE_TYPES.N_PLUS_ONE_DB_QUERIES, // Alternative ID for N+1 DB\n 1007: KNOWN_PERFORMANCE_ISSUE_TYPES.CONSECUTIVE_DB_QUERIES,\n 1008: KNOWN_PERFORMANCE_ISSUE_TYPES.FILE_IO_MAIN_THREAD,\n 1009: \"performance_consecutive_http\",\n 1010: KNOWN_PERFORMANCE_ISSUE_TYPES.N_PLUS_ONE_API_CALLS,\n 1910: KNOWN_PERFORMANCE_ISSUE_TYPES.N_PLUS_ONE_API_CALLS, // Alternative ID for N+1 API\n 1012: KNOWN_PERFORMANCE_ISSUE_TYPES.UNCOMPRESSED_ASSET,\n 1013: \"performance_db_main_thread\",\n 1015: KNOWN_PERFORMANCE_ISSUE_TYPES.LARGE_HTTP_PAYLOAD,\n 1016: \"performance_http_overhead\",\n};\n\n// Type alias currently unused but kept for potential future type safety\n// type PerformanceIssueType = typeof KNOWN_PERFORMANCE_ISSUE_TYPES[keyof typeof KNOWN_PERFORMANCE_ISSUE_TYPES];\n\n/**\n * Formats N+1 query issue evidence data.\n *\n * N+1 queries are a common performance anti-pattern where code executes\n * 1 query to get a list of items, then N additional queries (one per item)\n * instead of using a single JOIN or batch query.\n *\n * Evidence fields we use:\n * - parentSpan: The operation that triggered the N+1 queries\n * - repeatingSpansCompact/repeatingSpans: The query pattern being repeated\n * - numberRepeatingSpans: How many times the query was executed\n * - offenderSpanIds: IDs of the actual span instances\n * - parentSpanIds: IDs of parent spans for tree visualization\n */\nfunction formatN1QueryEvidence(\n evidenceData: N1EvidenceData,\n spansData: unknown,\n performanceTrace?: Trace,\n): string {\n const parts: string[] = [];\n\n // Format parent span info if available\n if (evidenceData.parentSpan) {\n parts.push(\"**Parent Operation:**\");\n parts.push(`${evidenceData.parentSpan}`);\n parts.push(\"\");\n }\n\n // Format repeating spans (the N+1 queries)\n const repeatingLines = getRepeatingSpanLines(evidenceData);\n if (repeatingLines.length > 0) {\n parts.push(\"### Repeated Database Queries\");\n parts.push(\"\");\n\n const queryCount = evidenceData.numberRepeatingSpans\n ? safeParseInt(evidenceData.numberRepeatingSpans, 0)\n : evidenceData.numPatternRepetitions ||\n evidenceData.offenderSpanIds?.length ||\n 0;\n\n if (queryCount > 0) {\n parts.push(`**Query executed ${queryCount} times:**`);\n }\n\n // Show the query pattern - if single line, render as SQL block; if multiple, as list\n if (repeatingLines.length === 1) {\n parts.push(\"```sql\");\n parts.push(repeatingLines[0]);\n parts.push(\"```\");\n parts.push(\"\");\n } else {\n parts.push(\"**Repeated operations:**\");\n for (const line of repeatingLines) {\n parts.push(`- ${line}`);\n }\n parts.push(\"\");\n }\n }\n\n const parentSpanIds = normalizeIdArray(evidenceData.parentSpanIds);\n const offenderSpanIds = normalizeIdArray(evidenceData.offenderSpanIds);\n\n const traceLines = performanceTrace\n ? buildTraceSpanTree(\n performanceTrace,\n parentSpanIds,\n offenderSpanIds,\n MAX_SPANS_IN_TREE,\n )\n : [];\n\n if (traceLines.length > 0) {\n parts.push(`### Span Tree (Limited to ${MAX_SPANS_IN_TREE} spans)`);\n parts.push(\"\");\n parts.push(\"```\");\n parts.push(...traceLines);\n parts.push(\"```\");\n parts.push(\"\");\n } else {\n const spanTree = isValidSpanArray(spansData)\n ? selectN1QuerySpans(spansData, evidenceData, MAX_SPANS_IN_TREE)\n : [];\n\n if (spanTree.length > 0) {\n parts.push(`### Span Tree (Limited to ${MAX_SPANS_IN_TREE} spans)`);\n parts.push(\"\");\n parts.push(\"```\");\n parts.push(...renderPerformanceSpanTree(spanTree));\n parts.push(\"```\");\n parts.push(\"\");\n } else if (isValidSpanArray(spansData)) {\n // Only show offender summaries if we have spans data but couldn't build a tree\n const offenderSummaries = buildOffenderSummaries(\n spansData as RawSpan[],\n offenderSpanIds,\n );\n\n if (offenderSummaries.length > 0) {\n parts.push(\"### Offending Spans\");\n parts.push(\"\");\n for (const summary of offenderSummaries) {\n parts.push(`- ${summary}`);\n }\n }\n }\n }\n\n return parts.join(\"\\n\");\n}\n\n/**\n * Formats slow DB query issue evidence data.\n *\n * Currently only partially implemented - shows parent span information.\n * Full implementation would show query duration, explain plan, etc.\n *\n * This is lower priority as the generic evidenceDisplay fields usually\n * provide sufficient information for slow query issues.\n */\nfunction formatSlowDbQueryEvidence(\n evidenceData: SlowDbEvidenceData,\n spansData: unknown,\n): string {\n const parts: string[] = [];\n\n // Show parent span if available (generic field that applies to slow queries)\n if (evidenceData.parentSpan) {\n parts.push(\"**Parent Operation:**\");\n parts.push(`${evidenceData.parentSpan}`);\n parts.push(\"\");\n }\n\n // TODO: Implement slow query specific fields when we know the structure\n // Potential fields: query duration, database name, query plan\n console.warn(\n \"[formatSlowDbQueryEvidence] Evidence data rendering not yet fully implemented\",\n );\n\n return parts.join(\"\\n\");\n}\n\n/**\n * Formats performance issue details from transaction events based on the issue type.\n *\n * This is the main dispatcher for performance issue formatting. It:\n * 1. Detects the issue type from occurrence data (numeric or string)\n * 2. Calls the appropriate type-specific formatter if implemented\n * 3. Falls back to generic evidenceDisplay fields for unimplemented types\n * 4. Provides span analysis fallback for events without occurrence data\n *\n * The occurrence data structure comes from Sentry's performance issue detection\n * and contains evidence about what triggered the issue.\n *\n * @param event - The transaction event containing performance issue data\n * @param spansData - The spans data from the event entries\n * @returns Formatted markdown string with performance issue details\n */\nfunction formatPerformanceIssueOutput(\n event: Event,\n spansData: unknown,\n options?: {\n performanceTrace?: Trace;\n },\n): string {\n const parts: string[] = [];\n\n // Check if we have occurrence data\n const occurrence = (event as any).occurrence;\n if (!occurrence) {\n return \"\";\n }\n\n // Get issue type - occurrence.type is numeric, issueType may be a string\n let issueType: string | undefined;\n if (typeof occurrence.type === \"number\") {\n issueType = OCCURRENCE_TYPE_TO_ISSUE_TYPE[occurrence.type];\n } else {\n issueType = occurrence.issueType || occurrence.type;\n }\n\n const evidenceData = occurrence.evidenceData;\n\n // Process evidence data based on known performance issue types\n if (evidenceData) {\n switch (issueType) {\n case KNOWN_PERFORMANCE_ISSUE_TYPES.N_PLUS_ONE_DB_QUERIES:\n case KNOWN_PERFORMANCE_ISSUE_TYPES.N_PLUS_ONE_API_CALLS:\n case KNOWN_PERFORMANCE_ISSUE_TYPES.M_N_PLUS_ONE_DB_QUERIES: {\n const result = formatN1QueryEvidence(\n evidenceData,\n spansData,\n options?.performanceTrace,\n );\n if (result) parts.push(result);\n break;\n }\n\n case KNOWN_PERFORMANCE_ISSUE_TYPES.SLOW_DB_QUERY: {\n const result = formatSlowDbQueryEvidence(evidenceData, spansData);\n if (result) parts.push(result);\n break;\n }\n\n default:\n // We don't implement formatters for all performance issue types.\n // Many lower-priority issues (consecutive queries, asset issues, file I/O)\n // work fine with just the generic evidenceDisplay fields below.\n // Only high-value, complex issues like N+1 queries need custom formatting.\n if (issueType) {\n console.warn(\n `[formatPerformanceIssueOutput] No custom formatter for issue type: ${issueType}`,\n );\n }\n // Fall through to show generic evidence display below\n }\n }\n\n // Show transaction name if available for any performance issue (generic field)\n if (evidenceData?.transactionName) {\n parts.push(\"**Transaction:**\");\n parts.push(`${evidenceData.transactionName}`);\n parts.push(\"\");\n }\n\n // Always show evidence display if available (this is generic and doesn't require type knowledge)\n if (occurrence.evidenceDisplay?.length > 0) {\n for (const display of occurrence.evidenceDisplay) {\n if (display.important) {\n parts.push(`**${display.name}:**`);\n parts.push(`${display.value}`);\n parts.push(\"\");\n }\n }\n }\n\n return parts.length > 0 ? `${parts.join(\"\\n\")}\\n` : \"\";\n}\n\nfunction formatTags(tags: z.infer<typeof EventSchema>[\"tags\"]) {\n if (!tags || tags.length === 0) {\n return \"\";\n }\n return `### Tags\\n\\n${tags\n .map((tag) => `**${tag.key}**: ${tag.value}`)\n .join(\"\\n\")}\\n\\n`;\n}\n\nfunction formatContext(context: z.infer<typeof EventSchema>[\"context\"]) {\n if (!context || Object.keys(context).length === 0) {\n return \"\";\n }\n return `### Extra Data\\n\\nAdditional data attached to this event.\\n\\n${Object.entries(\n context,\n )\n .map(([key, value]) => {\n return `**${key}**: ${JSON.stringify(value, undefined, 2)}`;\n })\n .join(\"\\n\")}\\n\\n`;\n}\n\nfunction formatContexts(contexts: z.infer<typeof EventSchema>[\"contexts\"]) {\n if (!contexts || Object.keys(contexts).length === 0) {\n return \"\";\n }\n return `### Additional Context\\n\\nThese are additional context provided by the user when they're instrumenting their application.\\n\\n${Object.entries(\n contexts,\n )\n .map(\n ([name, data]) =>\n `**${name}**\\n${Object.entries(data)\n .filter(([key, _]) => key !== \"type\")\n .map(([key, value]) => {\n return `${key}: ${JSON.stringify(value, undefined, 2)}`;\n })\n .join(\"\\n\")}`,\n )\n .join(\"\\n\\n\")}\\n\\n`;\n}\n\n/**\n * Formats a brief Seer analysis summary for inclusion in issue details.\n * Shows current status and high-level insights, prompting to use analyze_issue_with_seer for full details.\n *\n * @param autofixState - The autofix state containing Seer analysis data\n * @param organizationSlug - The organization slug for the issue\n * @param issueId - The issue ID (shortId)\n * @returns Formatted markdown string with Seer summary, or empty string if no analysis exists\n */\nfunction formatSeerSummary(\n autofixState: AutofixRunState | undefined,\n organizationSlug: string,\n issueId: string,\n): string {\n if (!autofixState || !autofixState.autofix) {\n return \"\";\n }\n\n const { autofix } = autofixState;\n const parts: string[] = [];\n\n parts.push(\"## Seer Analysis\");\n parts.push(\"\");\n\n // Show status first\n const statusDisplay = getStatusDisplayName(autofix.status);\n if (!isTerminalStatus(autofix.status)) {\n parts.push(`**Status:** ${statusDisplay}`);\n parts.push(\"\");\n }\n\n // Show summary of what we have so far\n if (autofix.steps.length > 0) {\n const completedSteps = autofix.steps.filter(\n (step) => step.status === \"COMPLETED\",\n );\n\n // Find the solution step if available\n const solutionStep = completedSteps.find(\n (step) => step.type === \"solution\",\n );\n\n if (solutionStep) {\n // For solution steps, use the description directly\n const solutionDescription = solutionStep.description;\n if (\n solutionDescription &&\n typeof solutionDescription === \"string\" &&\n solutionDescription.trim()\n ) {\n parts.push(\"**Summary:**\");\n parts.push(solutionDescription.trim());\n } else {\n // Fallback to extracting from output if no description\n const solutionOutput = getOutputForAutofixStep(solutionStep);\n const lines = solutionOutput.split(\"\\n\");\n const firstParagraph = lines.find(\n (line) =>\n line.trim().length > 50 &&\n !line.startsWith(\"#\") &&\n !line.startsWith(\"*\"),\n );\n if (firstParagraph) {\n parts.push(\"**Summary:**\");\n parts.push(firstParagraph.trim());\n }\n }\n } else if (completedSteps.length > 0) {\n // Show what steps have been completed so far\n const rootCauseStep = completedSteps.find(\n (step) => step.type === \"root_cause_analysis\",\n );\n\n if (rootCauseStep) {\n const typedStep = rootCauseStep as z.infer<\n typeof AutofixRunStepRootCauseAnalysisSchema\n >;\n if (\n typedStep.causes &&\n typedStep.causes.length > 0 &&\n typedStep.causes[0].description\n ) {\n parts.push(\"**Root Cause Identified:**\");\n parts.push(typedStep.causes[0].description.trim());\n }\n } else {\n // Show generic progress\n parts.push(\n `**Progress:** ${completedSteps.length} of ${autofix.steps.length} steps completed`,\n );\n }\n }\n } else {\n // No steps yet - check for terminal states first\n if (isTerminalStatus(autofix.status)) {\n if (autofix.status === \"FAILED\" || autofix.status === \"ERROR\") {\n parts.push(\"**Status:** Analysis failed.\");\n } else if (autofix.status === \"CANCELLED\") {\n parts.push(\"**Status:** Analysis was cancelled.\");\n } else if (\n autofix.status === \"NEED_MORE_INFORMATION\" ||\n autofix.status === \"WAITING_FOR_USER_RESPONSE\"\n ) {\n parts.push(\n \"**Status:** Analysis paused - additional information needed.\",\n );\n }\n } else {\n parts.push(\"Analysis has started but no results yet.\");\n }\n }\n\n // Add specific messages for terminal states when steps exist\n if (autofix.steps.length > 0 && isTerminalStatus(autofix.status)) {\n if (autofix.status === \"FAILED\" || autofix.status === \"ERROR\") {\n parts.push(\"\");\n parts.push(\"**Status:** Analysis failed.\");\n } else if (autofix.status === \"CANCELLED\") {\n parts.push(\"\");\n parts.push(\"**Status:** Analysis was cancelled.\");\n } else if (\n autofix.status === \"NEED_MORE_INFORMATION\" ||\n autofix.status === \"WAITING_FOR_USER_RESPONSE\"\n ) {\n parts.push(\"\");\n parts.push(\n \"**Status:** Analysis paused - additional information needed.\",\n );\n }\n }\n\n // Always suggest using analyze_issue_with_seer for more details\n parts.push(\"\");\n parts.push(\n `**Note:** For detailed root cause analysis and solutions, call \\`analyze_issue_with_seer(organizationSlug='${organizationSlug}', issueId='${issueId}')\\``,\n );\n\n return `${parts.join(\"\\n\")}\\n\\n`;\n}\n\n/**\n * Formats a Sentry issue with its latest event into comprehensive markdown output.\n * Includes issue metadata, event details, and usage instructions.\n *\n * @param params - Object containing organization slug, issue, event, and API service\n * @returns Formatted markdown string with complete issue information\n */\nexport function formatIssueOutput({\n organizationSlug,\n issue,\n event,\n apiService,\n autofixState,\n performanceTrace,\n}: {\n organizationSlug: string;\n issue: Issue;\n event: Event;\n apiService: SentryApiService;\n autofixState?: AutofixRunState;\n performanceTrace?: Trace;\n}) {\n let output = `# Issue ${issue.shortId} in **${organizationSlug}**\\n\\n`;\n\n // Check if this is a performance issue based on issueCategory or issueType\n // Performance issues can have various categories like 'db_query' but issueType starts with 'performance_'\n const isPerformanceIssue =\n issue.issueType?.startsWith(\"performance_\") ||\n issue.issueCategory === \"performance\";\n\n if (isPerformanceIssue && issue.metadata) {\n // For performance issues, use metadata for better context\n const issueTitle = issue.metadata.title || issue.title;\n output += `**Description**: ${issueTitle}\\n`;\n\n if (issue.metadata.location) {\n output += `**Location**: ${issue.metadata.location}\\n`;\n }\n if (issue.metadata.value) {\n output += `**Query Pattern**: \\`${issue.metadata.value}\\`\\n`;\n }\n } else {\n // For regular errors and other issues\n output += `**Description**: ${issue.title}\\n`;\n output += `**Culprit**: ${issue.culprit}\\n`;\n }\n\n output += `**First Seen**: ${new Date(issue.firstSeen).toISOString()}\\n`;\n output += `**Last Seen**: ${new Date(issue.lastSeen).toISOString()}\\n`;\n output += `**Occurrences**: ${issue.count}\\n`;\n output += `**Users Impacted**: ${issue.userCount}\\n`;\n output += `**Status**: ${issue.status}\\n`;\n output += `**Platform**: ${issue.platform}\\n`;\n output += `**Project**: ${issue.project.name}\\n`;\n output += `**URL**: ${apiService.getIssueUrl(organizationSlug, issue.shortId)}\\n`;\n output += \"\\n\";\n output += \"## Event Details\\n\\n\";\n output += `**Event ID**: ${event.id}\\n`;\n // \"default\" type represents error events without exception data\n if (event.type === \"error\" || event.type === \"default\") {\n output += `**Occurred At**: ${new Date((event as z.infer<typeof ErrorEventSchema>).dateCreated).toISOString()}\\n`;\n }\n if (event.message) {\n output += `**Message**:\\n${event.message}\\n`;\n }\n output += \"\\n\";\n output += formatEventOutput(event, { performanceTrace });\n\n // Add Seer context if available\n if (autofixState) {\n output += formatSeerSummary(autofixState, organizationSlug, issue.shortId);\n }\n\n output += \"# Using this information\\n\\n\";\n output += `- You can reference the IssueID in commit messages (e.g. \\`Fixes ${issue.shortId}\\`) to automatically close the issue when the commit is merged.\\n`;\n output +=\n \"- The stacktrace includes both first-party application code as well as third-party code, its important to triage to first-party code.\\n\";\n return output;\n}\n"],"mappings":";;;AAiCA,MAAMA,sBAA8C;CAClD,SAAS;CACT,OAAO;CACP,OAAO;CACP,QAAQ;CACR,OAAO;CACP,QAAQ;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,EAAA,QAAA,CAAA,EAAA,MAAA,GAAA,IAAA,CAAA,EAAA,MAAA;;;;;;;;;AAWmB,iBAt4CL,iBAAA,CAs4CK,KAAA,EAr4CZ,KAq4CY,EAAA,QAAA,EAAA;EAAK,gBAAA,CAAA,EAn4CH,KAm4CG;;;;;;;;;iBAbV,iBAAA;;;;;;;;;SASP;SACA;cACK;iBACG;qBACI"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatting-ClM7RU4L.d.ts","names":[],"sources":["../src/internal/formatting.ts"],"sourcesContent":[],"mappings":";;;;;;;AA2FgB;AAqEhB;;;;AAG4B;AAs3C5B;;;AAEE,iBAj8Cc,iBAAA,CAi8Cd,KAAA,EAh8CO,CAAA,CAAE,KAg8CT,CAAA,OAh8CsB,cAg8CtB,CAAA,EAAA,UAAA,CAAA,EAAA,MAAA,EAAA,QAAA,CAAA,EAAA,MAAA,GAAA,IAAA,CAAA,EAAA,MAAA;;;;;;;;;AAWmB,iBAt4CL,iBAAA,CAs4CK,KAAA,EAr4CZ,KAq4CY,EAAA,QAAA,EAAA;EAAK,gBAAA,CAAA,EAn4CH,KAm4CG;;;;;;;;;iBAbV,iBAAA;;;;;;;;;SASP;SACA;cACK;iBACG;qBACI"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-event-attachment-CTF-k6op.cjs","names":["ParamOrganizationSlug","ParamProjectSlug","ParamEventId","context: ServerContext","contentParts: (TextContent | ImageContent | EmbeddedResource)[]","image: ImageContent","resource: EmbeddedResource","output","text: TextContent"],"sources":["../src/tools/get-event-attachment.ts"],"sourcesContent":["import { defineTool } from \"../internal/tool-helpers/define\";\nimport { apiServiceFromContext } from \"../internal/tool-helpers/api\";\nimport type { ServerContext } from \"../types\";\nimport type {\n TextContent,\n ImageContent,\n EmbeddedResource,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport {\n ParamOrganizationSlug,\n ParamProjectSlug,\n ParamEventId,\n ParamAttachmentId,\n ParamRegionUrl,\n} from \"../schema\";\nimport { setTag } from \"@sentry/core\";\n\nexport default defineTool({\n name: \"get_event_attachment\",\n requiredSkills: [\"inspect\"], // Only available in inspect skill\n requiredScopes: [\"event:read\"],\n description: [\n \"Download attachments from a Sentry event.\",\n \"\",\n \"Use this tool when you need to:\",\n \"- Download files attached to a specific event\",\n \"- Access screenshots, log files, or other attachments uploaded with an error report\",\n \"- Retrieve attachment metadata and download URLs\",\n \"\",\n \"<examples>\",\n \"### Download a specific attachment by ID\",\n \"\",\n \"```\",\n \"get_event_attachment(organizationSlug='my-organization', projectSlug='my-project', eventId='c49541c747cb4d8aa3efb70ca5aba243', attachmentId='12345')\",\n \"```\",\n \"\",\n \"### List all attachments for an event\",\n \"\",\n \"```\",\n \"get_event_attachment(organizationSlug='my-organization', projectSlug='my-project', eventId='c49541c747cb4d8aa3efb70ca5aba243')\",\n \"```\",\n \"\",\n \"</examples>\",\n \"\",\n \"<hints>\",\n \"- If `attachmentId` is provided, the specific attachment will be downloaded as an embedded resource\",\n \"- If `attachmentId` is omitted, all attachments for the event will be listed with download information\",\n \"- The `projectSlug` is required to identify which project the event belongs to\",\n \"</hints>\",\n ].join(\"\\n\"),\n inputSchema: {\n organizationSlug: ParamOrganizationSlug,\n projectSlug: ParamProjectSlug,\n eventId: ParamEventId,\n attachmentId: ParamAttachmentId.optional(),\n regionUrl: ParamRegionUrl.optional(),\n },\n annotations: {\n readOnlyHint: true,\n openWorldHint: true,\n },\n async handler(params, context: ServerContext) {\n const apiService = apiServiceFromContext(context, {\n regionUrl: params.regionUrl,\n });\n\n setTag(\"organization.slug\", params.organizationSlug);\n\n // If attachmentId is provided, download the specific attachment\n if (params.attachmentId) {\n const attachment = await apiService.getEventAttachment({\n organizationSlug: params.organizationSlug,\n projectSlug: params.projectSlug,\n eventId: params.eventId,\n attachmentId: params.attachmentId,\n });\n\n const contentParts: (TextContent | ImageContent | EmbeddedResource)[] =\n [];\n const isBinary = !attachment.attachment.mimetype?.startsWith(\"text/\");\n\n if (isBinary) {\n const isImage = attachment.attachment.mimetype?.startsWith(\"image/\");\n // Base64 encode the binary attachment content\n // and add to the content as an embedded resource\n const uint8Array = new Uint8Array(await attachment.blob.arrayBuffer());\n let binary = \"\";\n for (let i = 0; i < uint8Array.byteLength; i++) {\n binary += String.fromCharCode(uint8Array[i]);\n }\n if (isImage) {\n const image: ImageContent = {\n type: \"image\",\n mimeType: attachment.attachment.mimetype,\n data: btoa(binary),\n };\n contentParts.push(image);\n } else {\n const resource: EmbeddedResource = {\n id: params.attachmentId,\n type: \"resource\",\n resource: {\n uri: `file://${attachment.filename}`,\n mimeType: attachment.attachment.mimetype,\n blob: btoa(binary),\n },\n };\n contentParts.push(resource);\n }\n }\n\n let output = `# Event Attachment Download\\n\\n`;\n output += `**Event ID:** ${params.eventId}\\n`;\n output += `**Attachment ID:** ${params.attachmentId}\\n`;\n output += `**Filename:** ${attachment.filename}\\n`;\n output += `**Type:** ${attachment.attachment.type}\\n`;\n output += `**Size:** ${attachment.attachment.size} bytes\\n`;\n output += `**MIME Type:** ${attachment.attachment.mimetype}\\n`;\n output += `**Created:** ${attachment.attachment.dateCreated}\\n`;\n output += `**SHA1:** ${attachment.attachment.sha1}\\n\\n`;\n output += `**Download URL:** ${attachment.downloadUrl}\\n\\n`;\n\n if (isBinary) {\n output += `## Binary Content\\n\\n`;\n output += `The attachment is included as a resource and accessible through your client.\\n`;\n } else {\n // If it's a text file and we have blob content, decode and display it instead\n // of embedding it as an image or resource\n const textContent = await attachment.blob.text();\n output += `## File Content\\n\\n`;\n output += `\\`\\`\\`\\n${textContent}\\n\\`\\`\\`\\n\\n`;\n }\n\n const text: TextContent = {\n type: \"text\",\n text: output,\n };\n contentParts.push(text);\n\n return contentParts;\n }\n\n // List all attachments for the event\n const attachments = await apiService.listEventAttachments({\n organizationSlug: params.organizationSlug,\n projectSlug: params.projectSlug,\n eventId: params.eventId,\n });\n\n let output = `# Event Attachments\\n\\n`;\n output += `**Event ID:** ${params.eventId}\\n`;\n output += `**Project:** ${params.projectSlug}\\n\\n`;\n\n if (attachments.length === 0) {\n output += \"No attachments found for this event.\\n\";\n return output;\n }\n\n output += `Found ${attachments.length} attachment(s):\\n\\n`;\n\n attachments.forEach((attachment, index) => {\n output += `## Attachment ${index + 1}\\n\\n`;\n output += `**ID:** ${attachment.id}\\n`;\n output += `**Name:** ${attachment.name}\\n`;\n output += `**Type:** ${attachment.type}\\n`;\n output += `**Size:** ${attachment.size} bytes\\n`;\n output += `**MIME Type:** ${attachment.mimetype}\\n`;\n output += `**Created:** ${attachment.dateCreated}\\n`;\n output += `**SHA1:** ${attachment.sha1}\\n\\n`;\n output += `To download this attachment, use the \"get_event_attachment\" tool with the attachmentId provided:\\n`;\n output += `\\`get_event_attachment(organizationSlug=\"${params.organizationSlug}\", projectSlug=\"${params.projectSlug}\", eventId=\"${params.eventId}\", attachmentId=\"${attachment.id}\")\\`\\n\\n`;\n });\n\n return output;\n },\n});\n"],"mappings":";;;;;;;AAiBA,mCAAe,0BAAW;CACxB,MAAM;CACN,gBAAgB,CAAC,SAAU;CAC3B,gBAAgB,CAAC,YAAa;CAC9B,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,EAAC,KAAK,KAAK;CACZ,aAAa;EACX,kBAAkBA;EAClB,aAAaC;EACb,SAASC;EACT,cAAc,iCAAkB,UAAU;EAC1C,WAAW,8BAAe,UAAU;CACrC;CACD,aAAa;EACX,cAAc;EACd,eAAe;CAChB;CACD,MAAM,QAAQ,QAAQC,SAAwB;EAC5C,MAAM,aAAa,kCAAsB,SAAS,EAChD,WAAW,OAAO,UACnB,EAAC;AAEF,4BAAO,qBAAqB,OAAO,iBAAiB;AAGpD,MAAI,OAAO,cAAc;GACvB,MAAM,aAAa,MAAM,WAAW,mBAAmB;IACrD,kBAAkB,OAA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,KAAK,KAAK;AAEvB,UAAO;EACR;EAGD,MAAM,cAAc,MAAM,WAAW,qBAAqB;GACxD,kBAAkB,OAAO;GACzB,aAAa,OAAO;GACpB,SAAS,OAAO;EACjB,EAAC;EAEF,IAAI,UAAU;AACd,aAAW,gBAAgB,OAAO,QAAQ;AAC1C,aAAW,eAAe,OAAO,YAAY;AAE7C,MAAI,YAAY,WAAW,GAAG;AAC5B,aAAU;AACV,UAAO;EACR;AAED,aAAW,QAAQ,YAAY,OAAO;AAEtC,cAAY,QAAQ,CAAC,YAAY,UAAU;AACzC,cAAW,gBAAgB,QAAQ,EAAE;AACrC,cAAW,UAAU,WAAW,GAAG;AACnC,cAAW,YAAY,WAAW,KAAK;AACvC,cAAW,YAAY,WAAW,KAAK;AACvC,cAAW,YAAY,WAAW,KAAK;AACvC,cAAW,iBAAiB,WAAW,SAAS;AAChD,cAAW,eAAe,WAAW,YAAY;AACjD,cAAW,YAAY,WAAW,KAAK;AACvC,cAAW;AACX,cAAW,2CAA2C,OAAO,iBAAiB,kBAAkB,OAAO,YAAY,cAAc,OAAO,QAAQ,mBAAmB,WAAW,GAAG;EAClL,EAAC;AAEF,SAAO;CACR;AACF,EAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-event-attachment-DDvsu6IQ.js","names":["context: ServerContext","contentParts: (TextContent | ImageContent | EmbeddedResource)[]","image: ImageContent","resource: EmbeddedResource","output","text: TextContent"],"sources":["../src/tools/get-event-attachment.ts"],"sourcesContent":["import { defineTool } from \"../internal/tool-helpers/define\";\nimport { apiServiceFromContext } from \"../internal/tool-helpers/api\";\nimport type { ServerContext } from \"../types\";\nimport type {\n TextContent,\n ImageContent,\n EmbeddedResource,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport {\n ParamOrganizationSlug,\n ParamProjectSlug,\n ParamEventId,\n ParamAttachmentId,\n ParamRegionUrl,\n} from \"../schema\";\nimport { setTag } from \"@sentry/core\";\n\nexport default defineTool({\n name: \"get_event_attachment\",\n requiredSkills: [\"inspect\"], // Only available in inspect skill\n requiredScopes: [\"event:read\"],\n description: [\n \"Download attachments from a Sentry event.\",\n \"\",\n \"Use this tool when you need to:\",\n \"- Download files attached to a specific event\",\n \"- Access screenshots, log files, or other attachments uploaded with an error report\",\n \"- Retrieve attachment metadata and download URLs\",\n \"\",\n \"<examples>\",\n \"### Download a specific attachment by ID\",\n \"\",\n \"```\",\n \"get_event_attachment(organizationSlug='my-organization', projectSlug='my-project', eventId='c49541c747cb4d8aa3efb70ca5aba243', attachmentId='12345')\",\n \"```\",\n \"\",\n \"### List all attachments for an event\",\n \"\",\n \"```\",\n \"get_event_attachment(organizationSlug='my-organization', projectSlug='my-project', eventId='c49541c747cb4d8aa3efb70ca5aba243')\",\n \"```\",\n \"\",\n \"</examples>\",\n \"\",\n \"<hints>\",\n \"- If `attachmentId` is provided, the specific attachment will be downloaded as an embedded resource\",\n \"- If `attachmentId` is omitted, all attachments for the event will be listed with download information\",\n \"- The `projectSlug` is required to identify which project the event belongs to\",\n \"</hints>\",\n ].join(\"\\n\"),\n inputSchema: {\n organizationSlug: ParamOrganizationSlug,\n projectSlug: ParamProjectSlug,\n eventId: ParamEventId,\n attachmentId: ParamAttachmentId.optional(),\n regionUrl: ParamRegionUrl.optional(),\n },\n annotations: {\n readOnlyHint: true,\n openWorldHint: true,\n },\n async handler(params, context: ServerContext) {\n const apiService = apiServiceFromContext(context, {\n regionUrl: params.regionUrl,\n });\n\n setTag(\"organization.slug\", params.organizationSlug);\n\n // If attachmentId is provided, download the specific attachment\n if (params.attachmentId) {\n const attachment = await apiService.getEventAttachment({\n organizationSlug: params.organizationSlug,\n projectSlug: params.projectSlug,\n eventId: params.eventId,\n attachmentId: params.attachmentId,\n });\n\n const contentParts: (TextContent | ImageContent | EmbeddedResource)[] =\n [];\n const isBinary = !attachment.attachment.mimetype?.startsWith(\"text/\");\n\n if (isBinary) {\n const isImage = attachment.attachment.mimetype?.startsWith(\"image/\");\n // Base64 encode the binary attachment content\n // and add to the content as an embedded resource\n const uint8Array = new Uint8Array(await attachment.blob.arrayBuffer());\n let binary = \"\";\n for (let i = 0; i < uint8Array.byteLength; i++) {\n binary += String.fromCharCode(uint8Array[i]);\n }\n if (isImage) {\n const image: ImageContent = {\n type: \"image\",\n mimeType: attachment.attachment.mimetype,\n data: btoa(binary),\n };\n contentParts.push(image);\n } else {\n const resource: EmbeddedResource = {\n id: params.attachmentId,\n type: \"resource\",\n resource: {\n uri: `file://${attachment.filename}`,\n mimeType: attachment.attachment.mimetype,\n blob: btoa(binary),\n },\n };\n contentParts.push(resource);\n }\n }\n\n let output = `# Event Attachment Download\\n\\n`;\n output += `**Event ID:** ${params.eventId}\\n`;\n output += `**Attachment ID:** ${params.attachmentId}\\n`;\n output += `**Filename:** ${attachment.filename}\\n`;\n output += `**Type:** ${attachment.attachment.type}\\n`;\n output += `**Size:** ${attachment.attachment.size} bytes\\n`;\n output += `**MIME Type:** ${attachment.attachment.mimetype}\\n`;\n output += `**Created:** ${attachment.attachment.dateCreated}\\n`;\n output += `**SHA1:** ${attachment.attachment.sha1}\\n\\n`;\n output += `**Download URL:** ${attachment.downloadUrl}\\n\\n`;\n\n if (isBinary) {\n output += `## Binary Content\\n\\n`;\n output += `The attachment is included as a resource and accessible through your client.\\n`;\n } else {\n // If it's a text file and we have blob content, decode and display it instead\n // of embedding it as an image or resource\n const textContent = await attachment.blob.text();\n output += `## File Content\\n\\n`;\n output += `\\`\\`\\`\\n${textContent}\\n\\`\\`\\`\\n\\n`;\n }\n\n const text: TextContent = {\n type: \"text\",\n text: output,\n };\n contentParts.push(text);\n\n return contentParts;\n }\n\n // List all attachments for the event\n const attachments = await apiService.listEventAttachments({\n organizationSlug: params.organizationSlug,\n projectSlug: params.projectSlug,\n eventId: params.eventId,\n });\n\n let output = `# Event Attachments\\n\\n`;\n output += `**Event ID:** ${params.eventId}\\n`;\n output += `**Project:** ${params.projectSlug}\\n\\n`;\n\n if (attachments.length === 0) {\n output += \"No attachments found for this event.\\n\";\n return output;\n }\n\n output += `Found ${attachments.length} attachment(s):\\n\\n`;\n\n attachments.forEach((attachment, index) => {\n output += `## Attachment ${index + 1}\\n\\n`;\n output += `**ID:** ${attachment.id}\\n`;\n output += `**Name:** ${attachment.name}\\n`;\n output += `**Type:** ${attachment.type}\\n`;\n output += `**Size:** ${attachment.size} bytes\\n`;\n output += `**MIME Type:** ${attachment.mimetype}\\n`;\n output += `**Created:** ${attachment.dateCreated}\\n`;\n output += `**SHA1:** ${attachment.sha1}\\n\\n`;\n output += `To download this attachment, use the \"get_event_attachment\" tool with the attachmentId provided:\\n`;\n output += `\\`get_event_attachment(organizationSlug=\"${params.organizationSlug}\", projectSlug=\"${params.projectSlug}\", eventId=\"${params.eventId}\", attachmentId=\"${attachment.id}\")\\`\\n\\n`;\n });\n\n return output;\n },\n});\n"],"mappings":";;;;;;AAiBA,mCAAe,WAAW;CACxB,MAAM;CACN,gBAAgB,CAAC,SAAU;CAC3B,gBAAgB,CAAC,YAAa;CAC9B,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,EAAC,KAAK,KAAK;CACZ,aAAa;EACX,kBAAkB;EAClB,aAAa;EACb,SAAS;EACT,cAAc,kBAAkB,UAAU;EAC1C,WAAW,eAAe,UAAU;CACrC;CACD,aAAa;EACX,cAAc;EACd,eAAe;CAChB;CACD,MAAM,QAAQ,QAAQA,SAAwB;EAC5C,MAAM,aAAa,sBAAsB,SAAS,EAChD,WAAW,OAAO,UACnB,EAAC;AAEF,SAAO,qBAAqB,OAAO,iBAAiB;AAGpD,MAAI,OAAO,cAAc;GACvB,MAAM,aAAa,MAAM,WAAW,mBAAmB;IACrD,kBAAkB,OAAO;IACzB,aAAa,OAAO;IACpB,SAAS,OAAO;IAChB,cAAc,OAAO;GACtB,EAAC;GAEF,MAAM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AkB,OAAO;GACzB,aAAa,OAAO;GACpB,SAAS,OAAO;EACjB,EAAC;EAEF,IAAI,UAAU;AACd,aAAW,gBAAgB,OAAO,QAAQ;AAC1C,aAAW,eAAe,OAAO,YAAY;AAE7C,MAAI,YAAY,WAAW,GAAG;AAC5B,aAAU;AACV,UAAO;EACR;AAED,aAAW,QAAQ,YAAY,OAAO;AAEtC,cAAY,QAAQ,CAAC,YAAY,UAAU;AACzC,cAAW,gBAAgB,QAAQ,EAAE;AACrC,cAAW,UAAU,WAAW,GAAG;AACnC,cAAW,YAAY,WAAW,KAAK;AACvC,cAAW,YAAY,WAAW,KAAK;AACvC,cAAW,YAAY,WAAW,KAAK;AACvC,cAAW,iBAAiB,WAAW,SAAS;AAChD,cAAW,eAAe,WAAW,YAAY;AACjD,cAAW,YAAY,WAAW,KAAK;AACvC,cAAW;AACX,cAAW,2CAA2C,OAAO,iBAAiB,kBAAkB,OAAO,YAAY,cAAc,OAAO,QAAQ,mBAAmB,WAAW,GAAG;EAClL,EAAC;AAEF,SAAO;CACR;AACF,EAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-issue-details-Bsax2jTY.js","names":["context: ServerContext","orgSlug","issue","event: Awaited<ReturnType<typeof apiService.getEventForIssue>>","autofixState:\n | Awaited<ReturnType<typeof apiService.getAutofixState>>\n | undefined","performanceTrace","issue: Awaited<ReturnType<typeof apiService.getIssue>>","autofixState:\n | Awaited<ReturnType<typeof apiService.getAutofixState>>\n | undefined","event: Event"],"sources":["../src/tools/get-issue-details.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { setTag } from \"@sentry/core\";\nimport { defineTool } from \"../internal/tool-helpers/define\";\nimport { apiServiceFromContext } from \"../internal/tool-helpers/api\";\nimport {\n parseIssueParams,\n formatIssueOutput,\n} from \"../internal/tool-helpers/issue\";\nimport { enhanceNotFoundError } from \"../internal/tool-helpers/enhance-error\";\nimport { ApiNotFoundError } from \"../api-client\";\nimport type { SentryApiService } from \"../api-client\";\nimport type {\n Event,\n ErrorEvent,\n DefaultEvent,\n TransactionEvent,\n Trace,\n} from \"../api-client/types\";\nimport { UserInputError } from \"../errors\";\nimport type { ServerContext } from \"../types\";\nimport { logError } from \"../telem/logging\";\nimport {\n ParamOrganizationSlug,\n ParamRegionUrl,\n ParamIssueShortId,\n ParamIssueUrl,\n} from \"../schema\";\n\nexport default defineTool({\n name: \"get_issue_details\",\n requiredSkills: [\"inspect\", \"triage\", \"seer\"], // Available in inspect, triage, and seer skills\n requiredScopes: [\"event:read\"],\n description: [\n \"Get detailed information about a specific Sentry issue by ID.\",\n \"\",\n \"🔍 USE THIS TOOL WHEN USERS:\",\n \"- Provide a specific issue ID (e.g., 'CLOUDFLARE-MCP-41', 'PROJECT-123')\",\n \"- Ask to 'explain [ISSUE-ID]', 'tell me about [ISSUE-ID]'\",\n \"- Want details/stacktrace/analysis for a known issue\",\n \"- Provide a Sentry issue URL\",\n \"\",\n \"❌ DO NOT USE for:\",\n \"- General searching or listing issues (use search_issues)\",\n \"- Root cause analysis (use analyze_issue_with_seer)\",\n \"\",\n \"TRIGGER PATTERNS:\",\n \"- 'Explain ISSUE-123' → use get_issue_details\",\n \"- 'Tell me about PROJECT-456' → use get_issue_details\",\n \"- 'What happened in [issue URL]' → use get_issue_details\",\n \"\",\n \"<examples>\",\n \"### With Sentry URL (recommended - simplest approach)\",\n \"```\",\n \"get_issue_details(issueUrl='https://sentry.sentry.io/issues/6916805731/?project=4509062593708032&query=is%3Aunresolved')\",\n \"```\",\n \"\",\n \"### With issue ID and organization\",\n \"```\",\n \"get_issue_details(organizationSlug='my-organization', issueId='CLOUDFLARE-MCP-41')\",\n \"```\",\n \"\",\n \"### With event ID and organization\",\n \"```\",\n \"get_issue_details(organizationSlug='my-organization', eventId='c49541c747cb4d8aa3efb70ca5aba243')\",\n \"```\",\n \"</examples>\",\n \"\",\n \"<hints>\",\n \"- **IMPORTANT**: If user provides a Sentry URL, pass the ENTIRE URL to issueUrl parameter unchanged\",\n \"- When using issueUrl, all other parameters are automatically extracted - don't provide them separately\",\n \"- If using issueId (not URL), then organizationSlug is required\",\n \"</hints>\",\n ].join(\"\\n\"),\n inputSchema: {\n organizationSlug: ParamOrganizationSlug.optional(),\n regionUrl: ParamRegionUrl.optional(),\n issueId: ParamIssueShortId.optional(),\n eventId: z.string().trim().describe(\"The ID of the event.\").optional(),\n issueUrl: ParamIssueUrl.optional(),\n },\n annotations: {\n readOnlyHint: true,\n openWorldHint: true,\n },\n async handler(params, context: ServerContext) {\n const apiService = apiServiceFromContext(context, {\n regionUrl: params.regionUrl,\n });\n\n if (params.eventId) {\n const orgSlug = params.organizationSlug;\n const eventId = params.eventId; // Capture eventId for type safety\n if (!orgSlug) {\n throw new UserInputError(\n \"`organizationSlug` is required when providing `eventId`\",\n );\n }\n\n setTag(\"organization.slug\", orgSlug);\n // API client will throw ApiClientError/ApiServerError which the MCP server wrapper handles\n const [issue] = await apiService.listIssues({\n organizationSlug: orgSlug,\n query: eventId,\n });\n if (!issue) {\n return `# Event Not Found\\n\\nNo issue found for Event ID: ${eventId}`;\n }\n // For this call, we might want to provide context if it fails\n let event: Awaited<ReturnType<typeof apiService.getEventForIssue>>;\n try {\n event = await apiService.getEventForIssue({\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n eventId,\n });\n } catch (error) {\n // Optionally enhance 404 errors with parameter context\n if (error instanceof ApiNotFoundError) {\n throw enhanceNotFoundError(error, {\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n eventId,\n });\n }\n throw error;\n }\n\n // Try to fetch Seer analysis context (non-blocking)\n let autofixState:\n | Awaited<ReturnType<typeof apiService.getAutofixState>>\n | undefined;\n try {\n autofixState = await apiService.getAutofixState({\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n });\n } catch (error) {\n // Silently continue if Seer analysis is not available\n // This ensures the tool works even if Seer is not enabled\n }\n\n const performanceTrace = await maybeFetchPerformanceTrace({\n apiService,\n organizationSlug: orgSlug,\n event,\n });\n\n return formatIssueOutput({\n organizationSlug: orgSlug,\n issue,\n event,\n apiService,\n autofixState,\n performanceTrace,\n });\n }\n\n // Validate that we have the minimum required parameters\n if (!params.issueUrl && !params.issueId) {\n throw new UserInputError(\n \"Either `issueId` or `issueUrl` must be provided\",\n );\n }\n\n if (!params.issueUrl && !params.organizationSlug) {\n throw new UserInputError(\n \"`organizationSlug` is required when providing `issueId`\",\n );\n }\n\n const { organizationSlug: orgSlug, issueId: parsedIssueId } =\n parseIssueParams({\n organizationSlug: params.organizationSlug,\n issueId: params.issueId,\n issueUrl: params.issueUrl,\n });\n\n setTag(\"organization.slug\", orgSlug);\n\n // For the main issue lookup, provide parameter context on 404\n let issue: Awaited<ReturnType<typeof apiService.getIssue>>;\n try {\n issue = await apiService.getIssue({\n organizationSlug: orgSlug,\n issueId: parsedIssueId!,\n });\n } catch (error) {\n if (error instanceof ApiNotFoundError) {\n throw enhanceNotFoundError(error, {\n organizationSlug: orgSlug,\n issueId: parsedIssueId,\n });\n }\n throw error;\n }\n\n const event = await apiService.getLatestEventForIssue({\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n });\n\n // Try to fetch Seer analysis context (non-blocking)\n let autofixState:\n | Awaited<ReturnType<typeof apiService.getAutofixState>>\n | undefined;\n try {\n autofixState = await apiService.getAutofixState({\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n });\n } catch (error) {\n // Silently continue if Seer analysis is not available\n // This ensures the tool works even if Seer is not enabled\n }\n\n const performanceTrace = await maybeFetchPerformanceTrace({\n apiService,\n organizationSlug: orgSlug,\n event,\n });\n\n return formatIssueOutput({\n organizationSlug: orgSlug,\n issue,\n event,\n apiService,\n autofixState,\n performanceTrace,\n });\n },\n});\n\nasync function maybeFetchPerformanceTrace({\n apiService,\n organizationSlug,\n event,\n}: {\n apiService: SentryApiService;\n organizationSlug: string;\n event: Event;\n}): Promise<Trace | undefined> {\n const context = shouldFetchTraceForEvent(event);\n if (!context) {\n return undefined;\n }\n\n try {\n return await apiService.getTrace({\n organizationSlug,\n traceId: context.traceId,\n limit: 10000,\n });\n } catch (error) {\n logError(error);\n return undefined;\n }\n}\n\nfunction isErrorEvent(event: Event): event is ErrorEvent | DefaultEvent {\n // \"default\" type represents error events without exception data\n return event.type === \"error\" || event.type === \"default\";\n}\n\nfunction isTransactionEvent(event: Event): event is TransactionEvent {\n return event.type === \"transaction\";\n}\n\nfunction shouldFetchTraceForEvent(event: Event): { traceId: string } | null {\n // Only fetch traces for non-error events (transactions, profiling, etc.)\n if (isErrorEvent(event)) {\n return null;\n }\n\n // Check if we have a trace ID\n const traceId = event.contexts?.trace?.trace_id;\n\n if (typeof traceId !== \"string\" || traceId.length === 0) {\n return null;\n }\n\n return { traceId };\n}\n"],"mappings":";;;;;;;;;;;;;AA4BA,gCAAe,WAAW;CACxB,MAAM;CACN,gBAAgB;EAAC;EAAW;EAAU;CAAO;CAC7C,gBAAgB,CAAC,YAAa;CAC9B,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,EAAC,KAAK,KAAK;CACZ,aAAa;EACX,kBAAkB,sBAAsB,UAAU;EAClD,WAAW,eAAe,UAAU;EACpC,SAAS,kBAAkB,UAAU;EACrC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,uBAAuB,CAAC,UAAU;EACtE,UAAU,cAAc,UAAU;CACnC;CACD,aAAa;EACX,cAAc;EACd,eAAe;CAChB;CACD,MAAM,QAAQ,QAAQA,SAAwB;EAC5C,MAAM,aAAa,sBAAsB,SAAS,EAChD,WAAW,OAAO,UACnB,EAAC;AAEF,MAAI,OAAO,SAAS;GAClB,MAAMC,YAAU,OAAO;GACvB,MAAM,UAAU,OAAO;AACvB,QAAKA,UACH,OAAM,IAAI,eACR;A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