@truefoundry/trueforge 0.181.0 → 0.182.0-rc.2
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/_frontend/assets/{AgentCodeSnippets-7YBGYKYT-C1L_5fwU.js → AgentCodeSnippets-N4CPPTXK-DSUmMTOD.js} +1 -1
- package/dist/_frontend/assets/AgentCodeSnippets-N4CPPTXK-DSUmMTOD.js.br +0 -0
- package/dist/_frontend/assets/AgentCodeSnippets-N4CPPTXK-DSUmMTOD.js.gz +0 -0
- package/dist/_frontend/assets/{AgentMetricChart-ECYBDKGM-M3_lXz3E.js → AgentMetricChart-FTAPT4JZ-DyMqN-qB.js} +1 -1
- package/dist/_frontend/assets/AgentMetricChart-FTAPT4JZ-DyMqN-qB.js.br +0 -0
- package/dist/_frontend/assets/AgentMetricChart-FTAPT4JZ-DyMqN-qB.js.gz +0 -0
- package/dist/_frontend/assets/{AgentOverview-NCWC4XDZ-C2t-4vS4.js → AgentOverview-LIJCKSVS-85yyAnLG.js} +1 -1
- package/dist/_frontend/assets/AgentOverview-LIJCKSVS-85yyAnLG.js.br +0 -0
- package/dist/_frontend/assets/AgentOverview-LIJCKSVS-85yyAnLG.js.gz +0 -0
- package/dist/_frontend/assets/{AgentSessionEventTimeline-GSHWZCTN-C0WAkO6T.js → AgentSessionEventTimeline-M5D62KKT-BuIii9iL.js} +1 -1
- package/dist/_frontend/assets/AgentSessionEventTimeline-M5D62KKT-BuIii9iL.js.br +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimeline-M5D62KKT-BuIii9iL.js.gz +0 -0
- package/dist/_frontend/assets/{AgentSessionEventTimelineChart-UY4YNTFB-BfmUzzT2.js → AgentSessionEventTimelineChart-YVSILI6L-BOWl8zwk.js} +1 -1
- package/dist/_frontend/assets/AgentSessionEventTimelineChart-YVSILI6L-BOWl8zwk.js.br +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimelineChart-YVSILI6L-BOWl8zwk.js.gz +0 -0
- package/dist/_frontend/assets/AgentSessions-WFRMCSTM-BlG0CoxT.js +1 -0
- package/dist/_frontend/assets/AgentSessions-WFRMCSTM-BlG0CoxT.js.br +0 -0
- package/dist/_frontend/assets/AgentSessions-WFRMCSTM-BlG0CoxT.js.gz +0 -0
- package/dist/_frontend/assets/{ConnectorSettings-DYJ6Z6YL-CcJhppzx.js → ConnectorSettings-E3TLRM6O-ByJogme7.js} +1 -1
- package/dist/_frontend/assets/ConnectorSettings-E3TLRM6O-ByJogme7.js.br +0 -0
- package/dist/_frontend/assets/ConnectorSettings-E3TLRM6O-ByJogme7.js.gz +0 -0
- package/dist/_frontend/assets/{DockLayout-YZPEWKJV-D_Oq8GAb.js → DockLayout-EEWA23SA-DpS-kL1g.js} +1 -1
- package/dist/_frontend/assets/{DrawerLayout-OWUKLUSV-D8yrGeh-.js → DrawerLayout-BE446YEE-DVQqHNiQ.js} +2 -2
- package/dist/_frontend/assets/DrawerLayout-BE446YEE-DVQqHNiQ.js.br +0 -0
- package/dist/_frontend/assets/DrawerLayout-BE446YEE-DVQqHNiQ.js.gz +0 -0
- package/dist/_frontend/assets/EnvironmentsPage-QFKQSLTG-JJMRqRzA.js +3 -0
- package/dist/_frontend/assets/EnvironmentsPage-QFKQSLTG-JJMRqRzA.js.br +0 -0
- package/dist/_frontend/assets/EnvironmentsPage-QFKQSLTG-JJMRqRzA.js.gz +0 -0
- package/dist/_frontend/assets/{ModelSettings-Y5NTNBCL-BWyZvSat.js → ModelSettings-TG67C4HM-C2ISxb0e.js} +1 -1
- package/dist/_frontend/assets/ModelSettings-TG67C4HM-C2ISxb0e.js.br +0 -0
- package/dist/_frontend/assets/ModelSettings-TG67C4HM-C2ISxb0e.js.gz +0 -0
- package/dist/_frontend/assets/{SandboxSettings-KLDK6WZH-DZLs35fh.js → SandboxSettings-2DKXEI4V-BQiHBjUq.js} +1 -1
- package/dist/_frontend/assets/SandboxSettings-2DKXEI4V-BQiHBjUq.js.br +0 -0
- package/dist/_frontend/assets/SandboxSettings-2DKXEI4V-BQiHBjUq.js.gz +0 -0
- package/dist/_frontend/assets/SchedulesPage-VAR5OFEN-D1LcpWk2.js +1 -0
- package/dist/_frontend/assets/SchedulesPage-VAR5OFEN-D1LcpWk2.js.br +0 -0
- package/dist/_frontend/assets/SchedulesPage-VAR5OFEN-D1LcpWk2.js.gz +0 -0
- package/dist/_frontend/assets/{SettingsBuilder-72KREKYT-CdDx-q8Q.js → SettingsBuilder-HD2YCHWF-DHM_ghs5.js} +2 -2
- package/dist/_frontend/assets/SettingsBuilder-HD2YCHWF-DHM_ghs5.js.br +0 -0
- package/dist/_frontend/assets/SettingsBuilder-HD2YCHWF-DHM_ghs5.js.gz +0 -0
- package/dist/_frontend/assets/{ShellRouteSync-G2PJ3G3L-DUPIHNaa.js → ShellRouteSync-SBVWQTZG-BrUCHtKf.js} +1 -1
- package/dist/_frontend/assets/ShellRouteSync-SBVWQTZG-BrUCHtKf.js.br +0 -0
- package/dist/_frontend/assets/ShellRouteSync-SBVWQTZG-BrUCHtKf.js.gz +0 -0
- package/dist/_frontend/assets/{SidebarLayout-BWR7N76R-DKICQgJu.js → SidebarLayout-HTRC2XLU-jIlxNDcG.js} +2 -2
- package/dist/_frontend/assets/SidebarLayout-HTRC2XLU-jIlxNDcG.js.br +0 -0
- package/dist/_frontend/assets/SidebarLayout-HTRC2XLU-jIlxNDcG.js.gz +0 -0
- package/dist/_frontend/assets/{SkillSettings-F7X7TZII-BPHGKv7f.js → SkillSettings-7RRCFIKY-B8t00_wo.js} +1 -1
- package/dist/_frontend/assets/SkillSettings-7RRCFIKY-B8t00_wo.js.br +0 -0
- package/dist/_frontend/assets/SkillSettings-7RRCFIKY-B8t00_wo.js.gz +0 -0
- package/dist/_frontend/assets/{TrueForgeUIWithRouter-KPZEEO7D-D5rLvr7Y.js → TrueForgeUIWithRouter-7OQFVUKS-8eFDBkXe.js} +1 -1
- package/dist/_frontend/assets/{WebSearchSettings-VNL63UFQ-D_dYueo8.js → WebSearchSettings-C7ZSPH3R-CntTNiFm.js} +1 -1
- package/dist/_frontend/assets/WebSearchSettings-C7ZSPH3R-CntTNiFm.js.br +0 -0
- package/dist/_frontend/assets/WebSearchSettings-C7ZSPH3R-CntTNiFm.js.gz +0 -0
- package/dist/_frontend/assets/{WidgetLayout-5E2MCZOP-D4SImULJ.js → WidgetLayout-DA2OGU4P-P0eeGeDi.js} +1 -1
- package/dist/_frontend/assets/WidgetLayout-DA2OGU4P-P0eeGeDi.js.br +0 -0
- package/dist/_frontend/assets/WidgetLayout-DA2OGU4P-P0eeGeDi.js.gz +0 -0
- package/dist/_frontend/assets/{chunk-NRMAG6HF-DQrtQbNO.js → chunk-4PLC2I76-c39-nxRr.js} +1 -1
- package/dist/_frontend/assets/chunk-4PLC2I76-c39-nxRr.js.br +0 -0
- package/dist/_frontend/assets/chunk-4PLC2I76-c39-nxRr.js.gz +0 -0
- package/dist/_frontend/assets/{chunk-HB2ZQ4CZ-DiRiTO48.js → chunk-7QIDFWGY-DuiTeueU.js} +1 -1
- package/dist/_frontend/assets/{chunk-XIE7TJW5-CvvubFnj.js → chunk-MKQPU2D6-BIV1yVAG.js} +1 -1
- package/dist/_frontend/assets/chunk-MKQPU2D6-BIV1yVAG.js.br +0 -0
- package/dist/_frontend/assets/chunk-MKQPU2D6-BIV1yVAG.js.gz +0 -0
- package/dist/_frontend/assets/{chunk-OB3PAWPO-Dubdb29l.js → chunk-OB3PAWPO-B88LYJWr.js} +1 -1
- package/dist/_frontend/assets/chunk-OB3PAWPO-B88LYJWr.js.br +0 -0
- package/dist/_frontend/assets/chunk-OB3PAWPO-B88LYJWr.js.gz +0 -0
- package/dist/_frontend/assets/{chunk-QYZB5BFZ-Y-d5Su7A.js → chunk-WOY37NOE-DTyj0-ev.js} +2 -2
- package/dist/_frontend/assets/chunk-WOY37NOE-DTyj0-ev.js.br +0 -0
- package/dist/_frontend/assets/chunk-WOY37NOE-DTyj0-ev.js.gz +0 -0
- package/dist/_frontend/assets/{cssMode-CHTRoDtG.js → cssMode-DjBq_wPE.js} +1 -1
- package/dist/_frontend/assets/cssMode-DjBq_wPE.js.br +0 -0
- package/dist/_frontend/assets/cssMode-DjBq_wPE.js.gz +0 -0
- package/dist/_frontend/assets/{freemarker2-DCfanxEk.js → freemarker2-DNWQ-KO8.js} +1 -1
- package/dist/_frontend/assets/freemarker2-DNWQ-KO8.js.br +0 -0
- package/dist/_frontend/assets/freemarker2-DNWQ-KO8.js.gz +0 -0
- package/dist/_frontend/assets/{handlebars-D1eUDHiC.js → handlebars-DCu_PoZb.js} +1 -1
- package/dist/_frontend/assets/handlebars-DCu_PoZb.js.br +0 -0
- package/dist/_frontend/assets/handlebars-DCu_PoZb.js.gz +0 -0
- package/dist/_frontend/assets/{html-BY_x5tuA.js → html-DhW585Q4.js} +1 -1
- package/dist/_frontend/assets/html-DhW585Q4.js.br +0 -0
- package/dist/_frontend/assets/html-DhW585Q4.js.gz +0 -0
- package/dist/_frontend/assets/{htmlMode-CQC06PWc.js → htmlMode-CPOFciaU.js} +1 -1
- package/dist/_frontend/assets/htmlMode-CPOFciaU.js.br +0 -0
- package/dist/_frontend/assets/htmlMode-CPOFciaU.js.gz +0 -0
- package/dist/_frontend/assets/{index-CLC73Sfk.js → index-YDts30x6.js} +3 -3
- package/dist/_frontend/assets/index-YDts30x6.js.br +0 -0
- package/dist/_frontend/assets/index-YDts30x6.js.gz +0 -0
- package/dist/_frontend/assets/{index-D962hlvu.js → index-dke3UELp.js} +262 -257
- package/dist/_frontend/assets/index-dke3UELp.js.br +0 -0
- package/dist/_frontend/assets/index-dke3UELp.js.gz +0 -0
- package/dist/_frontend/assets/{javascript-B-CwmGDX.js → javascript-vkhFGD3r.js} +1 -1
- package/dist/_frontend/assets/{jsonMode-D9OZ55Ze.js → jsonMode-BhpqItpx.js} +1 -1
- package/dist/_frontend/assets/jsonMode-BhpqItpx.js.br +0 -0
- package/dist/_frontend/assets/jsonMode-BhpqItpx.js.gz +0 -0
- package/dist/_frontend/assets/{liquid-BFKqoh1q.js → liquid-D8vGkR_6.js} +1 -1
- package/dist/_frontend/assets/liquid-D8vGkR_6.js.br +0 -0
- package/dist/_frontend/assets/liquid-D8vGkR_6.js.gz +0 -0
- package/dist/_frontend/assets/{lspLanguageFeatures-CISDQF7n.js → lspLanguageFeatures-CSw9tQ8F.js} +1 -1
- package/dist/_frontend/assets/lspLanguageFeatures-CSw9tQ8F.js.br +0 -0
- package/dist/_frontend/assets/lspLanguageFeatures-CSw9tQ8F.js.gz +0 -0
- package/dist/_frontend/assets/{mdx-szHIHXG5.js → mdx-DCenfAfv.js} +1 -1
- package/dist/_frontend/assets/mdx-DCenfAfv.js.br +0 -0
- package/dist/_frontend/assets/mdx-DCenfAfv.js.gz +0 -0
- package/dist/_frontend/assets/{python-CkLSQhYw.js → python-Dy2EU_dq.js} +1 -1
- package/dist/_frontend/assets/python-Dy2EU_dq.js.br +0 -0
- package/dist/_frontend/assets/python-Dy2EU_dq.js.gz +0 -0
- package/dist/_frontend/assets/{razor-Dcy4SEiu.js → razor-CPsfNaI9.js} +1 -1
- package/dist/_frontend/assets/razor-CPsfNaI9.js.br +0 -0
- package/dist/_frontend/assets/razor-CPsfNaI9.js.gz +0 -0
- package/dist/_frontend/assets/{tsMode-BGP6UWze.js → tsMode-Bm5PbP1s.js} +1 -1
- package/dist/_frontend/assets/tsMode-Bm5PbP1s.js.br +0 -0
- package/dist/_frontend/assets/tsMode-Bm5PbP1s.js.gz +0 -0
- package/dist/_frontend/assets/{typescript-DArV44f6.js → typescript-DNhbePLw.js} +1 -1
- package/dist/_frontend/assets/typescript-DNhbePLw.js.br +0 -0
- package/dist/_frontend/assets/typescript-DNhbePLw.js.gz +0 -0
- package/dist/_frontend/assets/{workers-BBj3mLYA.js → workers-CyoTJFsV.js} +1 -1
- package/dist/_frontend/assets/workers-CyoTJFsV.js.br +0 -0
- package/dist/_frontend/assets/workers-CyoTJFsV.js.gz +0 -0
- package/dist/_frontend/assets/{xml-CLu5PVjZ.js → xml-R5rs-Kf2.js} +1 -1
- package/dist/_frontend/assets/xml-R5rs-Kf2.js.br +0 -0
- package/dist/_frontend/assets/xml-R5rs-Kf2.js.gz +0 -0
- package/dist/_frontend/assets/{yaml-KYFquP3j.js → yaml-20b7WqO5.js} +1 -1
- package/dist/_frontend/assets/yaml-20b7WqO5.js.br +0 -0
- package/dist/_frontend/assets/yaml-20b7WqO5.js.gz +0 -0
- package/dist/_frontend/index.html +1 -1
- package/dist/main.js +958 -342
- package/dist/main.js.map +1 -1
- package/dist/postgres/migrations/20260831_000001_session_external_id.js.map +1 -1
- package/dist/postgres/migrations/20260902_000002_agent_external_id.js.map +1 -1
- package/dist/postgres/migrations/20260903_000002_created_by_subject.js.map +1 -1
- package/dist/postgres/migrations/20260904_000001_schedule_agent_id.js.map +1 -1
- package/dist/postgres/migrations/20260904_000002_session_source.js.map +1 -1
- package/dist/postgres/migrations/20260904_000003_session_metadata_gin.js.map +1 -1
- package/dist/postgres/migrations/20260926_000001_sandbox_environment.js.map +1 -1
- package/dist/postgres/migrations/20260930_000001_sandbox_environment_secret.js.map +1 -1
- package/dist/postgres/migrations/20261022_000001_drop_session_last_turn_id.js +16 -0
- package/dist/postgres/migrations/20261022_000001_drop_session_last_turn_id.js.map +1 -0
- package/dist/postgres/migrations/20261027_000001_access_control.js +21 -0
- package/dist/postgres/migrations/20261027_000001_access_control.js.map +1 -0
- package/dist/postgres/migrations/20261028_000001_session_tfg_source_backfill.js +21 -0
- package/dist/postgres/migrations/20261028_000001_session_tfg_source_backfill.js.map +1 -0
- package/dist/postgres/migrations/20261028_000002_session_tfg_source_list_idx.js +29 -0
- package/dist/postgres/migrations/20261028_000002_session_tfg_source_list_idx.js.map +1 -0
- package/dist/postgres/migrations/20261028_000003_access_control_tenant_backfill.js +32 -0
- package/dist/postgres/migrations/20261028_000003_access_control_tenant_backfill.js.map +1 -0
- package/dist/sqlite/migrations/20260831_000001_session_external_id.js.map +1 -1
- package/dist/sqlite/migrations/20260902_000001_session_metadata.js.map +1 -1
- package/dist/sqlite/migrations/20260902_000002_agent_external_id.js.map +1 -1
- package/dist/sqlite/migrations/20260903_000001_drop_agent_metadata.js.map +1 -1
- package/dist/sqlite/migrations/20260903_000002_created_by_subject.js.map +1 -1
- package/dist/sqlite/migrations/20260904_000001_schedule_agent_id.js.map +1 -1
- package/dist/sqlite/migrations/20260904_000002_session_source.js.map +1 -1
- package/dist/sqlite/migrations/20260926_000001_sandbox_environment.js.map +1 -1
- package/dist/sqlite/migrations/20260930_000001_sandbox_environment_secret.js.map +1 -1
- package/dist/sqlite/migrations/20261022_000001_drop_session_last_turn_id.js +22 -0
- package/dist/sqlite/migrations/20261022_000001_drop_session_last_turn_id.js.map +1 -0
- package/dist/sqlite/migrations/20261027_000001_access_control.js +27 -0
- package/dist/sqlite/migrations/20261027_000001_access_control.js.map +1 -0
- package/dist/sqlite/migrations/20261028_000001_session_tfg_source_backfill.js +22 -0
- package/dist/sqlite/migrations/20261028_000001_session_tfg_source_backfill.js.map +1 -0
- package/dist/sqlite/migrations/20261028_000002_session_tfg_source_list_idx.js +31 -0
- package/dist/sqlite/migrations/20261028_000002_session_tfg_source_list_idx.js.map +1 -0
- package/dist/sqlite/migrations/20261028_000003_access_control_tenant_backfill.js +34 -0
- package/dist/sqlite/migrations/20261028_000003_access_control_tenant_backfill.js.map +1 -0
- package/package.json +4 -4
- package/dist/_frontend/assets/AgentCodeSnippets-7YBGYKYT-C1L_5fwU.js.br +0 -0
- package/dist/_frontend/assets/AgentCodeSnippets-7YBGYKYT-C1L_5fwU.js.gz +0 -0
- package/dist/_frontend/assets/AgentMetricChart-ECYBDKGM-M3_lXz3E.js.br +0 -0
- package/dist/_frontend/assets/AgentMetricChart-ECYBDKGM-M3_lXz3E.js.gz +0 -0
- package/dist/_frontend/assets/AgentOverview-NCWC4XDZ-C2t-4vS4.js.br +0 -0
- package/dist/_frontend/assets/AgentOverview-NCWC4XDZ-C2t-4vS4.js.gz +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimeline-GSHWZCTN-C0WAkO6T.js.br +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimeline-GSHWZCTN-C0WAkO6T.js.gz +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimelineChart-UY4YNTFB-BfmUzzT2.js.br +0 -0
- package/dist/_frontend/assets/AgentSessionEventTimelineChart-UY4YNTFB-BfmUzzT2.js.gz +0 -0
- package/dist/_frontend/assets/AgentSessions-V2V6W7CC-DyO7bBT8.js +0 -1
- package/dist/_frontend/assets/AgentSessions-V2V6W7CC-DyO7bBT8.js.br +0 -0
- package/dist/_frontend/assets/AgentSessions-V2V6W7CC-DyO7bBT8.js.gz +0 -0
- package/dist/_frontend/assets/ConnectorSettings-DYJ6Z6YL-CcJhppzx.js.br +0 -0
- package/dist/_frontend/assets/ConnectorSettings-DYJ6Z6YL-CcJhppzx.js.gz +0 -0
- package/dist/_frontend/assets/DrawerLayout-OWUKLUSV-D8yrGeh-.js.br +0 -0
- package/dist/_frontend/assets/DrawerLayout-OWUKLUSV-D8yrGeh-.js.gz +0 -0
- package/dist/_frontend/assets/EnvironmentsPage-KOMO4W53-BlIcOJ78.js +0 -3
- package/dist/_frontend/assets/EnvironmentsPage-KOMO4W53-BlIcOJ78.js.br +0 -0
- package/dist/_frontend/assets/EnvironmentsPage-KOMO4W53-BlIcOJ78.js.gz +0 -0
- package/dist/_frontend/assets/ModelSettings-Y5NTNBCL-BWyZvSat.js.br +0 -0
- package/dist/_frontend/assets/ModelSettings-Y5NTNBCL-BWyZvSat.js.gz +0 -0
- package/dist/_frontend/assets/SandboxSettings-KLDK6WZH-DZLs35fh.js.br +0 -0
- package/dist/_frontend/assets/SandboxSettings-KLDK6WZH-DZLs35fh.js.gz +0 -0
- package/dist/_frontend/assets/SchedulesPage-4F5FX65T-BUxoTOQI.js +0 -1
- package/dist/_frontend/assets/SchedulesPage-4F5FX65T-BUxoTOQI.js.br +0 -0
- package/dist/_frontend/assets/SchedulesPage-4F5FX65T-BUxoTOQI.js.gz +0 -0
- package/dist/_frontend/assets/SettingsBuilder-72KREKYT-CdDx-q8Q.js.br +0 -0
- package/dist/_frontend/assets/SettingsBuilder-72KREKYT-CdDx-q8Q.js.gz +0 -0
- package/dist/_frontend/assets/ShellRouteSync-G2PJ3G3L-DUPIHNaa.js.br +0 -0
- package/dist/_frontend/assets/ShellRouteSync-G2PJ3G3L-DUPIHNaa.js.gz +0 -0
- package/dist/_frontend/assets/SidebarLayout-BWR7N76R-DKICQgJu.js.br +0 -0
- package/dist/_frontend/assets/SidebarLayout-BWR7N76R-DKICQgJu.js.gz +0 -0
- package/dist/_frontend/assets/SkillSettings-F7X7TZII-BPHGKv7f.js.br +0 -0
- package/dist/_frontend/assets/SkillSettings-F7X7TZII-BPHGKv7f.js.gz +0 -0
- package/dist/_frontend/assets/WebSearchSettings-VNL63UFQ-D_dYueo8.js.br +0 -0
- package/dist/_frontend/assets/WebSearchSettings-VNL63UFQ-D_dYueo8.js.gz +0 -0
- package/dist/_frontend/assets/WidgetLayout-5E2MCZOP-D4SImULJ.js.br +0 -0
- package/dist/_frontend/assets/WidgetLayout-5E2MCZOP-D4SImULJ.js.gz +0 -0
- package/dist/_frontend/assets/chunk-NRMAG6HF-DQrtQbNO.js.br +0 -0
- package/dist/_frontend/assets/chunk-NRMAG6HF-DQrtQbNO.js.gz +0 -0
- package/dist/_frontend/assets/chunk-OB3PAWPO-Dubdb29l.js.br +0 -0
- package/dist/_frontend/assets/chunk-OB3PAWPO-Dubdb29l.js.gz +0 -0
- package/dist/_frontend/assets/chunk-QYZB5BFZ-Y-d5Su7A.js.br +0 -0
- package/dist/_frontend/assets/chunk-QYZB5BFZ-Y-d5Su7A.js.gz +0 -0
- package/dist/_frontend/assets/chunk-XIE7TJW5-CvvubFnj.js.br +0 -0
- package/dist/_frontend/assets/chunk-XIE7TJW5-CvvubFnj.js.gz +0 -0
- package/dist/_frontend/assets/cssMode-CHTRoDtG.js.br +0 -0
- package/dist/_frontend/assets/cssMode-CHTRoDtG.js.gz +0 -0
- package/dist/_frontend/assets/freemarker2-DCfanxEk.js.br +0 -0
- package/dist/_frontend/assets/freemarker2-DCfanxEk.js.gz +0 -0
- package/dist/_frontend/assets/handlebars-D1eUDHiC.js.br +0 -0
- package/dist/_frontend/assets/handlebars-D1eUDHiC.js.gz +0 -0
- package/dist/_frontend/assets/html-BY_x5tuA.js.br +0 -0
- package/dist/_frontend/assets/html-BY_x5tuA.js.gz +0 -0
- package/dist/_frontend/assets/htmlMode-CQC06PWc.js.br +0 -0
- package/dist/_frontend/assets/htmlMode-CQC06PWc.js.gz +0 -0
- package/dist/_frontend/assets/index-CLC73Sfk.js.br +0 -0
- package/dist/_frontend/assets/index-CLC73Sfk.js.gz +0 -0
- package/dist/_frontend/assets/index-D962hlvu.js.br +0 -0
- package/dist/_frontend/assets/index-D962hlvu.js.gz +0 -0
- package/dist/_frontend/assets/jsonMode-D9OZ55Ze.js.br +0 -0
- package/dist/_frontend/assets/jsonMode-D9OZ55Ze.js.gz +0 -0
- package/dist/_frontend/assets/liquid-BFKqoh1q.js.br +0 -0
- package/dist/_frontend/assets/liquid-BFKqoh1q.js.gz +0 -0
- package/dist/_frontend/assets/lspLanguageFeatures-CISDQF7n.js.br +0 -0
- package/dist/_frontend/assets/lspLanguageFeatures-CISDQF7n.js.gz +0 -0
- package/dist/_frontend/assets/mdx-szHIHXG5.js.br +0 -0
- package/dist/_frontend/assets/mdx-szHIHXG5.js.gz +0 -0
- package/dist/_frontend/assets/python-CkLSQhYw.js.br +0 -0
- package/dist/_frontend/assets/python-CkLSQhYw.js.gz +0 -0
- package/dist/_frontend/assets/razor-Dcy4SEiu.js.br +0 -0
- package/dist/_frontend/assets/razor-Dcy4SEiu.js.gz +0 -0
- package/dist/_frontend/assets/tsMode-BGP6UWze.js.br +0 -0
- package/dist/_frontend/assets/tsMode-BGP6UWze.js.gz +0 -0
- package/dist/_frontend/assets/typescript-DArV44f6.js.br +0 -0
- package/dist/_frontend/assets/typescript-DArV44f6.js.gz +0 -0
- package/dist/_frontend/assets/workers-BBj3mLYA.js.br +0 -0
- package/dist/_frontend/assets/workers-BBj3mLYA.js.gz +0 -0
- package/dist/_frontend/assets/xml-CLu5PVjZ.js.br +0 -0
- package/dist/_frontend/assets/xml-CLu5PVjZ.js.gz +0 -0
- package/dist/_frontend/assets/yaml-KYFquP3j.js.br +0 -0
- package/dist/_frontend/assets/yaml-KYFquP3j.js.gz +0 -0
package/dist/main.js
CHANGED
|
@@ -3567,7 +3567,7 @@ var init_skillStore = __esm({
|
|
|
3567
3567
|
});
|
|
3568
3568
|
|
|
3569
3569
|
// src/db/gitSkillMounts.ts
|
|
3570
|
-
import { HTTPException as
|
|
3570
|
+
import { HTTPException as HTTPException23 } from "hono/http-exception";
|
|
3571
3571
|
async function validateGitAgentSkills(store, input) {
|
|
3572
3572
|
const { tenant_id, skills } = input;
|
|
3573
3573
|
if (skills.length === 0) {
|
|
@@ -3575,7 +3575,7 @@ async function validateGitAgentSkills(store, input) {
|
|
|
3575
3575
|
}
|
|
3576
3576
|
for (const skill of skills) {
|
|
3577
3577
|
if (skill.preload) {
|
|
3578
|
-
throw new
|
|
3578
|
+
throw new HTTPException23(422, {
|
|
3579
3579
|
message: `Skill "${skill.name}": preload is not supported for git skills`
|
|
3580
3580
|
});
|
|
3581
3581
|
}
|
|
@@ -3585,12 +3585,12 @@ async function validateGitAgentSkills(store, input) {
|
|
|
3585
3585
|
for (const skill of skills) {
|
|
3586
3586
|
const record = byName.get(skill.name);
|
|
3587
3587
|
if (record === void 0) {
|
|
3588
|
-
throw new
|
|
3588
|
+
throw new HTTPException23(422, {
|
|
3589
3589
|
message: `Unknown skill "${skill.name}" \u2014 not configured`
|
|
3590
3590
|
});
|
|
3591
3591
|
}
|
|
3592
3592
|
if (record.manifest.type !== "git") {
|
|
3593
|
-
throw new
|
|
3593
|
+
throw new HTTPException23(422, {
|
|
3594
3594
|
message: `Skill "${skill.name}" is not a git skill`
|
|
3595
3595
|
});
|
|
3596
3596
|
}
|
|
@@ -3608,13 +3608,13 @@ async function resolveGitTurnSkills(store, input) {
|
|
|
3608
3608
|
for (const skill of skills) {
|
|
3609
3609
|
const record = byName.get(skill.name);
|
|
3610
3610
|
if (record === void 0) {
|
|
3611
|
-
throw new
|
|
3611
|
+
throw new HTTPException23(422, {
|
|
3612
3612
|
message: `Unknown skill "${skill.name}" \u2014 not configured`
|
|
3613
3613
|
});
|
|
3614
3614
|
}
|
|
3615
3615
|
const git = parseGitSkill(record.manifest);
|
|
3616
3616
|
if (git === void 0) {
|
|
3617
|
-
throw new
|
|
3617
|
+
throw new HTTPException23(422, {
|
|
3618
3618
|
message: `Skill "${skill.name}" is not a git skill`
|
|
3619
3619
|
});
|
|
3620
3620
|
}
|
|
@@ -3778,9 +3778,9 @@ var PostgresAgentStore_exports = {};
|
|
|
3778
3778
|
__export(PostgresAgentStore_exports, {
|
|
3779
3779
|
PostgresAgentStore: () => PostgresAgentStore
|
|
3780
3780
|
});
|
|
3781
|
-
import { CreatedBySubjectSchema as
|
|
3781
|
+
import { CreatedBySubjectSchema as CreatedBySubjectSchema5 } from "@truefoundry/trueforge-core/agent-session";
|
|
3782
3782
|
import {
|
|
3783
|
-
decodeOffsetPageToken,
|
|
3783
|
+
decodeOffsetPageToken as decodeOffsetPageToken2,
|
|
3784
3784
|
paginateOffsetRows
|
|
3785
3785
|
} from "@truefoundry/trueforge-core/agent-session/store/OffsetPageToken";
|
|
3786
3786
|
import { sql as sql2 } from "kysely";
|
|
@@ -3792,7 +3792,7 @@ function toRecord(row) {
|
|
|
3792
3792
|
description: row.description,
|
|
3793
3793
|
manifest: parseStoredAgentSpec(row.manifest),
|
|
3794
3794
|
external_id: row.external_id,
|
|
3795
|
-
created_by_subject:
|
|
3795
|
+
created_by_subject: CreatedBySubjectSchema5.parse(row.created_by_subject),
|
|
3796
3796
|
created_at: row.created_at.toISOString(),
|
|
3797
3797
|
updated_at: row.updated_at.toISOString()
|
|
3798
3798
|
};
|
|
@@ -3867,7 +3867,7 @@ var init_PostgresAgentStore = __esm({
|
|
|
3867
3867
|
const data2 = rows2.map(toRecord);
|
|
3868
3868
|
return { data: data2, pagination: { limit: data2.length } };
|
|
3869
3869
|
}
|
|
3870
|
-
const offset =
|
|
3870
|
+
const offset = decodeOffsetPageToken2(input.page_token);
|
|
3871
3871
|
const rows = await query.limit(input.limit + 1).offset(offset).execute();
|
|
3872
3872
|
const { data, pagination } = paginateOffsetRows(rows, input.limit, offset);
|
|
3873
3873
|
return { data: data.map(toRecord), pagination };
|
|
@@ -4108,6 +4108,7 @@ var init_client2 = __esm({
|
|
|
4108
4108
|
"token",
|
|
4109
4109
|
"auth_data",
|
|
4110
4110
|
"created_by_subject",
|
|
4111
|
+
"granted_by_subject",
|
|
4111
4112
|
"source",
|
|
4112
4113
|
// sandbox_environment ↔ version join aliases
|
|
4113
4114
|
"ver_manifest",
|
|
@@ -4416,12 +4417,11 @@ async function assembleTurnRecord(db, args) {
|
|
|
4416
4417
|
async function createTurn(db, input) {
|
|
4417
4418
|
try {
|
|
4418
4419
|
await db.transaction().execute(async (trx) => {
|
|
4419
|
-
const locked = await trx.selectFrom("session").select(["
|
|
4420
|
+
const locked = await trx.selectFrom("session").select(["session_id"]).where("session_id", "=", input.session_id).executeTakeFirst();
|
|
4420
4421
|
if (!locked) {
|
|
4421
4422
|
throw new SessionNotFoundError(input.session_id);
|
|
4422
4423
|
}
|
|
4423
4424
|
let sessionUpdate = trx.updateTable("session").set({
|
|
4424
|
-
last_turn_id: input.turn.turn_id,
|
|
4425
4425
|
last_turn_details: lastTurnDetails({ turn_id: input.turn.turn_id, turn_state: input.turn.state }),
|
|
4426
4426
|
updated_at: nowIso(),
|
|
4427
4427
|
last_activity_timestamp_ms: input.last_activity_timestamp_ms,
|
|
@@ -4826,7 +4826,7 @@ var init_capabilities = __esm({
|
|
|
4826
4826
|
|
|
4827
4827
|
// src/db/sqlite/session-store/queries/events.ts
|
|
4828
4828
|
import {
|
|
4829
|
-
decodeOffsetPageToken as
|
|
4829
|
+
decodeOffsetPageToken as decodeOffsetPageToken3,
|
|
4830
4830
|
paginateOffsetRows as paginateOffsetRows2
|
|
4831
4831
|
} from "@truefoundry/trueforge-core/agent-session/store/OffsetPageToken";
|
|
4832
4832
|
import {
|
|
@@ -4862,7 +4862,7 @@ async function appendToEvents(db, input) {
|
|
|
4862
4862
|
});
|
|
4863
4863
|
}
|
|
4864
4864
|
async function listTurnEvents(db, input) {
|
|
4865
|
-
const offset =
|
|
4865
|
+
const offset = decodeOffsetPageToken3(input.page_token);
|
|
4866
4866
|
const limit = input.limit;
|
|
4867
4867
|
const eventOrder = input.order === "desc" ? "desc" : "asc";
|
|
4868
4868
|
const rows = await db.selectFrom("turn as t").leftJoin(
|
|
@@ -4903,7 +4903,7 @@ async function resolveAncestorChain(db, sessionId, anchor) {
|
|
|
4903
4903
|
}
|
|
4904
4904
|
async function listSessionEvents(db, input) {
|
|
4905
4905
|
const limit = input.limit;
|
|
4906
|
-
const session = await db.selectFrom("session").select("last_turn_id").where("session_id", "=", input.session_id).executeTakeFirst();
|
|
4906
|
+
const session = await db.selectFrom("session").select(sql7`json_extract(last_turn_details, '$.id')`.as("last_turn_id")).where("session_id", "=", input.session_id).executeTakeFirst();
|
|
4907
4907
|
if (!session) {
|
|
4908
4908
|
throw new SessionNotFoundError2(input.session_id);
|
|
4909
4909
|
}
|
|
@@ -5061,7 +5061,7 @@ var init_sessionAgentColumns = __esm({
|
|
|
5061
5061
|
|
|
5062
5062
|
// src/db/sqlite/session-store/queries/sessions.ts
|
|
5063
5063
|
import {
|
|
5064
|
-
CreatedBySubjectSchema as
|
|
5064
|
+
CreatedBySubjectSchema as CreatedBySubjectSchema6,
|
|
5065
5065
|
SessionLastTurnDetailsSchema as SessionLastTurnDetailsSchema2,
|
|
5066
5066
|
SessionMetadataSchema as SessionMetadataSchema2,
|
|
5067
5067
|
SessionSourceSchema
|
|
@@ -5096,7 +5096,7 @@ function mapRowToSessionRecord(row) {
|
|
|
5096
5096
|
return {
|
|
5097
5097
|
tenant_id: row.tenant_id,
|
|
5098
5098
|
session_id: row.session_id,
|
|
5099
|
-
created_by_subject:
|
|
5099
|
+
created_by_subject: CreatedBySubjectSchema6.parse(row.created_by_subject),
|
|
5100
5100
|
source: SessionSourceSchema.nullable().parse(row.source),
|
|
5101
5101
|
agent: sessionAgentFromColumns({
|
|
5102
5102
|
session_id: row.session_id,
|
|
@@ -5105,8 +5105,6 @@ function mapRowToSessionRecord(row) {
|
|
|
5105
5105
|
agent_spec: row.agent_spec
|
|
5106
5106
|
}),
|
|
5107
5107
|
title: row.title,
|
|
5108
|
-
shared: row.shared !== 0,
|
|
5109
|
-
last_turn_id: row.last_turn_id,
|
|
5110
5108
|
last_turn_details: SessionLastTurnDetailsSchema2.nullable().parse(row.last_turn_details),
|
|
5111
5109
|
external_id: row.external_id,
|
|
5112
5110
|
custom: parseSessionCustom(row.custom),
|
|
@@ -5127,8 +5125,6 @@ function sessionSelectColumns() {
|
|
|
5127
5125
|
"agent_name",
|
|
5128
5126
|
jsonText(sql8.ref("agent_spec")).as("agent_spec"),
|
|
5129
5127
|
"title",
|
|
5130
|
-
"shared",
|
|
5131
|
-
"last_turn_id",
|
|
5132
5128
|
jsonText(sql8.ref("last_turn_details")).as("last_turn_details"),
|
|
5133
5129
|
"external_id",
|
|
5134
5130
|
jsonText(sql8.ref("custom")).as("custom"),
|
|
@@ -5152,7 +5148,6 @@ async function createSession(db, input) {
|
|
|
5152
5148
|
agent_name: columns.agent_name,
|
|
5153
5149
|
agent_spec: columns.agent_spec !== null ? jsonbBind(columns.agent_spec) : null,
|
|
5154
5150
|
title: null,
|
|
5155
|
-
shared: 0,
|
|
5156
5151
|
custom: input.custom !== null ? jsonbBind(input.custom) : null,
|
|
5157
5152
|
metadata: jsonbBind(input.metadata),
|
|
5158
5153
|
external_id: input.external_id,
|
|
@@ -5208,7 +5203,6 @@ async function updateSession(db, input) {
|
|
|
5208
5203
|
const agent = input.agent;
|
|
5209
5204
|
const title = input.title;
|
|
5210
5205
|
const metadata = input.metadata;
|
|
5211
|
-
const shared2 = input.shared;
|
|
5212
5206
|
if (agent !== void 0) {
|
|
5213
5207
|
const existing = await getSession(db, { tenant_id: input.tenant_id, session_id: input.session_id });
|
|
5214
5208
|
if (existing === void 0) {
|
|
@@ -5231,9 +5225,6 @@ async function updateSession(db, input) {
|
|
|
5231
5225
|
if (metadata !== void 0) {
|
|
5232
5226
|
qb = qb.set({ metadata: jsonbBind(metadata) });
|
|
5233
5227
|
}
|
|
5234
|
-
if (shared2 !== void 0) {
|
|
5235
|
-
qb = qb.set({ shared: shared2 ? 1 : 0 });
|
|
5236
|
-
}
|
|
5237
5228
|
const result = await qb.executeTakeFirst();
|
|
5238
5229
|
const numUpdatedRows = Number(result.numUpdatedRows);
|
|
5239
5230
|
if (numUpdatedRows === 0) {
|
|
@@ -5574,8 +5565,8 @@ __export(SqliteSessionStore_exports, {
|
|
|
5574
5565
|
SqliteSessionStore: () => SqliteSessionStore
|
|
5575
5566
|
});
|
|
5576
5567
|
import {
|
|
5577
|
-
decodeOffsetPageToken as
|
|
5578
|
-
encodeOffsetPageToken as
|
|
5568
|
+
decodeOffsetPageToken as decodeOffsetPageToken4,
|
|
5569
|
+
encodeOffsetPageToken as encodeOffsetPageToken3
|
|
5579
5570
|
} from "@truefoundry/trueforge-core/agent-session/store/OffsetPageToken";
|
|
5580
5571
|
var SqliteSessionStore;
|
|
5581
5572
|
var init_SqliteSessionStore = __esm({
|
|
@@ -5653,7 +5644,7 @@ var init_SqliteSessionStore = __esm({
|
|
|
5653
5644
|
return getTurn(this.db, input);
|
|
5654
5645
|
}
|
|
5655
5646
|
async listTurns(input) {
|
|
5656
|
-
const offset =
|
|
5647
|
+
const offset = decodeOffsetPageToken4(input.page_token);
|
|
5657
5648
|
const result = await listTurns(this.db, {
|
|
5658
5649
|
session_id: input.session_id,
|
|
5659
5650
|
limit: input.limit,
|
|
@@ -5661,10 +5652,10 @@ var init_SqliteSessionStore = __esm({
|
|
|
5661
5652
|
});
|
|
5662
5653
|
const pagination = { limit: input.limit };
|
|
5663
5654
|
if (result.next_offset !== null) {
|
|
5664
|
-
pagination.next_page_token =
|
|
5655
|
+
pagination.next_page_token = encodeOffsetPageToken3(result.next_offset);
|
|
5665
5656
|
}
|
|
5666
5657
|
if (offset > 0) {
|
|
5667
|
-
pagination.previous_page_token =
|
|
5658
|
+
pagination.previous_page_token = encodeOffsetPageToken3(Math.max(0, offset - input.limit));
|
|
5668
5659
|
}
|
|
5669
5660
|
return { data: result.turns, pagination };
|
|
5670
5661
|
}
|
|
@@ -6332,10 +6323,10 @@ __export(SqliteAgentStore_exports, {
|
|
|
6332
6323
|
SqliteAgentStore: () => SqliteAgentStore
|
|
6333
6324
|
});
|
|
6334
6325
|
import {
|
|
6335
|
-
CreatedBySubjectSchema as
|
|
6326
|
+
CreatedBySubjectSchema as CreatedBySubjectSchema7
|
|
6336
6327
|
} from "@truefoundry/trueforge-core/agent-session";
|
|
6337
6328
|
import {
|
|
6338
|
-
decodeOffsetPageToken as
|
|
6329
|
+
decodeOffsetPageToken as decodeOffsetPageToken5,
|
|
6339
6330
|
paginateOffsetRows as paginateOffsetRows3
|
|
6340
6331
|
} from "@truefoundry/trueforge-core/agent-session/store/OffsetPageToken";
|
|
6341
6332
|
import { sql as sql13 } from "kysely";
|
|
@@ -6356,7 +6347,7 @@ function toRecord3(row) {
|
|
|
6356
6347
|
return {
|
|
6357
6348
|
...row,
|
|
6358
6349
|
manifest: parseStoredAgentSpec(row.manifest),
|
|
6359
|
-
created_by_subject:
|
|
6350
|
+
created_by_subject: CreatedBySubjectSchema7.parse(row.created_by_subject)
|
|
6360
6351
|
};
|
|
6361
6352
|
}
|
|
6362
6353
|
function catalogUsagePairs2({ entity, tenant_id }) {
|
|
@@ -6417,7 +6408,7 @@ var init_SqliteAgentStore = __esm({
|
|
|
6417
6408
|
const data2 = rows2.map(toRecord3);
|
|
6418
6409
|
return { data: data2, pagination: { limit: data2.length } };
|
|
6419
6410
|
}
|
|
6420
|
-
const offset =
|
|
6411
|
+
const offset = decodeOffsetPageToken5(input.page_token);
|
|
6421
6412
|
const rows = await query.limit(input.limit + 1).offset(offset).execute();
|
|
6422
6413
|
const { data, pagination } = paginateOffsetRows3(rows, input.limit, offset);
|
|
6423
6414
|
return { data: data.map(toRecord3), pagination };
|
|
@@ -6550,10 +6541,10 @@ __export(SqliteScheduleStore_exports, {
|
|
|
6550
6541
|
SqliteScheduleStore: () => SqliteScheduleStore
|
|
6551
6542
|
});
|
|
6552
6543
|
import {
|
|
6553
|
-
CreatedBySubjectSchema as
|
|
6544
|
+
CreatedBySubjectSchema as CreatedBySubjectSchema8
|
|
6554
6545
|
} from "@truefoundry/trueforge-core/agent-session";
|
|
6555
6546
|
import {
|
|
6556
|
-
decodeOffsetPageToken as
|
|
6547
|
+
decodeOffsetPageToken as decodeOffsetPageToken6,
|
|
6557
6548
|
paginateOffsetRows as paginateOffsetRows4
|
|
6558
6549
|
} from "@truefoundry/trueforge-core/agent-session/store/OffsetPageToken";
|
|
6559
6550
|
import { sql as sql14 } from "kysely";
|
|
@@ -6591,13 +6582,13 @@ function toScheduleRecord(row) {
|
|
|
6591
6582
|
return {
|
|
6592
6583
|
...row,
|
|
6593
6584
|
manifest: parseStoredScheduleManifest(row.manifest),
|
|
6594
|
-
created_by_subject:
|
|
6585
|
+
created_by_subject: CreatedBySubjectSchema8.parse(row.created_by_subject)
|
|
6595
6586
|
};
|
|
6596
6587
|
}
|
|
6597
6588
|
function toRunRecord(row) {
|
|
6598
6589
|
return {
|
|
6599
6590
|
...row,
|
|
6600
|
-
created_by_subject:
|
|
6591
|
+
created_by_subject: CreatedBySubjectSchema8.parse(row.created_by_subject)
|
|
6601
6592
|
};
|
|
6602
6593
|
}
|
|
6603
6594
|
var SqliteScheduleStore;
|
|
@@ -6722,7 +6713,7 @@ var init_SqliteScheduleStore = __esm({
|
|
|
6722
6713
|
await db.deleteFrom("schedule").where("tenant_id", "=", input.tenant_id).where("id", "=", input.id).execute();
|
|
6723
6714
|
}
|
|
6724
6715
|
async listSchedules(input, transaction) {
|
|
6725
|
-
const offset =
|
|
6716
|
+
const offset = decodeOffsetPageToken6(input.page_token);
|
|
6726
6717
|
const db = transaction ?? this.#db;
|
|
6727
6718
|
let query = db.selectFrom("schedule").select(scheduleColumns).where("tenant_id", "=", input.tenant_id);
|
|
6728
6719
|
if (input.agent_names !== void 0) {
|
|
@@ -6741,11 +6732,11 @@ var init_SqliteScheduleStore = __esm({
|
|
|
6741
6732
|
const rows = await db.selectFrom("schedule").select(["id", jsonText(sql14.ref("created_by_subject")).as("created_by_subject")]).where("tenant_id", "=", input.tenant_id).where("id", "in", [...input.ids]).execute();
|
|
6742
6733
|
return rows.map((row) => ({
|
|
6743
6734
|
id: row.id,
|
|
6744
|
-
created_by_subject:
|
|
6735
|
+
created_by_subject: CreatedBySubjectSchema8.parse(row.created_by_subject)
|
|
6745
6736
|
}));
|
|
6746
6737
|
}
|
|
6747
6738
|
async listRuns(input, transaction) {
|
|
6748
|
-
const offset =
|
|
6739
|
+
const offset = decodeOffsetPageToken6(input.page_token);
|
|
6749
6740
|
const db = transaction ?? this.#db;
|
|
6750
6741
|
const rows = await db.selectFrom("schedule_run").select(runColumns).where("tenant_id", "=", input.tenant_id).where("schedule_id", "=", input.schedule_id).orderBy("scheduled_for", "desc").orderBy("id").limit(input.limit + 1).offset(offset).execute();
|
|
6751
6742
|
const { data, pagination } = paginateOffsetRows4(rows, input.limit, offset);
|
|
@@ -6824,10 +6815,10 @@ __export(SqliteSandboxEnvironmentStore_exports, {
|
|
|
6824
6815
|
SqliteSandboxEnvironmentStore: () => SqliteSandboxEnvironmentStore
|
|
6825
6816
|
});
|
|
6826
6817
|
import {
|
|
6827
|
-
CreatedBySubjectSchema as
|
|
6818
|
+
CreatedBySubjectSchema as CreatedBySubjectSchema9
|
|
6828
6819
|
} from "@truefoundry/trueforge-core/agent-session";
|
|
6829
6820
|
import {
|
|
6830
|
-
decodeOffsetPageToken as
|
|
6821
|
+
decodeOffsetPageToken as decodeOffsetPageToken7,
|
|
6831
6822
|
paginateOffsetRows as paginateOffsetRows5
|
|
6832
6823
|
} from "@truefoundry/trueforge-core/agent-session/store/OffsetPageToken";
|
|
6833
6824
|
import { sql as sql15 } from "kysely";
|
|
@@ -6925,7 +6916,7 @@ function toEnvironmentRecord(row) {
|
|
|
6925
6916
|
description: row.description,
|
|
6926
6917
|
active_version: row.active_version,
|
|
6927
6918
|
lifecycle_stage: row.lifecycle_stage,
|
|
6928
|
-
created_by_subject:
|
|
6919
|
+
created_by_subject: CreatedBySubjectSchema9.parse(row.created_by_subject),
|
|
6929
6920
|
created_at: row.created_at,
|
|
6930
6921
|
updated_at: row.updated_at
|
|
6931
6922
|
};
|
|
@@ -6940,7 +6931,7 @@ function toVersionRecord(row) {
|
|
|
6940
6931
|
status_reason: row.status_reason,
|
|
6941
6932
|
external_ref: row.external_ref,
|
|
6942
6933
|
internal_metadata: SandboxEnvironmentVersionInternalMetadataSchema.parse(row.internal_metadata),
|
|
6943
|
-
created_by_subject:
|
|
6934
|
+
created_by_subject: CreatedBySubjectSchema9.parse(row.created_by_subject),
|
|
6944
6935
|
created_at: row.created_at,
|
|
6945
6936
|
updated_at: row.updated_at
|
|
6946
6937
|
};
|
|
@@ -6986,7 +6977,7 @@ var init_SqliteSandboxEnvironmentStore = __esm({
|
|
|
6986
6977
|
const rows2 = await query.execute();
|
|
6987
6978
|
return { data: rows2.map(toWithVersion), pagination: { limit: rows2.length } };
|
|
6988
6979
|
}
|
|
6989
|
-
const offset =
|
|
6980
|
+
const offset = decodeOffsetPageToken7(input.page_token);
|
|
6990
6981
|
const rows = await query.limit(input.limit + 1).offset(offset).execute();
|
|
6991
6982
|
const { data, pagination } = paginateOffsetRows5(rows, input.limit, offset);
|
|
6992
6983
|
return { data: data.map(toWithVersion), pagination };
|
|
@@ -7012,7 +7003,7 @@ var init_SqliteSandboxEnvironmentStore = __esm({
|
|
|
7012
7003
|
return rows.map((row) => ({
|
|
7013
7004
|
id: row.id,
|
|
7014
7005
|
name: row.name,
|
|
7015
|
-
created_by_subject:
|
|
7006
|
+
created_by_subject: CreatedBySubjectSchema9.parse(row.created_by_subject)
|
|
7016
7007
|
}));
|
|
7017
7008
|
}
|
|
7018
7009
|
async getActiveEnvironment(input, transaction) {
|
|
@@ -7376,6 +7367,77 @@ var init_SqliteSandboxEnvironmentStore = __esm({
|
|
|
7376
7367
|
}
|
|
7377
7368
|
});
|
|
7378
7369
|
|
|
7370
|
+
// src/db/sqlite/access-control-store/SqliteAccessControlStore.ts
|
|
7371
|
+
var SqliteAccessControlStore_exports = {};
|
|
7372
|
+
__export(SqliteAccessControlStore_exports, {
|
|
7373
|
+
SqliteAccessControlStore: () => SqliteAccessControlStore
|
|
7374
|
+
});
|
|
7375
|
+
function recordColumns7(eb) {
|
|
7376
|
+
return [
|
|
7377
|
+
"tenant_id",
|
|
7378
|
+
"session_id",
|
|
7379
|
+
"subject_type",
|
|
7380
|
+
"subject_id",
|
|
7381
|
+
jsonText(eb.ref("granted_by_subject")).as("granted_by_subject"),
|
|
7382
|
+
"created_at"
|
|
7383
|
+
];
|
|
7384
|
+
}
|
|
7385
|
+
var SqliteAccessControlStore;
|
|
7386
|
+
var init_SqliteAccessControlStore = __esm({
|
|
7387
|
+
"src/db/sqlite/access-control-store/SqliteAccessControlStore.ts"() {
|
|
7388
|
+
"use strict";
|
|
7389
|
+
init_sqlExpressions2();
|
|
7390
|
+
SqliteAccessControlStore = class {
|
|
7391
|
+
#db;
|
|
7392
|
+
constructor(db) {
|
|
7393
|
+
this.#db = db;
|
|
7394
|
+
}
|
|
7395
|
+
async createAccessGrants(input, transaction) {
|
|
7396
|
+
const db = transaction ?? this.#db;
|
|
7397
|
+
const timestamp = nowIso();
|
|
7398
|
+
await db.insertInto("access_control").values(
|
|
7399
|
+
input.subjects.map((subject) => ({
|
|
7400
|
+
tenant_id: input.tenant_id,
|
|
7401
|
+
session_id: input.session_id,
|
|
7402
|
+
subject_type: subject.subject_type,
|
|
7403
|
+
subject_id: subject.subject_id,
|
|
7404
|
+
granted_by_subject: jsonbBind(input.granted_by_subject),
|
|
7405
|
+
created_at: timestamp
|
|
7406
|
+
}))
|
|
7407
|
+
).onConflict((oc) => oc.columns(["tenant_id", "session_id", "subject_type", "subject_id"]).doNothing()).execute();
|
|
7408
|
+
}
|
|
7409
|
+
async listAccessGrants(input, transaction) {
|
|
7410
|
+
const { subjects } = input;
|
|
7411
|
+
if (input.session_ids.length === 0 || subjects?.length === 0) {
|
|
7412
|
+
return [];
|
|
7413
|
+
}
|
|
7414
|
+
const db = transaction ?? this.#db;
|
|
7415
|
+
let query = db.selectFrom("access_control").select(recordColumns7).where("tenant_id", "=", input.tenant_id).where("session_id", "in", [...input.session_ids]);
|
|
7416
|
+
if (subjects !== void 0) {
|
|
7417
|
+
query = query.where(
|
|
7418
|
+
(eb) => eb.or(
|
|
7419
|
+
subjects.map(
|
|
7420
|
+
(subject) => eb.and([eb("subject_type", "=", subject.subject_type), eb("subject_id", "=", subject.subject_id)])
|
|
7421
|
+
)
|
|
7422
|
+
)
|
|
7423
|
+
);
|
|
7424
|
+
}
|
|
7425
|
+
return await query.orderBy("session_id").orderBy("created_at").orderBy("subject_id").execute();
|
|
7426
|
+
}
|
|
7427
|
+
async deleteAccessGrants(input, transaction) {
|
|
7428
|
+
const db = transaction ?? this.#db;
|
|
7429
|
+
await db.deleteFrom("access_control").where("tenant_id", "=", input.tenant_id).where("session_id", "=", input.session_id).where(
|
|
7430
|
+
(eb) => eb.or(
|
|
7431
|
+
input.subjects.map(
|
|
7432
|
+
(subject) => eb.and([eb("subject_type", "=", subject.subject_type), eb("subject_id", "=", subject.subject_id)])
|
|
7433
|
+
)
|
|
7434
|
+
)
|
|
7435
|
+
).execute();
|
|
7436
|
+
}
|
|
7437
|
+
};
|
|
7438
|
+
}
|
|
7439
|
+
});
|
|
7440
|
+
|
|
7379
7441
|
// src/db/migratePostgres.ts
|
|
7380
7442
|
var migratePostgres_exports = {};
|
|
7381
7443
|
__export(migratePostgres_exports, {
|
|
@@ -7640,12 +7702,11 @@ async function assembleTurnRecord2(db, args) {
|
|
|
7640
7702
|
async function createTurn2(db, input) {
|
|
7641
7703
|
try {
|
|
7642
7704
|
await db.transaction().execute(async (trx) => {
|
|
7643
|
-
const locked = await trx.selectFrom("session").select(["
|
|
7705
|
+
const locked = await trx.selectFrom("session").select(["session_id"]).where("session_id", "=", input.session_id).forUpdate().executeTakeFirst();
|
|
7644
7706
|
if (!locked) {
|
|
7645
7707
|
throw new SessionNotFoundError5(input.session_id);
|
|
7646
7708
|
}
|
|
7647
7709
|
await trx.updateTable("session").set({
|
|
7648
|
-
last_turn_id: input.turn.turn_id,
|
|
7649
7710
|
last_turn_details: lastTurnDetails2({ turn_id: input.turn.turn_id, turn_state: input.turn.state }),
|
|
7650
7711
|
updated_at: sql17`now()`,
|
|
7651
7712
|
last_activity_timestamp_ms: input.last_activity_timestamp_ms,
|
|
@@ -7991,7 +8052,7 @@ var init_capabilities2 = __esm({
|
|
|
7991
8052
|
|
|
7992
8053
|
// src/db/postgres/session-store/queries/events.ts
|
|
7993
8054
|
import {
|
|
7994
|
-
decodeOffsetPageToken as
|
|
8055
|
+
decodeOffsetPageToken as decodeOffsetPageToken8,
|
|
7995
8056
|
paginateOffsetRows as paginateOffsetRows6
|
|
7996
8057
|
} from "@truefoundry/trueforge-core/agent-session/store/OffsetPageToken";
|
|
7997
8058
|
import {
|
|
@@ -8031,7 +8092,7 @@ async function appendToEvents2(db, input) {
|
|
|
8031
8092
|
}
|
|
8032
8093
|
}
|
|
8033
8094
|
async function listTurnEvents2(db, input) {
|
|
8034
|
-
const offset =
|
|
8095
|
+
const offset = decodeOffsetPageToken8(input.page_token);
|
|
8035
8096
|
const limit = input.limit;
|
|
8036
8097
|
const eventOrder = input.order === "desc" ? "desc" : "asc";
|
|
8037
8098
|
const rows = await db.selectFrom("turn as t").leftJoin(
|
|
@@ -8051,7 +8112,7 @@ async function listTurnEvents2(db, input) {
|
|
|
8051
8112
|
}
|
|
8052
8113
|
async function listSessionEvents2(db, input) {
|
|
8053
8114
|
const limit = input.limit;
|
|
8054
|
-
const session = await db.selectFrom("session").select("last_turn_id").where("session_id", "=", input.session_id).executeTakeFirst();
|
|
8115
|
+
const session = await db.selectFrom("session").select(sql19`last_turn_details->>'id'`.as("last_turn_id")).where("session_id", "=", input.session_id).executeTakeFirst();
|
|
8055
8116
|
if (!session) {
|
|
8056
8117
|
throw new SessionNotFoundError6(input.session_id);
|
|
8057
8118
|
}
|
|
@@ -8183,7 +8244,7 @@ var init_inboundEvents2 = __esm({
|
|
|
8183
8244
|
|
|
8184
8245
|
// src/db/postgres/session-store/queries/sessions.ts
|
|
8185
8246
|
import {
|
|
8186
|
-
CreatedBySubjectSchema as
|
|
8247
|
+
CreatedBySubjectSchema as CreatedBySubjectSchema10,
|
|
8187
8248
|
SessionLastTurnDetailsSchema as SessionLastTurnDetailsSchema4,
|
|
8188
8249
|
SessionMetadataSchema as SessionMetadataSchema3,
|
|
8189
8250
|
SessionSourceSchema as SessionSourceSchema2
|
|
@@ -8218,7 +8279,7 @@ function mapRowToSessionRecord2(row) {
|
|
|
8218
8279
|
return {
|
|
8219
8280
|
tenant_id: row.tenant_id,
|
|
8220
8281
|
session_id: row.session_id,
|
|
8221
|
-
created_by_subject:
|
|
8282
|
+
created_by_subject: CreatedBySubjectSchema10.parse(row.created_by_subject),
|
|
8222
8283
|
source: SessionSourceSchema2.nullable().parse(row.source),
|
|
8223
8284
|
agent: sessionAgentFromColumns({
|
|
8224
8285
|
session_id: row.session_id,
|
|
@@ -8227,8 +8288,6 @@ function mapRowToSessionRecord2(row) {
|
|
|
8227
8288
|
agent_spec: row.agent_spec
|
|
8228
8289
|
}),
|
|
8229
8290
|
title: row.title,
|
|
8230
|
-
shared: row.shared,
|
|
8231
|
-
last_turn_id: row.last_turn_id,
|
|
8232
8291
|
last_turn_details: SessionLastTurnDetailsSchema4.nullable().parse(row.last_turn_details),
|
|
8233
8292
|
external_id: row.external_id,
|
|
8234
8293
|
custom: parseSessionCustom2(row.custom),
|
|
@@ -8252,7 +8311,6 @@ async function createSession2(db, input) {
|
|
|
8252
8311
|
agent_name: columns.agent_name,
|
|
8253
8312
|
agent_spec: columns.agent_spec !== null ? json(columns.agent_spec) : null,
|
|
8254
8313
|
title: null,
|
|
8255
|
-
shared: false,
|
|
8256
8314
|
custom: input.custom !== null ? json(input.custom) : null,
|
|
8257
8315
|
metadata: json(input.metadata),
|
|
8258
8316
|
external_id: input.external_id,
|
|
@@ -8302,7 +8360,6 @@ async function updateSession2(db, input) {
|
|
|
8302
8360
|
const agent = input.agent;
|
|
8303
8361
|
const title = input.title;
|
|
8304
8362
|
const metadata = input.metadata;
|
|
8305
|
-
const shared2 = input.shared;
|
|
8306
8363
|
if (agent !== void 0) {
|
|
8307
8364
|
const existing = await getSession2(db, { tenant_id: input.tenant_id, session_id: input.session_id });
|
|
8308
8365
|
if (existing === void 0) {
|
|
@@ -8330,11 +8387,6 @@ async function updateSession2(db, input) {
|
|
|
8330
8387
|
return qb;
|
|
8331
8388
|
}
|
|
8332
8389
|
return qb.set({ metadata: json(metadata) });
|
|
8333
|
-
}).$if(shared2 !== void 0, (qb) => {
|
|
8334
|
-
if (shared2 === void 0) {
|
|
8335
|
-
return qb;
|
|
8336
|
-
}
|
|
8337
|
-
return qb.set({ shared: shared2 });
|
|
8338
8390
|
}).where("tenant_id", "=", input.tenant_id).where("session_id", "=", input.session_id).executeTakeFirst();
|
|
8339
8391
|
const numUpdatedRows = Number(result.numUpdatedRows);
|
|
8340
8392
|
if (numUpdatedRows === 0) {
|
|
@@ -8357,6 +8409,9 @@ async function listSessions2(db, input) {
|
|
|
8357
8409
|
query = query.where(sql21`metadata = '{}'::jsonb`);
|
|
8358
8410
|
} else {
|
|
8359
8411
|
query = query.where(sql21`metadata @> ${json(input.metadata)}`);
|
|
8412
|
+
for (const [key, value] of Object.entries(input.metadata)) {
|
|
8413
|
+
query = query.where(sql21`metadata->>${sql21.lit(key)}`, "=", value);
|
|
8414
|
+
}
|
|
8360
8415
|
}
|
|
8361
8416
|
}
|
|
8362
8417
|
if (input.source_type !== void 0) {
|
|
@@ -8635,8 +8690,8 @@ __export(PostgresSessionStore_exports, {
|
|
|
8635
8690
|
PostgresSessionStore: () => PostgresSessionStore
|
|
8636
8691
|
});
|
|
8637
8692
|
import {
|
|
8638
|
-
decodeOffsetPageToken as
|
|
8639
|
-
encodeOffsetPageToken as
|
|
8693
|
+
decodeOffsetPageToken as decodeOffsetPageToken9,
|
|
8694
|
+
encodeOffsetPageToken as encodeOffsetPageToken4
|
|
8640
8695
|
} from "@truefoundry/trueforge-core/agent-session/store/OffsetPageToken";
|
|
8641
8696
|
var PostgresSessionStore;
|
|
8642
8697
|
var init_PostgresSessionStore = __esm({
|
|
@@ -8714,7 +8769,7 @@ var init_PostgresSessionStore = __esm({
|
|
|
8714
8769
|
return getTurn2(this.db, input);
|
|
8715
8770
|
}
|
|
8716
8771
|
async listTurns(input) {
|
|
8717
|
-
const offset =
|
|
8772
|
+
const offset = decodeOffsetPageToken9(input.page_token);
|
|
8718
8773
|
const result = await listTurns2(this.db, {
|
|
8719
8774
|
session_id: input.session_id,
|
|
8720
8775
|
limit: input.limit,
|
|
@@ -8722,10 +8777,10 @@ var init_PostgresSessionStore = __esm({
|
|
|
8722
8777
|
});
|
|
8723
8778
|
const pagination = { limit: input.limit };
|
|
8724
8779
|
if (result.next_offset !== null) {
|
|
8725
|
-
pagination.next_page_token =
|
|
8780
|
+
pagination.next_page_token = encodeOffsetPageToken4(result.next_offset);
|
|
8726
8781
|
}
|
|
8727
8782
|
if (offset > 0) {
|
|
8728
|
-
pagination.previous_page_token =
|
|
8783
|
+
pagination.previous_page_token = encodeOffsetPageToken4(Math.max(0, offset - input.limit));
|
|
8729
8784
|
}
|
|
8730
8785
|
return { data: result.turns, pagination };
|
|
8731
8786
|
}
|
|
@@ -9409,9 +9464,9 @@ var PostgresScheduleStore_exports = {};
|
|
|
9409
9464
|
__export(PostgresScheduleStore_exports, {
|
|
9410
9465
|
PostgresScheduleStore: () => PostgresScheduleStore
|
|
9411
9466
|
});
|
|
9412
|
-
import { CreatedBySubjectSchema as
|
|
9467
|
+
import { CreatedBySubjectSchema as CreatedBySubjectSchema11 } from "@truefoundry/trueforge-core/agent-session";
|
|
9413
9468
|
import {
|
|
9414
|
-
decodeOffsetPageToken as
|
|
9469
|
+
decodeOffsetPageToken as decodeOffsetPageToken10,
|
|
9415
9470
|
paginateOffsetRows as paginateOffsetRows7
|
|
9416
9471
|
} from "@truefoundry/trueforge-core/agent-session/store/OffsetPageToken";
|
|
9417
9472
|
import "kysely";
|
|
@@ -9424,7 +9479,7 @@ function toScheduleRecord2(row) {
|
|
|
9424
9479
|
name: row.name,
|
|
9425
9480
|
manifest: parseStoredScheduleManifest(row.manifest),
|
|
9426
9481
|
status: row.status,
|
|
9427
|
-
created_by_subject:
|
|
9482
|
+
created_by_subject: CreatedBySubjectSchema11.parse(row.created_by_subject),
|
|
9428
9483
|
created_at: row.created_at.toISOString(),
|
|
9429
9484
|
updated_at: row.updated_at.toISOString()
|
|
9430
9485
|
};
|
|
@@ -9437,7 +9492,7 @@ function toRunRecord2(row) {
|
|
|
9437
9492
|
name: row.name,
|
|
9438
9493
|
scheduled_for: row.scheduled_for.toISOString(),
|
|
9439
9494
|
status: row.status,
|
|
9440
|
-
created_by_subject:
|
|
9495
|
+
created_by_subject: CreatedBySubjectSchema11.parse(row.created_by_subject),
|
|
9441
9496
|
triggered_at: row.triggered_at === null ? null : row.triggered_at.toISOString(),
|
|
9442
9497
|
reason: row.reason,
|
|
9443
9498
|
session_id: row.session_id,
|
|
@@ -9558,7 +9613,7 @@ var init_PostgresScheduleStore = __esm({
|
|
|
9558
9613
|
await db.deleteFrom("schedule").where("tenant_id", "=", input.tenant_id).where("id", "=", input.id).execute();
|
|
9559
9614
|
}
|
|
9560
9615
|
async listSchedules(input, transaction) {
|
|
9561
|
-
const offset =
|
|
9616
|
+
const offset = decodeOffsetPageToken10(input.page_token);
|
|
9562
9617
|
const db = transaction ?? this.#db;
|
|
9563
9618
|
let query = db.selectFrom("schedule").selectAll().where("tenant_id", "=", input.tenant_id);
|
|
9564
9619
|
if (input.agent_names !== void 0) {
|
|
@@ -9577,11 +9632,11 @@ var init_PostgresScheduleStore = __esm({
|
|
|
9577
9632
|
const rows = await db.selectFrom("schedule").select(["id", "created_by_subject"]).where("tenant_id", "=", input.tenant_id).where("id", "in", [...input.ids]).execute();
|
|
9578
9633
|
return rows.map((row) => ({
|
|
9579
9634
|
id: row.id,
|
|
9580
|
-
created_by_subject:
|
|
9635
|
+
created_by_subject: CreatedBySubjectSchema11.parse(row.created_by_subject)
|
|
9581
9636
|
}));
|
|
9582
9637
|
}
|
|
9583
9638
|
async listRuns(input, transaction) {
|
|
9584
|
-
const offset =
|
|
9639
|
+
const offset = decodeOffsetPageToken10(input.page_token);
|
|
9585
9640
|
const db = transaction ?? this.#db;
|
|
9586
9641
|
const rows = await db.selectFrom("schedule_run").selectAll().where("tenant_id", "=", input.tenant_id).where("schedule_id", "=", input.schedule_id).orderBy("scheduled_for", "desc").orderBy("id").limit(input.limit + 1).offset(offset).execute();
|
|
9587
9642
|
const { data, pagination } = paginateOffsetRows7(rows, input.limit, offset);
|
|
@@ -9658,9 +9713,9 @@ var PostgresSandboxEnvironmentStore_exports = {};
|
|
|
9658
9713
|
__export(PostgresSandboxEnvironmentStore_exports, {
|
|
9659
9714
|
PostgresSandboxEnvironmentStore: () => PostgresSandboxEnvironmentStore
|
|
9660
9715
|
});
|
|
9661
|
-
import { CreatedBySubjectSchema as
|
|
9716
|
+
import { CreatedBySubjectSchema as CreatedBySubjectSchema12 } from "@truefoundry/trueforge-core/agent-session";
|
|
9662
9717
|
import {
|
|
9663
|
-
decodeOffsetPageToken as
|
|
9718
|
+
decodeOffsetPageToken as decodeOffsetPageToken11,
|
|
9664
9719
|
paginateOffsetRows as paginateOffsetRows8
|
|
9665
9720
|
} from "@truefoundry/trueforge-core/agent-session/store/OffsetPageToken";
|
|
9666
9721
|
import { sql as sql25 } from "kysely";
|
|
@@ -9686,7 +9741,7 @@ function toEnvironmentRecord2(row) {
|
|
|
9686
9741
|
description: row.description,
|
|
9687
9742
|
active_version: row.active_version,
|
|
9688
9743
|
lifecycle_stage: row.lifecycle_stage,
|
|
9689
|
-
created_by_subject:
|
|
9744
|
+
created_by_subject: CreatedBySubjectSchema12.parse(row.created_by_subject),
|
|
9690
9745
|
created_at: row.created_at.toISOString(),
|
|
9691
9746
|
updated_at: row.updated_at.toISOString()
|
|
9692
9747
|
};
|
|
@@ -9701,7 +9756,7 @@ function toVersionRecord2(row) {
|
|
|
9701
9756
|
status_reason: row.status_reason,
|
|
9702
9757
|
external_ref: row.external_ref,
|
|
9703
9758
|
internal_metadata: SandboxEnvironmentVersionInternalMetadataSchema.parse(row.internal_metadata),
|
|
9704
|
-
created_by_subject:
|
|
9759
|
+
created_by_subject: CreatedBySubjectSchema12.parse(row.created_by_subject),
|
|
9705
9760
|
created_at: row.created_at.toISOString(),
|
|
9706
9761
|
updated_at: row.updated_at.toISOString()
|
|
9707
9762
|
};
|
|
@@ -9787,7 +9842,7 @@ var init_PostgresSandboxEnvironmentStore = __esm({
|
|
|
9787
9842
|
const rows2 = await query.execute();
|
|
9788
9843
|
return { data: rows2.map(toWithVersion2), pagination: { limit: rows2.length } };
|
|
9789
9844
|
}
|
|
9790
|
-
const offset =
|
|
9845
|
+
const offset = decodeOffsetPageToken11(input.page_token);
|
|
9791
9846
|
const rows = await query.limit(input.limit + 1).offset(offset).execute();
|
|
9792
9847
|
const { data, pagination } = paginateOffsetRows8(rows, input.limit, offset);
|
|
9793
9848
|
return { data: data.map(toWithVersion2), pagination };
|
|
@@ -9813,7 +9868,7 @@ var init_PostgresSandboxEnvironmentStore = __esm({
|
|
|
9813
9868
|
return rows.map((row) => ({
|
|
9814
9869
|
id: row.id,
|
|
9815
9870
|
name: row.name,
|
|
9816
|
-
created_by_subject:
|
|
9871
|
+
created_by_subject: CreatedBySubjectSchema12.parse(row.created_by_subject)
|
|
9817
9872
|
}));
|
|
9818
9873
|
}
|
|
9819
9874
|
async getActiveEnvironment(input, transaction) {
|
|
@@ -10141,6 +10196,74 @@ var init_PostgresSandboxEnvironmentStore = __esm({
|
|
|
10141
10196
|
}
|
|
10142
10197
|
});
|
|
10143
10198
|
|
|
10199
|
+
// src/db/postgres/access-control-store/PostgresAccessControlStore.ts
|
|
10200
|
+
var PostgresAccessControlStore_exports = {};
|
|
10201
|
+
__export(PostgresAccessControlStore_exports, {
|
|
10202
|
+
PostgresAccessControlStore: () => PostgresAccessControlStore
|
|
10203
|
+
});
|
|
10204
|
+
var PostgresAccessControlStore;
|
|
10205
|
+
var init_PostgresAccessControlStore = __esm({
|
|
10206
|
+
"src/db/postgres/access-control-store/PostgresAccessControlStore.ts"() {
|
|
10207
|
+
"use strict";
|
|
10208
|
+
init_sqlExpressions();
|
|
10209
|
+
PostgresAccessControlStore = class {
|
|
10210
|
+
#db;
|
|
10211
|
+
constructor(db) {
|
|
10212
|
+
this.#db = db;
|
|
10213
|
+
}
|
|
10214
|
+
async createAccessGrants(input, transaction) {
|
|
10215
|
+
const db = transaction ?? this.#db;
|
|
10216
|
+
await db.insertInto("access_control").values(
|
|
10217
|
+
input.subjects.map((subject) => ({
|
|
10218
|
+
tenant_id: input.tenant_id,
|
|
10219
|
+
session_id: input.session_id,
|
|
10220
|
+
subject_type: subject.subject_type,
|
|
10221
|
+
subject_id: subject.subject_id,
|
|
10222
|
+
granted_by_subject: json(input.granted_by_subject),
|
|
10223
|
+
created_at: now()
|
|
10224
|
+
}))
|
|
10225
|
+
).onConflict((oc) => oc.columns(["tenant_id", "session_id", "subject_type", "subject_id"]).doNothing()).execute();
|
|
10226
|
+
}
|
|
10227
|
+
async listAccessGrants(input, transaction) {
|
|
10228
|
+
const { subjects } = input;
|
|
10229
|
+
if (input.session_ids.length === 0 || subjects?.length === 0) {
|
|
10230
|
+
return [];
|
|
10231
|
+
}
|
|
10232
|
+
const db = transaction ?? this.#db;
|
|
10233
|
+
let query = db.selectFrom("access_control").selectAll().where("tenant_id", "=", input.tenant_id).where("session_id", "in", [...input.session_ids]);
|
|
10234
|
+
if (subjects !== void 0) {
|
|
10235
|
+
query = query.where(
|
|
10236
|
+
(eb) => eb.or(
|
|
10237
|
+
subjects.map(
|
|
10238
|
+
(subject) => eb.and([eb("subject_type", "=", subject.subject_type), eb("subject_id", "=", subject.subject_id)])
|
|
10239
|
+
)
|
|
10240
|
+
)
|
|
10241
|
+
);
|
|
10242
|
+
}
|
|
10243
|
+
const rows = await query.orderBy("session_id").orderBy("created_at").orderBy("subject_id").execute();
|
|
10244
|
+
return rows.map((row) => ({
|
|
10245
|
+
tenant_id: row.tenant_id,
|
|
10246
|
+
session_id: row.session_id,
|
|
10247
|
+
subject_type: row.subject_type,
|
|
10248
|
+
subject_id: row.subject_id,
|
|
10249
|
+
granted_by_subject: row.granted_by_subject,
|
|
10250
|
+
created_at: row.created_at.toISOString()
|
|
10251
|
+
}));
|
|
10252
|
+
}
|
|
10253
|
+
async deleteAccessGrants(input, transaction) {
|
|
10254
|
+
const db = transaction ?? this.#db;
|
|
10255
|
+
await db.deleteFrom("access_control").where("tenant_id", "=", input.tenant_id).where("session_id", "=", input.session_id).where(
|
|
10256
|
+
(eb) => eb.or(
|
|
10257
|
+
input.subjects.map(
|
|
10258
|
+
(subject) => eb.and([eb("subject_type", "=", subject.subject_type), eb("subject_id", "=", subject.subject_id)])
|
|
10259
|
+
)
|
|
10260
|
+
)
|
|
10261
|
+
).execute();
|
|
10262
|
+
}
|
|
10263
|
+
};
|
|
10264
|
+
}
|
|
10265
|
+
});
|
|
10266
|
+
|
|
10144
10267
|
// src/main.ts
|
|
10145
10268
|
import {
|
|
10146
10269
|
configureOperationMetrics,
|
|
@@ -10192,10 +10315,10 @@ import { RequestReplyExecutor, RequestReplyRouter } from "@truefoundry/trueforge
|
|
|
10192
10315
|
|
|
10193
10316
|
// src/app.ts
|
|
10194
10317
|
import { swaggerUI } from "@hono/swagger-ui";
|
|
10195
|
-
import { OpenAPIHono as
|
|
10318
|
+
import { OpenAPIHono as OpenAPIHono21, z as z43 } from "@hono/zod-openapi";
|
|
10196
10319
|
import { extractErrorLogFields as extractErrorLogFields7 } from "@truefoundry/trueforge-core/core";
|
|
10197
10320
|
import { bodyLimit } from "hono/body-limit";
|
|
10198
|
-
import { HTTPException as
|
|
10321
|
+
import { HTTPException as HTTPException19 } from "hono/http-exception";
|
|
10199
10322
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
10200
10323
|
|
|
10201
10324
|
// src/apis/agents.ts
|
|
@@ -10481,6 +10604,7 @@ var TOKEN_PAGINATION = {
|
|
|
10481
10604
|
var OPENAPI_DOCUMENT_TAGS = [
|
|
10482
10605
|
{ name: "Internal" /* INTERNAL */ },
|
|
10483
10606
|
{ name: "Auth" /* AUTH */ },
|
|
10607
|
+
{ name: "Users" /* USERS */ },
|
|
10484
10608
|
{ name: "Capabilities" /* CAPABILITIES */ },
|
|
10485
10609
|
{ name: "Models" /* MODELS */ },
|
|
10486
10610
|
{ name: "MCP Servers" /* MCP_SERVERS */ },
|
|
@@ -11155,7 +11279,20 @@ async function canReadAgentBoundResource(input) {
|
|
|
11155
11279
|
return managedAgentIds.includes(agent_id);
|
|
11156
11280
|
}
|
|
11157
11281
|
async function canReadSession(input) {
|
|
11158
|
-
|
|
11282
|
+
const { context } = input;
|
|
11283
|
+
if (input.created_by_subject_id === context.subject.id) {
|
|
11284
|
+
return true;
|
|
11285
|
+
}
|
|
11286
|
+
const subjects = [{ subject_type: "tenant", subject_id: context.tenant_id }];
|
|
11287
|
+
if (context.subject.type === "user") {
|
|
11288
|
+
subjects.push({ subject_type: "user", subject_id: context.subject.id });
|
|
11289
|
+
}
|
|
11290
|
+
const grants = await input.accessControlStore.listAccessGrants({
|
|
11291
|
+
tenant_id: context.tenant_id,
|
|
11292
|
+
session_ids: [input.session_id],
|
|
11293
|
+
subjects
|
|
11294
|
+
});
|
|
11295
|
+
if (grants.length > 0) {
|
|
11159
11296
|
return true;
|
|
11160
11297
|
}
|
|
11161
11298
|
return canReadAgentBoundResource(input);
|
|
@@ -12253,11 +12390,17 @@ var SettingsCapabilitySchema = z12.object({
|
|
|
12253
12390
|
var WebSearchCapabilitySchema = z12.object({
|
|
12254
12391
|
enabled: z12.boolean().describe("Whether a host web-search provider is configured.")
|
|
12255
12392
|
}).openapi("WebSearchCapability");
|
|
12393
|
+
var SessionSharingCapabilitySchema = z12.object({
|
|
12394
|
+
enabled: z12.boolean().describe(
|
|
12395
|
+
"Whether sessions can be shared with specific users. Sharing with the whole tenant is always available."
|
|
12396
|
+
)
|
|
12397
|
+
}).openapi("SessionSharingCapability");
|
|
12256
12398
|
var CapabilitiesDataSchema = z12.object({
|
|
12257
12399
|
sandbox: SandboxCapabilitySchema,
|
|
12258
12400
|
skill: SkillCapabilitySchema,
|
|
12259
12401
|
settings: SettingsCapabilitySchema,
|
|
12260
|
-
web_search: WebSearchCapabilitySchema
|
|
12402
|
+
web_search: WebSearchCapabilitySchema,
|
|
12403
|
+
session_sharing: SessionSharingCapabilitySchema
|
|
12261
12404
|
}).openapi("CapabilitiesData");
|
|
12262
12405
|
var GetCapabilitiesResponseSchema = z12.object({
|
|
12263
12406
|
data: CapabilitiesDataSchema
|
|
@@ -12390,7 +12533,8 @@ function createCapabilitiesRouter(deps) {
|
|
|
12390
12533
|
sandbox: { enabled: sandboxEnabled },
|
|
12391
12534
|
skill: sandboxEnabled ? { enabled: true } : { enabled: false, reason: skillDisabledReason(status) },
|
|
12392
12535
|
settings: { enabled: settingsEnabled },
|
|
12393
|
-
web_search: { enabled: webSearchEnabled }
|
|
12536
|
+
web_search: { enabled: webSearchEnabled },
|
|
12537
|
+
session_sharing: { enabled: deps.userStore.supportsUserLookup }
|
|
12394
12538
|
}
|
|
12395
12539
|
},
|
|
12396
12540
|
200
|
|
@@ -15760,7 +15904,7 @@ import { HTTPException as HTTPException12 } from "hono/http-exception";
|
|
|
15760
15904
|
import { streamSSE } from "hono/streaming";
|
|
15761
15905
|
|
|
15762
15906
|
// src/routes/turnRoutes.ts
|
|
15763
|
-
import { createRoute as createRoute13, z as
|
|
15907
|
+
import { createRoute as createRoute13, z as z35 } from "@hono/zod-openapi";
|
|
15764
15908
|
|
|
15765
15909
|
// src/schemas/events.ts
|
|
15766
15910
|
init_common();
|
|
@@ -15884,7 +16028,7 @@ var DownloadSandboxFileRequestQuerySchema = z30.object({
|
|
|
15884
16028
|
}).openapi("DownloadSandboxFileRequestQuery");
|
|
15885
16029
|
|
|
15886
16030
|
// src/routes/sessionRoutes.ts
|
|
15887
|
-
import { createRoute as createRoute12, z as
|
|
16031
|
+
import { createRoute as createRoute12, z as z34 } from "@hono/zod-openapi";
|
|
15888
16032
|
|
|
15889
16033
|
// src/schemas/session.ts
|
|
15890
16034
|
init_common();
|
|
@@ -15997,7 +16141,7 @@ var UpdateSessionRequestSchema = z32.object({
|
|
|
15997
16141
|
agent: SessionAgentSpecBodySchema.optional(),
|
|
15998
16142
|
title: SessionTitleSchema.optional(),
|
|
15999
16143
|
metadata: SessionMetadataSchema.optional(),
|
|
16000
|
-
shared: z32.boolean().optional().describe("
|
|
16144
|
+
shared: z32.boolean().optional().describe("Deprecated; use `POST /sessions/{session_id}/grants` with a `tenant` subject.").openapi({ deprecated: true })
|
|
16001
16145
|
}).strict().openapi("UpdateSessionRequest");
|
|
16002
16146
|
var IsoTimestampQueryParam = z32.iso.datetime({ offset: true }).openapi({ type: "string", format: "date-time" }).transform((s) => new Date(s));
|
|
16003
16147
|
var LIST_SESSIONS_METADATA_FILTER_MAX_KEYS = 10;
|
|
@@ -16045,9 +16189,31 @@ var ListSessionsResponseSchema = z32.object({
|
|
|
16045
16189
|
pagination: TokenPaginationSchema6
|
|
16046
16190
|
}).openapi("ListSessionsResponse");
|
|
16047
16191
|
|
|
16192
|
+
// src/schemas/sessionGrant.ts
|
|
16193
|
+
import { z as z33 } from "@hono/zod-openapi";
|
|
16194
|
+
import { CreatedBySubjectSchema as CreatedBySubjectSchema4 } from "@truefoundry/trueforge-core/agent-session";
|
|
16195
|
+
var SESSION_GRANT_MAX_SUBJECTS_PER_LIST = 50;
|
|
16196
|
+
var SessionGrantSubjectTypeSchema = z33.enum(["user", "tenant"]).describe("Kind of subject. A `tenant` subject shares the session with everyone in the tenant.").openapi("SessionGrantSubjectType");
|
|
16197
|
+
var SessionGrantSubjectSchema = z33.object({
|
|
16198
|
+
subject_type: SessionGrantSubjectTypeSchema,
|
|
16199
|
+
subject_id: z33.string().min(1).max(255).describe("ID of the subject.")
|
|
16200
|
+
}).strict().describe("Who the session is shared with.").openapi("SessionGrantSubject");
|
|
16201
|
+
var SessionGrantSchema = z33.object({
|
|
16202
|
+
subject: SessionGrantSubjectSchema,
|
|
16203
|
+
granted_by_subject: CreatedBySubjectSchema4,
|
|
16204
|
+
created_at: z33.string().describe("When the session was shared with the subject (ISO-8601 UTC).")
|
|
16205
|
+
}).strict().openapi("SessionGrant");
|
|
16206
|
+
var ListSessionGrantsResponseSchema = z33.object({ data: z33.array(SessionGrantSchema) }).openapi("ListSessionGrantsResponse");
|
|
16207
|
+
var UpdateSessionGrantsRequestSchema = z33.object({
|
|
16208
|
+
grant: z33.array(SessionGrantSubjectSchema).max(SESSION_GRANT_MAX_SUBJECTS_PER_LIST).optional().default([]).describe(`Subjects to share the session with (up to ${String(SESSION_GRANT_MAX_SUBJECTS_PER_LIST)}).`),
|
|
16209
|
+
revoke: z33.array(SessionGrantSubjectSchema).max(SESSION_GRANT_MAX_SUBJECTS_PER_LIST).optional().default([]).describe(`Subjects to remove access for (up to ${String(SESSION_GRANT_MAX_SUBJECTS_PER_LIST)}).`)
|
|
16210
|
+
}).strict().refine((body) => body.grant.length + body.revoke.length > 0, {
|
|
16211
|
+
message: "At least one subject to grant or revoke is required."
|
|
16212
|
+
}).openapi("UpdateSessionGrantsRequest");
|
|
16213
|
+
|
|
16048
16214
|
// src/routes/sessionRoutes.ts
|
|
16049
|
-
var SessionIdParamsSchema =
|
|
16050
|
-
session_id:
|
|
16215
|
+
var SessionIdParamsSchema = z34.object({
|
|
16216
|
+
session_id: z34.string().min(1).max(64).describe("Session identifier.")
|
|
16051
16217
|
});
|
|
16052
16218
|
var createSessionRoute = createRoute12({
|
|
16053
16219
|
method: "post",
|
|
@@ -16298,10 +16464,74 @@ var listSessionEventsRoute = createRoute12({
|
|
|
16298
16464
|
}
|
|
16299
16465
|
}
|
|
16300
16466
|
});
|
|
16467
|
+
var listSessionGrantsRoute = createRoute12({
|
|
16468
|
+
method: "get",
|
|
16469
|
+
path: "/{session_id}/grants",
|
|
16470
|
+
tags: ["Agent Sessions" /* AGENT_SESSIONS */],
|
|
16471
|
+
summary: "List session grants",
|
|
16472
|
+
description: "List the subjects this session is shared with.",
|
|
16473
|
+
"x-fern-sdk-group-name": ["sessions"],
|
|
16474
|
+
"x-fern-sdk-method-name": "list_grants",
|
|
16475
|
+
request: {
|
|
16476
|
+
params: SessionIdParamsSchema
|
|
16477
|
+
},
|
|
16478
|
+
responses: {
|
|
16479
|
+
200: {
|
|
16480
|
+
content: { "application/json": { schema: ListSessionGrantsResponseSchema } },
|
|
16481
|
+
description: "Subjects the session is shared with."
|
|
16482
|
+
},
|
|
16483
|
+
403: {
|
|
16484
|
+
content: { "application/json": { schema: RequestErrorResponseSchema } },
|
|
16485
|
+
description: "User does not have permission."
|
|
16486
|
+
},
|
|
16487
|
+
404: {
|
|
16488
|
+
content: { "application/json": { schema: RequestErrorResponseSchema } },
|
|
16489
|
+
description: "Session not found."
|
|
16490
|
+
}
|
|
16491
|
+
}
|
|
16492
|
+
});
|
|
16493
|
+
var updateSessionGrantsRoute = createRoute12({
|
|
16494
|
+
method: "post",
|
|
16495
|
+
path: "/{session_id}/grants",
|
|
16496
|
+
tags: ["Agent Sessions" /* AGENT_SESSIONS */],
|
|
16497
|
+
summary: "Update session grants",
|
|
16498
|
+
description: "Share this session with subjects and remove access for others in one atomic request. Subjects get read access to the session, its turns and its events. A `tenant` subject, whose `subject_id` must be your tenant ID, shares with everyone in the tenant. Granting an existing subject or revoking one without access is a no-op. Returns every subject the session is shared with.",
|
|
16499
|
+
"x-fern-sdk-group-name": ["sessions"],
|
|
16500
|
+
"x-fern-sdk-method-name": "update_grants",
|
|
16501
|
+
request: {
|
|
16502
|
+
params: SessionIdParamsSchema,
|
|
16503
|
+
body: {
|
|
16504
|
+
content: { "application/json": { schema: UpdateSessionGrantsRequestSchema } },
|
|
16505
|
+
required: true
|
|
16506
|
+
}
|
|
16507
|
+
},
|
|
16508
|
+
responses: {
|
|
16509
|
+
200: {
|
|
16510
|
+
content: { "application/json": { schema: ListSessionGrantsResponseSchema } },
|
|
16511
|
+
description: "Subjects the session is shared with after the change."
|
|
16512
|
+
},
|
|
16513
|
+
400: {
|
|
16514
|
+
content: { "application/json": { schema: RequestErrorResponseSchema } },
|
|
16515
|
+
description: "Invalid request body."
|
|
16516
|
+
},
|
|
16517
|
+
403: {
|
|
16518
|
+
content: { "application/json": { schema: RequestErrorResponseSchema } },
|
|
16519
|
+
description: "User does not have permission."
|
|
16520
|
+
},
|
|
16521
|
+
404: {
|
|
16522
|
+
content: { "application/json": { schema: RequestErrorResponseSchema } },
|
|
16523
|
+
description: "Session not found."
|
|
16524
|
+
},
|
|
16525
|
+
422: {
|
|
16526
|
+
content: { "application/json": { schema: RequestErrorResponseSchema } },
|
|
16527
|
+
description: "A subject to grant is unknown or is the session creator, or a subject is both granted and revoked."
|
|
16528
|
+
}
|
|
16529
|
+
}
|
|
16530
|
+
});
|
|
16301
16531
|
|
|
16302
16532
|
// src/routes/turnRoutes.ts
|
|
16303
16533
|
var TurnIdParamsSchema = SessionIdParamsSchema.extend({
|
|
16304
|
-
turn_id:
|
|
16534
|
+
turn_id: z35.string().min(1).describe("Turn identifier.")
|
|
16305
16535
|
});
|
|
16306
16536
|
var listTurnsRoute = createRoute13({
|
|
16307
16537
|
method: "get",
|
|
@@ -16375,7 +16605,7 @@ var downloadSandboxFileRoute = createRoute13({
|
|
|
16375
16605
|
},
|
|
16376
16606
|
responses: {
|
|
16377
16607
|
200: {
|
|
16378
|
-
content: { "application/octet-stream": { schema:
|
|
16608
|
+
content: { "application/octet-stream": { schema: z35.string().openapi({ format: "binary" }) } },
|
|
16379
16609
|
description: "File contents."
|
|
16380
16610
|
},
|
|
16381
16611
|
400: {
|
|
@@ -16861,10 +17091,11 @@ init_sandboxEnvironment();
|
|
|
16861
17091
|
|
|
16862
17092
|
// src/truefoundry/gatewayMetadata.ts
|
|
16863
17093
|
import { HTTPException as HTTPException11 } from "hono/http-exception";
|
|
16864
|
-
import { z as
|
|
17094
|
+
import { z as z36 } from "zod";
|
|
16865
17095
|
var X_TFY_METADATA = "x-tfy-metadata";
|
|
17096
|
+
var X_TFY_CONVERSATION_ID = "x-tfy-conversation-id";
|
|
16866
17097
|
var TFG_METADATA_PREFIX = "tfg";
|
|
16867
|
-
var GatewayMetadataSchema =
|
|
17098
|
+
var GatewayMetadataSchema = z36.record(z36.string().min(1), z36.string());
|
|
16868
17099
|
function parseGatewayMetadataHeader(raw) {
|
|
16869
17100
|
let decoded;
|
|
16870
17101
|
try {
|
|
@@ -16924,14 +17155,17 @@ function gatewayMetadataHeadersForTurn(turnMetadata) {
|
|
|
16924
17155
|
return {};
|
|
16925
17156
|
}
|
|
16926
17157
|
const raw = headerValue(turnMetadata.requestHeaders, X_TFY_METADATA);
|
|
16927
|
-
return
|
|
16928
|
-
|
|
16929
|
-
|
|
16930
|
-
|
|
16931
|
-
|
|
16932
|
-
|
|
16933
|
-
|
|
16934
|
-
|
|
17158
|
+
return {
|
|
17159
|
+
...gatewayMetadataHeaders(
|
|
17160
|
+
mergeGatewayMetadata({
|
|
17161
|
+
sessionId: turnMetadata.sessionId,
|
|
17162
|
+
turnId: turnMetadata.turnId,
|
|
17163
|
+
...turnMetadata.agent === void 0 ? {} : { agent: turnMetadata.agent },
|
|
17164
|
+
requestMetadata: raw === void 0 ? {} : parseGatewayMetadataHeader(raw)
|
|
17165
|
+
})
|
|
17166
|
+
),
|
|
17167
|
+
[X_TFY_CONVERSATION_ID]: turnMetadata.sessionId
|
|
17168
|
+
};
|
|
16935
17169
|
}
|
|
16936
17170
|
function headerValue(headers, name) {
|
|
16937
17171
|
if (headers === void 0) {
|
|
@@ -17205,7 +17439,7 @@ async function beginTurnExecution(params) {
|
|
|
17205
17439
|
...requestHeaders === void 0 ? {} : { requestHeaders }
|
|
17206
17440
|
}
|
|
17207
17441
|
});
|
|
17208
|
-
const title = session.record.
|
|
17442
|
+
const title = session.record.last_turn_details ? void 0 : deriveSessionTitle(input);
|
|
17209
17443
|
const turn = await session.createTurn({
|
|
17210
17444
|
turn_id: turnId,
|
|
17211
17445
|
active_executor_id: config_default.EXECUTOR_ID,
|
|
@@ -17311,7 +17545,8 @@ function createTurnsRouter(deps) {
|
|
|
17311
17545
|
return c.json({ error: { message: `Session not found: ${sessionId}` } }, 404);
|
|
17312
17546
|
}
|
|
17313
17547
|
const allowed = await canReadSession({
|
|
17314
|
-
|
|
17548
|
+
session_id: session.record.session_id,
|
|
17549
|
+
accessControlStore: deps.accessControlStore,
|
|
17315
17550
|
store: deps.resolveAgentStore(c),
|
|
17316
17551
|
context: requestContext,
|
|
17317
17552
|
authorizer: deps.authorizer,
|
|
@@ -17345,7 +17580,8 @@ function createTurnsRouter(deps) {
|
|
|
17345
17580
|
return c.json({ error: { message: `Session not found: ${sessionId}` } }, 404);
|
|
17346
17581
|
}
|
|
17347
17582
|
const allowed = await canReadSession({
|
|
17348
|
-
|
|
17583
|
+
session_id: session.record.session_id,
|
|
17584
|
+
accessControlStore: deps.accessControlStore,
|
|
17349
17585
|
store: deps.resolveAgentStore(c),
|
|
17350
17586
|
context: requestContext,
|
|
17351
17587
|
authorizer: deps.authorizer,
|
|
@@ -17430,7 +17666,8 @@ function createTurnsRouter(deps) {
|
|
|
17430
17666
|
return c.json({ error: { message: `Session not found: ${sessionId}` } }, 404);
|
|
17431
17667
|
}
|
|
17432
17668
|
const allowed = await canReadSession({
|
|
17433
|
-
|
|
17669
|
+
session_id: session.record.session_id,
|
|
17670
|
+
accessControlStore: deps.accessControlStore,
|
|
17434
17671
|
store: deps.resolveAgentStore(c),
|
|
17435
17672
|
context: requestContext,
|
|
17436
17673
|
authorizer: deps.authorizer,
|
|
@@ -18079,13 +18316,13 @@ import { OpenAPIHono as OpenAPIHono13 } from "@hono/zod-openapi";
|
|
|
18079
18316
|
import { createRoute as createRoute14 } from "@hono/zod-openapi";
|
|
18080
18317
|
|
|
18081
18318
|
// src/schemas/sessionMetrics.ts
|
|
18082
|
-
import { z as
|
|
18319
|
+
import { z as z37 } from "@hono/zod-openapi";
|
|
18083
18320
|
var MAX_SESSION_METRICS_WINDOW_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
18084
|
-
var SessionMetricsPointSchema =
|
|
18085
|
-
timestamp:
|
|
18086
|
-
value:
|
|
18321
|
+
var SessionMetricsPointSchema = z37.object({
|
|
18322
|
+
timestamp: z37.string(),
|
|
18323
|
+
value: z37.number().nonnegative()
|
|
18087
18324
|
}).strict().openapi("SessionMetricsPoint");
|
|
18088
|
-
var SessionMetricsMeterNameSchema =
|
|
18325
|
+
var SessionMetricsMeterNameSchema = z37.enum([
|
|
18089
18326
|
"total_sessions",
|
|
18090
18327
|
"total_cost_in_usd",
|
|
18091
18328
|
"total_turns",
|
|
@@ -18102,47 +18339,47 @@ var SessionMetricsMeterNameSchema = z36.enum([
|
|
|
18102
18339
|
var METRICS_USD_FERN_ENUM = {
|
|
18103
18340
|
$: { name: "USD" }
|
|
18104
18341
|
};
|
|
18105
|
-
var MetricsUnitSchema =
|
|
18342
|
+
var MetricsUnitSchema = z37.enum(["count", "$", "ms"]).openapi("MetricsUnit", {
|
|
18106
18343
|
"x-fern-enum": METRICS_USD_FERN_ENUM
|
|
18107
18344
|
});
|
|
18108
|
-
var SessionMetricsMeterSchema =
|
|
18345
|
+
var SessionMetricsMeterSchema = z37.object({
|
|
18109
18346
|
name: SessionMetricsMeterNameSchema,
|
|
18110
|
-
aggregate_value:
|
|
18111
|
-
description:
|
|
18347
|
+
aggregate_value: z37.number().nonnegative(),
|
|
18348
|
+
description: z37.string(),
|
|
18112
18349
|
unit: MetricsUnitSchema
|
|
18113
18350
|
}).strict().openapi("SessionMetricsMeter");
|
|
18114
|
-
var SessionMetricsMeterResponseSchema =
|
|
18115
|
-
meters:
|
|
18351
|
+
var SessionMetricsMeterResponseSchema = z37.object({
|
|
18352
|
+
meters: z37.array(SessionMetricsMeterSchema)
|
|
18116
18353
|
}).strict().openapi("SessionMetricsMeterResponse");
|
|
18117
|
-
var SessionMetricsChartNameSchema =
|
|
18118
|
-
var SessionMetricsChartSchema =
|
|
18354
|
+
var SessionMetricsChartNameSchema = z37.enum(["sessions_over_time", "sessions_cost_over_time", "turns_over_time"]).describe("Session metrics chart to return.").openapi("SessionMetricsChartName");
|
|
18355
|
+
var SessionMetricsChartSchema = z37.object({
|
|
18119
18356
|
name: SessionMetricsChartNameSchema,
|
|
18120
|
-
display_name:
|
|
18121
|
-
description:
|
|
18122
|
-
chart_type:
|
|
18357
|
+
display_name: z37.string(),
|
|
18358
|
+
description: z37.string(),
|
|
18359
|
+
chart_type: z37.literal("line")
|
|
18123
18360
|
}).strict().openapi("SessionMetricsChart");
|
|
18124
|
-
var SessionMetricsChartResponseSchema =
|
|
18125
|
-
charts:
|
|
18361
|
+
var SessionMetricsChartResponseSchema = z37.object({
|
|
18362
|
+
charts: z37.array(SessionMetricsChartSchema)
|
|
18126
18363
|
}).strict().openapi("SessionMetricsChartResponse");
|
|
18127
|
-
var SessionMetricsGraphLineSchema =
|
|
18128
|
-
name:
|
|
18129
|
-
values:
|
|
18364
|
+
var SessionMetricsGraphLineSchema = z37.object({
|
|
18365
|
+
name: z37.string(),
|
|
18366
|
+
values: z37.array(SessionMetricsPointSchema)
|
|
18130
18367
|
}).strict().openapi("SessionMetricsGraphLine");
|
|
18131
|
-
var SessionMetricsGraphSchema =
|
|
18368
|
+
var SessionMetricsGraphSchema = z37.object({
|
|
18132
18369
|
name: SessionMetricsChartNameSchema,
|
|
18133
|
-
display_name:
|
|
18134
|
-
description:
|
|
18370
|
+
display_name: z37.string(),
|
|
18371
|
+
description: z37.string(),
|
|
18135
18372
|
unit: MetricsUnitSchema,
|
|
18136
|
-
chart_type:
|
|
18137
|
-
graph_lines:
|
|
18373
|
+
chart_type: z37.literal("line"),
|
|
18374
|
+
graph_lines: z37.array(SessionMetricsGraphLineSchema)
|
|
18138
18375
|
}).strict().openapi("SessionMetricsGraph");
|
|
18139
|
-
var SessionMetricsChartDataResponseSchema =
|
|
18140
|
-
step:
|
|
18141
|
-
graphs:
|
|
18376
|
+
var SessionMetricsChartDataResponseSchema = z37.object({
|
|
18377
|
+
step: z37.string(),
|
|
18378
|
+
graphs: z37.array(SessionMetricsGraphSchema)
|
|
18142
18379
|
}).strict().openapi("SessionMetricsChartDataResponse");
|
|
18143
|
-
var IsoTimestampQueryParam2 =
|
|
18144
|
-
var GetSessionMetricsRequestQueryObjectSchema =
|
|
18145
|
-
agent_id:
|
|
18380
|
+
var IsoTimestampQueryParam2 = z37.iso.datetime({ offset: true }).openapi({ type: "string", format: "date-time" }).transform((s) => new Date(s));
|
|
18381
|
+
var GetSessionMetricsRequestQueryObjectSchema = z37.object({
|
|
18382
|
+
agent_id: z37.string().min(1).max(64).describe("Named agent identifier."),
|
|
18146
18383
|
start_timestamp: IsoTimestampQueryParam2.describe("Inclusive lower bound on session `created_at`."),
|
|
18147
18384
|
end_timestamp: IsoTimestampQueryParam2.describe("Inclusive upper bound on session `created_at`.")
|
|
18148
18385
|
});
|
|
@@ -18167,17 +18404,17 @@ function refineSessionMetricsTimeWindow(query, ctx) {
|
|
|
18167
18404
|
var GetSessionMetricsRequestQuerySchema = GetSessionMetricsRequestQueryObjectSchema.superRefine(
|
|
18168
18405
|
refineSessionMetricsTimeWindow
|
|
18169
18406
|
).openapi("GetSessionMetricsRequestQuery");
|
|
18170
|
-
var GetSessionMetricsChartDataRequestQuerySchema =
|
|
18407
|
+
var GetSessionMetricsChartDataRequestQuerySchema = z37.object({
|
|
18171
18408
|
...GetSessionMetricsRequestQueryObjectSchema.shape,
|
|
18172
18409
|
chart_name: SessionMetricsChartNameSchema
|
|
18173
18410
|
}).superRefine(refineSessionMetricsTimeWindow).openapi("GetSessionMetricsChartDataRequestQuery");
|
|
18174
|
-
var GetSessionMetricsMeterResponseSchema =
|
|
18411
|
+
var GetSessionMetricsMeterResponseSchema = z37.object({
|
|
18175
18412
|
data: SessionMetricsMeterResponseSchema
|
|
18176
18413
|
}).openapi("GetSessionMetricsMeterResponse");
|
|
18177
|
-
var GetSessionMetricsChartResponseSchema =
|
|
18414
|
+
var GetSessionMetricsChartResponseSchema = z37.object({
|
|
18178
18415
|
data: SessionMetricsChartResponseSchema
|
|
18179
18416
|
}).openapi("GetSessionMetricsChartResponse");
|
|
18180
|
-
var GetSessionMetricsChartDataResponseSchema =
|
|
18417
|
+
var GetSessionMetricsChartDataResponseSchema = z37.object({
|
|
18181
18418
|
data: SessionMetricsChartDataResponseSchema
|
|
18182
18419
|
}).openapi("GetSessionMetricsChartDataResponse");
|
|
18183
18420
|
|
|
@@ -18307,21 +18544,21 @@ import {
|
|
|
18307
18544
|
RequestTimeoutError
|
|
18308
18545
|
} from "@truefoundry/trueforge-core/request-reply";
|
|
18309
18546
|
import { HTTPException as HTTPException14 } from "hono/http-exception";
|
|
18310
|
-
import { z as
|
|
18547
|
+
import { z as z38 } from "zod";
|
|
18311
18548
|
init_config();
|
|
18312
18549
|
init_id();
|
|
18313
18550
|
var SESSIONS_CANCEL_PATH = "sessions/cancel";
|
|
18314
|
-
var CancelPeerBodySchema =
|
|
18315
|
-
session_id:
|
|
18316
|
-
turn_id:
|
|
18317
|
-
reason:
|
|
18551
|
+
var CancelPeerBodySchema = z38.object({
|
|
18552
|
+
session_id: z38.string(),
|
|
18553
|
+
turn_id: z38.string(),
|
|
18554
|
+
reason: z38.enum(CancellationReason2)
|
|
18318
18555
|
});
|
|
18319
|
-
function toWireSession(record) {
|
|
18556
|
+
function toWireSession(record, shared2) {
|
|
18320
18557
|
return {
|
|
18321
18558
|
id: record.session_id,
|
|
18322
18559
|
agent: record.agent,
|
|
18323
18560
|
title: record.title,
|
|
18324
|
-
shared:
|
|
18561
|
+
shared: shared2,
|
|
18325
18562
|
created_by_subject: record.created_by_subject,
|
|
18326
18563
|
created_at: record.created_at.toISOString(),
|
|
18327
18564
|
updated_at: record.updated_at.toISOString(),
|
|
@@ -18426,6 +18663,67 @@ function isSessionOwner2({
|
|
|
18426
18663
|
}) {
|
|
18427
18664
|
return subject_id === created_by_subject.subject_id;
|
|
18428
18665
|
}
|
|
18666
|
+
var FORBIDDEN_SESSION_ACCESS_MANAGEMENT = "Only the session creator can manage access to this session";
|
|
18667
|
+
async function requireOwnedSession(deps, input) {
|
|
18668
|
+
const requestContext = deps.resolveRequestContext(input.c);
|
|
18669
|
+
const record = await deps.sessionStore.getSession({
|
|
18670
|
+
tenant_id: requestContext.tenant_id,
|
|
18671
|
+
session_id: input.session_id
|
|
18672
|
+
});
|
|
18673
|
+
if (!record) {
|
|
18674
|
+
throw new HTTPException14(404, { message: `Session not found: ${input.session_id}` });
|
|
18675
|
+
}
|
|
18676
|
+
if (!isSessionOwner2({ subject_id: requestContext.subject.id, created_by_subject: record.created_by_subject })) {
|
|
18677
|
+
throw new HTTPException14(403, { message: FORBIDDEN_SESSION_ACCESS_MANAGEMENT });
|
|
18678
|
+
}
|
|
18679
|
+
return { requestContext, record };
|
|
18680
|
+
}
|
|
18681
|
+
function subjectKey(subject) {
|
|
18682
|
+
return `${subject.subject_type}:${subject.subject_id}`;
|
|
18683
|
+
}
|
|
18684
|
+
function uniqueSubjects(subjects) {
|
|
18685
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
18686
|
+
for (const subject of subjects) {
|
|
18687
|
+
byKey.set(subjectKey(subject), subject);
|
|
18688
|
+
}
|
|
18689
|
+
return [...byKey.values()];
|
|
18690
|
+
}
|
|
18691
|
+
async function tenantSharedSessionIds(accessControlStore, input) {
|
|
18692
|
+
const grants = await accessControlStore.listAccessGrants({
|
|
18693
|
+
tenant_id: input.tenant_id,
|
|
18694
|
+
session_ids: input.session_ids,
|
|
18695
|
+
subjects: [{ subject_type: "tenant", subject_id: input.tenant_id }]
|
|
18696
|
+
});
|
|
18697
|
+
return new Set(grants.map((grant) => grant.session_id));
|
|
18698
|
+
}
|
|
18699
|
+
async function isSharedWithTenant(accessControlStore, input) {
|
|
18700
|
+
const sharedIds = await tenantSharedSessionIds(accessControlStore, {
|
|
18701
|
+
tenant_id: input.tenant_id,
|
|
18702
|
+
session_ids: [input.session_id]
|
|
18703
|
+
});
|
|
18704
|
+
return sharedIds.has(input.session_id);
|
|
18705
|
+
}
|
|
18706
|
+
async function setSharedWithTenant(accessControlStore, input) {
|
|
18707
|
+
const { requestContext, session_id } = input;
|
|
18708
|
+
const subjects = [{ subject_type: "tenant", subject_id: requestContext.tenant_id }];
|
|
18709
|
+
if (input.shared) {
|
|
18710
|
+
await accessControlStore.createAccessGrants({
|
|
18711
|
+
tenant_id: requestContext.tenant_id,
|
|
18712
|
+
session_id,
|
|
18713
|
+
subjects,
|
|
18714
|
+
granted_by_subject: createdBySubjectFromRequestContext(requestContext)
|
|
18715
|
+
});
|
|
18716
|
+
return;
|
|
18717
|
+
}
|
|
18718
|
+
await accessControlStore.deleteAccessGrants({ tenant_id: requestContext.tenant_id, session_id, subjects });
|
|
18719
|
+
}
|
|
18720
|
+
function toWireSessionGrant(record) {
|
|
18721
|
+
return {
|
|
18722
|
+
subject: { subject_type: record.subject_type, subject_id: record.subject_id },
|
|
18723
|
+
granted_by_subject: record.granted_by_subject,
|
|
18724
|
+
created_at: record.created_at
|
|
18725
|
+
};
|
|
18726
|
+
}
|
|
18429
18727
|
function validateInlineSessionSpec(deps, input) {
|
|
18430
18728
|
const { c, spec, requestContext } = input;
|
|
18431
18729
|
return validateAgentSpec({
|
|
@@ -18449,17 +18747,21 @@ function createGetOrCreateSessionByExternalIdHandler(deps) {
|
|
|
18449
18747
|
external_id: body.external_id
|
|
18450
18748
|
});
|
|
18451
18749
|
if (existing !== void 0) {
|
|
18452
|
-
const
|
|
18750
|
+
const allowed2 = await canReadAgentBoundResource({
|
|
18453
18751
|
store: deps.resolveAgentStore(c),
|
|
18454
18752
|
context: requestContext,
|
|
18455
18753
|
authorizer: deps.authorizer,
|
|
18456
18754
|
agent_id: existing.record.agent.type === "reference" ? existing.record.agent.id : void 0,
|
|
18457
18755
|
created_by_subject_id: existing.record.created_by_subject.subject_id
|
|
18458
18756
|
});
|
|
18459
|
-
if (!
|
|
18757
|
+
if (!allowed2) {
|
|
18460
18758
|
return c.json({ error: { message: FORBIDDEN_SESSION_ACCESS2 } }, 403);
|
|
18461
18759
|
}
|
|
18462
|
-
|
|
18760
|
+
const shared3 = await isSharedWithTenant(deps.accessControlStore, {
|
|
18761
|
+
tenant_id: requestContext.tenant_id,
|
|
18762
|
+
session_id: existing.record.session_id
|
|
18763
|
+
});
|
|
18764
|
+
return c.json({ data: toWireSession(existing.record, shared3) }, 200);
|
|
18463
18765
|
}
|
|
18464
18766
|
let agent;
|
|
18465
18767
|
if (isSessionAgentNameRef(body.agent)) {
|
|
@@ -18491,19 +18793,24 @@ function createGetOrCreateSessionByExternalIdHandler(deps) {
|
|
|
18491
18793
|
agent,
|
|
18492
18794
|
source: body.source ?? null
|
|
18493
18795
|
});
|
|
18494
|
-
if (
|
|
18495
|
-
|
|
18496
|
-
store: deps.resolveAgentStore(c),
|
|
18497
|
-
context: requestContext,
|
|
18498
|
-
authorizer: deps.authorizer,
|
|
18499
|
-
agent_id: session.record.agent.type === "reference" ? session.record.agent.id : void 0,
|
|
18500
|
-
created_by_subject_id: session.record.created_by_subject.subject_id
|
|
18501
|
-
});
|
|
18502
|
-
if (!allowed) {
|
|
18503
|
-
return c.json({ error: { message: FORBIDDEN_SESSION_ACCESS2 } }, 403);
|
|
18504
|
-
}
|
|
18796
|
+
if (created) {
|
|
18797
|
+
return c.json({ data: toWireSession(session.record, false) }, 201);
|
|
18505
18798
|
}
|
|
18506
|
-
|
|
18799
|
+
const allowed = await canReadAgentBoundResource({
|
|
18800
|
+
store: deps.resolveAgentStore(c),
|
|
18801
|
+
context: requestContext,
|
|
18802
|
+
authorizer: deps.authorizer,
|
|
18803
|
+
agent_id: session.record.agent.type === "reference" ? session.record.agent.id : void 0,
|
|
18804
|
+
created_by_subject_id: session.record.created_by_subject.subject_id
|
|
18805
|
+
});
|
|
18806
|
+
if (!allowed) {
|
|
18807
|
+
return c.json({ error: { message: FORBIDDEN_SESSION_ACCESS2 } }, 403);
|
|
18808
|
+
}
|
|
18809
|
+
const shared2 = await isSharedWithTenant(deps.accessControlStore, {
|
|
18810
|
+
tenant_id: requestContext.tenant_id,
|
|
18811
|
+
session_id: session.record.session_id
|
|
18812
|
+
});
|
|
18813
|
+
return c.json({ data: toWireSession(session.record, shared2) }, 200);
|
|
18507
18814
|
};
|
|
18508
18815
|
}
|
|
18509
18816
|
function createInternalSessionsRouter(deps) {
|
|
@@ -18538,7 +18845,7 @@ function createSessionsRouter(deps) {
|
|
|
18538
18845
|
metadata: body.metadata,
|
|
18539
18846
|
external_id: null
|
|
18540
18847
|
});
|
|
18541
|
-
return c.json({ data: toWireSession(session2.record) }, 201);
|
|
18848
|
+
return c.json({ data: toWireSession(session2.record, false) }, 201);
|
|
18542
18849
|
}
|
|
18543
18850
|
await validateInlineSessionSpec(deps, {
|
|
18544
18851
|
c,
|
|
@@ -18553,7 +18860,7 @@ function createSessionsRouter(deps) {
|
|
|
18553
18860
|
metadata: body.metadata,
|
|
18554
18861
|
external_id: null
|
|
18555
18862
|
});
|
|
18556
|
-
return c.json({ data: toWireSession(session.record) }, 201);
|
|
18863
|
+
return c.json({ data: toWireSession(session.record, false) }, 201);
|
|
18557
18864
|
};
|
|
18558
18865
|
const getSessionHandler = async (c) => {
|
|
18559
18866
|
const { session_id: sessionId } = c.req.valid("param");
|
|
@@ -18566,7 +18873,8 @@ function createSessionsRouter(deps) {
|
|
|
18566
18873
|
return c.json({ error: { message: `Session not found: ${sessionId}` } }, 404);
|
|
18567
18874
|
}
|
|
18568
18875
|
const allowed = await canReadSession({
|
|
18569
|
-
|
|
18876
|
+
session_id: sessionId,
|
|
18877
|
+
accessControlStore: deps.accessControlStore,
|
|
18570
18878
|
store: deps.resolveAgentStore(c),
|
|
18571
18879
|
context: requestContext,
|
|
18572
18880
|
authorizer: deps.authorizer,
|
|
@@ -18576,7 +18884,11 @@ function createSessionsRouter(deps) {
|
|
|
18576
18884
|
if (!allowed) {
|
|
18577
18885
|
return c.json({ error: { message: FORBIDDEN_SESSION_ACCESS2 } }, 403);
|
|
18578
18886
|
}
|
|
18579
|
-
|
|
18887
|
+
const shared2 = await isSharedWithTenant(deps.accessControlStore, {
|
|
18888
|
+
tenant_id: requestContext.tenant_id,
|
|
18889
|
+
session_id: sessionId
|
|
18890
|
+
});
|
|
18891
|
+
return c.json({ data: toWireSession(record, shared2) }, 200);
|
|
18580
18892
|
};
|
|
18581
18893
|
const deleteSessionHandler = async (c) => {
|
|
18582
18894
|
const { session_id: sessionId } = c.req.valid("param");
|
|
@@ -18644,8 +18956,7 @@ function createSessionsRouter(deps) {
|
|
|
18644
18956
|
session_id: sessionId,
|
|
18645
18957
|
agent: body.agent === void 0 ? void 0 : { type: "inline", spec: body.agent.spec },
|
|
18646
18958
|
title: body.title,
|
|
18647
|
-
metadata: body.metadata
|
|
18648
|
-
shared: body.shared
|
|
18959
|
+
metadata: body.metadata
|
|
18649
18960
|
});
|
|
18650
18961
|
} catch (error) {
|
|
18651
18962
|
if (error instanceof SessionStoreNotFoundError2) {
|
|
@@ -18656,6 +18967,13 @@ function createSessionsRouter(deps) {
|
|
|
18656
18967
|
}
|
|
18657
18968
|
throw error;
|
|
18658
18969
|
}
|
|
18970
|
+
if (body.shared !== void 0) {
|
|
18971
|
+
await setSharedWithTenant(deps.accessControlStore, {
|
|
18972
|
+
requestContext,
|
|
18973
|
+
session_id: sessionId,
|
|
18974
|
+
shared: body.shared
|
|
18975
|
+
});
|
|
18976
|
+
}
|
|
18659
18977
|
const record = await deps.sessionStore.getSession({
|
|
18660
18978
|
tenant_id: requestContext.tenant_id,
|
|
18661
18979
|
session_id: sessionId
|
|
@@ -18663,7 +18981,11 @@ function createSessionsRouter(deps) {
|
|
|
18663
18981
|
if (!record) {
|
|
18664
18982
|
return c.json({ error: { message: `Session not found: ${sessionId}` } }, 404);
|
|
18665
18983
|
}
|
|
18666
|
-
|
|
18984
|
+
const shared2 = await isSharedWithTenant(deps.accessControlStore, {
|
|
18985
|
+
tenant_id: requestContext.tenant_id,
|
|
18986
|
+
session_id: sessionId
|
|
18987
|
+
});
|
|
18988
|
+
return c.json({ data: toWireSession(record, shared2) }, 200);
|
|
18667
18989
|
};
|
|
18668
18990
|
const listSessionsHandler = async (c) => {
|
|
18669
18991
|
const query = parseListSessionsQuery(honoQueriesToRecord(c.req.queries()));
|
|
@@ -18690,7 +19012,14 @@ function createSessionsRouter(deps) {
|
|
|
18690
19012
|
source_type: query.source_type,
|
|
18691
19013
|
source_id: query.source_id
|
|
18692
19014
|
});
|
|
18693
|
-
|
|
19015
|
+
const sharedIds = await tenantSharedSessionIds(deps.accessControlStore, {
|
|
19016
|
+
tenant_id: requestContext.tenant_id,
|
|
19017
|
+
session_ids: data.map((record) => record.session_id)
|
|
19018
|
+
});
|
|
19019
|
+
return c.json(
|
|
19020
|
+
{ data: data.map((record) => toWireSession(record, sharedIds.has(record.session_id))), pagination },
|
|
19021
|
+
200
|
|
19022
|
+
);
|
|
18694
19023
|
} catch (error) {
|
|
18695
19024
|
if (error instanceof SessionStoreConflictError2) {
|
|
18696
19025
|
throw new HTTPException14(400, { message: error.message, cause: error });
|
|
@@ -18714,7 +19043,7 @@ function createSessionsRouter(deps) {
|
|
|
18714
19043
|
})) {
|
|
18715
19044
|
return c.json({ error: { message: FORBIDDEN_SESSION_ACCESS2 } }, 403);
|
|
18716
19045
|
}
|
|
18717
|
-
const turnId = session.record.
|
|
19046
|
+
const turnId = session.record.last_turn_details?.id;
|
|
18718
19047
|
if (!turnId) {
|
|
18719
19048
|
return c.json({}, 200);
|
|
18720
19049
|
}
|
|
@@ -18733,7 +19062,8 @@ function createSessionsRouter(deps) {
|
|
|
18733
19062
|
return c.json({ error: { message: `Session not found: ${sessionId}` } }, 404);
|
|
18734
19063
|
}
|
|
18735
19064
|
const allowed = await canReadSession({
|
|
18736
|
-
|
|
19065
|
+
session_id: sessionId,
|
|
19066
|
+
accessControlStore: deps.accessControlStore,
|
|
18737
19067
|
store: deps.resolveAgentStore(c),
|
|
18738
19068
|
context: requestContext,
|
|
18739
19069
|
authorizer: deps.authorizer,
|
|
@@ -18760,6 +19090,65 @@ function createSessionsRouter(deps) {
|
|
|
18760
19090
|
throw error;
|
|
18761
19091
|
}
|
|
18762
19092
|
};
|
|
19093
|
+
const listSessionGrantsHandler = async (c) => {
|
|
19094
|
+
const { session_id: sessionId } = c.req.valid("param");
|
|
19095
|
+
const { requestContext } = await requireOwnedSession(deps, { c, session_id: sessionId });
|
|
19096
|
+
const records = await deps.accessControlStore.listAccessGrants({
|
|
19097
|
+
tenant_id: requestContext.tenant_id,
|
|
19098
|
+
session_ids: [sessionId]
|
|
19099
|
+
});
|
|
19100
|
+
return c.json({ data: records.map(toWireSessionGrant) }, 200);
|
|
19101
|
+
};
|
|
19102
|
+
const updateSessionGrantsHandler = async (c) => {
|
|
19103
|
+
const { session_id: sessionId } = c.req.valid("param");
|
|
19104
|
+
const body = c.req.valid("json");
|
|
19105
|
+
const { requestContext } = await requireOwnedSession(deps, { c, session_id: sessionId });
|
|
19106
|
+
const toGrant = uniqueSubjects(body.grant);
|
|
19107
|
+
const toRevoke = uniqueSubjects(body.revoke);
|
|
19108
|
+
const revokeKeys = new Set(toRevoke.map(subjectKey));
|
|
19109
|
+
if (toGrant.some((subject) => revokeKeys.has(subjectKey(subject)))) {
|
|
19110
|
+
throw new HTTPException14(422, { message: "A subject cannot be both granted and revoked." });
|
|
19111
|
+
}
|
|
19112
|
+
if (toGrant.some((subject) => subject.subject_type === "tenant" && subject.subject_id !== requestContext.tenant_id)) {
|
|
19113
|
+
throw new HTTPException14(422, { message: "A tenant subject must be your own tenant." });
|
|
19114
|
+
}
|
|
19115
|
+
const userIds = toGrant.filter((subject) => subject.subject_type === "user").map((subject) => subject.subject_id);
|
|
19116
|
+
if (userIds.includes(requestContext.subject.id)) {
|
|
19117
|
+
throw new HTTPException14(422, { message: "The session creator already has access." });
|
|
19118
|
+
}
|
|
19119
|
+
if (userIds.length > 0) {
|
|
19120
|
+
const knownUsers = await deps.userStore.getUsersByIds({ context: requestContext, ids: userIds });
|
|
19121
|
+
const knownIds = new Set(knownUsers.map((user) => user.id));
|
|
19122
|
+
const unknownIds = userIds.filter((id) => !knownIds.has(id));
|
|
19123
|
+
if (unknownIds.length > 0) {
|
|
19124
|
+
throw new HTTPException14(422, { message: `Unknown users: ${unknownIds.join(", ")}` });
|
|
19125
|
+
}
|
|
19126
|
+
}
|
|
19127
|
+
await deps.withTransaction(async (transaction) => {
|
|
19128
|
+
if (toGrant.length > 0) {
|
|
19129
|
+
await deps.accessControlStore.createAccessGrants(
|
|
19130
|
+
{
|
|
19131
|
+
tenant_id: requestContext.tenant_id,
|
|
19132
|
+
session_id: sessionId,
|
|
19133
|
+
subjects: toGrant,
|
|
19134
|
+
granted_by_subject: createdBySubjectFromRequestContext(requestContext)
|
|
19135
|
+
},
|
|
19136
|
+
transaction
|
|
19137
|
+
);
|
|
19138
|
+
}
|
|
19139
|
+
if (toRevoke.length > 0) {
|
|
19140
|
+
await deps.accessControlStore.deleteAccessGrants(
|
|
19141
|
+
{ tenant_id: requestContext.tenant_id, session_id: sessionId, subjects: toRevoke },
|
|
19142
|
+
transaction
|
|
19143
|
+
);
|
|
19144
|
+
}
|
|
19145
|
+
});
|
|
19146
|
+
const records = await deps.accessControlStore.listAccessGrants({
|
|
19147
|
+
tenant_id: requestContext.tenant_id,
|
|
19148
|
+
session_ids: [sessionId]
|
|
19149
|
+
});
|
|
19150
|
+
return c.json({ data: records.map(toWireSessionGrant) }, 200);
|
|
19151
|
+
};
|
|
18763
19152
|
const router = new OpenAPIHono14();
|
|
18764
19153
|
router.openapi(createSessionRoute, createSessionHandler);
|
|
18765
19154
|
router.openapi(getSessionRoute, getSessionHandler);
|
|
@@ -18768,6 +19157,8 @@ function createSessionsRouter(deps) {
|
|
|
18768
19157
|
router.openapi(listSessionsRoute, listSessionsHandler);
|
|
18769
19158
|
router.openapi(cancelSessionRoute, cancelSessionHandler);
|
|
18770
19159
|
router.openapi(listSessionEventsRoute, listSessionEventsHandler);
|
|
19160
|
+
router.openapi(listSessionGrantsRoute, listSessionGrantsHandler);
|
|
19161
|
+
router.openapi(updateSessionGrantsRoute, updateSessionGrantsHandler);
|
|
18771
19162
|
deps.requestReplyRouter.registerRoute(SESSIONS_CANCEL_PATH, cancelSessionTurnPeerHandler(deps.activeTurns));
|
|
18772
19163
|
return router;
|
|
18773
19164
|
}
|
|
@@ -18782,9 +19173,9 @@ import { assertSafeOutboundUrl as assertSafeOutboundUrl2, OUTBOUND_URL_BLOCKED a
|
|
|
18782
19173
|
import { HTTPException as HTTPException15 } from "hono/http-exception";
|
|
18783
19174
|
|
|
18784
19175
|
// src/routes/modelProviderRoutes.ts
|
|
18785
|
-
import { createRoute as createRoute15, z as
|
|
18786
|
-
var ModelProviderNameParamsSchema =
|
|
18787
|
-
name:
|
|
19176
|
+
import { createRoute as createRoute15, z as z39 } from "@hono/zod-openapi";
|
|
19177
|
+
var ModelProviderNameParamsSchema = z39.object({
|
|
19178
|
+
name: z39.string().min(1).describe("Model provider name.")
|
|
18788
19179
|
});
|
|
18789
19180
|
var listModelProvidersRoute = createRoute15({
|
|
18790
19181
|
method: "get",
|
|
@@ -19283,10 +19674,10 @@ init_skillStore();
|
|
|
19283
19674
|
import { OpenAPIHono as OpenAPIHono17 } from "@hono/zod-openapi";
|
|
19284
19675
|
|
|
19285
19676
|
// src/routes/skillRoutes.ts
|
|
19286
|
-
import { createRoute as createRoute17, z as
|
|
19677
|
+
import { createRoute as createRoute17, z as z40 } from "@hono/zod-openapi";
|
|
19287
19678
|
init_skill();
|
|
19288
|
-
var SkillNameParamsSchema =
|
|
19289
|
-
name:
|
|
19679
|
+
var SkillNameParamsSchema = z40.object({
|
|
19680
|
+
name: z40.string().min(1).describe("Skill name.")
|
|
19290
19681
|
});
|
|
19291
19682
|
var listAvailableSkillsRoute = createRoute17({
|
|
19292
19683
|
method: "get",
|
|
@@ -19737,6 +20128,114 @@ function createSettingsRouter(deps) {
|
|
|
19737
20128
|
return router;
|
|
19738
20129
|
}
|
|
19739
20130
|
|
|
20131
|
+
// src/apis/users.ts
|
|
20132
|
+
import { OpenAPIHono as OpenAPIHono20 } from "@hono/zod-openapi";
|
|
20133
|
+
import { InvalidPageTokenError as InvalidPageTokenError4 } from "@truefoundry/trueforge-core/agent-session";
|
|
20134
|
+
import {
|
|
20135
|
+
decodeOffsetPageToken,
|
|
20136
|
+
encodeOffsetPageToken
|
|
20137
|
+
} from "@truefoundry/trueforge-core/agent-session/store/OffsetPageToken";
|
|
20138
|
+
import { HTTPException as HTTPException18 } from "hono/http-exception";
|
|
20139
|
+
|
|
20140
|
+
// src/routes/userRoutes.ts
|
|
20141
|
+
import { createRoute as createRoute19 } from "@hono/zod-openapi";
|
|
20142
|
+
|
|
20143
|
+
// src/schemas/user.ts
|
|
20144
|
+
init_common();
|
|
20145
|
+
import { z as z41 } from "@hono/zod-openapi";
|
|
20146
|
+
import { TokenPaginationSchema as TokenPaginationSchema7 } from "@truefoundry/trueforge-core/agent-session";
|
|
20147
|
+
var LIST_USERS_PAGE_LIMIT = 100;
|
|
20148
|
+
var LIST_USERS_MAX_IDS = 100;
|
|
20149
|
+
var UserSchema = z41.object({
|
|
20150
|
+
id: z41.string().describe("User id, unique within the tenant."),
|
|
20151
|
+
display_name: z41.string().describe("Human-readable name for the user."),
|
|
20152
|
+
email: z41.string().describe("Email of the user.")
|
|
20153
|
+
}).openapi("User");
|
|
20154
|
+
var ListUsersRequestQuerySchema = z41.object({
|
|
20155
|
+
query: z41.string().trim().min(1).max(200).optional().describe("Case-insensitive substring match on email or display name."),
|
|
20156
|
+
limit: z41.coerce.number().int().min(1).max(LIST_USERS_PAGE_LIMIT).optional().default(PAGE_LIMIT).describe(`Page size. Defaults to ${String(PAGE_LIMIT)}, max ${String(LIST_USERS_PAGE_LIMIT)}.`),
|
|
20157
|
+
page_token: z41.string().optional().describe("Opaque token from a previous response `next_page_token`."),
|
|
20158
|
+
ids: z41.string().optional().openapi({
|
|
20159
|
+
type: "string",
|
|
20160
|
+
description: `Return only these users (comma-separated ids, up to ${String(LIST_USERS_MAX_IDS)}). Users that are unknown or inactive are omitted. Cannot be combined with \`query\` or \`page_token\`.`
|
|
20161
|
+
}).transform((value) => parseCommaSeparatedQuery(value)).pipe(z41.array(z41.string().min(1).max(255)).min(1).max(LIST_USERS_MAX_IDS).optional())
|
|
20162
|
+
}).refine((q) => q.ids === void 0 || q.query === void 0 && q.page_token === void 0, {
|
|
20163
|
+
message: "`ids` cannot be combined with `query` or `page_token`."
|
|
20164
|
+
}).openapi("ListUsersRequestQuery");
|
|
20165
|
+
var ListUsersResponseSchema = z41.object({
|
|
20166
|
+
data: z41.array(UserSchema),
|
|
20167
|
+
pagination: TokenPaginationSchema7
|
|
20168
|
+
}).openapi("ListUsersResponse");
|
|
20169
|
+
|
|
20170
|
+
// src/routes/userRoutes.ts
|
|
20171
|
+
var listUsersRoute = createRoute19({
|
|
20172
|
+
method: "get",
|
|
20173
|
+
path: "/",
|
|
20174
|
+
tags: ["Users" /* USERS */],
|
|
20175
|
+
summary: "List users",
|
|
20176
|
+
description: "List users in the tenant that sessions can be shared with. Searches email and display name, or looks up specific users with `ids`.",
|
|
20177
|
+
"x-fern-sdk-group-name": ["users"],
|
|
20178
|
+
"x-fern-sdk-method-name": "list",
|
|
20179
|
+
"x-fern-pagination": TOKEN_PAGINATION,
|
|
20180
|
+
request: {
|
|
20181
|
+
query: ListUsersRequestQuerySchema
|
|
20182
|
+
},
|
|
20183
|
+
responses: {
|
|
20184
|
+
200: {
|
|
20185
|
+
content: { "application/json": { schema: ListUsersResponseSchema } },
|
|
20186
|
+
description: "Paginated users."
|
|
20187
|
+
},
|
|
20188
|
+
400: {
|
|
20189
|
+
content: { "application/json": { schema: RequestErrorResponseSchema } },
|
|
20190
|
+
description: "Invalid query parameters or page token."
|
|
20191
|
+
}
|
|
20192
|
+
}
|
|
20193
|
+
});
|
|
20194
|
+
|
|
20195
|
+
// src/apis/users.ts
|
|
20196
|
+
function decodeOffset(pageToken) {
|
|
20197
|
+
try {
|
|
20198
|
+
return decodeOffsetPageToken(pageToken);
|
|
20199
|
+
} catch (error) {
|
|
20200
|
+
if (error instanceof InvalidPageTokenError4) {
|
|
20201
|
+
throw new HTTPException18(400, { message: error.message, cause: error });
|
|
20202
|
+
}
|
|
20203
|
+
throw error;
|
|
20204
|
+
}
|
|
20205
|
+
}
|
|
20206
|
+
function createUsersRouter(deps) {
|
|
20207
|
+
const listUsersHandler = async (c) => {
|
|
20208
|
+
const { query, limit, page_token: pageToken, ids } = c.req.valid("query");
|
|
20209
|
+
const context = deps.resolveRequestContext(c);
|
|
20210
|
+
if (ids !== void 0) {
|
|
20211
|
+
const users = await deps.userStore.getUsersByIds({ context, ids });
|
|
20212
|
+
return c.json({ data: users, pagination: { limit: ids.length } }, 200);
|
|
20213
|
+
}
|
|
20214
|
+
const offset = decodeOffset(pageToken);
|
|
20215
|
+
const { data, total } = await deps.userStore.listUsers({
|
|
20216
|
+
context,
|
|
20217
|
+
query,
|
|
20218
|
+
limit,
|
|
20219
|
+
offset
|
|
20220
|
+
});
|
|
20221
|
+
const nextOffset = offset + data.length;
|
|
20222
|
+
return c.json(
|
|
20223
|
+
{
|
|
20224
|
+
data,
|
|
20225
|
+
pagination: {
|
|
20226
|
+
limit,
|
|
20227
|
+
...data.length > 0 && nextOffset < total ? { next_page_token: encodeOffsetPageToken(nextOffset) } : {},
|
|
20228
|
+
...offset > 0 ? { previous_page_token: encodeOffsetPageToken(Math.max(0, offset - limit)) } : {}
|
|
20229
|
+
}
|
|
20230
|
+
},
|
|
20231
|
+
200
|
|
20232
|
+
);
|
|
20233
|
+
};
|
|
20234
|
+
const router = new OpenAPIHono20();
|
|
20235
|
+
router.openapi(listUsersRoute, listUsersHandler);
|
|
20236
|
+
return router;
|
|
20237
|
+
}
|
|
20238
|
+
|
|
19740
20239
|
// src/app.ts
|
|
19741
20240
|
init_config();
|
|
19742
20241
|
|
|
@@ -19763,9 +20262,9 @@ var PACKAGE_VERSION = readPackageVersion();
|
|
|
19763
20262
|
init_schedule();
|
|
19764
20263
|
|
|
19765
20264
|
// src/zodErrorResponse.ts
|
|
19766
|
-
import { z as
|
|
20265
|
+
import { z as z42 } from "@hono/zod-openapi";
|
|
19767
20266
|
function zodErrorResponse(c, error) {
|
|
19768
|
-
return c.json({ error: { message:
|
|
20267
|
+
return c.json({ error: { message: z42.prettifyError(error) } }, 400);
|
|
19769
20268
|
}
|
|
19770
20269
|
var zodValidationHook = (result) => {
|
|
19771
20270
|
if (!result.success) {
|
|
@@ -19808,13 +20307,13 @@ function createSessionPathLogContextMiddleware() {
|
|
|
19808
20307
|
};
|
|
19809
20308
|
}
|
|
19810
20309
|
function withAuth(router, middleware) {
|
|
19811
|
-
const shell = new
|
|
20310
|
+
const shell = new OpenAPIHono21();
|
|
19812
20311
|
shell.use("*", middleware);
|
|
19813
20312
|
shell.route("/", router);
|
|
19814
20313
|
return shell;
|
|
19815
20314
|
}
|
|
19816
20315
|
function withAdminAuth(router, middleware) {
|
|
19817
|
-
const shell = new
|
|
20316
|
+
const shell = new OpenAPIHono21();
|
|
19818
20317
|
shell.use("*", middleware);
|
|
19819
20318
|
shell.route("/", router);
|
|
19820
20319
|
return shell;
|
|
@@ -19862,7 +20361,7 @@ function createAppErrorHandler(params) {
|
|
|
19862
20361
|
}
|
|
19863
20362
|
params.logger.warn(message, fields);
|
|
19864
20363
|
};
|
|
19865
|
-
if (error instanceof
|
|
20364
|
+
if (error instanceof z43.ZodError) {
|
|
19866
20365
|
logError(400, "Client API error");
|
|
19867
20366
|
return zodErrorResponse(c, error);
|
|
19868
20367
|
}
|
|
@@ -19870,7 +20369,7 @@ function createAppErrorHandler(params) {
|
|
|
19870
20369
|
logError(400, "Client API error");
|
|
19871
20370
|
return c.json({ error: { message: error.message } }, 400);
|
|
19872
20371
|
}
|
|
19873
|
-
if (error instanceof
|
|
20372
|
+
if (error instanceof HTTPException19) {
|
|
19874
20373
|
logError(error.status, error.status >= 500 ? "Server API error" : "Client API error");
|
|
19875
20374
|
return c.json({ error: { message: error.message } }, error.status);
|
|
19876
20375
|
}
|
|
@@ -19911,7 +20410,7 @@ function routeNotFound(c) {
|
|
|
19911
20410
|
return c.json({ error: { message: `Route not found: ${c.req.method} ${c.req.path}` } }, 404);
|
|
19912
20411
|
}
|
|
19913
20412
|
function createServerApp(deps) {
|
|
19914
|
-
const app = new
|
|
20413
|
+
const app = new OpenAPIHono21({ defaultHook: zodValidationHook });
|
|
19915
20414
|
const authMiddleware = createAuthMiddleware(deps.authenticator);
|
|
19916
20415
|
const adminAuthMiddleware = createAdminAuthMiddleware(deps.authenticator);
|
|
19917
20416
|
const scheduleExecutionAuthMiddleware = createApiKeyAuthMiddleware(config_default.TRUEFORGE_API_KEY);
|
|
@@ -19952,12 +20451,17 @@ function createServerApp(deps) {
|
|
|
19952
20451
|
authMiddleware
|
|
19953
20452
|
})
|
|
19954
20453
|
);
|
|
20454
|
+
app.route(
|
|
20455
|
+
"/api/v1/users",
|
|
20456
|
+
withAuth(createUsersRouter({ userStore: deps.userStore, resolveRequestContext }), authMiddleware)
|
|
20457
|
+
);
|
|
19955
20458
|
app.route(
|
|
19956
20459
|
"/api/v1/capabilities",
|
|
19957
20460
|
withAuth(
|
|
19958
20461
|
createCapabilitiesRouter({
|
|
19959
20462
|
sandboxEnvironmentStore: deps.sandboxEnvironmentStore,
|
|
19960
20463
|
resolveWebSearchProviderStore: deps.resolveWebSearchProviderStore,
|
|
20464
|
+
userStore: deps.userStore,
|
|
19961
20465
|
withTransaction: deps.withTransaction,
|
|
19962
20466
|
logger: deps.logger,
|
|
19963
20467
|
resolveRequestContext
|
|
@@ -20105,6 +20609,7 @@ function createServerApp(deps) {
|
|
|
20105
20609
|
withAuth(
|
|
20106
20610
|
createInternalSessionsRouter({
|
|
20107
20611
|
sessions: deps.sessions,
|
|
20612
|
+
accessControlStore: deps.accessControlStore,
|
|
20108
20613
|
resolveModelProviderStore: deps.resolveModelProviderStore,
|
|
20109
20614
|
resolveMcpServerStore: deps.resolveMcpServerStore,
|
|
20110
20615
|
resolveSkillStore: deps.resolveSkillStore,
|
|
@@ -20150,6 +20655,9 @@ function createServerApp(deps) {
|
|
|
20150
20655
|
createSessionsRouter({
|
|
20151
20656
|
sessions: deps.sessions,
|
|
20152
20657
|
sessionStore: deps.sessionStore,
|
|
20658
|
+
accessControlStore: deps.accessControlStore,
|
|
20659
|
+
userStore: deps.userStore,
|
|
20660
|
+
withTransaction: deps.withTransaction,
|
|
20153
20661
|
activeTurns: deps.activeTurns,
|
|
20154
20662
|
resolveModelProviderStore: deps.resolveModelProviderStore,
|
|
20155
20663
|
resolveMcpServerStore: deps.resolveMcpServerStore,
|
|
@@ -20173,6 +20681,7 @@ function createServerApp(deps) {
|
|
|
20173
20681
|
createTurnsRouter({
|
|
20174
20682
|
sessions: deps.sessions,
|
|
20175
20683
|
sessionStore: deps.sessionStore,
|
|
20684
|
+
accessControlStore: deps.accessControlStore,
|
|
20176
20685
|
activeTurns: deps.activeTurns,
|
|
20177
20686
|
resolveModelProviderStore: deps.resolveModelProviderStore,
|
|
20178
20687
|
resolveMcpServerStore: deps.resolveMcpServerStore,
|
|
@@ -20295,7 +20804,7 @@ var TrueForgeAuthorizer = class {
|
|
|
20295
20804
|
init_config();
|
|
20296
20805
|
|
|
20297
20806
|
// src/truefoundry/TrueFoundryAuthenticator.ts
|
|
20298
|
-
import { HTTPException as
|
|
20807
|
+
import { HTTPException as HTTPException20 } from "hono/http-exception";
|
|
20299
20808
|
var TrueFoundryAuthenticator = class {
|
|
20300
20809
|
#client;
|
|
20301
20810
|
constructor(client2) {
|
|
@@ -20304,7 +20813,7 @@ var TrueFoundryAuthenticator = class {
|
|
|
20304
20813
|
async authenticate(c) {
|
|
20305
20814
|
const token = extractRequestToken(c);
|
|
20306
20815
|
if (!token) {
|
|
20307
|
-
throw new
|
|
20816
|
+
throw new HTTPException20(401, { message: "Authentication required" });
|
|
20308
20817
|
}
|
|
20309
20818
|
const session = await this.#client.getSession(token);
|
|
20310
20819
|
const { subject } = session.user;
|
|
@@ -20322,17 +20831,17 @@ var TrueFoundryAuthenticator = class {
|
|
|
20322
20831
|
};
|
|
20323
20832
|
|
|
20324
20833
|
// src/auth/oidcAuthenticator.ts
|
|
20325
|
-
import { HTTPException as
|
|
20834
|
+
import { HTTPException as HTTPException21 } from "hono/http-exception";
|
|
20326
20835
|
import { jwtVerify as jwtVerify2 } from "jose";
|
|
20327
20836
|
var OidcAuthenticator = class {
|
|
20328
20837
|
async authenticate(c) {
|
|
20329
20838
|
const oidcVerify2 = getOidcVerify();
|
|
20330
20839
|
if (!oidcVerify2) {
|
|
20331
|
-
throw new
|
|
20840
|
+
throw new HTTPException21(401, { message: "Authentication required" });
|
|
20332
20841
|
}
|
|
20333
20842
|
const token = extractRequestToken(c);
|
|
20334
20843
|
if (!token) {
|
|
20335
|
-
throw new
|
|
20844
|
+
throw new HTTPException21(401, { message: "Authentication required" });
|
|
20336
20845
|
}
|
|
20337
20846
|
let payload;
|
|
20338
20847
|
try {
|
|
@@ -20341,7 +20850,7 @@ var OidcAuthenticator = class {
|
|
|
20341
20850
|
audience: oidcVerify2.audience
|
|
20342
20851
|
}));
|
|
20343
20852
|
} catch {
|
|
20344
|
-
throw new
|
|
20853
|
+
throw new HTTPException21(401, { message: "Authentication required" });
|
|
20345
20854
|
}
|
|
20346
20855
|
try {
|
|
20347
20856
|
const claims = { ...payload };
|
|
@@ -20351,7 +20860,7 @@ var OidcAuthenticator = class {
|
|
|
20351
20860
|
user_credential: token
|
|
20352
20861
|
});
|
|
20353
20862
|
} catch (error) {
|
|
20354
|
-
throw new
|
|
20863
|
+
throw new HTTPException21(401, { message: "Authentication required", cause: error });
|
|
20355
20864
|
}
|
|
20356
20865
|
}
|
|
20357
20866
|
};
|
|
@@ -20412,7 +20921,7 @@ function loadYamlAtPath(filePath, schema) {
|
|
|
20412
20921
|
}
|
|
20413
20922
|
|
|
20414
20923
|
// src/catalog/mcpCatalog.gen.ts
|
|
20415
|
-
var shippedMcpCatalogYaml = "# Shipped MCP catalog: server presets offered by\n# GET /api/v1/catalog/mcp-servers for the UI to copy into\n# PUT /api/v1/settings/mcp-servers bodies. Discovery-only \u2014 never executed against.\nmcp_servers:\n - type: remote\n name: linear\n logo: https://assets.production.truefoundry.com/linear.svg\n url: https://mcp.linear.app/mcp\n description: Search, read, and create Linear issues.\n auth:\n type: dcr\n - type: remote\n name: notion\n logo: https://assets.production.truefoundry.com/notion.svg\n url: https://mcp.notion.com/mcp\n description: Search pages, read content, query databases, create pages.\n auth:\n type: dcr\n - type: remote\n name: sentry\n logo: https://assets.production.truefoundry.com/sentry.svg\n url: https://mcp.sentry.dev/mcp\n description: Search errors, read stack traces, and check releases.\n auth:\n type: dcr\n - type: remote\n name: deepwiki\n logo: https://assets.production.truefoundry.com/deepwiki.png\n url: https://mcp.deepwiki.com/mcp\n description: Read documentation and ask questions about any public GitHub repository.\n - type: remote\n name: exa\n logo: https://assets.production.truefoundry.com/exa.svg\n url: https://mcp.exa.ai/mcp\n description: Search the web, fetch page contents, and find similar pages.\n - type: remote\n name: parallel-web\n logo: https://assets.production.truefoundry.com/parallel-web.svg\n url: https://search.parallel.ai/mcp\n description: Search the web and get ranked results with extracted content.\n - type: remote\n name: github\n logo: https://assets.production.truefoundry.com/github.svg\n url: https://api.githubcopilot.com/mcp/\n description: Work with issues, pull requests, repository files, and CI status.\n auth:\n type: header\n headers:\n Authorization: Bearer YOUR_GITHUB_PAT\n - type: remote\n name: tavily\n logo: https://assets.production.truefoundry.com/tavily.svg\n url: https://mcp.tavily.com/mcp\n description: Search the web, extract page content, and crawl sites.\n auth:\n type: header\n headers:\n Authorization: Bearer YOUR_TAVILY_API_KEY\n - type: remote\n name: bright-data\n logo: https://assets.production.truefoundry.com/bright-data.png\n url: https://mcp.brightdata.com/mcp\n description: Search the web and scrape pages, including sites behind bot protection.\n auth:\n type: header\n headers:\n Authorization: Bearer YOUR_BRIGHT_DATA_API_TOKEN\n - type: remote\n name: supabase\n logo: https://assets.production.truefoundry.com/supabase.svg\n url: https://mcp.supabase.com/mcp\n description: Run SQL queries, manage tables, and inspect Supabase projects.\n auth:\n type: dcr\n - type: remote\n name: stripe\n logo: https://assets.production.truefoundry.com/stripe.svg\n url: https://mcp.stripe.com\n description: Create and manage customers, payments, invoices, and subscriptions.\n auth:\n type: dcr\n - type: remote\n name: confluence\n logo: https://assets.production.truefoundry.com/confluence.svg\n url: https://mcp.atlassian.com/v1/mcp\n description: Search spaces, read pages, and create or update content.\n auth:\n type: dcr\n - type: remote\n name: jira\n logo: https://assets.production.truefoundry.com/jira.png\n url: https://mcp.atlassian.com/v1/mcp\n description: Search, read, create, and update Jira issues.\n auth:\n type: dcr\n - type: remote\n name: posthog\n logo: https://assets.production.truefoundry.com/posthog.svg\n url: https://mcp.posthog.com/mcp\n description: Query product analytics, run SQL, and manage feature flags.\n auth:\n type: dcr\n - type: remote\n logo: https://assets.production.truefoundry.com/you.svg\n name: you\n url: https://api.you.com/mcp?profile=free\n description: Search the web, fetch page content, and run multi-step research using You.com. Keyless free profile; pass a You.com API key at https://api.you.com/mcp for full-rate access.\n - type: remote\n logo: https://assets.production.truefoundry.com/keenable.svg\n name: keenable\n url: https://api.keenable.ai/mcp?keenable_title=trueforge\n description: Search the web and fetch page content as markdown using Keenable. Keyless; add a Keenable API key as an X-API-Key header for higher rate limits.\n";
|
|
20924
|
+
var shippedMcpCatalogYaml = "# Shipped MCP catalog: server presets offered by\n# GET /api/v1/catalog/mcp-servers for the UI to copy into\n# PUT /api/v1/settings/mcp-servers bodies. Discovery-only \u2014 never executed against.\nmcp_servers:\n - type: remote\n name: linear\n logo: https://assets.production.truefoundry.com/linear.svg\n url: https://mcp.linear.app/mcp\n description: Search, read, and create Linear issues.\n auth:\n type: dcr\n - type: remote\n name: notion\n logo: https://assets.production.truefoundry.com/notion.svg\n url: https://mcp.notion.com/mcp\n description: Search pages, read content, query databases, create pages.\n auth:\n type: dcr\n - type: remote\n name: sentry\n logo: https://assets.production.truefoundry.com/sentry.svg\n url: https://mcp.sentry.dev/mcp\n description: Search errors, read stack traces, and check releases.\n auth:\n type: dcr\n - type: remote\n name: deepwiki\n logo: https://assets.production.truefoundry.com/deepwiki.png\n url: https://mcp.deepwiki.com/mcp\n description: Read documentation and ask questions about any public GitHub repository.\n - type: remote\n name: exa\n logo: https://assets.production.truefoundry.com/exa.svg\n url: https://mcp.exa.ai/mcp\n description: Search the web, fetch page contents, and find similar pages.\n - type: remote\n name: parallel-web\n logo: https://assets.production.truefoundry.com/parallel-web.svg\n url: https://search.parallel.ai/mcp\n description: Search the web and get ranked results with extracted content.\n - type: remote\n name: github\n logo: https://assets.production.truefoundry.com/github.svg\n url: https://api.githubcopilot.com/mcp/\n description: Work with issues, pull requests, repository files, and CI status.\n auth:\n type: header\n headers:\n Authorization: Bearer YOUR_GITHUB_PAT\n - type: remote\n name: tavily\n logo: https://assets.production.truefoundry.com/tavily.svg\n url: https://mcp.tavily.com/mcp\n description: Search the web, extract page content, and crawl sites.\n auth:\n type: header\n headers:\n Authorization: Bearer YOUR_TAVILY_API_KEY\n - type: remote\n name: bright-data\n logo: https://assets.production.truefoundry.com/bright-data.png\n url: https://mcp.brightdata.com/mcp\n description: Search the web and scrape pages, including sites behind bot protection.\n auth:\n type: header\n headers:\n Authorization: Bearer YOUR_BRIGHT_DATA_API_TOKEN\n - type: remote\n name: supabase\n logo: https://assets.production.truefoundry.com/supabase.svg\n url: https://mcp.supabase.com/mcp\n description: Run SQL queries, manage tables, and inspect Supabase projects.\n auth:\n type: dcr\n - type: remote\n name: stripe\n logo: https://assets.production.truefoundry.com/stripe.svg\n url: https://mcp.stripe.com\n description: Create and manage customers, payments, invoices, and subscriptions.\n auth:\n type: dcr\n - type: remote\n name: confluence\n logo: https://assets.production.truefoundry.com/confluence.svg\n url: https://mcp.atlassian.com/v1/mcp\n description: Search spaces, read pages, and create or update content.\n auth:\n type: dcr\n - type: remote\n name: jira\n logo: https://assets.production.truefoundry.com/jira.png\n url: https://mcp.atlassian.com/v1/mcp\n description: Search, read, create, and update Jira issues.\n auth:\n type: dcr\n - type: remote\n name: posthog\n logo: https://assets.production.truefoundry.com/posthog.svg\n url: https://mcp.posthog.com/mcp\n description: Query product analytics, run SQL, and manage feature flags.\n auth:\n type: dcr\n - type: remote\n logo: https://assets.production.truefoundry.com/you.svg\n name: you\n url: https://api.you.com/mcp?profile=free\n description: Search the web, fetch page content, and run multi-step research using You.com. Keyless free profile; pass a You.com API key at https://api.you.com/mcp for full-rate access.\n - type: remote\n logo: https://assets.production.truefoundry.com/keenable.svg\n name: keenable\n url: https://api.keenable.ai/mcp?keenable_title=trueforge\n description: Search the web and fetch page content as markdown using Keenable. Keyless; add a Keenable API key as an X-API-Key header for higher rate limits.\n - type: remote\n name: evolink\n url: https://mcp.evolink.ai/mcp\n description: Generate images, video, music and speech with 150+ AI models. Sign in with your EvoLink account (OAuth); model search, prices and quotes are free, and generation is billed to your EvoLink balance.\n auth:\n type: dcr\n";
|
|
20416
20925
|
|
|
20417
20926
|
// src/catalog/McpCatalog.ts
|
|
20418
20927
|
var McpCatalog = class _McpCatalog {
|
|
@@ -20925,6 +21434,17 @@ var McpServerWithAuthStore = class {
|
|
|
20925
21434
|
}
|
|
20926
21435
|
};
|
|
20927
21436
|
|
|
21437
|
+
// src/db/userStore.ts
|
|
21438
|
+
var EmptyUserStore = class {
|
|
21439
|
+
supportsUserLookup = false;
|
|
21440
|
+
listUsers() {
|
|
21441
|
+
return Promise.resolve({ data: [], total: 0 });
|
|
21442
|
+
}
|
|
21443
|
+
getUsersByIds() {
|
|
21444
|
+
return Promise.resolve([]);
|
|
21445
|
+
}
|
|
21446
|
+
};
|
|
21447
|
+
|
|
20928
21448
|
// src/frontend.ts
|
|
20929
21449
|
import { serveStatic } from "@hono/node-server/serve-static";
|
|
20930
21450
|
import { every } from "hono/combine";
|
|
@@ -21917,7 +22437,7 @@ var InlineModelProviderStore = class {
|
|
|
21917
22437
|
};
|
|
21918
22438
|
|
|
21919
22439
|
// src/truefoundry/inlineResources.ts
|
|
21920
|
-
import { HTTPException as
|
|
22440
|
+
import { HTTPException as HTTPException22 } from "hono/http-exception";
|
|
21921
22441
|
init_skill();
|
|
21922
22442
|
var X_TFG_MCP = "x-tfg-mcp";
|
|
21923
22443
|
var X_TFG_SKILLS = "x-tfg-skills";
|
|
@@ -21925,10 +22445,10 @@ var X_TFG_MODELS = "x-tfg-models";
|
|
|
21925
22445
|
function assertInlineResourceHeadersAllowed(input) {
|
|
21926
22446
|
const labeled = input.headerNames.join("/");
|
|
21927
22447
|
if (!input.isTrueFoundryMode) {
|
|
21928
|
-
throw new
|
|
22448
|
+
throw new HTTPException22(400, { message: `${labeled} requires TrueFoundry mode` });
|
|
21929
22449
|
}
|
|
21930
22450
|
if (!input.allowInlineResources) {
|
|
21931
|
-
throw new
|
|
22451
|
+
throw new HTTPException22(400, {
|
|
21932
22452
|
message: `${labeled} is only allowed when creating or updating an inline session, or on a turn for one`
|
|
21933
22453
|
});
|
|
21934
22454
|
}
|
|
@@ -21975,20 +22495,20 @@ function parseByName(input) {
|
|
|
21975
22495
|
try {
|
|
21976
22496
|
decoded = JSON.parse(raw);
|
|
21977
22497
|
} catch (error) {
|
|
21978
|
-
throw new
|
|
22498
|
+
throw new HTTPException22(400, { message: `${header} must be a JSON object`, cause: error });
|
|
21979
22499
|
}
|
|
21980
22500
|
if (!isPlainObject(decoded)) {
|
|
21981
|
-
throw new
|
|
22501
|
+
throw new HTTPException22(400, { message: `${header} must map each name to a definition` });
|
|
21982
22502
|
}
|
|
21983
22503
|
const manifests = {};
|
|
21984
22504
|
Object.setPrototypeOf(manifests, null);
|
|
21985
22505
|
for (const [name, definition] of Object.entries(decoded)) {
|
|
21986
22506
|
if (!isPlainObject(definition)) {
|
|
21987
|
-
throw new
|
|
22507
|
+
throw new HTTPException22(400, { message: `${header} entry "${name}" must be an object` });
|
|
21988
22508
|
}
|
|
21989
22509
|
const parsed = parseEntry(name, definition);
|
|
21990
22510
|
if (!parsed.ok) {
|
|
21991
|
-
throw new
|
|
22511
|
+
throw new HTTPException22(400, { message: `${header} entry "${name}" ${parsed.reason}` });
|
|
21992
22512
|
}
|
|
21993
22513
|
manifests[name] = parsed.manifest;
|
|
21994
22514
|
}
|
|
@@ -22000,7 +22520,7 @@ function isPlainObject(value) {
|
|
|
22000
22520
|
|
|
22001
22521
|
// src/truefoundry/InlineSkillStore.ts
|
|
22002
22522
|
init_gitSkillMounts();
|
|
22003
|
-
import { HTTPException as
|
|
22523
|
+
import { HTTPException as HTTPException24 } from "hono/http-exception";
|
|
22004
22524
|
var InlineSkillStore = class {
|
|
22005
22525
|
#inline;
|
|
22006
22526
|
constructor(input) {
|
|
@@ -22055,7 +22575,7 @@ var InlineSkillStore = class {
|
|
|
22055
22575
|
#require(name) {
|
|
22056
22576
|
const manifest = this.#inline[name];
|
|
22057
22577
|
if (manifest === void 0) {
|
|
22058
|
-
throw new
|
|
22578
|
+
throw new HTTPException24(422, {
|
|
22059
22579
|
message: `Unknown skill "${name}" \u2014 not present in ${X_TFG_SKILLS}`
|
|
22060
22580
|
});
|
|
22061
22581
|
}
|
|
@@ -22075,25 +22595,25 @@ var InlineSkillStore = class {
|
|
|
22075
22595
|
};
|
|
22076
22596
|
function unsupportedInlineSkillWrite() {
|
|
22077
22597
|
return Promise.reject(
|
|
22078
|
-
new
|
|
22598
|
+
new HTTPException24(400, { message: `Request-scoped skills from ${X_TFG_SKILLS} do not support writes` })
|
|
22079
22599
|
);
|
|
22080
22600
|
}
|
|
22081
22601
|
|
|
22082
22602
|
// src/truefoundry/perServerMcpHeaders.ts
|
|
22083
|
-
import { HTTPException as
|
|
22084
|
-
import { z as
|
|
22603
|
+
import { HTTPException as HTTPException25 } from "hono/http-exception";
|
|
22604
|
+
import { z as z44 } from "zod";
|
|
22085
22605
|
var X_TFG_MCP_HEADERS = "x-tfg-mcp-headers";
|
|
22086
|
-
var PerServerMcpHeadersSchema =
|
|
22606
|
+
var PerServerMcpHeadersSchema = z44.record(z44.string().min(1), z44.record(z44.string().min(1), z44.string()));
|
|
22087
22607
|
function parsePerServerMcpHeaders(raw) {
|
|
22088
22608
|
let decoded;
|
|
22089
22609
|
try {
|
|
22090
22610
|
decoded = JSON.parse(raw);
|
|
22091
22611
|
} catch (error) {
|
|
22092
|
-
throw new
|
|
22612
|
+
throw new HTTPException25(400, { message: `${X_TFG_MCP_HEADERS} must be a JSON object`, cause: error });
|
|
22093
22613
|
}
|
|
22094
22614
|
const parsed = PerServerMcpHeadersSchema.safeParse(decoded);
|
|
22095
22615
|
if (!parsed.success) {
|
|
22096
|
-
throw new
|
|
22616
|
+
throw new HTTPException25(400, {
|
|
22097
22617
|
message: `${X_TFG_MCP_HEADERS} must map each MCP server name to a header map`
|
|
22098
22618
|
});
|
|
22099
22619
|
}
|
|
@@ -22113,10 +22633,10 @@ import {
|
|
|
22113
22633
|
getOperationMetrics as getOperationMetrics4,
|
|
22114
22634
|
httpStatusClass
|
|
22115
22635
|
} from "@truefoundry/trueforge-core/core";
|
|
22116
|
-
import { HTTPException as
|
|
22636
|
+
import { HTTPException as HTTPException26 } from "hono/http-exception";
|
|
22117
22637
|
import { LRUCache } from "lru-cache";
|
|
22118
22638
|
import { fetch as undiciFetch3 } from "undici";
|
|
22119
|
-
import { z as
|
|
22639
|
+
import { z as z47 } from "zod";
|
|
22120
22640
|
|
|
22121
22641
|
// src/truefoundry/internalTls.ts
|
|
22122
22642
|
function normalizeInternalTlsUrl(input) {
|
|
@@ -22130,20 +22650,20 @@ function createInternalTlsDispatcher(options) {
|
|
|
22130
22650
|
}
|
|
22131
22651
|
|
|
22132
22652
|
// src/truefoundry/mapSfyAgentSkills.ts
|
|
22133
|
-
import { z as
|
|
22134
|
-
var SfyRegistryManifestSchema =
|
|
22653
|
+
import { z as z45 } from "zod";
|
|
22654
|
+
var SfyRegistryManifestSchema = z45.object({
|
|
22135
22655
|
// Display label only — not TF ResourceName / DNS-label rules.
|
|
22136
|
-
name:
|
|
22137
|
-
version:
|
|
22656
|
+
name: z45.string().min(1),
|
|
22657
|
+
version: z45.number().int().positive(),
|
|
22138
22658
|
// SFY field is `ml_repo`; TrueForge wire is `repository_name`.
|
|
22139
|
-
ml_repo:
|
|
22140
|
-
source:
|
|
22141
|
-
description:
|
|
22659
|
+
ml_repo: z45.string().min(1),
|
|
22660
|
+
source: z45.object({
|
|
22661
|
+
description: z45.string().min(1).optional()
|
|
22142
22662
|
}).optional()
|
|
22143
22663
|
});
|
|
22144
|
-
var SfyRegistrySkillSchema =
|
|
22145
|
-
latest_version:
|
|
22146
|
-
fqn:
|
|
22664
|
+
var SfyRegistrySkillSchema = z45.object({
|
|
22665
|
+
latest_version: z45.object({
|
|
22666
|
+
fqn: z45.string().min(1),
|
|
22147
22667
|
manifest: SfyRegistryManifestSchema
|
|
22148
22668
|
})
|
|
22149
22669
|
}).transform(({ latest_version }) => ({
|
|
@@ -22154,20 +22674,20 @@ var SfyRegistrySkillSchema = z43.object({
|
|
|
22154
22674
|
repository_name: latest_version.manifest.ml_repo,
|
|
22155
22675
|
version: latest_version.manifest.version
|
|
22156
22676
|
}));
|
|
22157
|
-
var SfyRegistrySkillVersionSchema =
|
|
22158
|
-
agent_skill_id:
|
|
22159
|
-
fqn:
|
|
22677
|
+
var SfyRegistrySkillVersionSchema = z45.object({
|
|
22678
|
+
agent_skill_id: z45.string().min(1),
|
|
22679
|
+
fqn: z45.string().min(1),
|
|
22160
22680
|
manifest: SfyRegistryManifestSchema
|
|
22161
22681
|
});
|
|
22162
|
-
var ResolvedAgentSkillVersionSchema =
|
|
22163
|
-
fqn:
|
|
22164
|
-
name:
|
|
22165
|
-
description:
|
|
22166
|
-
skill_md_content:
|
|
22167
|
-
presigned_url:
|
|
22682
|
+
var ResolvedAgentSkillVersionSchema = z45.object({
|
|
22683
|
+
fqn: z45.string().min(1),
|
|
22684
|
+
name: z45.string().min(1),
|
|
22685
|
+
description: z45.string().min(1),
|
|
22686
|
+
skill_md_content: z45.string().nullable().optional(),
|
|
22687
|
+
presigned_url: z45.string().min(1).optional()
|
|
22168
22688
|
});
|
|
22169
|
-
var ResolveAgentSkillVersionsResponseSchema =
|
|
22170
|
-
skills:
|
|
22689
|
+
var ResolveAgentSkillVersionsResponseSchema = z45.object({
|
|
22690
|
+
skills: z45.array(ResolvedAgentSkillVersionSchema)
|
|
22171
22691
|
});
|
|
22172
22692
|
function mapSfyRegistrySkills(rows) {
|
|
22173
22693
|
return rows.map((row) => SfyRegistrySkillSchema.parse(row));
|
|
@@ -22191,48 +22711,48 @@ function mapResolvedAgentSkillVersions(payload) {
|
|
|
22191
22711
|
}
|
|
22192
22712
|
|
|
22193
22713
|
// src/truefoundry/mapSfyMcpServers.ts
|
|
22194
|
-
import { z as
|
|
22714
|
+
import { z as z46 } from "zod";
|
|
22195
22715
|
var MCP_PROXY_BASE_URL_TEMPLATE = "{{mcpProxyBaseURL}}";
|
|
22196
|
-
var IsoInstantSchema =
|
|
22716
|
+
var IsoInstantSchema = z46.union([z46.string().min(1), z46.date()]).transform((value, ctx) => {
|
|
22197
22717
|
if (value instanceof Date) {
|
|
22198
22718
|
if (!Number.isFinite(value.getTime())) {
|
|
22199
22719
|
ctx.addIssue({ code: "custom", message: "Invalid Date" });
|
|
22200
|
-
return
|
|
22720
|
+
return z46.NEVER;
|
|
22201
22721
|
}
|
|
22202
22722
|
return value.toISOString();
|
|
22203
22723
|
}
|
|
22204
22724
|
const ms = Date.parse(value);
|
|
22205
22725
|
if (!Number.isFinite(ms)) {
|
|
22206
22726
|
ctx.addIssue({ code: "custom", message: "Invalid ISO timestamp" });
|
|
22207
|
-
return
|
|
22727
|
+
return z46.NEVER;
|
|
22208
22728
|
}
|
|
22209
22729
|
return new Date(ms).toISOString();
|
|
22210
22730
|
});
|
|
22211
|
-
var SfyMcpServerRowSchema =
|
|
22212
|
-
id:
|
|
22213
|
-
name:
|
|
22214
|
-
proxyUrl:
|
|
22731
|
+
var SfyMcpServerRowSchema = z46.object({
|
|
22732
|
+
id: z46.string().min(1),
|
|
22733
|
+
name: z46.string().min(1),
|
|
22734
|
+
proxyUrl: z46.string().min(1),
|
|
22215
22735
|
createdAt: IsoInstantSchema,
|
|
22216
22736
|
updatedAt: IsoInstantSchema,
|
|
22217
|
-
manifest:
|
|
22218
|
-
description:
|
|
22219
|
-
auth_data:
|
|
22220
|
-
type:
|
|
22737
|
+
manifest: z46.object({
|
|
22738
|
+
description: z46.string().min(1).optional(),
|
|
22739
|
+
auth_data: z46.object({
|
|
22740
|
+
type: z46.string().min(1).optional()
|
|
22221
22741
|
}).optional()
|
|
22222
22742
|
}).optional()
|
|
22223
22743
|
});
|
|
22224
|
-
var SfyMcpAuthStatusAuthenticatedSchema =
|
|
22225
|
-
var SfyMcpAuthStatusNotRequiredSchema =
|
|
22226
|
-
var SfyMcpAuthStatusRequiredSchema =
|
|
22744
|
+
var SfyMcpAuthStatusAuthenticatedSchema = z46.object({ status: z46.literal("authenticated") });
|
|
22745
|
+
var SfyMcpAuthStatusNotRequiredSchema = z46.object({ status: z46.literal("authentication_not_required") });
|
|
22746
|
+
var SfyMcpAuthStatusRequiredSchema = z46.object({ status: z46.literal("authentication_required") });
|
|
22227
22747
|
var SfyMcpAuthorizeRequiredSchema = SfyMcpAuthStatusRequiredSchema.extend({
|
|
22228
|
-
authorization_endpoint:
|
|
22748
|
+
authorization_endpoint: z46.url()
|
|
22229
22749
|
});
|
|
22230
|
-
var SfyMcpAuthStatusSchema =
|
|
22750
|
+
var SfyMcpAuthStatusSchema = z46.discriminatedUnion("status", [
|
|
22231
22751
|
SfyMcpAuthStatusAuthenticatedSchema,
|
|
22232
22752
|
SfyMcpAuthStatusRequiredSchema,
|
|
22233
22753
|
SfyMcpAuthStatusNotRequiredSchema
|
|
22234
22754
|
]);
|
|
22235
|
-
var SfyMcpAuthorizeResultSchema =
|
|
22755
|
+
var SfyMcpAuthorizeResultSchema = z46.discriminatedUnion("status", [
|
|
22236
22756
|
SfyMcpAuthStatusAuthenticatedSchema,
|
|
22237
22757
|
SfyMcpAuthorizeRequiredSchema,
|
|
22238
22758
|
SfyMcpAuthStatusNotRequiredSchema
|
|
@@ -22303,34 +22823,35 @@ var AGENT_SKILL_VERSIONS_PATH = "v1/agent-skill-versions";
|
|
|
22303
22823
|
var SESSION_PATH = "v1/session";
|
|
22304
22824
|
var AGENT_PERMISSIONS_PATH = "v1/authorize/permissions";
|
|
22305
22825
|
var VEND_TOKEN_PATH = "internal/vend-token";
|
|
22826
|
+
var SUBJECTS_PEEK_PATH = "v1/subjects/peek";
|
|
22306
22827
|
var AGENT_SKILLS_PAGE_SIZE = 100;
|
|
22307
22828
|
var AGENT_SKILL_RESOLVE_CHUNK_SIZE = 50;
|
|
22308
|
-
var SessionSubjectSchema =
|
|
22309
|
-
subjectId:
|
|
22310
|
-
subjectType:
|
|
22311
|
-
subjectDisplayName:
|
|
22312
|
-
subjectSlug:
|
|
22829
|
+
var SessionSubjectSchema = z47.object({
|
|
22830
|
+
subjectId: z47.string().min(1),
|
|
22831
|
+
subjectType: z47.string().min(1),
|
|
22832
|
+
subjectDisplayName: z47.string().nullable().optional(),
|
|
22833
|
+
subjectSlug: z47.string().nullable().optional()
|
|
22313
22834
|
});
|
|
22314
|
-
var GetSessionUserSchema =
|
|
22315
|
-
tenantName:
|
|
22316
|
-
roles:
|
|
22835
|
+
var GetSessionUserSchema = z47.object({
|
|
22836
|
+
tenantName: z47.string().min(1),
|
|
22837
|
+
roles: z47.array(z47.string()),
|
|
22317
22838
|
subject: SessionSubjectSchema
|
|
22318
22839
|
});
|
|
22319
|
-
var GetSessionUnauthenticatedSchema =
|
|
22320
|
-
user:
|
|
22840
|
+
var GetSessionUnauthenticatedSchema = z47.object({
|
|
22841
|
+
user: z47.null()
|
|
22321
22842
|
});
|
|
22322
|
-
var GetSessionAuthenticatedSchema =
|
|
22843
|
+
var GetSessionAuthenticatedSchema = z47.object({
|
|
22323
22844
|
user: GetSessionUserSchema
|
|
22324
22845
|
});
|
|
22325
|
-
var GetSessionWireSchema =
|
|
22326
|
-
var TenantControlPlaneUrlSchema =
|
|
22327
|
-
controlPlaneURL:
|
|
22846
|
+
var GetSessionWireSchema = z47.union([GetSessionUnauthenticatedSchema, GetSessionAuthenticatedSchema]);
|
|
22847
|
+
var TenantControlPlaneUrlSchema = z47.object({
|
|
22848
|
+
controlPlaneURL: z47.url()
|
|
22328
22849
|
});
|
|
22329
|
-
var ListResponseSchema =
|
|
22330
|
-
|
|
22331
|
-
|
|
22332
|
-
data:
|
|
22333
|
-
pagination:
|
|
22850
|
+
var ListResponseSchema = z47.union([
|
|
22851
|
+
z47.array(z47.unknown()),
|
|
22852
|
+
z47.object({
|
|
22853
|
+
data: z47.array(z47.unknown()).catch([]),
|
|
22854
|
+
pagination: z47.object({ total: z47.number().optional() }).optional()
|
|
22334
22855
|
})
|
|
22335
22856
|
]);
|
|
22336
22857
|
var SERVICE_FOUNDRY_OPERATIONS = {
|
|
@@ -22350,27 +22871,37 @@ var SERVICE_FOUNDRY_OPERATIONS = {
|
|
|
22350
22871
|
getTenantControlPlaneUrl: "get_session",
|
|
22351
22872
|
getAgentPermissions: "agent_permissions",
|
|
22352
22873
|
getTenantPermissions: "tenant_permissions",
|
|
22353
|
-
vendToken: "vend_token"
|
|
22874
|
+
vendToken: "vend_token",
|
|
22875
|
+
peekUsers: "users"
|
|
22354
22876
|
};
|
|
22355
|
-
var ServiceFoundryErrorSchema =
|
|
22356
|
-
message:
|
|
22877
|
+
var ServiceFoundryErrorSchema = z47.object({
|
|
22878
|
+
message: z47.union([z47.string(), z47.array(z47.string())]).optional()
|
|
22357
22879
|
});
|
|
22358
|
-
var PutRemoteAgentResponseSchema =
|
|
22359
|
-
agentId:
|
|
22880
|
+
var PutRemoteAgentResponseSchema = z47.object({
|
|
22881
|
+
agentId: z47.string().min(1)
|
|
22360
22882
|
});
|
|
22361
|
-
var AgentPermissionSchema =
|
|
22362
|
-
var AgentPermissionsSchema =
|
|
22363
|
-
|
|
22364
|
-
|
|
22883
|
+
var AgentPermissionSchema = z47.enum(["READ_AGENT", "USE_AGENT", "MANAGE_AGENT", "DELETE_AGENT"]);
|
|
22884
|
+
var AgentPermissionsSchema = z47.record(
|
|
22885
|
+
z47.string(),
|
|
22886
|
+
z47.array(z47.string()).transform(
|
|
22365
22887
|
(permissions) => permissions.flatMap((permission) => {
|
|
22366
22888
|
const parsed = AgentPermissionSchema.safeParse(permission);
|
|
22367
22889
|
return parsed.success ? [parsed.data] : [];
|
|
22368
22890
|
})
|
|
22369
22891
|
)
|
|
22370
22892
|
);
|
|
22371
|
-
var VendTokenResponseSchema =
|
|
22372
|
-
subjectToken:
|
|
22373
|
-
actorToken:
|
|
22893
|
+
var VendTokenResponseSchema = z47.object({
|
|
22894
|
+
subjectToken: z47.string().min(1),
|
|
22895
|
+
actorToken: z47.string().min(1)
|
|
22896
|
+
});
|
|
22897
|
+
var PeekUserSchema = z47.object({
|
|
22898
|
+
id: z47.string().min(1),
|
|
22899
|
+
name: z47.string().nullish(),
|
|
22900
|
+
email: z47.string().min(1)
|
|
22901
|
+
});
|
|
22902
|
+
var PeekUsersResponseSchema = z47.object({
|
|
22903
|
+
users: z47.array(PeekUserSchema),
|
|
22904
|
+
totalUsers: z47.number().int().nonnegative()
|
|
22374
22905
|
});
|
|
22375
22906
|
async function readServiceFoundryErrorMessage(response) {
|
|
22376
22907
|
const body = await response.json().catch(() => void 0);
|
|
@@ -22496,7 +23027,7 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
22496
23027
|
...extractErrorLogFields8(parsed.error),
|
|
22497
23028
|
reportable_error: { error: parsed.error }
|
|
22498
23029
|
});
|
|
22499
|
-
throw new
|
|
23030
|
+
throw new HTTPException26(424, {
|
|
22500
23031
|
message: "TrueFoundry ServiceFoundry put remote agent returned an unexpected response",
|
|
22501
23032
|
cause: parsed.error
|
|
22502
23033
|
});
|
|
@@ -22572,7 +23103,7 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
22572
23103
|
this.#logger.error("TrueFoundry ServiceFoundry resolve agent-skill-versions returned an unexpected response", {
|
|
22573
23104
|
...extractErrorLogFields8(error)
|
|
22574
23105
|
});
|
|
22575
|
-
throw new
|
|
23106
|
+
throw new HTTPException26(500, {
|
|
22576
23107
|
message: "TrueFoundry ServiceFoundry resolve agent-skill-versions returned an unexpected response",
|
|
22577
23108
|
cause: error
|
|
22578
23109
|
});
|
|
@@ -22626,7 +23157,7 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
22626
23157
|
...extractErrorLogFields8(error),
|
|
22627
23158
|
reportable_error: { error, extra: { mcp_server_id: input.mcpServerId } }
|
|
22628
23159
|
});
|
|
22629
|
-
throw new
|
|
23160
|
+
throw new HTTPException26(424, {
|
|
22630
23161
|
message: "TrueFoundry ServiceFoundry MCP authorize returned an unexpected response",
|
|
22631
23162
|
cause: error
|
|
22632
23163
|
});
|
|
@@ -22651,7 +23182,7 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
22651
23182
|
...extractErrorLogFields8(error),
|
|
22652
23183
|
reportable_error: { error, extra: { mcp_server_id: input.mcpServerId } }
|
|
22653
23184
|
});
|
|
22654
|
-
throw new
|
|
23185
|
+
throw new HTTPException26(424, {
|
|
22655
23186
|
message: "TrueFoundry ServiceFoundry MCP auth status returned an unexpected response",
|
|
22656
23187
|
cause: error
|
|
22657
23188
|
});
|
|
@@ -22685,23 +23216,23 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
22685
23216
|
method: "GET"
|
|
22686
23217
|
});
|
|
22687
23218
|
} catch (error) {
|
|
22688
|
-
if (error instanceof
|
|
23219
|
+
if (error instanceof HTTPException26 && (error.status === 401 || error.status === 403)) {
|
|
22689
23220
|
throw error;
|
|
22690
23221
|
}
|
|
22691
|
-
throw new
|
|
23222
|
+
throw new HTTPException26(500, {
|
|
22692
23223
|
message: "TrueFoundry ServiceFoundry session request failed",
|
|
22693
23224
|
cause: error
|
|
22694
23225
|
});
|
|
22695
23226
|
}
|
|
22696
23227
|
const parsed = GetSessionWireSchema.safeParse(payload);
|
|
22697
23228
|
if (!parsed.success) {
|
|
22698
|
-
throw new
|
|
23229
|
+
throw new HTTPException26(500, {
|
|
22699
23230
|
message: "TrueFoundry ServiceFoundry session response was malformed",
|
|
22700
23231
|
cause: parsed.error
|
|
22701
23232
|
});
|
|
22702
23233
|
}
|
|
22703
23234
|
if (parsed.data.user === null) {
|
|
22704
|
-
throw new
|
|
23235
|
+
throw new HTTPException26(401, { message: "Authentication required" });
|
|
22705
23236
|
}
|
|
22706
23237
|
return parsed.data;
|
|
22707
23238
|
}
|
|
@@ -22724,14 +23255,14 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
22724
23255
|
});
|
|
22725
23256
|
} catch (error) {
|
|
22726
23257
|
const causeString = error instanceof Error ? error.message : String(error);
|
|
22727
|
-
throw new
|
|
23258
|
+
throw new HTTPException26(500, {
|
|
22728
23259
|
message: `TrueFoundry ServiceFoundry session request failed: ${causeString}`,
|
|
22729
23260
|
cause: error
|
|
22730
23261
|
});
|
|
22731
23262
|
}
|
|
22732
23263
|
const parsed = TenantControlPlaneUrlSchema.safeParse(payload);
|
|
22733
23264
|
if (!parsed.success) {
|
|
22734
|
-
throw new
|
|
23265
|
+
throw new HTTPException26(500, {
|
|
22735
23266
|
message: "TrueFoundry ServiceFoundry session response was malformed",
|
|
22736
23267
|
cause: parsed.error
|
|
22737
23268
|
});
|
|
@@ -22757,7 +23288,7 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
22757
23288
|
...extractErrorLogFields8(parsed.error),
|
|
22758
23289
|
reportable_error: { error: parsed.error }
|
|
22759
23290
|
});
|
|
22760
|
-
throw new
|
|
23291
|
+
throw new HTTPException26(424, {
|
|
22761
23292
|
message: "TrueFoundry ServiceFoundry agent permissions response was malformed",
|
|
22762
23293
|
cause: parsed.error
|
|
22763
23294
|
});
|
|
@@ -22775,19 +23306,51 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
22775
23306
|
accessToken: input.accessToken,
|
|
22776
23307
|
method: "GET"
|
|
22777
23308
|
});
|
|
22778
|
-
const parsed =
|
|
23309
|
+
const parsed = z47.array(z47.string()).safeParse(payload);
|
|
22779
23310
|
if (!parsed.success) {
|
|
22780
23311
|
this.#logger.error("TrueFoundry ServiceFoundry tenant permissions response was malformed", {
|
|
22781
23312
|
...extractErrorLogFields8(parsed.error),
|
|
22782
23313
|
reportable_error: { error: parsed.error }
|
|
22783
23314
|
});
|
|
22784
|
-
throw new
|
|
23315
|
+
throw new HTTPException26(424, {
|
|
22785
23316
|
message: "TrueFoundry ServiceFoundry tenant permissions response was malformed",
|
|
22786
23317
|
cause: parsed.error
|
|
22787
23318
|
});
|
|
22788
23319
|
}
|
|
22789
23320
|
return parsed.data;
|
|
22790
23321
|
}
|
|
23322
|
+
/**
|
|
23323
|
+
* `GET v1/subjects/peek` for active tenant users, with the caller's token.
|
|
23324
|
+
* Search needs `limit`, since ServiceFoundry returns every match without one. An id lookup returns
|
|
23325
|
+
* at most one user per id, so it sends no paging.
|
|
23326
|
+
*/
|
|
23327
|
+
async peekUsers(input) {
|
|
23328
|
+
const search = "ids" in input ? { filter: JSON.stringify({ subjects: input.ids.map((id) => ({ subjectType: "user", subjectId: id })) }) } : {
|
|
23329
|
+
filter: JSON.stringify({
|
|
23330
|
+
subjectType: ["user"],
|
|
23331
|
+
...input.name === void 0 ? {} : { name: input.name }
|
|
23332
|
+
}),
|
|
23333
|
+
limit: String(input.limit),
|
|
23334
|
+
offset: String(input.offset)
|
|
23335
|
+
};
|
|
23336
|
+
const payload = await this.#requestJson({
|
|
23337
|
+
operation: SERVICE_FOUNDRY_OPERATIONS.peekUsers,
|
|
23338
|
+
url: this.#url(SUBJECTS_PEEK_PATH, search),
|
|
23339
|
+
accessToken: input.accessToken,
|
|
23340
|
+
method: "GET"
|
|
23341
|
+
});
|
|
23342
|
+
const parsed = PeekUsersResponseSchema.safeParse(payload);
|
|
23343
|
+
if (!parsed.success) {
|
|
23344
|
+
this.#logger.error("TrueFoundry ServiceFoundry subjects response was malformed", {
|
|
23345
|
+
...extractErrorLogFields8(parsed.error)
|
|
23346
|
+
});
|
|
23347
|
+
throw new HTTPException26(424, {
|
|
23348
|
+
message: "TrueFoundry ServiceFoundry subjects response was malformed",
|
|
23349
|
+
cause: parsed.error
|
|
23350
|
+
});
|
|
23351
|
+
}
|
|
23352
|
+
return parsed.data;
|
|
23353
|
+
}
|
|
22791
23354
|
/**
|
|
22792
23355
|
* Exchange a TrueFoundry API key for dual agent-scoped tokens.
|
|
22793
23356
|
* Wire `actorToken` is the agent identity. Wire `subjectToken` is the user with the agent in `act`.
|
|
@@ -22813,7 +23376,7 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
22813
23376
|
...extractErrorLogFields8(parsed.error),
|
|
22814
23377
|
reportable_error: { error: parsed.error }
|
|
22815
23378
|
});
|
|
22816
|
-
throw new
|
|
23379
|
+
throw new HTTPException26(424, {
|
|
22817
23380
|
message: "TrueFoundry ServiceFoundry vend-token response was malformed",
|
|
22818
23381
|
cause: parsed.error
|
|
22819
23382
|
});
|
|
@@ -22827,7 +23390,7 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
22827
23390
|
...extractErrorLogFields8(parsed.error),
|
|
22828
23391
|
reportable_error: { error: parsed.error }
|
|
22829
23392
|
});
|
|
22830
|
-
throw new
|
|
23393
|
+
throw new HTTPException26(424, {
|
|
22831
23394
|
message: "TrueFoundry ServiceFoundry server returned an unexpected list response",
|
|
22832
23395
|
cause: parsed.error
|
|
22833
23396
|
});
|
|
@@ -22884,7 +23447,7 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
22884
23447
|
timedOut,
|
|
22885
23448
|
...extractErrorLogFields8(error)
|
|
22886
23449
|
});
|
|
22887
|
-
throw new
|
|
23450
|
+
throw new HTTPException26(500, {
|
|
22888
23451
|
message: timedOut ? `TrueFoundry ServiceFoundry server request timed out after ${String(timeoutMs / 1e3)}s` : "TrueFoundry ServiceFoundry server request failed",
|
|
22889
23452
|
cause: error
|
|
22890
23453
|
});
|
|
@@ -22898,7 +23461,7 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
22898
23461
|
if (response.status === 401 || response.status === 403) {
|
|
22899
23462
|
record("error", response.status);
|
|
22900
23463
|
const detail = await readServiceFoundryErrorMessage(response);
|
|
22901
|
-
throw new
|
|
23464
|
+
throw new HTTPException26(response.status, {
|
|
22902
23465
|
message: `TrueFoundry ServiceFoundry server rejected the request: ${detail ?? `HTTP ${String(response.status)}`}`
|
|
22903
23466
|
});
|
|
22904
23467
|
}
|
|
@@ -22909,7 +23472,7 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
22909
23472
|
if (!response.ok) {
|
|
22910
23473
|
record("error", response.status);
|
|
22911
23474
|
const detail = await readServiceFoundryErrorMessage(response);
|
|
22912
|
-
throw new
|
|
23475
|
+
throw new HTTPException26(424, {
|
|
22913
23476
|
message: `TrueFoundry ServiceFoundry server request failed: ${detail ?? `HTTP ${String(response.status)}`}`
|
|
22914
23477
|
});
|
|
22915
23478
|
}
|
|
@@ -22933,7 +23496,7 @@ var TrueFoundryServiceFoundryServerClient = class {
|
|
|
22933
23496
|
...extractErrorLogFields8(error),
|
|
22934
23497
|
reportable_error: { error }
|
|
22935
23498
|
});
|
|
22936
|
-
throw new
|
|
23499
|
+
throw new HTTPException26(424, {
|
|
22937
23500
|
message: "TrueFoundry ServiceFoundry server returned non-JSON",
|
|
22938
23501
|
cause: error
|
|
22939
23502
|
});
|
|
@@ -23145,7 +23708,7 @@ var TrueFoundryAgentStore = class {
|
|
|
23145
23708
|
};
|
|
23146
23709
|
|
|
23147
23710
|
// src/truefoundry/TrueFoundryAuthorizer.ts
|
|
23148
|
-
import { HTTPException as
|
|
23711
|
+
import { HTTPException as HTTPException27 } from "hono/http-exception";
|
|
23149
23712
|
var permissionByAction = {
|
|
23150
23713
|
read: "READ_AGENT",
|
|
23151
23714
|
use: "USE_AGENT",
|
|
@@ -23166,7 +23729,7 @@ function toResourcePermissions(permissions) {
|
|
|
23166
23729
|
}
|
|
23167
23730
|
function requireUserCredential(context) {
|
|
23168
23731
|
if (context.user_credential === null) {
|
|
23169
|
-
throw new
|
|
23732
|
+
throw new HTTPException27(401, { message: "Authentication token required for agent authorization" });
|
|
23170
23733
|
}
|
|
23171
23734
|
return context.user_credential;
|
|
23172
23735
|
}
|
|
@@ -23242,32 +23805,32 @@ var TrueFoundryAuthorizer = class {
|
|
|
23242
23805
|
|
|
23243
23806
|
// src/truefoundry/TrueFoundryMcpServerStore.ts
|
|
23244
23807
|
import { McpConnectionError as McpConnectionError6 } from "@truefoundry/trueforge-core/core";
|
|
23245
|
-
import { HTTPException as
|
|
23808
|
+
import { HTTPException as HTTPException29 } from "hono/http-exception";
|
|
23246
23809
|
init_config();
|
|
23247
23810
|
init_mcpServerStore();
|
|
23248
23811
|
|
|
23249
23812
|
// src/truefoundry/mapEnabledModels.ts
|
|
23250
23813
|
init_config();
|
|
23251
23814
|
import { SUPPORTED_REASONING_EFFORTS as SUPPORTED_REASONING_EFFORTS3 } from "@truefoundry/trueforge-core/core";
|
|
23252
|
-
import { HTTPException as
|
|
23253
|
-
import { z as
|
|
23254
|
-
var ModelParamSchema =
|
|
23255
|
-
key:
|
|
23256
|
-
supportedValues:
|
|
23815
|
+
import { HTTPException as HTTPException28 } from "hono/http-exception";
|
|
23816
|
+
import { z as z48 } from "zod";
|
|
23817
|
+
var ModelParamSchema = z48.object({
|
|
23818
|
+
key: z48.string(),
|
|
23819
|
+
supportedValues: z48.array(z48.string()).optional()
|
|
23257
23820
|
});
|
|
23258
|
-
var MetadataSchema =
|
|
23259
|
-
limits:
|
|
23260
|
-
context_window:
|
|
23261
|
-
max_input_tokens:
|
|
23262
|
-
max_output_tokens:
|
|
23263
|
-
max_tokens:
|
|
23821
|
+
var MetadataSchema = z48.object({
|
|
23822
|
+
limits: z48.object({
|
|
23823
|
+
context_window: z48.number().optional(),
|
|
23824
|
+
max_input_tokens: z48.number().optional(),
|
|
23825
|
+
max_output_tokens: z48.number().optional(),
|
|
23826
|
+
max_tokens: z48.number().optional()
|
|
23264
23827
|
}).optional(),
|
|
23265
|
-
params:
|
|
23828
|
+
params: z48.array(ModelParamSchema).optional()
|
|
23266
23829
|
});
|
|
23267
|
-
var IntegrationSchema =
|
|
23268
|
-
name:
|
|
23269
|
-
manifest:
|
|
23270
|
-
providerAccount:
|
|
23830
|
+
var IntegrationSchema = z48.object({
|
|
23831
|
+
name: z48.string().min(1),
|
|
23832
|
+
manifest: z48.object({ model_types: z48.array(z48.string()).optional() }),
|
|
23833
|
+
providerAccount: z48.object({ name: z48.string().min(1) }),
|
|
23271
23834
|
metadata: MetadataSchema.optional()
|
|
23272
23835
|
});
|
|
23273
23836
|
function toReasoningEfforts(params) {
|
|
@@ -23325,11 +23888,11 @@ function filterEnvModels(input) {
|
|
|
23325
23888
|
const allowed = new Set(allowedAccounts);
|
|
23326
23889
|
return input.models.filter((model) => allowed.has(model.accountName));
|
|
23327
23890
|
}
|
|
23328
|
-
var InstallationSchema =
|
|
23329
|
-
isDefault:
|
|
23330
|
-
manifest:
|
|
23891
|
+
var InstallationSchema = z48.object({
|
|
23892
|
+
isDefault: z48.boolean().optional(),
|
|
23893
|
+
manifest: z48.object({ url: z48.string().min(1) })
|
|
23331
23894
|
});
|
|
23332
|
-
var InstallationsEnvelopeSchema =
|
|
23895
|
+
var InstallationsEnvelopeSchema = z48.union([z48.array(z48.unknown()), z48.object({ data: z48.array(z48.unknown()) })]);
|
|
23333
23896
|
function resolveDefaultGatewayUrl(payload) {
|
|
23334
23897
|
const envelope = InstallationsEnvelopeSchema.parse(payload);
|
|
23335
23898
|
const rows = Array.isArray(envelope) ? envelope : envelope.data;
|
|
@@ -23339,7 +23902,7 @@ function resolveDefaultGatewayUrl(payload) {
|
|
|
23339
23902
|
return installation.manifest.url;
|
|
23340
23903
|
}
|
|
23341
23904
|
}
|
|
23342
|
-
throw new
|
|
23905
|
+
throw new HTTPException28(502, { message: "No default TrueFoundry AI gateway installation is configured" });
|
|
23343
23906
|
}
|
|
23344
23907
|
|
|
23345
23908
|
// src/truefoundry/TrueFoundryMcpServerStore.ts
|
|
@@ -23393,7 +23956,7 @@ var TrueFoundryMcpServerStore = class {
|
|
|
23393
23956
|
if (status.status === "auth_required") {
|
|
23394
23957
|
const authUrl = status.authorization_url;
|
|
23395
23958
|
if (authUrl === void 0 || authUrl.length === 0) {
|
|
23396
|
-
throw new
|
|
23959
|
+
throw new HTTPException29(422, {
|
|
23397
23960
|
message: `MCP server "${record.name}" requires authentication but returned no authorization URL`
|
|
23398
23961
|
});
|
|
23399
23962
|
}
|
|
@@ -23669,7 +24232,7 @@ function toManifest(input) {
|
|
|
23669
24232
|
// src/truefoundry/TrueFoundrySandboxEnvironmentStore.ts
|
|
23670
24233
|
init_sandboxEnvironmentStore();
|
|
23671
24234
|
init_sandboxEnvironment();
|
|
23672
|
-
import { encodeOffsetPageToken } from "@truefoundry/trueforge-core/agent-session/store/OffsetPageToken";
|
|
24235
|
+
import { encodeOffsetPageToken as encodeOffsetPageToken2 } from "@truefoundry/trueforge-core/agent-session/store/OffsetPageToken";
|
|
23673
24236
|
import { createLogger as createLogger2 } from "winston";
|
|
23674
24237
|
|
|
23675
24238
|
// src/truefoundry/synthesizeTrueFoundryDefaultSandboxEnvironment.ts
|
|
@@ -23741,7 +24304,7 @@ var TrueFoundrySandboxEnvironmentStore = class {
|
|
|
23741
24304
|
data: [synthesized],
|
|
23742
24305
|
pagination: {
|
|
23743
24306
|
limit: input.limit ?? 1,
|
|
23744
|
-
...hasMore ? { next_page_token: peek.pagination.next_page_token ??
|
|
24307
|
+
...hasMore ? { next_page_token: peek.pagination.next_page_token ?? encodeOffsetPageToken2(0) } : {}
|
|
23745
24308
|
}
|
|
23746
24309
|
};
|
|
23747
24310
|
}
|
|
@@ -23947,7 +24510,7 @@ var TrueFoundrySandboxProviderStore = class {
|
|
|
23947
24510
|
};
|
|
23948
24511
|
|
|
23949
24512
|
// src/truefoundry/TrueFoundrySkillStore.ts
|
|
23950
|
-
import { HTTPException as
|
|
24513
|
+
import { HTTPException as HTTPException30 } from "hono/http-exception";
|
|
23951
24514
|
function toRegistryRecord(tenant_id, skill) {
|
|
23952
24515
|
const now2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
23953
24516
|
const manifest = {
|
|
@@ -23988,18 +24551,18 @@ var TrueFoundryAdminSkillStore = class {
|
|
|
23988
24551
|
return skills.map((skill) => {
|
|
23989
24552
|
const row = byFqn.get(skill.name);
|
|
23990
24553
|
if (row === void 0) {
|
|
23991
|
-
throw new
|
|
24554
|
+
throw new HTTPException30(422, {
|
|
23992
24555
|
message: `Unknown skill "${skill.name}" \u2014 not configured`
|
|
23993
24556
|
});
|
|
23994
24557
|
}
|
|
23995
24558
|
if (row.presigned_url === void 0) {
|
|
23996
|
-
throw new
|
|
24559
|
+
throw new HTTPException30(422, {
|
|
23997
24560
|
message: `Skill "${skill.name}" did not return a presigned URL`
|
|
23998
24561
|
});
|
|
23999
24562
|
}
|
|
24000
24563
|
const skillMdContent = skill.preload ? row.skill_md_content ?? null : null;
|
|
24001
24564
|
if (skill.preload && (skillMdContent === null || skillMdContent.length === 0)) {
|
|
24002
|
-
throw new
|
|
24565
|
+
throw new HTTPException30(422, {
|
|
24003
24566
|
message: `Skill "${skill.name}" did not return SKILL.md for preload`
|
|
24004
24567
|
});
|
|
24005
24568
|
}
|
|
@@ -24026,7 +24589,7 @@ var TrueFoundrySkillStore = class extends TrueFoundryAdminSkillStore {
|
|
|
24026
24589
|
async listSkills(input, transaction) {
|
|
24027
24590
|
void transaction;
|
|
24028
24591
|
if (input.names !== void 0) {
|
|
24029
|
-
throw new
|
|
24592
|
+
throw new HTTPException30(422, {
|
|
24030
24593
|
message: "TrueFoundry skill list does not support name filters"
|
|
24031
24594
|
});
|
|
24032
24595
|
}
|
|
@@ -24074,7 +24637,7 @@ var TrueFoundrySkillStore = class extends TrueFoundryAdminSkillStore {
|
|
|
24074
24637
|
const seenFqns = /* @__PURE__ */ new Set();
|
|
24075
24638
|
for (const skill of skills) {
|
|
24076
24639
|
if (seenFqns.has(skill.name)) {
|
|
24077
|
-
throw new
|
|
24640
|
+
throw new HTTPException30(422, {
|
|
24078
24641
|
message: `Duplicate skill FQN "${skill.name}"`
|
|
24079
24642
|
});
|
|
24080
24643
|
}
|
|
@@ -24088,7 +24651,7 @@ var TrueFoundrySkillStore = class extends TrueFoundryAdminSkillStore {
|
|
|
24088
24651
|
const byFqn = new Map(resolved.map((row) => [row.fqn, row]));
|
|
24089
24652
|
for (const skill of skills) {
|
|
24090
24653
|
if (!byFqn.has(skill.name)) {
|
|
24091
|
-
throw new
|
|
24654
|
+
throw new HTTPException30(422, {
|
|
24092
24655
|
message: `Unknown skill "${skill.name}" \u2014 not configured`
|
|
24093
24656
|
});
|
|
24094
24657
|
}
|
|
@@ -24096,7 +24659,7 @@ var TrueFoundrySkillStore = class extends TrueFoundryAdminSkillStore {
|
|
|
24096
24659
|
const seenNames = /* @__PURE__ */ new Set();
|
|
24097
24660
|
for (const row of resolved) {
|
|
24098
24661
|
if (seenNames.has(row.name)) {
|
|
24099
|
-
throw new
|
|
24662
|
+
throw new HTTPException30(422, {
|
|
24100
24663
|
message: `Agent skills must have unique names; duplicate skill name(s): ${row.name}`
|
|
24101
24664
|
});
|
|
24102
24665
|
}
|
|
@@ -24105,6 +24668,46 @@ var TrueFoundrySkillStore = class extends TrueFoundryAdminSkillStore {
|
|
|
24105
24668
|
}
|
|
24106
24669
|
};
|
|
24107
24670
|
|
|
24671
|
+
// src/truefoundry/TrueFoundryUserStore.ts
|
|
24672
|
+
var PEEK_IDS_CHUNK_SIZE = 50;
|
|
24673
|
+
function toUser(user) {
|
|
24674
|
+
return {
|
|
24675
|
+
id: user.id,
|
|
24676
|
+
display_name: user.name ?? user.email,
|
|
24677
|
+
email: user.email
|
|
24678
|
+
};
|
|
24679
|
+
}
|
|
24680
|
+
var TrueFoundryUserStore = class {
|
|
24681
|
+
supportsUserLookup = true;
|
|
24682
|
+
#client;
|
|
24683
|
+
constructor(client2) {
|
|
24684
|
+
this.#client = client2;
|
|
24685
|
+
}
|
|
24686
|
+
async listUsers(input) {
|
|
24687
|
+
const { users, totalUsers } = await this.#client.peekUsers({
|
|
24688
|
+
accessToken: await callerAccessToken(input.context)(),
|
|
24689
|
+
...input.query === void 0 ? {} : { name: input.query },
|
|
24690
|
+
limit: input.limit,
|
|
24691
|
+
offset: input.offset
|
|
24692
|
+
});
|
|
24693
|
+
return { data: users.map(toUser), total: totalUsers };
|
|
24694
|
+
}
|
|
24695
|
+
async getUsersByIds(input) {
|
|
24696
|
+
const ids = [...new Set(input.ids)];
|
|
24697
|
+
if (ids.length === 0) {
|
|
24698
|
+
return [];
|
|
24699
|
+
}
|
|
24700
|
+
const accessToken = await callerAccessToken(input.context)();
|
|
24701
|
+
const found = [];
|
|
24702
|
+
for (let i = 0; i < ids.length; i += PEEK_IDS_CHUNK_SIZE) {
|
|
24703
|
+
const chunk = ids.slice(i, i + PEEK_IDS_CHUNK_SIZE);
|
|
24704
|
+
const { users } = await this.#client.peekUsers({ accessToken, ids: chunk });
|
|
24705
|
+
found.push(...users.map(toUser));
|
|
24706
|
+
}
|
|
24707
|
+
return found;
|
|
24708
|
+
}
|
|
24709
|
+
};
|
|
24710
|
+
|
|
24108
24711
|
// src/truefoundry/TrueFoundryWebSearchProviderStore.ts
|
|
24109
24712
|
init_config();
|
|
24110
24713
|
function synthesizeParallelRecord(tenantId) {
|
|
@@ -24328,7 +24931,8 @@ async function createStandalonePersistence(options) {
|
|
|
24328
24931
|
Promise.resolve().then(() => (init_SqliteWebSearchProviderStore(), SqliteWebSearchProviderStore_exports)),
|
|
24329
24932
|
Promise.resolve().then(() => (init_SqliteAgentStore(), SqliteAgentStore_exports)),
|
|
24330
24933
|
Promise.resolve().then(() => (init_SqliteScheduleStore(), SqliteScheduleStore_exports)),
|
|
24331
|
-
Promise.resolve().then(() => (init_SqliteSandboxEnvironmentStore(), SqliteSandboxEnvironmentStore_exports))
|
|
24934
|
+
Promise.resolve().then(() => (init_SqliteSandboxEnvironmentStore(), SqliteSandboxEnvironmentStore_exports)),
|
|
24935
|
+
Promise.resolve().then(() => (init_SqliteAccessControlStore(), SqliteAccessControlStore_exports))
|
|
24332
24936
|
])
|
|
24333
24937
|
]);
|
|
24334
24938
|
const [
|
|
@@ -24342,7 +24946,8 @@ async function createStandalonePersistence(options) {
|
|
|
24342
24946
|
{ SqliteWebSearchProviderStore: SqliteWebSearchProviderStore2 },
|
|
24343
24947
|
{ SqliteAgentStore: SqliteAgentStore2 },
|
|
24344
24948
|
{ SqliteScheduleStore: SqliteScheduleStore2 },
|
|
24345
|
-
{ SqliteSandboxEnvironmentStore: SqliteSandboxEnvironmentStore2 }
|
|
24949
|
+
{ SqliteSandboxEnvironmentStore: SqliteSandboxEnvironmentStore2 },
|
|
24950
|
+
{ SqliteAccessControlStore: SqliteAccessControlStore2 }
|
|
24346
24951
|
] = sqliteStores;
|
|
24347
24952
|
const db = createSqliteDb2(sqlitePath);
|
|
24348
24953
|
await migrateSqliteToLatest2(db);
|
|
@@ -24363,6 +24968,7 @@ async function createStandalonePersistence(options) {
|
|
|
24363
24968
|
return {
|
|
24364
24969
|
withTransaction: (callback) => db.transaction().execute(callback),
|
|
24365
24970
|
sessionStore: new SqliteSessionStore2(db),
|
|
24971
|
+
accessControlStore: new SqliteAccessControlStore2(db),
|
|
24366
24972
|
sessionMetricsStore: new SqliteSessionMetricsStore2(db),
|
|
24367
24973
|
mcpOAuthStore: mcpServerStore,
|
|
24368
24974
|
tokenStore,
|
|
@@ -24420,7 +25026,8 @@ async function createDistributedPersistence(options) {
|
|
|
24420
25026
|
Promise.resolve().then(() => (init_PostgresWebSearchProviderStore(), PostgresWebSearchProviderStore_exports)),
|
|
24421
25027
|
Promise.resolve().then(() => (init_PostgresAgentStore(), PostgresAgentStore_exports)),
|
|
24422
25028
|
Promise.resolve().then(() => (init_PostgresScheduleStore(), PostgresScheduleStore_exports)),
|
|
24423
|
-
Promise.resolve().then(() => (init_PostgresSandboxEnvironmentStore(), PostgresSandboxEnvironmentStore_exports))
|
|
25029
|
+
Promise.resolve().then(() => (init_PostgresSandboxEnvironmentStore(), PostgresSandboxEnvironmentStore_exports)),
|
|
25030
|
+
Promise.resolve().then(() => (init_PostgresAccessControlStore(), PostgresAccessControlStore_exports))
|
|
24424
25031
|
])
|
|
24425
25032
|
]);
|
|
24426
25033
|
const [
|
|
@@ -24434,7 +25041,8 @@ async function createDistributedPersistence(options) {
|
|
|
24434
25041
|
{ PostgresWebSearchProviderStore: PostgresWebSearchProviderStore2 },
|
|
24435
25042
|
{ PostgresAgentStore: PostgresAgentStore3 },
|
|
24436
25043
|
{ PostgresScheduleStore: PostgresScheduleStore2 },
|
|
24437
|
-
{ PostgresSandboxEnvironmentStore: PostgresSandboxEnvironmentStore2 }
|
|
25044
|
+
{ PostgresSandboxEnvironmentStore: PostgresSandboxEnvironmentStore2 },
|
|
25045
|
+
{ PostgresAccessControlStore: PostgresAccessControlStore2 }
|
|
24438
25046
|
] = postgresStores;
|
|
24439
25047
|
logger2.info("Connecting to Postgres");
|
|
24440
25048
|
const db = createDb2({
|
|
@@ -24499,6 +25107,7 @@ async function createDistributedPersistence(options) {
|
|
|
24499
25107
|
return {
|
|
24500
25108
|
withTransaction: (callback) => db.transaction().execute(callback),
|
|
24501
25109
|
sessionStore: new PostgresSessionStore2(db),
|
|
25110
|
+
accessControlStore: new PostgresAccessControlStore2(db),
|
|
24502
25111
|
sessionMetricsStore: new PostgresSessionMetricsStore2(db),
|
|
24503
25112
|
mcpOAuthStore: mcpServerWithAuthStore,
|
|
24504
25113
|
tokenStore,
|
|
@@ -24536,6 +25145,7 @@ async function createServerRuntime(persistence, logger2) {
|
|
|
24536
25145
|
const {
|
|
24537
25146
|
withTransaction,
|
|
24538
25147
|
sessionStore,
|
|
25148
|
+
accessControlStore,
|
|
24539
25149
|
sessionMetricsStore,
|
|
24540
25150
|
tokenStore,
|
|
24541
25151
|
scheduleStore,
|
|
@@ -24560,6 +25170,7 @@ async function createServerRuntime(persistence, logger2) {
|
|
|
24560
25170
|
const oidcClient = await initOidc(oidc);
|
|
24561
25171
|
let authenticator;
|
|
24562
25172
|
let authorizer;
|
|
25173
|
+
let userStore;
|
|
24563
25174
|
const mode = getTrueForgeAuthMode2(configuration2);
|
|
24564
25175
|
if (mode === TrueForgeAuthMode2.TrueFoundry) {
|
|
24565
25176
|
if (serviceFoundryClient === void 0) {
|
|
@@ -24570,12 +25181,15 @@ async function createServerRuntime(persistence, logger2) {
|
|
|
24570
25181
|
serviceFoundryClient
|
|
24571
25182
|
});
|
|
24572
25183
|
authorizer = new TrueFoundryAuthorizer(serviceFoundryClient);
|
|
25184
|
+
userStore = new TrueFoundryUserStore(serviceFoundryClient);
|
|
24573
25185
|
} else if (mode === TrueForgeAuthMode2.Oidc) {
|
|
24574
25186
|
authenticator = createAuthenticator({ mode: TrueForgeAuthMode2.Oidc });
|
|
24575
25187
|
authorizer = new TrueForgeAuthorizer();
|
|
25188
|
+
userStore = new EmptyUserStore();
|
|
24576
25189
|
} else {
|
|
24577
25190
|
authenticator = createAuthenticator({ mode: TrueForgeAuthMode2.Standalone });
|
|
24578
25191
|
authorizer = new TrueForgeAuthorizer();
|
|
25192
|
+
userStore = new EmptyUserStore();
|
|
24579
25193
|
}
|
|
24580
25194
|
const controller = configuration2.STANDALONE ? createController({
|
|
24581
25195
|
scheduleStore,
|
|
@@ -24673,7 +25287,9 @@ async function createServerRuntime(persistence, logger2) {
|
|
|
24673
25287
|
sandboxEnvironmentStore,
|
|
24674
25288
|
sandboxProviderStore: persistence.sandboxProviderStore,
|
|
24675
25289
|
sessionStore,
|
|
25290
|
+
accessControlStore,
|
|
24676
25291
|
sessionMetricsStore,
|
|
25292
|
+
userStore,
|
|
24677
25293
|
sessions,
|
|
24678
25294
|
activeTurns,
|
|
24679
25295
|
redis: redis?.client,
|