@cursor/july 0.1.108 → 0.1.111
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/AGENTS.md +3 -7
- package/README.md +3 -21
- package/dist/bin/agent-serve.js +81 -66
- package/dist/channels/bitbucket/api.d.ts +41 -0
- package/dist/channels/bitbucket/api.d.ts.map +1 -1
- package/dist/channels/bitbucket/api.js +266 -6
- package/dist/channels/bitbucket/binding.d.ts +4 -0
- package/dist/channels/bitbucket/binding.d.ts.map +1 -1
- package/dist/channels/bitbucket/binding.js +20 -4
- package/dist/channels/bitbucket/bitbucket-channel.js +1 -1
- package/dist/channels/bitbucket/bitbucket-webhook.js +1 -1
- package/dist/channels/bitbucket/checks.d.ts.map +1 -1
- package/dist/channels/bitbucket/checks.js +1 -1
- package/dist/channels/bitbucket/cursor-account.js +1 -1
- package/dist/channels/bitbucket/events.js +1 -1
- package/dist/channels/bitbucket/index.d.ts +1 -1
- package/dist/channels/bitbucket/index.d.ts.map +1 -1
- package/dist/channels/bitbucket/index.js +1 -1
- package/dist/channels/change-monitors/change-monitors-channel.js +1 -1
- package/dist/channels/checks.d.ts.map +1 -1
- package/dist/channels/checks.js +2 -2
- package/dist/channels/deployments/deployments-channel.js +1 -1
- package/dist/channels/github/cursor-account.js +3 -3
- package/dist/channels/github/defaults.d.ts.map +1 -1
- package/dist/channels/github/defaults.js +5 -3
- package/dist/channels/github/events.js +1 -1
- package/dist/channels/github/forward.js +8 -8
- package/dist/channels/github/github-channel.d.ts.map +1 -1
- package/dist/channels/github/github-channel.js +17 -13
- package/dist/channels/github/progress.d.ts.map +1 -1
- package/dist/channels/github/progress.js +7 -2
- package/dist/channels/github/state.d.ts +6 -0
- package/dist/channels/github/state.d.ts.map +1 -1
- package/dist/channels/github/types.d.ts +6 -0
- package/dist/channels/github/types.d.ts.map +1 -1
- package/dist/channels/gitlab/api.d.ts +27 -0
- package/dist/channels/gitlab/api.d.ts.map +1 -1
- package/dist/channels/gitlab/api.js +88 -0
- package/dist/channels/gitlab/binding.d.ts +5 -0
- package/dist/channels/gitlab/binding.d.ts.map +1 -1
- package/dist/channels/gitlab/binding.js +14 -4
- package/dist/channels/gitlab/checks.d.ts.map +1 -1
- package/dist/channels/gitlab/checks.js +1 -1
- package/dist/channels/gitlab/cursor-account.js +1 -1
- package/dist/channels/gitlab/events.js +1 -1
- package/dist/channels/gitlab/gitlab-channel.js +1 -1
- package/dist/channels/gitlab/gitlab-webhook.js +1 -1
- package/dist/channels/gitlab/index.d.ts +1 -1
- package/dist/channels/gitlab/index.d.ts.map +1 -1
- package/dist/channels/gitlab/index.js +1 -1
- package/dist/channels/gitlab/replay.js +2 -2
- package/dist/channels/origin/binding.d.ts +2 -0
- package/dist/channels/origin/binding.d.ts.map +1 -1
- package/dist/channels/origin/binding.js +3 -3
- package/dist/channels/origin/checks.d.ts +19 -7
- package/dist/channels/origin/checks.d.ts.map +1 -1
- package/dist/channels/origin/checks.js +13 -9
- package/dist/channels/origin/cursor-account.js +1 -1
- package/dist/channels/origin/defaults.d.ts.map +1 -1
- package/dist/channels/origin/defaults.js +3 -1
- package/dist/channels/origin/events.js +1 -1
- package/dist/channels/origin/origin-channel.d.ts.map +1 -1
- package/dist/channels/origin/origin-channel.js +2 -1
- package/dist/channels/origin/origin-webhook.js +2 -2
- package/dist/channels/slack/agentic-delivery.d.ts +23 -0
- package/dist/channels/slack/agentic-delivery.d.ts.map +1 -0
- package/dist/channels/slack/agentic-delivery.js +558 -0
- package/dist/channels/slack/agentic-posted.d.ts +30 -0
- package/dist/channels/slack/agentic-posted.d.ts.map +1 -0
- package/dist/channels/slack/agentic-posted.js +102 -0
- package/dist/channels/slack/agentic-signals.d.ts +48 -0
- package/dist/channels/slack/agentic-signals.d.ts.map +1 -0
- package/dist/channels/slack/agentic-signals.js +204 -0
- package/dist/channels/slack/api.d.ts +20 -1
- package/dist/channels/slack/api.d.ts.map +1 -1
- package/dist/channels/slack/api.js +43 -11
- package/dist/channels/slack/approvals.js +1 -1
- package/dist/channels/slack/auth.d.ts.map +1 -1
- package/dist/channels/slack/auth.js +3 -1
- package/dist/channels/slack/blocks.js +3 -3
- package/dist/channels/slack/bot-mentions.d.ts.map +1 -1
- package/dist/channels/slack/bot-mentions.js +5 -5
- package/dist/channels/slack/channel-watch.js +1 -1
- package/dist/channels/slack/cli-project.js +3 -3
- package/dist/channels/slack/defaults.d.ts +3 -0
- package/dist/channels/slack/defaults.d.ts.map +1 -1
- package/dist/channels/slack/defaults.js +90 -29
- package/dist/channels/slack/dispatch.d.ts +44 -1
- package/dist/channels/slack/dispatch.d.ts.map +1 -1
- package/dist/channels/slack/dispatch.js +233 -103
- package/dist/channels/slack/doctor.js +1 -1
- package/dist/channels/slack/eval-directive.js +1 -1
- package/dist/channels/slack/external-policy.d.ts +2 -1
- package/dist/channels/slack/external-policy.d.ts.map +1 -1
- package/dist/channels/slack/external-policy.js +13 -2
- package/dist/channels/slack/footer.d.ts +30 -0
- package/dist/channels/slack/footer.d.ts.map +1 -0
- package/dist/channels/slack/footer.js +88 -0
- package/dist/channels/slack/index.d.ts +2 -0
- package/dist/channels/slack/index.d.ts.map +1 -1
- package/dist/channels/slack/index.js +2 -0
- package/dist/channels/slack/interactive.d.ts.map +1 -1
- package/dist/channels/slack/interactive.js +5 -3
- package/dist/channels/slack/live-delivery.d.ts +1 -1
- package/dist/channels/slack/live-delivery.d.ts.map +1 -1
- package/dist/channels/slack/live-delivery.js +20 -6
- package/dist/channels/slack/log.d.ts.map +1 -1
- package/dist/channels/slack/log.js +1 -1
- package/dist/channels/slack/manifest.js +1 -1
- package/dist/channels/slack/nudge-carrier.js +1 -1
- package/dist/channels/slack/nudge-store.js +2 -2
- package/dist/channels/slack/paint-start.d.ts +22 -0
- package/dist/channels/slack/paint-start.d.ts.map +1 -0
- package/dist/channels/slack/paint-start.js +91 -0
- package/dist/channels/slack/placeholder.d.ts +36 -0
- package/dist/channels/slack/placeholder.d.ts.map +1 -0
- package/dist/channels/slack/placeholder.js +240 -0
- package/dist/channels/slack/progress-delivery.d.ts.map +1 -1
- package/dist/channels/slack/progress-delivery.js +13 -4
- package/dist/channels/slack/reasoning-chip.d.ts +8 -0
- package/dist/channels/slack/reasoning-chip.d.ts.map +1 -0
- package/dist/channels/slack/reasoning-chip.js +30 -0
- package/dist/channels/slack/recording-sink.d.ts +29 -0
- package/dist/channels/slack/recording-sink.d.ts.map +1 -0
- package/dist/channels/slack/recording-sink.js +142 -0
- package/dist/channels/slack/reply-options.d.ts +8 -1
- package/dist/channels/slack/reply-options.d.ts.map +1 -1
- package/dist/channels/slack/reply-options.js +59 -14
- package/dist/channels/slack/setup.js +1 -1
- package/dist/channels/slack/slack-channel.d.ts +12 -5
- package/dist/channels/slack/slack-channel.d.ts.map +1 -1
- package/dist/channels/slack/slack-channel.js +110 -24
- package/dist/channels/slack/socket-mode.js +2 -2
- package/dist/channels/slack/thread-context.js +5 -5
- package/dist/channels/slack/tool-approval-events.d.ts +5 -0
- package/dist/channels/slack/tool-approval-events.d.ts.map +1 -1
- package/dist/channels/slack/tool-approval-events.js +50 -38
- package/dist/channels/slack/tool-cards.js +1 -1
- package/dist/channels/slack/tool-chip.d.ts +9 -0
- package/dist/channels/slack/tool-chip.d.ts.map +1 -0
- package/dist/channels/slack/tool-chip.js +25 -0
- package/dist/channels/slack/types.d.ts +49 -7
- package/dist/channels/slack/types.d.ts.map +1 -1
- package/dist/channels/slack/upload.d.ts +13 -0
- package/dist/channels/slack/upload.d.ts.map +1 -0
- package/dist/channels/slack/upload.js +135 -0
- package/dist/channels.d.ts +10 -14
- package/dist/channels.d.ts.map +1 -1
- package/dist/channels.js +9 -21
- package/dist/dashboard-session-url.d.ts +15 -0
- package/dist/dashboard-session-url.d.ts.map +1 -0
- package/dist/dashboard-session-url.js +25 -0
- package/dist/docs/404.html +3 -3
- package/dist/docs/architecture.svg +59 -0
- package/dist/docs/assets/app.Drol6mi6.js +309 -0
- package/dist/docs/assets/{building-with-agents.md.CUSWxlP_.js → building-with-agents.md.CEGVXkmO.js} +2 -2
- package/dist/docs/assets/{building-with-agents.md.CUSWxlP_.lean.js → building-with-agents.md.CEGVXkmO.lean.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.DtXk1hy-.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.BOKxlYGP.js → VPLocalSearchBox.CdqoBZJX.js} +2 -2
- package/dist/docs/assets/chunks/arc.BVX3ycTn.js +1 -0
- package/dist/docs/assets/chunks/architectureDiagram-Q4EWVU46.CcChnMxX.js +36 -0
- package/dist/docs/assets/chunks/baseUniq.xwtXO-yt.js +1 -0
- package/dist/docs/assets/chunks/blockDiagram-DXYQGD6D.CijZ_taK.js +132 -0
- package/dist/docs/assets/chunks/c4Diagram-AHTNJAMY.0FBvwBvK.js +10 -0
- package/dist/docs/assets/chunks/channel.Bkv1N-gK.js +1 -0
- package/dist/docs/assets/chunks/chunk-4BX2VUAB.CELMmMDA.js +1 -0
- package/dist/docs/assets/chunks/chunk-4TB4RGXK.C4bhFtSm.js +206 -0
- package/dist/docs/assets/chunks/chunk-55IACEB6.ZnQ9gRRQ.js +1 -0
- package/dist/docs/assets/chunks/chunk-EDXVE4YY.DPlmglG-.js +1 -0
- package/dist/docs/assets/chunks/chunk-FMBD7UC4.BrUk8pff.js +15 -0
- package/dist/docs/assets/chunks/chunk-OYMX7WX6.CcmWIncu.js +231 -0
- package/dist/docs/assets/chunks/chunk-QZHKN3VN.D65-cs8I.js +1 -0
- package/dist/docs/assets/chunks/chunk-YZCP3GAM.qoXZpG9F.js +1 -0
- package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.CZDco1o8.js +1 -0
- package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.CZDco1o8.js +1 -0
- package/dist/docs/assets/chunks/clone.YSt_40_s.js +1 -0
- package/dist/docs/assets/chunks/cose-bilkent-S5V4N54A.8rYtqudO.js +1 -0
- package/dist/docs/assets/chunks/cytoscape.esm.BQk4lpUV.js +331 -0
- package/dist/docs/assets/chunks/dagre-KV5264BT.DrRP1fOh.js +4 -0
- package/dist/docs/assets/chunks/defaultLocale.C4B-KCzX.js +1 -0
- package/dist/docs/assets/chunks/diagram-5BDNPKRD.DHj_xA2_.js +10 -0
- package/dist/docs/assets/chunks/diagram-G4DWMVQ6.Bz_6nAKj.js +24 -0
- package/dist/docs/assets/chunks/diagram-MMDJMWI5.BWA0xSW9.js +43 -0
- package/dist/docs/assets/chunks/diagram-TYMM5635.CpTJLNJI.js +24 -0
- package/dist/docs/assets/chunks/erDiagram-SMLLAGMA.-7AWWSrP.js +85 -0
- package/dist/docs/assets/chunks/flowDiagram-DWJPFMVM.BTnQ742_.js +162 -0
- package/dist/docs/assets/chunks/framework.dypDpWZ3.js +19 -0
- package/dist/docs/assets/chunks/ganttDiagram-T4ZO3ILL.B5_HiiQ5.js +292 -0
- package/dist/docs/assets/chunks/gitGraphDiagram-UUTBAWPF.CZcNTFZd.js +106 -0
- package/dist/docs/assets/chunks/graph.V2GLaab4.js +1 -0
- package/dist/docs/assets/chunks/infoDiagram-42DDH7IO.7pZOkCCU.js +2 -0
- package/dist/docs/assets/chunks/init.Gi6I4Gst.js +1 -0
- package/dist/docs/assets/chunks/ishikawaDiagram-UXIWVN3A.DSMo3Qa3.js +70 -0
- package/dist/docs/assets/chunks/journeyDiagram-VCZTEJTY.BNEgWN1S.js +139 -0
- package/dist/docs/assets/chunks/kanban-definition-6JOO6SKY.B-4d4tC7.js +89 -0
- package/dist/docs/assets/chunks/katex.DkKDou_j.js +257 -0
- package/dist/docs/assets/chunks/layout.Dvbn9nSb.js +1 -0
- package/dist/docs/assets/chunks/linear.D2GM4p4b.js +1 -0
- package/dist/docs/assets/chunks/min.DVBtLK-B.js +1 -0
- package/dist/docs/assets/chunks/mindmap-definition-QFDTVHPH.CnJRI55x.js +96 -0
- package/dist/docs/assets/chunks/ordinal.DBvzRdQf.js +1 -0
- package/dist/docs/assets/chunks/pieDiagram-DEJITSTG.CtoaTFlA.js +30 -0
- package/dist/docs/assets/chunks/quadrantDiagram-34T5L4WZ.DtT24_vN.js +7 -0
- package/dist/docs/assets/chunks/requirementDiagram-MS252O5E.CjSO4o8f.js +84 -0
- package/dist/docs/assets/chunks/sankeyDiagram-XADWPNL6.-wWiIVWa.js +10 -0
- package/dist/docs/assets/chunks/sequenceDiagram-FGHM5R23.DSk8s4gX.js +157 -0
- package/dist/docs/assets/chunks/stateDiagram-FHFEXIEX.BFKAsdkN.js +1 -0
- package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.C4CLm481.js +1 -0
- package/dist/docs/assets/chunks/{theme.DbDZW-zb.js → theme.C0MctGaz.js} +2 -2
- package/dist/docs/assets/chunks/timeline-definition-GMOUNBTQ.TUNJbAFe.js +120 -0
- package/dist/docs/assets/chunks/vennDiagram-DHZGUBPP.C-RGNnk4.js +34 -0
- package/dist/docs/assets/chunks/virtual_mermaid-config.DDnGl6nM.js +1 -0
- package/dist/docs/assets/chunks/wardley-RL74JXVD.g5efOWmT.js +162 -0
- package/dist/docs/assets/chunks/wardleyDiagram-NUSXRM2D.DH4zt73Y.js +20 -0
- package/dist/docs/assets/chunks/xychartDiagram-5P7HB3ND.B-3k6bF6.js +7 -0
- package/dist/docs/assets/{deployment.md.JenwuCCB.js → deployment.md.Dm4Qo3hp.js} +5 -5
- package/dist/docs/assets/{deployment.md.JenwuCCB.lean.js → deployment.md.Dm4Qo3hp.lean.js} +1 -1
- package/dist/docs/assets/evals.md.BLDRt5LH.js +211 -0
- package/dist/docs/assets/evals.md.BLDRt5LH.lean.js +1 -0
- package/dist/docs/assets/guides_agent-to-agent.md.BI0xclmy.js +14 -0
- package/dist/docs/assets/guides_agent-to-agent.md.BI0xclmy.lean.js +1 -0
- package/dist/docs/assets/guides_bitbucket.md.CTpCl__f.js +10 -0
- package/dist/docs/assets/guides_bitbucket.md.CTpCl__f.lean.js +1 -0
- package/dist/docs/assets/{guides_cloud-agents.md.BsloyHdY.js → guides_cloud-agents.md.lSE_l7lH.js} +2 -2
- package/dist/docs/assets/{guides_cloud-agents.md.BsloyHdY.lean.js → guides_cloud-agents.md.lSE_l7lH.lean.js} +1 -1
- package/dist/docs/assets/{guides_convert-automation.md.B4sjlodG.js → guides_convert-automation.md.Ck6Cr68A.js} +1 -1
- package/dist/docs/assets/{guides_convert-automation.md.B4sjlodG.lean.js → guides_convert-automation.md.Ck6Cr68A.lean.js} +1 -1
- package/dist/docs/assets/{guides_github.md.BH33UEBJ.js → guides_github.md.D6ER29dG.js} +13 -3
- package/dist/docs/assets/{guides_github.md.BH33UEBJ.lean.js → guides_github.md.D6ER29dG.lean.js} +1 -1
- package/dist/docs/assets/guides_gitlab.md.P-TjBnS5.js +14 -0
- package/dist/docs/assets/guides_gitlab.md.P-TjBnS5.lean.js +1 -0
- package/dist/docs/assets/guides_grokbot-agents.md.WBZIOvkz.js +9 -0
- package/dist/docs/assets/{guides_grokbot-agents.md.DyV-WArv.lean.js → guides_grokbot-agents.md.WBZIOvkz.lean.js} +1 -1
- package/dist/docs/assets/{guides_improve.md.BGVk32bK.js → guides_improve.md.BKaDuKKK.js} +1 -1
- package/dist/docs/assets/{guides_improve.md.BGVk32bK.lean.js → guides_improve.md.BKaDuKKK.lean.js} +1 -1
- package/dist/docs/assets/{guides_mcp-oauth.md.Dp6cDP7f.js → guides_mcp-oauth.md.DMNMpXtO.js} +1 -1
- package/dist/docs/assets/{guides_mcp-oauth.md.Dp6cDP7f.lean.js → guides_mcp-oauth.md.DMNMpXtO.lean.js} +1 -1
- package/dist/docs/assets/{guides_opentelemetry.md.SCRMskno.js → guides_opentelemetry.md._CRfDyzH.js} +14 -14
- package/dist/docs/assets/{guides_opentelemetry.md.SCRMskno.lean.js → guides_opentelemetry.md._CRfDyzH.lean.js} +1 -1
- package/dist/docs/assets/{guides_slack.md.D4RVMM4G.js → guides_slack.md.DdT8rmsj.js} +12 -4
- package/dist/docs/assets/{guides_slack.md.D4RVMM4G.lean.js → guides_slack.md.DdT8rmsj.lean.js} +1 -1
- package/dist/docs/assets/{guides_webhooks.md.DKdA43Qm.js → guides_webhooks.md.aQW10HRe.js} +3 -3
- package/dist/docs/assets/{guides_webhooks.md.DKdA43Qm.lean.js → guides_webhooks.md.aQW10HRe.lean.js} +1 -1
- package/dist/docs/assets/hillclimbing.md.Dq4kkVIL.js +1 -0
- package/dist/docs/assets/hillclimbing.md.Dq4kkVIL.lean.js +1 -0
- package/dist/docs/assets/index.md.BFVyY2KT.js +17 -0
- package/dist/docs/assets/index.md.BFVyY2KT.lean.js +1 -0
- package/dist/docs/assets/{quickstart.md.DdQOF7Y8.js → quickstart.md.D3MjSZN-.js} +30 -38
- package/dist/docs/assets/quickstart.md.D3MjSZN-.lean.js +1 -0
- package/dist/docs/assets/{reference_agent-config.md.CvoL6pof.js → reference_agent-config.md.CfVA-LZJ.js} +1 -1
- package/dist/docs/assets/{reference_agent-config.md.CvoL6pof.lean.js → reference_agent-config.md.CfVA-LZJ.lean.js} +1 -1
- package/dist/docs/assets/{reference_artifacts.md.Dior32Qw.js → reference_artifacts.md.Vf7qyIZ-.js} +1 -1
- package/dist/docs/assets/{reference_artifacts.md.Dior32Qw.lean.js → reference_artifacts.md.Vf7qyIZ-.lean.js} +1 -1
- package/dist/docs/assets/{reference_channels.md.D-qTqwcq.js → reference_channels.md.icqLKcTc.js} +2 -12
- package/dist/docs/assets/{reference_channels.md.D-qTqwcq.lean.js → reference_channels.md.icqLKcTc.lean.js} +1 -1
- package/dist/docs/assets/{reference_cli.md.Ca26u0Es.js → reference_cli.md.B2dBL6L8.js} +4 -4
- package/dist/docs/assets/{reference_cli.md.Ca26u0Es.lean.js → reference_cli.md.B2dBL6L8.lean.js} +1 -1
- package/dist/docs/assets/{reference_connections.md.BojkC6c5.js → reference_connections.md.Cb3U_c8n.js} +4 -4
- package/dist/docs/assets/{reference_connections.md.BojkC6c5.lean.js → reference_connections.md.Cb3U_c8n.lean.js} +1 -1
- package/dist/docs/assets/{reference_extensions.md.CPWt00ds.js → reference_extensions.md.wlFD3cUR.js} +3 -3
- package/dist/docs/assets/{reference_extensions.md.CPWt00ds.lean.js → reference_extensions.md.wlFD3cUR.lean.js} +1 -1
- package/dist/docs/assets/{reference_hooks.md.Ddt5DdgJ.js → reference_hooks.md.CZuynAxj.js} +3 -3
- package/dist/docs/assets/{reference_hooks.md.Ddt5DdgJ.lean.js → reference_hooks.md.CZuynAxj.lean.js} +1 -1
- package/dist/docs/assets/{reference_http-api.md.oySXBO8o.js → reference_http-api.md.DTKcYE6L.js} +3 -3
- package/dist/docs/assets/{reference_http-api.md.oySXBO8o.lean.js → reference_http-api.md.DTKcYE6L.lean.js} +1 -1
- package/dist/docs/assets/{reference_instructions.md.CR7XSsGk.js → reference_instructions.md.D7gkckK-.js} +1 -1
- package/dist/docs/assets/{reference_instructions.md.CR7XSsGk.lean.js → reference_instructions.md.D7gkckK-.lean.js} +1 -1
- package/dist/docs/assets/{reference_playground.md.4myJPxrf.js → reference_playground.md.D2YExv5K.js} +1 -1
- package/dist/docs/assets/{reference_playground.md.4myJPxrf.lean.js → reference_playground.md.D2YExv5K.lean.js} +1 -1
- package/dist/docs/assets/reference_project-layout.md.DPxbUJyt.js +19 -0
- package/dist/docs/assets/{reference_project-layout.md.DuBu9a96.lean.js → reference_project-layout.md.DPxbUJyt.lean.js} +1 -1
- package/dist/docs/assets/{reference_prompt.md.DnaD5dNK.js → reference_prompt.md.BQ5uAv1F.js} +1 -1
- package/dist/docs/assets/{reference_prompt.md.DnaD5dNK.lean.js → reference_prompt.md.BQ5uAv1F.lean.js} +1 -1
- package/dist/docs/assets/{reference_schedules.md.DI_JrHgq.js → reference_schedules.md.BasfZWO-.js} +1 -1
- package/dist/docs/assets/{reference_schedules.md.DI_JrHgq.lean.js → reference_schedules.md.BasfZWO-.lean.js} +1 -1
- package/dist/docs/assets/reference_sessions.md.YKvIsWAx.js +1 -0
- package/dist/docs/assets/{reference_sessions.md.CueyOHSL.lean.js → reference_sessions.md.YKvIsWAx.lean.js} +1 -1
- package/dist/docs/assets/{reference_skills.md.l2ezAcaN.js → reference_skills.md.rNgpsGd0.js} +1 -1
- package/dist/docs/assets/{reference_skills.md.l2ezAcaN.lean.js → reference_skills.md.rNgpsGd0.lean.js} +1 -1
- package/dist/docs/assets/{reference_subagents.md.CfsIloPm.js → reference_subagents.md.e5qitjJt.js} +2 -2
- package/dist/docs/assets/{reference_subagents.md.CfsIloPm.lean.js → reference_subagents.md.e5qitjJt.lean.js} +1 -1
- package/dist/docs/assets/{reference_tools.md.aGrn99hP.js → reference_tools.md.BdCO2aHZ.js} +4 -4
- package/dist/docs/assets/{reference_tools.md.aGrn99hP.lean.js → reference_tools.md.BdCO2aHZ.lean.js} +1 -1
- package/dist/docs/assets/{style.DCD_zyg3.css → style.Cfo2vbik.css} +1 -1
- package/dist/docs/assets/{templates_agentic-owners.md.BZSH4N9z.js → templates_agentic-owners.md.Da_AGDlH.js} +1 -1
- package/dist/docs/assets/{templates_agentic-owners.md.BZSH4N9z.lean.js → templates_agentic-owners.md.Da_AGDlH.lean.js} +1 -1
- package/dist/docs/assets/{templates_pr-autofixer.md.Bds_XWcV.js → templates_pr-autofixer.md.DqxocIGh.js} +1 -1
- package/dist/docs/assets/{templates_pr-autofixer.md.Bds_XWcV.lean.js → templates_pr-autofixer.md.DqxocIGh.lean.js} +1 -1
- package/dist/docs/assets/{templates_security-reviewer.md.lshxbCLK.js → templates_security-reviewer.md.Bhnvd8VE.js} +1 -1
- package/dist/docs/assets/{templates_security-reviewer.md.lshxbCLK.lean.js → templates_security-reviewer.md.Bhnvd8VE.lean.js} +1 -1
- package/dist/docs/assets/{templates_triage.md.Co4UNzkZ.js → templates_triage.md.BdBWO9Ic.js} +1 -1
- package/dist/docs/assets/{templates_triage.md.Co4UNzkZ.lean.js → templates_triage.md.BdBWO9Ic.lean.js} +1 -1
- package/dist/docs/assets/{troubleshooting.md.CYEAO9bM.js → troubleshooting.md.BcgNoYtJ.js} +1 -1
- package/dist/docs/assets/{troubleshooting.md.CYEAO9bM.lean.js → troubleshooting.md.BcgNoYtJ.lean.js} +1 -1
- package/dist/docs/building-with-agents.html +41 -8
- package/dist/docs/building-with-agents.md +15 -16
- package/dist/docs/deployment.html +44 -11
- package/dist/docs/deployment.md +6 -7
- package/dist/docs/evals.html +196 -37
- package/dist/docs/evals.md +612 -297
- package/dist/docs/guides/agent-to-agent.html +48 -11
- package/dist/docs/guides/agent-to-agent.md +40 -83
- package/dist/docs/guides/bitbucket.html +69 -0
- package/dist/docs/guides/bitbucket.md +84 -0
- package/dist/docs/guides/cloud-agents.html +41 -8
- package/dist/docs/guides/cloud-agents.md +24 -20
- package/dist/docs/guides/convert-automation.html +41 -8
- package/dist/docs/guides/github.html +52 -9
- package/dist/docs/guides/github.md +32 -1
- package/dist/docs/guides/gitlab.html +73 -0
- package/dist/docs/guides/gitlab.md +92 -0
- package/dist/docs/guides/grokbot-agents.html +41 -8
- package/dist/docs/guides/grokbot-agents.md +26 -19
- package/dist/docs/guides/improve.html +41 -8
- package/dist/docs/guides/mcp-oauth.html +41 -8
- package/dist/docs/guides/mcp-oauth.md +1 -1
- package/dist/docs/guides/opentelemetry.html +53 -20
- package/dist/docs/guides/opentelemetry.md +28 -41
- package/dist/docs/guides/slack.html +51 -10
- package/dist/docs/guides/slack.md +53 -4
- package/dist/docs/guides/webhooks.html +42 -9
- package/dist/docs/guides/webhooks.md +7 -6
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +40 -10
- package/dist/docs/hillclimbing.md +7 -7
- package/dist/docs/index.html +57 -12
- package/dist/docs/index.md +81 -146
- package/dist/docs/llms-full.txt +1368 -5551
- package/dist/docs/llms.txt +6 -31
- package/dist/docs/quickstart.html +70 -45
- package/dist/docs/quickstart.md +44 -105
- package/dist/docs/reference/agent-config.html +41 -8
- package/dist/docs/reference/artifacts.html +41 -8
- package/dist/docs/reference/channels.html +41 -18
- package/dist/docs/reference/channels.md +16 -19
- package/dist/docs/reference/cli.html +43 -10
- package/dist/docs/reference/cli.md +6 -20
- package/dist/docs/reference/connections.html +43 -10
- package/dist/docs/reference/connections.md +3 -5
- package/dist/docs/reference/extensions.html +43 -10
- package/dist/docs/reference/extensions.md +2 -5
- package/dist/docs/reference/hooks.html +42 -9
- package/dist/docs/reference/hooks.md +11 -16
- package/dist/docs/reference/http-api.html +42 -9
- package/dist/docs/reference/http-api.md +6 -7
- package/dist/docs/reference/instructions.html +41 -8
- package/dist/docs/reference/playground.html +40 -7
- package/dist/docs/reference/playground.md +2 -6
- package/dist/docs/reference/project-layout.html +42 -9
- package/dist/docs/reference/project-layout.md +4 -12
- package/dist/docs/reference/prompt.html +41 -8
- package/dist/docs/reference/schedules.html +41 -8
- package/dist/docs/reference/sessions.html +40 -7
- package/dist/docs/reference/sessions.md +6 -6
- package/dist/docs/reference/skills.html +41 -8
- package/dist/docs/reference/subagents.html +41 -8
- package/dist/docs/reference/subagents.md +2 -4
- package/dist/docs/reference/tools.html +43 -10
- package/dist/docs/reference/tools.md +2 -5
- package/dist/docs/templates/agentic-owners.html +41 -8
- package/dist/docs/templates/pr-autofixer.html +41 -8
- package/dist/docs/templates/security-reviewer.html +41 -8
- package/dist/docs/templates/triage.html +41 -8
- package/dist/docs/troubleshooting.html +40 -7
- package/dist/docs/troubleshooting.md +1 -2
- package/dist/evals/assertions.js +19 -19
- package/dist/evals/expect.js +1 -1
- package/dist/evals/judge.js +1 -1
- package/dist/evals/reporters.d.ts.map +1 -1
- package/dist/evals/reporters.js +8 -8
- package/dist/evals/run-facts.js +2 -2
- package/dist/evals.d.ts +1 -1
- package/dist/evals.d.ts.map +1 -1
- package/dist/evals.js +7 -7
- package/dist/extensions/cursor-cloud-agents/extension.js +1 -1
- package/dist/extensions/cursor-cloud-agents/lib/backend.js +3 -3
- package/dist/extensions/cursor-cloud-agents/lib/fleet.js +1 -1
- package/dist/extensions/cursor-cloud-agents/lib/repos.js +6 -6
- package/dist/extensions/cursor-cloud-agents/lib/transcript.d.ts.map +1 -1
- package/dist/extensions/cursor-cloud-agents/lib/transcript.js +2 -2
- package/dist/extensions/cursor-cloud-agents/tools/list.js +1 -1
- package/dist/extensions/improve/skills/yourself.js +1 -1
- package/dist/extensions/slack-communication/extension.d.ts +28 -0
- package/dist/extensions/slack-communication/extension.d.ts.map +1 -0
- package/dist/extensions/slack-communication/extension.js +32 -0
- package/dist/extensions/slack-communication/skills/slack-voice.d.ts +5 -0
- package/dist/extensions/slack-communication/skills/slack-voice.d.ts.map +1 -0
- package/dist/extensions/slack-communication/skills/slack-voice.js +54 -0
- package/dist/extensions/slack-communication/tools/delete-message.d.ts +4 -0
- package/dist/extensions/slack-communication/tools/delete-message.d.ts.map +1 -0
- package/dist/extensions/slack-communication/tools/delete-message.js +29 -0
- package/dist/extensions/slack-communication/tools/edit-message.d.ts +4 -0
- package/dist/extensions/slack-communication/tools/edit-message.d.ts.map +1 -0
- package/dist/extensions/slack-communication/tools/edit-message.js +37 -0
- package/dist/extensions/slack-communication/tools/post-card.d.ts +4 -0
- package/dist/extensions/slack-communication/tools/post-card.d.ts.map +1 -0
- package/dist/extensions/slack-communication/tools/post-card.js +25 -0
- package/dist/extensions/slack-communication/tools/post-file.d.ts +4 -0
- package/dist/extensions/slack-communication/tools/post-file.d.ts.map +1 -0
- package/dist/extensions/slack-communication/tools/post-file.js +76 -0
- package/dist/extensions/slack-communication/tools/post-update.d.ts +4 -0
- package/dist/extensions/slack-communication/tools/post-update.d.ts.map +1 -0
- package/dist/extensions/slack-communication/tools/post-update.js +36 -0
- package/dist/extensions/slack-communication/tools/react.d.ts +4 -0
- package/dist/extensions/slack-communication/tools/react.d.ts.map +1 -0
- package/dist/extensions/slack-communication/tools/react.js +27 -0
- package/dist/extensions/slack-communication/tools/set-status.d.ts +4 -0
- package/dist/extensions/slack-communication/tools/set-status.d.ts.map +1 -0
- package/dist/extensions/slack-communication/tools/set-status.js +18 -0
- package/dist/extensions.d.ts +2 -3
- package/dist/extensions.d.ts.map +1 -1
- package/dist/extensions.js +2 -5
- package/dist/files-backends/cursor-hosted.d.ts +18 -6
- package/dist/files-backends/cursor-hosted.d.ts.map +1 -1
- package/dist/files-backends/cursor-hosted.js +357 -74
- package/dist/files-backends/local-fs.js +1 -1
- package/dist/files.d.ts +15 -0
- package/dist/files.d.ts.map +1 -1
- package/dist/filesystem.d.ts.map +1 -1
- package/dist/filesystem.js +15 -15
- package/dist/index.d.ts +6 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -8
- package/dist/internal/advertise-tools.js +6 -6
- package/dist/internal/approval-gate.js +1 -1
- package/dist/internal/artifacts-store.js +3 -3
- package/dist/internal/as-of.js +2 -2
- package/dist/internal/authored-alias-hooks.d.ts +5 -0
- package/dist/internal/authored-alias-hooks.d.ts.map +1 -1
- package/dist/internal/authored-alias-hooks.js +17 -0
- package/dist/internal/authored-loaders.d.ts +4 -0
- package/dist/internal/authored-loaders.d.ts.map +1 -1
- package/dist/internal/authored-loaders.js +21 -2
- package/dist/internal/builtin-tools/reminders.js +2 -2
- package/dist/internal/chat-client.js +5 -5
- package/dist/internal/cli-ax.d.ts +2 -2
- package/dist/internal/cli-ax.d.ts.map +1 -1
- package/dist/internal/cli-ax.js +69 -15
- package/dist/internal/cli-bitbucket.js +10 -10
- package/dist/internal/cli-convert-automation.js +2 -2
- package/dist/internal/cli-cursor.d.ts +3 -11
- package/dist/internal/cli-cursor.d.ts.map +1 -1
- package/dist/internal/cli-cursor.js +5 -10
- package/dist/internal/cli-deploy.d.ts +12 -2
- package/dist/internal/cli-deploy.d.ts.map +1 -1
- package/dist/internal/cli-deploy.js +328 -96
- package/dist/internal/cli-docs.js +5 -5
- package/dist/internal/cli-github.js +15 -16
- package/dist/internal/cli-gitlab.js +10 -10
- package/dist/internal/cli-manifest.js +1 -1
- package/dist/internal/cli-mcp-oauth.d.ts.map +1 -1
- package/dist/internal/cli-mcp-oauth.js +5 -5
- package/dist/internal/cli-mcp.js +3 -3
- package/dist/internal/cli-skills.js +2 -2
- package/dist/internal/cli-slack.js +5 -5
- package/dist/internal/cloud-turn-cost.js +1 -1
- package/dist/internal/continuation-channel.d.ts.map +1 -1
- package/dist/internal/continuation-channel.js +2 -2
- package/dist/internal/continuation-identity.d.ts.map +1 -1
- package/dist/internal/continuation-identity.js +22 -12
- package/dist/internal/conversation-mirror.d.ts.map +1 -1
- package/dist/internal/conversation-mirror.js +33 -2
- package/dist/internal/convert-automation/convert-workflow.js +25 -24
- package/dist/internal/convert-automation/types.d.ts +8 -0
- package/dist/internal/convert-automation/types.d.ts.map +1 -1
- package/dist/internal/cursor/account-mcp.d.ts +2 -2
- package/dist/internal/cursor/account-mcp.d.ts.map +1 -1
- package/dist/internal/cursor/account-mcp.js +32 -27
- package/dist/internal/cursor/backend-client.d.ts +15 -10
- package/dist/internal/cursor/backend-client.d.ts.map +1 -1
- package/dist/internal/cursor/backend-client.js +17 -11
- package/dist/internal/cursor/credentials.js +1 -1
- package/dist/internal/cursor/hosted-store-secrets.d.ts +16 -0
- package/dist/internal/cursor/hosted-store-secrets.d.ts.map +1 -1
- package/dist/internal/cursor/hosted-store-secrets.js +25 -0
- package/dist/internal/cursor-account-mcp-auth.js +9 -9
- package/dist/internal/cursor-deployment-relay.js +9 -9
- package/dist/internal/cursor-event-relay.js +10 -10
- package/dist/internal/cursor-relay-core.js +2 -2
- package/dist/internal/deploy-client.d.ts +106 -9
- package/dist/internal/deploy-client.d.ts.map +1 -1
- package/dist/internal/deploy-client.js +171 -23
- package/dist/internal/deploy-manifest.d.ts +13 -0
- package/dist/internal/deploy-manifest.d.ts.map +1 -1
- package/dist/internal/deploy-manifest.js +32 -16
- package/dist/internal/discovery/agent-config.d.ts +5 -0
- package/dist/internal/discovery/agent-config.d.ts.map +1 -1
- package/dist/internal/discovery/agent-config.js +27 -0
- package/dist/internal/discovery/agent.d.ts +1 -1
- package/dist/internal/discovery/agent.d.ts.map +1 -1
- package/dist/internal/discovery/agent.js +10 -13
- package/dist/internal/discovery/channels.js +4 -4
- package/dist/internal/discovery/connections.js +4 -4
- package/dist/internal/discovery/cursor-plugin.js +12 -12
- package/dist/internal/discovery/extension-overlay.d.ts +1 -2
- package/dist/internal/discovery/extension-overlay.d.ts.map +1 -1
- package/dist/internal/discovery/extension-overlay.js +3 -17
- package/dist/internal/discovery/extensions.d.ts +1 -2
- package/dist/internal/discovery/extensions.d.ts.map +1 -1
- package/dist/internal/discovery/extensions.js +10 -28
- package/dist/internal/discovery/info.d.ts.map +1 -1
- package/dist/internal/discovery/info.js +44 -26
- package/dist/internal/discovery/instructions.js +1 -1
- package/dist/internal/discovery/modules.js +0 -1
- package/dist/internal/discovery/project.d.ts.map +1 -1
- package/dist/internal/discovery/project.js +4 -20
- package/dist/internal/discovery/services.js +1 -1
- package/dist/internal/discovery/tools.js +1 -1
- package/dist/internal/docs-site.js +2 -2
- package/dist/internal/env-file.js +1 -1
- package/dist/internal/eval-run-store.d.ts.map +1 -1
- package/dist/internal/eval-run-store.js +7 -7
- package/dist/internal/eval-runner.js +14 -15
- package/dist/internal/evals-client.js +4 -4
- package/dist/internal/event-log.js +8 -8
- package/dist/internal/event-mapper.d.ts +18 -0
- package/dist/internal/event-mapper.d.ts.map +1 -1
- package/dist/internal/event-mapper.js +34 -2
- package/dist/internal/filesystem/format.d.ts.map +1 -1
- package/dist/internal/filesystem/format.js +6 -3
- package/dist/internal/filesystem/scratch.js +3 -3
- package/dist/internal/filesystem/tools.d.ts.map +1 -1
- package/dist/internal/filesystem/tools.js +6 -6
- package/dist/internal/filesystem/walk.js +1 -1
- package/dist/internal/framework-file-storage.d.ts +10 -7
- package/dist/internal/framework-file-storage.d.ts.map +1 -1
- package/dist/internal/framework-file-storage.js +95 -7
- package/dist/internal/framework-storage-selection.d.ts +2 -8
- package/dist/internal/framework-storage-selection.d.ts.map +1 -1
- package/dist/internal/framework-storage-selection.js +4 -13
- package/dist/internal/github-fanout.js +3 -3
- package/dist/internal/guest-network.js +4 -4
- package/dist/internal/host-files.js +1 -1
- package/dist/internal/host-kv.js +2 -2
- package/dist/internal/hosted-admission-adapter.d.ts +2 -0
- package/dist/internal/hosted-admission-adapter.d.ts.map +1 -1
- package/dist/internal/hosted-catch-protocol.d.ts.map +1 -1
- package/dist/internal/hosted-catch-protocol.js +2 -4
- package/dist/internal/hosted-catch.js +1 -1
- package/dist/internal/hosted-delivery-protocol.d.ts +29 -0
- package/dist/internal/hosted-delivery-protocol.d.ts.map +1 -1
- package/dist/internal/hosted-delivery-protocol.js +76 -8
- package/dist/internal/hosted-delivery.d.ts.map +1 -1
- package/dist/internal/hosted-delivery.js +201 -64
- package/dist/internal/hosted-execution-diag.js +3 -3
- package/dist/internal/hosted-execution-latency.d.ts +80 -0
- package/dist/internal/hosted-execution-latency.d.ts.map +1 -0
- package/dist/internal/hosted-execution-latency.js +220 -0
- package/dist/internal/hosting.d.ts +5 -5
- package/dist/internal/hosting.d.ts.map +1 -1
- package/dist/internal/hosting.js +5 -6
- package/dist/internal/http-channel-define.d.ts +11 -0
- package/dist/internal/http-channel-define.d.ts.map +1 -0
- package/dist/internal/http-channel-define.js +18 -0
- package/dist/internal/http-channel.d.ts +2 -3
- package/dist/internal/http-channel.d.ts.map +1 -1
- package/dist/internal/http-channel.js +3 -4
- package/dist/internal/http-control-plane-session.d.ts +7 -3
- package/dist/internal/http-control-plane-session.d.ts.map +1 -1
- package/dist/internal/http-control-plane-session.js +22 -10
- package/dist/internal/incoming-headers-to-fetch.d.ts +10 -0
- package/dist/internal/incoming-headers-to-fetch.d.ts.map +1 -0
- package/dist/internal/incoming-headers-to-fetch.js +41 -0
- package/dist/internal/init-interview.js +7 -7
- package/dist/internal/init-project.d.ts.map +1 -1
- package/dist/internal/init-project.js +14 -14
- package/dist/internal/init-scaffold.d.ts.map +1 -1
- package/dist/internal/init-scaffold.js +2 -3
- package/dist/internal/inline-stdio-mcp.js +2 -2
- package/dist/internal/install-cursor-skills.d.ts +5 -2
- package/dist/internal/install-cursor-skills.d.ts.map +1 -1
- package/dist/internal/install-cursor-skills.js +35 -15
- package/dist/internal/json-schema.js +1 -1
- package/dist/internal/local-control-plane.d.ts.map +1 -1
- package/dist/internal/local-control-plane.js +3 -3
- package/dist/internal/local-env.js +3 -3
- package/dist/internal/log-ring.js +1 -1
- package/dist/internal/logs-client.js +1 -1
- package/dist/internal/mcp-endpoint.js +8 -8
- package/dist/internal/mcp-host.js +4 -4
- package/dist/internal/mcp-oauth-on-demand.js +3 -3
- package/dist/internal/mcp-oauth.js +5 -5
- package/dist/internal/net.js +2 -2
- package/dist/internal/otel/config.js +3 -3
- package/dist/internal/otel/runtime.js +13 -13
- package/dist/internal/peer-connections.js +2 -2
- package/dist/internal/platform-schedule-sync.js +1 -1
- package/dist/internal/platform-timers.js +1 -1
- package/dist/internal/playground/static.js +2 -2
- package/dist/internal/playground/toolchain.js +2 -2
- package/dist/internal/playground-proxy.js +3 -3
- package/dist/internal/process-memory-telemetry.js +1 -1
- package/dist/internal/reminder-runner.d.ts.map +1 -1
- package/dist/internal/reminder-runner.js +7 -7
- package/dist/internal/reminder-store.js +1 -1
- package/dist/internal/request-error-status.d.ts.map +1 -1
- package/dist/internal/request-error-status.js +9 -0
- package/dist/internal/resolved-connections.js +8 -8
- package/dist/internal/result-output.d.ts +14 -2
- package/dist/internal/result-output.d.ts.map +1 -1
- package/dist/internal/result-output.js +45 -2
- package/dist/internal/router.js +4 -4
- package/dist/internal/run-client.d.ts +1 -1
- package/dist/internal/run-client.js +2 -2
- package/dist/internal/schedule-runner.js +6 -6
- package/dist/internal/scm/pr-url.d.ts +3 -1
- package/dist/internal/scm/pr-url.d.ts.map +1 -1
- package/dist/internal/scm/pr-url.js +10 -2
- package/dist/internal/sdk-runner.d.ts.map +1 -1
- package/dist/internal/sdk-runner.js +15 -16
- package/dist/internal/serve-restart.js +1 -1
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +81 -101
- package/dist/internal/session-cost.js +3 -3
- package/dist/internal/session-engine.d.ts +39 -35
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +394 -343
- package/dist/internal/session-run-log.d.ts.map +1 -1
- package/dist/internal/session-run-log.js +4 -4
- package/dist/internal/session-store.d.ts +47 -3
- package/dist/internal/session-store.d.ts.map +1 -1
- package/dist/internal/session-store.js +198 -33
- package/dist/internal/sessions-client.js +3 -3
- package/dist/internal/slack-thread-key.d.ts +7 -0
- package/dist/internal/slack-thread-key.d.ts.map +1 -0
- package/dist/internal/slack-thread-key.js +10 -0
- package/dist/internal/sleep.js +1 -1
- package/dist/internal/storage-coordinator.d.ts +22 -19
- package/dist/internal/storage-coordinator.d.ts.map +1 -1
- package/dist/internal/storage-coordinator.js +114 -73
- package/dist/internal/storage-roles.d.ts +4 -9
- package/dist/internal/storage-roles.d.ts.map +1 -1
- package/dist/internal/storage-roles.js +2 -2
- package/dist/internal/storage.d.ts +2 -0
- package/dist/internal/storage.d.ts.map +1 -0
- package/dist/internal/storage.js +1 -0
- package/dist/internal/store-mirror.js +4 -4
- package/dist/internal/terminal-style.js +2 -2
- package/dist/internal/tool-result.js +3 -3
- package/dist/internal/trajectory.js +7 -7
- package/dist/internal/turn-governor.js +2 -2
- package/dist/internal/turn-outbox.js +1 -1
- package/dist/internal/update-check.js +2 -2
- package/dist/internal/v2-hosting.d.ts +9 -0
- package/dist/internal/v2-hosting.d.ts.map +1 -1
- package/dist/internal/v2-hosting.js +10 -0
- package/dist/internal/workspace.d.ts +13 -10
- package/dist/internal/workspace.d.ts.map +1 -1
- package/dist/internal/workspace.js +17 -16
- package/dist/kv/memory-kv.d.ts +6 -4
- package/dist/kv/memory-kv.d.ts.map +1 -1
- package/dist/kv/memory-kv.js +9 -7
- package/dist/kv.d.ts +4 -7
- package/dist/kv.d.ts.map +1 -1
- package/dist/kv.js +4 -7
- package/dist/otel-public.d.ts +7 -0
- package/dist/otel-public.d.ts.map +1 -0
- package/dist/otel-public.js +5 -0
- package/dist/otel.d.ts +7 -2
- package/dist/otel.d.ts.map +1 -1
- package/dist/otel.js +7 -2
- package/dist/playground/assets/index-BLlKgZtI.css +1 -0
- package/dist/playground/assets/index-CDS5p9sR.js +67 -0
- package/dist/playground/index.html +2 -2
- package/dist/prompt.js +1 -1
- package/dist/result.d.ts +10 -4
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +9 -3
- package/dist/storage-backends/cursor-hosted-v2.d.ts +4 -5
- package/dist/storage-backends/cursor-hosted-v2.d.ts.map +1 -1
- package/dist/storage-backends/cursor-hosted-v2.js +6 -7
- package/dist/storage-backends/cursor-hosted.d.ts +6 -19
- package/dist/storage-backends/cursor-hosted.d.ts.map +1 -1
- package/dist/storage-backends/cursor-hosted.js +6 -50
- package/dist/storage-backends/file-kv.d.ts +9 -12
- package/dist/storage-backends/file-kv.d.ts.map +1 -1
- package/dist/storage-backends/file-kv.js +18 -54
- package/dist/storage-protocol.d.ts +3 -11
- package/dist/storage-protocol.d.ts.map +1 -1
- package/dist/storage-protocol.js +3 -11
- package/dist/storage.d.ts +28 -38
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +15 -50
- package/dist/types.d.ts +87 -68
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +12 -4
- package/docs/README.md +83 -148
- package/docs/building-with-agents.md +15 -16
- package/docs/deployment.md +6 -7
- package/docs/evals.md +613 -298
- package/docs/guides/agent-to-agent.md +41 -84
- package/docs/guides/bitbucket.md +89 -0
- package/docs/guides/cloud-agents.md +25 -20
- package/docs/guides/github.md +32 -1
- package/docs/guides/gitlab.md +97 -0
- package/docs/guides/grokbot-agents.md +27 -19
- package/docs/guides/mcp-oauth.md +1 -1
- package/docs/guides/opentelemetry.md +28 -41
- package/docs/guides/slack.md +53 -4
- package/docs/guides/webhooks.md +7 -6
- package/docs/hillclimbing.md +7 -7
- package/docs/quickstart.md +45 -106
- package/docs/reference/channels.md +16 -19
- package/docs/reference/cli.md +6 -20
- package/docs/reference/connections.md +3 -5
- package/docs/reference/extensions.md +2 -5
- package/docs/reference/hooks.md +11 -16
- package/docs/reference/http-api.md +6 -7
- package/docs/reference/playground.md +2 -6
- package/docs/reference/project-layout.md +4 -12
- package/docs/reference/sessions.md +6 -6
- package/docs/reference/subagents.md +2 -4
- package/docs/reference/tools.md +2 -5
- package/docs/troubleshooting.md +1 -2
- package/package.json +55 -43
- package/skills/deploy/SKILL.md +169 -0
- package/skills/evals/SKILL.md +45 -8
- package/skills/framework-map/SKILL.md +3 -4
- package/skills/otel/SKILL.md +8 -18
- package/src/bin/agent-serve.ts +93 -72
- package/src/channels/bitbucket/api.ts +347 -6
- package/src/channels/bitbucket/binding.ts +29 -4
- package/src/channels/bitbucket/bitbucket-channel.ts +1 -1
- package/src/channels/bitbucket/bitbucket-webhook.ts +1 -1
- package/src/channels/bitbucket/checks.ts +3 -4
- package/src/channels/bitbucket/cursor-account.ts +1 -1
- package/src/channels/bitbucket/events.ts +1 -1
- package/src/channels/bitbucket/index.ts +2 -0
- package/src/channels/change-monitors/change-monitors-channel.ts +2 -2
- package/src/channels/checks.ts +5 -4
- package/src/channels/deployments/deployments-channel.ts +1 -1
- package/src/channels/github/api.ts +1 -1
- package/src/channels/github/checks.ts +1 -1
- package/src/channels/github/cursor-account.ts +3 -3
- package/src/channels/github/defaults.ts +8 -4
- package/src/channels/github/events.ts +1 -1
- package/src/channels/github/forward.ts +8 -8
- package/src/channels/github/github-channel.ts +19 -2
- package/src/channels/github/progress.ts +7 -2
- package/src/channels/github/state.ts +6 -0
- package/src/channels/github/types.ts +6 -0
- package/src/channels/gitlab/api.ts +123 -0
- package/src/channels/gitlab/binding.ts +16 -4
- package/src/channels/gitlab/checks.ts +3 -4
- package/src/channels/gitlab/cursor-account.ts +1 -1
- package/src/channels/gitlab/events.ts +1 -1
- package/src/channels/gitlab/gitlab-channel.ts +1 -1
- package/src/channels/gitlab/gitlab-webhook.ts +1 -1
- package/src/channels/gitlab/index.ts +1 -0
- package/src/channels/gitlab/replay.ts +2 -2
- package/src/channels/origin/binding.ts +6 -3
- package/src/channels/origin/checks.ts +27 -17
- package/src/channels/origin/cursor-account.ts +1 -1
- package/src/channels/origin/defaults.ts +5 -1
- package/src/channels/origin/events.ts +1 -1
- package/src/channels/origin/origin-channel.ts +2 -1
- package/src/channels/origin/origin-webhook.ts +2 -2
- package/src/channels/slack/agentic-delivery.ts +659 -0
- package/src/channels/slack/agentic-posted.ts +148 -0
- package/src/channels/slack/agentic-signals.ts +248 -0
- package/src/channels/slack/api.ts +51 -11
- package/src/channels/slack/approvals.ts +1 -1
- package/src/channels/slack/attachments.ts +1 -1
- package/src/channels/slack/auth.ts +3 -1
- package/src/channels/slack/blocks.ts +3 -3
- package/src/channels/slack/bot-mentions.ts +5 -7
- package/src/channels/slack/channel-watch.ts +1 -1
- package/src/channels/slack/cli-project.ts +3 -3
- package/src/channels/slack/defaults.ts +109 -37
- package/src/channels/slack/dispatch.ts +323 -164
- package/src/channels/slack/doctor.ts +1 -1
- package/src/channels/slack/eval-directive.ts +1 -1
- package/src/channels/slack/external-policy.ts +15 -2
- package/src/channels/slack/footer.ts +108 -0
- package/src/channels/slack/index.ts +2 -0
- package/src/channels/slack/interactive.ts +4 -2
- package/src/channels/slack/live-delivery.ts +23 -7
- package/src/channels/slack/log.ts +1 -1
- package/src/channels/slack/manifest.ts +1 -1
- package/src/channels/slack/nudge-carrier.ts +1 -1
- package/src/channels/slack/nudge-store.ts +2 -2
- package/src/channels/slack/paint-start.ts +93 -0
- package/src/channels/slack/placeholder.ts +315 -0
- package/src/channels/slack/progress-delivery.ts +14 -1
- package/src/channels/slack/reasoning-chip.ts +48 -0
- package/src/channels/slack/recording-sink.ts +176 -0
- package/src/channels/slack/reply-options.ts +71 -15
- package/src/channels/slack/setup.ts +1 -1
- package/src/channels/slack/slack-channel.ts +140 -18
- package/src/channels/slack/socket-mode.ts +2 -2
- package/src/channels/slack/thread-context.ts +5 -5
- package/src/channels/slack/tool-approval-events.ts +54 -38
- package/src/channels/slack/tool-cards.ts +1 -1
- package/src/channels/slack/tool-chip.ts +36 -0
- package/src/channels/slack/types.ts +47 -7
- package/src/channels/slack/upload.ts +142 -0
- package/src/channels.ts +12 -30
- package/src/dashboard-session-url.ts +32 -0
- package/src/evals/assertions.ts +19 -19
- package/src/evals/expect.ts +1 -1
- package/src/evals/judge.ts +1 -1
- package/src/evals/reporters.ts +8 -9
- package/src/evals/run-facts.ts +2 -2
- package/src/evals.ts +7 -10
- package/src/extensions/cursor-cloud-agents/extension.ts +1 -1
- package/src/extensions/cursor-cloud-agents/lib/backend.ts +3 -3
- package/src/extensions/cursor-cloud-agents/lib/fleet.ts +1 -1
- package/src/extensions/cursor-cloud-agents/lib/repos.ts +3 -3
- package/src/extensions/cursor-cloud-agents/lib/transcript.ts +3 -4
- package/src/extensions/cursor-cloud-agents/tools/list.ts +1 -1
- package/src/extensions/improve/skills/yourself.ts +1 -1
- package/src/extensions/slack-communication/evals/harness.ts +728 -0
- package/src/extensions/slack-communication/evals/slack-communication.eval.ts +953 -0
- package/src/extensions/slack-communication/evals/slack-placeholder.eval.ts +194 -0
- package/src/extensions/slack-communication/extension.ts +45 -0
- package/src/extensions/slack-communication/skills/slack-voice.ts +59 -0
- package/src/extensions/slack-communication/tools/delete-message.ts +34 -0
- package/src/extensions/slack-communication/tools/edit-message.ts +42 -0
- package/src/extensions/slack-communication/tools/post-card.ts +28 -0
- package/src/extensions/slack-communication/tools/post-file.ts +85 -0
- package/src/extensions/slack-communication/tools/post-update.ts +41 -0
- package/src/extensions/slack-communication/tools/react.ts +33 -0
- package/src/extensions/slack-communication/tools/set-status.ts +21 -0
- package/src/extensions.ts +2 -6
- package/src/files-backends/cursor-hosted.ts +502 -98
- package/src/files-backends/local-fs.ts +1 -1
- package/src/files.ts +15 -0
- package/src/filesystem.ts +16 -18
- package/src/index.ts +4 -39
- package/src/internal/advertise-tools.ts +6 -6
- package/src/internal/approval-gate.ts +1 -1
- package/src/internal/artifacts-store.ts +3 -3
- package/src/internal/as-of.ts +2 -2
- package/src/internal/authored-alias-hooks.ts +32 -0
- package/src/internal/authored-loaders.ts +25 -2
- package/src/internal/builtin-tools/reminders.ts +2 -2
- package/src/internal/chat-client.ts +5 -5
- package/src/internal/cli-ax.ts +85 -16
- package/src/internal/cli-bitbucket.ts +11 -11
- package/src/internal/cli-convert-automation.ts +2 -2
- package/src/internal/cli-cursor.ts +5 -16
- package/src/internal/cli-deploy.ts +389 -104
- package/src/internal/cli-docs.ts +5 -5
- package/src/internal/cli-github.ts +16 -19
- package/src/internal/cli-gitlab.ts +11 -11
- package/src/internal/cli-manifest.ts +1 -1
- package/src/internal/cli-mcp-oauth.ts +5 -7
- package/src/internal/cli-mcp.ts +3 -3
- package/src/internal/cli-skills.ts +2 -2
- package/src/internal/cli-slack.ts +5 -5
- package/src/internal/cloud-turn-cost.ts +1 -1
- package/src/internal/continuation-channel.ts +2 -1
- package/src/internal/continuation-identity.ts +23 -11
- package/src/internal/conversation-mirror.ts +36 -3
- package/src/internal/convert-automation/convert-workflow.ts +27 -27
- package/src/internal/convert-automation/types.ts +9 -0
- package/src/internal/cursor/account-mcp.ts +48 -31
- package/src/internal/cursor/backend-client.ts +28 -17
- package/src/internal/cursor/credentials.ts +1 -1
- package/src/internal/cursor/hosted-store-secrets.ts +34 -0
- package/src/internal/cursor-account-mcp-auth.ts +9 -9
- package/src/internal/cursor-deployment-relay.ts +10 -10
- package/src/internal/cursor-event-relay.ts +10 -10
- package/src/internal/cursor-relay-core.ts +2 -2
- package/src/internal/deploy-client.ts +266 -24
- package/src/internal/deploy-manifest.ts +46 -8
- package/src/internal/discovery/agent-config.ts +34 -0
- package/src/internal/discovery/agent.ts +15 -13
- package/src/internal/discovery/channels.ts +4 -4
- package/src/internal/discovery/connections.ts +4 -4
- package/src/internal/discovery/cursor-plugin.ts +12 -12
- package/src/internal/discovery/extension-overlay.ts +3 -21
- package/src/internal/discovery/extensions.ts +8 -32
- package/src/internal/discovery/info.ts +12 -22
- package/src/internal/discovery/instructions.ts +1 -1
- package/src/internal/discovery/modules.ts +0 -1
- package/src/internal/discovery/project.ts +4 -20
- package/src/internal/discovery/services.ts +1 -1
- package/src/internal/discovery/tools.ts +1 -1
- package/src/internal/docs-site.ts +2 -2
- package/src/internal/env-file.ts +2 -2
- package/src/internal/eval-run-store.ts +7 -9
- package/src/internal/eval-runner.ts +20 -21
- package/src/internal/evals-client.ts +6 -6
- package/src/internal/event-log.ts +10 -10
- package/src/internal/event-mapper.ts +37 -2
- package/src/internal/filesystem/format.ts +11 -12
- package/src/internal/filesystem/scratch.ts +3 -3
- package/src/internal/filesystem/tools.ts +6 -8
- package/src/internal/filesystem/walk.ts +1 -1
- package/src/internal/framework-file-storage.ts +108 -9
- package/src/internal/framework-storage-selection.ts +4 -14
- package/src/internal/github-fanout.ts +4 -4
- package/src/internal/guest-network.ts +4 -4
- package/src/internal/host-files.ts +1 -1
- package/src/internal/host-kv.ts +2 -2
- package/src/internal/hosted-admission-adapter.ts +2 -0
- package/src/internal/hosted-catch-protocol.ts +3 -5
- package/src/internal/hosted-catch.ts +1 -1
- package/src/internal/hosted-delivery-protocol.ts +111 -13
- package/src/internal/hosted-delivery.ts +286 -81
- package/src/internal/hosted-execution-diag.ts +3 -3
- package/src/internal/hosted-execution-latency.ts +334 -0
- package/src/internal/hosting.ts +5 -6
- package/src/internal/http-channel-define.ts +27 -0
- package/src/internal/http-channel.ts +3 -4
- package/src/internal/http-control-plane-session.ts +24 -11
- package/src/internal/incoming-headers-to-fetch.ts +54 -0
- package/src/internal/init-interview.ts +7 -7
- package/src/internal/init-project.ts +14 -16
- package/src/internal/init-scaffold.ts +2 -3
- package/src/internal/inline-stdio-mcp.ts +2 -2
- package/src/internal/install-cursor-skills.ts +49 -16
- package/src/internal/json-schema.ts +1 -1
- package/src/internal/local-control-plane.ts +4 -5
- package/src/internal/local-env.ts +3 -3
- package/src/internal/log-ring.ts +1 -1
- package/src/internal/logs-client.ts +1 -1
- package/src/internal/mcp-endpoint.ts +10 -10
- package/src/internal/mcp-host.ts +9 -9
- package/src/internal/mcp-oauth-on-demand.ts +3 -3
- package/src/internal/mcp-oauth.ts +5 -5
- package/src/internal/net.ts +2 -2
- package/src/internal/otel/config.ts +3 -3
- package/src/internal/otel/runtime.ts +14 -14
- package/src/internal/peer-connections.ts +2 -2
- package/src/internal/platform-schedule-sync.ts +1 -1
- package/src/internal/platform-timers.ts +1 -1
- package/src/internal/playground/static.ts +2 -2
- package/src/internal/playground/toolchain.ts +2 -2
- package/src/internal/playground-proxy.ts +3 -3
- package/src/internal/process-memory-telemetry.ts +1 -1
- package/src/internal/reminder-runner.ts +8 -10
- package/src/internal/reminder-store.ts +1 -1
- package/src/internal/request-error-status.ts +9 -0
- package/src/internal/resolved-connections.ts +8 -8
- package/src/internal/result-output.ts +62 -5
- package/src/internal/router.ts +4 -4
- package/src/internal/run-client.ts +3 -3
- package/src/internal/schedule-runner.ts +6 -6
- package/src/internal/scm/pr-url.ts +11 -2
- package/src/internal/sdk-runner.ts +15 -29
- package/src/internal/serve-restart.ts +1 -1
- package/src/internal/server.ts +97 -115
- package/src/internal/session-cost.ts +3 -3
- package/src/internal/session-engine.ts +517 -445
- package/src/internal/session-run-log.ts +4 -6
- package/src/internal/session-store.ts +213 -39
- package/src/internal/sessions-client.ts +3 -3
- package/src/internal/slack-thread-key.ts +11 -0
- package/src/internal/sleep.ts +1 -1
- package/src/internal/storage-coordinator.ts +122 -96
- package/src/internal/storage-roles.ts +4 -9
- package/src/internal/storage.ts +1 -0
- package/src/internal/store-mirror.ts +4 -4
- package/src/internal/terminal-style.ts +2 -2
- package/src/internal/tool-result.ts +3 -3
- package/src/internal/trajectory.ts +7 -7
- package/src/internal/turn-governor.ts +2 -2
- package/src/internal/turn-outbox.ts +1 -1
- package/src/internal/update-check.ts +2 -2
- package/src/internal/v2-hosting.ts +14 -0
- package/src/internal/workspace.ts +17 -17
- package/src/kv/memory-kv.ts +9 -7
- package/src/kv.ts +4 -7
- package/src/otel-public.ts +24 -0
- package/src/otel.ts +7 -2
- package/src/prompt.ts +1 -1
- package/src/result.ts +10 -8
- package/src/storage-backends/cursor-hosted-v2.ts +6 -9
- package/src/storage-backends/cursor-hosted.ts +6 -60
- package/src/storage-backends/file-kv.ts +17 -58
- package/src/storage-protocol.ts +3 -17
- package/src/storage.ts +32 -108
- package/src/types.ts +101 -73
- package/templates/agentic-owners/agent/channels/github.ts +3 -6
- package/templates/agentic-owners/agent/lib/github.ts +5 -5
- package/templates/agentic-owners/agent/lib/owners/decision.ts +13 -10
- package/templates/agentic-owners/agent/lib/owners/handles.ts +2 -2
- package/templates/agentic-owners/agent/lib/owners/match.ts +3 -3
- package/templates/agentic-owners/agent/lib/owners/matching.ts +1 -1
- package/templates/agentic-owners/agent/lib/owners/parse.ts +4 -9
- package/templates/agentic-owners/agent/lib/owners/prompt.ts +1 -1
- package/templates/agentic-owners/agent/lib/review.ts +37 -30
- package/templates/agentic-owners/evals/owners.eval.ts +2 -2
- package/templates/agentic-owners/package.json +1 -1
- package/templates/agents-md/agent/lib/collect.ts +16 -10
- package/templates/agents-md/agent/lib/config.ts +1 -1
- package/templates/agents-md/agent/tools/apply_agents.ts +10 -8
- package/templates/agents-md/package.json +1 -1
- package/templates/code-wiki/agent/channels/github.ts +4 -7
- package/templates/code-wiki/agent/lib/repos.ts +1 -1
- package/templates/code-wiki/agent/tools/apply_wiki.ts +3 -4
- package/templates/code-wiki/package.json +1 -1
- package/templates/demo/README.md +10 -6
- package/templates/demo/agent/channels/github.ts +2 -0
- package/templates/demo/agent/channels/queue.ts +6 -2
- package/templates/demo/agent/lib/collect.ts +6 -2
- package/templates/demo/agent/lib/repos.ts +5 -0
- package/templates/demo/agent/tools/record_demo.ts +1 -1
- package/templates/demo/evals/demo.eval.ts +1 -5
- package/templates/demo/init.json +25 -0
- package/templates/demo/package.json +1 -1
- package/templates/grokbot-agents/package.json +1 -1
- package/templates/pr-autofixer/agent/channels/github.ts +16 -13
- package/templates/pr-autofixer/agent/lib/merge-watch.ts +2 -4
- package/templates/pr-autofixer/agent/lib/repos.ts +2 -2
- package/templates/pr-autofixer/agent/lib/webhook-routing.ts +1 -1
- package/templates/pr-autofixer/package.json +1 -1
- package/templates/security-help/agent/lib/repos.ts +1 -1
- package/templates/security-help/package.json +1 -1
- package/templates/security-reviewer/agent/lib/repos.ts +1 -1
- package/templates/security-reviewer/agent/tools/post_findings.ts +1 -3
- package/templates/security-reviewer/package.json +1 -1
- package/templates/triage/agent/lib/actuate.ts +26 -41
- package/templates/triage/agent/lib/parse-queue-event.ts +2 -1
- package/templates/triage/agent/lib/verify-webhook.ts +10 -5
- package/templates/triage/agent/tools/record_triage.ts +1 -4
- package/templates/triage/package.json +1 -1
- package/dist/ab.d.ts +0 -209
- package/dist/ab.d.ts.map +0 -1
- package/dist/ab.js +0 -246
- package/dist/client.d.ts +0 -14
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -12
- package/dist/docs/ab.html +0 -80
- package/dist/docs/ab.md +0 -332
- package/dist/docs/assets/ab.md.mlVgqvSk.js +0 -54
- package/dist/docs/assets/ab.md.mlVgqvSk.lean.js +0 -1
- package/dist/docs/assets/app.BASKM3M4.js +0 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.BHZYsNVi.js +0 -1
- package/dist/docs/assets/chunks/framework.BCISBCiQ.js +0 -19
- package/dist/docs/assets/concepts.md.DgEcZOfT.js +0 -1
- package/dist/docs/assets/concepts.md.DgEcZOfT.lean.js +0 -1
- package/dist/docs/assets/evals.md.C1ekS3k2.js +0 -85
- package/dist/docs/assets/evals.md.C1ekS3k2.lean.js +0 -1
- package/dist/docs/assets/guides_agent-to-agent.md.BDb0t1QV.js +0 -10
- package/dist/docs/assets/guides_agent-to-agent.md.BDb0t1QV.lean.js +0 -1
- package/dist/docs/assets/guides_grokbot-agents.md.DyV-WArv.js +0 -9
- package/dist/docs/assets/guides_human-in-the-loop.md.By1G2T3_.js +0 -28
- package/dist/docs/assets/guides_human-in-the-loop.md.By1G2T3_.lean.js +0 -1
- package/dist/docs/assets/hillclimbing.md.CpTGTCle.js +0 -4
- package/dist/docs/assets/hillclimbing.md.CpTGTCle.lean.js +0 -1
- package/dist/docs/assets/index.md.BjH1w2ZW.js +0 -5
- package/dist/docs/assets/index.md.BjH1w2ZW.lean.js +0 -1
- package/dist/docs/assets/quickstart.md.DdQOF7Y8.lean.js +0 -1
- package/dist/docs/assets/reference_project-layout.md.DuBu9a96.js +0 -19
- package/dist/docs/assets/reference_result.md.BK5SxDrf.js +0 -19
- package/dist/docs/assets/reference_result.md.BK5SxDrf.lean.js +0 -1
- package/dist/docs/assets/reference_sessions.md.CueyOHSL.js +0 -1
- package/dist/docs/assets/scaffolding-agents.md.Kctn3OVb.js +0 -1
- package/dist/docs/assets/scaffolding-agents.md.Kctn3OVb.lean.js +0 -1
- package/dist/docs/assets/skills_ab.md.CsFNatVx.js +0 -26
- package/dist/docs/assets/skills_ab.md.CsFNatVx.lean.js +0 -1
- package/dist/docs/assets/skills_create-agent.md.Q3h6Je-e.js +0 -8
- package/dist/docs/assets/skills_create-agent.md.Q3h6Je-e.lean.js +0 -1
- package/dist/docs/assets/skills_debug.md.CVjCXMFF.js +0 -1
- package/dist/docs/assets/skills_debug.md.CVjCXMFF.lean.js +0 -1
- package/dist/docs/assets/skills_evals.md.BhovOvrl.js +0 -25
- package/dist/docs/assets/skills_evals.md.BhovOvrl.lean.js +0 -1
- package/dist/docs/assets/skills_framework-map.md.D-tFZhFS.js +0 -1
- package/dist/docs/assets/skills_framework-map.md.D-tFZhFS.lean.js +0 -1
- package/dist/docs/assets/skills_github.md.hgFX_oKY.js +0 -16
- package/dist/docs/assets/skills_github.md.hgFX_oKY.lean.js +0 -1
- package/dist/docs/assets/skills_hillclimb.md.B_zJerxA.js +0 -7
- package/dist/docs/assets/skills_hillclimb.md.B_zJerxA.lean.js +0 -1
- package/dist/docs/assets/skills_index.md.DKwIxzGg.js +0 -1
- package/dist/docs/assets/skills_index.md.DKwIxzGg.lean.js +0 -1
- package/dist/docs/assets/skills_mcp-auth.md.DGvFP3HE.js +0 -18
- package/dist/docs/assets/skills_mcp-auth.md.DGvFP3HE.lean.js +0 -1
- package/dist/docs/assets/skills_otel.md.B5Ddv1xH.js +0 -8
- package/dist/docs/assets/skills_otel.md.B5Ddv1xH.lean.js +0 -1
- package/dist/docs/assets/skills_setup-slack.md.BBgx8lUz.js +0 -20
- package/dist/docs/assets/skills_setup-slack.md.BBgx8lUz.lean.js +0 -1
- package/dist/docs/assets/storage.md.BOHeqk2M.js +0 -30
- package/dist/docs/assets/storage.md.BOHeqk2M.lean.js +0 -1
- package/dist/docs/assets/templates_agents-md.md.CXSMZljE.js +0 -2
- package/dist/docs/assets/templates_agents-md.md.CXSMZljE.lean.js +0 -1
- package/dist/docs/assets/templates_code-wiki.md.CDYZIBFN.js +0 -2
- package/dist/docs/assets/templates_code-wiki.md.CDYZIBFN.lean.js +0 -1
- package/dist/docs/assets/templates_demo.md.BeQX9V3H.js +0 -4
- package/dist/docs/assets/templates_demo.md.BeQX9V3H.lean.js +0 -1
- package/dist/docs/assets/templates_grokbot-agents.md.c1s6Flp9.js +0 -3
- package/dist/docs/assets/templates_grokbot-agents.md.c1s6Flp9.lean.js +0 -1
- package/dist/docs/assets/templates_security-help.md.C3Ny_Qr2.js +0 -4
- package/dist/docs/assets/templates_security-help.md.C3Ny_Qr2.lean.js +0 -1
- package/dist/docs/concepts.html +0 -27
- package/dist/docs/concepts.md +0 -168
- package/dist/docs/design/filesystem.md +0 -376
- package/dist/docs/design/runtime-abstraction.md +0 -1756
- package/dist/docs/guides/human-in-the-loop.html +0 -54
- package/dist/docs/guides/human-in-the-loop.md +0 -126
- package/dist/docs/reference/result.html +0 -45
- package/dist/docs/reference/result.md +0 -89
- package/dist/docs/scaffolding-agents.html +0 -27
- package/dist/docs/scaffolding-agents.md +0 -130
- package/dist/docs/skills/ab.html +0 -52
- package/dist/docs/skills/ab.md +0 -50
- package/dist/docs/skills/create-agent.html +0 -34
- package/dist/docs/skills/create-agent.md +0 -160
- package/dist/docs/skills/debug.html +0 -27
- package/dist/docs/skills/debug.md +0 -36
- package/dist/docs/skills/evals.html +0 -51
- package/dist/docs/skills/evals.md +0 -99
- package/dist/docs/skills/framework-map.html +0 -27
- package/dist/docs/skills/framework-map.md +0 -100
- package/dist/docs/skills/github.html +0 -42
- package/dist/docs/skills/github.md +0 -93
- package/dist/docs/skills/hillclimb.html +0 -33
- package/dist/docs/skills/hillclimb.md +0 -55
- package/dist/docs/skills/index.html +0 -27
- package/dist/docs/skills/index.md +0 -21
- package/dist/docs/skills/mcp-auth.html +0 -44
- package/dist/docs/skills/mcp-auth.md +0 -76
- package/dist/docs/skills/otel.html +0 -34
- package/dist/docs/skills/otel.md +0 -53
- package/dist/docs/skills/setup-slack.html +0 -46
- package/dist/docs/skills/setup-slack.md +0 -141
- package/dist/docs/storage.html +0 -56
- package/dist/docs/storage.md +0 -176
- package/dist/docs/templates/agents-md.html +0 -28
- package/dist/docs/templates/agents-md.md +0 -105
- package/dist/docs/templates/code-wiki.html +0 -28
- package/dist/docs/templates/code-wiki.md +0 -91
- package/dist/docs/templates/demo.html +0 -30
- package/dist/docs/templates/demo.md +0 -80
- package/dist/docs/templates/grokbot-agents.html +0 -29
- package/dist/docs/templates/grokbot-agents.md +0 -48
- package/dist/docs/templates/security-help.html +0 -30
- package/dist/docs/templates/security-help.md +0 -65
- package/dist/internal/ab-collector.d.ts +0 -44
- package/dist/internal/ab-collector.d.ts.map +0 -1
- package/dist/internal/ab-collector.js +0 -142
- package/dist/internal/ab-fold.d.ts +0 -36
- package/dist/internal/ab-fold.d.ts.map +0 -1
- package/dist/internal/ab-fold.js +0 -175
- package/dist/internal/ab-snapshot.d.ts +0 -68
- package/dist/internal/ab-snapshot.d.ts.map +0 -1
- package/dist/internal/ab-snapshot.js +0 -208
- package/dist/internal/discovery/ab.d.ts +0 -9
- package/dist/internal/discovery/ab.d.ts.map +0 -1
- package/dist/internal/discovery/ab.js +0 -113
- package/dist/internal/tenant-slack/relay.d.ts +0 -75
- package/dist/internal/tenant-slack/relay.d.ts.map +0 -1
- package/dist/internal/tenant-slack/relay.js +0 -148
- package/dist/playground/assets/index-BMDqAeXu.js +0 -67
- package/dist/playground/assets/index-LUgJoWdL.css +0 -1
- package/docs/ab.md +0 -337
- package/docs/concepts.md +0 -173
- package/docs/design/filesystem.md +0 -376
- package/docs/design/runtime-abstraction.md +0 -1756
- package/docs/guides/human-in-the-loop.md +0 -131
- package/docs/reference/result.md +0 -94
- package/docs/scaffolding-agents.md +0 -135
- package/docs/skills/index.md +0 -26
- package/docs/storage.md +0 -181
- package/docs/templates/agents-md.md +0 -110
- package/docs/templates/code-wiki.md +0 -96
- package/docs/templates/demo.md +0 -85
- package/docs/templates/grokbot-agents.md +0 -53
- package/docs/templates/security-help.md +0 -70
- package/skills/ab/SKILL.md +0 -58
- package/src/ab.ts +0 -430
- package/src/client.ts +0 -23
- package/src/internal/ab-collector.ts +0 -200
- package/src/internal/ab-fold.ts +0 -232
- package/src/internal/ab-snapshot.ts +0 -331
- package/src/internal/discovery/ab.ts +0 -131
- package/src/internal/tenant-slack/relay.ts +0 -203
- package/templates/pr-autofixer/agent/storage.ts +0 -7
|
@@ -16,9 +16,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
16
16
|
});
|
|
17
17
|
};
|
|
18
18
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
19
|
-
import { mkdir, rm, writeFile } from "node:fs/promises";
|
|
19
|
+
import { access, mkdir, rm, writeFile } from "node:fs/promises";
|
|
20
20
|
import { dirname, join } from "node:path";
|
|
21
|
-
import { mergeABInstructions, resolveABMaxPlaygroundSessions, resolveABSplit, } from "../ab.js";
|
|
22
21
|
import { SLACK_CHANNEL_ID } from "../channels/slack/constants.js";
|
|
23
22
|
import { materializeSlackNudgeCarrier } from "../channels/slack/nudge-carrier.js";
|
|
24
23
|
import { SlackAskDedupeStore, SlackNudgeStore, } from "../channels/slack/nudge-store.js";
|
|
@@ -28,9 +27,6 @@ import { cursorHostedFiles, isCursorHostedFilesAvailable, isCursorUserStoreFiles
|
|
|
28
27
|
import { isFileSystemToolAlias, isMutatingFileSystemTool, localFileSystem, resolveFileSystemTools, resolveHostHarnessToolOptions, tempFs, unionFs, writeWorkspaceFilesToRoot, } from "../filesystem.js";
|
|
29
28
|
import { storageKeysForArchitecture } from "../storage.js";
|
|
30
29
|
import { DEFAULT_MODEL, DIRECT_TOOL_CALL_CHANNEL_ID, isCursorAccountTransport, isHostOauthConnectionTransport, isSymbolicConnectionTransport, } from "../types.js";
|
|
31
|
-
import { ABCollector } from "./ab-collector.js";
|
|
32
|
-
import { foldABStream } from "./ab-fold.js";
|
|
33
|
-
import { buildABSnapshot } from "./ab-snapshot.js";
|
|
34
30
|
import { resolveAdvertisedTools, } from "./advertise-tools.js";
|
|
35
31
|
import { ApprovalGate } from "./approval-gate.js";
|
|
36
32
|
import { ArtifactsStore } from "./artifacts-store.js";
|
|
@@ -61,7 +57,7 @@ import { McpOauthOnDemandHub } from "./mcp-oauth-on-demand.js";
|
|
|
61
57
|
import { shouldStartProcessMemoryTelemetry, startProcessMemoryTelemetry, } from "./process-memory-telemetry.js";
|
|
62
58
|
import { buildSessionContextBlock, SCHEDULE_CHANNEL_PREFIX, } from "./prompt-context.js";
|
|
63
59
|
import { assertCloudCanHonorAccountServersFilters } from "./resolved-connections.js";
|
|
64
|
-
import { applyAuthoredResult } from "./result-output.js";
|
|
60
|
+
import { addTurnUsage, applyAuthoredResult, RESULT_REPAIR_BUDGET, resultRepairPrompt, } from "./result-output.js";
|
|
65
61
|
import { sessionExternalLinks } from "./session-links.js";
|
|
66
62
|
import { SessionStore } from "./session-store.js";
|
|
67
63
|
import { syncSkillsToStore } from "./skills-sync.js";
|
|
@@ -85,6 +81,18 @@ export class SessionBusyError extends Error {
|
|
|
85
81
|
this.name = "SessionBusyError";
|
|
86
82
|
}
|
|
87
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Hosted enqueue-only admission could not coalesce into an active turn.
|
|
86
|
+
* Distinct from {@link SessionBusyError}: the caller asked not to start work.
|
|
87
|
+
*/
|
|
88
|
+
export class HostedEnqueueNotActiveError extends Error {
|
|
89
|
+
constructor(sessionId) {
|
|
90
|
+
super(sessionId === undefined
|
|
91
|
+
? "Hosted enqueue requires an active accepting session"
|
|
92
|
+
: `Hosted enqueue requires an active turn on session ${sessionId}`);
|
|
93
|
+
this.name = "HostedEnqueueNotActiveError";
|
|
94
|
+
}
|
|
95
|
+
}
|
|
88
96
|
// Defined in auth.js (HTTP/session-store callers import it without this
|
|
89
97
|
// module); re-exported here because this is its historical public home.
|
|
90
98
|
export { SessionAuthError } from "./auth.js";
|
|
@@ -162,6 +170,33 @@ export class AuthInterruptedError extends Error {
|
|
|
162
170
|
}
|
|
163
171
|
}
|
|
164
172
|
const mcpAuthAls = new AsyncLocalStorage();
|
|
173
|
+
/** Marker that we `git init`'d this shared harness so scaffold is ours to write. */
|
|
174
|
+
const OWNED_HARNESS = join(".agent-serve", "owned-harness");
|
|
175
|
+
function pathExists(path) {
|
|
176
|
+
return access(path).then(() => true, () => false);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Nested dirs get their own git root so the harness does not ripwalk the
|
|
180
|
+
* enclosing checkout. A real `workspaceDir` checkout (already a git root)
|
|
181
|
+
* is left alone.
|
|
182
|
+
*/
|
|
183
|
+
function ownSharedHarness(dir) {
|
|
184
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
+
if (yield pathExists(join(dir, OWNED_HARNESS))) {
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
if (!(yield isNestedInGitRepo(dir))) {
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
yield ensureOwnGitRoot(dir);
|
|
192
|
+
if (yield isNestedInGitRepo(dir)) {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
yield mkdir(join(dir, ".agent-serve"), { recursive: true });
|
|
196
|
+
yield writeFile(join(dir, OWNED_HARNESS), "");
|
|
197
|
+
return true;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
165
200
|
export class SessionEngine {
|
|
166
201
|
constructor(options) {
|
|
167
202
|
var _a, _b, _c, _d, _e;
|
|
@@ -201,6 +236,8 @@ export class SessionEngine {
|
|
|
201
236
|
this.turnAborts = new Map();
|
|
202
237
|
/** Serializes turn admission per session (latest follow-up wins). */
|
|
203
238
|
this.admissionChains = new Map();
|
|
239
|
+
/** Live turn snapshot so a coalesced Slack wake can repaint on this process. */
|
|
240
|
+
this.liveTurns = new Map();
|
|
204
241
|
/**
|
|
205
242
|
* Per-session coalesce queue for `admission: "coalesce"` (Slack). Drained
|
|
206
243
|
* into one follow-up turn when the active turn finishes without interrupt.
|
|
@@ -249,7 +286,7 @@ export class SessionEngine {
|
|
|
249
286
|
this.askDedupe = new SlackAskDedupeStore(join(options.stateRoot, "slack-asks"));
|
|
250
287
|
this.turnLeases = new TurnLeaseStore(join(options.stateRoot, "turn-leases"));
|
|
251
288
|
this.outbox = new TurnOutbox(join(options.stateRoot, "outbox"));
|
|
252
|
-
this.logs = new EventLogStore(
|
|
289
|
+
this.logs = new EventLogStore(sessionId => this.sessions.eventFilePath(sessionId), (sessionId, error) => this.logger(`[agent-sdk] failed to persist events for ${sessionId}: ${describeError(error)}`));
|
|
253
290
|
// Framework session state (records, event chunks, continuations) is
|
|
254
291
|
// mirrored to whatever this selects; see framework-storage-selection.ts
|
|
255
292
|
// for why the choice does not belong to the agent author.
|
|
@@ -287,16 +324,13 @@ export class SessionEngine {
|
|
|
287
324
|
config: options.project.artifacts,
|
|
288
325
|
sink: managedV2Files === null || managedV2Files === void 0 ? void 0 : managedV2Files(),
|
|
289
326
|
});
|
|
290
|
-
this.abCollector = new ABCollector(options.project.abs, this.logger, (sessionId) => __awaiter(this, void 0, void 0, function* () { return (yield this.logs.get(sessionId)).snapshot(0); }),
|
|
291
|
-
// Samples flow to the defineStorage `abs` table (no-op without one).
|
|
292
|
-
{ persistSample: (sample) => { var _a; return (_a = this.storage) === null || _a === void 0 ? void 0 : _a.abSample(sample); } });
|
|
293
327
|
// Peer and Cursor-account transports are symbolic until the serve host
|
|
294
328
|
// resolves them; the host-side MCP registry starts with the concrete
|
|
295
329
|
// connections and gains the rest via setResolvedConnections.
|
|
296
330
|
this.mcpHost = new McpHost([
|
|
297
331
|
...options.project.agent.connections,
|
|
298
332
|
...((_d = options.project.agent.hostConnections) !== null && _d !== void 0 ? _d : []),
|
|
299
|
-
].filter(
|
|
333
|
+
].filter(connection => !isSymbolicConnectionTransport(connection.transport)));
|
|
300
334
|
const basePlatforms = (_e = options.platforms) !== null && _e !== void 0 ? _e : createHostPlatforms();
|
|
301
335
|
const slackBinding = resolveDedicatedSlackHostBinding(options.project.channels);
|
|
302
336
|
this.platforms =
|
|
@@ -340,7 +374,7 @@ export class SessionEngine {
|
|
|
340
374
|
authoredConnection(name) {
|
|
341
375
|
var _a;
|
|
342
376
|
var _b;
|
|
343
|
-
return ((_b = this.project.agent.connections.find(
|
|
377
|
+
return ((_b = this.project.agent.connections.find(item => item.name === name)) !== null && _b !== void 0 ? _b : (_a = this.project.agent.hostConnections) === null || _a === void 0 ? void 0 : _a.find(item => item.name === name));
|
|
344
378
|
}
|
|
345
379
|
setCloudServerToolsConnection(connection) {
|
|
346
380
|
this.cloudServerToolsConnection = connection;
|
|
@@ -405,7 +439,7 @@ export class SessionEngine {
|
|
|
405
439
|
}
|
|
406
440
|
return this.tagArtifact(Object.assign(Object.assign({}, input), { sessionId: binding.sessionId, turnId: (_a = input.turnId) !== null && _a !== void 0 ? _a : binding.turnId }));
|
|
407
441
|
}),
|
|
408
|
-
list:
|
|
442
|
+
list: filter => this.artifactsStore.list(filter),
|
|
409
443
|
};
|
|
410
444
|
}
|
|
411
445
|
/**
|
|
@@ -543,10 +577,10 @@ export class SessionEngine {
|
|
|
543
577
|
}
|
|
544
578
|
slackNudgeHostApi() {
|
|
545
579
|
return {
|
|
546
|
-
append:
|
|
547
|
-
drainFormatted:
|
|
548
|
-
clear:
|
|
549
|
-
hasUndelivered:
|
|
580
|
+
append: input => this.nudgeStore.append(input),
|
|
581
|
+
drainFormatted: continuationKey => this.nudgeStore.drainFormatted(continuationKey),
|
|
582
|
+
clear: continuationKey => this.nudgeStore.clear(continuationKey),
|
|
583
|
+
hasUndelivered: continuationKey => this.nudgeStore.hasUndelivered(continuationKey),
|
|
550
584
|
isDelivered: (continuationKey, sourceTs) => this.nudgeStore.isDelivered(continuationKey, sourceTs),
|
|
551
585
|
tryClaimAsk: (channelId, messageTs) => this.askDedupe.tryClaim(channelId, messageTs),
|
|
552
586
|
releaseAsk: (channelId, messageTs) => this.askDedupe.release(channelId, messageTs),
|
|
@@ -627,35 +661,49 @@ export class SessionEngine {
|
|
|
627
661
|
// Refresh harness cwd when the caller supplies a newer worktree (e.g. PR
|
|
628
662
|
// synchronize). Leave the durable continuation key unchanged.
|
|
629
663
|
let record = existing;
|
|
630
|
-
const
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
664
|
+
const enqueueOnly = sendOptions.hostedEnqueueOnly === true;
|
|
665
|
+
if (!enqueueOnly) {
|
|
666
|
+
const refreshWorkspace = sendOptions.workspaceDir !== undefined &&
|
|
667
|
+
sendOptions.workspaceDir !== existing.workspaceOverride;
|
|
668
|
+
if (refreshWorkspace ||
|
|
669
|
+
sendOptions.workspaceFiles !== undefined ||
|
|
670
|
+
sendOptions.images !== undefined) {
|
|
671
|
+
record = yield this.updateRecord(existing.sessionId, current => (Object.assign(Object.assign({}, current), { workspaceOverride: refreshWorkspace
|
|
672
|
+
? sendOptions.workspaceDir
|
|
673
|
+
: current.workspaceOverride, pendingWorkspaceFiles: mergePendingWorkspaceFiles(current.pendingWorkspaceFiles, sendOptions.workspaceFiles), pendingImages: mergePendingImages(current.pendingImages, sendOptions.images) })));
|
|
674
|
+
}
|
|
675
|
+
// Refresh the cloud attach the same way: a follow-up send carries the
|
|
676
|
+
// caller's CURRENT cloud options (e.g. a PR attach re-derived per wake),
|
|
677
|
+
// and the first send's snapshot must not pin this session's turns to a
|
|
678
|
+
// stale repo/prUrl for the session's lifetime.
|
|
679
|
+
if (sendOptions.cloud !== undefined &&
|
|
680
|
+
JSON.stringify(sendOptions.cloud) !==
|
|
681
|
+
JSON.stringify(record.cloudOverride)) {
|
|
682
|
+
record = yield this.updateRecord(record.sessionId, current => (Object.assign(Object.assign({}, current), { cloudOverride: sendOptions.cloud })));
|
|
683
|
+
}
|
|
684
|
+
// Refresh wake-derived channel state (GitHub headSha / refs) without
|
|
685
|
+
// wiping sticky fields. Null patch values are skipped.
|
|
686
|
+
if (sendOptions.refreshState !== undefined) {
|
|
687
|
+
record = yield this.updateRecord(record.sessionId, current => (Object.assign(Object.assign({}, current), { channelState: mergeChannelStateSkipNull(current.channelState, sendOptions.refreshState) })));
|
|
688
|
+
}
|
|
652
689
|
}
|
|
653
690
|
const since = (yield this.logs.get(record.sessionId)).count;
|
|
654
|
-
const coalesced = yield this.startTurn(record.sessionId, message, Object.assign({ admission:
|
|
691
|
+
const coalesced = yield this.startTurn(record.sessionId, message, Object.assign(Object.assign({ admission: enqueueOnly
|
|
692
|
+
? "coalesce"
|
|
693
|
+
: ((_d = sendOptions.admission) !== null && _d !== void 0 ? _d : "preempt") }, (sendOptions.coalesceSourceTs === undefined
|
|
655
694
|
? {}
|
|
656
|
-
: { sourceTs: sendOptions.coalesceSourceTs })));
|
|
695
|
+
: { sourceTs: sendOptions.coalesceSourceTs })), (enqueueOnly ? { hostedEnqueueOnly: true } : {})));
|
|
696
|
+
if (enqueueOnly && !coalesced) {
|
|
697
|
+
throw new HostedEnqueueNotActiveError(record.sessionId);
|
|
698
|
+
}
|
|
699
|
+
if (!enqueueOnly && coalesced && sendOptions.refreshState !== undefined) {
|
|
700
|
+
yield this.repaintOnCoalescedRefresh(record.sessionId, sendOptions.refreshState);
|
|
701
|
+
}
|
|
657
702
|
return this.channelSession(record.sessionId, record, false, coalesced, since);
|
|
658
703
|
}
|
|
704
|
+
if (sendOptions.hostedEnqueueOnly === true) {
|
|
705
|
+
throw new HostedEnqueueNotActiveError(sendOptions.hostedSessionId);
|
|
706
|
+
}
|
|
659
707
|
if (sendOptions.hostedSessionId !== undefined) {
|
|
660
708
|
const collision = yield this.getOrRestoreSession(sendOptions.hostedSessionId);
|
|
661
709
|
if (collision !== undefined) {
|
|
@@ -667,7 +715,7 @@ export class SessionEngine {
|
|
|
667
715
|
const purpose = sendOptions.purpose === "eval" ? "eval" : "live";
|
|
668
716
|
const frozenAsOf = normalizeAsOf(sendOptions.asOf);
|
|
669
717
|
assertTimeArgs(this.project.agent.tools, frozenAsOf);
|
|
670
|
-
|
|
718
|
+
const record = {
|
|
671
719
|
sessionId: (_e = sendOptions.hostedSessionId) !== null && _e !== void 0 ? _e : newSessionId(),
|
|
672
720
|
channelId,
|
|
673
721
|
mode: (_f = sendOptions.mode) !== null && _f !== void 0 ? _f : "chat",
|
|
@@ -696,7 +744,6 @@ export class SessionEngine {
|
|
|
696
744
|
dryRun: record.dryRun === true ? true : undefined,
|
|
697
745
|
},
|
|
698
746
|
});
|
|
699
|
-
record = yield this.enrollABs(record);
|
|
700
747
|
const since = (yield this.logs.get(record.sessionId)).count;
|
|
701
748
|
yield this.startTurn(record.sessionId, message, Object.assign({ admission: (_h = sendOptions.admission) !== null && _h !== void 0 ? _h : "preempt" }, (sendOptions.coalesceSourceTs === undefined
|
|
702
749
|
? {}
|
|
@@ -714,7 +761,7 @@ export class SessionEngine {
|
|
|
714
761
|
const stale = new Error("stale HTTP continuation");
|
|
715
762
|
let previous;
|
|
716
763
|
try {
|
|
717
|
-
yield this.updateRecord(sessionId,
|
|
764
|
+
yield this.updateRecord(sessionId, record => {
|
|
718
765
|
var _a;
|
|
719
766
|
const expectedChannel = record.httpContinuationKey === undefined
|
|
720
767
|
? record.channelId
|
|
@@ -738,7 +785,7 @@ export class SessionEngine {
|
|
|
738
785
|
return next;
|
|
739
786
|
}
|
|
740
787
|
catch (error) {
|
|
741
|
-
yield this.updateRecord(sessionId,
|
|
788
|
+
yield this.updateRecord(sessionId, record => record.httpContinuationKey === next
|
|
742
789
|
? Object.assign(Object.assign({}, record), { httpContinuationKey: previous }) : record);
|
|
743
790
|
throw error;
|
|
744
791
|
}
|
|
@@ -754,85 +801,6 @@ export class SessionEngine {
|
|
|
754
801
|
return existing !== undefined;
|
|
755
802
|
});
|
|
756
803
|
}
|
|
757
|
-
/**
|
|
758
|
-
* Sticky A/B enrollment at session creation — before the first turn, so
|
|
759
|
-
* variants are in the durable stream (and on {@link SessionRecord.abs})
|
|
760
|
-
* ahead of model/instructions work. Failures persist as `variant: null`
|
|
761
|
-
* (sticky skip). Eval harness sessions (`purpose: "eval"`) are never
|
|
762
|
-
* enrolled.
|
|
763
|
-
*/
|
|
764
|
-
enrollABs(record) {
|
|
765
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
766
|
-
if (!this.abCollector.enabled || record.purpose === "eval") {
|
|
767
|
-
return record;
|
|
768
|
-
}
|
|
769
|
-
const sessionInfo = this.sessionInfo(record);
|
|
770
|
-
const abs = {};
|
|
771
|
-
for (const experiment of this.project.abs) {
|
|
772
|
-
const def = experiment.definition;
|
|
773
|
-
const variantKeys = Object.keys(def.variants);
|
|
774
|
-
let variant = null;
|
|
775
|
-
try {
|
|
776
|
-
variant = yield resolveABSplit(def.split, {
|
|
777
|
-
agent: { name: this.project.name },
|
|
778
|
-
channel: { id: record.channelId },
|
|
779
|
-
session: sessionInfo,
|
|
780
|
-
experiment: experiment.name,
|
|
781
|
-
variants: variantKeys,
|
|
782
|
-
});
|
|
783
|
-
if (variant !== null && !(variant in def.variants)) {
|
|
784
|
-
throw new Error(`split resolved to ${JSON.stringify(variant)}; expected one of ${variantKeys.join(", ")} or null to skip`);
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
catch (error) {
|
|
788
|
-
this.logger(`[agent-sdk] ab "${experiment.name}" enrollment failed (sticky skip): ${describeError(error)}`);
|
|
789
|
-
variant = null;
|
|
790
|
-
}
|
|
791
|
-
abs[experiment.name] = variant;
|
|
792
|
-
yield this.appendEvent(record.sessionId, {
|
|
793
|
-
type: "ab.assigned",
|
|
794
|
-
data: { experiment: experiment.name, variant },
|
|
795
|
-
});
|
|
796
|
-
}
|
|
797
|
-
return this.updateRecord(record.sessionId, (current) => (Object.assign(Object.assign({}, current), { abs })));
|
|
798
|
-
});
|
|
799
|
-
}
|
|
800
|
-
/**
|
|
801
|
-
* Ensure {@link SessionRecord.abs} is populated (hydrate from the durable
|
|
802
|
-
* `ab.assigned` stream when missing — e.g. older sessions after upgrade).
|
|
803
|
-
*/
|
|
804
|
-
ensureAbs(record) {
|
|
805
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
806
|
-
if (record.abs !== undefined || record.purpose === "eval") {
|
|
807
|
-
return record;
|
|
808
|
-
}
|
|
809
|
-
if (!this.abCollector.enabled) {
|
|
810
|
-
return record;
|
|
811
|
-
}
|
|
812
|
-
const events = yield this.listEvents(record.sessionId, 0);
|
|
813
|
-
const folded = foldABStream(events);
|
|
814
|
-
if (folded.arms.size === 0) {
|
|
815
|
-
return record;
|
|
816
|
-
}
|
|
817
|
-
const abs = Object.fromEntries(folded.arms);
|
|
818
|
-
return this.updateRecord(record.sessionId, (current) => (Object.assign(Object.assign({}, current), { abs })));
|
|
819
|
-
});
|
|
820
|
-
}
|
|
821
|
-
/**
|
|
822
|
-
* Agent config for this session: base project agent plus any per-variant
|
|
823
|
-
* `instructions` overlays from enrolled A/B arms.
|
|
824
|
-
*/
|
|
825
|
-
agentForSession(record) {
|
|
826
|
-
const base = this.project.agent;
|
|
827
|
-
const instructions = mergeABInstructions(base.instructions, record.abs, this.project.abs.map((experiment) => ({
|
|
828
|
-
name: experiment.name,
|
|
829
|
-
definition: experiment.definition,
|
|
830
|
-
})));
|
|
831
|
-
if (instructions === base.instructions) {
|
|
832
|
-
return base;
|
|
833
|
-
}
|
|
834
|
-
return Object.assign(Object.assign({}, base), { instructions });
|
|
835
|
-
}
|
|
836
804
|
/** Look up a session as a channel-scoped handle. */
|
|
837
805
|
getChannelSession(channelId, sessionId) {
|
|
838
806
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -880,6 +848,45 @@ export class SessionEngine {
|
|
|
880
848
|
// ==========================================================================
|
|
881
849
|
// Turn execution
|
|
882
850
|
// ==========================================================================
|
|
851
|
+
/**
|
|
852
|
+
* Repaint on the follow-up wake without retargeting the live turn.
|
|
853
|
+
* Persist already took the refresh; in-flight writes stay on the carrier ts.
|
|
854
|
+
*/
|
|
855
|
+
repaintOnCoalescedRefresh(sessionId, patch) {
|
|
856
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
857
|
+
var _a;
|
|
858
|
+
var _b;
|
|
859
|
+
const live = this.liveTurns.get(sessionId);
|
|
860
|
+
if (live === undefined || patch === undefined) {
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
const repaintState = (_b = mergeChannelStateSkipNull(live.channelState, patch)) !== null && _b !== void 0 ? _b : live.channelState;
|
|
864
|
+
const record = yield this.sessions.get(sessionId);
|
|
865
|
+
if (record === undefined) {
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
const handler = (_a = this.channelEventHandlersFor(record.channelId)) === null || _a === void 0 ? void 0 : _a["message.received"];
|
|
869
|
+
if (handler === undefined) {
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
yield handler({
|
|
873
|
+
type: "message.received",
|
|
874
|
+
data: { text: "" },
|
|
875
|
+
index: 0,
|
|
876
|
+
sessionId,
|
|
877
|
+
at: new Date().toISOString(),
|
|
878
|
+
}, {
|
|
879
|
+
channelId: record.channelId,
|
|
880
|
+
state: repaintState,
|
|
881
|
+
continuationToken: record.continuationKey,
|
|
882
|
+
setContinuationToken: (token) => this.setContinuationToken(sessionId, token),
|
|
883
|
+
}, {
|
|
884
|
+
session: live.session,
|
|
885
|
+
host: this.hostForSession(sessionId),
|
|
886
|
+
artifacts: this.artifactsApi({ sessionId }),
|
|
887
|
+
});
|
|
888
|
+
});
|
|
889
|
+
}
|
|
883
890
|
/**
|
|
884
891
|
* Admit a turn for `sessionId`.
|
|
885
892
|
*
|
|
@@ -898,7 +905,12 @@ export class SessionEngine {
|
|
|
898
905
|
.catch(() => { })
|
|
899
906
|
.then(() => __awaiter(this, void 0, void 0, function* () {
|
|
900
907
|
// Another server holds the turn: hand the message to it and coalesce.
|
|
908
|
+
// Enqueue-only must not report coalesced success without a local
|
|
909
|
+
// enqueue — the outbox drain may never run on this process.
|
|
901
910
|
if (yield this.turnLeases.runningElsewhere(sessionId)) {
|
|
911
|
+
if (options.hostedEnqueueOnly === true) {
|
|
912
|
+
throw new HostedEnqueueNotActiveError(sessionId);
|
|
913
|
+
}
|
|
902
914
|
yield this.outbox.post(sessionId, { message, options });
|
|
903
915
|
return true;
|
|
904
916
|
}
|
|
@@ -911,7 +923,7 @@ export class SessionEngine {
|
|
|
911
923
|
drainOutbox(sessionId) {
|
|
912
924
|
void this.outbox
|
|
913
925
|
.takeAll(sessionId)
|
|
914
|
-
.then(
|
|
926
|
+
.then(items => {
|
|
915
927
|
for (const item of items) {
|
|
916
928
|
void this.startTurn(sessionId, item.message, item.options).catch(() => { });
|
|
917
929
|
}
|
|
@@ -922,7 +934,7 @@ export class SessionEngine {
|
|
|
922
934
|
var _a;
|
|
923
935
|
const queue = (_a = this.coalesceQueues.get(sessionId)) !== null && _a !== void 0 ? _a : [];
|
|
924
936
|
if (item.sourceTs !== undefined &&
|
|
925
|
-
queue.some(
|
|
937
|
+
queue.some(entry => entry.sourceTs === item.sourceTs)) {
|
|
926
938
|
return;
|
|
927
939
|
}
|
|
928
940
|
queue.push(item);
|
|
@@ -992,7 +1004,7 @@ export class SessionEngine {
|
|
|
992
1004
|
}
|
|
993
1005
|
const parts = [
|
|
994
1006
|
"<slack_followups>",
|
|
995
|
-
|
|
1007
|
+
`${items.length} asks arrived while you were busy.`,
|
|
996
1008
|
"",
|
|
997
1009
|
];
|
|
998
1010
|
for (let i = 0; i < items.length; i++) {
|
|
@@ -1075,10 +1087,19 @@ export class SessionEngine {
|
|
|
1075
1087
|
// enqueue: `drainCoalescedFollowups` reads only this process's queue, so
|
|
1076
1088
|
// the shared nudge store is the carrier. Not redundant with `acquire`
|
|
1077
1089
|
// below — this returns before preempt's `clearCoalesced` drops the queue.
|
|
1090
|
+
// Enqueue-only cannot claim coalesced here: nothing joined a local turn.
|
|
1078
1091
|
if (yield this.turnLeases.runningElsewhere(sessionId)) {
|
|
1092
|
+
if (options.hostedEnqueueOnly === true) {
|
|
1093
|
+
throw new HostedEnqueueNotActiveError(sessionId);
|
|
1094
|
+
}
|
|
1079
1095
|
this.logger(`[session] coalesce; another server owns ${sessionId}`);
|
|
1080
1096
|
return true;
|
|
1081
1097
|
}
|
|
1098
|
+
// Enqueue-only must never start a turn (or preempt/interrupt). Steer and
|
|
1099
|
+
// coalesce above already returned true when they absorbed the message.
|
|
1100
|
+
if (options.hostedEnqueueOnly === true) {
|
|
1101
|
+
throw new HostedEnqueueNotActiveError(sessionId);
|
|
1102
|
+
}
|
|
1082
1103
|
// Interrupt any turn in flight and wait for it to settle so the SDK run is
|
|
1083
1104
|
// terminal before this turn's send (the follow-up also force-expires as a
|
|
1084
1105
|
// belt-and-suspenders — see buildTurnRequest). Drain-resume skips interrupt:
|
|
@@ -1107,9 +1128,7 @@ export class SessionEngine {
|
|
|
1107
1128
|
this.pendingTurns.add(sessionId);
|
|
1108
1129
|
let lifecycleInstalled = false;
|
|
1109
1130
|
try {
|
|
1110
|
-
|
|
1111
|
-
// Arms must be on the record before tools/instructions see SessionInfo.
|
|
1112
|
-
record = yield this.ensureAbs(record);
|
|
1131
|
+
const record = yield this.updateRecord(sessionId, current => (Object.assign(Object.assign({}, current), { turnCount: current.turnCount + 1 })));
|
|
1113
1132
|
const turnId = `turn_${record.turnCount}`;
|
|
1114
1133
|
const isFirstTurn = record.turnCount === 1;
|
|
1115
1134
|
yield this.appendEvent(sessionId, {
|
|
@@ -1146,6 +1165,7 @@ export class SessionEngine {
|
|
|
1146
1165
|
}
|
|
1147
1166
|
finally {
|
|
1148
1167
|
clearInterval(poll);
|
|
1168
|
+
this.liveTurns.delete(sessionId);
|
|
1149
1169
|
}
|
|
1150
1170
|
this.lastOutcomes.set(sessionId, outcome);
|
|
1151
1171
|
const wasCurrent = this.activeTurns.get(sessionId) === lifecycle;
|
|
@@ -1155,8 +1175,13 @@ export class SessionEngine {
|
|
|
1155
1175
|
if (this.turnAborts.get(sessionId) === abort) {
|
|
1156
1176
|
this.turnAborts.delete(sessionId);
|
|
1157
1177
|
}
|
|
1158
|
-
|
|
1159
|
-
|
|
1178
|
+
// Failed/cancelled owners must not start a coalesced successor.
|
|
1179
|
+
// Hosted execute would then 503 and Temporal/FIFO would re-run the
|
|
1180
|
+
// same follow-ups as full deliveries.
|
|
1181
|
+
if (wasCurrent &&
|
|
1182
|
+
!abort.signal.aborted &&
|
|
1183
|
+
outcome.status === "finished") {
|
|
1184
|
+
const drain = this.drainCoalescedFollowups(sessionId).catch(error => {
|
|
1160
1185
|
this.logger(`[session] coalesce drain failed for ${sessionId}: ${describeError(error)}`);
|
|
1161
1186
|
});
|
|
1162
1187
|
this.coalesceDrains.set(sessionId, drain);
|
|
@@ -1380,7 +1405,7 @@ export class SessionEngine {
|
|
|
1380
1405
|
if (turn === undefined) {
|
|
1381
1406
|
return tools;
|
|
1382
1407
|
}
|
|
1383
|
-
return tools.map(
|
|
1408
|
+
return tools.map(tool => {
|
|
1384
1409
|
const execute = tool.definition.execute;
|
|
1385
1410
|
if (typeof execute !== "function") {
|
|
1386
1411
|
return tool;
|
|
@@ -1538,6 +1563,14 @@ export class SessionEngine {
|
|
|
1538
1563
|
* Best effort — warming is an optimization, and a turn rebuilds on its own.
|
|
1539
1564
|
*/
|
|
1540
1565
|
prewarmSharedWorkspace() {
|
|
1566
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1567
|
+
if (this.sharedWarm === undefined) {
|
|
1568
|
+
this.sharedWarm = this.warmSharedWorkspace();
|
|
1569
|
+
}
|
|
1570
|
+
yield this.sharedWarm;
|
|
1571
|
+
});
|
|
1572
|
+
}
|
|
1573
|
+
warmSharedWorkspace() {
|
|
1541
1574
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1542
1575
|
var _a, _b;
|
|
1543
1576
|
const agent = this.project.agent;
|
|
@@ -1550,6 +1583,15 @@ export class SessionEngine {
|
|
|
1550
1583
|
}
|
|
1551
1584
|
const startedAt = Date.now();
|
|
1552
1585
|
try {
|
|
1586
|
+
yield mkdir(workspaceDir, { recursive: true });
|
|
1587
|
+
if (yield ownSharedHarness(workspaceDir)) {
|
|
1588
|
+
yield materializeWorkspace({
|
|
1589
|
+
agent,
|
|
1590
|
+
workspaceDir,
|
|
1591
|
+
seed: true,
|
|
1592
|
+
stateRoot: this.stateRoot,
|
|
1593
|
+
});
|
|
1594
|
+
}
|
|
1553
1595
|
const harness = resolveHostHarnessToolOptions(agent.allowedTools);
|
|
1554
1596
|
const outcome = yield this.runner.prewarm(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ workspaceDir, runnerStateDir: join(this.stateRoot, "runner"), sandbox: ((_b = agent.local) === null || _b === void 0 ? void 0 : _b.sandbox) === true }, (harness.tools === undefined ? {} : { tools: harness.tools })), (harness.disallowedTools === undefined
|
|
1555
1597
|
? {}
|
|
@@ -1557,7 +1599,8 @@ export class SessionEngine {
|
|
|
1557
1599
|
// No session yet, so auth'd connections are omitted rather than
|
|
1558
1600
|
// warmed without an identity; the per-send flag still has to match
|
|
1559
1601
|
// the turns' requests or the warmed executor is one no turn asks for.
|
|
1560
|
-
mcpServers: this.buildMcpServers("local") }), (this.hasAttachedAuthedConnections()
|
|
1602
|
+
mcpServers: this.buildMcpServers("local") }), (this.hasAttachedAuthedConnections() ||
|
|
1603
|
+
this.project.agent.connections.some(connection => isCursorAccountTransport(connection.transport))
|
|
1561
1604
|
? { perSendMcpServers: true }
|
|
1562
1605
|
: {})), { subagents: buildRunnerSubagents(agent) }), (agent.model === undefined ? {} : { model: agent.model })));
|
|
1563
1606
|
// Report what happened rather than that the call returned: a runner
|
|
@@ -1581,15 +1624,17 @@ export class SessionEngine {
|
|
|
1581
1624
|
}
|
|
1582
1625
|
executeTurn(record, turnId, message, isFirstTurn, signal) {
|
|
1583
1626
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1584
|
-
var _a
|
|
1627
|
+
var _a;
|
|
1628
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1585
1629
|
const sessionId = record.sessionId;
|
|
1586
1630
|
const workspaceDir = this.scaffoldDir(record);
|
|
1587
1631
|
const harnessCwd = this.harnessCwd(record);
|
|
1588
|
-
const turnChannelState = structuredClone((
|
|
1632
|
+
const turnChannelState = structuredClone((_b = record.channelState) !== null && _b !== void 0 ? _b : null);
|
|
1589
1633
|
const eventContext = {
|
|
1590
1634
|
channelState: structuredClone(turnChannelState),
|
|
1591
1635
|
session: this.sessionInfo(record),
|
|
1592
1636
|
};
|
|
1637
|
+
this.liveTurns.set(sessionId, eventContext);
|
|
1593
1638
|
// Hold the open log so tool events append synchronously. Fire-and-forget
|
|
1594
1639
|
// `appendEvent` races parallel tool completions and delays the live stream
|
|
1595
1640
|
// until the next await tick — often after *all* parallel tools finish.
|
|
@@ -1606,7 +1651,7 @@ export class SessionEngine {
|
|
|
1606
1651
|
// Read by closure, so the mapper still sees it while draining after the
|
|
1607
1652
|
// registry entry below is gone.
|
|
1608
1653
|
const stubbed = new Set();
|
|
1609
|
-
const mapper = new TurnEventMapper(emit,
|
|
1654
|
+
const mapper = new TurnEventMapper(emit, callId => stubbed.has(callId));
|
|
1610
1655
|
// Take a turn slot before any work happens. When every slot is busy the
|
|
1611
1656
|
// turn waits FIFO — durable `turn.queued` marks the wait — and a
|
|
1612
1657
|
// preempting follow-up (or interrupt) resolves the wait as cancelled
|
|
@@ -1614,7 +1659,7 @@ export class SessionEngine {
|
|
|
1614
1659
|
const permit = yield this.turnGovernor.acquire({
|
|
1615
1660
|
sessionId,
|
|
1616
1661
|
signal,
|
|
1617
|
-
onQueued:
|
|
1662
|
+
onQueued: position => {
|
|
1618
1663
|
var _a;
|
|
1619
1664
|
const maxRunningTurns = (_a = this.turnGovernor.maxRunningTurns) !== null && _a !== void 0 ? _a : 0;
|
|
1620
1665
|
emit({ type: "turn.queued", data: { position, maxRunningTurns } });
|
|
@@ -1629,13 +1674,15 @@ export class SessionEngine {
|
|
|
1629
1674
|
else {
|
|
1630
1675
|
emit({ type: "turn.started", data: {} });
|
|
1631
1676
|
try {
|
|
1677
|
+
if (record.workspaceOverride === undefined &&
|
|
1678
|
+
((_a = this.project.agent.local) === null || _a === void 0 ? void 0 : _a.workspaceDir) !== undefined) {
|
|
1679
|
+
yield this.prewarmSharedWorkspace();
|
|
1680
|
+
}
|
|
1632
1681
|
// Scaffold agent files into the session workspace even when the harness
|
|
1633
|
-
// cwd is overridden (e.g. a PR worktree).
|
|
1634
|
-
// overlays are applied via agentForSession.
|
|
1635
|
-
const agent = this.agentForSession(record);
|
|
1682
|
+
// cwd is overridden (e.g. a PR worktree).
|
|
1636
1683
|
if (!this.hasRootOverride()) {
|
|
1637
1684
|
yield materializeWorkspace({
|
|
1638
|
-
agent,
|
|
1685
|
+
agent: this.project.agent,
|
|
1639
1686
|
workspaceDir,
|
|
1640
1687
|
seed: isFirstTurn,
|
|
1641
1688
|
stateRoot: this.stateRoot,
|
|
@@ -1657,14 +1704,14 @@ export class SessionEngine {
|
|
|
1657
1704
|
const pendingFiles = record.pendingWorkspaceFiles;
|
|
1658
1705
|
const pendingImages = record.pendingImages;
|
|
1659
1706
|
const runtime = resolveSessionRuntime({
|
|
1660
|
-
agentRuntime: agent.runtime,
|
|
1707
|
+
agentRuntime: this.project.agent.runtime,
|
|
1661
1708
|
cloudOverride: record.cloudOverride,
|
|
1662
1709
|
});
|
|
1663
1710
|
const hasPendingFiles = pendingFiles !== undefined && Object.keys(pendingFiles).length > 0;
|
|
1664
1711
|
if (hasPendingFiles && runtime !== "cloud") {
|
|
1665
1712
|
const root = yield this.resolveFileSystem({
|
|
1666
1713
|
sessionId,
|
|
1667
|
-
continuationKey: (
|
|
1714
|
+
continuationKey: (_c = record.continuationKey) !== null && _c !== void 0 ? _c : undefined,
|
|
1668
1715
|
cache: true,
|
|
1669
1716
|
cwd: harnessCwd,
|
|
1670
1717
|
});
|
|
@@ -1672,7 +1719,7 @@ export class SessionEngine {
|
|
|
1672
1719
|
}
|
|
1673
1720
|
if ((hasPendingFiles && runtime !== "cloud") ||
|
|
1674
1721
|
(pendingImages !== undefined && pendingImages.length > 0)) {
|
|
1675
|
-
yield this.updateRecord(sessionId,
|
|
1722
|
+
yield this.updateRecord(sessionId, current => (Object.assign(Object.assign({}, current), { pendingWorkspaceFiles: hasPendingFiles &&
|
|
1676
1723
|
runtime !== "cloud" &&
|
|
1677
1724
|
current.pendingWorkspaceFiles === pendingFiles
|
|
1678
1725
|
? undefined
|
|
@@ -1680,15 +1727,7 @@ export class SessionEngine {
|
|
|
1680
1727
|
? undefined
|
|
1681
1728
|
: current.pendingImages })));
|
|
1682
1729
|
}
|
|
1683
|
-
|
|
1684
|
-
// workspace is its own project root. When the harness cwd is borrowed
|
|
1685
|
-
// (PR worktree, shared checkout) the scaffold lands elsewhere, and a
|
|
1686
|
-
// workspace nested inside a git repo re-roots harness rules at that
|
|
1687
|
-
// repo — in both cases deliver instructions inline on the first turn.
|
|
1688
|
-
const instructionsInvisibleToHarness = isFirstTurn &&
|
|
1689
|
-
(this.hasBorrowedWorkspace(record) ||
|
|
1690
|
-
(yield isNestedInGitRepo(harnessCwd)));
|
|
1691
|
-
const request = yield this.buildTurnRequest(record, agent, turnId, message, isFirstTurn, instructionsInvisibleToHarness, emit, eventContext, (update) => __awaiter(this, void 0, void 0, function* () {
|
|
1730
|
+
const onUpdate = (update) => __awaiter(this, void 0, void 0, function* () {
|
|
1692
1731
|
const turn = this.turnRoots.get(sessionId);
|
|
1693
1732
|
if (turn !== undefined) {
|
|
1694
1733
|
update = yield applyWebScratchUpdate({
|
|
@@ -1710,11 +1749,26 @@ export class SessionEngine {
|
|
|
1710
1749
|
yield this.emitDeliveredNudges(record, emit);
|
|
1711
1750
|
yield yieldEventLoop();
|
|
1712
1751
|
}
|
|
1713
|
-
})
|
|
1752
|
+
});
|
|
1753
|
+
const request = yield this.buildTurnRequest(record, turnId, message, isFirstTurn, emit, eventContext, onUpdate, signal, pendingImages);
|
|
1714
1754
|
this.activeToolContexts.set(sessionId, { record, turnId, emit });
|
|
1715
1755
|
this.stubbedCallIds.set(sessionId, stubbed);
|
|
1716
1756
|
try {
|
|
1717
1757
|
outcome = yield this.runTurnExecute(record, turnId, () => this.runner.runTurn(request));
|
|
1758
|
+
// Commit before dropping the turn FS so `ctx.reject` can
|
|
1759
|
+
// re-run the model with tools still mounted.
|
|
1760
|
+
outcome = yield this.settleAuthoredResult({
|
|
1761
|
+
record,
|
|
1762
|
+
turnId,
|
|
1763
|
+
emit,
|
|
1764
|
+
eventContext,
|
|
1765
|
+
turnChannelState,
|
|
1766
|
+
harnessCwd,
|
|
1767
|
+
signal,
|
|
1768
|
+
onUpdate,
|
|
1769
|
+
mapper,
|
|
1770
|
+
outcome,
|
|
1771
|
+
});
|
|
1718
1772
|
}
|
|
1719
1773
|
finally {
|
|
1720
1774
|
this.activeToolContexts.delete(sessionId);
|
|
@@ -1745,47 +1799,22 @@ export class SessionEngine {
|
|
|
1745
1799
|
mapper.finish();
|
|
1746
1800
|
if (mapper.title !== undefined) {
|
|
1747
1801
|
const title = mapper.title;
|
|
1748
|
-
yield this.updateRecord(sessionId,
|
|
1802
|
+
yield this.updateRecord(sessionId, current => (Object.assign(Object.assign({}, current), { title })));
|
|
1749
1803
|
eventContext.session = Object.assign(Object.assign({}, eventContext.session), { title });
|
|
1750
1804
|
}
|
|
1751
|
-
const finalResult = (
|
|
1752
|
-
const finalUsage = (
|
|
1805
|
+
const finalResult = (_d = outcome.result) !== null && _d !== void 0 ? _d : mapper.finalText;
|
|
1806
|
+
const finalUsage = (_e = outcome.usage) !== null && _e !== void 0 ? _e : mapper.usage;
|
|
1753
1807
|
const finalCost = finalUsage === undefined
|
|
1754
1808
|
? undefined
|
|
1755
1809
|
: yield this.estimateTurnCost({
|
|
1756
|
-
model: (
|
|
1810
|
+
model: (_f = this.project.agent.model) !== null && _f !== void 0 ? _f : DEFAULT_MODEL,
|
|
1757
1811
|
usage: finalUsage,
|
|
1758
1812
|
agentId: record.sdkAgentId,
|
|
1759
|
-
conversationId: (
|
|
1813
|
+
conversationId: (_g = record.sdkAgentId) !== null && _g !== void 0 ? _g : sessionId,
|
|
1760
1814
|
});
|
|
1761
1815
|
if (finalCost !== undefined) {
|
|
1762
1816
|
outcome = Object.assign(Object.assign({}, outcome), { cost: finalCost });
|
|
1763
1817
|
}
|
|
1764
|
-
const authored = this.project.result;
|
|
1765
|
-
if (outcome.status === "finished" && authored !== undefined) {
|
|
1766
|
-
const settled = yield applyAuthoredResult({
|
|
1767
|
-
definition: authored,
|
|
1768
|
-
text: finalResult,
|
|
1769
|
-
dryRun: record.dryRun === true,
|
|
1770
|
-
ctx: {
|
|
1771
|
-
session: eventContext.session,
|
|
1772
|
-
channelState: turnChannelState,
|
|
1773
|
-
host: this.hostForSession(sessionId),
|
|
1774
|
-
artifacts: this.artifactsApi({ sessionId, turnId }),
|
|
1775
|
-
stateRoot: this.stateRoot,
|
|
1776
|
-
workspaceDir: harnessCwd,
|
|
1777
|
-
},
|
|
1778
|
-
});
|
|
1779
|
-
if (!settled.ok) {
|
|
1780
|
-
outcome = {
|
|
1781
|
-
status: "error",
|
|
1782
|
-
result: finalResult,
|
|
1783
|
-
errorMessage: `turn output failed: ${settled.message}`,
|
|
1784
|
-
usage: finalUsage,
|
|
1785
|
-
cost: finalCost,
|
|
1786
|
-
};
|
|
1787
|
-
}
|
|
1788
|
-
}
|
|
1789
1818
|
if (outcome.status === "finished") {
|
|
1790
1819
|
yield this.appendEvent(sessionId, {
|
|
1791
1820
|
type: "turn.completed",
|
|
@@ -1806,21 +1835,21 @@ export class SessionEngine {
|
|
|
1806
1835
|
status: outcome.status,
|
|
1807
1836
|
message: interrupted
|
|
1808
1837
|
? "turn interrupted"
|
|
1809
|
-
: ((
|
|
1838
|
+
: ((_h = outcome.errorMessage) !== null && _h !== void 0 ? _h : (outcome.status === "cancelled"
|
|
1810
1839
|
? "turn cancelled"
|
|
1811
1840
|
: "turn failed")),
|
|
1812
1841
|
},
|
|
1813
1842
|
}, eventContext);
|
|
1814
1843
|
}
|
|
1815
1844
|
const current = yield this.sessions.get(sessionId);
|
|
1816
|
-
const mode = (
|
|
1845
|
+
const mode = (_j = current === null || current === void 0 ? void 0 : current.mode) !== null && _j !== void 0 ? _j : record.mode;
|
|
1817
1846
|
if (mode === "task") {
|
|
1818
1847
|
yield this.appendEvent(sessionId, outcome.status === "finished"
|
|
1819
1848
|
? { type: "session.completed", turnId, data: {} }
|
|
1820
1849
|
: {
|
|
1821
1850
|
type: "session.failed",
|
|
1822
1851
|
turnId,
|
|
1823
|
-
data: { message: (
|
|
1852
|
+
data: { message: (_k = outcome.errorMessage) !== null && _k !== void 0 ? _k : "task failed" },
|
|
1824
1853
|
}, eventContext);
|
|
1825
1854
|
yield this.wipeCloudSessionWorkspace(sessionId);
|
|
1826
1855
|
}
|
|
@@ -1834,6 +1863,65 @@ export class SessionEngine {
|
|
|
1834
1863
|
return Object.assign(Object.assign({}, outcome), { result: finalResult, usage: finalUsage });
|
|
1835
1864
|
});
|
|
1836
1865
|
}
|
|
1866
|
+
/**
|
|
1867
|
+
* Run `defineResult` while the turn FS and tools are still up.
|
|
1868
|
+
* `ctx.reject` re-invokes `runTurn` on this turnId until commit
|
|
1869
|
+
* succeeds, throws, or the repair budget is gone.
|
|
1870
|
+
*/
|
|
1871
|
+
settleAuthoredResult(args) {
|
|
1872
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1873
|
+
var _a;
|
|
1874
|
+
const authored = this.project.result;
|
|
1875
|
+
if (args.outcome.status !== "finished" || authored === undefined) {
|
|
1876
|
+
return args.outcome;
|
|
1877
|
+
}
|
|
1878
|
+
let outcome = args.outcome;
|
|
1879
|
+
let usage = outcome.usage;
|
|
1880
|
+
let repairs = 0;
|
|
1881
|
+
while (true) {
|
|
1882
|
+
const settled = yield applyAuthoredResult({
|
|
1883
|
+
definition: authored,
|
|
1884
|
+
text: (_a = outcome.result) !== null && _a !== void 0 ? _a : args.mapper.pendingText,
|
|
1885
|
+
dryRun: args.record.dryRun === true,
|
|
1886
|
+
ctx: {
|
|
1887
|
+
session: args.eventContext.session,
|
|
1888
|
+
channelState: args.turnChannelState,
|
|
1889
|
+
host: this.hostForSession(args.record.sessionId),
|
|
1890
|
+
artifacts: this.artifactsApi({
|
|
1891
|
+
sessionId: args.record.sessionId,
|
|
1892
|
+
turnId: args.turnId,
|
|
1893
|
+
}),
|
|
1894
|
+
stateRoot: this.stateRoot,
|
|
1895
|
+
workspaceDir: args.harnessCwd,
|
|
1896
|
+
},
|
|
1897
|
+
});
|
|
1898
|
+
if (settled.ok) {
|
|
1899
|
+
return Object.assign(Object.assign({}, outcome), { result: settled.text, usage });
|
|
1900
|
+
}
|
|
1901
|
+
if (settled.kind === "error" || repairs >= RESULT_REPAIR_BUDGET) {
|
|
1902
|
+
return {
|
|
1903
|
+
status: "error",
|
|
1904
|
+
result: outcome.result,
|
|
1905
|
+
errorMessage: `turn output failed: ${settled.message}`,
|
|
1906
|
+
usage,
|
|
1907
|
+
};
|
|
1908
|
+
}
|
|
1909
|
+
repairs += 1;
|
|
1910
|
+
// Close the rejected stream without posting it (empty `stop`)
|
|
1911
|
+
// so Slack does not append a repair onto that block, and so an
|
|
1912
|
+
// empty repair cannot recommit `lastAssistantText`.
|
|
1913
|
+
args.mapper.abandonPendingText();
|
|
1914
|
+
this.logger(`[session] ${args.record.sessionId} ${args.turnId} result rejected; repairing (${repairs}/${RESULT_REPAIR_BUDGET})`);
|
|
1915
|
+
const repairRequest = yield this.buildTurnRequest(args.record, args.turnId, resultRepairPrompt(settled.message), false, args.emit, args.eventContext, args.onUpdate, args.signal);
|
|
1916
|
+
const repaired = yield this.runTurnExecute(args.record, args.turnId, () => this.runner.runTurn(repairRequest));
|
|
1917
|
+
usage = addTurnUsage(usage, repaired.usage);
|
|
1918
|
+
if (repaired.status !== "finished") {
|
|
1919
|
+
return Object.assign(Object.assign({}, repaired), { usage });
|
|
1920
|
+
}
|
|
1921
|
+
outcome = Object.assign(Object.assign({}, repaired), { usage });
|
|
1922
|
+
}
|
|
1923
|
+
});
|
|
1924
|
+
}
|
|
1837
1925
|
/**
|
|
1838
1926
|
* Sync authored skills onto the Agent Store at `skills/<name>/…` (hosted)
|
|
1839
1927
|
* or `agent-serve/<agent>/skills/<name>/…` (personal-key local+cloud)
|
|
@@ -1912,7 +2000,7 @@ export class SessionEngine {
|
|
|
1912
2000
|
}
|
|
1913
2001
|
clearPendingWorkspaceFiles(sessionId, pending) {
|
|
1914
2002
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1915
|
-
yield this.updateRecord(sessionId,
|
|
2003
|
+
yield this.updateRecord(sessionId, current => (Object.assign(Object.assign({}, current), { pendingWorkspaceFiles: current.pendingWorkspaceFiles === pending
|
|
1916
2004
|
? undefined
|
|
1917
2005
|
: current.pendingWorkspaceFiles })));
|
|
1918
2006
|
});
|
|
@@ -1934,7 +2022,7 @@ export class SessionEngine {
|
|
|
1934
2022
|
if (inFlight !== undefined) {
|
|
1935
2023
|
return inFlight;
|
|
1936
2024
|
}
|
|
1937
|
-
let sync = run().then(() => true,
|
|
2025
|
+
let sync = run().then(() => true, error => {
|
|
1938
2026
|
this.logger(`[${surface}] ${store.label} sync failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
1939
2027
|
return false;
|
|
1940
2028
|
});
|
|
@@ -1949,11 +2037,17 @@ export class SessionEngine {
|
|
|
1949
2037
|
/**
|
|
1950
2038
|
* Hosted deployments own the deployment store. Local `serve`/`run` with
|
|
1951
2039
|
* a personal API key writes into the USER store under `agent-serve/`.
|
|
2040
|
+
* A persistent deployment's version container has no cloud store at all:
|
|
2041
|
+
* its state directory is the durable copy, and its service-account key
|
|
2042
|
+
* must not be mistaken for a personal one.
|
|
1952
2043
|
*/
|
|
1953
2044
|
cloudStore() {
|
|
1954
2045
|
const v2Hosting = resolveAgentV2Hosting({
|
|
1955
2046
|
architecture: this.project.agent.architecture,
|
|
1956
2047
|
});
|
|
2048
|
+
if (v2Hosting.kind === "cursor-managed-persistent") {
|
|
2049
|
+
return undefined;
|
|
2050
|
+
}
|
|
1957
2051
|
const deployment = {
|
|
1958
2052
|
mountPath: DEPLOYMENT_STORE_MOUNT_PATH,
|
|
1959
2053
|
skillsPrefix: agentStoreKeys.skillsPrefix(),
|
|
@@ -1983,10 +2077,11 @@ export class SessionEngine {
|
|
|
1983
2077
|
}
|
|
1984
2078
|
return undefined;
|
|
1985
2079
|
}
|
|
1986
|
-
buildTurnRequest(record,
|
|
2080
|
+
buildTurnRequest(record, turnId, prompt, isFirstTurn, emit, eventContext, onUpdate, signal, images) {
|
|
1987
2081
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1988
2082
|
var _a, _b, _c;
|
|
1989
2083
|
var _d;
|
|
2084
|
+
const agent = this.project.agent;
|
|
1990
2085
|
// Per-session cloud attach (channel/tool handoff) forces cloud runtime
|
|
1991
2086
|
// even when the agent defaults to local for chat server tools.
|
|
1992
2087
|
const runtime = resolveSessionRuntime({
|
|
@@ -2016,7 +2111,7 @@ export class SessionEngine {
|
|
|
2016
2111
|
// per-session tools or identity is worse than a refused one. Non-local
|
|
2017
2112
|
// agents already fail discovery; this guards hybrid agents' per-send
|
|
2018
2113
|
// cloud sessions.
|
|
2019
|
-
const perSessionConnection = agent.connections.find(
|
|
2114
|
+
const perSessionConnection = agent.connections.find(connection => connection.advertiseTools === true || connection.auth !== undefined);
|
|
2020
2115
|
if (runtime !== "local" && perSessionConnection !== undefined) {
|
|
2021
2116
|
throw new Error(`Agent "${agent.name}" connection "${perSessionConnection.name}" uses advertiseTools/auth, which only run on local turns. Refusing the session rather than running it without the connection's tools or identity.`);
|
|
2022
2117
|
}
|
|
@@ -2057,7 +2152,7 @@ export class SessionEngine {
|
|
|
2057
2152
|
? []
|
|
2058
2153
|
: this.withTurnScratchTools(authoredRoot
|
|
2059
2154
|
? fileTools
|
|
2060
|
-
: fileTools.filter(
|
|
2155
|
+
: fileTools.filter(tool => tool.name !== "SemanticSearch"), record.sessionId);
|
|
2061
2156
|
let turnPrompt = prompt;
|
|
2062
2157
|
if (isFirstTurn) {
|
|
2063
2158
|
const contextBlock = buildSessionContextBlock({
|
|
@@ -2119,6 +2214,7 @@ export class SessionEngine {
|
|
|
2119
2214
|
}
|
|
2120
2215
|
}
|
|
2121
2216
|
else if (pending !== undefined && Object.keys(pending).length > 0) {
|
|
2217
|
+
this.logger(`[workspace] no cloud store on this hosting; dropping workspaceFiles for session ${record.sessionId}: ${Object.keys(pending).join(", ")}`);
|
|
2122
2218
|
yield this.clearPendingWorkspaceFiles(record.sessionId, pending);
|
|
2123
2219
|
}
|
|
2124
2220
|
if (isFirstTurn && hosted) {
|
|
@@ -2126,67 +2222,60 @@ export class SessionEngine {
|
|
|
2126
2222
|
}
|
|
2127
2223
|
if (preamble !== "" || sections.length > 0) {
|
|
2128
2224
|
turnPrompt = [preamble, ...sections, turnPrompt]
|
|
2129
|
-
.filter(
|
|
2225
|
+
.filter(part => part !== "")
|
|
2130
2226
|
.join("\n\n");
|
|
2131
2227
|
}
|
|
2132
2228
|
}
|
|
2133
2229
|
else if (isFirstTurn && runtime === "local" && authoredRoot) {
|
|
2134
|
-
//
|
|
2135
|
-
|
|
2136
|
-
const preamble = buildAgentsMdContent(Object.assign(Object.assign({}, agent), { tools: [...agent.tools, ...synthesized] }), { includeScripts: true });
|
|
2137
|
-
const workspaceInfo = `<user_info>\nWorkspace Path: /\n</user_info>`;
|
|
2138
|
-
turnPrompt =
|
|
2139
|
-
preamble === ""
|
|
2140
|
-
? `${workspaceInfo}\n\n${turnPrompt}`
|
|
2141
|
-
: `${workspaceInfo}\n\n${preamble}\n\n${turnPrompt}`;
|
|
2142
|
-
}
|
|
2143
|
-
else if (isFirstTurn &&
|
|
2144
|
-
runtime === "local" &&
|
|
2145
|
-
instructionsInvisibleToHarness) {
|
|
2146
|
-
// Local workspace whose AGENTS.md the harness will not load. With a
|
|
2147
|
-
// borrowed harness cwd, agent tool scripts live only in the durable
|
|
2148
|
-
// scaffold dir — embed bodies like cloud. Otherwise the catalog can
|
|
2149
|
-
// reference on-disk paths under the harness cwd. Grokbot turns are
|
|
2150
|
-
// excluded: their instructions ride the request's `instructions`
|
|
2151
|
-
// field into the Sand system prompt instead.
|
|
2152
|
-
const includeScripts = this.hasBorrowedWorkspace(record);
|
|
2153
|
-
const preamble = buildAgentsMdContent(agent, { includeScripts });
|
|
2154
|
-
turnPrompt = `${preamble}\n\n${turnPrompt}`;
|
|
2230
|
+
// The harness reports no path for a root it never mounted.
|
|
2231
|
+
turnPrompt = `<user_info>\nWorkspace Path: /\n</user_info>\n\n${turnPrompt}`;
|
|
2155
2232
|
}
|
|
2233
|
+
// A virtual root has no scaffold dir either, so its catalog carries the
|
|
2234
|
+
// synthesized file tools and embedded script bodies.
|
|
2235
|
+
const localInstructions = runtime === "local"
|
|
2236
|
+
? authoredRoot
|
|
2237
|
+
? buildAgentsMdContent(Object.assign(Object.assign({}, agent), { tools: [...agent.tools, ...synthesized] }), { includeScripts: true })
|
|
2238
|
+
: buildAgentsMdContent(agent, {
|
|
2239
|
+
includeScripts: this.hasBorrowedWorkspace(record),
|
|
2240
|
+
})
|
|
2241
|
+
: undefined;
|
|
2156
2242
|
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ sessionId: record.sessionId }, (record.sdkAgentId === undefined
|
|
2157
2243
|
? {}
|
|
2158
|
-
: { sdkAgentId: record.sdkAgentId })), { workspaceDir: this.harnessCwd(record), sandbox: authoredRoot
|
|
2159
|
-
? false
|
|
2160
|
-
: ((_c = this.project.agent.local) === null || _c === void 0 ? void 0 : _c.sandbox) === true }), (runtime === "local" && harnessTools !== undefined
|
|
2244
|
+
: { sdkAgentId: record.sdkAgentId })), { workspaceDir: this.harnessCwd(record), sandbox: authoredRoot ? false : ((_c = agent.local) === null || _c === void 0 ? void 0 : _c.sandbox) === true }), (runtime === "local" && harnessTools !== undefined
|
|
2161
2245
|
? Object.assign(Object.assign({}, (harnessTools.tools === undefined
|
|
2162
2246
|
? {}
|
|
2163
2247
|
: { tools: harnessTools.tools })), (harnessTools.disallowedTools === undefined
|
|
2164
2248
|
? {}
|
|
2165
2249
|
: { disallowedTools: harnessTools.disallowedTools })) : {})), { runnerStateDir: join(this.stateRoot, "runner"), prompt: turnPrompt, isFirstTurn }), (images !== undefined && images.length > 0 ? { images } : {})), (agent.model === undefined ? {} : { model: agent.model })), { runtime, agentName: agent.name }), (mergedCloud === undefined ? {} : { cloud: mergedCloud })), {
|
|
2166
|
-
//
|
|
2167
|
-
// turns carry
|
|
2168
|
-
//
|
|
2169
|
-
// the
|
|
2170
|
-
//
|
|
2250
|
+
// Local turns send the composed instructions as the harness system
|
|
2251
|
+
// prompt; grokbot turns carry them into the hosted session, which
|
|
2252
|
+
// surfaces them in the Sand system prompt. Cloud turns inline them into
|
|
2253
|
+
// the first prompt above instead. Script bodies are embedded whenever
|
|
2254
|
+
// the harness cannot reach the scaffold dir: always for grokbot (the
|
|
2255
|
+
// box never sees the session workspace) and for a borrowed local cwd
|
|
2256
|
+
// (PR worktree, shared checkout); otherwise the catalog references the
|
|
2257
|
+
// on-disk paths under the harness cwd.
|
|
2171
2258
|
instructions: runtime === "grokbot"
|
|
2172
2259
|
? buildAgentsMdContent(agent, { includeScripts: true })
|
|
2173
|
-
:
|
|
2260
|
+
: localInstructions }), (runtime === "cloud" && !isCursorHostedFilesAvailable()
|
|
2174
2261
|
? { agentServeAgent: this.project.name }
|
|
2175
2262
|
: {})), { customTools: runtime === "local"
|
|
2176
|
-
? yield this.buildCustomTools(record,
|
|
2177
|
-
: {}, mcpServers: this.buildMcpServers(runtime, record.sessionId, yield this.evaluateConnectionAuth(record)) }), (runtime === "local" &&
|
|
2263
|
+
? yield this.buildCustomTools(record, turnId, emit, synthesized)
|
|
2264
|
+
: {}, mcpServers: this.buildMcpServers(runtime, record.sessionId, yield this.evaluateConnectionAuth(record)) }), (runtime === "local" &&
|
|
2265
|
+
(this.hasAttachedAuthedConnections() ||
|
|
2266
|
+
this.project.agent.connections.some(connection => isCursorAccountTransport(connection.transport)))
|
|
2178
2267
|
? { perSendMcpServers: true }
|
|
2179
2268
|
: {})), { subagents: buildRunnerSubagents(agent), onUpdate,
|
|
2180
2269
|
signal,
|
|
2181
2270
|
// Local follow-ups expire any lingering active run so a preempted turn
|
|
2182
2271
|
// (or one orphaned by a crashed process) never blocks this send.
|
|
2183
|
-
forceExpireActiveRun: runtime === "local" && !isFirstTurn, onRequestId:
|
|
2272
|
+
forceExpireActiveRun: runtime === "local" && !isFirstTurn, onRequestId: requestId => {
|
|
2184
2273
|
emit({ type: "turn.bound", data: { requestId } });
|
|
2185
2274
|
}, onSdkAgentId: (sdkAgentId) => __awaiter(this, void 0, void 0, function* () {
|
|
2186
2275
|
if (record.sdkAgentId === sdkAgentId) {
|
|
2187
2276
|
return;
|
|
2188
2277
|
}
|
|
2189
|
-
yield this.updateRecord(record.sessionId,
|
|
2278
|
+
yield this.updateRecord(record.sessionId, current => (Object.assign(Object.assign({}, current), { sdkAgentId })));
|
|
2190
2279
|
record.sdkAgentId = sdkAgentId;
|
|
2191
2280
|
eventContext.session = Object.assign(Object.assign({}, eventContext.session), { sdkAgentId });
|
|
2192
2281
|
yield this.appendEvent(record.sessionId, {
|
|
@@ -2265,9 +2354,9 @@ export class SessionEngine {
|
|
|
2265
2354
|
// Advertised connections surface as named server tools instead of an
|
|
2266
2355
|
// attached MCP server (each tool appears exactly once).
|
|
2267
2356
|
const advertisedNames = new Set(this.project.agent.connections
|
|
2268
|
-
.filter(
|
|
2269
|
-
.map(
|
|
2270
|
-
const hostConnectionNames = new Set(((_a = this.project.agent.hostConnections) !== null && _a !== void 0 ? _a : []).map(
|
|
2357
|
+
.filter(connection => connection.advertiseTools === true)
|
|
2358
|
+
.map(connection => connection.name));
|
|
2359
|
+
const hostConnectionNames = new Set(((_a = this.project.agent.hostConnections) !== null && _a !== void 0 ? _a : []).map(connection => connection.name));
|
|
2271
2360
|
const bridgedNames = new Set(runtime === "cloud" &&
|
|
2272
2361
|
sessionId !== undefined &&
|
|
2273
2362
|
this.cloudServerToolsConnection !== undefined &&
|
|
@@ -2276,7 +2365,7 @@ export class SessionEngine {
|
|
|
2276
2365
|
: []);
|
|
2277
2366
|
assertCloudCanHonorAccountServersFilters({
|
|
2278
2367
|
runtime,
|
|
2279
|
-
resolvedConnections: this.resolvedConnections.filter(
|
|
2368
|
+
resolvedConnections: this.resolvedConnections.filter(resolved => !advertisedNames.has(resolved.name) &&
|
|
2280
2369
|
!hostConnectionNames.has(resolved.name)),
|
|
2281
2370
|
bridgedNames,
|
|
2282
2371
|
});
|
|
@@ -2337,6 +2426,18 @@ export class SessionEngine {
|
|
|
2337
2426
|
}
|
|
2338
2427
|
continue;
|
|
2339
2428
|
}
|
|
2429
|
+
const authored = this.authoredConnection(resolved.name);
|
|
2430
|
+
if (sessionId !== undefined &&
|
|
2431
|
+
authored !== undefined &&
|
|
2432
|
+
isCursorAccountTransport(authored.transport)) {
|
|
2433
|
+
const bound = new URL(url);
|
|
2434
|
+
bound.searchParams.set("agentkitSessionId", sessionId);
|
|
2435
|
+
servers[resolved.name] = {
|
|
2436
|
+
url: bound.toString(),
|
|
2437
|
+
headers: resolved.headers,
|
|
2438
|
+
};
|
|
2439
|
+
continue;
|
|
2440
|
+
}
|
|
2340
2441
|
servers[resolved.name] = {
|
|
2341
2442
|
url,
|
|
2342
2443
|
headers: resolved.headers,
|
|
@@ -2345,7 +2446,7 @@ export class SessionEngine {
|
|
|
2345
2446
|
if (runtime === "cloud" &&
|
|
2346
2447
|
sessionId !== undefined &&
|
|
2347
2448
|
this.cloudServerToolsConnection !== undefined &&
|
|
2348
|
-
this.project.agent.tools.some(
|
|
2449
|
+
this.project.agent.tools.some(tool => tool.execution === "server")) {
|
|
2349
2450
|
if (servers[SERVER_TOOLS_MCP_SERVER_NAME] !== undefined) {
|
|
2350
2451
|
throw new Error(`MCP connection name "${SERVER_TOOLS_MCP_SERVER_NAME}" is reserved for authored server tools on cloud turns.`);
|
|
2351
2452
|
}
|
|
@@ -2365,7 +2466,7 @@ export class SessionEngine {
|
|
|
2365
2466
|
* ride every send instead of being pinned on the cached agent handle.
|
|
2366
2467
|
*/
|
|
2367
2468
|
hasAttachedAuthedConnections() {
|
|
2368
|
-
return this.project.agent.connections.some(
|
|
2469
|
+
return this.project.agent.connections.some(connection => connection.auth !== undefined && connection.advertiseTools !== true);
|
|
2369
2470
|
}
|
|
2370
2471
|
/**
|
|
2371
2472
|
* Evaluate per-session connection auth (`defineConnection({ auth })`)
|
|
@@ -2376,7 +2477,7 @@ export class SessionEngine {
|
|
|
2376
2477
|
*/
|
|
2377
2478
|
evaluateConnectionAuth(record) {
|
|
2378
2479
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2379
|
-
const authed = this.project.agent.connections.filter(
|
|
2480
|
+
const authed = this.project.agent.connections.filter(connection => connection.auth !== undefined && connection.advertiseTools !== true);
|
|
2380
2481
|
if (authed.length === 0) {
|
|
2381
2482
|
return undefined;
|
|
2382
2483
|
}
|
|
@@ -2397,8 +2498,9 @@ export class SessionEngine {
|
|
|
2397
2498
|
return evaluated;
|
|
2398
2499
|
});
|
|
2399
2500
|
}
|
|
2400
|
-
buildCustomTools(record_1,
|
|
2401
|
-
return __awaiter(this, arguments, void 0, function* (record,
|
|
2501
|
+
buildCustomTools(record_1, turnId_1, emit_1) {
|
|
2502
|
+
return __awaiter(this, arguments, void 0, function* (record, turnId, emit, extraTools = []) {
|
|
2503
|
+
const agent = this.project.agent;
|
|
2402
2504
|
const tools = {};
|
|
2403
2505
|
const register = (tool) => {
|
|
2404
2506
|
tools[tool.name] = Object.assign(Object.assign(Object.assign({ description: tool.description, inputSchema: tool.inputSchema }, (tool.outputSchema === undefined
|
|
@@ -2463,7 +2565,7 @@ export class SessionEngine {
|
|
|
2463
2565
|
if (active === undefined) {
|
|
2464
2566
|
return toolErrorResult(`Session ${sessionId} has no active turn for tool "${toolName}".`);
|
|
2465
2567
|
}
|
|
2466
|
-
const tool = this.project.agent.tools.find(
|
|
2568
|
+
const tool = this.project.agent.tools.find(candidate => candidate.name === toolName && candidate.execution === "server");
|
|
2467
2569
|
if (tool === undefined) {
|
|
2468
2570
|
return toolErrorResult(`Unknown server tool "${toolName}".`);
|
|
2469
2571
|
}
|
|
@@ -2617,8 +2719,8 @@ export class SessionEngine {
|
|
|
2617
2719
|
requestedAt,
|
|
2618
2720
|
};
|
|
2619
2721
|
const resolutionPromise = this.approvals.wait(args.sessionId, pendingRecord);
|
|
2620
|
-
yield this.updateRecord(args.sessionId,
|
|
2621
|
-
...((_a = current.pendingApprovals) !== null && _a !== void 0 ? _a : []).filter(
|
|
2722
|
+
yield this.updateRecord(args.sessionId, current => { var _a; return (Object.assign(Object.assign({}, current), { pendingApprovals: [
|
|
2723
|
+
...((_a = current.pendingApprovals) !== null && _a !== void 0 ? _a : []).filter(item => item.callId !== args.callId),
|
|
2622
2724
|
pendingRecord,
|
|
2623
2725
|
] })); });
|
|
2624
2726
|
args.emit({
|
|
@@ -2631,7 +2733,7 @@ export class SessionEngine {
|
|
|
2631
2733
|
});
|
|
2632
2734
|
this.logger(`[session] tool ${args.toolName} awaiting approval (${args.callId})`);
|
|
2633
2735
|
const { decision, by } = yield resolutionPromise;
|
|
2634
|
-
yield this.updateRecord(args.sessionId,
|
|
2736
|
+
yield this.updateRecord(args.sessionId, current => { var _a; return (Object.assign(Object.assign({}, current), { pendingApprovals: ((_a = current.pendingApprovals) !== null && _a !== void 0 ? _a : []).filter(item => item.callId !== args.callId) })); });
|
|
2635
2737
|
args.emit({
|
|
2636
2738
|
type: "action.approval_resolved",
|
|
2637
2739
|
data: Object.assign({ callId: args.callId, toolName: args.toolName, decision }, (by === undefined ? {} : { by })),
|
|
@@ -2648,7 +2750,7 @@ export class SessionEngine {
|
|
|
2648
2750
|
current.pendingApprovals.length === 0) {
|
|
2649
2751
|
return;
|
|
2650
2752
|
}
|
|
2651
|
-
yield this.updateRecord(sessionId,
|
|
2753
|
+
yield this.updateRecord(sessionId, record => (Object.assign(Object.assign({}, record), { pendingApprovals: [] })));
|
|
2652
2754
|
});
|
|
2653
2755
|
}
|
|
2654
2756
|
/** Pending tool approvals for a session (live waiters ∪ persisted). */
|
|
@@ -2685,7 +2787,7 @@ export class SessionEngine {
|
|
|
2685
2787
|
if (!samePrincipal(record.auth, ownershipAuth)) {
|
|
2686
2788
|
throw new SessionAuthError(sessionId);
|
|
2687
2789
|
}
|
|
2688
|
-
const pending = (_b = ((_a = record.pendingApprovals) !== null && _a !== void 0 ? _a : []).find(
|
|
2790
|
+
const pending = (_b = ((_a = record.pendingApprovals) !== null && _a !== void 0 ? _a : []).find(item => item.callId === callId)) !== null && _b !== void 0 ? _b : this.approvals.list(sessionId).find(item => item.callId === callId);
|
|
2689
2791
|
if (pending === undefined) {
|
|
2690
2792
|
throw new ApprovalNotFoundError(sessionId, callId);
|
|
2691
2793
|
}
|
|
@@ -2699,21 +2801,21 @@ export class SessionEngine {
|
|
|
2699
2801
|
}
|
|
2700
2802
|
removePendingApproval(sessionId, callId) {
|
|
2701
2803
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2702
|
-
yield this.updateRecord(sessionId,
|
|
2804
|
+
yield this.updateRecord(sessionId, current => { var _a; return (Object.assign(Object.assign({}, current), { pendingApprovals: ((_a = current.pendingApprovals) !== null && _a !== void 0 ? _a : []).filter(item => item.callId !== callId) })); });
|
|
2703
2805
|
});
|
|
2704
2806
|
}
|
|
2705
2807
|
wrapMcp(inner) {
|
|
2706
2808
|
return {
|
|
2707
2809
|
names: () => inner.names(),
|
|
2708
|
-
listTools:
|
|
2810
|
+
listTools: name => this.withMcpAuth(name, () => inner.listTools(name)),
|
|
2709
2811
|
callTool: (name, tool, args) => this.withMcpAuth(name, () => inner.callTool(name, tool, args)),
|
|
2710
2812
|
};
|
|
2711
2813
|
}
|
|
2712
2814
|
advertiseMcp() {
|
|
2713
2815
|
return {
|
|
2714
|
-
listTools:
|
|
2816
|
+
listTools: name => this.withMcpListAuth(name, () => this.mcpHost.listTools(name)),
|
|
2715
2817
|
callTool: (name, tool, args) => this.withMcpAuth(name, () => this.mcpHost.callTool(name, tool, args)),
|
|
2716
|
-
oneOff:
|
|
2818
|
+
oneOff: connection => {
|
|
2717
2819
|
const inner = this.mcpHost.oneOff(connection);
|
|
2718
2820
|
return {
|
|
2719
2821
|
listTools: () => this.withMcpListAuth(connection.name, () => inner.listTools()),
|
|
@@ -2834,8 +2936,8 @@ export class SessionEngine {
|
|
|
2834
2936
|
requestedAt,
|
|
2835
2937
|
};
|
|
2836
2938
|
const resolutionPromise = this.auths.wait(args.sessionId, pendingRecord);
|
|
2837
|
-
yield this.updateRecord(args.sessionId,
|
|
2838
|
-
...((_a = current.pendingAuths) !== null && _a !== void 0 ? _a : []).filter(
|
|
2939
|
+
yield this.updateRecord(args.sessionId, current => { var _a; return (Object.assign(Object.assign({}, current), { pendingAuths: [
|
|
2940
|
+
...((_a = current.pendingAuths) !== null && _a !== void 0 ? _a : []).filter(item => item.callId !== args.callId),
|
|
2839
2941
|
pendingRecord,
|
|
2840
2942
|
] })); });
|
|
2841
2943
|
args.emit({
|
|
@@ -2849,7 +2951,7 @@ export class SessionEngine {
|
|
|
2849
2951
|
});
|
|
2850
2952
|
this.logger(`[session] tool ${args.toolName} awaiting MCP auth ${args.connection} (${args.callId})`);
|
|
2851
2953
|
const { decision, by } = yield resolutionPromise;
|
|
2852
|
-
yield this.updateRecord(args.sessionId,
|
|
2954
|
+
yield this.updateRecord(args.sessionId, current => { var _a; return (Object.assign(Object.assign({}, current), { pendingAuths: ((_a = current.pendingAuths) !== null && _a !== void 0 ? _a : []).filter(item => item.callId !== args.callId) })); });
|
|
2853
2955
|
args.emit({
|
|
2854
2956
|
type: "action.auth_resolved",
|
|
2855
2957
|
data: {
|
|
@@ -2873,7 +2975,7 @@ export class SessionEngine {
|
|
|
2873
2975
|
current.pendingAuths.length === 0) {
|
|
2874
2976
|
return;
|
|
2875
2977
|
}
|
|
2876
|
-
yield this.updateRecord(sessionId,
|
|
2978
|
+
yield this.updateRecord(sessionId, record => (Object.assign(Object.assign({}, record), { pendingAuths: [] })));
|
|
2877
2979
|
});
|
|
2878
2980
|
}
|
|
2879
2981
|
listPendingAuths(sessionId) {
|
|
@@ -2901,7 +3003,7 @@ export class SessionEngine {
|
|
|
2901
3003
|
if (!samePrincipal(record.auth, ownershipAuth)) {
|
|
2902
3004
|
throw new SessionAuthError(sessionId);
|
|
2903
3005
|
}
|
|
2904
|
-
const pending = (_b = ((_a = record.pendingAuths) !== null && _a !== void 0 ? _a : []).find(
|
|
3006
|
+
const pending = (_b = ((_a = record.pendingAuths) !== null && _a !== void 0 ? _a : []).find(item => item.callId === callId)) !== null && _b !== void 0 ? _b : this.auths.list(sessionId).find(item => item.callId === callId);
|
|
2905
3007
|
if (pending === undefined) {
|
|
2906
3008
|
throw new AuthNotFoundError(sessionId, callId);
|
|
2907
3009
|
}
|
|
@@ -2918,7 +3020,7 @@ export class SessionEngine {
|
|
|
2918
3020
|
}
|
|
2919
3021
|
removePendingAuth(sessionId, callId) {
|
|
2920
3022
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2921
|
-
yield this.updateRecord(sessionId,
|
|
3023
|
+
yield this.updateRecord(sessionId, current => { var _a; return (Object.assign(Object.assign({}, current), { pendingAuths: ((_a = current.pendingAuths) !== null && _a !== void 0 ? _a : []).filter(item => item.callId !== callId) })); });
|
|
2922
3024
|
});
|
|
2923
3025
|
}
|
|
2924
3026
|
runWithMcpPark(sessionId, toolName, fn) {
|
|
@@ -3068,16 +3170,16 @@ export class SessionEngine {
|
|
|
3068
3170
|
*/
|
|
3069
3171
|
describeCatalogTool(toolName_1) {
|
|
3070
3172
|
return __awaiter(this, arguments, void 0, function* (toolName, options = {}) {
|
|
3071
|
-
const authored = this.project.agent.tools.find(
|
|
3173
|
+
const authored = this.project.agent.tools.find(tool => tool.name === toolName);
|
|
3072
3174
|
if (authored !== undefined) {
|
|
3073
3175
|
return { tool: authored };
|
|
3074
3176
|
}
|
|
3075
3177
|
const catalog = yield this.listCatalogTools(options);
|
|
3076
|
-
const tool = catalog.tools.find(
|
|
3178
|
+
const tool = catalog.tools.find(entry => entry.name === toolName);
|
|
3077
3179
|
if (tool === undefined) {
|
|
3078
3180
|
return {
|
|
3079
3181
|
tool: undefined,
|
|
3080
|
-
availableTools: catalog.tools.map(
|
|
3182
|
+
availableTools: catalog.tools.map(entry => entry.name),
|
|
3081
3183
|
connectionErrors: catalog.connectionErrors,
|
|
3082
3184
|
};
|
|
3083
3185
|
}
|
|
@@ -3115,9 +3217,9 @@ export class SessionEngine {
|
|
|
3115
3217
|
if (native !== undefined) {
|
|
3116
3218
|
return native;
|
|
3117
3219
|
}
|
|
3118
|
-
let tool = this.project.agent.tools.find(
|
|
3220
|
+
let tool = this.project.agent.tools.find(t => t.name === toolName);
|
|
3119
3221
|
if (tool === undefined &&
|
|
3120
|
-
this.project.agent.connections.some(
|
|
3222
|
+
this.project.agent.connections.some(c => c.advertiseTools === true)) {
|
|
3121
3223
|
// Advertised passthroughs are ordinary server tools in the session's
|
|
3122
3224
|
// namespace; resolve the live listing so direct calls address them by
|
|
3123
3225
|
// the same model-facing name a turn would. A listing failure fails
|
|
@@ -3127,12 +3229,12 @@ export class SessionEngine {
|
|
|
3127
3229
|
session,
|
|
3128
3230
|
hostMcp: this.advertiseMcp(),
|
|
3129
3231
|
});
|
|
3130
|
-
tool = advertised.find(
|
|
3232
|
+
tool = advertised.find(t => t.name === toolName);
|
|
3131
3233
|
}
|
|
3132
3234
|
if (tool === undefined) {
|
|
3133
3235
|
throw new UnknownToolError(toolName, this.project.agent.tools
|
|
3134
|
-
.filter(
|
|
3135
|
-
.map(
|
|
3236
|
+
.filter(t => t.execution === "server")
|
|
3237
|
+
.map(t => t.name));
|
|
3136
3238
|
}
|
|
3137
3239
|
const execute = tool.definition.execute;
|
|
3138
3240
|
if (tool.execution !== "server" || typeof execute !== "function") {
|
|
@@ -3411,7 +3513,7 @@ export class SessionEngine {
|
|
|
3411
3513
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3412
3514
|
try {
|
|
3413
3515
|
const listed = yield this.host.mcp.listTools(connectionName);
|
|
3414
|
-
return listed.find(
|
|
3516
|
+
return listed.find(tool => tool.name === toolName);
|
|
3415
3517
|
}
|
|
3416
3518
|
catch (_a) {
|
|
3417
3519
|
return undefined;
|
|
@@ -3438,7 +3540,7 @@ export class SessionEngine {
|
|
|
3438
3540
|
const chain = (_b = this.dispatchChains.get(sessionId)) !== null && _b !== void 0 ? _b : Promise.resolve();
|
|
3439
3541
|
const next = chain
|
|
3440
3542
|
.then(() => this.dispatchEvent(sessionId, event, context))
|
|
3441
|
-
.catch(
|
|
3543
|
+
.catch(error => {
|
|
3442
3544
|
this.logger(`[agent-sdk] event dispatch failed for ${sessionId}: ${describeError(error)}`);
|
|
3443
3545
|
})
|
|
3444
3546
|
.then(() => {
|
|
@@ -3497,12 +3599,12 @@ export class SessionEngine {
|
|
|
3497
3599
|
}
|
|
3498
3600
|
if (context === undefined || channelStateBefore === undefined) {
|
|
3499
3601
|
// Handlers mutate live channel state in place; save the current record.
|
|
3500
|
-
yield this.updateRecord(sessionId,
|
|
3602
|
+
yield this.updateRecord(sessionId, current => (Object.assign({}, current)));
|
|
3501
3603
|
}
|
|
3502
3604
|
else {
|
|
3503
3605
|
const updatedState = channelCtx.state;
|
|
3504
3606
|
context.channelState = updatedState;
|
|
3505
|
-
yield this.updateRecord(sessionId,
|
|
3607
|
+
yield this.updateRecord(sessionId, current => (Object.assign(Object.assign({}, current), { channelState: mergeChannelStateMutation({
|
|
3506
3608
|
current: current.channelState,
|
|
3507
3609
|
before: channelStateBefore,
|
|
3508
3610
|
after: updatedState,
|
|
@@ -3529,9 +3631,6 @@ export class SessionEngine {
|
|
|
3529
3631
|
}
|
|
3530
3632
|
}
|
|
3531
3633
|
}
|
|
3532
|
-
if (this.abCollector.enabled) {
|
|
3533
|
-
yield this.abCollector.onEvent(event, sessionCtx.session, this.project.name);
|
|
3534
|
-
}
|
|
3535
3634
|
(_a = this.otel) === null || _a === void 0 ? void 0 : _a.onEvent(event, sessionCtx.session);
|
|
3536
3635
|
});
|
|
3537
3636
|
}
|
|
@@ -3578,8 +3677,10 @@ export class SessionEngine {
|
|
|
3578
3677
|
var _a;
|
|
3579
3678
|
// Drain admission first so pendingTurns → activeTurns is visible before we
|
|
3580
3679
|
// decide the session is idle (reminders use this for queueBehindTurn).
|
|
3581
|
-
//
|
|
3582
|
-
// follow-up
|
|
3680
|
+
// Wait for coalesce drain and any successor turn so hosted execute does
|
|
3681
|
+
// not park mid-follow-up, but report the root turn's outcome: a drained
|
|
3682
|
+
// successor failure must not un-ACK an already-finished owner.
|
|
3683
|
+
let root;
|
|
3583
3684
|
for (;;) {
|
|
3584
3685
|
const chain = this.admissionChains.get(sessionId);
|
|
3585
3686
|
if (chain !== undefined) {
|
|
@@ -3587,14 +3688,15 @@ export class SessionEngine {
|
|
|
3587
3688
|
}
|
|
3588
3689
|
const active = this.activeTurns.get(sessionId);
|
|
3589
3690
|
if (active !== undefined) {
|
|
3590
|
-
yield active;
|
|
3691
|
+
const outcome = yield active;
|
|
3692
|
+
root !== null && root !== void 0 ? root : (root = outcome);
|
|
3591
3693
|
continue;
|
|
3592
3694
|
}
|
|
3593
3695
|
const dispatch = this.dispatchChains.get(sessionId);
|
|
3594
3696
|
if (dispatch !== undefined) {
|
|
3595
3697
|
yield dispatch.catch(() => { });
|
|
3596
3698
|
}
|
|
3597
|
-
return (_a = this.lastOutcomes.get(sessionId)) !== null && _a !== void 0 ? _a : { status: "finished" };
|
|
3699
|
+
return (_a = root !== null && root !== void 0 ? root : this.lastOutcomes.get(sessionId)) !== null && _a !== void 0 ? _a : { status: "finished" };
|
|
3598
3700
|
}
|
|
3599
3701
|
});
|
|
3600
3702
|
}
|
|
@@ -3628,7 +3730,7 @@ export class SessionEngine {
|
|
|
3628
3730
|
return records;
|
|
3629
3731
|
}
|
|
3630
3732
|
const owned = yield this.ownedSessionIds(caller);
|
|
3631
|
-
return records.filter(
|
|
3733
|
+
return records.filter(record => record.sessionId !== undefined && owned.has(record.sessionId));
|
|
3632
3734
|
});
|
|
3633
3735
|
}
|
|
3634
3736
|
/**
|
|
@@ -3659,8 +3761,8 @@ export class SessionEngine {
|
|
|
3659
3761
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3660
3762
|
const sessions = yield this.sessions.list();
|
|
3661
3763
|
return new Set(sessions
|
|
3662
|
-
.filter(
|
|
3663
|
-
.map(
|
|
3764
|
+
.filter(record => samePrincipal(record.auth, caller))
|
|
3765
|
+
.map(record => record.sessionId));
|
|
3664
3766
|
});
|
|
3665
3767
|
}
|
|
3666
3768
|
/**
|
|
@@ -3780,8 +3882,8 @@ export class SessionEngine {
|
|
|
3780
3882
|
}
|
|
3781
3883
|
summarizeSessionRecords(records, caller, includeAll) {
|
|
3782
3884
|
return records
|
|
3783
|
-
.filter(
|
|
3784
|
-
.map(
|
|
3885
|
+
.filter(record => includeAll || samePrincipal(record.auth, caller))
|
|
3886
|
+
.map(record => {
|
|
3785
3887
|
var _a;
|
|
3786
3888
|
const links = sessionExternalLinks(record);
|
|
3787
3889
|
return {
|
|
@@ -3808,57 +3910,6 @@ export class SessionEngine {
|
|
|
3808
3910
|
};
|
|
3809
3911
|
});
|
|
3810
3912
|
}
|
|
3811
|
-
/**
|
|
3812
|
-
* Fold durable session streams into per-session A/B assignments and
|
|
3813
|
-
* aggregate arm metrics (`GET /v1/abs`). Collector-independent: always
|
|
3814
|
-
* reads `events.ndjson`.
|
|
3815
|
-
*/
|
|
3816
|
-
abSnapshot(caller, options) {
|
|
3817
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3818
|
-
var _a, _b;
|
|
3819
|
-
var _c;
|
|
3820
|
-
const sessions = yield this.listSessions(caller, options);
|
|
3821
|
-
const abConfig = this.project.abConfig;
|
|
3822
|
-
const maxPlaygroundSessions = resolveABMaxPlaygroundSessions(abConfig === null || abConfig === void 0 ? void 0 : abConfig.maxPlaygroundSessions);
|
|
3823
|
-
const foldedSessions = sessions.slice(0, maxPlaygroundSessions);
|
|
3824
|
-
// Backfill for a replacement host with nothing local to fold (e.g.
|
|
3825
|
-
// lazy-only restore before any session resumed): serve the persisted
|
|
3826
|
-
// aggregate instead of an empty surface. Gated on the host having no
|
|
3827
|
-
// sessions AT ALL — the persisted snapshot spans every principal, so a
|
|
3828
|
-
// caller who merely owns no sessions must not see it. Loaded once per
|
|
3829
|
-
// process (playground polls this route ~every 4s); skip the persist
|
|
3830
|
-
// side effect below — re-saving a restored snapshot would echo stale
|
|
3831
|
-
// data back into the store.
|
|
3832
|
-
if (foldedSessions.length === 0 &&
|
|
3833
|
-
this.storage !== undefined &&
|
|
3834
|
-
(yield this.sessions.list()).length === 0) {
|
|
3835
|
-
(_c = this.restoredAbSnapshot) !== null && _c !== void 0 ? _c : (this.restoredAbSnapshot = this.storage.getLatestAbSnapshot());
|
|
3836
|
-
const restoredSnapshot = yield this.restoredAbSnapshot;
|
|
3837
|
-
if (restoredSnapshot !== undefined) {
|
|
3838
|
-
return restoredSnapshot;
|
|
3839
|
-
}
|
|
3840
|
-
}
|
|
3841
|
-
const abTable = (_a = this.project.storage) === null || _a === void 0 ? void 0 : _a.abs;
|
|
3842
|
-
const snapshot = yield buildABSnapshot({
|
|
3843
|
-
experiments: this.project.abs,
|
|
3844
|
-
agentName: this.project.name,
|
|
3845
|
-
sessions: foldedSessions,
|
|
3846
|
-
loadRecord: (sessionId) => this.sessions.get(sessionId),
|
|
3847
|
-
loadEvents: (sessionId) => this.listEvents(sessionId, 0),
|
|
3848
|
-
sessionInfo: (record) => this.sessionInfo(record),
|
|
3849
|
-
logger: this.logger,
|
|
3850
|
-
config: {
|
|
3851
|
-
maxPlaygroundSessions,
|
|
3852
|
-
durableSamples: abTable !== undefined,
|
|
3853
|
-
durableSnapshots: (abTable === null || abTable === void 0 ? void 0 : abTable.putSnapshot) !== undefined,
|
|
3854
|
-
},
|
|
3855
|
-
});
|
|
3856
|
-
// Side effect on the read path: playground polls GET /v1/abs ~every 4s;
|
|
3857
|
-
// the coordinator throttles the actual table write.
|
|
3858
|
-
(_b = this.storage) === null || _b === void 0 ? void 0 : _b.abSnapshot(snapshot);
|
|
3859
|
-
return snapshot;
|
|
3860
|
-
});
|
|
3861
|
-
}
|
|
3862
3913
|
eventStream(sessionId_1) {
|
|
3863
3914
|
return __awaiter(this, arguments, void 0, function* (sessionId, startIndex = 0) {
|
|
3864
3915
|
// Playground Trace replays this stream; backfill before the snapshot
|
|
@@ -3882,7 +3933,7 @@ export class SessionEngine {
|
|
|
3882
3933
|
if (existing === undefined) {
|
|
3883
3934
|
throw new Error(`Unknown session: ${sessionId}`);
|
|
3884
3935
|
}
|
|
3885
|
-
const record = yield this.updateRecord(sessionId,
|
|
3936
|
+
const record = yield this.updateRecord(sessionId, current => (Object.assign(Object.assign({}, current), { turnCount: current.turnCount + 1 })));
|
|
3886
3937
|
const turnId = `turn_${record.turnCount}`;
|
|
3887
3938
|
yield this.appendEvent(sessionId, {
|
|
3888
3939
|
type: "turn.started",
|
|
@@ -3997,7 +4048,7 @@ export class SessionEngine {
|
|
|
3997
4048
|
return pending;
|
|
3998
4049
|
}
|
|
3999
4050
|
const work = this.runCloudTurnCostBackfill(sessionId)
|
|
4000
|
-
.catch(
|
|
4051
|
+
.catch(error => {
|
|
4001
4052
|
this.logger(`[agent-sdk] cloud cost backfill failed for ${sessionId}: ${describeError(error)}`);
|
|
4002
4053
|
})
|
|
4003
4054
|
.finally(() => {
|
|
@@ -4012,9 +4063,9 @@ export class SessionEngine {
|
|
|
4012
4063
|
var _b, _c;
|
|
4013
4064
|
const log = yield this.logs.get(sessionId);
|
|
4014
4065
|
const events = yield log.snapshot(0);
|
|
4015
|
-
if (!events.some(
|
|
4066
|
+
if (!events.some(event => isUnpricedCompletedTurn(event))) {
|
|
4016
4067
|
if (!this.isTurnRunning(sessionId) &&
|
|
4017
|
-
events.some(
|
|
4068
|
+
events.some(event => event.type === "turn.completed")) {
|
|
4018
4069
|
this.cloudCostBackfillDone.add(sessionId);
|
|
4019
4070
|
}
|
|
4020
4071
|
return;
|
|
@@ -4041,7 +4092,7 @@ export class SessionEngine {
|
|
|
4041
4092
|
}
|
|
4042
4093
|
log.replace(i, next);
|
|
4043
4094
|
}
|
|
4044
|
-
if (!(yield log.snapshot(0)).some(
|
|
4095
|
+
if (!(yield log.snapshot(0)).some(event => isUnpricedCompletedTurn(event))) {
|
|
4045
4096
|
this.cloudCostBackfillDone.add(sessionId);
|
|
4046
4097
|
}
|
|
4047
4098
|
});
|
|
@@ -4050,7 +4101,7 @@ export class SessionEngine {
|
|
|
4050
4101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4051
4102
|
var _a;
|
|
4052
4103
|
const previous = yield this.sessions.get(sessionId);
|
|
4053
|
-
yield this.updateRecord(sessionId,
|
|
4104
|
+
yield this.updateRecord(sessionId, current => (Object.assign(Object.assign({}, current), { continuationKey: token })));
|
|
4054
4105
|
// Keep armed reminders addressed at the conversation across channel
|
|
4055
4106
|
// continuation rotation.
|
|
4056
4107
|
if ((previous === null || previous === void 0 ? void 0 : previous.continuationKey) != null &&
|
|
@@ -4069,7 +4120,7 @@ export class SessionEngine {
|
|
|
4069
4120
|
this.coalesceDrains.has(sessionId));
|
|
4070
4121
|
}
|
|
4071
4122
|
sessionInfo(record) {
|
|
4072
|
-
return Object.assign(Object.assign(
|
|
4123
|
+
return Object.assign(Object.assign({ id: record.sessionId, channelId: record.channelId, mode: record.mode, purpose: record.purpose === "eval" ? "eval" : "live", dryRun: record.dryRun === true ? true : undefined, asOf: record.asOf, auth: record.auth, continuationKey: record.continuationKey }, (record.title === undefined ? {} : { title: record.title })), (record.sdkAgentId === undefined
|
|
4073
4124
|
? {}
|
|
4074
4125
|
: { sdkAgentId: record.sdkAgentId }));
|
|
4075
4126
|
}
|
|
@@ -4131,9 +4182,9 @@ export class SessionEngine {
|
|
|
4131
4182
|
* serve start, before channels accept traffic: any persisted session
|
|
4132
4183
|
* missing from the local `--state-root` is materialized there — events
|
|
4133
4184
|
* as `events.ndjson`, record as `session.json` — after which every
|
|
4134
|
-
* existing read path (continuation lookup, event replay/streams
|
|
4135
|
-
*
|
|
4136
|
-
*
|
|
4185
|
+
* existing read path (continuation lookup, event replay/streams) works
|
|
4186
|
+
* unchanged. Local state always wins over the sink, so restarts on the
|
|
4187
|
+
* same host are no-ops.
|
|
4137
4188
|
*
|
|
4138
4189
|
* Failures are logged and skipped; a broken store (including rows that
|
|
4139
4190
|
* violate the SessionRecord shape) never blocks serve start.
|
|
@@ -4165,7 +4216,7 @@ export class SessionEngine {
|
|
|
4165
4216
|
// the lazy continuation-lookup path.
|
|
4166
4217
|
const cutoff = Date.now() - policy.maxAgeMs;
|
|
4167
4218
|
const candidates = loaded
|
|
4168
|
-
.map(
|
|
4219
|
+
.map(record => ({
|
|
4169
4220
|
record,
|
|
4170
4221
|
// Numeric timestamp for both the age filter and the sort; a
|
|
4171
4222
|
// non-string updatedAt (e.g. a raw DB Date from an untyped sink)
|
|
@@ -4401,7 +4452,7 @@ function eventsNdjson(events) {
|
|
|
4401
4452
|
if (events.length === 0) {
|
|
4402
4453
|
return undefined;
|
|
4403
4454
|
}
|
|
4404
|
-
return `${events.map(
|
|
4455
|
+
return `${events.map(event => JSON.stringify(event)).join("\n")}\n`;
|
|
4405
4456
|
}
|
|
4406
4457
|
function subagentPrompt(subagent) {
|
|
4407
4458
|
var _a;
|
|
@@ -4416,7 +4467,7 @@ function subagentPrompt(subagent) {
|
|
|
4416
4467
|
* executor that turn will run on.
|
|
4417
4468
|
*/
|
|
4418
4469
|
function buildRunnerSubagents(agent) {
|
|
4419
|
-
return agent.subagents.map(
|
|
4470
|
+
return agent.subagents.map(subagent => { var _a; return (Object.assign({ name: subagent.name, description: (_a = subagent.description) !== null && _a !== void 0 ? _a : subagent.name, prompt: subagentPrompt(subagent) }, (subagent.model === undefined ? {} : { model: subagent.model }))); });
|
|
4420
4471
|
}
|
|
4421
4472
|
function toolErrorResult(message) {
|
|
4422
4473
|
return {
|
|
@@ -4432,7 +4483,7 @@ function defaultGetCloudUsage(sdkAgentId) {
|
|
|
4432
4483
|
return {
|
|
4433
4484
|
usage: mapSdkTokenUsage(billed.usage),
|
|
4434
4485
|
cost: billed.cost,
|
|
4435
|
-
runs: billed.runs.map(
|
|
4486
|
+
runs: billed.runs.map(run => ({
|
|
4436
4487
|
runId: run.runId,
|
|
4437
4488
|
usage: mapSdkTokenUsage(run.usage),
|
|
4438
4489
|
cost: run.cost,
|
|
@@ -4478,7 +4529,7 @@ function approvalResolverLabel(auth) {
|
|
|
4478
4529
|
}
|
|
4479
4530
|
/** Let the HTTP NDJSON writer flush before the next SDK update. */
|
|
4480
4531
|
function yieldEventLoop() {
|
|
4481
|
-
return new Promise(
|
|
4532
|
+
return new Promise(resolve => {
|
|
4482
4533
|
setImmediate(resolve);
|
|
4483
4534
|
});
|
|
4484
4535
|
}
|