@mastra/server 1.79.0-alpha.10 → 1.79.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{a2a-CHBSYHxu.js → a2a-BqLB3McP.js} +17 -16
- package/dist/a2a-BqLB3McP.js.map +1 -0
- package/dist/{a2a-B465DD1u.cjs → a2a-Uood_0DN.cjs} +19 -18
- package/dist/a2a-Uood_0DN.cjs.map +1 -0
- package/dist/agent-builder-CuBD1tpv.cjs +728 -0
- package/dist/agent-builder-CuBD1tpv.cjs.map +1 -0
- package/dist/agent-builder-VhM8ADW-.js +627 -0
- package/dist/agent-builder-VhM8ADW-.js.map +1 -0
- package/dist/{agents-X1E7fW3p.js → agents-BHLTMBff.js} +2 -2
- package/dist/{agents-X1E7fW3p.js.map → agents-BHLTMBff.js.map} +1 -1
- package/dist/agents-BOWEUKyV.cjs +3127 -0
- package/dist/agents-BOWEUKyV.cjs.map +1 -0
- package/dist/agents-DRQ3ScbX.js +2828 -0
- package/dist/agents-DRQ3ScbX.js.map +1 -0
- package/dist/{agents-DoNMSCMt.cjs → agents-T-OIM9IK.cjs} +2 -2
- package/dist/{agents-DoNMSCMt.cjs.map → agents-T-OIM9IK.cjs.map} +1 -1
- package/dist/{api-schema-manifest-DUseI2VG.cjs → api-schema-manifest-A2qfi54Y.cjs} +4 -4
- package/dist/{api-schema-manifest-DUseI2VG.cjs.map → api-schema-manifest-A2qfi54Y.cjs.map} +1 -1
- package/dist/{api-schema-manifest-CWRIJP-B.js → api-schema-manifest-Dun5VMRT.js} +3 -3
- package/dist/{api-schema-manifest-CWRIJP-B.js.map → api-schema-manifest-Dun5VMRT.js.map} +1 -1
- package/dist/{background-tasks-CabImVak.cjs → background-tasks-B3VAKTJh.cjs} +3 -3
- package/dist/{background-tasks-CabImVak.cjs.map → background-tasks-B3VAKTJh.cjs.map} +1 -1
- package/dist/{background-tasks-oBaLtnCn.js → background-tasks-Du2zYOPl.js} +2 -2
- package/dist/{background-tasks-oBaLtnCn.js.map → background-tasks-Du2zYOPl.js.map} +1 -1
- package/dist/{builder-registry-DOkLe8ES.js → builder-registry-DLdu9bWH.js} +3 -3
- package/dist/{builder-registry-DOkLe8ES.js.map → builder-registry-DLdu9bWH.js.map} +1 -1
- package/dist/{builder-registry-D0frV8lQ.cjs → builder-registry-DaFAaMTf.cjs} +3 -3
- package/dist/{builder-registry-D0frV8lQ.cjs.map → builder-registry-DaFAaMTf.cjs.map} +1 -1
- package/dist/{channels-CBIopVWd.cjs → channels-BnVRmnzK.cjs} +6 -3
- package/dist/{channels-CBIopVWd.cjs.map → channels-BnVRmnzK.cjs.map} +1 -1
- package/dist/{channels-BOxgHvzI.js → channels-Db-4pXVZ.js} +6 -3
- package/dist/{channels-BOxgHvzI.js.map → channels-Db-4pXVZ.js.map} +1 -1
- package/dist/conversations-8BWryNlF.js +165 -0
- package/dist/conversations-8BWryNlF.js.map +1 -0
- package/dist/conversations-C5MkQBB8.cjs +194 -0
- package/dist/conversations-C5MkQBB8.cjs.map +1 -0
- package/dist/{conversations-Bj5TLNqF.cjs → conversations-DasqEDCF.cjs} +3 -3
- package/dist/{conversations-Bj5TLNqF.cjs.map → conversations-DasqEDCF.cjs.map} +1 -1
- package/dist/{dist-9c3PXXpk.cjs → dist-B-bEVWlJ.cjs} +4733 -1251
- package/dist/dist-B-bEVWlJ.cjs.map +1 -0
- package/dist/dist-B3kC8Yd0.cjs +3 -0
- package/dist/{dist-CQ3FSKT-.cjs → dist-B9ery9Zw.cjs} +38 -35
- package/dist/{dist-CQ3FSKT-.cjs.map → dist-B9ery9Zw.cjs.map} +1 -1
- package/dist/{dist-BxMmGD3n.js → dist-BBOnrL_A.js} +10 -12
- package/dist/{dist-BxMmGD3n.js.map → dist-BBOnrL_A.js.map} +1 -1
- package/dist/{dist-DOWsEmo6.js → dist-BIrQLUV9.js} +20 -20
- package/dist/{dist-DOWsEmo6.js.map → dist-BIrQLUV9.js.map} +1 -1
- package/dist/dist-BM9J-PTK.js +1 -0
- package/dist/{dist-DC1Pewf5.cjs → dist-Bo3GdQwf.cjs} +21 -21
- package/dist/{dist-DC1Pewf5.cjs.map → dist-Bo3GdQwf.cjs.map} +1 -1
- package/dist/{dist-BwYL7Ykb.js → dist-CREG82cy.js} +37 -34
- package/dist/{dist-BwYL7Ykb.js.map → dist-CREG82cy.js.map} +1 -1
- package/dist/{dist-rDRetJVY.cjs → dist-CeTLA-e5.cjs} +2 -3
- package/dist/{dist-rDRetJVY.cjs.map → dist-CeTLA-e5.cjs.map} +1 -1
- package/dist/{dist-CBRJax5e.js → dist-DLld1qjf.js} +25 -31
- package/dist/{dist-CBRJax5e.js.map → dist-DLld1qjf.js.map} +1 -1
- package/dist/{dist-B_bet8uz.js → dist-DjkPkAzV.js} +2 -3
- package/dist/{dist-B_bet8uz.js.map → dist-DjkPkAzV.js.map} +1 -1
- package/dist/{dist-UKEksCGq.cjs → dist-DsrJXwic.cjs} +11 -13
- package/dist/{dist-UKEksCGq.cjs.map → dist-DsrJXwic.cjs.map} +1 -1
- package/dist/{dist-DGCnbhNe.js → dist-k77XQGUn.js} +4493 -1043
- package/dist/dist-k77XQGUn.js.map +1 -0
- package/dist/{dist-3FPW9nVj.cjs → dist-lT2rqyY9.cjs} +26 -32
- package/dist/{dist-3FPW9nVj.cjs.map → dist-lT2rqyY9.cjs.map} +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/{dynamic-workflows-Rr_6ac1y.js → dynamic-workflows-CTUO0SFu.js} +3 -3
- package/dist/{dynamic-workflows-Rr_6ac1y.js.map → dynamic-workflows-CTUO0SFu.js.map} +1 -1
- package/dist/{dynamic-workflows-DXlkr-jK.cjs → dynamic-workflows-HwPX3mcf.cjs} +3 -3
- package/dist/{dynamic-workflows-DXlkr-jK.cjs.map → dynamic-workflows-HwPX3mcf.cjs.map} +1 -1
- package/dist/{editor-builder-BclcHxN6.cjs → editor-builder-BDtiWw0f.cjs} +2 -2
- package/dist/{editor-builder-BclcHxN6.cjs.map → editor-builder-BDtiWw0f.cjs.map} +1 -1
- package/dist/{editor-builder-D16kc1P6.js → editor-builder-ClFlGXoX.js} +4 -4
- package/dist/{editor-builder-D16kc1P6.js.map → editor-builder-ClFlGXoX.js.map} +1 -1
- package/dist/{editor-builder-s9WqPJgA.js → editor-builder-DnLCfqnY.js} +2 -2
- package/dist/{editor-builder-s9WqPJgA.js.map → editor-builder-DnLCfqnY.js.map} +1 -1
- package/dist/{editor-builder-DXHiPX1A.cjs → editor-builder-DtpP1FtW.cjs} +5 -5
- package/dist/{editor-builder-DXHiPX1A.cjs.map → editor-builder-DtpP1FtW.cjs.map} +1 -1
- package/dist/{helpers-ElhPeCSK.cjs → helpers-CAcEhq38.cjs} +21 -17
- package/dist/{helpers-ElhPeCSK.cjs.map → helpers-CAcEhq38.cjs.map} +1 -1
- package/dist/{helpers-DLhX1fqc.js → helpers-vrqddDd5.js} +21 -17
- package/dist/{helpers-DLhX1fqc.js.map → helpers-vrqddDd5.js.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/logs-CiSw7r0s.cjs +119 -0
- package/dist/logs-CiSw7r0s.cjs.map +1 -0
- package/dist/logs-CxfPk-iL.js +96 -0
- package/dist/logs-CxfPk-iL.js.map +1 -0
- package/dist/mcp-BTdLh6E_.js +274 -0
- package/dist/mcp-BTdLh6E_.js.map +1 -0
- package/dist/mcp-BYqFR5q-.cjs +339 -0
- package/dist/mcp-BYqFR5q-.cjs.map +1 -0
- package/dist/memory-BHtTSzvJ.js +1739 -0
- package/dist/memory-BHtTSzvJ.js.map +1 -0
- package/dist/memory-CwwkVDh1.cjs +1906 -0
- package/dist/memory-CwwkVDh1.cjs.map +1 -0
- package/dist/observability-BBMCMeT-.cjs +502 -0
- package/dist/observability-BBMCMeT-.cjs.map +1 -0
- package/dist/observability-ZRgRcvoX.js +431 -0
- package/dist/observability-ZRgRcvoX.js.map +1 -0
- package/dist/{observability-new-endpoints-BU8JYPfh.js → observability-new-endpoints-fjoZzEtk.js} +10 -9
- package/dist/{observability-new-endpoints-BU8JYPfh.js.map → observability-new-endpoints-fjoZzEtk.js.map} +1 -1
- package/dist/{observability-new-endpoints-AMp9bnMV.cjs → observability-new-endpoints-tG3-odLa.cjs} +11 -10
- package/dist/observability-new-endpoints-tG3-odLa.cjs.map +1 -0
- package/dist/plans-CiPgWBhO.cjs +68 -0
- package/dist/plans-CiPgWBhO.cjs.map +1 -0
- package/dist/plans-DCepEY7n.js +57 -0
- package/dist/plans-DCepEY7n.js.map +1 -0
- package/dist/{probe-image-size-DBGjhUtJ.cjs → probe-image-size-Alv3gwKl.cjs} +194 -184
- package/dist/probe-image-size-Alv3gwKl.cjs.map +1 -0
- package/dist/{probe-image-size-Dmoxv93t.js → probe-image-size-BdfbUHxx.js} +158 -148
- package/dist/probe-image-size-BdfbUHxx.js.map +1 -0
- package/dist/responses-4FwMNxoJ.js +628 -0
- package/dist/responses-4FwMNxoJ.js.map +1 -0
- package/dist/responses-CCRijwDF.cjs +651 -0
- package/dist/responses-CCRijwDF.cjs.map +1 -0
- package/dist/{responses-CKNdSRkS.cjs → responses-CfcIc53b.cjs} +2 -2
- package/dist/{responses-CKNdSRkS.cjs.map → responses-CfcIc53b.cjs.map} +1 -1
- package/dist/{rolldown-runtime-Bd6kNlEP.cjs → rolldown-runtime-BwC_XMyb.cjs} +2 -2
- package/dist/{rolldown-runtime-maW3aOIk.js → rolldown-runtime-D3Hj5m0v.js} +2 -2
- package/dist/{route-builder-BNZs643f.cjs → route-builder-B2Qhhd7C.cjs} +52 -66
- package/dist/route-builder-B2Qhhd7C.cjs.map +1 -0
- package/dist/{route-builder-BfQYtclb.js → route-builder-CjkWxv4E.js} +51 -65
- package/dist/route-builder-CjkWxv4E.js.map +1 -0
- package/dist/{routes-Dl6_kWm7.js → routes-CKfXiwRc.js} +5 -3
- package/dist/routes-CKfXiwRc.js.map +1 -0
- package/dist/{routes-rwufkyUe.js → routes-D1cP2OeF.js} +26 -26
- package/dist/{routes-rwufkyUe.js.map → routes-D1cP2OeF.js.map} +1 -1
- package/dist/{routes-DPojsNf1.cjs → routes-bxG4x1MV.cjs} +199 -199
- package/dist/{routes-DPojsNf1.cjs.map → routes-bxG4x1MV.cjs.map} +1 -1
- package/dist/{routes-BULZI-PU.cjs → routes-jXksmX9G.cjs} +5 -3
- package/dist/routes-jXksmX9G.cjs.map +1 -0
- package/dist/{schedules-Bj-giFbc.cjs → schedules-CTTTCgbk.cjs} +3 -3
- package/dist/{schedules-Bj-giFbc.cjs.map → schedules-CTTTCgbk.cjs.map} +1 -1
- package/dist/{schedules-BQYgaz66.js → schedules-DXh37n6-.js} +2 -2
- package/dist/{schedules-BQYgaz66.js.map → schedules-DXh37n6-.js.map} +1 -1
- package/dist/{schema-e0VHpMt0-C0452jOk.cjs → schema-CzbEIyhE-20gGIWkz.cjs} +83 -88
- package/dist/schema-CzbEIyhE-20gGIWkz.cjs.map +1 -0
- package/dist/{schema-e0VHpMt0-CVP5Hnxy.js → schema-CzbEIyhE-BsMcj9Ws.js} +82 -87
- package/dist/schema-CzbEIyhE-BsMcj9Ws.js.map +1 -0
- package/dist/scores-D9UgETt_.js +288 -0
- package/dist/scores-D9UgETt_.js.map +1 -0
- package/dist/scores-DRdtS7NT.cjs +329 -0
- package/dist/scores-DRdtS7NT.cjs.map +1 -0
- package/dist/server/a2a/store.cjs +1 -1
- package/dist/server/auth/index.cjs +2 -2
- package/dist/server/auth/index.js +1 -1
- package/dist/server/browser-stream/index.cjs +9 -11
- package/dist/server/browser-stream/index.cjs.map +1 -1
- package/dist/server/browser-stream/index.js +8 -10
- package/dist/server/browser-stream/index.js.map +1 -1
- package/dist/server/handlers/a2a.cjs +2 -2
- package/dist/server/handlers/a2a.js +1 -2
- package/dist/server/handlers/agent-builder.cjs +18 -648
- package/dist/server/handlers/agent-builder.js +1 -627
- package/dist/server/handlers/agent-controller.cjs +5 -5
- package/dist/server/handlers/agent-controller.cjs.map +1 -1
- package/dist/server/handlers/agent-controller.js +11 -9
- package/dist/server/handlers/agent-controller.js.map +1 -1
- package/dist/server/handlers/agent-versions.cjs +15 -8
- package/dist/server/handlers/agent-versions.cjs.map +1 -1
- package/dist/server/handlers/agent-versions.js +14 -7
- package/dist/server/handlers/agent-versions.js.map +1 -1
- package/dist/server/handlers/agents.cjs +51 -2860
- package/dist/server/handlers/agents.js +1 -2806
- package/dist/server/handlers/auth.cjs +14 -12
- package/dist/server/handlers/auth.cjs.map +1 -1
- package/dist/server/handlers/auth.js +20 -16
- package/dist/server/handlers/auth.js.map +1 -1
- package/dist/server/handlers/author-enrichment.cjs +1 -1
- package/dist/server/handlers/authorship.cjs +1 -1
- package/dist/server/handlers/authorship.cjs.map +1 -1
- package/dist/server/handlers/background-tasks.cjs +2 -2
- package/dist/server/handlers/background-tasks.js +1 -2
- package/dist/server/handlers/builder-registry.cjs +2 -2
- package/dist/server/handlers/builder-registry.js +1 -2
- package/dist/server/handlers/channels.cjs +2 -2
- package/dist/server/handlers/channels.js +1 -2
- package/dist/server/handlers/conversations.cjs +6 -171
- package/dist/server/handlers/conversations.js +1 -162
- package/dist/server/handlers/datasets.cjs +2 -2
- package/dist/server/handlers/datasets.cjs.map +1 -1
- package/dist/server/handlers/datasets.js +1 -1
- package/dist/server/handlers/dynamic-workflows.cjs +2 -2
- package/dist/server/handlers/dynamic-workflows.js +1 -2
- package/dist/server/handlers/editor-builder.cjs +2 -2
- package/dist/server/handlers/editor-builder.js +1 -2
- package/dist/server/handlers/error.cjs +18 -13
- package/dist/server/handlers/error.cjs.map +1 -1
- package/dist/server/handlers/error.js +17 -12
- package/dist/server/handlers/error.js.map +1 -1
- package/dist/server/handlers/favorites-enrichment.cjs +2 -2
- package/dist/server/handlers/favorites-enrichment.js +1 -1
- package/dist/server/handlers/gateway-memory-client.cjs +1 -1
- package/dist/server/handlers/logs.cjs +5 -104
- package/dist/server/handlers/logs.js +1 -96
- package/dist/server/handlers/mcp-client-versions.cjs +15 -8
- package/dist/server/handlers/mcp-client-versions.cjs.map +1 -1
- package/dist/server/handlers/mcp-client-versions.js +14 -7
- package/dist/server/handlers/mcp-client-versions.js.map +1 -1
- package/dist/server/handlers/mcp.cjs +12 -289
- package/dist/server/handlers/mcp.js +1 -274
- package/dist/server/handlers/memory.cjs +29 -1763
- package/dist/server/handlers/memory.js +1 -1731
- package/dist/server/handlers/observability-list-query-schemas.cjs +1 -1
- package/dist/server/handlers/observability-new-endpoints.cjs +2 -2
- package/dist/server/handlers/observability-new-endpoints.js +1 -2
- package/dist/server/handlers/observability-shared.cjs +2 -2
- package/dist/server/handlers/observability-shared.js +1 -1
- package/dist/server/handlers/observability-storage-schemas.cjs +1 -1
- package/dist/server/handlers/observability.cjs +14 -445
- package/dist/server/handlers/observability.js +3 -429
- package/dist/server/handlers/plans.cjs +3 -63
- package/dist/server/handlers/plans.js +1 -57
- package/dist/server/handlers/processor-providers.cjs +2 -2
- package/dist/server/handlers/processor-providers.cjs.map +1 -1
- package/dist/server/handlers/processor-providers.js +1 -1
- package/dist/server/handlers/processors.cjs +13 -15
- package/dist/server/handlers/processors.cjs.map +1 -1
- package/dist/server/handlers/processors.js +12 -14
- package/dist/server/handlers/processors.js.map +1 -1
- package/dist/server/handlers/prompt-block-versions.cjs +15 -8
- package/dist/server/handlers/prompt-block-versions.cjs.map +1 -1
- package/dist/server/handlers/prompt-block-versions.js +14 -7
- package/dist/server/handlers/prompt-block-versions.js.map +1 -1
- package/dist/server/handlers/responses.adapter.cjs +1 -1
- package/dist/server/handlers/responses.adapter.cjs.map +1 -1
- package/dist/server/handlers/responses.cjs +5 -632
- package/dist/server/handlers/responses.js +1 -624
- package/dist/server/handlers/responses.storage.cjs +2 -2
- package/dist/server/handlers/schedules-workflows-shim.cjs +1 -1
- package/dist/server/handlers/schedules.cjs +2 -2
- package/dist/server/handlers/schedules.js +1 -2
- package/dist/server/handlers/scorer-versions.cjs +15 -8
- package/dist/server/handlers/scorer-versions.cjs.map +1 -1
- package/dist/server/handlers/scorer-versions.js +14 -7
- package/dist/server/handlers/scorer-versions.js.map +1 -1
- package/dist/server/handlers/scores.cjs +8 -299
- package/dist/server/handlers/scores.js +1 -288
- package/dist/server/handlers/skills-sh-shared.cjs +1 -1
- package/dist/server/handlers/stored-agent-favorites.cjs +4 -4
- package/dist/server/handlers/stored-agent-favorites.js +3 -3
- package/dist/server/handlers/stored-agents.cjs +19 -13
- package/dist/server/handlers/stored-agents.cjs.map +1 -1
- package/dist/server/handlers/stored-agents.js +18 -12
- package/dist/server/handlers/stored-agents.js.map +1 -1
- package/dist/server/handlers/stored-mcp-clients.cjs +8 -6
- package/dist/server/handlers/stored-mcp-clients.cjs.map +1 -1
- package/dist/server/handlers/stored-mcp-clients.js +7 -5
- package/dist/server/handlers/stored-mcp-clients.js.map +1 -1
- package/dist/server/handlers/stored-prompt-blocks.cjs +3 -3
- package/dist/server/handlers/stored-prompt-blocks.js +2 -2
- package/dist/server/handlers/stored-scorers.cjs +3 -3
- package/dist/server/handlers/stored-scorers.js +2 -2
- package/dist/server/handlers/stored-skill-favorites.cjs +4 -4
- package/dist/server/handlers/stored-skill-favorites.js +3 -3
- package/dist/server/handlers/stored-skills.cjs +6 -5
- package/dist/server/handlers/stored-skills.cjs.map +1 -1
- package/dist/server/handlers/stored-skills.js +5 -4
- package/dist/server/handlers/stored-skills.js.map +1 -1
- package/dist/server/handlers/stored-workspaces.cjs +3 -3
- package/dist/server/handlers/stored-workspaces.js +2 -2
- package/dist/server/handlers/system.cjs +3 -3
- package/dist/server/handlers/system.cjs.map +1 -1
- package/dist/server/handlers/system.js +2 -2
- package/dist/server/handlers/test-utils.cjs +1 -1
- package/dist/server/handlers/tool-providers.cjs +2 -2
- package/dist/server/handlers/tool-providers.js +1 -1
- package/dist/server/handlers/tool-schema-overrides.cjs +1 -1
- package/dist/server/handlers/tools.cjs +7 -267
- package/dist/server/handlers/tools.js +1 -257
- package/dist/server/handlers/utils.cjs +2 -2
- package/dist/server/handlers/utils.js +1 -2
- package/dist/server/handlers/validate-agent-instructions.cjs +2 -2
- package/dist/server/handlers/validate-agent-instructions.js +1 -1
- package/dist/server/handlers/validate-avatar.cjs +2 -2
- package/dist/server/handlers/validate-avatar.cjs.map +1 -1
- package/dist/server/handlers/validate-avatar.js +1 -1
- package/dist/server/handlers/validate-avatar.js.map +1 -1
- package/dist/server/handlers/vector.cjs +17 -334
- package/dist/server/handlers/vector.js +1 -314
- package/dist/server/handlers/version-helpers.cjs +1 -1
- package/dist/server/handlers/voice.cjs +9 -35
- package/dist/server/handlers/voice.js +1 -23
- package/dist/server/handlers/workflow-builder.cjs +2 -2
- package/dist/server/handlers/workflow-builder.js +1 -2
- package/dist/server/handlers/workflows.cjs +30 -1293
- package/dist/server/handlers/workflows.js +1 -1257
- package/dist/server/handlers/workspace.cjs +27 -1176
- package/dist/server/handlers/workspace.js +1 -1146
- package/dist/server/handlers.cjs +33 -33
- package/dist/server/handlers.js +17 -17
- package/dist/server/schemas/index.cjs +6 -6
- package/dist/server/schemas/index.js +3 -3
- package/dist/server/server-adapter/index.cjs +5 -5
- package/dist/server/server-adapter/index.cjs.map +1 -1
- package/dist/server/server-adapter/index.js +4 -4
- package/dist/server/server-adapter/index.js.map +1 -1
- package/dist/tools-CmFSfDMn.js +256 -0
- package/dist/tools-CmFSfDMn.js.map +1 -0
- package/dist/tools-SPJtxG9N.cjs +291 -0
- package/dist/tools-SPJtxG9N.cjs.map +1 -0
- package/dist/{utils-DCgeTrq2.cjs → utils-CF76qzZR.cjs} +12 -17
- package/dist/{utils-DCgeTrq2.cjs.map → utils-CF76qzZR.cjs.map} +1 -1
- package/dist/{utils-DCAUeb6M.js → utils-aoLN3Wfi.js} +11 -16
- package/dist/{utils-DCAUeb6M.js.map → utils-aoLN3Wfi.js.map} +1 -1
- package/dist/{utils-Du-EpvDs.cjs → utils-dDLIDg8O.cjs} +2 -2
- package/dist/{utils-Du-EpvDs.cjs.map → utils-dDLIDg8O.cjs.map} +1 -1
- package/dist/vector-BKDD1kwc.cjs +409 -0
- package/dist/vector-BKDD1kwc.cjs.map +1 -0
- package/dist/vector-TWv4t-4g.js +314 -0
- package/dist/vector-TWv4t-4g.js.map +1 -0
- package/dist/voice-BnGwlZ75.cjs +70 -0
- package/dist/voice-BnGwlZ75.cjs.map +1 -0
- package/dist/voice-DjG8tBAD.js +23 -0
- package/dist/voice-DjG8tBAD.js.map +1 -0
- package/dist/{workflow-builder-Brj3IArM.cjs → workflow-builder-C9-8ZOWF.cjs} +5 -5
- package/dist/{workflow-builder-Brj3IArM.cjs.map → workflow-builder-C9-8ZOWF.cjs.map} +1 -1
- package/dist/{workflow-builder-DOa1Vx6w.js → workflow-builder-CjlLoQvo.js} +10 -8
- package/dist/{workflow-builder-DOa1Vx6w.js.map → workflow-builder-CjlLoQvo.js.map} +1 -1
- package/dist/workflows-DjqeJcdJ.cjs +1446 -0
- package/dist/workflows-DjqeJcdJ.cjs.map +1 -0
- package/dist/workflows-bb-otd2o.js +1273 -0
- package/dist/workflows-bb-otd2o.js.map +1 -0
- package/dist/workspace-B6kzp-bo.js +1154 -0
- package/dist/workspace-B6kzp-bo.js.map +1 -0
- package/dist/workspace-COKR1SxH.cjs +1309 -0
- package/dist/workspace-COKR1SxH.cjs.map +1 -0
- package/package.json +4 -4
- package/dist/a2a-B465DD1u.cjs.map +0 -1
- package/dist/a2a-CHBSYHxu.js.map +0 -1
- package/dist/dist-9c3PXXpk.cjs.map +0 -1
- package/dist/dist-B5OwHWTo.cjs +0 -2294
- package/dist/dist-B5OwHWTo.cjs.map +0 -1
- package/dist/dist-DGCnbhNe.js.map +0 -1
- package/dist/dist-DcoIg_tp.js +0 -2293
- package/dist/dist-DcoIg_tp.js.map +0 -1
- package/dist/observability-new-endpoints-AMp9bnMV.cjs.map +0 -1
- package/dist/probe-image-size-DBGjhUtJ.cjs.map +0 -1
- package/dist/probe-image-size-Dmoxv93t.js.map +0 -1
- package/dist/route-builder-BNZs643f.cjs.map +0 -1
- package/dist/route-builder-BfQYtclb.js.map +0 -1
- package/dist/routes-BULZI-PU.cjs.map +0 -1
- package/dist/routes-Dl6_kWm7.js.map +0 -1
- package/dist/schema-Drf2W04o.js +0 -2
- package/dist/schema-EQanefYq.cjs +0 -1
- package/dist/schema-e0VHpMt0-C0452jOk.cjs.map +0 -1
- package/dist/schema-e0VHpMt0-CVP5Hnxy.js.map +0 -1
- package/dist/server/handlers/agent-builder.cjs.map +0 -1
- package/dist/server/handlers/agent-builder.js.map +0 -1
- package/dist/server/handlers/agents.cjs.map +0 -1
- package/dist/server/handlers/agents.js.map +0 -1
- package/dist/server/handlers/conversations.cjs.map +0 -1
- package/dist/server/handlers/conversations.js.map +0 -1
- package/dist/server/handlers/logs.cjs.map +0 -1
- package/dist/server/handlers/logs.js.map +0 -1
- package/dist/server/handlers/mcp.cjs.map +0 -1
- package/dist/server/handlers/mcp.js.map +0 -1
- package/dist/server/handlers/memory.cjs.map +0 -1
- package/dist/server/handlers/memory.js.map +0 -1
- package/dist/server/handlers/observability.cjs.map +0 -1
- package/dist/server/handlers/observability.js.map +0 -1
- package/dist/server/handlers/plans.cjs.map +0 -1
- package/dist/server/handlers/plans.js.map +0 -1
- package/dist/server/handlers/responses.cjs.map +0 -1
- package/dist/server/handlers/responses.js.map +0 -1
- package/dist/server/handlers/scores.cjs.map +0 -1
- package/dist/server/handlers/scores.js.map +0 -1
- package/dist/server/handlers/tools.cjs.map +0 -1
- package/dist/server/handlers/tools.js.map +0 -1
- package/dist/server/handlers/vector.cjs.map +0 -1
- package/dist/server/handlers/vector.js.map +0 -1
- package/dist/server/handlers/voice.cjs.map +0 -1
- package/dist/server/handlers/voice.js.map +0 -1
- package/dist/server/handlers/workflows.cjs.map +0 -1
- package/dist/server/handlers/workflows.js.map +0 -1
- package/dist/server/handlers/workspace.cjs.map +0 -1
- package/dist/server/handlers/workspace.js.map +0 -1
- package/dist/sync-Ai_ZDz7U.js +0 -1700
- package/dist/sync-Ai_ZDz7U.js.map +0 -1
- package/dist/sync-BrO5MtSe.cjs +0 -1729
- package/dist/sync-BrO5MtSe.cjs.map +0 -1
|
@@ -0,0 +1,1309 @@
|
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-BwC_XMyb.cjs");
|
|
2
|
+
const require_http_exception = require("./http-exception-CKDHupKw.cjs");
|
|
3
|
+
const require_route_builder = require("./route-builder-B2Qhhd7C.cjs");
|
|
4
|
+
const require_server_handlers_error = require("./server/handlers/error.cjs");
|
|
5
|
+
const require_workspace = require("./workspace-BJYV2lkt.cjs");
|
|
6
|
+
let _mastra_core_features = require("@mastra/core/features");
|
|
7
|
+
//#region src/server/handlers/workspace.ts
|
|
8
|
+
/**
|
|
9
|
+
* Workspace Handlers
|
|
10
|
+
*
|
|
11
|
+
* Unified handlers for workspace operations including:
|
|
12
|
+
* - Filesystem operations (read, write, list, delete, mkdir, stat)
|
|
13
|
+
* - Search operations (search, index)
|
|
14
|
+
* - Skills operations (list, get, search, references)
|
|
15
|
+
*/
|
|
16
|
+
var workspace_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
17
|
+
GET_WORKSPACE_ROUTE: () => GET_WORKSPACE_ROUTE,
|
|
18
|
+
LIST_WORKSPACES_ROUTE: () => LIST_WORKSPACES_ROUTE,
|
|
19
|
+
WORKSPACE_FS_DELETE_ROUTE: () => WORKSPACE_FS_DELETE_ROUTE,
|
|
20
|
+
WORKSPACE_FS_LIST_ROUTE: () => WORKSPACE_FS_LIST_ROUTE,
|
|
21
|
+
WORKSPACE_FS_MKDIR_ROUTE: () => WORKSPACE_FS_MKDIR_ROUTE,
|
|
22
|
+
WORKSPACE_FS_READ_ROUTE: () => WORKSPACE_FS_READ_ROUTE,
|
|
23
|
+
WORKSPACE_FS_ROUTES: () => WORKSPACE_FS_ROUTES,
|
|
24
|
+
WORKSPACE_FS_STAT_ROUTE: () => WORKSPACE_FS_STAT_ROUTE,
|
|
25
|
+
WORKSPACE_FS_WRITE_ROUTE: () => WORKSPACE_FS_WRITE_ROUTE,
|
|
26
|
+
WORKSPACE_GET_SKILL_REFERENCE_ROUTE: () => WORKSPACE_GET_SKILL_REFERENCE_ROUTE,
|
|
27
|
+
WORKSPACE_GET_SKILL_ROUTE: () => WORKSPACE_GET_SKILL_ROUTE,
|
|
28
|
+
WORKSPACE_INDEX_ROUTE: () => WORKSPACE_INDEX_ROUTE,
|
|
29
|
+
WORKSPACE_LIST_SKILLS_ROUTE: () => WORKSPACE_LIST_SKILLS_ROUTE,
|
|
30
|
+
WORKSPACE_LIST_SKILL_REFERENCES_ROUTE: () => WORKSPACE_LIST_SKILL_REFERENCES_ROUTE,
|
|
31
|
+
WORKSPACE_SEARCH_ROUTE: () => WORKSPACE_SEARCH_ROUTE,
|
|
32
|
+
WORKSPACE_SEARCH_ROUTES: () => WORKSPACE_SEARCH_ROUTES,
|
|
33
|
+
WORKSPACE_SEARCH_SKILLS_ROUTE: () => WORKSPACE_SEARCH_SKILLS_ROUTE,
|
|
34
|
+
WORKSPACE_SKILLS_ROUTES: () => WORKSPACE_SKILLS_ROUTES,
|
|
35
|
+
WORKSPACE_SKILLS_SH_INSTALL_ROUTE: () => WORKSPACE_SKILLS_SH_INSTALL_ROUTE,
|
|
36
|
+
WORKSPACE_SKILLS_SH_POPULAR_ROUTE: () => WORKSPACE_SKILLS_SH_POPULAR_ROUTE,
|
|
37
|
+
WORKSPACE_SKILLS_SH_PREVIEW_ROUTE: () => WORKSPACE_SKILLS_SH_PREVIEW_ROUTE,
|
|
38
|
+
WORKSPACE_SKILLS_SH_REMOVE_ROUTE: () => WORKSPACE_SKILLS_SH_REMOVE_ROUTE,
|
|
39
|
+
WORKSPACE_SKILLS_SH_ROUTES: () => WORKSPACE_SKILLS_SH_ROUTES,
|
|
40
|
+
WORKSPACE_SKILLS_SH_SEARCH_ROUTE: () => WORKSPACE_SKILLS_SH_SEARCH_ROUTE,
|
|
41
|
+
WORKSPACE_SKILLS_SH_UPDATE_ROUTE: () => WORKSPACE_SKILLS_SH_UPDATE_ROUTE
|
|
42
|
+
});
|
|
43
|
+
/** Directory path for skills installed via skills.sh */
|
|
44
|
+
const SKILLS_SH_DIR = ".agents/skills";
|
|
45
|
+
/**
|
|
46
|
+
* Runtime check for CompositeFilesystem using duck typing.
|
|
47
|
+
* Uses a type-only import so older @mastra/core versions (< 1.3.0) work fine.
|
|
48
|
+
*/
|
|
49
|
+
function isCompositeFilesystem(fs) {
|
|
50
|
+
return !!fs && typeof fs === "object" && "mounts" in fs && fs.mounts instanceof Map;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Check if an error is a workspace filesystem not-found error.
|
|
54
|
+
* Handles Node.js ENOENT and workspace FileNotFoundError/DirectoryNotFoundError.
|
|
55
|
+
*/
|
|
56
|
+
function isFilesystemNotFoundError(error) {
|
|
57
|
+
if (!error || typeof error !== "object") return false;
|
|
58
|
+
if ("code" in error && error.code === "ENOENT") return true;
|
|
59
|
+
if ("name" in error) {
|
|
60
|
+
const name = error.name;
|
|
61
|
+
if (name === "FileNotFoundError" || name === "DirectoryNotFoundError") return true;
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Check if an error is a workspace filesystem permission error.
|
|
67
|
+
* Handles Node.js EACCES and workspace PermissionError.
|
|
68
|
+
*/
|
|
69
|
+
function isFilesystemPermissionError(error) {
|
|
70
|
+
if (!error || typeof error !== "object") return false;
|
|
71
|
+
if ("code" in error && error.code === "EACCES") return true;
|
|
72
|
+
if ("name" in error && error.name === "PermissionError") return true;
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Workspace-specific error handler.
|
|
77
|
+
* Converts filesystem errors to appropriate HTTP status codes,
|
|
78
|
+
* then falls back to generic handler.
|
|
79
|
+
*/
|
|
80
|
+
function handleWorkspaceError(error, defaultMessage) {
|
|
81
|
+
if (isFilesystemNotFoundError(error)) {
|
|
82
|
+
const message = error instanceof Error ? error.message : "Not found";
|
|
83
|
+
throw new require_http_exception.HTTPException(404, { message });
|
|
84
|
+
}
|
|
85
|
+
if (isFilesystemPermissionError(error)) {
|
|
86
|
+
const message = error instanceof Error ? error.message : "Permission denied";
|
|
87
|
+
throw new require_http_exception.HTTPException(403, { message });
|
|
88
|
+
}
|
|
89
|
+
return require_server_handlers_error.handleError(error, defaultMessage);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Throws if workspace v1 is not supported by the current version of @mastra/core.
|
|
93
|
+
*/
|
|
94
|
+
function requireWorkspaceV1Support() {
|
|
95
|
+
if (!_mastra_core_features.coreFeatures.has("workspaces-v1")) throw new require_http_exception.HTTPException(501, { message: "Workspace v1 not supported by this version of @mastra/core. Please upgrade to a newer version." });
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get a workspace by ID from Mastra's workspace registry.
|
|
99
|
+
*
|
|
100
|
+
* Backwards compatible: Falls back to searching through agents if
|
|
101
|
+
* mastra.getWorkspaceById() is not available (older @mastra/core versions).
|
|
102
|
+
*/
|
|
103
|
+
async function getWorkspaceById(mastra, workspaceId) {
|
|
104
|
+
requireWorkspaceV1Support();
|
|
105
|
+
const globalWorkspace = mastra.getWorkspace?.();
|
|
106
|
+
if (globalWorkspace?.id === workspaceId) return globalWorkspace;
|
|
107
|
+
if (typeof mastra.getWorkspaceById === "function") try {
|
|
108
|
+
return mastra.getWorkspaceById(workspaceId);
|
|
109
|
+
} catch {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const agents = mastra.listAgents?.() ?? {};
|
|
113
|
+
for (const agent of Object.values(agents)) if (agent.hasOwnWorkspace?.()) {
|
|
114
|
+
const agentWorkspace = await agent.getWorkspace?.();
|
|
115
|
+
if (agentWorkspace?.id === workspaceId) return agentWorkspace;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get skills from a specific workspace by ID.
|
|
120
|
+
* Note: getWorkspaceById already checks for workspace v1 support.
|
|
121
|
+
*/
|
|
122
|
+
async function getSkillsById(mastra, workspaceId) {
|
|
123
|
+
return (await getWorkspaceById(mastra, workspaceId))?.skills;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Build the install path for a skill from skills.sh.
|
|
127
|
+
*
|
|
128
|
+
* For CompositeFilesystem: resolves the requested mount (or first writable),
|
|
129
|
+
* validates it is writable, and returns `<mount>/.agents/skills/<skillId>`.
|
|
130
|
+
* For non-composite: returns `.agents/skills/<skillId>` (unchanged behavior).
|
|
131
|
+
*/
|
|
132
|
+
/** Strip a single trailing slash (leaves `/` alone). */
|
|
133
|
+
function stripTrailingSlash(p) {
|
|
134
|
+
return p.length > 1 && p.endsWith("/") ? p.slice(0, -1) : p;
|
|
135
|
+
}
|
|
136
|
+
function buildSkillInstallPath(filesystem, safeSkillId, requestedMount) {
|
|
137
|
+
if (isCompositeFilesystem(filesystem)) {
|
|
138
|
+
if (requestedMount) {
|
|
139
|
+
const mountFs = filesystem.mounts.get(requestedMount);
|
|
140
|
+
if (!mountFs) throw new require_http_exception.HTTPException(400, { message: `Mount "${requestedMount}" not found. Available mounts: ${filesystem.mountPaths.join(", ")}` });
|
|
141
|
+
if (mountFs.readOnly) throw new require_http_exception.HTTPException(403, { message: `Mount "${requestedMount}" is read-only` });
|
|
142
|
+
return `${stripTrailingSlash(requestedMount)}/${SKILLS_SH_DIR}/${safeSkillId}`;
|
|
143
|
+
}
|
|
144
|
+
for (const [mountPath, mountFs] of filesystem.mounts) if (!mountFs.readOnly) return `${stripTrailingSlash(mountPath)}/${SKILLS_SH_DIR}/${safeSkillId}`;
|
|
145
|
+
throw new require_http_exception.HTTPException(403, { message: "No writable mount available for skill installation" });
|
|
146
|
+
}
|
|
147
|
+
return `${SKILLS_SH_DIR}/${safeSkillId}`;
|
|
148
|
+
}
|
|
149
|
+
const LIST_WORKSPACES_ROUTE = require_route_builder.createRoute({
|
|
150
|
+
method: "GET",
|
|
151
|
+
path: "/workspaces",
|
|
152
|
+
responseType: "json",
|
|
153
|
+
responseSchema: require_workspace.listWorkspacesResponseSchema,
|
|
154
|
+
summary: "List all workspaces",
|
|
155
|
+
description: "Returns all workspaces from both Mastra instance and agents",
|
|
156
|
+
tags: ["Workspace"],
|
|
157
|
+
handler: async ({ mastra }) => {
|
|
158
|
+
try {
|
|
159
|
+
requireWorkspaceV1Support();
|
|
160
|
+
const workspaces = [];
|
|
161
|
+
if (typeof mastra.listWorkspaces === "function") {
|
|
162
|
+
const registeredWorkspaces = mastra.listWorkspaces();
|
|
163
|
+
for (const [, entry] of Object.entries(registeredWorkspaces)) {
|
|
164
|
+
const ws = entry.workspace ?? entry;
|
|
165
|
+
const source = entry.source ?? "mastra";
|
|
166
|
+
const agentId = entry.agentId;
|
|
167
|
+
const agentName = entry.agentName;
|
|
168
|
+
workspaces.push({
|
|
169
|
+
id: ws.id,
|
|
170
|
+
name: ws.name,
|
|
171
|
+
status: ws.status,
|
|
172
|
+
source,
|
|
173
|
+
...source === "agent" && agentId ? {
|
|
174
|
+
agentId,
|
|
175
|
+
...agentName != null ? { agentName } : {}
|
|
176
|
+
} : {},
|
|
177
|
+
capabilities: {
|
|
178
|
+
hasFilesystem: !!ws.filesystem,
|
|
179
|
+
hasSandbox: !!ws.sandbox,
|
|
180
|
+
canBM25: ws.canBM25,
|
|
181
|
+
canVector: ws.canVector,
|
|
182
|
+
canHybrid: ws.canHybrid,
|
|
183
|
+
hasSkills: !!ws.skills
|
|
184
|
+
},
|
|
185
|
+
safety: { readOnly: ws.filesystem?.readOnly ?? false }
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
190
|
+
const globalWorkspace = mastra.getWorkspace?.();
|
|
191
|
+
if (globalWorkspace) {
|
|
192
|
+
seenIds.add(globalWorkspace.id);
|
|
193
|
+
workspaces.push({
|
|
194
|
+
id: globalWorkspace.id,
|
|
195
|
+
name: globalWorkspace.name,
|
|
196
|
+
status: globalWorkspace.status,
|
|
197
|
+
source: "mastra",
|
|
198
|
+
capabilities: {
|
|
199
|
+
hasFilesystem: !!globalWorkspace.filesystem,
|
|
200
|
+
hasSandbox: !!globalWorkspace.sandbox,
|
|
201
|
+
canBM25: globalWorkspace.canBM25,
|
|
202
|
+
canVector: globalWorkspace.canVector,
|
|
203
|
+
canHybrid: globalWorkspace.canHybrid,
|
|
204
|
+
hasSkills: !!globalWorkspace.skills
|
|
205
|
+
},
|
|
206
|
+
safety: { readOnly: globalWorkspace.filesystem?.readOnly ?? false }
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
const agents = mastra.listAgents?.() ?? {};
|
|
210
|
+
for (const [agentId, agent] of Object.entries(agents)) if (agent.hasOwnWorkspace?.()) try {
|
|
211
|
+
const agentWorkspace = await agent.getWorkspace?.();
|
|
212
|
+
if (agentWorkspace && !seenIds.has(agentWorkspace.id)) {
|
|
213
|
+
seenIds.add(agentWorkspace.id);
|
|
214
|
+
workspaces.push({
|
|
215
|
+
id: agentWorkspace.id,
|
|
216
|
+
name: agentWorkspace.name,
|
|
217
|
+
status: agentWorkspace.status,
|
|
218
|
+
source: "agent",
|
|
219
|
+
agentId,
|
|
220
|
+
agentName: agent.name,
|
|
221
|
+
capabilities: {
|
|
222
|
+
hasFilesystem: !!agentWorkspace.filesystem,
|
|
223
|
+
hasSandbox: !!agentWorkspace.sandbox,
|
|
224
|
+
canBM25: agentWorkspace.canBM25,
|
|
225
|
+
canVector: agentWorkspace.canVector,
|
|
226
|
+
canHybrid: agentWorkspace.canHybrid,
|
|
227
|
+
hasSkills: !!agentWorkspace.skills
|
|
228
|
+
},
|
|
229
|
+
safety: { readOnly: agentWorkspace.filesystem?.readOnly ?? false }
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
} catch {
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return { workspaces };
|
|
237
|
+
} catch (error) {
|
|
238
|
+
return handleWorkspaceError(error, "Error listing workspaces");
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
const GET_WORKSPACE_ROUTE = require_route_builder.createRoute({
|
|
243
|
+
method: "GET",
|
|
244
|
+
path: "/workspaces/:workspaceId",
|
|
245
|
+
responseType: "json",
|
|
246
|
+
pathParamSchema: require_workspace.workspaceIdPathParams,
|
|
247
|
+
responseSchema: require_workspace.workspaceInfoResponseSchema,
|
|
248
|
+
summary: "Get workspace info",
|
|
249
|
+
description: "Returns information about a specific workspace and its capabilities",
|
|
250
|
+
tags: ["Workspace"],
|
|
251
|
+
handler: async ({ mastra, workspaceId }) => {
|
|
252
|
+
try {
|
|
253
|
+
const workspace = await getWorkspaceById(mastra, workspaceId);
|
|
254
|
+
if (!workspace) return { isWorkspaceConfigured: false };
|
|
255
|
+
const fsInfo = await workspace.filesystem?.getInfo?.();
|
|
256
|
+
let mounts;
|
|
257
|
+
if (isCompositeFilesystem(workspace.filesystem)) {
|
|
258
|
+
mounts = [];
|
|
259
|
+
for (const [mountPath, mountFs] of workspace.filesystem.mounts) try {
|
|
260
|
+
const info = await mountFs.getInfo?.();
|
|
261
|
+
mounts.push({
|
|
262
|
+
path: mountPath,
|
|
263
|
+
provider: info?.provider ?? mountFs.provider ?? "unknown",
|
|
264
|
+
readOnly: mountFs.readOnly ?? false,
|
|
265
|
+
displayName: info?.name ?? mountFs.name,
|
|
266
|
+
icon: info?.icon,
|
|
267
|
+
name: mountFs.name
|
|
268
|
+
});
|
|
269
|
+
} catch {
|
|
270
|
+
mounts.push({
|
|
271
|
+
path: mountPath,
|
|
272
|
+
provider: mountFs.provider ?? "unknown",
|
|
273
|
+
readOnly: mountFs.readOnly ?? true,
|
|
274
|
+
name: mountFs.name
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return {
|
|
279
|
+
isWorkspaceConfigured: true,
|
|
280
|
+
id: workspace.id,
|
|
281
|
+
name: workspace.name,
|
|
282
|
+
status: workspace.status,
|
|
283
|
+
capabilities: {
|
|
284
|
+
hasFilesystem: !!workspace.filesystem,
|
|
285
|
+
hasSandbox: !!workspace.sandbox,
|
|
286
|
+
canBM25: workspace.canBM25,
|
|
287
|
+
canVector: workspace.canVector,
|
|
288
|
+
canHybrid: workspace.canHybrid,
|
|
289
|
+
hasSkills: !!workspace.skills
|
|
290
|
+
},
|
|
291
|
+
safety: { readOnly: workspace.filesystem?.readOnly ?? false },
|
|
292
|
+
filesystem: fsInfo ? {
|
|
293
|
+
id: fsInfo.id,
|
|
294
|
+
name: fsInfo.name,
|
|
295
|
+
provider: fsInfo.provider,
|
|
296
|
+
status: fsInfo.status,
|
|
297
|
+
error: fsInfo.error,
|
|
298
|
+
readOnly: fsInfo.readOnly,
|
|
299
|
+
icon: fsInfo.icon,
|
|
300
|
+
metadata: fsInfo.metadata
|
|
301
|
+
} : void 0,
|
|
302
|
+
mounts
|
|
303
|
+
};
|
|
304
|
+
} catch (error) {
|
|
305
|
+
return handleWorkspaceError(error, "Error getting workspace info");
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
const WORKSPACE_FS_READ_ROUTE = require_route_builder.createRoute({
|
|
310
|
+
method: "GET",
|
|
311
|
+
path: "/workspaces/:workspaceId/fs/read",
|
|
312
|
+
responseType: "json",
|
|
313
|
+
pathParamSchema: require_workspace.workspaceIdPathParams,
|
|
314
|
+
queryParamSchema: require_workspace.fsReadQuerySchema,
|
|
315
|
+
responseSchema: require_workspace.fsReadResponseSchema,
|
|
316
|
+
summary: "Read file content",
|
|
317
|
+
description: "Returns the content of a file at the specified path",
|
|
318
|
+
tags: ["Workspace"],
|
|
319
|
+
handler: async ({ mastra, path, encoding, workspaceId }) => {
|
|
320
|
+
try {
|
|
321
|
+
requireWorkspaceV1Support();
|
|
322
|
+
if (!path) throw new require_http_exception.HTTPException(400, { message: "Path is required" });
|
|
323
|
+
const workspace = await getWorkspaceById(mastra, workspaceId);
|
|
324
|
+
if (!workspace?.filesystem) throw new require_http_exception.HTTPException(404, { message: "No workspace filesystem configured" });
|
|
325
|
+
const decodedPath = path;
|
|
326
|
+
if (!await workspace.filesystem.exists(decodedPath)) throw new require_http_exception.HTTPException(404, { message: `Path "${decodedPath}" not found` });
|
|
327
|
+
const content = await workspace.filesystem.readFile(decodedPath, { encoding: encoding || "utf-8" });
|
|
328
|
+
return {
|
|
329
|
+
path: decodedPath,
|
|
330
|
+
content: typeof content === "string" ? content : content.toString("utf-8"),
|
|
331
|
+
type: "file"
|
|
332
|
+
};
|
|
333
|
+
} catch (error) {
|
|
334
|
+
return handleWorkspaceError(error, "Error reading file");
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
const WORKSPACE_FS_WRITE_ROUTE = require_route_builder.createRoute({
|
|
339
|
+
method: "POST",
|
|
340
|
+
path: "/workspaces/:workspaceId/fs/write",
|
|
341
|
+
responseType: "json",
|
|
342
|
+
pathParamSchema: require_workspace.workspaceIdPathParams,
|
|
343
|
+
bodySchema: require_workspace.fsWriteBodySchema,
|
|
344
|
+
responseSchema: require_workspace.fsWriteResponseSchema,
|
|
345
|
+
summary: "Write file content",
|
|
346
|
+
description: "Writes content to a file at the specified path. Supports base64 encoding for binary files.",
|
|
347
|
+
tags: ["Workspace"],
|
|
348
|
+
handler: async ({ mastra, path, content, encoding, recursive, workspaceId }) => {
|
|
349
|
+
try {
|
|
350
|
+
requireWorkspaceV1Support();
|
|
351
|
+
if (!path || content === void 0) throw new require_http_exception.HTTPException(400, { message: "Path and content are required" });
|
|
352
|
+
const workspace = await getWorkspaceById(mastra, workspaceId);
|
|
353
|
+
if (!workspace?.filesystem) throw new require_http_exception.HTTPException(404, { message: "No workspace filesystem configured" });
|
|
354
|
+
if (workspace.filesystem?.readOnly) throw new require_http_exception.HTTPException(403, { message: "Workspace is in read-only mode" });
|
|
355
|
+
const decodedPath = path;
|
|
356
|
+
let fileContent = content;
|
|
357
|
+
if (encoding === "base64") fileContent = Buffer.from(content, "base64");
|
|
358
|
+
await workspace.filesystem.writeFile(decodedPath, fileContent, { recursive: recursive ?? true });
|
|
359
|
+
return {
|
|
360
|
+
success: true,
|
|
361
|
+
path: decodedPath
|
|
362
|
+
};
|
|
363
|
+
} catch (error) {
|
|
364
|
+
return handleWorkspaceError(error, "Error writing file");
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
const WORKSPACE_FS_LIST_ROUTE = require_route_builder.createRoute({
|
|
369
|
+
method: "GET",
|
|
370
|
+
path: "/workspaces/:workspaceId/fs/list",
|
|
371
|
+
responseType: "json",
|
|
372
|
+
pathParamSchema: require_workspace.workspaceIdPathParams,
|
|
373
|
+
queryParamSchema: require_workspace.fsListQuerySchema,
|
|
374
|
+
responseSchema: require_workspace.fsListResponseSchema,
|
|
375
|
+
summary: "List directory contents",
|
|
376
|
+
description: "Returns a list of files and directories at the specified path",
|
|
377
|
+
tags: ["Workspace"],
|
|
378
|
+
handler: async ({ mastra, path, recursive, workspaceId }) => {
|
|
379
|
+
try {
|
|
380
|
+
requireWorkspaceV1Support();
|
|
381
|
+
if (!path) throw new require_http_exception.HTTPException(400, { message: "Path is required" });
|
|
382
|
+
const workspace = await getWorkspaceById(mastra, workspaceId);
|
|
383
|
+
if (!workspace?.filesystem) return {
|
|
384
|
+
path,
|
|
385
|
+
entries: [],
|
|
386
|
+
error: "No workspace filesystem configured"
|
|
387
|
+
};
|
|
388
|
+
const decodedPath = path;
|
|
389
|
+
if (!await workspace.filesystem.exists(decodedPath)) throw new require_http_exception.HTTPException(404, { message: `Path "${decodedPath}" not found` });
|
|
390
|
+
return {
|
|
391
|
+
path: decodedPath,
|
|
392
|
+
entries: await workspace.filesystem.readdir(decodedPath, { recursive })
|
|
393
|
+
};
|
|
394
|
+
} catch (error) {
|
|
395
|
+
return handleWorkspaceError(error, "Error listing directory");
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
const WORKSPACE_FS_DELETE_ROUTE = require_route_builder.createRoute({
|
|
400
|
+
method: "DELETE",
|
|
401
|
+
path: "/workspaces/:workspaceId/fs/delete",
|
|
402
|
+
responseType: "json",
|
|
403
|
+
pathParamSchema: require_workspace.workspaceIdPathParams,
|
|
404
|
+
queryParamSchema: require_workspace.fsDeleteQuerySchema,
|
|
405
|
+
responseSchema: require_workspace.fsDeleteResponseSchema,
|
|
406
|
+
summary: "Delete file or directory",
|
|
407
|
+
description: "Deletes a file or directory at the specified path",
|
|
408
|
+
tags: ["Workspace"],
|
|
409
|
+
handler: async ({ mastra, path, recursive, force, workspaceId }) => {
|
|
410
|
+
try {
|
|
411
|
+
requireWorkspaceV1Support();
|
|
412
|
+
if (!path) throw new require_http_exception.HTTPException(400, { message: "Path is required" });
|
|
413
|
+
const workspace = await getWorkspaceById(mastra, workspaceId);
|
|
414
|
+
if (!workspace?.filesystem) throw new require_http_exception.HTTPException(404, { message: "No workspace filesystem configured" });
|
|
415
|
+
if (workspace.filesystem?.readOnly) throw new require_http_exception.HTTPException(403, { message: "Workspace is in read-only mode" });
|
|
416
|
+
const decodedPath = path;
|
|
417
|
+
const exists = await workspace.filesystem.exists(decodedPath);
|
|
418
|
+
if (!exists && !force) throw new require_http_exception.HTTPException(404, { message: `Path "${decodedPath}" not found` });
|
|
419
|
+
if (exists) try {
|
|
420
|
+
await workspace.filesystem.deleteFile(decodedPath, { force });
|
|
421
|
+
} catch {
|
|
422
|
+
await workspace.filesystem.rmdir(decodedPath, {
|
|
423
|
+
recursive,
|
|
424
|
+
force
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
return {
|
|
428
|
+
success: true,
|
|
429
|
+
path: decodedPath
|
|
430
|
+
};
|
|
431
|
+
} catch (error) {
|
|
432
|
+
return handleWorkspaceError(error, "Error deleting path");
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
const WORKSPACE_FS_MKDIR_ROUTE = require_route_builder.createRoute({
|
|
437
|
+
method: "POST",
|
|
438
|
+
path: "/workspaces/:workspaceId/fs/mkdir",
|
|
439
|
+
responseType: "json",
|
|
440
|
+
pathParamSchema: require_workspace.workspaceIdPathParams,
|
|
441
|
+
bodySchema: require_workspace.fsMkdirBodySchema,
|
|
442
|
+
responseSchema: require_workspace.fsMkdirResponseSchema,
|
|
443
|
+
summary: "Create directory",
|
|
444
|
+
description: "Creates a directory at the specified path",
|
|
445
|
+
tags: ["Workspace"],
|
|
446
|
+
handler: async ({ mastra, path, recursive, workspaceId }) => {
|
|
447
|
+
try {
|
|
448
|
+
requireWorkspaceV1Support();
|
|
449
|
+
if (!path) throw new require_http_exception.HTTPException(400, { message: "Path is required" });
|
|
450
|
+
const workspace = await getWorkspaceById(mastra, workspaceId);
|
|
451
|
+
if (!workspace?.filesystem) throw new require_http_exception.HTTPException(404, { message: "No workspace filesystem configured" });
|
|
452
|
+
if (workspace.filesystem?.readOnly) throw new require_http_exception.HTTPException(403, { message: "Workspace is in read-only mode" });
|
|
453
|
+
const decodedPath = path;
|
|
454
|
+
await workspace.filesystem.mkdir(decodedPath, { recursive: recursive ?? true });
|
|
455
|
+
return {
|
|
456
|
+
success: true,
|
|
457
|
+
path: decodedPath
|
|
458
|
+
};
|
|
459
|
+
} catch (error) {
|
|
460
|
+
return handleWorkspaceError(error, "Error creating directory");
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
const WORKSPACE_FS_STAT_ROUTE = require_route_builder.createRoute({
|
|
465
|
+
method: "GET",
|
|
466
|
+
path: "/workspaces/:workspaceId/fs/stat",
|
|
467
|
+
responseType: "json",
|
|
468
|
+
pathParamSchema: require_workspace.workspaceIdPathParams,
|
|
469
|
+
queryParamSchema: require_workspace.fsStatQuerySchema,
|
|
470
|
+
responseSchema: require_workspace.fsStatResponseSchema,
|
|
471
|
+
summary: "Get file/directory info",
|
|
472
|
+
description: "Returns metadata about a file or directory",
|
|
473
|
+
tags: ["Workspace"],
|
|
474
|
+
handler: async ({ mastra, path, workspaceId }) => {
|
|
475
|
+
try {
|
|
476
|
+
requireWorkspaceV1Support();
|
|
477
|
+
if (!path) throw new require_http_exception.HTTPException(400, { message: "Path is required" });
|
|
478
|
+
const workspace = await getWorkspaceById(mastra, workspaceId);
|
|
479
|
+
if (!workspace?.filesystem) throw new require_http_exception.HTTPException(404, { message: "No workspace filesystem configured" });
|
|
480
|
+
const decodedPath = path;
|
|
481
|
+
if (!await workspace.filesystem.exists(decodedPath)) throw new require_http_exception.HTTPException(404, { message: `Path "${decodedPath}" not found` });
|
|
482
|
+
const stat = await workspace.filesystem.stat(decodedPath);
|
|
483
|
+
return {
|
|
484
|
+
path: stat.path,
|
|
485
|
+
type: stat.type,
|
|
486
|
+
size: stat.size,
|
|
487
|
+
createdAt: stat.createdAt?.toISOString(),
|
|
488
|
+
modifiedAt: stat.modifiedAt?.toISOString(),
|
|
489
|
+
mimeType: stat.mimeType
|
|
490
|
+
};
|
|
491
|
+
} catch (error) {
|
|
492
|
+
return handleWorkspaceError(error, "Error getting file info");
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
const WORKSPACE_SEARCH_ROUTE = require_route_builder.createRoute({
|
|
497
|
+
method: "GET",
|
|
498
|
+
path: "/workspaces/:workspaceId/search",
|
|
499
|
+
responseType: "json",
|
|
500
|
+
pathParamSchema: require_workspace.workspaceIdPathParams,
|
|
501
|
+
queryParamSchema: require_workspace.searchQuerySchema,
|
|
502
|
+
responseSchema: require_workspace.searchResponseSchema,
|
|
503
|
+
summary: "Search workspace content",
|
|
504
|
+
description: "Searches across indexed workspace content using BM25, vector, or hybrid search",
|
|
505
|
+
tags: ["Workspace"],
|
|
506
|
+
handler: async ({ mastra, query, topK, mode, minScore, workspaceId }) => {
|
|
507
|
+
try {
|
|
508
|
+
requireWorkspaceV1Support();
|
|
509
|
+
if (!query) throw new require_http_exception.HTTPException(400, { message: "Search query is required" });
|
|
510
|
+
const workspace = await getWorkspaceById(mastra, workspaceId);
|
|
511
|
+
if (!workspace) return {
|
|
512
|
+
results: [],
|
|
513
|
+
query,
|
|
514
|
+
mode: mode || "bm25"
|
|
515
|
+
};
|
|
516
|
+
if (!(workspace.canBM25 || workspace.canVector)) return {
|
|
517
|
+
results: [],
|
|
518
|
+
query,
|
|
519
|
+
mode: mode || "bm25"
|
|
520
|
+
};
|
|
521
|
+
let searchMode = mode;
|
|
522
|
+
if (!searchMode) {
|
|
523
|
+
if (workspace.canHybrid) searchMode = "hybrid";
|
|
524
|
+
else if (workspace.canVector) searchMode = "vector";
|
|
525
|
+
else searchMode = "bm25";
|
|
526
|
+
}
|
|
527
|
+
return {
|
|
528
|
+
results: (await workspace.search(query, {
|
|
529
|
+
topK: topK || 5,
|
|
530
|
+
mode: searchMode,
|
|
531
|
+
minScore
|
|
532
|
+
})).map((r) => ({
|
|
533
|
+
id: r.id,
|
|
534
|
+
content: r.content,
|
|
535
|
+
score: r.score,
|
|
536
|
+
lineRange: r.lineRange,
|
|
537
|
+
scoreDetails: r.scoreDetails
|
|
538
|
+
})),
|
|
539
|
+
query,
|
|
540
|
+
mode: searchMode
|
|
541
|
+
};
|
|
542
|
+
} catch (error) {
|
|
543
|
+
return handleWorkspaceError(error, "Error searching workspace");
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
const WORKSPACE_INDEX_ROUTE = require_route_builder.createRoute({
|
|
548
|
+
method: "POST",
|
|
549
|
+
path: "/workspaces/:workspaceId/index",
|
|
550
|
+
responseType: "json",
|
|
551
|
+
pathParamSchema: require_workspace.workspaceIdPathParams,
|
|
552
|
+
bodySchema: require_workspace.indexBodySchema,
|
|
553
|
+
responseSchema: require_workspace.indexResponseSchema,
|
|
554
|
+
summary: "Index content for search",
|
|
555
|
+
description: "Indexes content for later search operations",
|
|
556
|
+
tags: ["Workspace"],
|
|
557
|
+
handler: async ({ mastra, path, content, metadata, workspaceId }) => {
|
|
558
|
+
try {
|
|
559
|
+
requireWorkspaceV1Support();
|
|
560
|
+
if (!path || content === void 0) throw new require_http_exception.HTTPException(400, { message: "Path and content are required" });
|
|
561
|
+
const workspace = await getWorkspaceById(mastra, workspaceId);
|
|
562
|
+
if (!workspace) throw new require_http_exception.HTTPException(404, { message: "No workspace configured" });
|
|
563
|
+
if (!(workspace.canBM25 || workspace.canVector)) throw new require_http_exception.HTTPException(400, { message: "Workspace does not have search configured" });
|
|
564
|
+
await workspace.index(path, content, { metadata });
|
|
565
|
+
return {
|
|
566
|
+
success: true,
|
|
567
|
+
path
|
|
568
|
+
};
|
|
569
|
+
} catch (error) {
|
|
570
|
+
return handleWorkspaceError(error, "Error indexing content");
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
/** Path prefix for skills installed via skills.sh (with trailing slash for prefix matching) */
|
|
575
|
+
const SKILLS_SH_PATH_PREFIX = `${SKILLS_SH_DIR}/`;
|
|
576
|
+
const WORKSPACE_LIST_SKILLS_ROUTE = require_route_builder.createRoute({
|
|
577
|
+
method: "GET",
|
|
578
|
+
path: "/workspaces/:workspaceId/skills",
|
|
579
|
+
responseType: "json",
|
|
580
|
+
pathParamSchema: require_workspace.workspaceIdPathParams,
|
|
581
|
+
responseSchema: require_workspace.listSkillsResponseSchema,
|
|
582
|
+
summary: "List all skills",
|
|
583
|
+
description: "Returns a list of all discovered skills with their metadata",
|
|
584
|
+
tags: ["Workspace", "Skills"],
|
|
585
|
+
handler: async ({ mastra, workspaceId, requestContext }) => {
|
|
586
|
+
try {
|
|
587
|
+
requireWorkspaceV1Support();
|
|
588
|
+
const workspace = await getWorkspaceById(mastra, workspaceId);
|
|
589
|
+
const skills = workspace?.skills;
|
|
590
|
+
if (!skills) return {
|
|
591
|
+
skills: [],
|
|
592
|
+
isSkillsConfigured: false
|
|
593
|
+
};
|
|
594
|
+
await skills.maybeRefresh({ requestContext });
|
|
595
|
+
const skillsList = await skills.list();
|
|
596
|
+
return {
|
|
597
|
+
skills: await Promise.all(skillsList.map(async (skillMeta) => {
|
|
598
|
+
let skillsShSource;
|
|
599
|
+
if (skillMeta.path.includes(SKILLS_SH_PATH_PREFIX) && workspace.filesystem) try {
|
|
600
|
+
const metaPath = `${skillMeta.path}/.meta.json`;
|
|
601
|
+
const metaContent = await workspace.filesystem.readFile(metaPath);
|
|
602
|
+
const metaText = typeof metaContent === "string" ? metaContent : metaContent.toString("utf-8");
|
|
603
|
+
const meta = JSON.parse(metaText);
|
|
604
|
+
if (meta.owner && meta.repo) skillsShSource = {
|
|
605
|
+
owner: meta.owner,
|
|
606
|
+
repo: meta.repo
|
|
607
|
+
};
|
|
608
|
+
} catch {}
|
|
609
|
+
return {
|
|
610
|
+
name: skillMeta.name,
|
|
611
|
+
description: skillMeta.description,
|
|
612
|
+
license: skillMeta.license,
|
|
613
|
+
compatibility: skillMeta.compatibility,
|
|
614
|
+
metadata: skillMeta.metadata,
|
|
615
|
+
path: skillMeta.path,
|
|
616
|
+
skillsShSource
|
|
617
|
+
};
|
|
618
|
+
})),
|
|
619
|
+
isSkillsConfigured: true
|
|
620
|
+
};
|
|
621
|
+
} catch (error) {
|
|
622
|
+
return handleWorkspaceError(error, "Error listing skills");
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
const WORKSPACE_GET_SKILL_ROUTE = require_route_builder.createRoute({
|
|
627
|
+
method: "GET",
|
|
628
|
+
path: "/workspaces/:workspaceId/skills/:skillName",
|
|
629
|
+
responseType: "json",
|
|
630
|
+
pathParamSchema: require_workspace.skillNamePathParams,
|
|
631
|
+
queryParamSchema: require_workspace.skillDisambiguationQuerySchema,
|
|
632
|
+
responseSchema: require_workspace.getSkillResponseSchema,
|
|
633
|
+
summary: "Get skill details",
|
|
634
|
+
description: "Returns the full details of a specific skill including instructions and file lists",
|
|
635
|
+
tags: ["Workspace", "Skills"],
|
|
636
|
+
handler: async ({ mastra, skillName, path, workspaceId, requestContext }) => {
|
|
637
|
+
try {
|
|
638
|
+
requireWorkspaceV1Support();
|
|
639
|
+
if (!skillName) throw new require_http_exception.HTTPException(400, { message: "Skill name is required" });
|
|
640
|
+
const identifier = path ?? skillName;
|
|
641
|
+
const skills = await getSkillsById(mastra, workspaceId);
|
|
642
|
+
if (!skills) throw new require_http_exception.HTTPException(404, { message: "No workspace with skills configured" });
|
|
643
|
+
await skills.maybeRefresh({ requestContext });
|
|
644
|
+
const skill = await skills.get(identifier);
|
|
645
|
+
if (!skill) throw new require_http_exception.HTTPException(404, { message: `Skill "${identifier}" not found` });
|
|
646
|
+
return {
|
|
647
|
+
name: skill.name,
|
|
648
|
+
description: skill.description,
|
|
649
|
+
license: skill.license,
|
|
650
|
+
compatibility: skill.compatibility,
|
|
651
|
+
metadata: skill.metadata,
|
|
652
|
+
path: skill.path,
|
|
653
|
+
instructions: skill.instructions,
|
|
654
|
+
source: skill.source,
|
|
655
|
+
references: skill.references,
|
|
656
|
+
scripts: skill.scripts,
|
|
657
|
+
assets: skill.assets
|
|
658
|
+
};
|
|
659
|
+
} catch (error) {
|
|
660
|
+
return handleWorkspaceError(error, "Error getting skill");
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
});
|
|
664
|
+
const WORKSPACE_LIST_SKILL_REFERENCES_ROUTE = require_route_builder.createRoute({
|
|
665
|
+
method: "GET",
|
|
666
|
+
path: "/workspaces/:workspaceId/skills/:skillName/references",
|
|
667
|
+
responseType: "json",
|
|
668
|
+
pathParamSchema: require_workspace.skillNamePathParams,
|
|
669
|
+
queryParamSchema: require_workspace.skillDisambiguationQuerySchema,
|
|
670
|
+
responseSchema: require_workspace.listReferencesResponseSchema,
|
|
671
|
+
summary: "List skill references",
|
|
672
|
+
description: "Returns a list of all reference file paths for a skill",
|
|
673
|
+
tags: ["Workspace", "Skills"],
|
|
674
|
+
handler: async ({ mastra, skillName, path, workspaceId, requestContext }) => {
|
|
675
|
+
try {
|
|
676
|
+
requireWorkspaceV1Support();
|
|
677
|
+
if (!skillName) throw new require_http_exception.HTTPException(400, { message: "Skill name is required" });
|
|
678
|
+
const identifier = path ?? skillName;
|
|
679
|
+
const skills = await getSkillsById(mastra, workspaceId);
|
|
680
|
+
if (!skills) throw new require_http_exception.HTTPException(404, { message: "No workspace with skills configured" });
|
|
681
|
+
await skills.maybeRefresh({ requestContext });
|
|
682
|
+
const skill = await skills.get(identifier);
|
|
683
|
+
if (!skill) throw new require_http_exception.HTTPException(404, { message: `Skill "${identifier}" not found` });
|
|
684
|
+
const references = await skills.listReferences(identifier);
|
|
685
|
+
return {
|
|
686
|
+
skillName: skill.name,
|
|
687
|
+
references
|
|
688
|
+
};
|
|
689
|
+
} catch (error) {
|
|
690
|
+
return handleWorkspaceError(error, "Error listing skill references");
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
const WORKSPACE_GET_SKILL_REFERENCE_ROUTE = require_route_builder.createRoute({
|
|
695
|
+
method: "GET",
|
|
696
|
+
path: "/workspaces/:workspaceId/skills/:skillName/references/:referencePath",
|
|
697
|
+
responseType: "json",
|
|
698
|
+
pathParamSchema: require_workspace.skillReferencePathParams,
|
|
699
|
+
queryParamSchema: require_workspace.skillDisambiguationQuerySchema,
|
|
700
|
+
responseSchema: require_workspace.skillReferenceResponseSchema,
|
|
701
|
+
summary: "Get skill reference content",
|
|
702
|
+
description: "Returns the content of a specific reference file from a skill",
|
|
703
|
+
tags: ["Workspace", "Skills"],
|
|
704
|
+
handler: async ({ mastra, skillName, path: skillPath, referencePath, workspaceId, requestContext }) => {
|
|
705
|
+
try {
|
|
706
|
+
requireWorkspaceV1Support();
|
|
707
|
+
const identifier = skillPath ?? skillName;
|
|
708
|
+
const skills = await getSkillsById(mastra, workspaceId);
|
|
709
|
+
if (!skills) throw new require_http_exception.HTTPException(404, { message: "No workspace with skills configured" });
|
|
710
|
+
await skills.maybeRefresh({ requestContext });
|
|
711
|
+
const skill = await skills.get(identifier);
|
|
712
|
+
if (!skill) throw new require_http_exception.HTTPException(404, { message: `Skill "${identifier}" not found` });
|
|
713
|
+
const decodedPath = referencePath;
|
|
714
|
+
assertSafeFilePath(decodedPath);
|
|
715
|
+
const content = await skills.getReference(identifier, `references/${decodedPath}`);
|
|
716
|
+
if (content === null) throw new require_http_exception.HTTPException(404, { message: `Reference "${decodedPath}" not found in skill "${identifier}"` });
|
|
717
|
+
return {
|
|
718
|
+
skillName: skill.name,
|
|
719
|
+
referencePath: decodedPath,
|
|
720
|
+
content
|
|
721
|
+
};
|
|
722
|
+
} catch (error) {
|
|
723
|
+
return handleWorkspaceError(error, "Error getting skill reference");
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
const WORKSPACE_SEARCH_SKILLS_ROUTE = require_route_builder.createRoute({
|
|
728
|
+
method: "GET",
|
|
729
|
+
path: "/workspaces/:workspaceId/skills/search",
|
|
730
|
+
responseType: "json",
|
|
731
|
+
pathParamSchema: require_workspace.workspaceIdPathParams,
|
|
732
|
+
queryParamSchema: require_workspace.searchSkillsQuerySchema,
|
|
733
|
+
responseSchema: require_workspace.searchSkillsResponseSchema,
|
|
734
|
+
summary: "Search skills",
|
|
735
|
+
description: "Searches across all skills content using BM25 keyword search",
|
|
736
|
+
tags: ["Workspace", "Skills"],
|
|
737
|
+
handler: async ({ mastra, query, topK, minScore, skillNames, includeReferences, workspaceId, requestContext }) => {
|
|
738
|
+
try {
|
|
739
|
+
requireWorkspaceV1Support();
|
|
740
|
+
if (!query) throw new require_http_exception.HTTPException(400, { message: "Search query is required" });
|
|
741
|
+
const skills = await getSkillsById(mastra, workspaceId);
|
|
742
|
+
if (!skills) return {
|
|
743
|
+
results: [],
|
|
744
|
+
query
|
|
745
|
+
};
|
|
746
|
+
await skills.maybeRefresh({ requestContext });
|
|
747
|
+
const skillNamesList = skillNames ? skillNames.split(",").map((s) => s.trim()) : void 0;
|
|
748
|
+
return {
|
|
749
|
+
results: (await skills.search(query, {
|
|
750
|
+
topK: topK || 5,
|
|
751
|
+
minScore,
|
|
752
|
+
skillNames: skillNamesList,
|
|
753
|
+
includeReferences: includeReferences ?? true
|
|
754
|
+
})).map((r) => ({
|
|
755
|
+
skillName: r.skillName,
|
|
756
|
+
skillPath: r.skillPath,
|
|
757
|
+
source: r.source,
|
|
758
|
+
content: r.content,
|
|
759
|
+
score: r.score,
|
|
760
|
+
lineRange: r.lineRange,
|
|
761
|
+
scoreDetails: r.scoreDetails
|
|
762
|
+
})),
|
|
763
|
+
query
|
|
764
|
+
};
|
|
765
|
+
} catch (error) {
|
|
766
|
+
return handleWorkspaceError(error, "Error searching skills");
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
const SKILLS_SH_API_URL = "https://skills-api-production.up.railway.app";
|
|
771
|
+
const WORKSPACE_SKILLS_SH_SEARCH_ROUTE = require_route_builder.createRoute({
|
|
772
|
+
method: "GET",
|
|
773
|
+
path: "/workspaces/:workspaceId/skills-sh/search",
|
|
774
|
+
responseType: "json",
|
|
775
|
+
pathParamSchema: require_workspace.workspaceIdPathParams,
|
|
776
|
+
queryParamSchema: require_workspace.skillsShSearchQuerySchema,
|
|
777
|
+
responseSchema: require_workspace.skillsShSearchResponseSchema,
|
|
778
|
+
summary: "Search skills on skills.sh",
|
|
779
|
+
description: "Proxies search requests to skills.sh API to avoid CORS issues",
|
|
780
|
+
tags: ["Workspace", "Skills"],
|
|
781
|
+
handler: async ({ q, limit }) => {
|
|
782
|
+
try {
|
|
783
|
+
const controller = new AbortController();
|
|
784
|
+
const timeoutId = setTimeout(() => controller.abort(), 1e4);
|
|
785
|
+
const url = `${SKILLS_SH_API_URL}/api/skills?query=${encodeURIComponent(q)}&pageSize=${limit}`;
|
|
786
|
+
const response = await fetch(url, { signal: controller.signal });
|
|
787
|
+
clearTimeout(timeoutId);
|
|
788
|
+
if (!response.ok) throw new require_http_exception.HTTPException(502, { message: `Skills API error: ${response.status} ${response.statusText}` });
|
|
789
|
+
const data = await response.json();
|
|
790
|
+
return {
|
|
791
|
+
query: q,
|
|
792
|
+
searchType: "query",
|
|
793
|
+
skills: data.skills.map((s) => ({
|
|
794
|
+
id: s.skillId,
|
|
795
|
+
name: s.name,
|
|
796
|
+
installs: s.installs,
|
|
797
|
+
topSource: s.source
|
|
798
|
+
})),
|
|
799
|
+
count: data.total
|
|
800
|
+
};
|
|
801
|
+
} catch (error) {
|
|
802
|
+
if (error instanceof require_http_exception.HTTPException) throw error;
|
|
803
|
+
return require_server_handlers_error.handleError(error, "Error searching skills");
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
const WORKSPACE_SKILLS_SH_POPULAR_ROUTE = require_route_builder.createRoute({
|
|
808
|
+
method: "GET",
|
|
809
|
+
path: "/workspaces/:workspaceId/skills-sh/popular",
|
|
810
|
+
responseType: "json",
|
|
811
|
+
pathParamSchema: require_workspace.workspaceIdPathParams,
|
|
812
|
+
queryParamSchema: require_workspace.skillsShPopularQuerySchema,
|
|
813
|
+
responseSchema: require_workspace.skillsShListResponseSchema,
|
|
814
|
+
summary: "Get popular skills from skills.sh",
|
|
815
|
+
description: "Proxies popular skills requests to skills.sh API to avoid CORS issues",
|
|
816
|
+
tags: ["Workspace", "Skills"],
|
|
817
|
+
handler: async ({ limit, offset }) => {
|
|
818
|
+
try {
|
|
819
|
+
const controller = new AbortController();
|
|
820
|
+
const timeoutId = setTimeout(() => controller.abort(), 1e4);
|
|
821
|
+
const page = offset > 0 ? Math.floor(offset / limit) + 1 : 1;
|
|
822
|
+
const url = `${SKILLS_SH_API_URL}/api/skills/top?pageSize=${limit}&page=${page}`;
|
|
823
|
+
const response = await fetch(url, { signal: controller.signal });
|
|
824
|
+
clearTimeout(timeoutId);
|
|
825
|
+
if (!response.ok) throw new require_http_exception.HTTPException(502, { message: `Skills API error: ${response.status} ${response.statusText}` });
|
|
826
|
+
const data = await response.json();
|
|
827
|
+
return {
|
|
828
|
+
skills: data.skills.map((s) => ({
|
|
829
|
+
id: s.skillId,
|
|
830
|
+
name: s.name,
|
|
831
|
+
installs: s.installs,
|
|
832
|
+
topSource: s.source
|
|
833
|
+
})),
|
|
834
|
+
count: data.total,
|
|
835
|
+
limit,
|
|
836
|
+
offset
|
|
837
|
+
};
|
|
838
|
+
} catch (error) {
|
|
839
|
+
if (error instanceof require_http_exception.HTTPException) throw error;
|
|
840
|
+
return require_server_handlers_error.handleError(error, "Error fetching popular skills");
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
});
|
|
844
|
+
/**
|
|
845
|
+
* Validate skill name to prevent path traversal attacks.
|
|
846
|
+
* Only allows alphanumeric characters, hyphens, and underscores.
|
|
847
|
+
*/
|
|
848
|
+
const SKILL_NAME_REGEX = /^[a-z0-9][a-z0-9-_]*$/i;
|
|
849
|
+
function assertSafeSkillName(name) {
|
|
850
|
+
if (!SKILL_NAME_REGEX.test(name)) throw new require_http_exception.HTTPException(400, { message: `Invalid skill name "${name}". Names must start with alphanumeric and contain only letters, numbers, hyphens, and underscores.` });
|
|
851
|
+
return name;
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* Validate that a file path is safe (no traversal, no absolute paths).
|
|
855
|
+
* Prevents malicious API responses from writing files outside the skill directory.
|
|
856
|
+
*/
|
|
857
|
+
function assertSafeFilePath(filePath) {
|
|
858
|
+
if (filePath.startsWith("/") || /^[a-zA-Z]:/.test(filePath)) throw new require_http_exception.HTTPException(400, { message: `Invalid file path "${filePath}". Absolute paths are not allowed.` });
|
|
859
|
+
const segments = filePath.split("/");
|
|
860
|
+
for (const segment of segments) if (segment === ".." || segment === ".") throw new require_http_exception.HTTPException(400, { message: `Invalid file path "${filePath}". Path traversal is not allowed.` });
|
|
861
|
+
return filePath;
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Fetch skill files from the Skills API.
|
|
865
|
+
* Returns all files for a skill with their content.
|
|
866
|
+
*/
|
|
867
|
+
async function fetchSkillFiles(owner, repo, skillName) {
|
|
868
|
+
const controller = new AbortController();
|
|
869
|
+
const timeoutId = setTimeout(() => controller.abort(), 3e4);
|
|
870
|
+
const url = `${SKILLS_SH_API_URL}/api/skills/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/${encodeURIComponent(skillName)}/files`;
|
|
871
|
+
const response = await fetch(url, { signal: controller.signal });
|
|
872
|
+
clearTimeout(timeoutId);
|
|
873
|
+
if (!response.ok) {
|
|
874
|
+
if (response.status === 404) return null;
|
|
875
|
+
throw new Error(`Skills API error: ${response.status} ${response.statusText}`);
|
|
876
|
+
}
|
|
877
|
+
return await response.json();
|
|
878
|
+
}
|
|
879
|
+
const WORKSPACE_SKILLS_SH_PREVIEW_ROUTE = require_route_builder.createRoute({
|
|
880
|
+
method: "GET",
|
|
881
|
+
path: "/workspaces/:workspaceId/skills-sh/preview",
|
|
882
|
+
responseType: "json",
|
|
883
|
+
pathParamSchema: require_workspace.workspaceIdPathParams,
|
|
884
|
+
queryParamSchema: require_workspace.skillsShPreviewQuerySchema,
|
|
885
|
+
responseSchema: require_workspace.skillsShPreviewResponseSchema,
|
|
886
|
+
summary: "Preview skill content",
|
|
887
|
+
description: "Fetches the skill content from the Skills API.",
|
|
888
|
+
tags: ["Workspace", "Skills"],
|
|
889
|
+
handler: async ({ owner, repo, path: skillName }) => {
|
|
890
|
+
try {
|
|
891
|
+
const controller = new AbortController();
|
|
892
|
+
const timeoutId = setTimeout(() => controller.abort(), 1e4);
|
|
893
|
+
const url = `${SKILLS_SH_API_URL}/api/skills/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/${encodeURIComponent(skillName)}/content`;
|
|
894
|
+
const response = await fetch(url, { signal: controller.signal });
|
|
895
|
+
clearTimeout(timeoutId);
|
|
896
|
+
if (!response.ok) throw new require_http_exception.HTTPException(404, { message: `Could not find skill "${skillName}" for ${owner}/${repo}` });
|
|
897
|
+
const data = await response.json();
|
|
898
|
+
const content = data.instructions || data.raw || "";
|
|
899
|
+
if (!content) throw new require_http_exception.HTTPException(404, { message: `No content available for skill "${skillName}"` });
|
|
900
|
+
return { content };
|
|
901
|
+
} catch (error) {
|
|
902
|
+
if (error instanceof require_http_exception.HTTPException) throw error;
|
|
903
|
+
return require_server_handlers_error.handleError(error, "Error fetching skill preview");
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
});
|
|
907
|
+
const WORKSPACE_SKILLS_SH_INSTALL_ROUTE = require_route_builder.createRoute({
|
|
908
|
+
method: "POST",
|
|
909
|
+
path: "/workspaces/:workspaceId/skills-sh/install",
|
|
910
|
+
responseType: "json",
|
|
911
|
+
pathParamSchema: require_workspace.workspaceIdPathParams,
|
|
912
|
+
bodySchema: require_workspace.skillsShInstallBodySchema,
|
|
913
|
+
responseSchema: require_workspace.skillsShInstallResponseSchema,
|
|
914
|
+
summary: "Install skill from Skills API",
|
|
915
|
+
description: "Installs a skill by fetching files from the Skills API and writing to workspace filesystem.",
|
|
916
|
+
tags: ["Workspace", "Skills"],
|
|
917
|
+
handler: async ({ mastra, workspaceId, owner, repo, skillName, mount }) => {
|
|
918
|
+
try {
|
|
919
|
+
requireWorkspaceV1Support();
|
|
920
|
+
const workspace = await getWorkspaceById(mastra, workspaceId);
|
|
921
|
+
if (!workspace) throw new require_http_exception.HTTPException(404, { message: "Workspace not found" });
|
|
922
|
+
if (!workspace.filesystem) throw new require_http_exception.HTTPException(400, { message: "Workspace filesystem not available" });
|
|
923
|
+
if (workspace.filesystem.readOnly) throw new require_http_exception.HTTPException(403, { message: "Workspace is read-only" });
|
|
924
|
+
const result = await fetchSkillFiles(owner, repo, skillName);
|
|
925
|
+
if (!result || result.files.length === 0) throw new require_http_exception.HTTPException(404, { message: `Could not find skill "${skillName}" in ${owner}/${repo}.` });
|
|
926
|
+
const safeSkillId = assertSafeSkillName(result.skillId);
|
|
927
|
+
const installPath = buildSkillInstallPath(workspace.filesystem, safeSkillId, mount);
|
|
928
|
+
try {
|
|
929
|
+
await workspace.filesystem.mkdir(installPath, { recursive: true });
|
|
930
|
+
} catch {}
|
|
931
|
+
let filesWritten = 0;
|
|
932
|
+
for (const file of result.files) {
|
|
933
|
+
const safePath = assertSafeFilePath(file.path);
|
|
934
|
+
const filePath = `${installPath}/${safePath}`;
|
|
935
|
+
if (safePath.includes("/")) {
|
|
936
|
+
const dirPath = filePath.substring(0, filePath.lastIndexOf("/"));
|
|
937
|
+
try {
|
|
938
|
+
await workspace.filesystem.mkdir(dirPath, { recursive: true });
|
|
939
|
+
} catch {}
|
|
940
|
+
}
|
|
941
|
+
const content = file.encoding === "base64" ? Buffer.from(file.content, "base64") : file.content;
|
|
942
|
+
await workspace.filesystem.writeFile(filePath, content);
|
|
943
|
+
filesWritten++;
|
|
944
|
+
}
|
|
945
|
+
const metadata = {
|
|
946
|
+
skillName: result.skillId,
|
|
947
|
+
owner: result.owner,
|
|
948
|
+
repo: result.repo,
|
|
949
|
+
branch: result.branch,
|
|
950
|
+
installedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
951
|
+
};
|
|
952
|
+
await workspace.filesystem.writeFile(`${installPath}/.meta.json`, JSON.stringify(metadata, null, 2));
|
|
953
|
+
filesWritten++;
|
|
954
|
+
if (workspace.skills?.addSkill) try {
|
|
955
|
+
await workspace.skills.addSkill(installPath);
|
|
956
|
+
} catch (cacheError) {
|
|
957
|
+
console.warn(`[skills-sh] Failed to update cache after install: ${cacheError instanceof Error ? cacheError.message : String(cacheError)}`);
|
|
958
|
+
}
|
|
959
|
+
return {
|
|
960
|
+
success: true,
|
|
961
|
+
skillName: result.skillId,
|
|
962
|
+
installedPath: installPath,
|
|
963
|
+
filesWritten
|
|
964
|
+
};
|
|
965
|
+
} catch (error) {
|
|
966
|
+
if (error instanceof require_http_exception.HTTPException) throw error;
|
|
967
|
+
return require_server_handlers_error.handleError(error, "Error installing skill");
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
});
|
|
971
|
+
const WORKSPACE_SKILLS_SH_REMOVE_ROUTE = require_route_builder.createRoute({
|
|
972
|
+
method: "POST",
|
|
973
|
+
path: "/workspaces/:workspaceId/skills-sh/remove",
|
|
974
|
+
responseType: "json",
|
|
975
|
+
pathParamSchema: require_workspace.workspaceIdPathParams,
|
|
976
|
+
bodySchema: require_workspace.skillsShRemoveBodySchema,
|
|
977
|
+
responseSchema: require_workspace.skillsShRemoveResponseSchema,
|
|
978
|
+
summary: "Remove an installed skill",
|
|
979
|
+
description: "Removes an installed skill by deleting its directory. Does not require sandbox.",
|
|
980
|
+
tags: ["Workspace", "Skills"],
|
|
981
|
+
handler: async ({ mastra, workspaceId, skillName }) => {
|
|
982
|
+
try {
|
|
983
|
+
requireWorkspaceV1Support();
|
|
984
|
+
const workspace = await getWorkspaceById(mastra, workspaceId);
|
|
985
|
+
if (!workspace) throw new require_http_exception.HTTPException(404, { message: "Workspace not found" });
|
|
986
|
+
if (!workspace.filesystem) throw new require_http_exception.HTTPException(400, { message: "Workspace filesystem not available" });
|
|
987
|
+
if (workspace.filesystem.readOnly) throw new require_http_exception.HTTPException(403, { message: "Workspace is read-only" });
|
|
988
|
+
const safeSkillName = assertSafeSkillName(skillName);
|
|
989
|
+
const skillPath = ((await workspace.skills?.list())?.find((s) => s.name === safeSkillName && s.path.includes(SKILLS_SH_PATH_PREFIX)))?.path ?? buildSkillInstallPath(workspace.filesystem, safeSkillName);
|
|
990
|
+
try {
|
|
991
|
+
await workspace.filesystem.stat(skillPath);
|
|
992
|
+
} catch {
|
|
993
|
+
throw new require_http_exception.HTTPException(404, { message: `Skill "${skillName}" not found at ${skillPath}` });
|
|
994
|
+
}
|
|
995
|
+
await workspace.filesystem.rmdir(skillPath, { recursive: true });
|
|
996
|
+
if (workspace.skills?.removeSkill) try {
|
|
997
|
+
await workspace.skills.removeSkill(skillPath);
|
|
998
|
+
} catch (cacheError) {
|
|
999
|
+
console.warn(`[skills-sh] Failed to update cache after remove: ${cacheError instanceof Error ? cacheError.message : String(cacheError)}`);
|
|
1000
|
+
}
|
|
1001
|
+
return {
|
|
1002
|
+
success: true,
|
|
1003
|
+
skillName,
|
|
1004
|
+
removedPath: skillPath
|
|
1005
|
+
};
|
|
1006
|
+
} catch (error) {
|
|
1007
|
+
if (error instanceof require_http_exception.HTTPException) throw error;
|
|
1008
|
+
return require_server_handlers_error.handleError(error, "Error removing skill");
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
});
|
|
1012
|
+
const WORKSPACE_SKILLS_SH_UPDATE_ROUTE = require_route_builder.createRoute({
|
|
1013
|
+
method: "POST",
|
|
1014
|
+
path: "/workspaces/:workspaceId/skills-sh/update",
|
|
1015
|
+
responseType: "json",
|
|
1016
|
+
pathParamSchema: require_workspace.workspaceIdPathParams,
|
|
1017
|
+
bodySchema: require_workspace.skillsShUpdateBodySchema,
|
|
1018
|
+
responseSchema: require_workspace.skillsShUpdateResponseSchema,
|
|
1019
|
+
summary: "Update installed skills",
|
|
1020
|
+
description: "Updates installed skills by re-fetching from GitHub. Specify skillName to update one, or omit to update all.",
|
|
1021
|
+
tags: ["Workspace", "Skills"],
|
|
1022
|
+
handler: async ({ mastra, workspaceId, skillName }) => {
|
|
1023
|
+
try {
|
|
1024
|
+
requireWorkspaceV1Support();
|
|
1025
|
+
const workspace = await getWorkspaceById(mastra, workspaceId);
|
|
1026
|
+
if (!workspace) throw new require_http_exception.HTTPException(404, { message: "Workspace not found" });
|
|
1027
|
+
if (!workspace.filesystem) throw new require_http_exception.HTTPException(400, { message: "Workspace filesystem not available" });
|
|
1028
|
+
if (workspace.filesystem.readOnly) throw new require_http_exception.HTTPException(403, { message: "Workspace is read-only" });
|
|
1029
|
+
const results = [];
|
|
1030
|
+
let skillsToUpdate;
|
|
1031
|
+
if (skillName) {
|
|
1032
|
+
const safeName = assertSafeSkillName(skillName);
|
|
1033
|
+
const discoveredSkill = (await workspace.skills?.list())?.find((s) => s.name === safeName && s.path.includes(SKILLS_SH_PATH_PREFIX));
|
|
1034
|
+
let basePath;
|
|
1035
|
+
if (discoveredSkill?.path) basePath = discoveredSkill.path.substring(0, discoveredSkill.path.lastIndexOf("/"));
|
|
1036
|
+
else basePath = SKILLS_SH_DIR;
|
|
1037
|
+
skillsToUpdate = [{
|
|
1038
|
+
name: safeName,
|
|
1039
|
+
basePath
|
|
1040
|
+
}];
|
|
1041
|
+
} else {
|
|
1042
|
+
skillsToUpdate = [];
|
|
1043
|
+
const dirsToScan = [];
|
|
1044
|
+
if (isCompositeFilesystem(workspace.filesystem)) {
|
|
1045
|
+
for (const [mountPath, mountFs] of workspace.filesystem.mounts) if (!mountFs.readOnly) dirsToScan.push(`${stripTrailingSlash(mountPath)}/${SKILLS_SH_DIR}`);
|
|
1046
|
+
} else dirsToScan.push(SKILLS_SH_DIR);
|
|
1047
|
+
for (const dir of dirsToScan) try {
|
|
1048
|
+
const entries = await workspace.filesystem.readdir(dir);
|
|
1049
|
+
for (const e of entries) if (e.type === "directory") skillsToUpdate.push({
|
|
1050
|
+
name: e.name,
|
|
1051
|
+
basePath: dir
|
|
1052
|
+
});
|
|
1053
|
+
} catch {}
|
|
1054
|
+
if (skillsToUpdate.length === 0) return { updated: [] };
|
|
1055
|
+
}
|
|
1056
|
+
for (const { name: skill, basePath } of skillsToUpdate) {
|
|
1057
|
+
try {
|
|
1058
|
+
assertSafeSkillName(skill);
|
|
1059
|
+
} catch {
|
|
1060
|
+
results.push({
|
|
1061
|
+
skillName: skill,
|
|
1062
|
+
success: false,
|
|
1063
|
+
error: "Invalid skill name"
|
|
1064
|
+
});
|
|
1065
|
+
continue;
|
|
1066
|
+
}
|
|
1067
|
+
const installPath = `${basePath}/${skill}`;
|
|
1068
|
+
const metaPath = `${installPath}/.meta.json`;
|
|
1069
|
+
try {
|
|
1070
|
+
const metaContent = await workspace.filesystem.readFile(metaPath, { encoding: "utf-8" });
|
|
1071
|
+
const meta = JSON.parse(metaContent);
|
|
1072
|
+
const fetchResult = await fetchSkillFiles(meta.owner, meta.repo, meta.skillName);
|
|
1073
|
+
if (!fetchResult || fetchResult.files.length === 0) {
|
|
1074
|
+
results.push({
|
|
1075
|
+
skillName: skill,
|
|
1076
|
+
success: false,
|
|
1077
|
+
error: "No files found in skill directory"
|
|
1078
|
+
});
|
|
1079
|
+
continue;
|
|
1080
|
+
}
|
|
1081
|
+
let filesWritten = 0;
|
|
1082
|
+
for (const file of fetchResult.files) {
|
|
1083
|
+
const safePath = assertSafeFilePath(file.path);
|
|
1084
|
+
const filePath = `${installPath}/${safePath}`;
|
|
1085
|
+
if (safePath.includes("/")) {
|
|
1086
|
+
const dirPath = filePath.substring(0, filePath.lastIndexOf("/"));
|
|
1087
|
+
try {
|
|
1088
|
+
await workspace.filesystem.mkdir(dirPath, { recursive: true });
|
|
1089
|
+
} catch {}
|
|
1090
|
+
}
|
|
1091
|
+
const content = file.encoding === "base64" ? Buffer.from(file.content, "base64") : file.content;
|
|
1092
|
+
await workspace.filesystem.writeFile(filePath, content);
|
|
1093
|
+
filesWritten++;
|
|
1094
|
+
}
|
|
1095
|
+
const updatedMeta = {
|
|
1096
|
+
...meta,
|
|
1097
|
+
branch: fetchResult.branch,
|
|
1098
|
+
installedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1099
|
+
};
|
|
1100
|
+
await workspace.filesystem.writeFile(metaPath, JSON.stringify(updatedMeta, null, 2));
|
|
1101
|
+
filesWritten++;
|
|
1102
|
+
if (workspace.skills?.addSkill) try {
|
|
1103
|
+
await workspace.skills.addSkill(installPath);
|
|
1104
|
+
} catch (cacheError) {
|
|
1105
|
+
console.warn(`[skills-sh] Failed to update cache after update: ${cacheError instanceof Error ? cacheError.message : String(cacheError)}`);
|
|
1106
|
+
}
|
|
1107
|
+
results.push({
|
|
1108
|
+
skillName: skill,
|
|
1109
|
+
success: true,
|
|
1110
|
+
filesWritten
|
|
1111
|
+
});
|
|
1112
|
+
} catch (error) {
|
|
1113
|
+
results.push({
|
|
1114
|
+
skillName: skill,
|
|
1115
|
+
success: false,
|
|
1116
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
return { updated: results };
|
|
1121
|
+
} catch (error) {
|
|
1122
|
+
if (error instanceof require_http_exception.HTTPException) throw error;
|
|
1123
|
+
return require_server_handlers_error.handleError(error, "Error updating skills");
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
});
|
|
1127
|
+
const WORKSPACE_SKILLS_SH_ROUTES = [
|
|
1128
|
+
WORKSPACE_SKILLS_SH_SEARCH_ROUTE,
|
|
1129
|
+
WORKSPACE_SKILLS_SH_POPULAR_ROUTE,
|
|
1130
|
+
WORKSPACE_SKILLS_SH_PREVIEW_ROUTE,
|
|
1131
|
+
WORKSPACE_SKILLS_SH_INSTALL_ROUTE,
|
|
1132
|
+
WORKSPACE_SKILLS_SH_REMOVE_ROUTE,
|
|
1133
|
+
WORKSPACE_SKILLS_SH_UPDATE_ROUTE
|
|
1134
|
+
];
|
|
1135
|
+
const WORKSPACE_FS_ROUTES = [
|
|
1136
|
+
WORKSPACE_FS_READ_ROUTE,
|
|
1137
|
+
WORKSPACE_FS_WRITE_ROUTE,
|
|
1138
|
+
WORKSPACE_FS_LIST_ROUTE,
|
|
1139
|
+
WORKSPACE_FS_DELETE_ROUTE,
|
|
1140
|
+
WORKSPACE_FS_MKDIR_ROUTE,
|
|
1141
|
+
WORKSPACE_FS_STAT_ROUTE
|
|
1142
|
+
];
|
|
1143
|
+
const WORKSPACE_SEARCH_ROUTES = [WORKSPACE_SEARCH_ROUTE, WORKSPACE_INDEX_ROUTE];
|
|
1144
|
+
const WORKSPACE_SKILLS_ROUTES = [
|
|
1145
|
+
WORKSPACE_SEARCH_SKILLS_ROUTE,
|
|
1146
|
+
WORKSPACE_LIST_SKILLS_ROUTE,
|
|
1147
|
+
WORKSPACE_GET_SKILL_ROUTE,
|
|
1148
|
+
WORKSPACE_LIST_SKILL_REFERENCES_ROUTE,
|
|
1149
|
+
WORKSPACE_GET_SKILL_REFERENCE_ROUTE
|
|
1150
|
+
];
|
|
1151
|
+
//#endregion
|
|
1152
|
+
Object.defineProperty(exports, "GET_WORKSPACE_ROUTE", {
|
|
1153
|
+
enumerable: true,
|
|
1154
|
+
get: function() {
|
|
1155
|
+
return GET_WORKSPACE_ROUTE;
|
|
1156
|
+
}
|
|
1157
|
+
});
|
|
1158
|
+
Object.defineProperty(exports, "LIST_WORKSPACES_ROUTE", {
|
|
1159
|
+
enumerable: true,
|
|
1160
|
+
get: function() {
|
|
1161
|
+
return LIST_WORKSPACES_ROUTE;
|
|
1162
|
+
}
|
|
1163
|
+
});
|
|
1164
|
+
Object.defineProperty(exports, "WORKSPACE_FS_DELETE_ROUTE", {
|
|
1165
|
+
enumerable: true,
|
|
1166
|
+
get: function() {
|
|
1167
|
+
return WORKSPACE_FS_DELETE_ROUTE;
|
|
1168
|
+
}
|
|
1169
|
+
});
|
|
1170
|
+
Object.defineProperty(exports, "WORKSPACE_FS_LIST_ROUTE", {
|
|
1171
|
+
enumerable: true,
|
|
1172
|
+
get: function() {
|
|
1173
|
+
return WORKSPACE_FS_LIST_ROUTE;
|
|
1174
|
+
}
|
|
1175
|
+
});
|
|
1176
|
+
Object.defineProperty(exports, "WORKSPACE_FS_MKDIR_ROUTE", {
|
|
1177
|
+
enumerable: true,
|
|
1178
|
+
get: function() {
|
|
1179
|
+
return WORKSPACE_FS_MKDIR_ROUTE;
|
|
1180
|
+
}
|
|
1181
|
+
});
|
|
1182
|
+
Object.defineProperty(exports, "WORKSPACE_FS_READ_ROUTE", {
|
|
1183
|
+
enumerable: true,
|
|
1184
|
+
get: function() {
|
|
1185
|
+
return WORKSPACE_FS_READ_ROUTE;
|
|
1186
|
+
}
|
|
1187
|
+
});
|
|
1188
|
+
Object.defineProperty(exports, "WORKSPACE_FS_ROUTES", {
|
|
1189
|
+
enumerable: true,
|
|
1190
|
+
get: function() {
|
|
1191
|
+
return WORKSPACE_FS_ROUTES;
|
|
1192
|
+
}
|
|
1193
|
+
});
|
|
1194
|
+
Object.defineProperty(exports, "WORKSPACE_FS_STAT_ROUTE", {
|
|
1195
|
+
enumerable: true,
|
|
1196
|
+
get: function() {
|
|
1197
|
+
return WORKSPACE_FS_STAT_ROUTE;
|
|
1198
|
+
}
|
|
1199
|
+
});
|
|
1200
|
+
Object.defineProperty(exports, "WORKSPACE_FS_WRITE_ROUTE", {
|
|
1201
|
+
enumerable: true,
|
|
1202
|
+
get: function() {
|
|
1203
|
+
return WORKSPACE_FS_WRITE_ROUTE;
|
|
1204
|
+
}
|
|
1205
|
+
});
|
|
1206
|
+
Object.defineProperty(exports, "WORKSPACE_GET_SKILL_REFERENCE_ROUTE", {
|
|
1207
|
+
enumerable: true,
|
|
1208
|
+
get: function() {
|
|
1209
|
+
return WORKSPACE_GET_SKILL_REFERENCE_ROUTE;
|
|
1210
|
+
}
|
|
1211
|
+
});
|
|
1212
|
+
Object.defineProperty(exports, "WORKSPACE_GET_SKILL_ROUTE", {
|
|
1213
|
+
enumerable: true,
|
|
1214
|
+
get: function() {
|
|
1215
|
+
return WORKSPACE_GET_SKILL_ROUTE;
|
|
1216
|
+
}
|
|
1217
|
+
});
|
|
1218
|
+
Object.defineProperty(exports, "WORKSPACE_INDEX_ROUTE", {
|
|
1219
|
+
enumerable: true,
|
|
1220
|
+
get: function() {
|
|
1221
|
+
return WORKSPACE_INDEX_ROUTE;
|
|
1222
|
+
}
|
|
1223
|
+
});
|
|
1224
|
+
Object.defineProperty(exports, "WORKSPACE_LIST_SKILLS_ROUTE", {
|
|
1225
|
+
enumerable: true,
|
|
1226
|
+
get: function() {
|
|
1227
|
+
return WORKSPACE_LIST_SKILLS_ROUTE;
|
|
1228
|
+
}
|
|
1229
|
+
});
|
|
1230
|
+
Object.defineProperty(exports, "WORKSPACE_LIST_SKILL_REFERENCES_ROUTE", {
|
|
1231
|
+
enumerable: true,
|
|
1232
|
+
get: function() {
|
|
1233
|
+
return WORKSPACE_LIST_SKILL_REFERENCES_ROUTE;
|
|
1234
|
+
}
|
|
1235
|
+
});
|
|
1236
|
+
Object.defineProperty(exports, "WORKSPACE_SEARCH_ROUTE", {
|
|
1237
|
+
enumerable: true,
|
|
1238
|
+
get: function() {
|
|
1239
|
+
return WORKSPACE_SEARCH_ROUTE;
|
|
1240
|
+
}
|
|
1241
|
+
});
|
|
1242
|
+
Object.defineProperty(exports, "WORKSPACE_SEARCH_ROUTES", {
|
|
1243
|
+
enumerable: true,
|
|
1244
|
+
get: function() {
|
|
1245
|
+
return WORKSPACE_SEARCH_ROUTES;
|
|
1246
|
+
}
|
|
1247
|
+
});
|
|
1248
|
+
Object.defineProperty(exports, "WORKSPACE_SEARCH_SKILLS_ROUTE", {
|
|
1249
|
+
enumerable: true,
|
|
1250
|
+
get: function() {
|
|
1251
|
+
return WORKSPACE_SEARCH_SKILLS_ROUTE;
|
|
1252
|
+
}
|
|
1253
|
+
});
|
|
1254
|
+
Object.defineProperty(exports, "WORKSPACE_SKILLS_ROUTES", {
|
|
1255
|
+
enumerable: true,
|
|
1256
|
+
get: function() {
|
|
1257
|
+
return WORKSPACE_SKILLS_ROUTES;
|
|
1258
|
+
}
|
|
1259
|
+
});
|
|
1260
|
+
Object.defineProperty(exports, "WORKSPACE_SKILLS_SH_INSTALL_ROUTE", {
|
|
1261
|
+
enumerable: true,
|
|
1262
|
+
get: function() {
|
|
1263
|
+
return WORKSPACE_SKILLS_SH_INSTALL_ROUTE;
|
|
1264
|
+
}
|
|
1265
|
+
});
|
|
1266
|
+
Object.defineProperty(exports, "WORKSPACE_SKILLS_SH_POPULAR_ROUTE", {
|
|
1267
|
+
enumerable: true,
|
|
1268
|
+
get: function() {
|
|
1269
|
+
return WORKSPACE_SKILLS_SH_POPULAR_ROUTE;
|
|
1270
|
+
}
|
|
1271
|
+
});
|
|
1272
|
+
Object.defineProperty(exports, "WORKSPACE_SKILLS_SH_PREVIEW_ROUTE", {
|
|
1273
|
+
enumerable: true,
|
|
1274
|
+
get: function() {
|
|
1275
|
+
return WORKSPACE_SKILLS_SH_PREVIEW_ROUTE;
|
|
1276
|
+
}
|
|
1277
|
+
});
|
|
1278
|
+
Object.defineProperty(exports, "WORKSPACE_SKILLS_SH_REMOVE_ROUTE", {
|
|
1279
|
+
enumerable: true,
|
|
1280
|
+
get: function() {
|
|
1281
|
+
return WORKSPACE_SKILLS_SH_REMOVE_ROUTE;
|
|
1282
|
+
}
|
|
1283
|
+
});
|
|
1284
|
+
Object.defineProperty(exports, "WORKSPACE_SKILLS_SH_ROUTES", {
|
|
1285
|
+
enumerable: true,
|
|
1286
|
+
get: function() {
|
|
1287
|
+
return WORKSPACE_SKILLS_SH_ROUTES;
|
|
1288
|
+
}
|
|
1289
|
+
});
|
|
1290
|
+
Object.defineProperty(exports, "WORKSPACE_SKILLS_SH_SEARCH_ROUTE", {
|
|
1291
|
+
enumerable: true,
|
|
1292
|
+
get: function() {
|
|
1293
|
+
return WORKSPACE_SKILLS_SH_SEARCH_ROUTE;
|
|
1294
|
+
}
|
|
1295
|
+
});
|
|
1296
|
+
Object.defineProperty(exports, "WORKSPACE_SKILLS_SH_UPDATE_ROUTE", {
|
|
1297
|
+
enumerable: true,
|
|
1298
|
+
get: function() {
|
|
1299
|
+
return WORKSPACE_SKILLS_SH_UPDATE_ROUTE;
|
|
1300
|
+
}
|
|
1301
|
+
});
|
|
1302
|
+
Object.defineProperty(exports, "workspace_exports", {
|
|
1303
|
+
enumerable: true,
|
|
1304
|
+
get: function() {
|
|
1305
|
+
return workspace_exports;
|
|
1306
|
+
}
|
|
1307
|
+
});
|
|
1308
|
+
|
|
1309
|
+
//# sourceMappingURL=workspace-COKR1SxH.cjs.map
|