@cursor/bdk 0.2.2 → 0.2.4
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 +1 -1
- package/dist/bin/agent-serve.js +32 -8
- package/dist/channels/github/auth.d.ts.map +1 -1
- package/dist/channels/github/auth.js +36 -5
- package/dist/channels/slack/attachments.d.ts +2 -1
- package/dist/channels/slack/attachments.d.ts.map +1 -1
- package/dist/channels/slack/attachments.js +19 -9
- package/dist/channels/slack/dispatch.d.ts.map +1 -1
- package/dist/channels/slack/dispatch.js +26 -24
- package/dist/channels/slack/thread-context.d.ts +21 -11
- package/dist/channels/slack/thread-context.d.ts.map +1 -1
- package/dist/channels/slack/thread-context.js +75 -27
- package/dist/connections.d.ts +1 -1
- package/dist/connections.js +1 -1
- package/dist/docs/404.html +2 -2
- package/dist/docs/assets/{app.DtYVVVyK.js → app.4kQ8Db_q.js} +4 -4
- package/dist/docs/assets/chunks/@localSearchIndexroot.CvuAJ0My.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.D47xT7J4.js → VPLocalSearchBox.DY1RwB8Q.js} +1 -1
- package/dist/docs/assets/chunks/{arc.CDJ6xzxR.js → arc.CxE_fSPK.js} +1 -1
- package/dist/docs/assets/chunks/{architectureDiagram-Q4EWVU46.l1Xnjd3N.js → architectureDiagram-Q4EWVU46.CPX426ui.js} +1 -1
- package/dist/docs/assets/chunks/{baseUniq.x-finShZ.js → baseUniq.CB52JrKG.js} +1 -1
- package/dist/docs/assets/chunks/{blockDiagram-DXYQGD6D.COC3qynH.js → blockDiagram-DXYQGD6D.J0cNaQCL.js} +1 -1
- package/dist/docs/assets/chunks/{c4Diagram-AHTNJAMY.DdQO850E.js → c4Diagram-AHTNJAMY.DJn3vEGT.js} +1 -1
- package/dist/docs/assets/chunks/channel.BoNycAoN.js +1 -0
- package/dist/docs/assets/chunks/{chunk-4BX2VUAB.Dpn8omLk.js → chunk-4BX2VUAB.Dao618F6.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-4TB4RGXK.C0XWStUN.js → chunk-4TB4RGXK.QW8Rhjai.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-55IACEB6.DsKSZfIM.js → chunk-55IACEB6.DfRLLKF_.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-EDXVE4YY.dNU6JDu6.js → chunk-EDXVE4YY.CIV2ApKQ.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-FMBD7UC4.DN41fxKE.js → chunk-FMBD7UC4.BEheSuxp.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-OYMX7WX6.COpKCZus.js → chunk-OYMX7WX6.CUN88ENB.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-QZHKN3VN.HDB-azx2.js → chunk-QZHKN3VN.CgqCs8b_.js} +1 -1
- package/dist/docs/assets/chunks/{chunk-YZCP3GAM.DEeX_a2j.js → chunk-YZCP3GAM.iCH0nnTJ.js} +1 -1
- package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.C4x07Gkj.js +1 -0
- package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.C4x07Gkj.js +1 -0
- package/dist/docs/assets/chunks/clone.Db22cH_-.js +1 -0
- package/dist/docs/assets/chunks/{cose-bilkent-S5V4N54A.C3yGL2A8.js → cose-bilkent-S5V4N54A.BLcUxhWE.js} +1 -1
- package/dist/docs/assets/chunks/{dagre-KV5264BT.Bpl24en4.js → dagre-KV5264BT.Ep7LofOm.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-5BDNPKRD.nFco6seU.js → diagram-5BDNPKRD.Bzf4GSQ4.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-G4DWMVQ6.DXhA6DWR.js → diagram-G4DWMVQ6.DD6Jh-eM.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-MMDJMWI5.8GoOYcwk.js → diagram-MMDJMWI5.oOIl8bWd.js} +1 -1
- package/dist/docs/assets/chunks/{diagram-TYMM5635.DDBlqvlJ.js → diagram-TYMM5635.DHs85Ade.js} +1 -1
- package/dist/docs/assets/chunks/{erDiagram-SMLLAGMA.vl_N81P4.js → erDiagram-SMLLAGMA.BIb5ghCk.js} +1 -1
- package/dist/docs/assets/chunks/{flowDiagram-DWJPFMVM.Cteg8g7I.js → flowDiagram-DWJPFMVM.DV4paY9k.js} +1 -1
- package/dist/docs/assets/chunks/{ganttDiagram-T4ZO3ILL.D4aMhlMM.js → ganttDiagram-T4ZO3ILL.AyEKA6_v.js} +1 -1
- package/dist/docs/assets/chunks/{gitGraphDiagram-UUTBAWPF.DF_J0D4q.js → gitGraphDiagram-UUTBAWPF.BltiCDFo.js} +1 -1
- package/dist/docs/assets/chunks/{graph.DJs0LDCf.js → graph.DzuEYGdC.js} +1 -1
- package/dist/docs/assets/chunks/{infoDiagram-42DDH7IO.Bb-4RQwg.js → infoDiagram-42DDH7IO.BV2l981J.js} +1 -1
- package/dist/docs/assets/chunks/{ishikawaDiagram-UXIWVN3A.DEtQRSbc.js → ishikawaDiagram-UXIWVN3A.BA4Izf-m.js} +1 -1
- package/dist/docs/assets/chunks/{journeyDiagram-VCZTEJTY.DhQQ75FA.js → journeyDiagram-VCZTEJTY.DjaFbFS3.js} +1 -1
- package/dist/docs/assets/chunks/{kanban-definition-6JOO6SKY.C4gEw3Rk.js → kanban-definition-6JOO6SKY.CfTFieDs.js} +1 -1
- package/dist/docs/assets/chunks/{layout.DT-PGlXa.js → layout.DzfWqTBV.js} +1 -1
- package/dist/docs/assets/chunks/{linear.BMMe__JW.js → linear.BO6mpulV.js} +1 -1
- package/dist/docs/assets/chunks/{min.XyaU9K9Q.js → min.BGgTadgT.js} +1 -1
- package/dist/docs/assets/chunks/{mindmap-definition-QFDTVHPH.CbBM6xZ-.js → mindmap-definition-QFDTVHPH.DPuIXVWY.js} +1 -1
- package/dist/docs/assets/chunks/{pieDiagram-DEJITSTG.DFJoIVou.js → pieDiagram-DEJITSTG.BOnl3bBg.js} +1 -1
- package/dist/docs/assets/chunks/{quadrantDiagram-34T5L4WZ.CQjkDYqb.js → quadrantDiagram-34T5L4WZ.DNB6Ckdc.js} +1 -1
- package/dist/docs/assets/chunks/{requirementDiagram-MS252O5E.D-mK-JQu.js → requirementDiagram-MS252O5E.D5-Qo7vb.js} +1 -1
- package/dist/docs/assets/chunks/{sankeyDiagram-XADWPNL6.BStQInpd.js → sankeyDiagram-XADWPNL6.8t65cesf.js} +1 -1
- package/dist/docs/assets/chunks/{sequenceDiagram-FGHM5R23.CA_eooPJ.js → sequenceDiagram-FGHM5R23.CaG07BdS.js} +1 -1
- package/dist/docs/assets/chunks/{stateDiagram-FHFEXIEX.BXl-b7ad.js → stateDiagram-FHFEXIEX.TKOweTB6.js} +1 -1
- package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.CuqmyQc4.js +1 -0
- package/dist/docs/assets/chunks/{theme.q37tOs4x.js → theme.Dx-JhpTB.js} +2 -2
- package/dist/docs/assets/chunks/{timeline-definition-GMOUNBTQ.vjuaGOSe.js → timeline-definition-GMOUNBTQ.fE53zQ2s.js} +1 -1
- package/dist/docs/assets/chunks/{vennDiagram-DHZGUBPP.BxduJl-F.js → vennDiagram-DHZGUBPP.DJsZZaJg.js} +1 -1
- package/dist/docs/assets/chunks/wardley-RL74JXVD.844kyrjl.js +162 -0
- package/dist/docs/assets/chunks/{wardleyDiagram-NUSXRM2D.D1z3ds0D.js → wardleyDiagram-NUSXRM2D.CMZ-Ru_t.js} +1 -1
- package/dist/docs/assets/chunks/{xychartDiagram-5P7HB3ND.CRU5Ti9b.js → xychartDiagram-5P7HB3ND.XXrhBc7a.js} +1 -1
- package/dist/docs/assets/{deployment.md.nGo1yIsa.js → deployment.md.UhnJIMr-.js} +6 -9
- package/dist/docs/assets/{deployment.md.nGo1yIsa.lean.js → deployment.md.UhnJIMr-.lean.js} +1 -1
- package/dist/docs/assets/{guides_github.md.C2_DSWlE.js → guides_github.md.Bq9kQU9B.js} +9 -3
- package/dist/docs/assets/{guides_github.md.C2_DSWlE.lean.js → guides_github.md.Bq9kQU9B.lean.js} +1 -1
- package/dist/docs/assets/{guides_jev.md.BNDm14Gy.js → guides_jev.md.CRcgmjDb.js} +2 -2
- package/dist/docs/assets/{guides_jev.md.BNDm14Gy.lean.js → guides_jev.md.CRcgmjDb.lean.js} +1 -1
- package/dist/docs/assets/{guides_slack.md.ZbHQETOT.js → guides_slack.md.diqqXTTm.js} +2 -2
- package/dist/docs/assets/{guides_slack.md.ZbHQETOT.lean.js → guides_slack.md.diqqXTTm.lean.js} +1 -1
- package/dist/docs/assets/{quickstart.md.wG4shE1f.js → quickstart.md.CHpHPBUN.js} +5 -3
- package/dist/docs/assets/{quickstart.md.wG4shE1f.lean.js → quickstart.md.CHpHPBUN.lean.js} +1 -1
- package/dist/docs/assets/{reference_agent-config.md.DzGI777n.js → reference_agent-config.md.Cj5uBKp4.js} +1 -1
- package/dist/docs/assets/{reference_artifacts.md.CFMNPreZ.js → reference_artifacts.md.CQfKq8F2.js} +1 -1
- package/dist/docs/assets/reference_cli.md.DgeLTO18.js +91 -0
- package/dist/docs/assets/reference_cli.md.DgeLTO18.lean.js +1 -0
- package/dist/docs/assets/{reference_connections.md._XpKiOaF.js → reference_connections.md.COq--gAm.js} +7 -3
- package/dist/docs/assets/{reference_connections.md._XpKiOaF.lean.js → reference_connections.md.COq--gAm.lean.js} +1 -1
- package/dist/docs/assets/{reference_evals.md.DqNyHMA6.js → reference_evals.md.CJm3uCUm.js} +4 -4
- package/dist/docs/assets/{reference_evals.md.DqNyHMA6.lean.js → reference_evals.md.CJm3uCUm.lean.js} +1 -1
- package/dist/docs/assets/{reference_extensions.md.CPPrkWlJ.js → reference_extensions.md.pa2tN-e4.js} +4 -3
- package/dist/docs/assets/{reference_extensions.md.CPPrkWlJ.lean.js → reference_extensions.md.pa2tN-e4.lean.js} +1 -1
- package/dist/docs/assets/{reference_skills.md.CRFTxt9M.js → reference_skills.md.Cy00QMKS.js} +3 -3
- package/dist/docs/assets/{reference_skills.md.CRFTxt9M.lean.js → reference_skills.md.Cy00QMKS.lean.js} +1 -1
- package/dist/docs/assets/troubleshooting.md.Cw5PKa3t.js +1 -0
- package/dist/docs/assets/{troubleshooting.md.BzZSu1Gz.lean.js → troubleshooting.md.Cw5PKa3t.lean.js} +1 -1
- package/dist/docs/building-with-agents.html +35 -35
- package/dist/docs/deployment.html +41 -44
- package/dist/docs/deployment.md +49 -16
- package/dist/docs/evals.html +35 -35
- package/dist/docs/guides/agent-to-agent.html +35 -35
- package/dist/docs/guides/bitbucket.html +35 -35
- package/dist/docs/guides/cloud-agents.html +35 -35
- package/dist/docs/guides/convert-automation.html +35 -35
- package/dist/docs/guides/github.html +43 -37
- package/dist/docs/guides/github.md +34 -0
- package/dist/docs/guides/gitlab.html +35 -35
- package/dist/docs/guides/grokbot-agents.html +35 -35
- package/dist/docs/guides/hooks.html +35 -35
- package/dist/docs/guides/improve.html +35 -35
- package/dist/docs/guides/jev.html +37 -37
- package/dist/docs/guides/jev.md +7 -0
- package/dist/docs/guides/mcp-oauth.html +35 -35
- package/dist/docs/guides/opentelemetry.html +35 -35
- package/dist/docs/guides/slack.html +37 -37
- package/dist/docs/guides/slack.md +5 -0
- package/dist/docs/guides/webhooks.html +35 -35
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +35 -35
- package/dist/docs/index.html +35 -35
- package/dist/docs/llms-full.txt +223 -94
- package/dist/docs/quickstart.html +40 -38
- package/dist/docs/quickstart.md +7 -1
- package/dist/docs/reference/agent-config.html +37 -37
- package/dist/docs/reference/agent-config.md +1 -1
- package/dist/docs/reference/artifacts.html +37 -37
- package/dist/docs/reference/artifacts.md +1 -1
- package/dist/docs/reference/channels.html +35 -35
- package/dist/docs/reference/cli.html +55 -61
- package/dist/docs/reference/cli.md +65 -63
- package/dist/docs/reference/connections.html +42 -38
- package/dist/docs/reference/connections.md +28 -2
- package/dist/docs/reference/evals.html +39 -39
- package/dist/docs/reference/evals.md +6 -7
- package/dist/docs/reference/extensions.html +39 -38
- package/dist/docs/reference/extensions.md +13 -0
- package/dist/docs/reference/hooks.html +35 -35
- package/dist/docs/reference/http-api.html +35 -35
- package/dist/docs/reference/instructions.html +35 -35
- package/dist/docs/reference/playground.html +35 -35
- package/dist/docs/reference/project-layout.html +35 -35
- package/dist/docs/reference/prompt.html +35 -35
- package/dist/docs/reference/schedules.html +35 -35
- package/dist/docs/reference/sessions.html +35 -35
- package/dist/docs/reference/skills.html +38 -38
- package/dist/docs/reference/subagents.html +35 -35
- package/dist/docs/reference/tools.html +35 -35
- package/dist/docs/templates/agentic-owners.html +35 -35
- package/dist/docs/templates/security-reviewer.html +35 -35
- package/dist/docs/templates/thermo-quality-review.html +35 -35
- package/dist/docs/templates/thermo-review.html +35 -35
- package/dist/docs/templates/triage.html +35 -35
- package/dist/docs/troubleshooting.html +36 -36
- package/dist/docs/troubleshooting.md +7 -3
- package/dist/extensions/cursor-grokbot-agents/extension.d.ts +77 -0
- package/dist/extensions/cursor-grokbot-agents/extension.d.ts.map +1 -0
- package/dist/extensions/cursor-grokbot-agents/extension.js +63 -0
- package/dist/extensions/cursor-grokbot-agents/lib/agents.d.ts +11 -0
- package/dist/extensions/cursor-grokbot-agents/lib/agents.d.ts.map +1 -0
- package/dist/extensions/cursor-grokbot-agents/lib/agents.js +31 -0
- package/dist/extensions/cursor-grokbot-agents/lib/backend.d.ts +56 -0
- package/dist/extensions/cursor-grokbot-agents/lib/backend.d.ts.map +1 -0
- package/dist/extensions/cursor-grokbot-agents/lib/backend.js +158 -0
- package/dist/extensions/cursor-grokbot-agents/lib/contacts.d.ts +28 -0
- package/dist/extensions/cursor-grokbot-agents/lib/contacts.d.ts.map +1 -0
- package/dist/extensions/cursor-grokbot-agents/lib/contacts.js +59 -0
- package/dist/extensions/cursor-grokbot-agents/lib/conversation.d.ts +53 -0
- package/dist/extensions/cursor-grokbot-agents/lib/conversation.d.ts.map +1 -0
- package/dist/extensions/cursor-grokbot-agents/lib/conversation.js +206 -0
- package/dist/extensions/cursor-grokbot-agents/lib/inputs.d.ts +4 -0
- package/dist/extensions/cursor-grokbot-agents/lib/inputs.d.ts.map +1 -0
- package/dist/extensions/cursor-grokbot-agents/lib/inputs.js +15 -0
- package/dist/extensions/cursor-grokbot-agents/lib/lock.d.ts +12 -0
- package/dist/extensions/cursor-grokbot-agents/lib/lock.d.ts.map +1 -0
- package/dist/extensions/cursor-grokbot-agents/lib/lock.js +25 -0
- package/dist/extensions/cursor-grokbot-agents/skills/consult.md +40 -0
- package/dist/extensions/cursor-grokbot-agents/tools/ask.d.ts +4 -0
- package/dist/extensions/cursor-grokbot-agents/tools/ask.d.ts.map +1 -0
- package/dist/extensions/cursor-grokbot-agents/tools/ask.js +37 -0
- package/dist/extensions/cursor-grokbot-agents/tools/check.d.ts +4 -0
- package/dist/extensions/cursor-grokbot-agents/tools/check.d.ts.map +1 -0
- package/dist/extensions/cursor-grokbot-agents/tools/check.js +32 -0
- package/dist/extensions/cursor-grokbot-agents/tools/interrupt.d.ts +4 -0
- package/dist/extensions/cursor-grokbot-agents/tools/interrupt.d.ts.map +1 -0
- package/dist/extensions/cursor-grokbot-agents/tools/interrupt.js +24 -0
- package/dist/extensions/cursor-grokbot-agents/tools/list.d.ts +4 -0
- package/dist/extensions/cursor-grokbot-agents/tools/list.d.ts.map +1 -0
- package/dist/extensions/cursor-grokbot-agents/tools/list.js +34 -0
- package/dist/extensions/jev/extension.d.ts +3 -0
- package/dist/extensions/jev/extension.d.ts.map +1 -1
- package/dist/extensions/jev/extension.js +10 -1
- package/dist/extensions/jev/lib/evaluate.d.ts +4 -0
- package/dist/extensions/jev/lib/evaluate.d.ts.map +1 -1
- package/dist/extensions/jev/lib/evaluate.js +6 -2
- package/dist/extensions.d.ts +4 -2
- package/dist/extensions.d.ts.map +1 -1
- package/dist/extensions.js +5 -2
- package/dist/internal/cli-ax.d.ts +1 -0
- package/dist/internal/cli-ax.d.ts.map +1 -1
- package/dist/internal/cli-ax.js +43 -10
- package/dist/internal/cli-deploy.d.ts +5 -1
- package/dist/internal/cli-deploy.d.ts.map +1 -1
- package/dist/internal/cli-deploy.js +41 -9
- package/dist/internal/cli-mcp-oauth.d.ts.map +1 -1
- package/dist/internal/cli-mcp-oauth.js +2 -1
- package/dist/internal/cli-skills.d.ts +1 -1
- package/dist/internal/cli-skills.d.ts.map +1 -1
- package/dist/internal/cli-skills.js +5 -5
- package/dist/internal/connection-env.d.ts +31 -0
- package/dist/internal/connection-env.d.ts.map +1 -0
- package/dist/internal/connection-env.js +84 -0
- package/dist/internal/cursor/backend-client.js +5 -0
- package/dist/internal/deploy-client.d.ts +30 -6
- package/dist/internal/deploy-client.d.ts.map +1 -1
- package/dist/internal/deploy-client.js +45 -9
- package/dist/internal/discovery/agent-config.d.ts +6 -5
- package/dist/internal/discovery/agent-config.d.ts.map +1 -1
- package/dist/internal/discovery/agent-config.js +29 -28
- package/dist/internal/discovery/agent.js +1 -1
- package/dist/internal/discovery/connections.d.ts.map +1 -1
- package/dist/internal/discovery/connections.js +11 -0
- package/dist/internal/discovery/extensions.d.ts.map +1 -1
- package/dist/internal/discovery/extensions.js +12 -0
- package/dist/internal/hosted-delivery-protocol.d.ts +36 -11
- package/dist/internal/hosted-delivery-protocol.d.ts.map +1 -1
- package/dist/internal/hosted-delivery-protocol.js +31 -8
- package/dist/internal/hosted-delivery.d.ts +2 -2
- package/dist/internal/hosted-delivery.d.ts.map +1 -1
- package/dist/internal/hosted-delivery.js +228 -48
- package/dist/internal/hosting.d.ts +10 -2
- package/dist/internal/hosting.d.ts.map +1 -1
- package/dist/internal/hosting.js +33 -3
- package/dist/internal/install-cursor-skills.d.ts +20 -24
- package/dist/internal/install-cursor-skills.d.ts.map +1 -1
- package/dist/internal/install-cursor-skills.js +50 -48
- package/dist/internal/legacy-command-guard.d.ts +2 -0
- package/dist/internal/legacy-command-guard.d.ts.map +1 -1
- package/dist/internal/legacy-command-guard.js +10 -1
- package/dist/internal/mcp-host.d.ts +6 -0
- package/dist/internal/mcp-host.d.ts.map +1 -1
- package/dist/internal/mcp-host.js +35 -16
- package/dist/internal/sdk-runner.d.ts +2 -0
- package/dist/internal/sdk-runner.d.ts.map +1 -1
- package/dist/internal/sdk-runner.js +10 -0
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +11 -1
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +9 -5
- package/dist/types.d.ts +29 -3
- package/dist/types.d.ts.map +1 -1
- package/docs/deployment.md +49 -16
- package/docs/guides/github.md +34 -0
- package/docs/guides/jev.md +7 -0
- package/docs/guides/slack.md +5 -0
- package/docs/quickstart.md +7 -1
- package/docs/reference/agent-config.md +1 -1
- package/docs/reference/artifacts.md +1 -1
- package/docs/reference/cli.md +65 -63
- package/docs/reference/connections.md +28 -2
- package/docs/reference/evals.md +6 -7
- package/docs/reference/extensions.md +13 -0
- package/docs/troubleshooting.md +7 -3
- package/package.json +1 -11
- package/scripts/install-cursor-skills.mjs +1 -1
- package/skills/create-agent/SKILL.md +1 -1
- package/skills/debug/SKILL.md +1 -1
- package/skills/deploy/SKILL.md +1 -1
- package/skills/evals/SKILL.md +1 -1
- package/skills/framework-map/SKILL.md +1 -1
- package/skills/github/SKILL.md +1 -1
- package/skills/hillclimb/SKILL.md +1 -1
- package/skills/mcp-auth/SKILL.md +1 -1
- package/skills/otel/SKILL.md +1 -1
- package/skills/setup-slack/SKILL.md +1 -1
- package/templates/agents-md/bot/lib/collect.ts +1 -4
- package/templates/code-wiki/bot/channels/github.ts +2 -2
- package/templates/demo/bot/channels/github.ts +5 -1
- package/templates/pr-autofixer/bot/lib/start-drive.ts +4 -4
- package/templates/triage/bot/lib/types.ts +6 -6
- package/dist/docs/assets/chunks/@localSearchIndexroot.BgTA2tV1.js +0 -1
- package/dist/docs/assets/chunks/channel.B2nMEx82.js +0 -1
- package/dist/docs/assets/chunks/classDiagram-6PBFFD2Q.D8iCH2ve.js +0 -1
- package/dist/docs/assets/chunks/classDiagram-v2-HSJHXN6E.D8iCH2ve.js +0 -1
- package/dist/docs/assets/chunks/clone.5XNLjby0.js +0 -1
- package/dist/docs/assets/chunks/stateDiagram-v2-QKLJ7IA2.yGM2uLZQ.js +0 -1
- package/dist/docs/assets/chunks/wardley-RL74JXVD.DKfyIejL.js +0 -162
- package/dist/docs/assets/reference_cli.md.BK2QUH67.js +0 -97
- package/dist/docs/assets/reference_cli.md.BK2QUH67.lean.js +0 -1
- package/dist/docs/assets/troubleshooting.md.BzZSu1Gz.js +0 -1
- package/src/artifacts.ts +0 -68
- package/src/bin/agent-serve.ts +0 -1833
- package/src/channels/bitbucket/api.ts +0 -891
- package/src/channels/bitbucket/binding.ts +0 -417
- package/src/channels/bitbucket/bitbucket-channel.ts +0 -162
- package/src/channels/bitbucket/bitbucket-webhook.ts +0 -519
- package/src/channels/bitbucket/checks.ts +0 -146
- package/src/channels/bitbucket/cursor-account.ts +0 -106
- package/src/channels/bitbucket/defaults.ts +0 -100
- package/src/channels/bitbucket/events.ts +0 -74
- package/src/channels/bitbucket/index.ts +0 -51
- package/src/channels/bitbucket/replay.ts +0 -421
- package/src/channels/bitbucket/state.ts +0 -59
- package/src/channels/bitbucket/types.ts +0 -261
- package/src/channels/change-monitors/change-monitors-channel.ts +0 -63
- package/src/channels/change-monitors/index.ts +0 -8
- package/src/channels/change-monitors/types.ts +0 -42
- package/src/channels/checks.ts +0 -185
- package/src/channels/deployments/deployments-channel.ts +0 -224
- package/src/channels/deployments/index.ts +0 -25
- package/src/channels/deployments/types.ts +0 -92
- package/src/channels/github/api.ts +0 -526
- package/src/channels/github/auth.ts +0 -254
- package/src/channels/github/binding.ts +0 -233
- package/src/channels/github/checks.ts +0 -145
- package/src/channels/github/cursor-account.ts +0 -303
- package/src/channels/github/defaults.ts +0 -168
- package/src/channels/github/events.ts +0 -67
- package/src/channels/github/forward.ts +0 -359
- package/src/channels/github/github-channel.ts +0 -2334
- package/src/channels/github/index.ts +0 -54
- package/src/channels/github/progress.ts +0 -365
- package/src/channels/github/replay.ts +0 -372
- package/src/channels/github/state.ts +0 -124
- package/src/channels/github/types.ts +0 -590
- package/src/channels/gitlab/api.ts +0 -329
- package/src/channels/gitlab/binding.ts +0 -231
- package/src/channels/gitlab/checks.ts +0 -228
- package/src/channels/gitlab/cursor-account.ts +0 -105
- package/src/channels/gitlab/defaults.ts +0 -80
- package/src/channels/gitlab/events.ts +0 -37
- package/src/channels/gitlab/gitlab-channel.ts +0 -160
- package/src/channels/gitlab/gitlab-webhook.ts +0 -509
- package/src/channels/gitlab/index.ts +0 -44
- package/src/channels/gitlab/replay.ts +0 -328
- package/src/channels/gitlab/state.ts +0 -55
- package/src/channels/gitlab/types.ts +0 -247
- package/src/channels/issues/index.ts +0 -9
- package/src/channels/issues/issues-channel.ts +0 -45
- package/src/channels/issues/types.ts +0 -38
- package/src/channels/origin/api.ts +0 -507
- package/src/channels/origin/binding.ts +0 -114
- package/src/channels/origin/checks.ts +0 -250
- package/src/channels/origin/cursor-account.ts +0 -58
- package/src/channels/origin/defaults.ts +0 -140
- package/src/channels/origin/events.ts +0 -35
- package/src/channels/origin/index.ts +0 -35
- package/src/channels/origin/origin-channel.ts +0 -815
- package/src/channels/origin/origin-webhook.ts +0 -296
- package/src/channels/origin/reactions.ts +0 -72
- package/src/channels/origin/state.ts +0 -54
- package/src/channels/origin/types.ts +0 -295
- package/src/channels/slack/agentic-delivery.ts +0 -634
- package/src/channels/slack/agentic-posted.ts +0 -135
- package/src/channels/slack/agentic-signals.ts +0 -231
- package/src/channels/slack/api.ts +0 -761
- package/src/channels/slack/approvals.ts +0 -279
- package/src/channels/slack/assistant.ts +0 -76
- package/src/channels/slack/attachments.ts +0 -596
- package/src/channels/slack/auth.ts +0 -127
- package/src/channels/slack/blocks.ts +0 -131
- package/src/channels/slack/bot-mentions.ts +0 -318
- package/src/channels/slack/channel-watch.ts +0 -314
- package/src/channels/slack/cli-project.ts +0 -249
- package/src/channels/slack/code-fences.ts +0 -171
- package/src/channels/slack/constants.ts +0 -38
- package/src/channels/slack/credentials.ts +0 -88
- package/src/channels/slack/defaults.ts +0 -714
- package/src/channels/slack/dispatch.ts +0 -1060
- package/src/channels/slack/doctor.ts +0 -338
- package/src/channels/slack/eval-directive.ts +0 -306
- package/src/channels/slack/event-id-dedupe.ts +0 -30
- package/src/channels/slack/external-policy.ts +0 -75
- package/src/channels/slack/footer.ts +0 -106
- package/src/channels/slack/inbound.ts +0 -416
- package/src/channels/slack/index.ts +0 -53
- package/src/channels/slack/init.ts +0 -169
- package/src/channels/slack/interactive.ts +0 -406
- package/src/channels/slack/links.ts +0 -23
- package/src/channels/slack/live-delivery.ts +0 -489
- package/src/channels/slack/log.ts +0 -70
- package/src/channels/slack/manifest.ts +0 -240
- package/src/channels/slack/message-body.ts +0 -82
- package/src/channels/slack/nudge-carrier.ts +0 -224
- package/src/channels/slack/nudge-store.ts +0 -334
- package/src/channels/slack/paint-start.ts +0 -93
- package/src/channels/slack/placeholder.ts +0 -358
- package/src/channels/slack/pr-ref.ts +0 -74
- package/src/channels/slack/progress-delivery.ts +0 -138
- package/src/channels/slack/reasoning-card.ts +0 -125
- package/src/channels/slack/reasoning-chip.ts +0 -41
- package/src/channels/slack/recording-sink.ts +0 -167
- package/src/channels/slack/redact.ts +0 -6
- package/src/channels/slack/reply-options.ts +0 -279
- package/src/channels/slack/setup.ts +0 -125
- package/src/channels/slack/slack-channel.ts +0 -744
- package/src/channels/slack/socket-mode.ts +0 -140
- package/src/channels/slack/stop.ts +0 -25
- package/src/channels/slack/stream.ts +0 -66
- package/src/channels/slack/thread-context.ts +0 -485
- package/src/channels/slack/tool-approval-events.ts +0 -233
- package/src/channels/slack/tool-cards.ts +0 -198
- package/src/channels/slack/tool-chip.ts +0 -34
- package/src/channels/slack/types.ts +0 -787
- package/src/channels/slack/upload.ts +0 -137
- package/src/channels.ts +0 -543
- package/src/connections.ts +0 -153
- package/src/dashboard-session-url.ts +0 -30
- package/src/evals/assertions.ts +0 -688
- package/src/evals/expect.ts +0 -250
- package/src/evals/judge.ts +0 -329
- package/src/evals/loaders.ts +0 -111
- package/src/evals/matchers.ts +0 -223
- package/src/evals/reporters.ts +0 -257
- package/src/evals/results.ts +0 -130
- package/src/evals/run-facts.ts +0 -306
- package/src/evals.ts +0 -709
- package/src/extensions/cursor-cloud-agents/extension.ts +0 -131
- package/src/extensions/cursor-cloud-agents/lib/backend.ts +0 -386
- package/src/extensions/cursor-cloud-agents/lib/channels.ts +0 -11
- package/src/extensions/cursor-cloud-agents/lib/fleet.ts +0 -98
- package/src/extensions/cursor-cloud-agents/lib/inputs.ts +0 -5
- package/src/extensions/cursor-cloud-agents/lib/repos.ts +0 -80
- package/src/extensions/cursor-cloud-agents/lib/transcript.ts +0 -19
- package/src/extensions/cursor-cloud-agents/skills/handoff.md +0 -37
- package/src/extensions/cursor-cloud-agents/tools/cancel.ts +0 -21
- package/src/extensions/cursor-cloud-agents/tools/dump.ts +0 -47
- package/src/extensions/cursor-cloud-agents/tools/get.ts +0 -18
- package/src/extensions/cursor-cloud-agents/tools/launch.ts +0 -62
- package/src/extensions/cursor-cloud-agents/tools/list.ts +0 -31
- package/src/extensions/cursor-cloud-agents/tools/reply.ts +0 -36
- package/src/extensions/improve/extension.ts +0 -69
- package/src/extensions/improve/skills/yourself.ts +0 -50
- package/src/extensions/jev/extension.ts +0 -95
- package/src/extensions/jev/lib/evaluate.ts +0 -266
- package/src/extensions/jev/skills/gated-write.md +0 -25
- package/src/extensions/jev/skills/questions.md +0 -33
- package/src/extensions/jev/tools/evaluate.ts +0 -82
- package/src/extensions/slack-communication/evals/harness.ts +0 -705
- package/src/extensions/slack-communication/evals/slack-communication.eval.ts +0 -830
- package/src/extensions/slack-communication/evals/slack-placeholder.eval.ts +0 -172
- package/src/extensions/slack-communication/extension.ts +0 -44
- package/src/extensions/slack-communication/skills/slack-voice.ts +0 -56
- package/src/extensions/slack-communication/tools/delete-message.ts +0 -33
- package/src/extensions/slack-communication/tools/edit-message.ts +0 -42
- package/src/extensions/slack-communication/tools/post-card.ts +0 -28
- package/src/extensions/slack-communication/tools/post-file.ts +0 -82
- package/src/extensions/slack-communication/tools/post-update.ts +0 -40
- package/src/extensions/slack-communication/tools/react.ts +0 -30
- package/src/extensions/slack-communication/tools/set-status.ts +0 -21
- package/src/extensions.ts +0 -179
- package/src/files-backends/agent-store-presigned-url.ts +0 -11
- package/src/files-backends/cursor-hosted.ts +0 -1212
- package/src/files-backends/local-fs.ts +0 -163
- package/src/files.ts +0 -293
- package/src/filesystem.ts +0 -2005
- package/src/hooks.ts +0 -30
- package/src/index.ts +0 -259
- package/src/internal/advertise-tools.ts +0 -370
- package/src/internal/approval-gate.ts +0 -103
- package/src/internal/artifacts-store.ts +0 -836
- package/src/internal/as-of.ts +0 -257
- package/src/internal/auth.ts +0 -46
- package/src/internal/authored-alias-hooks.ts +0 -138
- package/src/internal/authored-loaders.ts +0 -188
- package/src/internal/bounded-int.ts +0 -24
- package/src/internal/bounded.ts +0 -25
- package/src/internal/brand.ts +0 -28
- package/src/internal/browser-origin-guard.ts +0 -67
- package/src/internal/builtin-tools/artifacts.ts +0 -62
- package/src/internal/builtin-tools/index.ts +0 -53
- package/src/internal/builtin-tools/reminders.ts +0 -145
- package/src/internal/channel-dispatch.ts +0 -129
- package/src/internal/channel-route-dispatch.ts +0 -58
- package/src/internal/channel-state.ts +0 -83
- package/src/internal/chat-client.ts +0 -594
- package/src/internal/cli-ax.ts +0 -2273
- package/src/internal/cli-bitbucket.ts +0 -438
- package/src/internal/cli-convert-automation.ts +0 -335
- package/src/internal/cli-cursor.ts +0 -282
- package/src/internal/cli-deploy.ts +0 -2486
- package/src/internal/cli-docs.ts +0 -192
- package/src/internal/cli-github.ts +0 -806
- package/src/internal/cli-gitlab.ts +0 -452
- package/src/internal/cli-images.ts +0 -672
- package/src/internal/cli-manifest.ts +0 -56
- package/src/internal/cli-mcp-oauth.ts +0 -395
- package/src/internal/cli-mcp.ts +0 -808
- package/src/internal/cli-skills.ts +0 -99
- package/src/internal/cli-slack-manual.ts +0 -418
- package/src/internal/cli-slack.ts +0 -874
- package/src/internal/cloud-merge.ts +0 -51
- package/src/internal/cloud-turn-cost.ts +0 -159
- package/src/internal/continuation-channel.ts +0 -233
- package/src/internal/continuation-identity.ts +0 -935
- package/src/internal/conversation-mirror.ts +0 -423
- package/src/internal/convert-automation/convert-workflow.ts +0 -1377
- package/src/internal/convert-automation/slug.ts +0 -29
- package/src/internal/convert-automation/types.ts +0 -212
- package/src/internal/cron.ts +0 -76
- package/src/internal/cursor/account-mcp.ts +0 -692
- package/src/internal/cursor/backend-client.ts +0 -978
- package/src/internal/cursor/bound-secret-file.ts +0 -101
- package/src/internal/cursor/credentials.ts +0 -560
- package/src/internal/cursor/cursor-api-transport.ts +0 -65
- package/src/internal/cursor/github-credentials.ts +0 -228
- package/src/internal/cursor/hosted-bound-secrets.ts +0 -71
- package/src/internal/cursor/hosted-deployment-secrets.ts +0 -100
- package/src/internal/cursor/hosted-store-secrets.ts +0 -152
- package/src/internal/cursor/session-token.ts +0 -111
- package/src/internal/cursor/store-api-client.ts +0 -323
- package/src/internal/cursor-account-mcp-auth.ts +0 -303
- package/src/internal/cursor-agent-template.ts +0 -50
- package/src/internal/cursor-deployment-relay.ts +0 -315
- package/src/internal/cursor-event-relay.ts +0 -675
- package/src/internal/cursor-relay-core.ts +0 -563
- package/src/internal/deferred-channel-session.ts +0 -61
- package/src/internal/deploy-client.ts +0 -1504
- package/src/internal/deploy-manifest.ts +0 -361
- package/src/internal/deploy-source.ts +0 -144
- package/src/internal/describe-error.ts +0 -32
- package/src/internal/dev-mode.ts +0 -20
- package/src/internal/discovery/agent-config.ts +0 -288
- package/src/internal/discovery/agent.ts +0 -381
- package/src/internal/discovery/channels.ts +0 -100
- package/src/internal/discovery/connections.ts +0 -505
- package/src/internal/discovery/context.ts +0 -38
- package/src/internal/discovery/cursor-plugin.ts +0 -628
- package/src/internal/discovery/extension-overlay.ts +0 -247
- package/src/internal/discovery/extensions.ts +0 -490
- package/src/internal/discovery/fs.ts +0 -103
- package/src/internal/discovery/hooks.ts +0 -63
- package/src/internal/discovery/info.ts +0 -174
- package/src/internal/discovery/instructions.ts +0 -98
- package/src/internal/discovery/modules.ts +0 -107
- package/src/internal/discovery/names.ts +0 -45
- package/src/internal/discovery/project.ts +0 -319
- package/src/internal/discovery/reminders.ts +0 -65
- package/src/internal/discovery/runtime.ts +0 -158
- package/src/internal/discovery/schedules.ts +0 -120
- package/src/internal/discovery/seed-files.ts +0 -34
- package/src/internal/discovery/services.ts +0 -151
- package/src/internal/discovery/skills.ts +0 -174
- package/src/internal/discovery/subagent.ts +0 -138
- package/src/internal/discovery/tools.ts +0 -170
- package/src/internal/discovery.ts +0 -27
- package/src/internal/distribution.ts +0 -126
- package/src/internal/docs-site.ts +0 -248
- package/src/internal/duration.ts +0 -37
- package/src/internal/env-file.ts +0 -83
- package/src/internal/eval-judge-model.ts +0 -142
- package/src/internal/eval-run-store.ts +0 -585
- package/src/internal/eval-runner.ts +0 -823
- package/src/internal/evals-client.ts +0 -475
- package/src/internal/event-log.ts +0 -342
- package/src/internal/event-mapper.ts +0 -811
- package/src/internal/expected-delivery-failure.ts +0 -34
- package/src/internal/factory-resource-channel.ts +0 -103
- package/src/internal/filesystem/errors.ts +0 -207
- package/src/internal/filesystem/format.ts +0 -253
- package/src/internal/filesystem/merge.ts +0 -192
- package/src/internal/filesystem/nearest.ts +0 -112
- package/src/internal/filesystem/scratch.ts +0 -239
- package/src/internal/filesystem/sdk-schemas.ts +0 -204
- package/src/internal/filesystem/tools.ts +0 -804
- package/src/internal/filesystem/walk.ts +0 -366
- package/src/internal/fixtures/units-server.ts +0 -52
- package/src/internal/framework-file-storage.ts +0 -357
- package/src/internal/framework-storage-selection.ts +0 -156
- package/src/internal/frontmatter.ts +0 -108
- package/src/internal/github-fanout.ts +0 -144
- package/src/internal/guest-network.ts +0 -391
- package/src/internal/handleAgentServeTrigger.ts +0 -286
- package/src/internal/host-files.ts +0 -341
- package/src/internal/host-kv.ts +0 -81
- package/src/internal/host-otel.ts +0 -231
- package/src/internal/host-platforms.ts +0 -170
- package/src/internal/hosted-admission-adapter.ts +0 -47
- package/src/internal/hosted-admission-context.ts +0 -37
- package/src/internal/hosted-catch-protocol.ts +0 -112
- package/src/internal/hosted-catch.ts +0 -179
- package/src/internal/hosted-delivery-protocol.ts +0 -787
- package/src/internal/hosted-delivery.ts +0 -1152
- package/src/internal/hosted-execution-diag.ts +0 -291
- package/src/internal/hosted-execution-flush.ts +0 -136
- package/src/internal/hosted-execution-latency.ts +0 -301
- package/src/internal/hosted-managed-automation.ts +0 -116
- package/src/internal/hosting.ts +0 -107
- package/src/internal/http-channel-define.ts +0 -25
- package/src/internal/http-channel.ts +0 -669
- package/src/internal/http-control-plane-session.ts +0 -110
- package/src/internal/ids.ts +0 -39
- package/src/internal/incoming-headers-to-fetch.ts +0 -45
- package/src/internal/init-interview.ts +0 -360
- package/src/internal/init-project.ts +0 -711
- package/src/internal/init-scaffold.ts +0 -182
- package/src/internal/inline-stdio-define-stub.ts +0 -4
- package/src/internal/inline-stdio-mcp.ts +0 -230
- package/src/internal/install-cursor-skills.ts +0 -601
- package/src/internal/is-record.ts +0 -3
- package/src/internal/json-schema.ts +0 -95
- package/src/internal/legacy-command-guard.ts +0 -54
- package/src/internal/listen-port.ts +0 -85
- package/src/internal/local-control-plane.ts +0 -442
- package/src/internal/local-env.ts +0 -59
- package/src/internal/local-ingress.ts +0 -90
- package/src/internal/log-ring.ts +0 -59
- package/src/internal/logs-client.ts +0 -477
- package/src/internal/map-pool.ts +0 -39
- package/src/internal/mcp-endpoint.ts +0 -747
- package/src/internal/mcp-host.ts +0 -481
- package/src/internal/mcp-oauth-on-demand.ts +0 -337
- package/src/internal/mcp-oauth-persist.ts +0 -118
- package/src/internal/mcp-oauth.ts +0 -549
- package/src/internal/net.ts +0 -29
- package/src/internal/open-browser.ts +0 -41
- package/src/internal/otel/attrs.ts +0 -16
- package/src/internal/otel/collector.ts +0 -937
- package/src/internal/otel/config.ts +0 -287
- package/src/internal/otel/http.ts +0 -122
- package/src/internal/otel/mcp.ts +0 -56
- package/src/internal/otel/propagation.ts +0 -17
- package/src/internal/otel/runtime.ts +0 -441
- package/src/internal/package-inline-stdio.ts +0 -114
- package/src/internal/peer-connections.ts +0 -96
- package/src/internal/platform-schedule-sync.ts +0 -75
- package/src/internal/platform-timers.ts +0 -365
- package/src/internal/playground/static.ts +0 -278
- package/src/internal/playground/toolchain.ts +0 -270
- package/src/internal/playground-proxy.ts +0 -564
- package/src/internal/process-memory-telemetry.ts +0 -334
- package/src/internal/project-layout.ts +0 -31
- package/src/internal/prompt-context.ts +0 -116
- package/src/internal/reminder-control-plane-protocol.ts +0 -482
- package/src/internal/reminder-runner.ts +0 -1559
- package/src/internal/reminder-schedule.ts +0 -104
- package/src/internal/reminder-store.ts +0 -176
- package/src/internal/request-error-status.ts +0 -95
- package/src/internal/request-headers.ts +0 -21
- package/src/internal/resolve-prod-target.ts +0 -334
- package/src/internal/resolved-connections.ts +0 -190
- package/src/internal/router.ts +0 -143
- package/src/internal/run-client.ts +0 -354
- package/src/internal/runtime-dispatch-runner.ts +0 -50
- package/src/internal/sanitize-mcp-tool-name.ts +0 -31
- package/src/internal/schedule-runner.ts +0 -154
- package/src/internal/scm/pr-url.ts +0 -245
- package/src/internal/sdk-runner.ts +0 -948
- package/src/internal/serve-restart.ts +0 -113
- package/src/internal/server.ts +0 -3135
- package/src/internal/session-cost.ts +0 -208
- package/src/internal/session-engine.ts +0 -5618
- package/src/internal/session-links.ts +0 -84
- package/src/internal/session-run-log.ts +0 -535
- package/src/internal/session-store.ts +0 -307
- package/src/internal/session-urls.ts +0 -32
- package/src/internal/sessions-client.ts +0 -239
- package/src/internal/skill-catalog.ts +0 -66
- package/src/internal/skills-sync.ts +0 -55
- package/src/internal/slack-provision-client.ts +0 -544
- package/src/internal/slack-thread-key.ts +0 -11
- package/src/internal/sleep.ts +0 -3
- package/src/internal/start-log-store.ts +0 -164
- package/src/internal/steering.ts +0 -17
- package/src/internal/storage-coordinator.ts +0 -800
- package/src/internal/storage-roles.ts +0 -86
- package/src/internal/storage.ts +0 -1
- package/src/internal/store-api-protocol.ts +0 -205
- package/src/internal/store-mirror.ts +0 -73
- package/src/internal/stream-progress.ts +0 -294
- package/src/internal/terminal-style.ts +0 -133
- package/src/internal/testing/factory-resource-fixtures.ts +0 -84
- package/src/internal/testing/scm-continuation-fixtures.ts +0 -285
- package/src/internal/tool-catalog.ts +0 -104
- package/src/internal/tool-policy.ts +0 -222
- package/src/internal/tool-result.ts +0 -50
- package/src/internal/trajectory.ts +0 -418
- package/src/internal/turn-cost.ts +0 -136
- package/src/internal/turn-governor.ts +0 -145
- package/src/internal/turn-lease-store.ts +0 -144
- package/src/internal/turn-outbox.ts +0 -77
- package/src/internal/update-check.ts +0 -517
- package/src/internal/v2-hosting.ts +0 -52
- package/src/internal/workspace-sync.ts +0 -114
- package/src/internal/workspace.ts +0 -505
- package/src/kv/memory-kv.ts +0 -94
- package/src/kv.ts +0 -18
- package/src/memory.ts +0 -487
- package/src/otel-public.ts +0 -24
- package/src/otel.ts +0 -320
- package/src/prompt.ts +0 -80
- package/src/reminders.ts +0 -65
- package/src/schedules.ts +0 -31
- package/src/skills.ts +0 -27
- package/src/storage-backends/cursor-hosted-v2.ts +0 -204
- package/src/storage-backends/cursor-hosted.ts +0 -388
- package/src/storage-backends/file-kv.ts +0 -276
- package/src/storage-protocol.ts +0 -261
- package/src/storage.ts +0 -408
- package/src/tools.ts +0 -166
- package/src/types.ts +0 -3766
- /package/dist/docs/assets/{reference_agent-config.md.DzGI777n.lean.js → reference_agent-config.md.Cj5uBKp4.lean.js} +0 -0
- /package/dist/docs/assets/{reference_artifacts.md.CFMNPreZ.lean.js → reference_artifacts.md.CQfKq8F2.lean.js} +0 -0
package/src/types.ts
DELETED
|
@@ -1,3766 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Public types for @cursor/bdk.
|
|
3
|
-
*
|
|
4
|
-
* The framework is filesystem-first: customers author an agent as files under
|
|
5
|
-
* an `agent/` directory (markdown for prose, TypeScript for typed behavior),
|
|
6
|
-
* and the framework discovers those files, compiles them into an
|
|
7
|
-
* {@link AgentProject}, and serves the agent over channels using the Cursor
|
|
8
|
-
* SDK as the execution harness.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type { InteractionUpdate, SDKCustomTool, ToolName } from "@cursor/sdk";
|
|
12
|
-
import type { z } from "zod";
|
|
13
|
-
import type { FileSystem } from "./filesystem.js";
|
|
14
|
-
import type {
|
|
15
|
-
ContinuationClaim,
|
|
16
|
-
ContinuationIdentity,
|
|
17
|
-
MailboxContinuation,
|
|
18
|
-
} from "./internal/continuation-identity.js";
|
|
19
|
-
import type { OtelConfig, OtelDefinition } from "./otel.js";
|
|
20
|
-
import type { StorageDefinition } from "./storage.js";
|
|
21
|
-
|
|
22
|
-
// ============================================================================
|
|
23
|
-
// JSON
|
|
24
|
-
// ============================================================================
|
|
25
|
-
|
|
26
|
-
export type JsonPrimitive = string | number | boolean | null;
|
|
27
|
-
export type JsonValue = JsonPrimitive | JsonValue[] | JsonObject;
|
|
28
|
-
export type JsonObject = { [key: string]: JsonValue };
|
|
29
|
-
|
|
30
|
-
/** A plain JSON Schema object (already-serialized tool input schema). */
|
|
31
|
-
export type JsonSchemaObject = Record<string, unknown>;
|
|
32
|
-
|
|
33
|
-
// ============================================================================
|
|
34
|
-
// Definition branding
|
|
35
|
-
// ============================================================================
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Discriminates the `define*` helper that produced a module's default export
|
|
39
|
-
* so discovery can validate that a file landed in the right authored slot.
|
|
40
|
-
*/
|
|
41
|
-
export type DefinitionKind =
|
|
42
|
-
| "agent"
|
|
43
|
-
| "instructions"
|
|
44
|
-
| "tool"
|
|
45
|
-
| "skill"
|
|
46
|
-
| "extension"
|
|
47
|
-
| "disabled-tool"
|
|
48
|
-
| "disabled-connection"
|
|
49
|
-
| "disabled"
|
|
50
|
-
| "connection"
|
|
51
|
-
| "channel"
|
|
52
|
-
| "http-channel"
|
|
53
|
-
| "schedule"
|
|
54
|
-
| "reminder"
|
|
55
|
-
| "hook"
|
|
56
|
-
| "eval"
|
|
57
|
-
| "storage"
|
|
58
|
-
| "artifacts"
|
|
59
|
-
| "otel";
|
|
60
|
-
|
|
61
|
-
export interface BrandedDefinition<K extends DefinitionKind> {
|
|
62
|
-
readonly __agentServe: K;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// ============================================================================
|
|
66
|
-
// Agent config (agent.ts)
|
|
67
|
-
// ============================================================================
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* A Cursor model selection. Either a bare model id (`"gpt-5.2"`) or an id
|
|
71
|
-
* with model parameters, mirroring the Cursor SDK's `ModelSelection`.
|
|
72
|
-
*/
|
|
73
|
-
export type ModelSetting =
|
|
74
|
-
| string
|
|
75
|
-
| {
|
|
76
|
-
id: string;
|
|
77
|
-
params?: Array<{ id: string; value: string }>;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Model used when the root agent omits `model` (local Cursor agents have no
|
|
82
|
-
* harness-level default of their own).
|
|
83
|
-
*/
|
|
84
|
-
export const DEFAULT_MODEL: ModelSetting = {
|
|
85
|
-
id: "grok-4.5",
|
|
86
|
-
params: [
|
|
87
|
-
{ id: "effort", value: "high" },
|
|
88
|
-
{ id: "fast", value: "true" },
|
|
89
|
-
],
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
/** Runtime selector. New public agents use the default local runtime. */
|
|
93
|
-
export type AgentRuntime = "local" | "cloud" | "grokbot";
|
|
94
|
-
|
|
95
|
-
/** Options used when launching Cursor cloud agents. */
|
|
96
|
-
export interface AgentCloudOptions {
|
|
97
|
-
env?:
|
|
98
|
-
| { type: "cloud"; name?: string }
|
|
99
|
-
| { type: "pool"; name?: string }
|
|
100
|
-
| { type: "machine"; name?: string };
|
|
101
|
-
repos?: Array<{
|
|
102
|
-
url: string;
|
|
103
|
-
startingRef?: string;
|
|
104
|
-
prUrl?: string;
|
|
105
|
-
}>;
|
|
106
|
-
workOnCurrentBranch?: boolean;
|
|
107
|
-
autoCreatePR?: boolean;
|
|
108
|
-
skipReviewerRequest?: boolean;
|
|
109
|
-
/**
|
|
110
|
-
* Per-session env vars injected into the cloud agent's shell.
|
|
111
|
-
* When set, the cloud API mints the SDK agent id (persisted as
|
|
112
|
-
* {@link SessionRecord.sdkAgentId}).
|
|
113
|
-
*/
|
|
114
|
-
envVars?: Record<string, string>;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/** Safe `/v1/info` projection of {@link AgentCloudOptions}; secret values are omitted. */
|
|
118
|
-
export type AgentCloudPublicInfo = Omit<AgentCloudOptions, "envVars"> & {
|
|
119
|
-
envVarsConfigured?: boolean;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
function redactHttpUrlCredentials(url: string): string {
|
|
123
|
-
try {
|
|
124
|
-
const parsed = new URL(url);
|
|
125
|
-
if (parsed.username !== "" || parsed.password !== "") {
|
|
126
|
-
parsed.username = "";
|
|
127
|
-
parsed.password = "";
|
|
128
|
-
}
|
|
129
|
-
return parsed.toString();
|
|
130
|
-
} catch {
|
|
131
|
-
return url.replace(/^(https?:\/\/)[^@/]+@/i, "$1");
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export function toPublicCloudInfo(cloud: AgentCloudOptions): AgentCloudPublicInfo {
|
|
136
|
-
const { envVars, repos, ...rest } = cloud;
|
|
137
|
-
const hasEnvVars = envVars !== undefined && Object.keys(envVars).length > 0;
|
|
138
|
-
return {
|
|
139
|
-
...rest,
|
|
140
|
-
...(repos !== undefined
|
|
141
|
-
? {
|
|
142
|
-
repos: repos.map(repo => ({
|
|
143
|
-
...repo,
|
|
144
|
-
url: redactHttpUrlCredentials(repo.url),
|
|
145
|
-
...(repo.prUrl !== undefined ? { prUrl: redactHttpUrlCredentials(repo.prUrl) } : {}),
|
|
146
|
-
})),
|
|
147
|
-
}
|
|
148
|
-
: {}),
|
|
149
|
-
...(hasEnvVars ? { envVarsConfigured: true } : {}),
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Session-scoped facts a `root` factory needs and does not otherwise
|
|
155
|
-
* have at `defineAgent` time. The factory returns a handle: each
|
|
156
|
-
* method must observe the current binding. Do not snapshot the tree.
|
|
157
|
-
*/
|
|
158
|
-
export interface RootContext {
|
|
159
|
-
sessionId: string;
|
|
160
|
-
agentName?: string;
|
|
161
|
-
continuationKey?: string;
|
|
162
|
-
host?: { files: HostFilesApi; reminders?: ReminderHostApi; kv?: HostKvApi };
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/** Input to `defineAgent` (authored at `agent/agent.ts`). */
|
|
166
|
-
export interface AgentConfig {
|
|
167
|
-
/**
|
|
168
|
-
* Cursor model to run the agent on. Defaults to {@link DEFAULT_MODEL} on
|
|
169
|
-
* the root agent when omitted. Subagents omit it to inherit the parent's
|
|
170
|
-
* model.
|
|
171
|
-
*/
|
|
172
|
-
model?: ModelSetting;
|
|
173
|
-
/**
|
|
174
|
-
* Models to try, in order, when {@link model} is rejected before the
|
|
175
|
-
* turn produces any output: catalog refusal ("Cannot use this model")
|
|
176
|
-
* or a capacity error (`resource_exhausted` / `[unavailable]`). The
|
|
177
|
-
* rejection is usually inside agent creation, before authored tools
|
|
178
|
-
* run, so a fallback list on the agent is the only retry that can save
|
|
179
|
-
* the turn. Each entry is the same shape as {@link model}.
|
|
180
|
-
*/
|
|
181
|
-
fallbacks?: readonly ModelSetting[];
|
|
182
|
-
/**
|
|
183
|
-
* What this agent is for. Required on subagents: the parent model reads it
|
|
184
|
-
* to decide when to delegate. Optional (documentation only) on the root.
|
|
185
|
-
*/
|
|
186
|
-
description?: string;
|
|
187
|
-
/** Display name override. Defaults to the package name / directory name. */
|
|
188
|
-
name?: string;
|
|
189
|
-
/**
|
|
190
|
-
* Inline instructions. Prefer `instructions.md` next to `agent.ts`; this
|
|
191
|
-
* exists for subagents and generated configs.
|
|
192
|
-
*/
|
|
193
|
-
instructions?: string;
|
|
194
|
-
/**
|
|
195
|
-
* Execution runtime. Defaults to `"local"`. Compatibility strings
|
|
196
|
-
* `"cloud"` and `"grokbot"` remain for agents that already ship; they
|
|
197
|
-
* are not a product surface. New agents omit this field.
|
|
198
|
-
*/
|
|
199
|
-
runtime?: AgentRuntime;
|
|
200
|
-
/**
|
|
201
|
-
* The FileSystem the model can see. Omit it and the root is the host
|
|
202
|
-
* disk. A static handle (`tempFs`, `unionFs`, ...) is that object on
|
|
203
|
-
* every session — writes are shared. Pass `(ctx) => …` and return a
|
|
204
|
-
* new handle per session when you want isolation. A factory that
|
|
205
|
-
* returns the same object still shares. Incompatible with
|
|
206
|
-
* {@link local} `cwd` / `workspaceDir` / `sandbox` and with
|
|
207
|
-
* {@link runtime} `"cloud"`.
|
|
208
|
-
*/
|
|
209
|
-
root?: FileSystem | ((ctx: RootContext) => FileSystem | Promise<FileSystem>);
|
|
210
|
-
/**
|
|
211
|
-
* Cloud attach defaults merged under per-session
|
|
212
|
-
* {@link SendMessageOptions.cloud}. Used by existing agents that still
|
|
213
|
-
* set {@link runtime} `"cloud"` and by hybrid channel/tool handoffs.
|
|
214
|
-
* In-process `agent/tools` run on local turns only.
|
|
215
|
-
*/
|
|
216
|
-
cloud?: AgentCloudOptions;
|
|
217
|
-
/** Local harness defaults. */
|
|
218
|
-
local?: AgentLocalOptions;
|
|
219
|
-
/**
|
|
220
|
-
* Managed-hosting declarations (`agent-sdk deploy` onto Cursor's
|
|
221
|
-
* agent-serve hosting). The manifest is the source of truth: deploy reads
|
|
222
|
-
* it and sends it with the deployment request. Ignored by local serving.
|
|
223
|
-
*/
|
|
224
|
-
hosting?: AgentHostingOptions;
|
|
225
|
-
/**
|
|
226
|
-
* Engine-wide turn admission limits. See {@link AgentConcurrencyOptions}.
|
|
227
|
-
*/
|
|
228
|
-
concurrency?: AgentConcurrencyOptions;
|
|
229
|
-
/**
|
|
230
|
-
* Framework-provided model-facing tools, opted in per capability. See
|
|
231
|
-
* {@link BuiltinToolsConfig}.
|
|
232
|
-
*/
|
|
233
|
-
builtinTools?: BuiltinToolsConfig;
|
|
234
|
-
/**
|
|
235
|
-
* Allowlist of built-in harness tools offered to the model
|
|
236
|
-
* (`AgentOptions.tools` on the SDK). Opt-in by design: unset keeps the
|
|
237
|
-
* model's full standard toolset, and once set the agent gets exactly
|
|
238
|
-
* what it names — nothing more, `[]` meaning no native built-in tools.
|
|
239
|
-
* There is deliberately no exclusion form: an agent that restricts
|
|
240
|
-
* tools states what it keeps, so tools the platform adds later stay
|
|
241
|
-
* off until someone opts in.
|
|
242
|
-
*
|
|
243
|
-
* `"mcp"` is always granted alongside a configured allowlist. It is
|
|
244
|
-
* transport, not capability: this kit's own server tools reach the
|
|
245
|
-
* model over the SDK custom-tool MCP path, so omitting it would
|
|
246
|
-
* silently strand `agent/tools/`. What MCP actually exposes stays
|
|
247
|
-
* governed by the second layer — the tools you author, the connections
|
|
248
|
-
* you declare, and the harness cwd's ambient `.cursor` config (point
|
|
249
|
-
* `local.cwd` outside checkouts whose MCP servers the agent must not
|
|
250
|
-
* see, and `local.sandbox` makes MCP calls fail closed).
|
|
251
|
-
*
|
|
252
|
-
* Names use the SDK's public tool vocabulary (`"shell"`, `"read"`,
|
|
253
|
-
* `"edit"`, `"grep"`, `"glob"`, `"ls"`, `"task"`, ...). `"shell"` is a
|
|
254
|
-
* capability group that also grants shell stdin writes — and is what
|
|
255
|
-
* `execution: "agent"` tool scripts run through, so an allowlist
|
|
256
|
-
* without it strands them (discovery warns). `"task"` gates subagents.
|
|
257
|
-
* Unknown names fail the turn (`ConfigurationError` at `Agent.create`).
|
|
258
|
-
*
|
|
259
|
-
* This is not a security boundary against the serve host: like
|
|
260
|
-
* `local.sandbox`, it only shapes what the model can call.
|
|
261
|
-
*/
|
|
262
|
-
tools?: ToolName[];
|
|
263
|
-
/**
|
|
264
|
-
* Hosted architecture. Defaults to `"v2"`. Set `"v1"` to stay on the
|
|
265
|
-
* resident-engine architecture.
|
|
266
|
-
*/
|
|
267
|
-
architecture?: AgentArchitecture;
|
|
268
|
-
/**
|
|
269
|
-
* Persistent hosting for `architecture: "v2"`.
|
|
270
|
-
*
|
|
271
|
-
* Default (`false`): each session boots a pod from the release snapshot;
|
|
272
|
-
* framework and author state are mirrored to Cursor stores because pod
|
|
273
|
-
* disks are disposable.
|
|
274
|
-
*
|
|
275
|
-
* `true`: one long-lived pod per deployment runs each deployed version as
|
|
276
|
-
* a container over one state directory on the pod's disk. Nothing is
|
|
277
|
-
* mirrored: that directory is the durable copy. A redeploy starts the new
|
|
278
|
-
* version beside the old one on the same state, then drains the old one.
|
|
279
|
-
*/
|
|
280
|
-
persistent?: boolean;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
/** Hosted architecture on {@link AgentConfig.architecture}. */
|
|
284
|
-
export type AgentArchitecture = "v1" | "v2";
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Built-in tools on {@link AgentConfig.builtinTools}. Each enabled
|
|
288
|
-
* capability materializes as ordinary server tools at discovery time, so
|
|
289
|
-
* turns, direct calls, `info`, and the playground treat them like authored
|
|
290
|
-
* tools. Authored tools with the same name win with a warning.
|
|
291
|
-
*/
|
|
292
|
-
export interface BuiltinToolsConfig {
|
|
293
|
-
/**
|
|
294
|
-
* Reminder tools bound to the current conversation, over
|
|
295
|
-
* {@link HostContext.reminders}: `reminders_create`, `reminders_list`,
|
|
296
|
-
* and `reminders_cancel` (the name the framework's reminder fire prompt
|
|
297
|
-
* tells the model to call when a stop condition is met). Sessions
|
|
298
|
-
* without a continuation key cannot arm reminders.
|
|
299
|
-
*/
|
|
300
|
-
reminders?: boolean;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Turn admission limits on {@link AgentConfig.concurrency}.
|
|
305
|
-
*
|
|
306
|
-
* ```ts
|
|
307
|
-
* export default defineAgent({
|
|
308
|
-
* // At most 3 sessions run a model turn at once; the rest queue FIFO.
|
|
309
|
-
* concurrency: { maxRunningTurns: 3 },
|
|
310
|
-
* });
|
|
311
|
-
* ```
|
|
312
|
-
*/
|
|
313
|
-
export interface AgentConcurrencyOptions {
|
|
314
|
-
/**
|
|
315
|
-
* Max model turns running at once across **all** of this agent's
|
|
316
|
-
* sessions. When every slot is busy, newly admitted turns queue FIFO
|
|
317
|
-
* (surfaced as a durable `turn.queued` event and `queued: true` on
|
|
318
|
-
* `GET /v1/sessions`) instead of failing; each queued turn starts as
|
|
319
|
-
* soon as a slot frees. Positive integer, hard-capped at
|
|
320
|
-
* {@link MAX_RUNNING_TURNS_LIMIT}. Omit for unlimited.
|
|
321
|
-
*
|
|
322
|
-
* A queued turn still counts as `running` for busy semantics
|
|
323
|
-
* (follow-ups preempt it; direct write-effect tool calls get
|
|
324
|
-
* `SessionBusyError`),
|
|
325
|
-
* and a follow-up that preempts a queued turn re-queues at the back.
|
|
326
|
-
*/
|
|
327
|
-
maxRunningTurns?: number;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Hard ceiling for {@link AgentConcurrencyOptions.maxRunningTurns}.
|
|
332
|
-
* Matches the eval harness ceiling: each running turn issues model
|
|
333
|
-
* provider requests, so unbounded parallelism is never meaningful.
|
|
334
|
-
*/
|
|
335
|
-
export const MAX_RUNNING_TURNS_LIMIT = 200;
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* Managed-hosting block on {@link AgentConfig.hosting}.
|
|
339
|
-
*/
|
|
340
|
-
export interface AgentHostingOptions {
|
|
341
|
-
/**
|
|
342
|
-
* Domains the deployed engine pod may reach (egress allowlist), e.g.
|
|
343
|
-
* `"api.example.com"` or `"*.example.com"` (single leading wildcard).
|
|
344
|
-
* Lowercase hostnames with at least two labels and an alphabetic TLD;
|
|
345
|
-
* max 20. `agent-sdk deploy` sends these as `egressAllowedDomains`
|
|
346
|
-
* (unioned with any `--allow-domain` flags). Only valid on repo-backed
|
|
347
|
-
* deployments. Deployment-scoped like {@link secretNames}: not capped by
|
|
348
|
-
* the team's Cloud Agent egress allowlist. The platform still merges a
|
|
349
|
-
* bootstrap set (npm, Slack, Cursor API) at provision time.
|
|
350
|
-
*/
|
|
351
|
-
egressDomains?: string[];
|
|
352
|
-
/**
|
|
353
|
-
* Secret names this agent expects at runtime (declarative documentation;
|
|
354
|
-
* values are never authored in files). `agent-sdk deploy` warns when a
|
|
355
|
-
* declared name is not set on the deployment — set values with
|
|
356
|
-
* `agent-sdk secrets set <slug> NAME`.
|
|
357
|
-
*/
|
|
358
|
-
secretNames?: string[];
|
|
359
|
-
/**
|
|
360
|
-
* Name of a container image the team pushed with
|
|
361
|
-
* `agent-sdk images push <local-image> --name <name>`; the deployed agent
|
|
362
|
-
* runs inside it instead of the platform's default `node:22` image. The
|
|
363
|
-
* image must be `linux/amd64` and provide `bash`, `node` (>= 22.13) and
|
|
364
|
-
* `npm` on `PATH`. Requires `architecture: "v2"`; today only
|
|
365
|
-
* `persistent: true` agents honor it. Deploy pins the image bytes it saw
|
|
366
|
-
* (sha256); pushing the same name again takes effect on the next deploy.
|
|
367
|
-
*/
|
|
368
|
-
image?: string;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* Local runtime options on {@link AgentConfig.local}.
|
|
373
|
-
*/
|
|
374
|
-
export interface AgentLocalOptions {
|
|
375
|
-
/**
|
|
376
|
-
* Default local harness cwd parent. Absolute, or relative to the agent
|
|
377
|
-
* project root. Each session uses `<cwd>/<sessionId>` unless a per-send
|
|
378
|
-
* {@link SendMessageOptions.workspaceDir} overrides it.
|
|
379
|
-
*
|
|
380
|
-
* When omitted, a project nested in another git repo (a monorepo package)
|
|
381
|
-
* defaults to `~/.cache/agent-serve/<dir>` so Cursor does not load the
|
|
382
|
-
* enclosing checkout's AGENTS.md, rules, skills, or MCP servers. A
|
|
383
|
-
* standalone git root keeps the in-project session workspace. Point this
|
|
384
|
-
* at a checkout when the agent must inherit that tree.
|
|
385
|
-
*/
|
|
386
|
-
cwd?: string;
|
|
387
|
-
/**
|
|
388
|
-
* One harness cwd shared by every session, for agents that work inside an
|
|
389
|
-
* existing checkout. Absolute, or relative to the agent project root.
|
|
390
|
-
* Takes precedence over {@link cwd}; a per-send
|
|
391
|
-
* {@link SendMessageOptions.workspaceDir} still wins over both.
|
|
392
|
-
*
|
|
393
|
-
* The SDK keys its local executor — Cursor rules, skills, MCP, the ignore
|
|
394
|
-
* mappings — on the harness cwd, so a shared directory resolves the
|
|
395
|
-
* workspace once per serve process instead of once per session. With
|
|
396
|
-
* `cwd`'s `<cwd>/<sessionId>` layout that cache never hits, and on a large
|
|
397
|
-
* repo each session pays the full scan again.
|
|
398
|
-
*
|
|
399
|
-
* Sessions are no longer isolated from each other on disk: they share a
|
|
400
|
-
* working tree, and a file one turn writes is visible to the next. Agent
|
|
401
|
-
* scaffold (`AGENTS.md`, skills, tool scripts) is kept out of the shared
|
|
402
|
-
* directory and delivered inline instead, so pointing this at a repo does
|
|
403
|
-
* not write Agent SDK files into it — but `workspaceFiles` still lands in
|
|
404
|
-
* the harness cwd, as it does for a per-send override.
|
|
405
|
-
*/
|
|
406
|
-
workspaceDir?: string;
|
|
407
|
-
/**
|
|
408
|
-
* Run the harness inside Cursor's local sandbox (`sandboxOptions.enabled`
|
|
409
|
-
* on the SDK). Off by default, matching the SDK: shell then auto-approves
|
|
410
|
-
* and inherits the serve process environment — including any credentials
|
|
411
|
-
* the host holds.
|
|
412
|
-
*
|
|
413
|
-
* Turn this on for agents whose turns read untrusted input (webhook
|
|
414
|
-
* payloads, PR diffs, inbound chat). It is a real tool boundary rather
|
|
415
|
-
* than a prompt-level one, so it still holds when the model is steered
|
|
416
|
-
* into ignoring its instructions.
|
|
417
|
-
*/
|
|
418
|
-
sandbox?: boolean;
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
export type AgentConfigDefinition = AgentConfig & BrandedDefinition<"agent">;
|
|
422
|
-
|
|
423
|
-
/** Input to `defineInstructions` (authored at `agent/instructions.ts`). */
|
|
424
|
-
export interface InstructionsConfig {
|
|
425
|
-
markdown: string;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
export type InstructionsDefinition = InstructionsConfig & BrandedDefinition<"instructions">;
|
|
429
|
-
|
|
430
|
-
// ============================================================================
|
|
431
|
-
// Tools (agent/tools/*.ts)
|
|
432
|
-
// ============================================================================
|
|
433
|
-
|
|
434
|
-
export type ToolResultContent =
|
|
435
|
-
| { type: "text"; text: string }
|
|
436
|
-
| { type: "image"; data: string; mimeType?: string };
|
|
437
|
-
|
|
438
|
-
/**
|
|
439
|
-
* JSON-ish value a tool may return. Unlike {@link JsonValue} this permits
|
|
440
|
-
* `undefined` leaves (and thus optional object properties), because the
|
|
441
|
-
* result is JSON-serialized before it reaches the model and `undefined`
|
|
442
|
-
* fields are simply dropped — so authored tools can return objects shaped by
|
|
443
|
-
* optional fields without fighting the type system.
|
|
444
|
-
*/
|
|
445
|
-
export type ToolResultValue =
|
|
446
|
-
| string
|
|
447
|
-
| number
|
|
448
|
-
| boolean
|
|
449
|
-
| null
|
|
450
|
-
| undefined
|
|
451
|
-
| ToolResultValue[]
|
|
452
|
-
| readonly ToolResultValue[]
|
|
453
|
-
| { [key: string]: ToolResultValue };
|
|
454
|
-
|
|
455
|
-
/**
|
|
456
|
-
* What a tool's `execute` may return. Strings are passed to the model
|
|
457
|
-
* verbatim, JSON values are serialized, and the envelope form carries rich
|
|
458
|
-
* content and an error flag.
|
|
459
|
-
*/
|
|
460
|
-
export type ToolExecuteResult =
|
|
461
|
-
| ToolResultValue
|
|
462
|
-
| {
|
|
463
|
-
content: ToolResultContent[];
|
|
464
|
-
isError?: boolean;
|
|
465
|
-
/**
|
|
466
|
-
* Structured result for tools that declare an `outputSchema`: MCP
|
|
467
|
-
* clients require `structuredContent` on calls to schema-declaring
|
|
468
|
-
* tools. Plain-object returns get it filled in automatically; the
|
|
469
|
-
* envelope form (needed for images or `isError`) sets it here.
|
|
470
|
-
*/
|
|
471
|
-
structuredContent?: JsonObject;
|
|
472
|
-
};
|
|
473
|
-
|
|
474
|
-
/** Repo-agnostic GitHub client on the agent-serve host. */
|
|
475
|
-
export interface HostGitHubClient {
|
|
476
|
-
getOctokit(): Promise<import("@octokit/rest").Octokit>;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
/** Bot-token Slack Web API client on the agent-serve host. */
|
|
480
|
-
export interface HostSlackClient {
|
|
481
|
-
getClient(): Promise<import("@slack/web-api").WebClient>;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
/** Host-side handle for calling an MCP connection from a server tool or channel handler. */
|
|
485
|
-
export interface HostMcpRegistry {
|
|
486
|
-
/** MCP connection names (filenames under `agent/mcp-connections/`). */
|
|
487
|
-
names(): string[];
|
|
488
|
-
listTools(connectionName: string): Promise<HostMcpToolInfo[]>;
|
|
489
|
-
callTool(
|
|
490
|
-
connectionName: string,
|
|
491
|
-
toolName: string,
|
|
492
|
-
args?: Record<string, unknown>,
|
|
493
|
-
): Promise<HostMcpCallResult>;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* MCP spec tool annotations (`Tool.annotations`, 2025-03-26 revision).
|
|
498
|
-
*
|
|
499
|
-
* A closed type on purpose: these are exactly the fields listing-time
|
|
500
|
-
* bounding keeps, so the type matches what a reader can ever see — and the
|
|
501
|
-
* hints are behavioral, so a misspelled or wrong-typed key must not
|
|
502
|
-
* masquerade as a declaration.
|
|
503
|
-
*/
|
|
504
|
-
export interface McpToolAnnotations {
|
|
505
|
-
/** Human-readable display name for the tool, length-capped at listing. */
|
|
506
|
-
title?: string;
|
|
507
|
-
/** The tool does not modify its environment. */
|
|
508
|
-
readOnlyHint?: boolean;
|
|
509
|
-
/** The tool may perform destructive updates (meaningful when not read-only). */
|
|
510
|
-
destructiveHint?: boolean;
|
|
511
|
-
/** Repeated calls with the same arguments have no additional effect. */
|
|
512
|
-
idempotentHint?: boolean;
|
|
513
|
-
/** The tool may interact with an open world of external entities. */
|
|
514
|
-
openWorldHint?: boolean;
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
export interface HostMcpToolInfo {
|
|
518
|
-
name: string;
|
|
519
|
-
description?: string;
|
|
520
|
-
inputSchema?: JsonObject;
|
|
521
|
-
outputSchema?: JsonObject;
|
|
522
|
-
/**
|
|
523
|
-
* MCP spec tool annotations, bounded at listing time to the
|
|
524
|
-
* {@link McpToolAnnotations} fields. Untrusted server hints — consumers
|
|
525
|
-
* that classify on them must fail closed when absent, and absent is
|
|
526
|
-
* exactly what a server that declares nothing produces.
|
|
527
|
-
*/
|
|
528
|
-
annotations?: McpToolAnnotations;
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
export interface HostMcpCallResult {
|
|
532
|
-
content: Array<
|
|
533
|
-
| { type: "text"; text: string }
|
|
534
|
-
| { type: "image"; data: string; mimeType?: string }
|
|
535
|
-
| { type: string; [key: string]: unknown }
|
|
536
|
-
>;
|
|
537
|
-
isError?: boolean;
|
|
538
|
-
structuredContent?: JsonObject;
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
/**
|
|
542
|
-
* Durable Slack follow-up nudge + ask-claim API attached to {@link HostContext}.
|
|
543
|
-
* Used for mid-turn inject, boundary resume skip, and delayed-parent dedupe.
|
|
544
|
-
*/
|
|
545
|
-
export interface SlackNudgeHostApi {
|
|
546
|
-
append(input: {
|
|
547
|
-
continuationKey: string;
|
|
548
|
-
sourceTs: string;
|
|
549
|
-
text: string;
|
|
550
|
-
author?: string;
|
|
551
|
-
}): Promise<boolean>;
|
|
552
|
-
/** Drain pending nudges and return a `<slack_followup>` block, if any. */
|
|
553
|
-
drainFormatted(continuationKey: string): Promise<string | undefined>;
|
|
554
|
-
clear(continuationKey: string): Promise<void>;
|
|
555
|
-
hasUndelivered(continuationKey: string): Promise<boolean>;
|
|
556
|
-
isDelivered(continuationKey: string, sourceTs: string): Promise<boolean>;
|
|
557
|
-
/** Claim `channelId:message.ts` exactly once (false = already seen). */
|
|
558
|
-
tryClaimAsk(channelId: string, messageTs: string): Promise<boolean>;
|
|
559
|
-
/** Release a claim after a failed send so Slack redelivery can retry. */
|
|
560
|
-
releaseAsk(channelId: string, messageTs: string): Promise<void>;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
/**
|
|
564
|
-
* Shared host services available on every tool / hook / channel / schedule
|
|
565
|
-
* surface. Channel packs attach this as `ctx.host` so handlers can tap
|
|
566
|
-
* GitHub, Slack, or MCP without the pack depending on another platform.
|
|
567
|
-
*/
|
|
568
|
-
export interface HostContext {
|
|
569
|
-
/**
|
|
570
|
-
* Authored MCP connections (`agent/mcp-connections/*` and
|
|
571
|
-
* `agent/host-connections/*`). Call a specific MCP tool deterministically
|
|
572
|
-
* without going through the agent loop.
|
|
573
|
-
*/
|
|
574
|
-
mcp: HostMcpRegistry;
|
|
575
|
-
/**
|
|
576
|
-
* Host GitHub client (PAT / env / `gh auth` / App). Prefer webhook
|
|
577
|
-
* `ctx.github` (installation-scoped) when handling a GitHub delivery.
|
|
578
|
-
*/
|
|
579
|
-
github: HostGitHubClient;
|
|
580
|
-
/** Host Slack Web API client (`SLACK_BOT_TOKEN` / channel envPrefix). */
|
|
581
|
-
slack: HostSlackClient;
|
|
582
|
-
/**
|
|
583
|
-
* Per-session reminders (create / list / cancel / dispatch). Present once
|
|
584
|
-
* the serve host has attached a {@link ReminderRunner}.
|
|
585
|
-
*/
|
|
586
|
-
reminders?: ReminderHostApi;
|
|
587
|
-
/**
|
|
588
|
-
* Slack ask-dedupe / nudge helpers. Always present on a live
|
|
589
|
-
* {@link SessionEngine} host. A busy Slack thread's follow-ups queue here
|
|
590
|
-
* and reach the running agent at its next tool boundary, via the workspace
|
|
591
|
-
* carrier hook; whatever the carrier does not reach in time still drains
|
|
592
|
-
* into the boundary turn, deduped by source ts.
|
|
593
|
-
*/
|
|
594
|
-
slackNudges?: SlackNudgeHostApi;
|
|
595
|
-
/**
|
|
596
|
-
* Playground eval batches (`/v1/dev/evals*`). Present once the serve host
|
|
597
|
-
* has attached an {@link import("./evals.js").HostEvalsApi}. Used by the
|
|
598
|
-
* built-in Slack `eval` directive and available to tools/handlers.
|
|
599
|
-
*/
|
|
600
|
-
evals?: import("./evals.js").HostEvalsApi;
|
|
601
|
-
/**
|
|
602
|
-
* Author-facing durable JSON KV (`agentkit/v1/{agent}/kv/…`). Backed by
|
|
603
|
-
* `agent/storage.ts` (`defineStorage`) when authored; otherwise files
|
|
604
|
-
* under `--state-root/kv`. Prefer this over ad-hoc files under the
|
|
605
|
-
* project tree so state survives host replacement.
|
|
606
|
-
*/
|
|
607
|
-
kv: HostKvApi;
|
|
608
|
-
/**
|
|
609
|
-
* Author-facing durable files (`agentkit/v1/{agent}/files/…`). On
|
|
610
|
-
* Cursor-managed hosting they live in the deployment's durable store;
|
|
611
|
-
* otherwise under `--state-root/files`. Use this for file-shaped state —
|
|
612
|
-
* evidence, reports, hand-offs to a delegated run — that must outlive the
|
|
613
|
-
* process.
|
|
614
|
-
*/
|
|
615
|
-
files: HostFilesApi;
|
|
616
|
-
/**
|
|
617
|
-
* Author-facing OpenTelemetry metrics and session tags. Always present.
|
|
618
|
-
* Counters and histograms no-op when no meter is running. `setAttributes`
|
|
619
|
-
* still tags the open session when a collector is attached.
|
|
620
|
-
*/
|
|
621
|
-
otel: HostOtelApi;
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
/** Host-facing JSON key-value API attached to {@link HostContext.kv}. */
|
|
625
|
-
export interface HostKvApi {
|
|
626
|
-
/** Read one value. Miss → `undefined`. */
|
|
627
|
-
get(key: string): Promise<JsonValue | undefined>;
|
|
628
|
-
/** Write or replace one value. */
|
|
629
|
-
put(key: string, value: JsonValue): Promise<void>;
|
|
630
|
-
/** Remove one key. No-op when missing. */
|
|
631
|
-
delete(key: string): Promise<void>;
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
/** A value plus its opaque version token, as returned by CAS-capable reads. */
|
|
635
|
-
export interface KvVersionedEntry {
|
|
636
|
-
value: JsonValue;
|
|
637
|
-
/**
|
|
638
|
-
* Opaque per-key token that changes on every successful write. Callers
|
|
639
|
-
* must not parse it — backends mint whatever is cheap for them (a
|
|
640
|
-
* counter, a UUID, an `updated_at`/`xmin` pair, …).
|
|
641
|
-
*/
|
|
642
|
-
version: string;
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
/**
|
|
646
|
-
* Outcome of a conditional write. On conflict the backend returns the
|
|
647
|
-
* entry it observed (`undefined` when the key is absent), so a CAS retry
|
|
648
|
-
* loop gets its re-read for free instead of paying a second round trip.
|
|
649
|
-
*/
|
|
650
|
-
export type KvCasResult =
|
|
651
|
-
| { ok: true; version: string }
|
|
652
|
-
| { ok: false; current: KvVersionedEntry | undefined };
|
|
653
|
-
|
|
654
|
-
/**
|
|
655
|
-
* Conditional-write superset of {@link HostKvApi}. Version-token CAS was
|
|
656
|
-
* chosen over compare-value: every candidate backend can mint a cheap
|
|
657
|
-
* opaque token (counter, UUID, row version), while compare-value would
|
|
658
|
-
* force deep JSON equality with key-order pitfalls on each of them. The
|
|
659
|
-
* agent-facing `host.kv` stays plain {@link HostKvApi}; storage backends
|
|
660
|
-
* supply CAS via the optional `cas` group on `defineStorage`.
|
|
661
|
-
*/
|
|
662
|
-
export interface HostKvCasApi extends HostKvApi {
|
|
663
|
-
/** Read one value with its version token. Miss → `undefined`. */
|
|
664
|
-
getWithVersion(key: string): Promise<KvVersionedEntry | undefined>;
|
|
665
|
-
/** Create the key only when absent. Conflict returns the existing entry. */
|
|
666
|
-
putIfAbsent(key: string, value: JsonValue): Promise<KvCasResult>;
|
|
667
|
-
/**
|
|
668
|
-
* Replace the value only when the key still carries `expectedVersion`.
|
|
669
|
-
* Conflict (version moved, or key deleted) returns the current entry.
|
|
670
|
-
*/
|
|
671
|
-
putIfVersion(key: string, value: JsonValue, expectedVersion: string): Promise<KvCasResult>;
|
|
672
|
-
/** All keys under a prefix, in ascending key order. */
|
|
673
|
-
listKeys(prefix: string): Promise<string[]>;
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
/**
|
|
677
|
-
* Runtime probe: does this KV implement the CAS superset? Only for
|
|
678
|
-
* stores of unknown provenance — e.g. a caller-supplied {@link HostKvApi}
|
|
679
|
-
* object whose static type does not carry the CAS methods. A
|
|
680
|
-
* `defineStorage` backend declares CAS through its `cas` group instead
|
|
681
|
-
* and never needs probing.
|
|
682
|
-
*/
|
|
683
|
-
export function supportsKvCas(kv: HostKvApi): kv is HostKvCasApi {
|
|
684
|
-
const candidate = kv as Partial<HostKvCasApi>;
|
|
685
|
-
return (
|
|
686
|
-
typeof candidate.getWithVersion === "function" &&
|
|
687
|
-
typeof candidate.putIfAbsent === "function" &&
|
|
688
|
-
typeof candidate.putIfVersion === "function" &&
|
|
689
|
-
typeof candidate.listKeys === "function"
|
|
690
|
-
);
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
/**
|
|
694
|
-
* Which set of files a call addresses.
|
|
695
|
-
*
|
|
696
|
-
* `"session"` (the default) is private to one session. `"deployment"` is shared
|
|
697
|
-
* by every session of the agent and survives redeploys; `partition` subdivides
|
|
698
|
-
* it for author-chosen groupings such as a pull request or a customer.
|
|
699
|
-
*/
|
|
700
|
-
export type HostFilesScope =
|
|
701
|
-
| "session"
|
|
702
|
-
| "deployment"
|
|
703
|
-
| { kind: "session"; sessionId?: string }
|
|
704
|
-
| { kind: "deployment"; partition?: string };
|
|
705
|
-
|
|
706
|
-
/** Scope selector shared by every {@link HostFilesApi} call. */
|
|
707
|
-
export interface HostFilesCallOptions {
|
|
708
|
-
scope?: HostFilesScope;
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
/** One entry from {@link HostFilesApi.list}. */
|
|
712
|
-
export interface HostFileEntry {
|
|
713
|
-
/** Path within the scope, as authors address it. */
|
|
714
|
-
path: string;
|
|
715
|
-
size: number;
|
|
716
|
-
/** Last-modified epoch ms, when the sink tracks one. */
|
|
717
|
-
mtimeMs?: number;
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
/** Result of {@link HostFilesApi.stat}. */
|
|
721
|
-
export interface HostFileStat {
|
|
722
|
-
size: number;
|
|
723
|
-
mtimeMs?: number;
|
|
724
|
-
/** Opaque version tag; pass back as `ifMatch` to make a write conditional. */
|
|
725
|
-
etag?: string;
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
/**
|
|
729
|
-
* What the configured sink actually supports. Read these instead of assuming:
|
|
730
|
-
* the same authored code runs against local disk, an Agent Store, and whatever
|
|
731
|
-
* a customer plugged in, and those differ in ways that change correctness.
|
|
732
|
-
*/
|
|
733
|
-
export interface HostFilesCapabilities {
|
|
734
|
-
/**
|
|
735
|
-
* Conditional writes are enforced, so a lost race raises
|
|
736
|
-
* `FileConflictError` instead of silently clobbering. False means
|
|
737
|
-
* last-writer-wins.
|
|
738
|
-
*/
|
|
739
|
-
conflictDetection: boolean;
|
|
740
|
-
/**
|
|
741
|
-
* Files have a real local path ({@link HostFilesApi.materializedPath}) the
|
|
742
|
-
* harness can open with ordinary file tools. False means the model cannot
|
|
743
|
-
* reach them directly — only authored handler code (tools, hooks) can,
|
|
744
|
-
* through this API.
|
|
745
|
-
*/
|
|
746
|
-
materialized: boolean;
|
|
747
|
-
/** Largest value the sink accepts, when it declares a limit. */
|
|
748
|
-
maxBytes?: number;
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
/**
|
|
752
|
-
* Durable files attached to {@link HostContext.files}.
|
|
753
|
-
*
|
|
754
|
-
* Deliberately not a filesystem: no handles, no seeking, no rename, no
|
|
755
|
-
* directories, no errno. Paths are addresses within a {@link HostFilesScope},
|
|
756
|
-
* never filesystem paths — {@link materializedPath} is the one place a real
|
|
757
|
-
* path appears, and it is `undefined` whenever the sink keeps no local copy.
|
|
758
|
-
*/
|
|
759
|
-
export interface HostFilesApi {
|
|
760
|
-
/** What the configured sink supports. */
|
|
761
|
-
readonly capabilities: HostFilesCapabilities;
|
|
762
|
-
|
|
763
|
-
/** Bind `"session"`-scoped calls to `sessionId`. */
|
|
764
|
-
forSession(sessionId: string): HostFilesApi;
|
|
765
|
-
|
|
766
|
-
/** Read as text. Miss → `undefined`. */
|
|
767
|
-
read(
|
|
768
|
-
path: string,
|
|
769
|
-
options?: HostFilesCallOptions & { encoding?: BufferEncoding },
|
|
770
|
-
): Promise<string | undefined>;
|
|
771
|
-
|
|
772
|
-
/** Read as bytes. Miss → `undefined`. */
|
|
773
|
-
readBytes(path: string, options?: HostFilesCallOptions): Promise<Uint8Array | undefined>;
|
|
774
|
-
|
|
775
|
-
/**
|
|
776
|
-
* Write or replace. Pass `ifMatch` with a {@link HostFileStat.etag} to make
|
|
777
|
-
* the write conditional, or `null` to require that it does not exist —
|
|
778
|
-
* enforced only when {@link HostFilesCapabilities.conflictDetection} is set.
|
|
779
|
-
*/
|
|
780
|
-
write(
|
|
781
|
-
path: string,
|
|
782
|
-
data: string | Uint8Array,
|
|
783
|
-
options?: HostFilesCallOptions & { ifMatch?: string | null },
|
|
784
|
-
): Promise<void>;
|
|
785
|
-
|
|
786
|
-
/** Remove one path. No-op when missing. */
|
|
787
|
-
remove(path: string, options?: HostFilesCallOptions): Promise<void>;
|
|
788
|
-
|
|
789
|
-
/** Entries whose path starts with `prefix` (all when omitted), in path order. */
|
|
790
|
-
list(prefix?: string, options?: HostFilesCallOptions): Promise<HostFileEntry[]>;
|
|
791
|
-
|
|
792
|
-
exists(path: string, options?: HostFilesCallOptions): Promise<boolean>;
|
|
793
|
-
|
|
794
|
-
stat(path: string, options?: HostFilesCallOptions): Promise<HostFileStat | undefined>;
|
|
795
|
-
|
|
796
|
-
/**
|
|
797
|
-
* Absolute local path the harness can read, or `undefined` when the sink
|
|
798
|
-
* keeps no local copy. Never use it as an identity — pass paths and scopes
|
|
799
|
-
* to the other calls so the same code works against a sink that has none.
|
|
800
|
-
*/
|
|
801
|
-
materializedPath(path: string, options?: HostFilesCallOptions): string | undefined;
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
/** Attribute bag accepted by {@link HostOtelApi}. `undefined` values are dropped. */
|
|
805
|
-
export type HostOtelAttributes = Record<string, string | number | boolean | undefined>;
|
|
806
|
-
|
|
807
|
-
/**
|
|
808
|
-
* Author-facing OpenTelemetry surface on {@link HostContext.otel}.
|
|
809
|
-
*
|
|
810
|
-
* Metrics and tags only — no custom spans, and no raw OTel `Meter` /
|
|
811
|
-
* `Tracer`. First-party names (`cursor.token.usage`, …) and join keys
|
|
812
|
-
* (`cursor.conversation.id`, `agent_sdk.session_id`, `agent_sdk.agent`,
|
|
813
|
-
* …) are reserved.
|
|
814
|
-
*/
|
|
815
|
-
export interface HostOtelApi {
|
|
816
|
-
/** True when a meter is running and `increment` / `record` export. */
|
|
817
|
-
readonly enabled: boolean;
|
|
818
|
-
|
|
819
|
-
/**
|
|
820
|
-
* Merge tags onto this host binding. On a session-bound host they join
|
|
821
|
-
* open turn/tool spans and later first-party metrics. Unbound tags
|
|
822
|
-
* stay on this host instance only.
|
|
823
|
-
*/
|
|
824
|
-
setAttributes(attributes: HostOtelAttributes): void;
|
|
825
|
-
|
|
826
|
-
/** Add 1 to a counter. */
|
|
827
|
-
increment(name: string, attributes?: HostOtelAttributes): void;
|
|
828
|
-
/** Add `value` to a counter. */
|
|
829
|
-
increment(name: string, value: number, attributes?: HostOtelAttributes): void;
|
|
830
|
-
|
|
831
|
-
/** Record one histogram observation. */
|
|
832
|
-
record(name: string, value: number, attributes?: HostOtelAttributes): void;
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
/** Runtime context handed to a tool's `execute`. */
|
|
836
|
-
export interface ToolContext {
|
|
837
|
-
/** Correlates with `actions.requested` / `actions.completed` stream events. */
|
|
838
|
-
toolCallId?: string;
|
|
839
|
-
/** The session this tool call runs inside. */
|
|
840
|
-
session: SessionInfo;
|
|
841
|
-
/** Absolute path of the session's materialized workspace directory. */
|
|
842
|
-
workspaceDir: string;
|
|
843
|
-
/**
|
|
844
|
-
* Absolute path of the agent's durable state root (shared across every
|
|
845
|
-
* session of this agent).
|
|
846
|
-
*/
|
|
847
|
-
stateRoot: string;
|
|
848
|
-
/** Shared host services (MCP / GitHub / Slack). */
|
|
849
|
-
host: HostContext;
|
|
850
|
-
/**
|
|
851
|
-
* Start or resume a session on any channel (cross-channel handoff).
|
|
852
|
-
* Same semantics as a channel route's `send`, with an explicit channel id.
|
|
853
|
-
* `auth` defaults to this tool call's session principal (like HTTP
|
|
854
|
-
* channel `send`); pass explicitly to override.
|
|
855
|
-
*/
|
|
856
|
-
send(channelId: string, message: string, options?: SendMessageOptions): Promise<ChannelSession>;
|
|
857
|
-
/** Look up a session on a channel (e.g. refresh `sdkAgentId` after a turn). */
|
|
858
|
-
getSession(channelId: string, sessionId: string): Promise<ChannelSession | null>;
|
|
859
|
-
/**
|
|
860
|
-
* Durable artifacts, bound to this tool call's session: `tag` auto-fills
|
|
861
|
-
* `sessionId` (and `turnId` when known).
|
|
862
|
-
*/
|
|
863
|
-
artifacts: ArtifactsApi;
|
|
864
|
-
/**
|
|
865
|
-
* Append a session event onto this call's in-flight turn. Same shape as a
|
|
866
|
-
* Task subagent stream (`parentCallId`, `subagent.called` /
|
|
867
|
-
* `subagent.completed`). Omitted for scratch `callTool` with no session.
|
|
868
|
-
*/
|
|
869
|
-
emit?: (payload: SessionEventPayload) => void;
|
|
870
|
-
/** The session's frozen `asOf`, or the wall clock. Use instead of `Date.now()`. */
|
|
871
|
-
now(): Date;
|
|
872
|
-
/**
|
|
873
|
-
* The session's frozen instant (ISO-8601), when it has one. Present exactly
|
|
874
|
-
* when this is an `asOf` session. A tool that reaches other tools itself —
|
|
875
|
-
* the script sandbox — reads it to apply the same forward-time guard to the
|
|
876
|
-
* calls it makes, which do not pass back through the host's gate.
|
|
877
|
-
*/
|
|
878
|
-
asOf?: string;
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
/**
|
|
882
|
-
* Where a tool's body runs.
|
|
883
|
-
*
|
|
884
|
-
* - `"server"` (default): in-process on the agent-serve host via Cursor SDK
|
|
885
|
-
* custom tools. Only available when the agent {@link AgentConfig.runtime}
|
|
886
|
-
* is `"local"`.
|
|
887
|
-
* - `"agent"` — materialized into the session workspace as a shell
|
|
888
|
-
* script the Cursor agent invokes. Requires
|
|
889
|
-
* {@link ToolConfig.script}; `execute` is not used.
|
|
890
|
-
*/
|
|
891
|
-
export type ToolExecution = "server" | "agent";
|
|
892
|
-
|
|
893
|
-
/**
|
|
894
|
-
* Whether a server tool call must pause for human approval before
|
|
895
|
-
* `execute` runs. Boolean always gates; a predicate decides per call from
|
|
896
|
-
* validated input only (no {@link ToolContext} — runs before the gate).
|
|
897
|
-
*/
|
|
898
|
-
export type ToolNeedsApproval<TInput> = boolean | ((input: TInput) => boolean | Promise<boolean>);
|
|
899
|
-
|
|
900
|
-
/**
|
|
901
|
-
* Whether invoking a tool can change anything outside this session.
|
|
902
|
-
*
|
|
903
|
-
* `"read"` cannot, by construction — a query, a file read, a listing.
|
|
904
|
-
* `"write"` changes something a person or another agent will later see: an
|
|
905
|
-
* external system (a comment, a message, a ticket) or shared storage another
|
|
906
|
-
* session reads back.
|
|
907
|
-
*
|
|
908
|
-
* This is what {@link SendMessageOptions.dryRun} enforces. In a dry-run
|
|
909
|
-
* session a write is answered by the host and never executed, while reads run
|
|
910
|
-
* for real — so an agent can be run against real data to see what it *would*
|
|
911
|
-
* have done.
|
|
912
|
-
*
|
|
913
|
-
* A tool that declares nothing is treated as a write: a dry run promises
|
|
914
|
-
* "nothing outside this session changed", which it cannot promise about a tool
|
|
915
|
-
* it knows nothing about. An unannotated tool is therefore useless in a dry
|
|
916
|
-
* run.
|
|
917
|
-
*/
|
|
918
|
-
export type ToolEffect = "read" | "write";
|
|
919
|
-
|
|
920
|
-
/** Authored `defineConnection({ effects })` — one effect or a set. */
|
|
921
|
-
export type ConnectionEffects = ToolEffect | readonly ToolEffect[];
|
|
922
|
-
|
|
923
|
-
const TOOL_EFFECTS: readonly ToolEffect[] = ["read", "write"];
|
|
924
|
-
|
|
925
|
-
export function isToolEffect(value: unknown): value is ToolEffect {
|
|
926
|
-
return value === "read" || value === "write";
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
/**
|
|
930
|
-
* Normalize authored {@link ConnectionConfig.effects} to a unique list.
|
|
931
|
-
* Invalid values are left for discovery to reject — this only collapses
|
|
932
|
-
* `"read"` / `["read"]` / duplicates.
|
|
933
|
-
*/
|
|
934
|
-
export function normalizeConnectionEffects(effects: ConnectionEffects): ToolEffect[] {
|
|
935
|
-
const list = typeof effects === "string" ? [effects] : [...effects];
|
|
936
|
-
const unique: ToolEffect[] = [];
|
|
937
|
-
for (const effect of TOOL_EFFECTS) {
|
|
938
|
-
if (list.includes(effect)) {
|
|
939
|
-
unique.push(effect);
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
return unique;
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
/**
|
|
946
|
-
* Trim, drop blanks, and unique-preserve authored
|
|
947
|
-
* {@link ConnectionConfig.tools} name lists. Invalid shapes are left
|
|
948
|
-
* for discovery.
|
|
949
|
-
*/
|
|
950
|
-
export function normalizeConnectionTools(tools: readonly string[]): string[] {
|
|
951
|
-
const unique: string[] = [];
|
|
952
|
-
const seen = new Set<string>();
|
|
953
|
-
for (const raw of tools) {
|
|
954
|
-
const name = raw.trim();
|
|
955
|
-
if (name === "" || seen.has(name)) {
|
|
956
|
-
continue;
|
|
957
|
-
}
|
|
958
|
-
seen.add(name);
|
|
959
|
-
unique.push(name);
|
|
960
|
-
}
|
|
961
|
-
return unique;
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
/** True when `toolName` passes the connection's `tools` / `disallowedTools` filter. */
|
|
965
|
-
export function connectionAllowsTool(
|
|
966
|
-
filter: {
|
|
967
|
-
tools?: readonly string[];
|
|
968
|
-
disallowedTools?: readonly string[];
|
|
969
|
-
},
|
|
970
|
-
toolName: string,
|
|
971
|
-
): boolean {
|
|
972
|
-
if (filter.tools !== undefined && !filter.tools.includes(toolName)) {
|
|
973
|
-
return false;
|
|
974
|
-
}
|
|
975
|
-
return filter.disallowedTools === undefined || !filter.disallowedTools.includes(toolName);
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
/**
|
|
979
|
-
* A tool's declared {@link ToolEffect} — fixed, or decided per call from
|
|
980
|
-
* validated input for tools that read or write depending on their arguments
|
|
981
|
-
* (an HTTP request keyed on method, a SQL tool keyed on statement).
|
|
982
|
-
*/
|
|
983
|
-
export type ToolEffectDeclaration<TInput> = ToolEffect | ((input: TInput) => ToolEffect);
|
|
984
|
-
|
|
985
|
-
export interface ToolConfig<TInput> {
|
|
986
|
-
description: string;
|
|
987
|
-
/**
|
|
988
|
-
* Where the tool body runs. Defaults to `"server"` (in-process on the
|
|
989
|
-
* agent-serve process). Use `"agent"` to materialize a workspace script
|
|
990
|
-
* the Cursor agent invokes instead.
|
|
991
|
-
*/
|
|
992
|
-
execution?: ToolExecution;
|
|
993
|
-
/**
|
|
994
|
-
* Zod schema (validated before `execute` runs) or a plain JSON Schema
|
|
995
|
-
* object (forwarded to the model as-is, unvalidated). Omit to accept any
|
|
996
|
-
* JSON object.
|
|
997
|
-
*/
|
|
998
|
-
inputSchema?: z.ZodType<TInput> | JsonSchemaObject;
|
|
999
|
-
/**
|
|
1000
|
-
* JSON Schema for the tool's structured output (`Tool.outputSchema` from
|
|
1001
|
-
* the MCP spec), as a zod schema (converted, never validated against) or a
|
|
1002
|
-
* plain JSON Schema object. Advertised when declared and omitted
|
|
1003
|
-
* otherwise — results are not validated against it.
|
|
1004
|
-
*/
|
|
1005
|
-
outputSchema?: z.ZodTypeAny | JsonSchemaObject;
|
|
1006
|
-
/**
|
|
1007
|
-
* When true (or when the predicate returns true), the host parks the
|
|
1008
|
-
* in-flight tool call until a human approves or denies via
|
|
1009
|
-
* `POST /v1/session/:sessionId/approvals/:callId`. Only supported for
|
|
1010
|
-
* `execution: "server"` tools on the local runtime.
|
|
1011
|
-
*/
|
|
1012
|
-
needsApproval?: ToolNeedsApproval<TInput>;
|
|
1013
|
-
/**
|
|
1014
|
-
* Whether this tool changes anything outside the session. Undeclared means
|
|
1015
|
-
* write, so a dry run stubs it — see {@link ToolEffect}.
|
|
1016
|
-
*/
|
|
1017
|
-
effect?: ToolEffectDeclaration<TInput>;
|
|
1018
|
-
/**
|
|
1019
|
-
* Input properties that carry time bounds. In a session created with
|
|
1020
|
-
* {@link SendMessageOptions.asOf}, every named argument must be an
|
|
1021
|
-
* absolute ISO-8601 instant with a timezone, no later than the session's
|
|
1022
|
-
* frozen instant — a call that omits one, or supplies a relative or later
|
|
1023
|
-
* value, is refused so the model retries with absolute bounds. Names must
|
|
1024
|
-
* exist in {@link inputSchema}; a session with `asOf` refuses to start
|
|
1025
|
-
* otherwise, because a misspelled name would silently check nothing.
|
|
1026
|
-
* Ignored in sessions without `asOf`.
|
|
1027
|
-
*/
|
|
1028
|
-
timeArgs?: readonly string[];
|
|
1029
|
-
/**
|
|
1030
|
-
* What a write tool returns in a dry-run session instead of executing.
|
|
1031
|
-
*
|
|
1032
|
-
* Omit for a tool whose result the caller only acknowledges. Supply one when
|
|
1033
|
-
* the result is read structurally — a caller that uses `result.revision`
|
|
1034
|
-
* breaks on a bare string — so a dry run stays on the same path production
|
|
1035
|
-
* takes. Ignored unless {@link effect} resolves to `"write"`.
|
|
1036
|
-
*/
|
|
1037
|
-
dryRunResult?: ToolExecuteResult | ((input: TInput) => ToolExecuteResult);
|
|
1038
|
-
/**
|
|
1039
|
-
* In-process implementation. Required when {@link execution} is
|
|
1040
|
-
* `"server"` (the default); ignored for `"agent"` tools.
|
|
1041
|
-
*/
|
|
1042
|
-
execute?: (input: TInput, ctx: ToolContext) => ToolExecuteResult | Promise<ToolExecuteResult>;
|
|
1043
|
-
/**
|
|
1044
|
-
* Agent tools: shell script body written into the session workspace.
|
|
1045
|
-
* Receives a JSON object on stdin and should print the result on
|
|
1046
|
-
* stdout. Required when {@link execution} is `"agent"`.
|
|
1047
|
-
*/
|
|
1048
|
-
script?: string;
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
/** Discovered tool definition with erased input generics. */
|
|
1052
|
-
export interface ToolDefinition extends BrandedDefinition<"tool"> {
|
|
1053
|
-
readonly description: string;
|
|
1054
|
-
readonly execution?: ToolExecution;
|
|
1055
|
-
readonly inputSchema?: z.ZodTypeAny | JsonSchemaObject;
|
|
1056
|
-
readonly outputSchema?: z.ZodTypeAny | JsonSchemaObject;
|
|
1057
|
-
readonly needsApproval?: ToolNeedsApproval<never>;
|
|
1058
|
-
readonly effect?: ToolEffectDeclaration<never>;
|
|
1059
|
-
readonly timeArgs?: readonly string[];
|
|
1060
|
-
readonly dryRunResult?: ToolExecuteResult | ((input: never) => ToolExecuteResult);
|
|
1061
|
-
readonly execute?: (
|
|
1062
|
-
input: never,
|
|
1063
|
-
ctx: ToolContext,
|
|
1064
|
-
) => ToolExecuteResult | Promise<ToolExecuteResult>;
|
|
1065
|
-
readonly script?: string;
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
// ============================================================================
|
|
1069
|
-
// Skills (agent/skills/*)
|
|
1070
|
-
// ============================================================================
|
|
1071
|
-
|
|
1072
|
-
/** Input to `defineSkill` (authored at `agent/skills/<name>.ts`). */
|
|
1073
|
-
export interface SkillConfig {
|
|
1074
|
-
/** Routing hint advertised to the model in the skills catalog. */
|
|
1075
|
-
description?: string;
|
|
1076
|
-
/** The skill body (becomes `SKILL.md`). */
|
|
1077
|
-
markdown: string;
|
|
1078
|
-
/** Package-relative sibling files, e.g. `references/checklist.md`. */
|
|
1079
|
-
files?: Record<string, string>;
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
export type SkillDefinition = SkillConfig & BrandedDefinition<"skill">;
|
|
1083
|
-
|
|
1084
|
-
// ============================================================================
|
|
1085
|
-
// Extensions (agent/extensions/<ns>.ts | agent/extensions/<ns>/extension.ts)
|
|
1086
|
-
// ============================================================================
|
|
1087
|
-
|
|
1088
|
-
/**
|
|
1089
|
-
* Input to `defineExtension`, the `extension.ts` at the root of an
|
|
1090
|
-
* agent-shaped tree (`tools/`, `skills/`, `lib/`).
|
|
1091
|
-
*/
|
|
1092
|
-
export interface ExtensionOptions<TConfig, TInput = TConfig> {
|
|
1093
|
-
/** The tree's directory; pass `import.meta.dirname`. */
|
|
1094
|
-
root: string;
|
|
1095
|
-
/** What the extension adds; shown by `info`. */
|
|
1096
|
-
description?: string;
|
|
1097
|
-
/** Mount configuration schema. A consumer's settings are validated at mount. */
|
|
1098
|
-
config?: z.ZodType<TConfig, z.ZodTypeDef, TInput>;
|
|
1099
|
-
/** Choose which contribution groups this mount includes. */
|
|
1100
|
-
contributions?: (config: TConfig) => ExtensionContributionSelection;
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
|
-
/** Contribution groups a configured extension mount may include or omit. */
|
|
1104
|
-
export interface ExtensionContributionSelection {
|
|
1105
|
-
/** Include tools from the extension tree. Defaults to true. */
|
|
1106
|
-
tools?: boolean;
|
|
1107
|
-
/** Include skills from the extension tree. Defaults to true. */
|
|
1108
|
-
skills?: boolean;
|
|
1109
|
-
}
|
|
1110
|
-
|
|
1111
|
-
/**
|
|
1112
|
-
* What `extension.ts` default-exports. A consumer calls it from
|
|
1113
|
-
* `agent/extensions/<ns>.ts` to mount the extension with a configuration;
|
|
1114
|
-
* the extension's own modules import it to read that configuration.
|
|
1115
|
-
*/
|
|
1116
|
-
export interface Extension<TConfig = undefined, TInput = TConfig> extends ExtensionDeclaration {
|
|
1117
|
-
(...args: undefined extends TInput ? [config?: TInput] : [config: TInput]): ExtensionMount;
|
|
1118
|
-
/** The mounted configuration (schema defaults applied); throws before the mount. */
|
|
1119
|
-
readonly config: TConfig;
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
/** The mount-independent part of an {@link Extension}: an agent-shaped tree. */
|
|
1123
|
-
export interface ExtensionDeclaration {
|
|
1124
|
-
readonly root: string;
|
|
1125
|
-
readonly description: string | undefined;
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
/** A Cursor plugin directory declared by `cursorPlugin`. */
|
|
1129
|
-
export interface CursorPluginDeclaration extends ExtensionDeclaration {
|
|
1130
|
-
readonly layout: "cursor-plugin";
|
|
1131
|
-
readonly variables: Record<string, string>;
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
/** What `agent/extensions/<ns>.ts` default-exports. */
|
|
1135
|
-
export interface ExtensionMount extends BrandedDefinition<"extension"> {
|
|
1136
|
-
readonly extension: ExtensionDeclaration | CursorPluginDeclaration;
|
|
1137
|
-
readonly config: unknown;
|
|
1138
|
-
readonly contributions?: ExtensionContributionSelection;
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
/** `cursorPlugin({ ... })`: mount a Cursor plugin directory as an extension. */
|
|
1142
|
-
export interface CursorPluginOptions {
|
|
1143
|
-
/**
|
|
1144
|
-
* The plugin directory: the one holding `.cursor-plugin/plugin.json`
|
|
1145
|
-
* (or `.claude-plugin/plugin.json` / `plugin.json`). A relative path
|
|
1146
|
-
* resolves against the project root.
|
|
1147
|
-
*/
|
|
1148
|
-
path: string;
|
|
1149
|
-
/**
|
|
1150
|
-
* Values for the `${NAME}` placeholders in the plugin's MCP config, the
|
|
1151
|
-
* variables a Cursor install prompts for. Names the mount omits fall back
|
|
1152
|
-
* to `process.env`; a placeholder nothing resolves fails discovery.
|
|
1153
|
-
*/
|
|
1154
|
-
variables?: Record<string, string>;
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
|
-
/**
|
|
1158
|
-
* `export default disableTool()` in a directory mount's `tools/<name>.ts`
|
|
1159
|
-
* removes the extension's `<ns>__<name>`.
|
|
1160
|
-
*/
|
|
1161
|
-
export type DisabledToolDefinition = BrandedDefinition<"disabled-tool">;
|
|
1162
|
-
|
|
1163
|
-
/**
|
|
1164
|
-
* `export default disableConnection()` in a directory mount's
|
|
1165
|
-
* `mcp-connections/<server>.ts` removes the extension's `<ns>__<server>`.
|
|
1166
|
-
*/
|
|
1167
|
-
export type DisabledConnectionDefinition = BrandedDefinition<"disabled-connection">;
|
|
1168
|
-
|
|
1169
|
-
/**
|
|
1170
|
-
* `export default disable()` / `disableSkill()` / `disableHook()` /
|
|
1171
|
-
* `disableChannel()` / `disableSchedule()` / `disableSubagent()` /
|
|
1172
|
-
* `disableInstructions()` / `disableArtifacts()` in a directory mount
|
|
1173
|
-
* removes that contribution from the matching overlay slot.
|
|
1174
|
-
*/
|
|
1175
|
-
export type DisabledDefinition = BrandedDefinition<"disabled">;
|
|
1176
|
-
|
|
1177
|
-
/** One mounted extension and the names it contributed. */
|
|
1178
|
-
export interface DiscoveredExtension {
|
|
1179
|
-
/** Mount namespace: the filename stem or directory name under `agent/extensions/`. */
|
|
1180
|
-
name: string;
|
|
1181
|
-
description?: string;
|
|
1182
|
-
/** Composed tool names (`<ns>__<name>`), overrides applied. */
|
|
1183
|
-
tools: string[];
|
|
1184
|
-
/** Composed skill names (`<ns>__<name>`), overrides applied. */
|
|
1185
|
-
skills: string[];
|
|
1186
|
-
/** Composed MCP connection names (`<ns>__<server>`). */
|
|
1187
|
-
connections: string[];
|
|
1188
|
-
/** Composed host MCP connection names (`<ns>__<server>`). */
|
|
1189
|
-
hostConnections: string[];
|
|
1190
|
-
/** Composed subagent names (`<ns>__<id>`). */
|
|
1191
|
-
subagents: string[];
|
|
1192
|
-
/** Composed hook names (`<ns>__<name>`). */
|
|
1193
|
-
hooks: string[];
|
|
1194
|
-
/** Composed channel ids (`<ns>__<id>`). */
|
|
1195
|
-
channels: string[];
|
|
1196
|
-
/** Composed schedule names (`<ns>__<name>`). */
|
|
1197
|
-
schedules: string[];
|
|
1198
|
-
/** Whether the mount contributed an instructions fragment. */
|
|
1199
|
-
instructions: boolean;
|
|
1200
|
-
/** Workspace seed paths the mount contributed. */
|
|
1201
|
-
seedFiles: string[];
|
|
1202
|
-
/** Composed artifact kind names (`<ns>__<kind>`). */
|
|
1203
|
-
artifactKinds: string[];
|
|
1204
|
-
}
|
|
1205
|
-
|
|
1206
|
-
// ============================================================================
|
|
1207
|
-
// MCP connections (agent/mcp-connections/*.ts)
|
|
1208
|
-
// ============================================================================
|
|
1209
|
-
|
|
1210
|
-
/**
|
|
1211
|
-
* Transport for an MCP connection, mirroring the Cursor SDK's
|
|
1212
|
-
* `McpServerConfig` shapes — plus two agent-serve variants that stay
|
|
1213
|
-
* symbolic until the server starts:
|
|
1214
|
-
*
|
|
1215
|
-
* - `agent` addresses a **peer agent** mounted on the same serve host by
|
|
1216
|
-
* slug; it resolves to that agent's MCP endpoint (`/<slug>/v1/mcp`).
|
|
1217
|
-
* - `cursorAccount` exposes the **Cursor account's MCP connectors** (the
|
|
1218
|
-
* HTTP/SSE servers the operator already authorized in Cursor). It
|
|
1219
|
-
* resolves to a bridge on this host that executes every tool **on the
|
|
1220
|
-
* Cursor backend** with the account's stored OAuth credentials — tokens
|
|
1221
|
-
* never reach this host.
|
|
1222
|
-
*/
|
|
1223
|
-
export type ConnectionTransport =
|
|
1224
|
-
| {
|
|
1225
|
-
type?: "stdio";
|
|
1226
|
-
command: string;
|
|
1227
|
-
args?: string[];
|
|
1228
|
-
env?: Record<string, string>;
|
|
1229
|
-
cwd?: string;
|
|
1230
|
-
}
|
|
1231
|
-
| {
|
|
1232
|
-
type?: "http" | "sse";
|
|
1233
|
-
url: string;
|
|
1234
|
-
headers?: Record<string, string>;
|
|
1235
|
-
/** Host PKCE OAuth; `agent-sdk mcp oauth <name>`. No Authorization header. */
|
|
1236
|
-
oauth?: true;
|
|
1237
|
-
}
|
|
1238
|
-
| {
|
|
1239
|
-
/** Slug of a peer agent mounted on the same serve host. */
|
|
1240
|
-
agent: string;
|
|
1241
|
-
}
|
|
1242
|
-
| {
|
|
1243
|
-
/** Expose the Cursor account's MCP connectors (backend-executed). */
|
|
1244
|
-
cursorAccount: true;
|
|
1245
|
-
/**
|
|
1246
|
-
* Restrict to these connector names after discovery normalization.
|
|
1247
|
-
* Authored configs may also pass `"*"` / `["*"]` (see
|
|
1248
|
-
* {@link ConnectionConfig}); those normalize to `undefined` (= all).
|
|
1249
|
-
*/
|
|
1250
|
-
servers?: string[];
|
|
1251
|
-
};
|
|
1252
|
-
|
|
1253
|
-
/** True for the peer-agent transport variant (`{ agent: "<slug>" }`). */
|
|
1254
|
-
export function isPeerConnectionTransport(
|
|
1255
|
-
transport: ConnectionTransport,
|
|
1256
|
-
): transport is { agent: string } {
|
|
1257
|
-
return "agent" in transport;
|
|
1258
|
-
}
|
|
1259
|
-
|
|
1260
|
-
/** True for the Cursor account transport variant (`{ cursorAccount: true }`). */
|
|
1261
|
-
export function isCursorAccountTransport(
|
|
1262
|
-
transport: ConnectionTransport,
|
|
1263
|
-
): transport is { cursorAccount: true; servers?: string[] } {
|
|
1264
|
-
return "cursorAccount" in transport && transport.cursorAccount === true;
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
/**
|
|
1268
|
-
* Normalize an authored Cursor account `servers` filter.
|
|
1269
|
-
*
|
|
1270
|
-
* `undefined`, `"*"`, and `["*"]` (after trim) all mean every connected
|
|
1271
|
-
* HTTP/SSE server on the account. Returns a concrete allowlist, or
|
|
1272
|
-
* `undefined` for all. Does not validate emptiness, blank entries, or a
|
|
1273
|
-
* mixed `"*"` + names list — discovery owns those diagnostics.
|
|
1274
|
-
*/
|
|
1275
|
-
export function normalizeCursorAccountServers(
|
|
1276
|
-
servers: string[] | "*" | undefined,
|
|
1277
|
-
): string[] | undefined {
|
|
1278
|
-
if (servers === undefined || servers === "*") {
|
|
1279
|
-
return undefined;
|
|
1280
|
-
}
|
|
1281
|
-
const trimmed = servers.map(server => server.trim());
|
|
1282
|
-
if (trimmed.length === 1 && trimmed[0] === "*") {
|
|
1283
|
-
return undefined;
|
|
1284
|
-
}
|
|
1285
|
-
return [...servers];
|
|
1286
|
-
}
|
|
1287
|
-
|
|
1288
|
-
/** True when an authored allowlist mixes `"*"` with other connector names. */
|
|
1289
|
-
export function cursorAccountServersHasMixedWildcard(servers: string[] | "*" | undefined): boolean {
|
|
1290
|
-
if (servers === undefined || servers === "*") {
|
|
1291
|
-
return false;
|
|
1292
|
-
}
|
|
1293
|
-
const trimmed = servers.map(server => server.trim());
|
|
1294
|
-
return trimmed.includes("*") && trimmed.some(server => server !== "*");
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
/**
|
|
1298
|
-
* True for an HTTP/SSE transport authorized with host PKCE OAuth
|
|
1299
|
-
* (`defineConnection({ url, oauth: true })`). The tokens live on the serve
|
|
1300
|
-
* host (`mcp-auth.json` / `MCP_OAUTH_*`), so only host-side MCP clients can
|
|
1301
|
-
* use them.
|
|
1302
|
-
*/
|
|
1303
|
-
export function isHostOauthConnectionTransport(
|
|
1304
|
-
transport: ConnectionTransport,
|
|
1305
|
-
): transport is Extract<ConnectionTransport, { url: string }> & {
|
|
1306
|
-
oauth: true;
|
|
1307
|
-
} {
|
|
1308
|
-
return "url" in transport && transport.oauth === true;
|
|
1309
|
-
}
|
|
1310
|
-
|
|
1311
|
-
/**
|
|
1312
|
-
* True for transports that stay symbolic at discovery time and are resolved
|
|
1313
|
-
* by the serve host once it is listening (peers and the Cursor account
|
|
1314
|
-
* bridge). Symbolic transports never reach the SDK or the host MCP registry
|
|
1315
|
-
* unresolved.
|
|
1316
|
-
*/
|
|
1317
|
-
export function isSymbolicConnectionTransport(transport: ConnectionTransport): boolean {
|
|
1318
|
-
return isPeerConnectionTransport(transport) || isCursorAccountTransport(transport);
|
|
1319
|
-
}
|
|
1320
|
-
|
|
1321
|
-
/** One TypeScript tool on `defineConnection({ tools })`. */
|
|
1322
|
-
export type InlineStdioToolConfig = {
|
|
1323
|
-
description: string;
|
|
1324
|
-
inputSchema?: z.ZodTypeAny | JsonSchemaObject;
|
|
1325
|
-
/** Output JSON Schema (zod converted, never validated); advertised when declared. */
|
|
1326
|
-
outputSchema?: z.ZodTypeAny | JsonSchemaObject;
|
|
1327
|
-
execute: (input: JsonObject) => unknown | Promise<unknown>;
|
|
1328
|
-
};
|
|
1329
|
-
|
|
1330
|
-
/** `defineConnection({ tools })`. TypeScript in; stdio MCP out. */
|
|
1331
|
-
export type InlineStdioConnectionConfig = {
|
|
1332
|
-
tools: Record<string, InlineStdioToolConfig>;
|
|
1333
|
-
};
|
|
1334
|
-
|
|
1335
|
-
/**
|
|
1336
|
-
* Authored MCP connection config (`defineConnection(...)`).
|
|
1337
|
-
*
|
|
1338
|
-
* For Cursor account connections, `servers` may be omitted, `"*"`, or
|
|
1339
|
-
* `["*"]` to forward every connected HTTP/SSE connector; a concrete
|
|
1340
|
-
* `string[]` allowlists by connector name. Discovery normalizes the
|
|
1341
|
-
* wildcard forms to an unfiltered {@link ConnectionTransport}.
|
|
1342
|
-
*
|
|
1343
|
-
* `{ tools }` authors TypeScript handlers. Discovery packages them into a
|
|
1344
|
-
* stdio MCP server the agent environment can spawn.
|
|
1345
|
-
*/
|
|
1346
|
-
export type ConnectionConfig = (
|
|
1347
|
-
| ((
|
|
1348
|
-
| Exclude<ConnectionTransport, { cursorAccount: true }>
|
|
1349
|
-
| {
|
|
1350
|
-
cursorAccount: true;
|
|
1351
|
-
/**
|
|
1352
|
-
* Which account connectors to expose.
|
|
1353
|
-
*
|
|
1354
|
-
* - Omit, pass `"*"`, or pass `["*"]` to forward **every** connected
|
|
1355
|
-
* HTTP/SSE server on the account (no per-connector allowlist).
|
|
1356
|
-
* - Pass connector names as they appear in the Cursor account's MCP
|
|
1357
|
-
* config (e.g. `["Linear", "Notion"]`) to restrict the set.
|
|
1358
|
-
*/
|
|
1359
|
-
servers?: string[] | "*";
|
|
1360
|
-
}
|
|
1361
|
-
) & {
|
|
1362
|
-
/**
|
|
1363
|
-
* Tool-name allowlist. Same shape as {@link AgentConfig.tools}:
|
|
1364
|
-
* when set, only these MCP tool names (the server's `tools/list`
|
|
1365
|
-
* names) are advertised and callable through `host.mcp`. Names
|
|
1366
|
-
* the server does not list are omitted, not guessed.
|
|
1367
|
-
*
|
|
1368
|
-
* A list of names is an allowlist. An object of handlers authors
|
|
1369
|
-
* TypeScript tools ({@link InlineStdioConnectionConfig}).
|
|
1370
|
-
*
|
|
1371
|
-
* On a model-visible connection this requires {@link advertiseTools}:
|
|
1372
|
-
* an attached server would still expose every tool. On
|
|
1373
|
-
* `host-connections/` it restricts `host.mcp` alone.
|
|
1374
|
-
*
|
|
1375
|
-
* Combines with {@link disallowedTools} as deny-wins.
|
|
1376
|
-
*/
|
|
1377
|
-
tools?: readonly string[];
|
|
1378
|
-
})
|
|
1379
|
-
| InlineStdioConnectionConfig
|
|
1380
|
-
) & {
|
|
1381
|
-
/** Documentation only; shown in `info` output. */
|
|
1382
|
-
description?: string;
|
|
1383
|
-
/**
|
|
1384
|
-
* Per-session auth: called at turn-build time with the session's
|
|
1385
|
-
* {@link SessionInfo}, returning headers merged over the transport's
|
|
1386
|
-
* static `headers` for that session's use of this connection. This is
|
|
1387
|
-
* how a multi-tenant agent injects the caller's identity — it derives
|
|
1388
|
-
* who the session is for host-side and mints a tenant-scoped
|
|
1389
|
-
* credential; the model never sees a tenant parameter and can never
|
|
1390
|
-
* choose the tenant.
|
|
1391
|
-
*
|
|
1392
|
-
* Derive the identity from durable session facts — `session.auth`,
|
|
1393
|
-
* `session.id`, or your channel's own session state. Do **not** key it
|
|
1394
|
-
* off `session.continuationKey`: it is a channel routing key, and channels
|
|
1395
|
-
* may re-key it independently of the authenticated principal.
|
|
1396
|
-
*
|
|
1397
|
-
* Works attached or advertised. Advertised connections
|
|
1398
|
-
* ({@link advertiseTools}) open per-operation clients with the
|
|
1399
|
-
* evaluated headers. Attached connections ride the turn's SDK
|
|
1400
|
-
* `mcpServers`, passed on every send rather than pinned on the cached
|
|
1401
|
-
* per-session agent handle, so every turn — follow-ups, reminder
|
|
1402
|
-
* wakes — runs on headers evaluated for that turn. The cost: when any
|
|
1403
|
-
* attached connection has `auth`, *all* of the agent's attached
|
|
1404
|
-
* connections are configured per send, so the harness opens fresh MCP
|
|
1405
|
-
* clients for them each turn (stdio servers respawn per turn — avoid
|
|
1406
|
-
* pairing an auth'd connection with a stateful stdio server), and
|
|
1407
|
-
* workspace prewarm omits auth'd connections rather than attaching
|
|
1408
|
-
* them without an identity.
|
|
1409
|
-
*
|
|
1410
|
-
* HTTP/SSE transports only, not combinable with `oauth: true`
|
|
1411
|
-
* (discovery rejects both). A callback that throws fails the turn: a
|
|
1412
|
-
* turn never silently runs without the connection's identity.
|
|
1413
|
-
* `host.mcp` calls from server tools keep the static headers only.
|
|
1414
|
-
*/
|
|
1415
|
-
auth?: ConnectionAuthProvider;
|
|
1416
|
-
/**
|
|
1417
|
-
* Advertise this connection's tools by name instead of leaving them
|
|
1418
|
-
* behind the MCP meta-tools: at turn-build time the engine lists the
|
|
1419
|
-
* connection's tools and synthesizes a named 1:1 passthrough server
|
|
1420
|
-
* tool per entry — the server's own names, descriptions, and live
|
|
1421
|
-
* schemas — merged into the authored `agent/tools/` catalog. The raw
|
|
1422
|
-
* connection is then not attached to the model (it stays available on
|
|
1423
|
-
* `host.mcp`), so each tool appears exactly once.
|
|
1424
|
-
*
|
|
1425
|
-
* Fail-closed: a `listTools` failure, an invalid tool name, or a name
|
|
1426
|
-
* collision (with an authored tool or another advertised connection)
|
|
1427
|
-
* fails the turn — a turn never silently runs with a shrunken toolset.
|
|
1428
|
-
* The listing runs once per turn; point this at endpoints that can
|
|
1429
|
-
* answer `tools/list` cheaply. Tools whose MCP `annotations.title` is
|
|
1430
|
-
* `do-not-call` are omitted (vendor host-UI / MCP Apps helpers).
|
|
1431
|
-
*/
|
|
1432
|
-
advertiseTools?: boolean;
|
|
1433
|
-
/**
|
|
1434
|
-
* With {@link advertiseTools}, a `listTools` or `auth` failure skips this
|
|
1435
|
-
* connection (zero tools from it) instead of failing the turn. Other
|
|
1436
|
-
* advertised connections still fail closed. Requires `advertiseTools`.
|
|
1437
|
-
*/
|
|
1438
|
-
optional?: boolean;
|
|
1439
|
-
/**
|
|
1440
|
-
* Intended effects of tools this connection serves. When set, only
|
|
1441
|
-
* tools whose classified effect is in this set are advertised — a
|
|
1442
|
-
* connection that wants reads never puts a write, or a tool nothing
|
|
1443
|
-
* classified, in the model's toolset.
|
|
1444
|
-
*
|
|
1445
|
-
* Classification is the same fail-closed read of MCP annotations the
|
|
1446
|
-
* dry-run gate uses (`readOnlyHint` / `destructiveHint`). A tool the
|
|
1447
|
-
* server does not classify is omitted, not guessed. Servers that leave
|
|
1448
|
-
* tools unannotated stay empty here until they annotate or a trusted
|
|
1449
|
-
* listing injects a known-read hint.
|
|
1450
|
-
*
|
|
1451
|
-
* Requires {@link advertiseTools}: this filters the named passthroughs
|
|
1452
|
-
* the model sees. A single value (`"read"`) and an array (`["read"]`)
|
|
1453
|
-
* are the same.
|
|
1454
|
-
*/
|
|
1455
|
-
effects?: ConnectionEffects;
|
|
1456
|
-
/**
|
|
1457
|
-
* Tool-name denylist. Same shape as the Cursor SDK's
|
|
1458
|
-
* `disallowedTools`: when set, these MCP tool names are omitted from
|
|
1459
|
-
* the advertised set and rejected on `host.mcp`. Combines with
|
|
1460
|
-
* {@link ConnectionConfig.tools} as deny-wins.
|
|
1461
|
-
*
|
|
1462
|
-
* On a model-visible connection this requires {@link advertiseTools}.
|
|
1463
|
-
* On `host-connections/` it restricts `host.mcp` alone.
|
|
1464
|
-
*/
|
|
1465
|
-
disallowedTools?: readonly string[];
|
|
1466
|
-
};
|
|
1467
|
-
|
|
1468
|
-
/**
|
|
1469
|
-
* Per-session connection auth on {@link ConnectionConfig.auth}: session →
|
|
1470
|
-
* headers merged over the transport's static headers for that session's
|
|
1471
|
-
* turns. See the field docs for the fail-closed semantics.
|
|
1472
|
-
*/
|
|
1473
|
-
export type ConnectionAuthProvider = (
|
|
1474
|
-
session: SessionInfo,
|
|
1475
|
-
) => ConnectionAuthResult | Promise<ConnectionAuthResult>;
|
|
1476
|
-
|
|
1477
|
-
/** What a {@link ConnectionAuthProvider} returns. */
|
|
1478
|
-
export type ConnectionAuthResult = {
|
|
1479
|
-
headers: Record<string, string>;
|
|
1480
|
-
};
|
|
1481
|
-
|
|
1482
|
-
/** True when the connection authors tools instead of a spawn/URL/peer. */
|
|
1483
|
-
export function isInlineStdioConnection(
|
|
1484
|
-
connection: ConnectionConfig,
|
|
1485
|
-
): connection is InlineStdioConnectionConfig & {
|
|
1486
|
-
description?: string;
|
|
1487
|
-
} {
|
|
1488
|
-
return (
|
|
1489
|
-
"tools" in connection && connection.tools !== undefined && !Array.isArray(connection.tools)
|
|
1490
|
-
);
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1493
|
-
/**
|
|
1494
|
-
* An MCP connection is available to the agent (SDK `mcpServers`), host
|
|
1495
|
-
* (`ctx.host.mcp`), and channel/schedule handlers.
|
|
1496
|
-
*/
|
|
1497
|
-
export type ConnectionDefinition = ConnectionConfig & BrandedDefinition<"connection">;
|
|
1498
|
-
|
|
1499
|
-
// ============================================================================
|
|
1500
|
-
// Auth
|
|
1501
|
-
// ============================================================================
|
|
1502
|
-
|
|
1503
|
-
/** Who initiated a session (or an authenticated channel request). */
|
|
1504
|
-
export interface AuthContext {
|
|
1505
|
-
/** Which policy authenticated the caller, e.g. `"local-dev"`. */
|
|
1506
|
-
authenticator: string;
|
|
1507
|
-
principalId: string;
|
|
1508
|
-
principalType: "user" | "service" | "runtime";
|
|
1509
|
-
attributes?: Record<string, string>;
|
|
1510
|
-
}
|
|
1511
|
-
|
|
1512
|
-
export interface AuthRequestInfo {
|
|
1513
|
-
/** Client IP, or null when the host cannot provide it. */
|
|
1514
|
-
requestIp: string | null;
|
|
1515
|
-
}
|
|
1516
|
-
|
|
1517
|
-
/**
|
|
1518
|
-
* A route auth policy. Return an {@link AuthContext} to admit the request,
|
|
1519
|
-
* or null to pass to the next policy in the chain. A request is rejected
|
|
1520
|
-
* with 401 when every policy in the chain returns null.
|
|
1521
|
-
*/
|
|
1522
|
-
export type AuthPolicy = (
|
|
1523
|
-
request: Request,
|
|
1524
|
-
info: AuthRequestInfo,
|
|
1525
|
-
) => AuthContext | null | Promise<AuthContext | null>;
|
|
1526
|
-
|
|
1527
|
-
// ============================================================================
|
|
1528
|
-
// Session events (the NDJSON stream vocabulary)
|
|
1529
|
-
// ============================================================================
|
|
1530
|
-
|
|
1531
|
-
export interface SessionEventEnvelope {
|
|
1532
|
-
/** Monotonic per-session event index; reconnect with `?startIndex=`. */
|
|
1533
|
-
index: number;
|
|
1534
|
-
sessionId: string;
|
|
1535
|
-
/** Present on turn-scoped events. */
|
|
1536
|
-
turnId?: string;
|
|
1537
|
-
/** ISO-8601 timestamp. */
|
|
1538
|
-
at: string;
|
|
1539
|
-
}
|
|
1540
|
-
|
|
1541
|
-
export interface ActionCall {
|
|
1542
|
-
callId: string;
|
|
1543
|
-
toolName: string;
|
|
1544
|
-
args?: unknown;
|
|
1545
|
-
/**
|
|
1546
|
-
* When set, this tool call belongs to a nested subagent turn whose
|
|
1547
|
-
* parent `task` tool call id is `parentCallId`.
|
|
1548
|
-
*/
|
|
1549
|
-
parentCallId?: string;
|
|
1550
|
-
/**
|
|
1551
|
-
* Model generation that requested this call. Every tool from one
|
|
1552
|
-
* `runStep` shares the same id (the step's invocation id).
|
|
1553
|
-
*/
|
|
1554
|
-
modelCallId?: string;
|
|
1555
|
-
}
|
|
1556
|
-
|
|
1557
|
-
/** One tool result inside an {@link SessionEventPayload} `actions.completed` batch. */
|
|
1558
|
-
export interface ActionResult {
|
|
1559
|
-
callId: string;
|
|
1560
|
-
toolName: string;
|
|
1561
|
-
output?: unknown;
|
|
1562
|
-
isError: boolean;
|
|
1563
|
-
stubbed?: true;
|
|
1564
|
-
parentCallId?: string;
|
|
1565
|
-
modelCallId?: string;
|
|
1566
|
-
}
|
|
1567
|
-
|
|
1568
|
-
/** Human decision for a parked {@link ToolConfig.needsApproval} tool call. */
|
|
1569
|
-
export type ApprovalDecision = "approve" | "deny";
|
|
1570
|
-
|
|
1571
|
-
/** Durable record of a tool call waiting on human approval. */
|
|
1572
|
-
export interface PendingApproval {
|
|
1573
|
-
callId: string;
|
|
1574
|
-
turnId: string;
|
|
1575
|
-
toolName: string;
|
|
1576
|
-
args: unknown;
|
|
1577
|
-
requestedAt: string;
|
|
1578
|
-
}
|
|
1579
|
-
|
|
1580
|
-
/** Durable record of a tool call waiting on MCP authorization. */
|
|
1581
|
-
export interface PendingAuth {
|
|
1582
|
-
callId: string;
|
|
1583
|
-
turnId: string;
|
|
1584
|
-
toolName: string;
|
|
1585
|
-
connection: string;
|
|
1586
|
-
authUrl: string;
|
|
1587
|
-
requestedAt: string;
|
|
1588
|
-
}
|
|
1589
|
-
|
|
1590
|
-
export type SessionEventPayload =
|
|
1591
|
-
| { type: "session.started"; data: { channelId: string; dryRun?: boolean } }
|
|
1592
|
-
| {
|
|
1593
|
-
/** Cursor SDK agent id is known (cloud: `bc-…`; local: session id). */
|
|
1594
|
-
type: "agent.bound";
|
|
1595
|
-
data: { sdkAgentId: string; url?: string };
|
|
1596
|
-
}
|
|
1597
|
-
| { type: "message.received"; data: { text: string } }
|
|
1598
|
-
| {
|
|
1599
|
-
/**
|
|
1600
|
-
* The turn was admitted while every {@link AgentConcurrencyOptions.maxRunningTurns}
|
|
1601
|
-
* slot was busy; it waits FIFO and `turn.started` follows once a slot
|
|
1602
|
-
* frees. `position` is 1-based among waiting turns at enqueue time.
|
|
1603
|
-
*/
|
|
1604
|
-
type: "turn.queued";
|
|
1605
|
-
data: { position: number; maxRunningTurns: number };
|
|
1606
|
-
}
|
|
1607
|
-
| { type: "turn.started"; data: Record<string, never> }
|
|
1608
|
-
| { type: "step.started"; data: { stepId: number } }
|
|
1609
|
-
| { type: "step.completed"; data: { stepId: number; durationMs: number } }
|
|
1610
|
-
| {
|
|
1611
|
-
type: "reasoning.appended";
|
|
1612
|
-
data: { delta: string; text: string; parentCallId?: string };
|
|
1613
|
-
}
|
|
1614
|
-
| {
|
|
1615
|
-
type: "reasoning.completed";
|
|
1616
|
-
data: { durationMs?: number; parentCallId?: string };
|
|
1617
|
-
}
|
|
1618
|
-
| {
|
|
1619
|
-
type: "message.appended";
|
|
1620
|
-
data: { delta: string; text: string; parentCallId?: string };
|
|
1621
|
-
}
|
|
1622
|
-
| {
|
|
1623
|
-
type: "message.completed";
|
|
1624
|
-
data: {
|
|
1625
|
-
text: string;
|
|
1626
|
-
finishReason: "stop" | "tool_call";
|
|
1627
|
-
parentCallId?: string;
|
|
1628
|
-
};
|
|
1629
|
-
}
|
|
1630
|
-
| {
|
|
1631
|
-
type: "actions.requested";
|
|
1632
|
-
data: {
|
|
1633
|
-
calls: ActionCall[];
|
|
1634
|
-
parentCallId?: string;
|
|
1635
|
-
/**
|
|
1636
|
-
* Same id as {@link ActionCall.modelCallId} on every call.
|
|
1637
|
-
* One envelope per model step (a single tool is a batch of one)
|
|
1638
|
-
* once that step has finished listing tools.
|
|
1639
|
-
*/
|
|
1640
|
-
modelCallId?: string;
|
|
1641
|
-
};
|
|
1642
|
-
}
|
|
1643
|
-
| {
|
|
1644
|
-
/**
|
|
1645
|
-
* A server tool with {@link ToolConfig.needsApproval} is parked until
|
|
1646
|
-
* a human resolves it. The turn stays running; send follow-ups
|
|
1647
|
-
* after `session.waiting` as usual.
|
|
1648
|
-
*/
|
|
1649
|
-
type: "action.approval_requested";
|
|
1650
|
-
data: {
|
|
1651
|
-
callId: string;
|
|
1652
|
-
toolName: string;
|
|
1653
|
-
args?: unknown;
|
|
1654
|
-
parentCallId?: string;
|
|
1655
|
-
};
|
|
1656
|
-
}
|
|
1657
|
-
| {
|
|
1658
|
-
type: "action.approval_resolved";
|
|
1659
|
-
data: {
|
|
1660
|
-
callId: string;
|
|
1661
|
-
toolName: string;
|
|
1662
|
-
decision: ApprovalDecision;
|
|
1663
|
-
by?: string;
|
|
1664
|
-
parentCallId?: string;
|
|
1665
|
-
};
|
|
1666
|
-
}
|
|
1667
|
-
| {
|
|
1668
|
-
/**
|
|
1669
|
-
* A host MCP call/list needs OAuth. The turn stays running until
|
|
1670
|
-
* the human completes the `authUrl` and the runtime retries.
|
|
1671
|
-
*/
|
|
1672
|
-
type: "action.auth_requested";
|
|
1673
|
-
data: {
|
|
1674
|
-
callId: string;
|
|
1675
|
-
toolName: string;
|
|
1676
|
-
connection: string;
|
|
1677
|
-
authUrl: string;
|
|
1678
|
-
parentCallId?: string;
|
|
1679
|
-
};
|
|
1680
|
-
}
|
|
1681
|
-
| {
|
|
1682
|
-
type: "action.auth_resolved";
|
|
1683
|
-
data: {
|
|
1684
|
-
callId: string;
|
|
1685
|
-
toolName: string;
|
|
1686
|
-
connection: string;
|
|
1687
|
-
decision: ApprovalDecision;
|
|
1688
|
-
by?: string;
|
|
1689
|
-
parentCallId?: string;
|
|
1690
|
-
};
|
|
1691
|
-
}
|
|
1692
|
-
| {
|
|
1693
|
-
type: "action.result";
|
|
1694
|
-
data: {
|
|
1695
|
-
callId: string;
|
|
1696
|
-
toolName: string;
|
|
1697
|
-
output?: unknown;
|
|
1698
|
-
isError: boolean;
|
|
1699
|
-
/**
|
|
1700
|
-
* The tool never ran: a write answered by the host in a `dryRun`
|
|
1701
|
-
* session. `actions.requested` still carries the arguments the model
|
|
1702
|
-
* chose, so this is the marker that separates "what it would have
|
|
1703
|
-
* done" from a real effect when reading a trajectory.
|
|
1704
|
-
*/
|
|
1705
|
-
stubbed?: true;
|
|
1706
|
-
parentCallId?: string;
|
|
1707
|
-
/** Same id as the matching {@link ActionCall.modelCallId}. */
|
|
1708
|
-
modelCallId?: string;
|
|
1709
|
-
};
|
|
1710
|
-
}
|
|
1711
|
-
| {
|
|
1712
|
-
/**
|
|
1713
|
-
* Every result for one {@link SessionEventPayload} `actions.requested`
|
|
1714
|
-
* batch. Pair these two events; `action.result` stays the live
|
|
1715
|
-
* per-call envelope for chips and spans.
|
|
1716
|
-
*/
|
|
1717
|
-
type: "actions.completed";
|
|
1718
|
-
data: {
|
|
1719
|
-
results: ActionResult[];
|
|
1720
|
-
parentCallId?: string;
|
|
1721
|
-
modelCallId?: string;
|
|
1722
|
-
};
|
|
1723
|
-
}
|
|
1724
|
-
| {
|
|
1725
|
-
/**
|
|
1726
|
-
* A dry-run call was refused because nothing classifies the tool's
|
|
1727
|
-
* effect: the MCP server sent no readOnlyHint/destructiveHint and no
|
|
1728
|
-
* server-side classification exists for it. The per-run count of these
|
|
1729
|
-
* is the coverage signal — how much of a backtest was actually
|
|
1730
|
-
* runnable, reported rather than assumed.
|
|
1731
|
-
*/
|
|
1732
|
-
type: "action.effect_unclassified";
|
|
1733
|
-
data: { callId: string; toolName: string; connection?: string };
|
|
1734
|
-
}
|
|
1735
|
-
| {
|
|
1736
|
-
type: "subagent.called";
|
|
1737
|
-
data: { callId: string; name?: string; description?: string };
|
|
1738
|
-
}
|
|
1739
|
-
| { type: "subagent.completed"; data: { callId: string; name?: string } }
|
|
1740
|
-
| {
|
|
1741
|
-
/** An artifact was tagged for this session (see {@link ArtifactsApi.tag}). */
|
|
1742
|
-
type: "artifact.tagged";
|
|
1743
|
-
data: {
|
|
1744
|
-
id: string;
|
|
1745
|
-
kind: string;
|
|
1746
|
-
key?: string;
|
|
1747
|
-
title?: string;
|
|
1748
|
-
data: JsonValue;
|
|
1749
|
-
source: ArtifactSource;
|
|
1750
|
-
};
|
|
1751
|
-
}
|
|
1752
|
-
| {
|
|
1753
|
-
type: "turn.completed";
|
|
1754
|
-
data: {
|
|
1755
|
-
result?: string;
|
|
1756
|
-
usage?: TurnUsage;
|
|
1757
|
-
cost?: TurnCost;
|
|
1758
|
-
};
|
|
1759
|
-
}
|
|
1760
|
-
| {
|
|
1761
|
-
/**
|
|
1762
|
-
* The harness accepted the turn and named the run. Emitted once the
|
|
1763
|
-
* send lands, so a channel can show the request id while the turn is
|
|
1764
|
-
* still going rather than after it. Quote it verbatim when correlating
|
|
1765
|
-
* with backend logs — never abbreviated.
|
|
1766
|
-
*/
|
|
1767
|
-
type: "turn.bound";
|
|
1768
|
-
data: { requestId: string };
|
|
1769
|
-
}
|
|
1770
|
-
| {
|
|
1771
|
-
type: "turn.failed";
|
|
1772
|
-
data: {
|
|
1773
|
-
message: string;
|
|
1774
|
-
/** Machine-readable terminal status. Omitted on legacy stored events. */
|
|
1775
|
-
status?: "error" | "cancelled";
|
|
1776
|
-
};
|
|
1777
|
-
}
|
|
1778
|
-
| {
|
|
1779
|
-
/**
|
|
1780
|
-
* A Slack follow-up queued mid-turn reached the running agent: the
|
|
1781
|
-
* workspace carrier moved it from `pending/` to `delivered/` at a tool
|
|
1782
|
-
* boundary. Channels use this to reposition a live progress message
|
|
1783
|
-
* below the follow-up, which Slack cannot do any other way.
|
|
1784
|
-
*/
|
|
1785
|
-
type: "nudge.delivered";
|
|
1786
|
-
data: Record<string, never>;
|
|
1787
|
-
}
|
|
1788
|
-
| { type: "session.waiting"; data: Record<string, never> }
|
|
1789
|
-
| { type: "session.completed"; data: Record<string, never> }
|
|
1790
|
-
| { type: "session.failed"; data: { message: string } };
|
|
1791
|
-
|
|
1792
|
-
export type SessionEvent = SessionEventEnvelope & SessionEventPayload;
|
|
1793
|
-
export type SessionEventType = SessionEventPayload["type"];
|
|
1794
|
-
|
|
1795
|
-
export interface TurnUsage {
|
|
1796
|
-
inputTokens: number;
|
|
1797
|
-
outputTokens: number;
|
|
1798
|
-
cacheReadTokens: number;
|
|
1799
|
-
cacheWriteTokens: number;
|
|
1800
|
-
reasoningTokens?: number;
|
|
1801
|
-
}
|
|
1802
|
-
|
|
1803
|
-
/**
|
|
1804
|
-
* Dollar cost of one turn's token usage (one agent loop pass).
|
|
1805
|
-
* Recorded on `turn.completed` events so traces, the playground, and the
|
|
1806
|
-
* CLI can aggregate spend. Computed by
|
|
1807
|
-
* `POST /v1/models/estimate-cost` — billed usage events when available
|
|
1808
|
-
* (credits, discounts, CTF), otherwise live catalog pricing.
|
|
1809
|
-
*/
|
|
1810
|
-
export interface TurnCost {
|
|
1811
|
-
/** Charged total for the turn, in USD. */
|
|
1812
|
-
totalUsd: number;
|
|
1813
|
-
inputUsd: number;
|
|
1814
|
-
outputUsd: number;
|
|
1815
|
-
cacheReadUsd: number;
|
|
1816
|
-
cacheWriteUsd: number;
|
|
1817
|
-
/** Model id the cost was priced against. */
|
|
1818
|
-
model: string;
|
|
1819
|
-
/** `"usage"` is billed events; `"catalog"` is live list pricing. */
|
|
1820
|
-
source: "usage" | "catalog";
|
|
1821
|
-
rawCostCents?: number;
|
|
1822
|
-
chargedCents?: number;
|
|
1823
|
-
}
|
|
1824
|
-
|
|
1825
|
-
// ============================================================================
|
|
1826
|
-
// Sessions
|
|
1827
|
-
// ============================================================================
|
|
1828
|
-
|
|
1829
|
-
export type SessionMode = "chat" | "task";
|
|
1830
|
-
|
|
1831
|
-
/**
|
|
1832
|
-
* Why the session exists. `"eval"` is regression traffic (`defineEval` /
|
|
1833
|
-
* `agent-sdk eval` / playground Evals). Default `"live"`.
|
|
1834
|
-
*/
|
|
1835
|
-
export type SessionPurpose = "live" | "eval";
|
|
1836
|
-
|
|
1837
|
-
/** Read-only view of a session, handed to tools, hooks, and channel events. */
|
|
1838
|
-
export interface SessionInfo {
|
|
1839
|
-
id: string;
|
|
1840
|
-
channelId: string;
|
|
1841
|
-
mode: SessionMode;
|
|
1842
|
-
/** Omit / `"live"` for production traffic; `"eval"` for eval harness sessions. */
|
|
1843
|
-
purpose?: SessionPurpose;
|
|
1844
|
-
/** True when write-classified tool calls are answered by the host. */
|
|
1845
|
-
dryRun?: boolean;
|
|
1846
|
-
/** Frozen instant this session reads at; absent means the wall clock. */
|
|
1847
|
-
asOf?: string;
|
|
1848
|
-
auth: AuthContext | null;
|
|
1849
|
-
title?: string;
|
|
1850
|
-
/**
|
|
1851
|
-
* Channel-local continuation key when the session is addressable for
|
|
1852
|
-
* follow-ups / reminders. Null when the session is not re-keyable.
|
|
1853
|
-
*/
|
|
1854
|
-
continuationKey?: string | null;
|
|
1855
|
-
/**
|
|
1856
|
-
* Cursor SDK agent id once bound (hosted ids start with `bc-`; local
|
|
1857
|
-
* turns use the session id). Hosted ids are minted during the first
|
|
1858
|
-
* send, so read this from a fresh `getSession()` handle after a turn
|
|
1859
|
-
* completes — unless the session was created with a seeded
|
|
1860
|
-
* {@link SendMessageOptions.sdkAgentId}.
|
|
1861
|
-
*/
|
|
1862
|
-
sdkAgentId?: string;
|
|
1863
|
-
}
|
|
1864
|
-
|
|
1865
|
-
/** Persisted session record (stored at `sessions/<id>/session.json`). */
|
|
1866
|
-
export interface SessionRecord {
|
|
1867
|
-
sessionId: string;
|
|
1868
|
-
channelId: string;
|
|
1869
|
-
mode: SessionMode;
|
|
1870
|
-
/**
|
|
1871
|
-
* `"eval"` for harness sessions. Older records omit this (treated as
|
|
1872
|
-
* `"live"`).
|
|
1873
|
-
*/
|
|
1874
|
-
purpose?: SessionPurpose;
|
|
1875
|
-
/** Frozen at create from {@link SendMessageOptions.dryRun}. */
|
|
1876
|
-
dryRun?: boolean;
|
|
1877
|
-
/** Frozen at create from {@link SendMessageOptions.asOf}. */
|
|
1878
|
-
asOf?: string;
|
|
1879
|
-
/** Channel-local continuation key; null when the session is not addressable. */
|
|
1880
|
-
continuationKey: string | null;
|
|
1881
|
-
/**
|
|
1882
|
-
* Rotating HTTP follow-up credential for a channel-owned session.
|
|
1883
|
-
* Omitted until HTTP accepts the first follow-up.
|
|
1884
|
-
*/
|
|
1885
|
-
httpContinuationKey?: string;
|
|
1886
|
-
auth: AuthContext | null;
|
|
1887
|
-
title?: string;
|
|
1888
|
-
channelState?: JsonValue;
|
|
1889
|
-
/** Cursor SDK agent id for this session. */
|
|
1890
|
-
sdkAgentId?: string;
|
|
1891
|
-
/**
|
|
1892
|
-
* When set, local harness turns use this directory as `cwd` (e.g. a PR
|
|
1893
|
-
* worktree). Session scaffold files still land under the session workspace.
|
|
1894
|
-
*/
|
|
1895
|
-
workspaceOverride?: string;
|
|
1896
|
-
/**
|
|
1897
|
-
* One-shot files for the next turn (see
|
|
1898
|
-
* {@link SendMessageOptions.workspaceFiles}). Cleared after apply.
|
|
1899
|
-
*/
|
|
1900
|
-
pendingWorkspaceFiles?: Record<
|
|
1901
|
-
string,
|
|
1902
|
-
string | { encoding: "base64"; data: string; mimeType?: string }
|
|
1903
|
-
>;
|
|
1904
|
-
/**
|
|
1905
|
-
* One-shot vision images for the next turn (see
|
|
1906
|
-
* {@link SendMessageOptions.images}). Cleared after apply.
|
|
1907
|
-
*/
|
|
1908
|
-
pendingImages?: Array<{ data: string; mimeType: string }>;
|
|
1909
|
-
/**
|
|
1910
|
-
* Per-session cloud attach options captured at session creation, merged
|
|
1911
|
-
* over the agent's static `cloud` config on every turn of this session.
|
|
1912
|
-
*/
|
|
1913
|
-
cloudOverride?: AgentCloudOptions;
|
|
1914
|
-
/**
|
|
1915
|
-
* Server-tool calls parked for human approval. Cleared when resolved
|
|
1916
|
-
* or when the host process restarts without a live waiter (the in-flight
|
|
1917
|
-
* SDK tool callback cannot be resumed after process restart).
|
|
1918
|
-
*/
|
|
1919
|
-
pendingApprovals?: PendingApproval[];
|
|
1920
|
-
/**
|
|
1921
|
-
* Server-tool MCP calls parked for host or Cursor-account OAuth.
|
|
1922
|
-
* Cleared when resolved or when the host restarts without a live waiter.
|
|
1923
|
-
*/
|
|
1924
|
-
pendingAuths?: PendingAuth[];
|
|
1925
|
-
turnCount: number;
|
|
1926
|
-
createdAt: string;
|
|
1927
|
-
updatedAt: string;
|
|
1928
|
-
}
|
|
1929
|
-
|
|
1930
|
-
export interface TurnOutcome {
|
|
1931
|
-
status: "finished" | "error" | "cancelled";
|
|
1932
|
-
result?: string;
|
|
1933
|
-
errorMessage?: string;
|
|
1934
|
-
/** Stable machine-readable runner code when the failure supplied one. */
|
|
1935
|
-
errorCode?: string;
|
|
1936
|
-
/** Why a cancelled turn stopped, when the engine observed the boundary. */
|
|
1937
|
-
cancellationReason?: "signal" | "runner";
|
|
1938
|
-
usage?: TurnUsage;
|
|
1939
|
-
/** Cost of {@link usage} from the Cloud Agents cost endpoint. */
|
|
1940
|
-
cost?: TurnCost;
|
|
1941
|
-
}
|
|
1942
|
-
|
|
1943
|
-
/**
|
|
1944
|
-
* Session metadata returned by `GET /v1/sessions` (and consumed by the
|
|
1945
|
-
* bundled playground). Includes the current wire-format continuation token:
|
|
1946
|
-
* the listing is a testing/observability surface for callers already
|
|
1947
|
-
* admitted by the route auth chain.
|
|
1948
|
-
*/
|
|
1949
|
-
export interface SessionSummary {
|
|
1950
|
-
sessionId: string;
|
|
1951
|
-
channelId: string;
|
|
1952
|
-
mode: SessionMode;
|
|
1953
|
-
title?: string;
|
|
1954
|
-
turnCount: number;
|
|
1955
|
-
/** True while a turn is executing right now (including queued turns). */
|
|
1956
|
-
running: boolean;
|
|
1957
|
-
/**
|
|
1958
|
-
* True while the session's admitted turn is waiting for a
|
|
1959
|
-
* {@link AgentConcurrencyOptions.maxRunningTurns} slot (subset of
|
|
1960
|
-
* {@link running}). Omitted when the agent has no turn limit.
|
|
1961
|
-
*/
|
|
1962
|
-
queued?: boolean;
|
|
1963
|
-
createdAt: string;
|
|
1964
|
-
updatedAt: string;
|
|
1965
|
-
/** True when write-classified tool calls are answered by the host. */
|
|
1966
|
-
dryRun?: boolean;
|
|
1967
|
-
/** Active wire token for HTTP follow-ups, or null when not addressable. */
|
|
1968
|
-
continuationToken: string | null;
|
|
1969
|
-
/**
|
|
1970
|
-
* Conversation permalink (Slack thread, else GitHub PR).
|
|
1971
|
-
*/
|
|
1972
|
-
externalUrl?: string;
|
|
1973
|
-
/** GitHub PR when the session is about one. */
|
|
1974
|
-
prUrl?: string;
|
|
1975
|
-
}
|
|
1976
|
-
|
|
1977
|
-
/**
|
|
1978
|
-
* Where `GET /v1/sessions` loaded rows from.
|
|
1979
|
-
* - `cursor-hosted` — durable Bugbot `agent_serve_kv` via `cursorHostedStorage`
|
|
1980
|
-
* - `local` — the serve process `--state-root` session store
|
|
1981
|
-
*/
|
|
1982
|
-
export type SessionListSource = "cursor-hosted" | "local";
|
|
1983
|
-
|
|
1984
|
-
/**
|
|
1985
|
-
* A session handle scoped to the channel that owns it. This is what channel
|
|
1986
|
-
* route handlers get back from `send()` / `getSession()`.
|
|
1987
|
-
*/
|
|
1988
|
-
export interface ChannelSession {
|
|
1989
|
-
readonly id: string;
|
|
1990
|
-
/** Channel-local continuation key currently addressing this session. */
|
|
1991
|
-
readonly continuationToken: string | null;
|
|
1992
|
-
/** True when this `send()` created the session. */
|
|
1993
|
-
readonly isNew: boolean;
|
|
1994
|
-
/**
|
|
1995
|
-
* True when `admission: "coalesce"` enqueued this message behind an
|
|
1996
|
-
* in-flight turn instead of starting immediately (Slack busy path).
|
|
1997
|
-
*/
|
|
1998
|
-
readonly coalesced?: boolean;
|
|
1999
|
-
readonly info: SessionInfo;
|
|
2000
|
-
/**
|
|
2001
|
-
* Replay recorded events from `startIndex`, then follow live (NDJSON).
|
|
2002
|
-
* A handle from `send()` defaults `startIndex` to this admission so a
|
|
2003
|
-
* resumed continuation does not replay earlier turns.
|
|
2004
|
-
*/
|
|
2005
|
-
getEventStream(options?: { startIndex?: number }): Promise<ReadableStream<Uint8Array>>;
|
|
2006
|
-
/**
|
|
2007
|
-
* Resolves after the currently running turn reaches a terminal event and
|
|
2008
|
-
* handlers already queued for that session have settled.
|
|
2009
|
-
*/
|
|
2010
|
-
waitForCompletion(): Promise<TurnOutcome>;
|
|
2011
|
-
/** Re-key the session's channel-local continuation token. */
|
|
2012
|
-
setContinuationToken(token: string | null): Promise<void>;
|
|
2013
|
-
}
|
|
2014
|
-
|
|
2015
|
-
export interface SendMessageOptions {
|
|
2016
|
-
/**
|
|
2017
|
-
* Who is sending; flows to `session.auth` on newly created sessions.
|
|
2018
|
-
* On HTTP channel routes, defaults to the request principal from
|
|
2019
|
-
* {@link ChannelHandlerArgs.auth}. Pass explicitly to override (e.g.
|
|
2020
|
-
* `null` or a Slack-derived principal).
|
|
2021
|
-
*/
|
|
2022
|
-
auth?: AuthContext | null;
|
|
2023
|
-
/**
|
|
2024
|
-
* Channel-local continuation token. When it addresses an existing session
|
|
2025
|
-
* the message is a follow-up; otherwise a new session is created keyed by
|
|
2026
|
-
* this token. Omit to always create a fresh session.
|
|
2027
|
-
*
|
|
2028
|
-
* `/v2` selectors refuse this field — pass {@link mailboxContinuation} or
|
|
2029
|
-
* a structured {@link claim} instead.
|
|
2030
|
-
*/
|
|
2031
|
-
continuationToken?: string;
|
|
2032
|
-
/**
|
|
2033
|
-
* v2 mailbox stamp from the control plane (hosted verified ingress or
|
|
2034
|
-
* the local CP). Channel adapters do not extract. Ignored on v1.
|
|
2035
|
-
*/
|
|
2036
|
-
mailboxContinuation?: MailboxContinuation;
|
|
2037
|
-
/**
|
|
2038
|
-
* v2 host join. Never a concatenated `pr:owner/repo#N` string — the
|
|
2039
|
-
* registry mints `cont:` bytes from this claim.
|
|
2040
|
-
*/
|
|
2041
|
-
claim?: ContinuationClaim;
|
|
2042
|
-
/** Initial channel state for newly created sessions. */
|
|
2043
|
-
state?: JsonValue;
|
|
2044
|
-
/**
|
|
2045
|
-
* On resume (continuation hit), shallow-merge into the existing session
|
|
2046
|
-
* channel state before the turn starts. Null / undefined values in the
|
|
2047
|
-
* patch do not overwrite existing keys, so sticky fields (stream ts,
|
|
2048
|
-
* progress banner comment id, …) survive while wake-derived fields
|
|
2049
|
-
* (`headSha`, refs) refresh. Ignored on create; pass {@link state} there.
|
|
2050
|
-
*/
|
|
2051
|
-
refreshState?: JsonValue;
|
|
2052
|
-
/** Session display title (applied when creating a new session). */
|
|
2053
|
-
title?: string;
|
|
2054
|
-
/**
|
|
2055
|
-
* Session purpose at create time. `"eval"` marks regression traffic so
|
|
2056
|
-
* hooks and telemetry can tell it from live sessions.
|
|
2057
|
-
*/
|
|
2058
|
-
purpose?: SessionPurpose;
|
|
2059
|
-
/**
|
|
2060
|
-
* Answer every write-classified tool call from the host instead of running
|
|
2061
|
-
* it, for this session's whole life (create only — a follow-up cannot clear
|
|
2062
|
-
* it, so a session that starts as a rehearsal stays one).
|
|
2063
|
-
*
|
|
2064
|
-
* Reads execute, writes are answered and recorded, and the arguments the
|
|
2065
|
-
* model chose stay on the session log as the record of the intended action.
|
|
2066
|
-
*/
|
|
2067
|
-
dryRun?: boolean;
|
|
2068
|
-
/**
|
|
2069
|
-
* ISO-8601 instant with a timezone, frozen at create: the prompt states
|
|
2070
|
-
* it, {@link ToolContext.now} returns it, and every tool call is checked
|
|
2071
|
-
* against it — a relative time argument (`now-1h`), an absolute one after
|
|
2072
|
-
* the instant, or an omitted window a vendor schema declares is refused so
|
|
2073
|
-
* the model retries with explicit absolute bounds. Tools may also declare
|
|
2074
|
-
* {@link ToolConfig.timeArgs} for precise per-field checking. The check
|
|
2075
|
-
* reads arguments, not behavior: a tool that reads present state without a
|
|
2076
|
-
* time argument still answers from the present.
|
|
2077
|
-
*/
|
|
2078
|
-
asOf?: string;
|
|
2079
|
-
/**
|
|
2080
|
-
* Absolute directory used as the local harness `cwd` for this session.
|
|
2081
|
-
* On create, sets the session workspace. On resume (continuation hit),
|
|
2082
|
-
* refreshes `workspaceOverride` when the path differs — e.g. a newer PR
|
|
2083
|
-
* worktree after synchronize.
|
|
2084
|
-
*/
|
|
2085
|
-
workspaceDir?: string;
|
|
2086
|
-
/**
|
|
2087
|
-
* Relative path to contents for the next turn. On create, queued for the
|
|
2088
|
-
* first turn; on resume, merged into pending files. Prefer this over
|
|
2089
|
-
* {@link workspaceDir} when you only need to inject a few host-prepared
|
|
2090
|
-
* files. Values may be utf8 strings or
|
|
2091
|
-
* `{ encoding: "base64", data }` blobs (Slack attachments, binary docs).
|
|
2092
|
-
*/
|
|
2093
|
-
workspaceFiles?: Record<string, string | { encoding: "base64"; data: string; mimeType?: string }>;
|
|
2094
|
-
/**
|
|
2095
|
-
* Base64 images for this turn's Cursor SDK `send({ images })` (vision).
|
|
2096
|
-
* Cleared after the turn starts. Slack inbound fills this from uploads.
|
|
2097
|
-
*/
|
|
2098
|
-
images?: Array<{ data: string; mimeType: string }>;
|
|
2099
|
-
/**
|
|
2100
|
-
* Per-session cloud attach options, merged over the agent's static
|
|
2101
|
-
* `cloud` config (new sessions only). When set, this session attaches
|
|
2102
|
-
* even if {@link AgentConfig.runtime} is `"local"`. Cannot be combined
|
|
2103
|
-
* with {@link clearCloudOverride}.
|
|
2104
|
-
*/
|
|
2105
|
-
cloud?: AgentCloudOptions;
|
|
2106
|
-
/**
|
|
2107
|
-
* Clear cloud attach options retained by an existing continuation
|
|
2108
|
-
* session before starting this turn. Cannot be combined with
|
|
2109
|
-
* {@link cloud}. No-op on a new session.
|
|
2110
|
-
*/
|
|
2111
|
-
clearCloudOverride?: boolean;
|
|
2112
|
-
/**
|
|
2113
|
-
* Seed the Cursor SDK agent id for a new session (ignored when the
|
|
2114
|
-
* continuation token matches an existing session). A `bc-…` value
|
|
2115
|
-
* reattaches the first turn to that hosted conversation.
|
|
2116
|
-
*/
|
|
2117
|
-
sdkAgentId?: string;
|
|
2118
|
-
/**
|
|
2119
|
-
* Turn admission when a session is already busy.
|
|
2120
|
-
* - `"preempt"` (default) — interrupt the in-flight turn (HTTP / MCP).
|
|
2121
|
-
* - `"coalesce"` — enqueue and return without interrupting (Slack).
|
|
2122
|
-
*/
|
|
2123
|
-
admission?: "preempt" | "coalesce";
|
|
2124
|
-
/**
|
|
2125
|
-
* Optional source message timestamp for coalesce queue items. When a
|
|
2126
|
-
* mid-turn nudge already delivered this `sourceTs`, boundary resume skips it.
|
|
2127
|
-
*/
|
|
2128
|
-
coalesceSourceTs?: string;
|
|
2129
|
-
}
|
|
2130
|
-
|
|
2131
|
-
export type SendMessageFn = (
|
|
2132
|
-
message: string,
|
|
2133
|
-
options?: SendMessageOptions,
|
|
2134
|
-
) => Promise<ChannelSession>;
|
|
2135
|
-
|
|
2136
|
-
// ============================================================================
|
|
2137
|
-
// Direct tool calls (deterministic invocation, no model turn)
|
|
2138
|
-
// ============================================================================
|
|
2139
|
-
|
|
2140
|
-
/**
|
|
2141
|
-
* Channel id recorded on the synthetic session info handed to tools invoked
|
|
2142
|
-
* directly (outside any existing session).
|
|
2143
|
-
*/
|
|
2144
|
-
export const DIRECT_TOOL_CALL_CHANNEL_ID = "direct";
|
|
2145
|
-
|
|
2146
|
-
/** Options for {@link CallToolFn} — calling an authored tool directly. */
|
|
2147
|
-
export interface CallToolOptions {
|
|
2148
|
-
/** Who is calling; becomes the tool context's session auth. */
|
|
2149
|
-
auth?: AuthContext | null;
|
|
2150
|
-
/**
|
|
2151
|
-
* Address the session by its wire continuation token
|
|
2152
|
-
* (`<channelId>:<key>`, as `/v1/sessions` lists it). A token that maps
|
|
2153
|
-
* to a live (or restorable) session behaves exactly like passing that
|
|
2154
|
-
* session's {@link sessionId} — ownership check, turn serialization, and
|
|
2155
|
-
* event recording included. A token with no session behind it runs the
|
|
2156
|
-
* call scratch-bound with the token's channel id and continuation key as
|
|
2157
|
-
* the call's session identity, so deployments whose tools resolve state
|
|
2158
|
-
* from the continuation key (e.g. VFS mounts rebuilt by a binding
|
|
2159
|
-
* resolver) can serve it with no live session. Mutually exclusive with
|
|
2160
|
-
* {@link sessionId}.
|
|
2161
|
-
*/
|
|
2162
|
-
continuationToken?: string;
|
|
2163
|
-
/**
|
|
2164
|
-
* Run the tool inside an existing session: the tool sees that session's
|
|
2165
|
-
* info and materialized workspace, and the call is recorded on the
|
|
2166
|
-
* session's event stream (`actions.requested` / `action.result` under a
|
|
2167
|
-
* per-call `turnId`). Rejected while a model turn is running on the
|
|
2168
|
-
* session. Omit to run against an ephemeral scratch workspace under
|
|
2169
|
-
* `<stateRoot>/tool-calls/<callId>` (materialized with seed files and
|
|
2170
|
-
* removed after the call) with a synthetic
|
|
2171
|
-
* {@link DIRECT_TOOL_CALL_CHANNEL_ID} session info.
|
|
2172
|
-
*/
|
|
2173
|
-
sessionId?: string;
|
|
2174
|
-
}
|
|
2175
|
-
|
|
2176
|
-
/** Result of a direct (deterministic) tool call. */
|
|
2177
|
-
export interface ToolCallOutcome {
|
|
2178
|
-
toolName: string;
|
|
2179
|
-
/** Correlates with the recorded events for session-bound calls. */
|
|
2180
|
-
callId: string;
|
|
2181
|
-
/** True when the tool threw or returned an error envelope. */
|
|
2182
|
-
isError: boolean;
|
|
2183
|
-
/** Normalized result, exactly as the model would receive it. */
|
|
2184
|
-
result: unknown;
|
|
2185
|
-
/**
|
|
2186
|
-
* Human-readable failure text when {@link isError} is true (joined text
|
|
2187
|
-
* parts from the error envelope, or a string result). Prefer this over
|
|
2188
|
-
* re-parsing {@link result} in channel handlers.
|
|
2189
|
-
*/
|
|
2190
|
-
errorMessage?: string;
|
|
2191
|
-
durationMs: number;
|
|
2192
|
-
/** Present when the call ran inside an existing session. */
|
|
2193
|
-
sessionId?: string;
|
|
2194
|
-
/**
|
|
2195
|
-
* Present (true) when a session-bound call could not materialize a
|
|
2196
|
-
* session-owned harness cwd and ran in a scratch workspace instead.
|
|
2197
|
-
* The session identity still applied (read-effect calls only get here),
|
|
2198
|
-
* but `ctx.workspaceDir` was not the session workspace — callers
|
|
2199
|
-
* rendering results as session state should surface this.
|
|
2200
|
-
*
|
|
2201
|
-
* A shared `local.workspaceDir` the host cannot create (a phantom path
|
|
2202
|
-
* like `/repo`) is kept as-is and does not set this flag.
|
|
2203
|
-
*/
|
|
2204
|
-
scratchWorkspace?: true;
|
|
2205
|
-
}
|
|
2206
|
-
|
|
2207
|
-
/**
|
|
2208
|
-
* Call an authored server tool (`agent/tools/<name>.ts`) deterministically:
|
|
2209
|
-
* the input is validated against the tool's schema (zod schemas validate;
|
|
2210
|
-
* plain JSON Schema inputs pass through unvalidated, matching the model
|
|
2211
|
-
* path) and `execute` runs in-process, without a model turn deciding to
|
|
2212
|
-
* call it. Rejects unknown tools, `execution: "agent"` tools, and invalid
|
|
2213
|
-
* input by throwing.
|
|
2214
|
-
*/
|
|
2215
|
-
export type CallToolFn = (
|
|
2216
|
-
toolName: string,
|
|
2217
|
-
input?: unknown,
|
|
2218
|
-
options?: CallToolOptions,
|
|
2219
|
-
) => Promise<ToolCallOutcome>;
|
|
2220
|
-
|
|
2221
|
-
// ============================================================================
|
|
2222
|
-
// Channels (agent/channels/*.ts)
|
|
2223
|
-
// ============================================================================
|
|
2224
|
-
|
|
2225
|
-
export type RouteMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
2226
|
-
|
|
2227
|
-
export interface ChannelHandlerArgs {
|
|
2228
|
-
/** Route parameters extracted from the path pattern. */
|
|
2229
|
-
params: Record<string, string>;
|
|
2230
|
-
requestIp: string | null;
|
|
2231
|
-
/** Auth context resolved by the channel's auth chain. */
|
|
2232
|
-
auth: AuthContext | null;
|
|
2233
|
-
/**
|
|
2234
|
-
* Validated JSON body when the route declares `bodySchema` (Zod).
|
|
2235
|
-
* Prefer this over `request.json()` so the body is not read twice.
|
|
2236
|
-
*/
|
|
2237
|
-
body?: unknown;
|
|
2238
|
-
/**
|
|
2239
|
-
* Validated query object when the route declares `querySchema` (Zod).
|
|
2240
|
-
* Built from `URLSearchParams` (string values) before validation.
|
|
2241
|
-
*/
|
|
2242
|
-
query?: unknown;
|
|
2243
|
-
/** Shared host services (MCP / GitHub / Slack). Same as tool `ctx.host`. */
|
|
2244
|
-
host: HostContext;
|
|
2245
|
-
/** Start or resume a session on this channel. */
|
|
2246
|
-
send: SendMessageFn;
|
|
2247
|
-
/** Look up an existing session on this channel. */
|
|
2248
|
-
getSession(sessionId: string): Promise<ChannelSession | null>;
|
|
2249
|
-
/** Hand inbound work to a different channel (cross-channel hand-off). */
|
|
2250
|
-
receive(
|
|
2251
|
-
channel: ChannelDefinition | HttpChannelDefinition | string,
|
|
2252
|
-
input: ReceiveInput,
|
|
2253
|
-
): Promise<ChannelSession>;
|
|
2254
|
-
/** Call an authored server tool directly (no model turn). */
|
|
2255
|
-
callTool: CallToolFn;
|
|
2256
|
-
/** Extend server lifetime tracking for background work. */
|
|
2257
|
-
waitUntil(promise: Promise<unknown>): void;
|
|
2258
|
-
/**
|
|
2259
|
-
* Absolute playground + NDJSON trace URLs for a session on this agent
|
|
2260
|
-
* mount (single-agent `""` or multi-agent `"/<slug>"`). Prefer this over
|
|
2261
|
-
* rebuilding paths from the request URL.
|
|
2262
|
-
*/
|
|
2263
|
-
sessionUrls(request: Request, sessionId: string): { playgroundUrl: string; traceUrl: string };
|
|
2264
|
-
/**
|
|
2265
|
-
* Durable artifacts (unbound — channel handlers have no ambient session;
|
|
2266
|
-
* pass `sessionId` in `tag` input to attribute one).
|
|
2267
|
-
*/
|
|
2268
|
-
artifacts: ArtifactsApi;
|
|
2269
|
-
/** Hosted Slack admission uses this to paint a warm follow-up. */
|
|
2270
|
-
hasContinuationSession?(continuationToken: string): Promise<boolean>;
|
|
2271
|
-
isContinuationBusy?(continuationToken: string): Promise<boolean>;
|
|
2272
|
-
getContinuationLastBotMessageTs?(continuationToken: string): Promise<string | undefined>;
|
|
2273
|
-
interruptContinuation?(continuationToken: string): Promise<boolean>;
|
|
2274
|
-
}
|
|
2275
|
-
|
|
2276
|
-
export type ChannelRouteHandler = (
|
|
2277
|
-
request: Request,
|
|
2278
|
-
args: ChannelHandlerArgs,
|
|
2279
|
-
) => Response | Promise<Response>;
|
|
2280
|
-
|
|
2281
|
-
/**
|
|
2282
|
-
* Channel HTTP routes must declare a Zod schema (plain JSON Schema objects
|
|
2283
|
-
* are not accepted — TypeScript will reject them).
|
|
2284
|
-
*/
|
|
2285
|
-
export type ChannelRouteSchema = z.ZodTypeAny;
|
|
2286
|
-
|
|
2287
|
-
/** Handler args with a required, schema-inferred `query`. */
|
|
2288
|
-
export type ChannelHandlerArgsWithQuery<TQuery> = ChannelHandlerArgs & {
|
|
2289
|
-
query: TQuery;
|
|
2290
|
-
};
|
|
2291
|
-
|
|
2292
|
-
/** Handler args with a required, schema-inferred `body`. */
|
|
2293
|
-
export type ChannelHandlerArgsWithBody<TBody> = ChannelHandlerArgs & {
|
|
2294
|
-
body: TBody;
|
|
2295
|
-
};
|
|
2296
|
-
|
|
2297
|
-
/** Handler args with inferred `body` and optional inferred `query`. */
|
|
2298
|
-
export type ChannelHandlerArgsWithBodyAndQuery<TBody, TQuery> = ChannelHandlerArgs & {
|
|
2299
|
-
body: TBody;
|
|
2300
|
-
query: TQuery;
|
|
2301
|
-
};
|
|
2302
|
-
|
|
2303
|
-
/**
|
|
2304
|
-
* GET routes must declare a Zod `querySchema` (use `z.object({})` when there
|
|
2305
|
-
* are no query params — path params still live on `args.params`).
|
|
2306
|
-
*/
|
|
2307
|
-
export interface ChannelGetRouteSpec<TQuery extends z.ZodTypeAny = z.ZodTypeAny> {
|
|
2308
|
-
description?: string;
|
|
2309
|
-
querySchema: TQuery;
|
|
2310
|
-
handler: (
|
|
2311
|
-
request: Request,
|
|
2312
|
-
args: ChannelHandlerArgsWithQuery<z.infer<TQuery>>,
|
|
2313
|
-
) => Response | Promise<Response>;
|
|
2314
|
-
}
|
|
2315
|
-
|
|
2316
|
-
/**
|
|
2317
|
-
* POST / PUT / PATCH routes must declare a Zod `bodySchema`. Optional
|
|
2318
|
-
* `querySchema` when the route also reads search params.
|
|
2319
|
-
*/
|
|
2320
|
-
export interface ChannelBodyRouteSpec<
|
|
2321
|
-
TBody extends z.ZodTypeAny = z.ZodTypeAny,
|
|
2322
|
-
TQuery extends z.ZodTypeAny | undefined = undefined,
|
|
2323
|
-
> {
|
|
2324
|
-
description?: string;
|
|
2325
|
-
bodySchema: TBody;
|
|
2326
|
-
querySchema?: TQuery;
|
|
2327
|
-
handler: (
|
|
2328
|
-
request: Request,
|
|
2329
|
-
args: TQuery extends z.ZodTypeAny
|
|
2330
|
-
? ChannelHandlerArgsWithBodyAndQuery<z.infer<TBody>, z.infer<TQuery>>
|
|
2331
|
-
: ChannelHandlerArgsWithBody<z.infer<TBody>>,
|
|
2332
|
-
) => Response | Promise<Response>;
|
|
2333
|
-
}
|
|
2334
|
-
|
|
2335
|
-
/**
|
|
2336
|
-
* DELETE routes may declare Zod schemas when useful; neither is required.
|
|
2337
|
-
*/
|
|
2338
|
-
export interface ChannelDeleteRouteSpec<
|
|
2339
|
-
TBody extends z.ZodTypeAny | undefined = undefined,
|
|
2340
|
-
TQuery extends z.ZodTypeAny | undefined = undefined,
|
|
2341
|
-
> {
|
|
2342
|
-
description?: string;
|
|
2343
|
-
bodySchema?: TBody;
|
|
2344
|
-
querySchema?: TQuery;
|
|
2345
|
-
handler: ChannelRouteHandler;
|
|
2346
|
-
}
|
|
2347
|
-
|
|
2348
|
-
export interface ChannelRoute {
|
|
2349
|
-
method: RouteMethod;
|
|
2350
|
-
path: string;
|
|
2351
|
-
handler: ChannelRouteHandler;
|
|
2352
|
-
description?: string;
|
|
2353
|
-
bodySchema?: ChannelRouteSchema;
|
|
2354
|
-
querySchema?: ChannelRouteSchema;
|
|
2355
|
-
}
|
|
2356
|
-
|
|
2357
|
-
/** Input to a channel's `receive` hook (and to `args.receive(...)`). */
|
|
2358
|
-
export interface ReceiveInput {
|
|
2359
|
-
message: string;
|
|
2360
|
-
auth: AuthContext | null;
|
|
2361
|
-
/** Channel-specific delivery target (e.g. a chat channel id). */
|
|
2362
|
-
target?: JsonObject;
|
|
2363
|
-
}
|
|
2364
|
-
|
|
2365
|
-
/**
|
|
2366
|
-
* Per-event channel context. `state` is mutable. Turn events receive the
|
|
2367
|
-
* state snapshot captured for that turn; handler mutations are recursively
|
|
2368
|
-
* merged into the latest persisted state so fields refreshed by overlapping
|
|
2369
|
-
* deliveries survive. At paths changed by the handler, objects merge
|
|
2370
|
-
* recursively, arrays and scalars replace the latest value, and deletion
|
|
2371
|
-
* removes the latest value. Events outside a turn receive current live state.
|
|
2372
|
-
*/
|
|
2373
|
-
export interface ChannelEventContext<TState = JsonValue> {
|
|
2374
|
-
channelId: string;
|
|
2375
|
-
state: TState;
|
|
2376
|
-
continuationToken: string | null;
|
|
2377
|
-
setContinuationToken(token: string | null): Promise<void>;
|
|
2378
|
-
}
|
|
2379
|
-
|
|
2380
|
-
/** Per-event session context shared by channel `events` handlers and hooks. */
|
|
2381
|
-
export interface SessionContext {
|
|
2382
|
-
session: SessionInfo;
|
|
2383
|
-
/**
|
|
2384
|
-
* Shared host services (MCP / GitHub / Slack / kv / files). Same as
|
|
2385
|
-
* tool `ctx.host`. `files` and `otel` are bound to this session, so a
|
|
2386
|
-
* relative path cannot read another session's files.
|
|
2387
|
-
*/
|
|
2388
|
-
host: HostContext;
|
|
2389
|
-
/**
|
|
2390
|
-
* Durable artifacts bound to this event's session and turn. `tag`
|
|
2391
|
-
* auto-fills both ids and rejects a conflicting explicit `sessionId`.
|
|
2392
|
-
*/
|
|
2393
|
-
artifacts: ArtifactsApi;
|
|
2394
|
-
}
|
|
2395
|
-
|
|
2396
|
-
export type ChannelEventHandler<TState = JsonValue, TEvent extends SessionEvent = SessionEvent> = (
|
|
2397
|
-
event: TEvent,
|
|
2398
|
-
channel: ChannelEventContext<TState>,
|
|
2399
|
-
ctx: SessionContext,
|
|
2400
|
-
) => void | Promise<void>;
|
|
2401
|
-
|
|
2402
|
-
/** Handlers are keyed by event type and receive the narrowed event. */
|
|
2403
|
-
export type ChannelEventHandlers<TState = JsonValue> = {
|
|
2404
|
-
[K in SessionEventType]?: ChannelEventHandler<TState, Extract<SessionEvent, { type: K }>>;
|
|
2405
|
-
} & {
|
|
2406
|
-
"*"?: ChannelEventHandler<TState, SessionEvent>;
|
|
2407
|
-
};
|
|
2408
|
-
|
|
2409
|
-
/** Bound helpers passed to {@link ChannelConfig.onStart}. */
|
|
2410
|
-
export interface ChannelStartArgs {
|
|
2411
|
-
send: SendMessageFn;
|
|
2412
|
-
/**
|
|
2413
|
-
* Hosted architecture from {@link AgentConfig.architecture}. Discovery
|
|
2414
|
-
* fills `"v2"` when the author omits it. Host pipelines that call
|
|
2415
|
-
* `send()` themselves (instead of letting the channel adapter stamp
|
|
2416
|
-
* continuation) branch on this so v1 `continuationToken` and v2 `claim`
|
|
2417
|
-
* stay mutually exclusive.
|
|
2418
|
-
*/
|
|
2419
|
-
architecture?: AgentArchitecture;
|
|
2420
|
-
getSession(sessionId: string): Promise<ChannelSession | null>;
|
|
2421
|
-
receive(
|
|
2422
|
-
channel: ChannelDefinition | HttpChannelDefinition | string,
|
|
2423
|
-
input: ReceiveInput,
|
|
2424
|
-
): Promise<ChannelSession>;
|
|
2425
|
-
/** Call an authored server tool directly (no model turn). */
|
|
2426
|
-
callTool: CallToolFn;
|
|
2427
|
-
/**
|
|
2428
|
-
* Append an assistant message to a session without a model turn and without
|
|
2429
|
-
* a user `message.received` bubble. Prefer this over `send()` when a host
|
|
2430
|
-
* task already produced the final text (e.g. after staged `callTool`s).
|
|
2431
|
-
*/
|
|
2432
|
-
emitAssistantMessage(sessionId: string, text: string): Promise<void>;
|
|
2433
|
-
/** Shared host services (MCP / GitHub / Slack). Same as {@link ChannelHandlerArgs.host}. */
|
|
2434
|
-
host: HostContext;
|
|
2435
|
-
waitUntil(promise: Promise<unknown>): void;
|
|
2436
|
-
/**
|
|
2437
|
-
* Whether a live session already exists for a continuation token on this
|
|
2438
|
-
* channel (includes lazy restore from storage).
|
|
2439
|
-
*/
|
|
2440
|
-
hasContinuationSession(continuationToken: string): Promise<boolean>;
|
|
2441
|
-
/**
|
|
2442
|
-
* Whether a model turn is in flight (or being admitted) for the session
|
|
2443
|
-
* addressed by this continuation token.
|
|
2444
|
-
*/
|
|
2445
|
-
isContinuationBusy(continuationToken: string): Promise<boolean>;
|
|
2446
|
-
/**
|
|
2447
|
-
* Slack warm-delta watermark: last agent reply ts recorded on the session's
|
|
2448
|
-
* channel state (`lastBotMessageTs`), when present.
|
|
2449
|
-
*/
|
|
2450
|
-
getContinuationLastBotMessageTs(continuationToken: string): Promise<string | undefined>;
|
|
2451
|
-
/**
|
|
2452
|
-
* Interrupt the in-flight turn for a continuation token and clear any
|
|
2453
|
-
* coalesced follow-ups queued behind it. Returns whether work was active.
|
|
2454
|
-
*/
|
|
2455
|
-
interruptContinuation(continuationToken: string): Promise<boolean>;
|
|
2456
|
-
/**
|
|
2457
|
-
* Approve or deny a parked {@link ToolConfig.needsApproval} tool call
|
|
2458
|
-
* for a session on this channel. Channel packs (e.g. Slack Block Kit
|
|
2459
|
-
* buttons) use this to unblock the turn without going through the HTTP
|
|
2460
|
-
* approvals route.
|
|
2461
|
-
*/
|
|
2462
|
-
resolveApproval(
|
|
2463
|
-
sessionId: string,
|
|
2464
|
-
callId: string,
|
|
2465
|
-
decision: ApprovalDecision,
|
|
2466
|
-
auth: AuthContext | null,
|
|
2467
|
-
options?: { asSessionOwner?: boolean },
|
|
2468
|
-
): Promise<PendingApproval>;
|
|
2469
|
-
/**
|
|
2470
|
-
* Mark a parked MCP auth as connected or cancelled. Channel packs
|
|
2471
|
-
* (Slack "Connected") use this; the public OAuth callback also
|
|
2472
|
-
* resolves after `finishAuth`.
|
|
2473
|
-
*/
|
|
2474
|
-
resolveAuth(
|
|
2475
|
-
sessionId: string,
|
|
2476
|
-
callId: string,
|
|
2477
|
-
decision: ApprovalDecision,
|
|
2478
|
-
auth: AuthContext | null,
|
|
2479
|
-
options?: { asSessionOwner?: boolean },
|
|
2480
|
-
): Promise<PendingAuth>;
|
|
2481
|
-
/**
|
|
2482
|
-
* Server log sink (same as {@link ServeOptions.logger}). Channel packs
|
|
2483
|
-
* should prefer this over `console.*` so CLI/eval hosts can redirect.
|
|
2484
|
-
*/
|
|
2485
|
-
logger: (line: string) => void;
|
|
2486
|
-
/**
|
|
2487
|
-
* Durable artifacts (unbound, same facade as
|
|
2488
|
-
* {@link ChannelHandlerArgs.artifacts}) — for host pipelines the channel
|
|
2489
|
-
* drives outside any route handler.
|
|
2490
|
-
*/
|
|
2491
|
-
artifacts: ArtifactsApi;
|
|
2492
|
-
}
|
|
2493
|
-
|
|
2494
|
-
/**
|
|
2495
|
-
* Metadata a channel pack attaches for discovery, `projectInfo`, and CLI
|
|
2496
|
-
* helpers (e.g. `agent-sdk github forward`). Most fields are descriptive;
|
|
2497
|
-
* explicitly documented protocol fields may also be consumed by the host.
|
|
2498
|
-
*/
|
|
2499
|
-
export interface ChannelMeta {
|
|
2500
|
-
/** Well-known pack kind, e.g. `"github"` or `"slack"`. */
|
|
2501
|
-
kind?: string;
|
|
2502
|
-
/**
|
|
2503
|
-
* For GitHub webhook packs: the webhook event names this channel is wired
|
|
2504
|
-
* to dispatch on. Used to derive `gh webhook forward --events`.
|
|
2505
|
-
*/
|
|
2506
|
-
githubWebhookEvents?: readonly string[];
|
|
2507
|
-
/**
|
|
2508
|
-
* For Origin webhook packs: the Origin event types this channel is wired
|
|
2509
|
-
* to dispatch on. Used by `--cursor-events` to subscribe `provider: "origin"`.
|
|
2510
|
-
*/
|
|
2511
|
-
originWebhookEvents?: readonly string[];
|
|
2512
|
-
/**
|
|
2513
|
-
* For GitLab webhook packs: the `object_kind`s this channel is wired to
|
|
2514
|
-
* dispatch on (`merge_request`, `note`, `push`, `pipeline`, `tag_push`).
|
|
2515
|
-
*/
|
|
2516
|
-
gitlabWebhookEvents?: readonly string[];
|
|
2517
|
-
/**
|
|
2518
|
-
* For Bitbucket webhook packs: the event keys this channel is wired to
|
|
2519
|
-
* dispatch on, in the Cloud vocabulary (`pullrequest:created`, …).
|
|
2520
|
-
*/
|
|
2521
|
-
bitbucketWebhookEvents?: readonly string[];
|
|
2522
|
-
/**
|
|
2523
|
-
* For deployments packs: the factory event types this channel is wired
|
|
2524
|
-
* to dispatch on. Extracted into the deploy manifest as `eventTypes`.
|
|
2525
|
-
*/
|
|
2526
|
-
deploymentEventTypes?: readonly string[];
|
|
2527
|
-
/**
|
|
2528
|
-
* For Change Monitor checkpoint and Factory issue packs: the factory
|
|
2529
|
-
* event types this channel is wired to dispatch on. Extracted into the
|
|
2530
|
-
* deploy manifest as `eventTypes`. Kept separate from
|
|
2531
|
-
* `deploymentEventTypes`.
|
|
2532
|
-
*/
|
|
2533
|
-
factoryEventTypes?: readonly string[];
|
|
2534
|
-
/**
|
|
2535
|
-
* For Slack packs: the Events API event types this channel dispatches on
|
|
2536
|
-
* (`app_mention`, `message`), derived from `engagement`. Extracted into
|
|
2537
|
-
* the deploy manifest as `eventTypes` so hosted v2 fanout subscribes to
|
|
2538
|
-
* exactly these. Local Socket Mode ignores it (the socket delivers
|
|
2539
|
-
* whatever the app manifest subscribed to).
|
|
2540
|
-
*/
|
|
2541
|
-
slackEventTypes?: readonly string[];
|
|
2542
|
-
/**
|
|
2543
|
-
* Static agentic-reply protocol for hosted Slack ingress. Only literals
|
|
2544
|
-
* belong here: the control plane persists this declaration at deploy time
|
|
2545
|
-
* and may act before author code starts.
|
|
2546
|
-
*/
|
|
2547
|
-
slackReply?: {
|
|
2548
|
-
mode: "agentic";
|
|
2549
|
-
ack: string;
|
|
2550
|
-
placeholder?: string;
|
|
2551
|
-
};
|
|
2552
|
-
/**
|
|
2553
|
-
* For Slack packs with the opt-in channel watch: the allowlisted channels
|
|
2554
|
-
* (ids or `#names`) this channel dispatches on without a mention. Surfaced
|
|
2555
|
-
* by `info` so watched channels are auditable.
|
|
2556
|
-
*/
|
|
2557
|
-
slackChannelPosts?: readonly string[];
|
|
2558
|
-
/**
|
|
2559
|
-
* Author-facing notices about deprecated options the pack still honored.
|
|
2560
|
-
* Discovery surfaces each one as a `validate` warning on the channel file.
|
|
2561
|
-
*/
|
|
2562
|
-
deprecations?: readonly string[];
|
|
2563
|
-
}
|
|
2564
|
-
|
|
2565
|
-
export interface ChannelConfig<TState = JsonValue> {
|
|
2566
|
-
/**
|
|
2567
|
-
* Route auth chain. Defaults to `[localDevStrict()]`. Include
|
|
2568
|
-
* `publicEndpoint()` to serve this channel WITHOUT the platform alias
|
|
2569
|
-
* token on Cursor hosting (for webhook senders that cannot attach custom
|
|
2570
|
-
* headers — the handler must verify deliveries itself).
|
|
2571
|
-
*/
|
|
2572
|
-
auth?: AuthPolicy[];
|
|
2573
|
-
routes?: ChannelRoute[];
|
|
2574
|
-
/**
|
|
2575
|
-
* Descriptive metadata for tooling (kind, webhook events). Attached by
|
|
2576
|
-
* channel packs; ignored by the router and session engine.
|
|
2577
|
-
*/
|
|
2578
|
-
meta?: ChannelMeta;
|
|
2579
|
-
/** Initial per-session channel state (JSON-serializable). */
|
|
2580
|
-
state?: TState;
|
|
2581
|
-
/**
|
|
2582
|
-
* Owns inbound cross-channel hand-offs. When omitted, `receive` starts a
|
|
2583
|
-
* fresh session with the input message.
|
|
2584
|
-
*/
|
|
2585
|
-
receive?: (
|
|
2586
|
-
input: ReceiveInput,
|
|
2587
|
-
args: { send: SendMessageFn; artifacts: ArtifactsApi },
|
|
2588
|
-
// biome-ignore lint/suspicious/noConfusingVoidType: hooks may return a session, nothing, or an async nothing
|
|
2589
|
-
) => Promise<ChannelSession | undefined | void> | ChannelSession | void;
|
|
2590
|
-
/** Stream-event handlers for sessions owned by this channel. */
|
|
2591
|
-
events?: ChannelEventHandlers<TState>;
|
|
2592
|
-
/** Called once when the server mounts this channel. Optional stop via onStop. */
|
|
2593
|
-
onStart?: (args: ChannelStartArgs) => void | Promise<void>;
|
|
2594
|
-
/** Called when the server shuts down. */
|
|
2595
|
-
onStop?: () => void | Promise<void>;
|
|
2596
|
-
}
|
|
2597
|
-
|
|
2598
|
-
export type ChannelDefinition<TState = JsonValue> = ChannelConfig<TState> &
|
|
2599
|
-
BrandedDefinition<"channel">;
|
|
2600
|
-
|
|
2601
|
-
/** Configuration for the built-in HTTP session channel. */
|
|
2602
|
-
export interface HttpChannelConfig {
|
|
2603
|
-
/** Route auth chain. Defaults to `[localDevStrict()]`. */
|
|
2604
|
-
auth?: AuthPolicy[];
|
|
2605
|
-
/**
|
|
2606
|
-
* Continuation selector. Omit this to inherit the agent architecture's
|
|
2607
|
-
* default. Set it explicitly only when migrating persisted identities.
|
|
2608
|
-
*/
|
|
2609
|
-
continuation?: ContinuationIdentity;
|
|
2610
|
-
/**
|
|
2611
|
-
* Transform the inbound message before the agent sees it (e.g. prepend
|
|
2612
|
-
* request-specific context).
|
|
2613
|
-
*/
|
|
2614
|
-
onMessage?: (message: string, info: { auth: AuthContext | null }) => string | Promise<string>;
|
|
2615
|
-
/**
|
|
2616
|
-
* Bind host state after the control plane names this session's mailbox
|
|
2617
|
-
* key and before `send()`.
|
|
2618
|
-
*/
|
|
2619
|
-
onAdmit?: (info: HttpSessionAdmitInfo) => void | Promise<void>;
|
|
2620
|
-
/** Stream-event handlers for sessions created over HTTP. */
|
|
2621
|
-
events?: ChannelEventHandlers;
|
|
2622
|
-
}
|
|
2623
|
-
|
|
2624
|
-
/** Subject of a hosted HTTP startSession, seen by {@link HttpChannelConfig.onAdmit}. */
|
|
2625
|
-
export type HttpSessionAdmitInfo = {
|
|
2626
|
-
message: string;
|
|
2627
|
-
sessionKey: string;
|
|
2628
|
-
dryRun?: boolean;
|
|
2629
|
-
asOf?: string;
|
|
2630
|
-
host: HostContext;
|
|
2631
|
-
};
|
|
2632
|
-
|
|
2633
|
-
/** Reject a hosted startSession subject from {@link HttpChannelConfig.onAdmit}. */
|
|
2634
|
-
export class HttpSessionAdmitError extends Error {
|
|
2635
|
-
readonly status = 400 as const;
|
|
2636
|
-
constructor(message: string) {
|
|
2637
|
-
super(message);
|
|
2638
|
-
this.name = "HttpSessionAdmitError";
|
|
2639
|
-
}
|
|
2640
|
-
}
|
|
2641
|
-
|
|
2642
|
-
export type HttpChannelDefinition = HttpChannelConfig & BrandedDefinition<"http-channel">;
|
|
2643
|
-
|
|
2644
|
-
// ============================================================================
|
|
2645
|
-
// Hooks (agent/hooks/*.ts)
|
|
2646
|
-
// ============================================================================
|
|
2647
|
-
|
|
2648
|
-
export interface HookContext extends SessionContext {
|
|
2649
|
-
agent: { name: string };
|
|
2650
|
-
channel: { id: string; continuationToken: string | null };
|
|
2651
|
-
/**
|
|
2652
|
-
* Durable channel state for this session (the turn snapshot when
|
|
2653
|
-
* dispatching inside a turn). Same blob `send({ state })` stamped;
|
|
2654
|
-
* survives process restart. Null when the session has none.
|
|
2655
|
-
*/
|
|
2656
|
-
channelState: JsonValue | null;
|
|
2657
|
-
/**
|
|
2658
|
-
* Absolute path of the agent's durable state root (shared across every
|
|
2659
|
-
* session of this agent). Hooks that maintain derived state (e.g. the
|
|
2660
|
-
* memory journal) write here.
|
|
2661
|
-
*/
|
|
2662
|
-
stateRoot: string;
|
|
2663
|
-
/**
|
|
2664
|
-
* Durable artifacts, bound to this hook's session: `tag` auto-fills
|
|
2665
|
-
* `sessionId` (and `turnId` when known).
|
|
2666
|
-
*/
|
|
2667
|
-
artifacts: ArtifactsApi;
|
|
2668
|
-
}
|
|
2669
|
-
|
|
2670
|
-
export type HookHandler<TEvent extends SessionEvent = SessionEvent> = (
|
|
2671
|
-
event: TEvent,
|
|
2672
|
-
ctx: HookContext,
|
|
2673
|
-
) => void | Promise<void>;
|
|
2674
|
-
|
|
2675
|
-
/** Handlers are keyed by event type and receive the narrowed event. */
|
|
2676
|
-
export type HookEventHandlers = {
|
|
2677
|
-
[K in SessionEventType]?: HookHandler<Extract<SessionEvent, { type: K }>>;
|
|
2678
|
-
} & {
|
|
2679
|
-
"*"?: HookHandler;
|
|
2680
|
-
};
|
|
2681
|
-
|
|
2682
|
-
export interface HookConfig {
|
|
2683
|
-
events: HookEventHandlers;
|
|
2684
|
-
}
|
|
2685
|
-
|
|
2686
|
-
export type HookDefinition = HookConfig & BrandedDefinition<"hook">;
|
|
2687
|
-
|
|
2688
|
-
// ============================================================================
|
|
2689
|
-
// Artifacts (agent/artifacts.ts)
|
|
2690
|
-
// ============================================================================
|
|
2691
|
-
|
|
2692
|
-
/** One declared artifact kind (see {@link ArtifactsConfig.kinds}). */
|
|
2693
|
-
export interface ArtifactKindConfig {
|
|
2694
|
-
/**
|
|
2695
|
-
* What this kind holds. Also the model-facing prompt for the
|
|
2696
|
-
* `tag_artifact` built-in tool when {@link ArtifactsConfig.agentTool}
|
|
2697
|
-
* is enabled.
|
|
2698
|
-
*/
|
|
2699
|
-
description: string;
|
|
2700
|
-
/**
|
|
2701
|
-
* Optional Zod schema; `tag` validates the payload against it and
|
|
2702
|
-
* persists the parsed output (defaults and coercions applied), so
|
|
2703
|
-
* the schema's output must stay JSON-serializable.
|
|
2704
|
-
*/
|
|
2705
|
-
schema?: z.ZodType;
|
|
2706
|
-
}
|
|
2707
|
-
|
|
2708
|
-
/** Input to `defineArtifacts` (authored at `agent/artifacts.ts`). */
|
|
2709
|
-
export interface ArtifactsConfig {
|
|
2710
|
-
/**
|
|
2711
|
-
* Declared artifact kinds. With kinds declared, `tag` only accepts
|
|
2712
|
-
* these; with none, any kind string is accepted freeform.
|
|
2713
|
-
*/
|
|
2714
|
-
kinds?: Record<string, ArtifactKindConfig>;
|
|
2715
|
-
/**
|
|
2716
|
-
* Expose the model-facing `tag_artifact` built-in tool generated from
|
|
2717
|
-
* {@link kinds}. Requires at least one declared kind.
|
|
2718
|
-
*/
|
|
2719
|
-
agentTool?: boolean;
|
|
2720
|
-
/**
|
|
2721
|
-
* Retention cap (default 1000). Architecture v1 and self-hosted v2
|
|
2722
|
-
* evict the oldest-updated artifact on insert past the cap. Hosted
|
|
2723
|
-
* architecture v2 does not evict; the installation store keeps every row.
|
|
2724
|
-
*/
|
|
2725
|
-
max?: number;
|
|
2726
|
-
}
|
|
2727
|
-
|
|
2728
|
-
export type ArtifactsDefinition = ArtifactsConfig & BrandedDefinition<"artifacts">;
|
|
2729
|
-
|
|
2730
|
-
/** Who tagged an artifact: host code, or the model via `tag_artifact`. */
|
|
2731
|
-
export type ArtifactSource = "host" | "model";
|
|
2732
|
-
|
|
2733
|
-
/** One durable tagged artifact. */
|
|
2734
|
-
export interface ArtifactRecord {
|
|
2735
|
-
/** Stable id: derived from {@link key} when present, else random. */
|
|
2736
|
-
id: string;
|
|
2737
|
-
kind: string;
|
|
2738
|
-
/** Author-chosen upsert key (same key ⇒ same id ⇒ replaces the row). */
|
|
2739
|
-
key?: string;
|
|
2740
|
-
title?: string;
|
|
2741
|
-
data: JsonValue;
|
|
2742
|
-
/** Present when the artifact carries a file/blob payload (served at `GET /v1/artifacts/:id/content`). */
|
|
2743
|
-
content?: { size: number; contentType?: string };
|
|
2744
|
-
sessionId?: string;
|
|
2745
|
-
turnId?: string;
|
|
2746
|
-
source: ArtifactSource;
|
|
2747
|
-
createdAt: string;
|
|
2748
|
-
updatedAt: string;
|
|
2749
|
-
}
|
|
2750
|
-
|
|
2751
|
-
/** Input to {@link ArtifactsApi.tag}. */
|
|
2752
|
-
export interface ArtifactTagInput {
|
|
2753
|
-
/** Defaults to `"artifact"` when no kinds are declared. */
|
|
2754
|
-
kind?: string;
|
|
2755
|
-
data: JsonValue;
|
|
2756
|
-
title?: string;
|
|
2757
|
-
/** Upsert key: tagging the same key again replaces the row. */
|
|
2758
|
-
key?: string;
|
|
2759
|
-
/**
|
|
2760
|
-
* File/blob payload, served via `GET /v1/artifacts/:id/content`.
|
|
2761
|
-
* Re-tagging a keyed artifact without `contents` keeps the existing payload.
|
|
2762
|
-
*/
|
|
2763
|
-
contents?: string | Uint8Array;
|
|
2764
|
-
/** MIME type reported when serving {@link contents}. */
|
|
2765
|
-
contentType?: string;
|
|
2766
|
-
/**
|
|
2767
|
-
* Session to attribute (and stream an `artifact.tagged` event to). On
|
|
2768
|
-
* session-bound facades ({@link ToolContext.artifacts},
|
|
2769
|
-
* {@link HookContext.artifacts}) this is auto-filled and a different
|
|
2770
|
-
* value is rejected; unbound facades
|
|
2771
|
-
* ({@link ChannelHandlerArgs.artifacts}) accept it explicitly.
|
|
2772
|
-
*/
|
|
2773
|
-
sessionId?: string;
|
|
2774
|
-
turnId?: string;
|
|
2775
|
-
/** Defaults to `"host"`. */
|
|
2776
|
-
source?: ArtifactSource;
|
|
2777
|
-
}
|
|
2778
|
-
|
|
2779
|
-
/** Filter for {@link ArtifactsApi.list} and {@link ArtifactsApi.page}. */
|
|
2780
|
-
export interface ArtifactListFilter {
|
|
2781
|
-
kind?: string;
|
|
2782
|
-
sessionId?: string;
|
|
2783
|
-
}
|
|
2784
|
-
|
|
2785
|
-
/** Options for {@link ArtifactsApi.page}. */
|
|
2786
|
-
export interface ArtifactPageOptions extends ArtifactListFilter {
|
|
2787
|
-
/** Page size, clamped to 1–1000. Default 200. */
|
|
2788
|
-
limit?: number;
|
|
2789
|
-
/**
|
|
2790
|
-
* Opaque resume position from the previous page's
|
|
2791
|
-
* {@link ArtifactPage.nextCursor}. Pass the same filter on every page of
|
|
2792
|
-
* one walk; the cursor marks a position, not a query.
|
|
2793
|
-
*/
|
|
2794
|
-
cursor?: string;
|
|
2795
|
-
}
|
|
2796
|
-
|
|
2797
|
-
/** One page of {@link ArtifactsApi.page} results, newest-updated first. */
|
|
2798
|
-
export interface ArtifactPage {
|
|
2799
|
-
records: ArtifactRecord[];
|
|
2800
|
-
/**
|
|
2801
|
-
* Present while rows remain to examine; pass back as
|
|
2802
|
-
* {@link ArtifactPageOptions.cursor}. Each call reads a bounded number of
|
|
2803
|
-
* rows, so with a sparse filter a page can carry fewer records than
|
|
2804
|
-
* `limit` — even none — while `nextCursor` says the walk is not done.
|
|
2805
|
-
*/
|
|
2806
|
-
nextCursor?: string;
|
|
2807
|
-
}
|
|
2808
|
-
|
|
2809
|
-
/**
|
|
2810
|
-
* The artifacts API, attached as `ctx.artifacts` on tools
|
|
2811
|
-
* ({@link ToolContext}), hooks ({@link HookContext}), and channel handlers
|
|
2812
|
-
* ({@link ChannelHandlerArgs}). Tool and hook facades are session-bound:
|
|
2813
|
-
* `tag` auto-fills the session; the channel facade is unbound.
|
|
2814
|
-
*/
|
|
2815
|
-
export interface ArtifactsApi {
|
|
2816
|
-
/** Tag (upsert) one artifact. See {@link ArtifactTagInput}. */
|
|
2817
|
-
tag(input: ArtifactTagInput): Promise<ArtifactRecord>;
|
|
2818
|
-
/**
|
|
2819
|
-
* Tagged artifacts, newest-updated first — the newest page only (at most
|
|
2820
|
-
* 200 records). Walk the full set with {@link ArtifactsApi.page}.
|
|
2821
|
-
*/
|
|
2822
|
-
list(filter?: ArtifactListFilter): Promise<ArtifactRecord[]>;
|
|
2823
|
-
/** Bounded, cursor-paginated artifacts, newest-updated first. */
|
|
2824
|
-
page(options?: ArtifactPageOptions): Promise<ArtifactPage>;
|
|
2825
|
-
}
|
|
2826
|
-
|
|
2827
|
-
// ============================================================================
|
|
2828
|
-
// Schedules (agent/schedules/*)
|
|
2829
|
-
// ============================================================================
|
|
2830
|
-
|
|
2831
|
-
export interface ScheduleHandlerArgs {
|
|
2832
|
-
/** Hand the scheduled work to a channel. */
|
|
2833
|
-
receive: (
|
|
2834
|
-
channel: ChannelDefinition | HttpChannelDefinition | string,
|
|
2835
|
-
input: ReceiveInput,
|
|
2836
|
-
) => Promise<ChannelSession>;
|
|
2837
|
-
/** Call an authored server tool directly (no model turn). */
|
|
2838
|
-
callTool: CallToolFn;
|
|
2839
|
-
/** Keep the dispatch alive past handler return. */
|
|
2840
|
-
waitUntil(promise: Promise<unknown>): void;
|
|
2841
|
-
/** Pre-built app principal for work the agent does on its own behalf. */
|
|
2842
|
-
appAuth: AuthContext;
|
|
2843
|
-
/** Shared host services (MCP / GitHub / Slack). Same as tool `ctx.host`. */
|
|
2844
|
-
host: HostContext;
|
|
2845
|
-
/**
|
|
2846
|
-
* Durable artifacts (unbound — schedule handlers have no ambient session;
|
|
2847
|
-
* pass `sessionId` explicitly to attribute).
|
|
2848
|
-
*/
|
|
2849
|
-
artifacts: ArtifactsApi;
|
|
2850
|
-
}
|
|
2851
|
-
|
|
2852
|
-
export interface ScheduleConfig {
|
|
2853
|
-
/** Standard 5-field cron expression, evaluated in UTC. */
|
|
2854
|
-
cron: string;
|
|
2855
|
-
/** Fire-and-forget prompt (task mode). Mutually exclusive with `run`. */
|
|
2856
|
-
markdown?: string;
|
|
2857
|
-
/** Handler form: full control over dispatch. */
|
|
2858
|
-
run?: (args: ScheduleHandlerArgs) => void | Promise<void>;
|
|
2859
|
-
}
|
|
2860
|
-
|
|
2861
|
-
export type ScheduleDefinition = ScheduleConfig & BrandedDefinition<"schedule">;
|
|
2862
|
-
|
|
2863
|
-
// ============================================================================
|
|
2864
|
-
// Reminder handlers (agent/reminders/*) — named durable fire policies
|
|
2865
|
-
// ============================================================================
|
|
2866
|
-
|
|
2867
|
-
/**
|
|
2868
|
-
* Authored at `agent/reminders/<name>.ts`. The registry name is the module
|
|
2869
|
-
* stem. Pass the discovered definition to {@link ReminderCreateInput.handler}
|
|
2870
|
-
* with serializable {@link ReminderCreateInput.args}; the engine persists the
|
|
2871
|
-
* stem, not the function.
|
|
2872
|
-
*/
|
|
2873
|
-
export interface ReminderHandlerConfig {
|
|
2874
|
-
/**
|
|
2875
|
-
* Invoked on every fire with {@link ReminderFireContext} (including the
|
|
2876
|
-
* create-time {@link ReminderFireContext.args} blob).
|
|
2877
|
-
*/
|
|
2878
|
-
run: (ctx: ReminderFireContext) => Promise<ReminderFireResult>;
|
|
2879
|
-
}
|
|
2880
|
-
|
|
2881
|
-
export type ReminderDefinition = ReminderHandlerConfig & BrandedDefinition<"reminder">;
|
|
2882
|
-
|
|
2883
|
-
export interface DiscoveredReminder {
|
|
2884
|
-
name: string;
|
|
2885
|
-
definition: ReminderDefinition;
|
|
2886
|
-
}
|
|
2887
|
-
|
|
2888
|
-
// ============================================================================
|
|
2889
|
-
// Reminders (runtime per-session wakes)
|
|
2890
|
-
// ============================================================================
|
|
2891
|
-
|
|
2892
|
-
export type ReminderBusyPolicy = "skipIfBusy" | "queueBehindTurn";
|
|
2893
|
-
|
|
2894
|
-
/** Public reminder status. Internal claim state (`firing`) is not exposed. */
|
|
2895
|
-
export type ReminderStatus = "armed" | "completed" | "cancelled" | "disarmed";
|
|
2896
|
-
|
|
2897
|
-
export type ReminderScheduleKind = "every" | "cron" | "delay" | "at";
|
|
2898
|
-
|
|
2899
|
-
export type ReminderFireResult =
|
|
2900
|
-
| { action: "skip"; reschedule?: ReminderReschedule }
|
|
2901
|
-
| { action: "delivered"; reschedule?: ReminderReschedule }
|
|
2902
|
-
| { action: "stop" };
|
|
2903
|
-
|
|
2904
|
-
export interface ReminderReschedule {
|
|
2905
|
-
delay?: string | number;
|
|
2906
|
-
at?: Date | string;
|
|
2907
|
-
}
|
|
2908
|
-
|
|
2909
|
-
export interface ReminderTarget {
|
|
2910
|
-
channelId: string;
|
|
2911
|
-
continuationToken: string;
|
|
2912
|
-
[key: string]: unknown;
|
|
2913
|
-
}
|
|
2914
|
-
|
|
2915
|
-
export interface ReminderUntilContext {
|
|
2916
|
-
id: string;
|
|
2917
|
-
purpose: string;
|
|
2918
|
-
fireCount: number;
|
|
2919
|
-
target: ReminderTarget;
|
|
2920
|
-
host: HostContext;
|
|
2921
|
-
mcp: HostMcpRegistry;
|
|
2922
|
-
}
|
|
2923
|
-
|
|
2924
|
-
/**
|
|
2925
|
-
* Send fields a reminder followup may carry onto the turn it starts, the
|
|
2926
|
-
* subset of {@link SendMessageOptions} a host pipeline needs when the fire
|
|
2927
|
-
* itself prepares the turn (channel state for a later host hook,
|
|
2928
|
-
* a session title, a cloud-attach reset). Continuation addressing stays the
|
|
2929
|
-
* reminder's stored binding and is not overridable here.
|
|
2930
|
-
*/
|
|
2931
|
-
export interface ReminderFollowupOptions {
|
|
2932
|
-
/** Initial channel state when the followup creates the session. */
|
|
2933
|
-
state?: JsonValue;
|
|
2934
|
-
/** Shallow-merged into an existing session's channel state (see {@link SendMessageOptions.refreshState}). */
|
|
2935
|
-
refreshState?: JsonValue;
|
|
2936
|
-
/** Session display title (applied when creating a new session). */
|
|
2937
|
-
title?: string;
|
|
2938
|
-
/** See {@link SendMessageOptions.clearCloudOverride}. */
|
|
2939
|
-
clearCloudOverride?: boolean;
|
|
2940
|
-
/**
|
|
2941
|
-
* Open a new session under this principal when the stored continuation
|
|
2942
|
-
* has none anywhere (pod or durable storage) — the session an inbound
|
|
2943
|
-
* delivery on that key would create, so later deliveries under the same
|
|
2944
|
-
* principal keep joining it. A durable session that exists but cannot be
|
|
2945
|
-
* materialized still throws, matching prompt fires: opening over it would
|
|
2946
|
-
* shadow the record. Omitted, a missing session also keeps the existing
|
|
2947
|
-
* behavior: the followup throws.
|
|
2948
|
-
*/
|
|
2949
|
-
openAuth?: AuthContext;
|
|
2950
|
-
}
|
|
2951
|
-
|
|
2952
|
-
export interface ReminderFireContext extends ReminderUntilContext {
|
|
2953
|
-
appAuth: AuthContext;
|
|
2954
|
-
/**
|
|
2955
|
-
* Serializable args from {@link ReminderCreateInput.args} when the fire
|
|
2956
|
-
* uses a named {@link ReminderCreateInput.handler}. Empty object otherwise.
|
|
2957
|
-
*/
|
|
2958
|
-
args: JsonObject;
|
|
2959
|
-
/**
|
|
2960
|
-
* Wake the reminder's already-bound session (target is implicit). On a
|
|
2961
|
-
* hosted architecture v2 deployment this resolves after the woken turn
|
|
2962
|
-
* completes, because the pod may stop once the fire's outcome is applied;
|
|
2963
|
-
* locally and on v1 it resolves as soon as the turn is admitted.
|
|
2964
|
-
*/
|
|
2965
|
-
followup(args: { message: string } & ReminderFollowupOptions): Promise<ChannelSession>;
|
|
2966
|
-
cancel(reason?: string): Promise<void>;
|
|
2967
|
-
/**
|
|
2968
|
-
* Durable artifacts (unbound — the reminder is bound to a continuation
|
|
2969
|
-
* token, not a resolved session; pass `sessionId` in `tag` input to
|
|
2970
|
-
* attribute one).
|
|
2971
|
-
*/
|
|
2972
|
-
artifacts: ArtifactsApi;
|
|
2973
|
-
}
|
|
2974
|
-
|
|
2975
|
-
/**
|
|
2976
|
-
* Create a durable wake bound to a channel continuation.
|
|
2977
|
-
*
|
|
2978
|
-
* Exactly one of `prompt` | `handler` | `run`, and exactly one of
|
|
2979
|
-
* `every` | `cron` | `delay` | `at`. Prompt fires always follow up into the
|
|
2980
|
-
* bound session. Named `handler` resolves `agent/reminders/<name>.ts` on
|
|
2981
|
-
* every fire (survives restart). Anonymous `run` stays supported on local
|
|
2982
|
-
* and hosted v1; hosted architecture v2 rejects it at create.
|
|
2983
|
-
*
|
|
2984
|
-
* @example Recurring (host policy)
|
|
2985
|
-
* ```ts
|
|
2986
|
-
* await host.reminders.create({
|
|
2987
|
-
* purpose: "merge_conflict_watch",
|
|
2988
|
-
* channelId: "drive",
|
|
2989
|
-
* continuationToken,
|
|
2990
|
-
* every: "30m",
|
|
2991
|
-
* async run({ followup, host }) {
|
|
2992
|
-
* if (await isPrClosed(host)) return { action: "stop" };
|
|
2993
|
-
* if (!(await isConflicted(host))) return { action: "skip" };
|
|
2994
|
-
* await followup({ message: "Merge conflict detected." });
|
|
2995
|
-
* return { action: "delivered" };
|
|
2996
|
-
* },
|
|
2997
|
-
* });
|
|
2998
|
-
* ```
|
|
2999
|
-
*
|
|
3000
|
-
* @example Named handler (durable across restart / hosted v2)
|
|
3001
|
-
* ```ts
|
|
3002
|
-
* // agent/reminders/verdict_recheck.ts
|
|
3003
|
-
* export default defineReminder({
|
|
3004
|
-
* async run({ args, followup }) {
|
|
3005
|
-
* // ...
|
|
3006
|
-
* return { action: "delivered" };
|
|
3007
|
-
* },
|
|
3008
|
-
* });
|
|
3009
|
-
*
|
|
3010
|
-
* import verdictRecheck from "./reminders/verdict_recheck.js";
|
|
3011
|
-
*
|
|
3012
|
-
* await host.reminders.create({
|
|
3013
|
-
* purpose: "verdict_recheck",
|
|
3014
|
-
* channelId: "origin",
|
|
3015
|
-
* continuationToken,
|
|
3016
|
-
* delay: "15m",
|
|
3017
|
-
* handler: verdictRecheck,
|
|
3018
|
-
* args: { headSha: "abc" },
|
|
3019
|
-
* });
|
|
3020
|
-
* ```
|
|
3021
|
-
*
|
|
3022
|
-
* @example One-shot (agent tool / prompt form)
|
|
3023
|
-
* ```ts
|
|
3024
|
-
* await host.reminders.create({
|
|
3025
|
-
* purpose: "ci_recheck",
|
|
3026
|
-
* channelId: "drive",
|
|
3027
|
-
* continuationToken,
|
|
3028
|
-
* delay: "2h",
|
|
3029
|
-
* prompt: "Re-check CI. Only act if still failing.",
|
|
3030
|
-
* until: "Cancel once CI is green or the PR is merged.",
|
|
3031
|
-
* });
|
|
3032
|
-
* ```
|
|
3033
|
-
*/
|
|
3034
|
-
export interface ReminderCreateInput {
|
|
3035
|
-
purpose: string;
|
|
3036
|
-
/** Channel that owns the session (e.g. `drive`). */
|
|
3037
|
-
channelId: string;
|
|
3038
|
-
/** Channel-local continuation key for the bound session. */
|
|
3039
|
-
continuationToken: string;
|
|
3040
|
-
/** Optional opaque metadata (e.g. `{ prUrl }`). */
|
|
3041
|
-
target?: Record<string, unknown>;
|
|
3042
|
-
/** Exactly one of prompt, handler, or run. */
|
|
3043
|
-
prompt?: string;
|
|
3044
|
-
/**
|
|
3045
|
-
* A definition discovered from `agent/reminders/<name>.ts`, or its stem
|
|
3046
|
-
* for compatibility. Mutually exclusive with `prompt` and `run`. The
|
|
3047
|
-
* definition form avoids coupling callers to a filename string; discovery
|
|
3048
|
-
* resolves it to the stable stem persisted by the control plane. Do not
|
|
3049
|
-
* combine with {@link until}; encode stop conditions in {@link args} and
|
|
3050
|
-
* the handler body.
|
|
3051
|
-
*/
|
|
3052
|
-
handler?: ReminderDefinition | string;
|
|
3053
|
-
/**
|
|
3054
|
-
* Serializable args for {@link handler} (UTF-8 JSON capped at 32 KiB).
|
|
3055
|
-
* Only valid with `handler`.
|
|
3056
|
-
*/
|
|
3057
|
-
args?: JsonObject;
|
|
3058
|
-
run?: (ctx: ReminderFireContext) => Promise<ReminderFireResult>;
|
|
3059
|
-
/** Exactly one schedule shape. */
|
|
3060
|
-
every?: string;
|
|
3061
|
-
cron?: string;
|
|
3062
|
-
delay?: string | number;
|
|
3063
|
-
at?: Date | string | number;
|
|
3064
|
-
/**
|
|
3065
|
-
* Auto-cancel: function (host evaluates, true → cancel) XOR prompt string
|
|
3066
|
-
* (agent-facing stop condition; platform does not interpret it).
|
|
3067
|
-
* Valid with `prompt` (string until) and legacy `run` (function until on
|
|
3068
|
-
* local / hosted v1). Not valid with named `handler`. Function until is
|
|
3069
|
-
* rejected on hosted architecture v2.
|
|
3070
|
-
*/
|
|
3071
|
-
until?: string | ((ctx: ReminderUntilContext) => Promise<boolean>);
|
|
3072
|
-
/**
|
|
3073
|
-
* Defaults: recurring → `skipIfBusy`; one-shot → `queueBehindTurn`.
|
|
3074
|
-
*/
|
|
3075
|
-
busyPolicy?: ReminderBusyPolicy;
|
|
3076
|
-
}
|
|
3077
|
-
|
|
3078
|
-
export interface ReminderInfo {
|
|
3079
|
-
id: string;
|
|
3080
|
-
purpose: string;
|
|
3081
|
-
channelId: string;
|
|
3082
|
-
continuationToken: string;
|
|
3083
|
-
target?: Record<string, unknown>;
|
|
3084
|
-
scheduleKind: ReminderScheduleKind;
|
|
3085
|
-
scheduleValue: string;
|
|
3086
|
-
prompt?: string;
|
|
3087
|
-
/** Named handler stem when create used `handler`. */
|
|
3088
|
-
handler?: string;
|
|
3089
|
-
/** Serializable args when create used `handler`. */
|
|
3090
|
-
args?: JsonObject;
|
|
3091
|
-
untilPrompt?: string;
|
|
3092
|
-
busyPolicy: ReminderBusyPolicy;
|
|
3093
|
-
status: ReminderStatus;
|
|
3094
|
-
disarmReason?: string;
|
|
3095
|
-
fireCount: number;
|
|
3096
|
-
nextFireAt: string;
|
|
3097
|
-
createdAt: string;
|
|
3098
|
-
updatedAt: string;
|
|
3099
|
-
hasRunHandler: boolean;
|
|
3100
|
-
hasUntilFn: boolean;
|
|
3101
|
-
}
|
|
3102
|
-
|
|
3103
|
-
/** Host-facing reminder API attached to {@link HostContext.reminders}. */
|
|
3104
|
-
export interface ReminderHostApi {
|
|
3105
|
-
/** Arm a reminder. See {@link ReminderCreateInput}. */
|
|
3106
|
-
create(input: ReminderCreateInput): Promise<ReminderInfo>;
|
|
3107
|
-
/** List reminders, optionally filtered. */
|
|
3108
|
-
list(filter?: {
|
|
3109
|
-
status?: ReminderStatus;
|
|
3110
|
-
purpose?: string;
|
|
3111
|
-
continuationToken?: string;
|
|
3112
|
-
}): Promise<ReminderInfo[]>;
|
|
3113
|
-
/** Cancel one reminder by id. No-op (returns undefined) if unknown. */
|
|
3114
|
-
cancel(id: string, reason?: string): Promise<ReminderInfo | undefined>;
|
|
3115
|
-
/** Cancel all armed reminders for a continuation token. Returns count. */
|
|
3116
|
-
cancelForContinuation(continuationToken: string, reason: string): Promise<number>;
|
|
3117
|
-
/**
|
|
3118
|
-
* Re-key armed reminders after a channel rotates a session's continuation
|
|
3119
|
-
* token, so earlier reminders keep waking the conversation. The engine
|
|
3120
|
-
* calls this from `setContinuationToken`; channels rarely need to.
|
|
3121
|
-
*/
|
|
3122
|
-
rekeyContinuation(channelId: string, oldToken: string, newToken: string): Promise<number>;
|
|
3123
|
-
/**
|
|
3124
|
-
* Fire immediately (dev / hillclimb).
|
|
3125
|
-
* `outcome` is `"noop"` when already firing or not armed.
|
|
3126
|
-
*/
|
|
3127
|
-
dispatch(id: string): Promise<{
|
|
3128
|
-
reminderId: string;
|
|
3129
|
-
outcome: "fired" | "noop";
|
|
3130
|
-
reason?: string;
|
|
3131
|
-
}>;
|
|
3132
|
-
}
|
|
3133
|
-
|
|
3134
|
-
// ============================================================================
|
|
3135
|
-
// Discovery / manifest
|
|
3136
|
-
// ============================================================================
|
|
3137
|
-
|
|
3138
|
-
export interface Diagnostic {
|
|
3139
|
-
severity: "error" | "warning";
|
|
3140
|
-
/** Repo-relative or absolute path of the offending file. */
|
|
3141
|
-
path?: string;
|
|
3142
|
-
message: string;
|
|
3143
|
-
}
|
|
3144
|
-
|
|
3145
|
-
export interface DiscoveredTool {
|
|
3146
|
-
name: string;
|
|
3147
|
-
description: string;
|
|
3148
|
-
/** JSON Schema advertised to the model. */
|
|
3149
|
-
inputSchema: JsonSchemaObject;
|
|
3150
|
-
/** Output JSON Schema, advertised only when the tool declares one. */
|
|
3151
|
-
outputSchema?: JsonSchemaObject;
|
|
3152
|
-
/** Where the tool body runs. Defaults to `"server"`. */
|
|
3153
|
-
execution: ToolExecution;
|
|
3154
|
-
/**
|
|
3155
|
-
* True when the tool may park for human approval (boolean true or a
|
|
3156
|
-
* predicate). Runtime evaluation still runs the predicate per call.
|
|
3157
|
-
*/
|
|
3158
|
-
needsApproval: boolean;
|
|
3159
|
-
/**
|
|
3160
|
-
* The tool's declared {@link ToolEffect} when it declares one statically, or
|
|
3161
|
-
* `"dynamic"` when it declares a predicate resolved per call. Absent when it
|
|
3162
|
-
* declares nothing, which a dry run treats as a write.
|
|
3163
|
-
*/
|
|
3164
|
-
effect?: ToolEffect | "dynamic";
|
|
3165
|
-
/**
|
|
3166
|
-
* MCP spec tool annotations, present only on advertised MCP passthroughs
|
|
3167
|
-
* whose server declared them (see {@link HostMcpToolInfo.annotations}).
|
|
3168
|
-
* Authored tools declare {@link effect} instead. Untrusted hints,
|
|
3169
|
-
* propagated so the harness listing carries them and so effect
|
|
3170
|
-
* classification can read them; absent is the fail-closed state.
|
|
3171
|
-
*/
|
|
3172
|
-
annotations?: McpToolAnnotations;
|
|
3173
|
-
/**
|
|
3174
|
-
* True for a 1:1 MCP passthrough synthesized from an advertised
|
|
3175
|
-
* connection's listing. The policy treats these differently from authored
|
|
3176
|
-
* tools when nothing declares an effect: an undeclared authored tool is
|
|
3177
|
-
* stubbed as a write in a dry run, an unclassifiable advertised tool is
|
|
3178
|
-
* refused — see `decideToolCall`.
|
|
3179
|
-
*/
|
|
3180
|
-
advertised?: true;
|
|
3181
|
-
/** Name of the advertising connection an advertised tool came from. */
|
|
3182
|
-
connection?: string;
|
|
3183
|
-
/** Mounted extension this tool came from; absent for `agent/tools/`. */
|
|
3184
|
-
extension?: string;
|
|
3185
|
-
/**
|
|
3186
|
-
* Agent tools: script body materialized under
|
|
3187
|
-
* `.agent-serve/tools/<name>.sh`.
|
|
3188
|
-
*/
|
|
3189
|
-
script?: string;
|
|
3190
|
-
definition: ToolDefinition;
|
|
3191
|
-
}
|
|
3192
|
-
|
|
3193
|
-
/** A packaged-skill sibling file: inline contents or a file to copy. */
|
|
3194
|
-
export type SkillFileSource = { contents: string } | { sourcePath: string };
|
|
3195
|
-
|
|
3196
|
-
export interface DiscoveredSkill {
|
|
3197
|
-
name: string;
|
|
3198
|
-
description: string;
|
|
3199
|
-
/** SKILL.md body (without generated frontmatter). */
|
|
3200
|
-
markdown: string;
|
|
3201
|
-
/** Package-relative sibling files. */
|
|
3202
|
-
files: Record<string, SkillFileSource>;
|
|
3203
|
-
/** Mounted extension this skill came from; absent for `agent/skills/`. */
|
|
3204
|
-
extension?: string;
|
|
3205
|
-
}
|
|
3206
|
-
|
|
3207
|
-
export interface DiscoveredConnection {
|
|
3208
|
-
name: string;
|
|
3209
|
-
transport: ConnectionTransport;
|
|
3210
|
-
description?: string;
|
|
3211
|
-
/** Per-session auth from {@link ConnectionConfig.auth} (http/sse only). */
|
|
3212
|
-
auth?: ConnectionAuthProvider;
|
|
3213
|
-
/** Advertise-by-name from {@link ConnectionConfig.advertiseTools}. */
|
|
3214
|
-
advertiseTools?: boolean;
|
|
3215
|
-
/** Skip a listing failure instead of failing the turn. */
|
|
3216
|
-
optional?: boolean;
|
|
3217
|
-
/**
|
|
3218
|
-
* Normalized intended effects from {@link ConnectionConfig.effects}.
|
|
3219
|
-
* Absent means every listed tool is advertised.
|
|
3220
|
-
*/
|
|
3221
|
-
effects?: readonly ToolEffect[];
|
|
3222
|
-
/**
|
|
3223
|
-
* Normalized tool-name allowlist from {@link ConnectionConfig.tools}.
|
|
3224
|
-
* Absent means every listed tool is kept.
|
|
3225
|
-
*/
|
|
3226
|
-
tools?: readonly string[];
|
|
3227
|
-
/**
|
|
3228
|
-
* Normalized tool-name denylist from
|
|
3229
|
-
* {@link ConnectionConfig.disallowedTools}.
|
|
3230
|
-
*/
|
|
3231
|
-
disallowedTools?: readonly string[];
|
|
3232
|
-
}
|
|
3233
|
-
|
|
3234
|
-
export interface DiscoveredChannel {
|
|
3235
|
-
id: string;
|
|
3236
|
-
definition: ChannelDefinition;
|
|
3237
|
-
}
|
|
3238
|
-
|
|
3239
|
-
export interface DiscoveredSchedule {
|
|
3240
|
-
name: string;
|
|
3241
|
-
cron: string;
|
|
3242
|
-
kind: "markdown" | "run";
|
|
3243
|
-
definition: ScheduleDefinition;
|
|
3244
|
-
}
|
|
3245
|
-
|
|
3246
|
-
export interface DiscoveredHook {
|
|
3247
|
-
name: string;
|
|
3248
|
-
definition: HookDefinition;
|
|
3249
|
-
}
|
|
3250
|
-
|
|
3251
|
-
export interface SeedFile {
|
|
3252
|
-
/** Path inside the session workspace. */
|
|
3253
|
-
relativePath: string;
|
|
3254
|
-
/** Absolute path of the authored source file. */
|
|
3255
|
-
sourcePath: string;
|
|
3256
|
-
}
|
|
3257
|
-
|
|
3258
|
-
/** A fully resolved agent (the root agent or a subagent). */
|
|
3259
|
-
export interface ResolvedAgent {
|
|
3260
|
-
name: string;
|
|
3261
|
-
description?: string;
|
|
3262
|
-
model?: ModelSetting;
|
|
3263
|
-
/**
|
|
3264
|
-
* Remaining models from {@link AgentConfig.fallbacks}, in order. The
|
|
3265
|
-
* runner steps down this list when the primary model is rejected before
|
|
3266
|
-
* the turn produces output (catalog refusal or capacity).
|
|
3267
|
-
*/
|
|
3268
|
-
modelFallbacks?: readonly ModelSetting[];
|
|
3269
|
-
/**
|
|
3270
|
-
* Composed system prompt: identity preamble from {@link name}, then
|
|
3271
|
-
* authored `instructions.md` / `.ts` / dir (or inline `agent.ts`).
|
|
3272
|
-
*/
|
|
3273
|
-
instructions?: string;
|
|
3274
|
-
/** Execution runtime. Root agents default to `"local"`. */
|
|
3275
|
-
runtime: AgentRuntime;
|
|
3276
|
-
/**
|
|
3277
|
-
* Authored {@link AgentConfig.root}. The factory is persisted, not a
|
|
3278
|
-
* serialized tree. A resumed session calls it again (or reuses the handle).
|
|
3279
|
-
*/
|
|
3280
|
-
root?: FileSystem | ((ctx: RootContext) => FileSystem | Promise<FileSystem>);
|
|
3281
|
-
/** Resolved {@link AgentConfig.cloud} for this agent. */
|
|
3282
|
-
cloud?: AgentCloudOptions;
|
|
3283
|
-
/**
|
|
3284
|
-
* Resolved local harness options from {@link AgentConfig.local}
|
|
3285
|
-
* (`cwd` is absolute — relative paths resolved against the project root).
|
|
3286
|
-
*/
|
|
3287
|
-
local?: AgentLocalOptions;
|
|
3288
|
-
/**
|
|
3289
|
-
* Built-in harness tool allowlist from {@link AgentConfig.tools}, with
|
|
3290
|
-
* the "mcp" transport grant injected. Named apart from {@link tools}
|
|
3291
|
-
* (the authored `agent/tools/` list).
|
|
3292
|
-
*/
|
|
3293
|
-
allowedTools?: ToolName[];
|
|
3294
|
-
/** Managed-hosting declarations from {@link AgentConfig.hosting}. */
|
|
3295
|
-
hosting?: AgentHostingOptions;
|
|
3296
|
-
/** Validated turn admission limits from {@link AgentConfig.concurrency}. */
|
|
3297
|
-
concurrency?: AgentConcurrencyOptions;
|
|
3298
|
-
/**
|
|
3299
|
-
* Validated architecture from {@link AgentConfig.architecture}.
|
|
3300
|
-
* Omitted authors resolve to `"v2"`. `"v2"` deploys onto the v2
|
|
3301
|
-
* control plane and stamps kind `/v2` continuation defaults onto
|
|
3302
|
-
* channels that omitted a selector.
|
|
3303
|
-
*/
|
|
3304
|
-
architecture?: AgentArchitecture;
|
|
3305
|
-
persistent?: boolean;
|
|
3306
|
-
tools: DiscoveredTool[];
|
|
3307
|
-
skills: DiscoveredSkill[];
|
|
3308
|
-
/**
|
|
3309
|
-
* Mounted `agent/extensions/`. Their contributions are already merged
|
|
3310
|
-
* into the agent and project lists; this records provenance.
|
|
3311
|
-
*/
|
|
3312
|
-
extensions?: DiscoveredExtension[];
|
|
3313
|
-
connections: DiscoveredConnection[];
|
|
3314
|
-
/**
|
|
3315
|
-
* MCP connections from `agent/host-connections/`. Host tools and
|
|
3316
|
-
* `mcp oauth` see them; the model does not.
|
|
3317
|
-
*/
|
|
3318
|
-
hostConnections?: DiscoveredConnection[];
|
|
3319
|
-
subagents: ResolvedAgent[];
|
|
3320
|
-
seedFiles: SeedFile[];
|
|
3321
|
-
}
|
|
3322
|
-
|
|
3323
|
-
/** The compiled project manifest produced by `loadAgentProject`. */
|
|
3324
|
-
export interface AgentProject {
|
|
3325
|
-
/** App root (the directory containing package.json / agent/). */
|
|
3326
|
-
rootDir: string;
|
|
3327
|
-
/** The authored agent directory. */
|
|
3328
|
-
agentDir: string;
|
|
3329
|
-
name: string;
|
|
3330
|
-
agent: ResolvedAgent;
|
|
3331
|
-
/** Built-in HTTP session channel. */
|
|
3332
|
-
httpChannel: HttpChannelDefinition;
|
|
3333
|
-
channels: DiscoveredChannel[];
|
|
3334
|
-
schedules: DiscoveredSchedule[];
|
|
3335
|
-
/** Named reminder handlers from `agent/reminders/*` (optional / additive). */
|
|
3336
|
-
reminders?: DiscoveredReminder[];
|
|
3337
|
-
hooks: DiscoveredHook[];
|
|
3338
|
-
/** Optional `agent/storage.ts` (`defineStorage`). */
|
|
3339
|
-
storage?: StorageDefinition;
|
|
3340
|
-
/** Optional `agent/artifacts.ts` (`defineArtifacts`). */
|
|
3341
|
-
artifacts?: ArtifactsDefinition;
|
|
3342
|
-
/** Optional `agent/otel.ts` (`defineOtel`). */
|
|
3343
|
-
otel?: OtelDefinition;
|
|
3344
|
-
diagnostics: Diagnostic[];
|
|
3345
|
-
}
|
|
3346
|
-
|
|
3347
|
-
/** JSON-safe projection of one channel HTTP route on `GET /v1/info`. */
|
|
3348
|
-
export interface AgentChannelRouteInfo {
|
|
3349
|
-
method: RouteMethod;
|
|
3350
|
-
/** Authored path (e.g. `"/findings"`), or the absolute path for built-in http. */
|
|
3351
|
-
path: string;
|
|
3352
|
-
/** Mount path including `/v1/channels/<id>` (or absolute for built-in http). */
|
|
3353
|
-
url: string;
|
|
3354
|
-
description?: string;
|
|
3355
|
-
bodySchema?: JsonSchemaObject;
|
|
3356
|
-
querySchema?: JsonSchemaObject;
|
|
3357
|
-
}
|
|
3358
|
-
|
|
3359
|
-
/** JSON-safe projection of the manifest returned by `GET /v1/info`. */
|
|
3360
|
-
export interface AgentProjectInfo {
|
|
3361
|
-
name: string;
|
|
3362
|
-
/** Short agent description when authored on `defineAgent`. */
|
|
3363
|
-
description?: string;
|
|
3364
|
-
model?: ModelSetting;
|
|
3365
|
-
runtime: AgentRuntime;
|
|
3366
|
-
cloud?: AgentCloudPublicInfo;
|
|
3367
|
-
/** Local harness options when authored (`cwd` absolute). */
|
|
3368
|
-
local?: { cwd?: string };
|
|
3369
|
-
/** Managed-hosting declarations when authored (egress allowlist, expected secrets, container image). */
|
|
3370
|
-
hosting?: {
|
|
3371
|
-
egressDomains?: string[];
|
|
3372
|
-
secretNames?: string[];
|
|
3373
|
-
image?: string;
|
|
3374
|
-
};
|
|
3375
|
-
/** Turn admission limits when authored (`concurrency` on `agent.ts`). */
|
|
3376
|
-
concurrency?: { maxRunningTurns?: number };
|
|
3377
|
-
/**
|
|
3378
|
-
* The agent's own MCP surface (mounted at `<base>/v1/mcp`): other agents
|
|
3379
|
-
* and MCP clients delegate to this agent through these tools.
|
|
3380
|
-
*/
|
|
3381
|
-
mcp: { path: string; tools: string[] };
|
|
3382
|
-
instructions?: { chars: number; preview: string };
|
|
3383
|
-
tools: Array<{
|
|
3384
|
-
name: string;
|
|
3385
|
-
description: string;
|
|
3386
|
-
execution: ToolExecution;
|
|
3387
|
-
needsApproval: boolean;
|
|
3388
|
-
/**
|
|
3389
|
-
* The tool's declared {@link ToolEffect} when static, `"dynamic"` when
|
|
3390
|
-
* declared as a predicate. Absent when the author declared nothing —
|
|
3391
|
-
* "unknown", not "mutates".
|
|
3392
|
-
*/
|
|
3393
|
-
effect?: ToolEffect | "dynamic";
|
|
3394
|
-
inputSchema: JsonSchemaObject;
|
|
3395
|
-
}>;
|
|
3396
|
-
skills: Array<{ name: string; description: string }>;
|
|
3397
|
-
/** Mounted extensions and the tool / skill names each contributed. */
|
|
3398
|
-
extensions: DiscoveredExtension[];
|
|
3399
|
-
connections: Array<{
|
|
3400
|
-
name: string;
|
|
3401
|
-
transport: string;
|
|
3402
|
-
advertiseTools?: boolean;
|
|
3403
|
-
optional?: boolean;
|
|
3404
|
-
effects?: readonly ToolEffect[];
|
|
3405
|
-
tools?: readonly string[];
|
|
3406
|
-
disallowedTools?: readonly string[];
|
|
3407
|
-
/**
|
|
3408
|
-
* Present only for `cursorAccount` connections: the connector-name
|
|
3409
|
-
* allowlist, or `"*"` for every connected server. Structured twin of the
|
|
3410
|
-
* `cursor-account[:a,b]` transport label so consumers (e.g. the
|
|
3411
|
-
* dashboard's connector scoping) never parse the display string.
|
|
3412
|
-
*/
|
|
3413
|
-
cursorAccountServers?: string[] | "*";
|
|
3414
|
-
}>;
|
|
3415
|
-
subagents: Array<{
|
|
3416
|
-
name: string;
|
|
3417
|
-
description?: string;
|
|
3418
|
-
model?: ModelSetting;
|
|
3419
|
-
}>;
|
|
3420
|
-
channels: Array<{
|
|
3421
|
-
id: string;
|
|
3422
|
-
routes: AgentChannelRouteInfo[];
|
|
3423
|
-
/** Pack kind when the channel declares one (e.g. `"github"`). */
|
|
3424
|
-
kind?: string;
|
|
3425
|
-
/** GitHub webhook events the channel dispatches on, when declared. */
|
|
3426
|
-
githubWebhookEvents?: readonly string[];
|
|
3427
|
-
/** Origin webhook event types the channel dispatches on, when declared. */
|
|
3428
|
-
originWebhookEvents?: readonly string[];
|
|
3429
|
-
/** GitLab `object_kind`s the channel dispatches on, when declared. */
|
|
3430
|
-
gitlabWebhookEvents?: readonly string[];
|
|
3431
|
-
/** Bitbucket event keys (Cloud vocabulary) the channel dispatches on. */
|
|
3432
|
-
bitbucketWebhookEvents?: readonly string[];
|
|
3433
|
-
/** Factory deployment event types the channel dispatches on, when declared. */
|
|
3434
|
-
deploymentEventTypes?: readonly string[];
|
|
3435
|
-
/** Change Monitor checkpoint or Factory issue event types the channel dispatches on, when declared. */
|
|
3436
|
-
factoryEventTypes?: readonly string[];
|
|
3437
|
-
/** Slack Events API event types the channel dispatches on, when declared. */
|
|
3438
|
-
slackEventTypes?: readonly string[];
|
|
3439
|
-
/** Slack channels watched for posts (opt-in channel watch), when declared. */
|
|
3440
|
-
slackChannelPosts?: readonly string[];
|
|
3441
|
-
}>;
|
|
3442
|
-
schedules: Array<{ name: string; cron: string; kind: "markdown" | "run" }>;
|
|
3443
|
-
/** Named reminder handlers (`agent/reminders/<name>.ts`) when present. */
|
|
3444
|
-
reminders?: Array<{ name: string }>;
|
|
3445
|
-
hooks: string[];
|
|
3446
|
-
/** Project storage sink from `agent/storage.ts`, when authored. */
|
|
3447
|
-
storage?: { name?: string };
|
|
3448
|
-
otel?: { serviceName?: string; enabled: true };
|
|
3449
|
-
/** Declared artifact kinds from `agent/artifacts.ts`, when authored. */
|
|
3450
|
-
artifacts?: { kinds: string[]; agentTool: boolean; max: number };
|
|
3451
|
-
diagnostics: Diagnostic[];
|
|
3452
|
-
}
|
|
3453
|
-
|
|
3454
|
-
// ============================================================================
|
|
3455
|
-
// Runner (the Cursor SDK seam)
|
|
3456
|
-
// ============================================================================
|
|
3457
|
-
|
|
3458
|
-
/**
|
|
3459
|
-
* A streaming update from the harness, re-exported from the Cursor SDK's
|
|
3460
|
-
* delta vocabulary.
|
|
3461
|
-
*/
|
|
3462
|
-
export type RunnerUpdate = InteractionUpdate;
|
|
3463
|
-
|
|
3464
|
-
export interface RunnerSubagent {
|
|
3465
|
-
name: string;
|
|
3466
|
-
description: string;
|
|
3467
|
-
prompt: string;
|
|
3468
|
-
model?: ModelSetting;
|
|
3469
|
-
}
|
|
3470
|
-
|
|
3471
|
-
export interface RunnerTurnRequest {
|
|
3472
|
-
sessionId: string;
|
|
3473
|
-
/**
|
|
3474
|
-
* Cursor SDK agent id to create/resume. Defaults to {@link sessionId}
|
|
3475
|
-
* for local agents; cloud agents use the persisted `bc-…` id after
|
|
3476
|
-
* the first turn.
|
|
3477
|
-
*/
|
|
3478
|
-
sdkAgentId?: string;
|
|
3479
|
-
/** Absolute path of the session's materialized workspace. */
|
|
3480
|
-
workspaceDir: string;
|
|
3481
|
-
/** Resolved FileSystem handle when {@link AgentConfig.root} is set. */
|
|
3482
|
-
root?: FileSystem;
|
|
3483
|
-
/** Run the local harness sandboxed ({@link AgentLocalOptions.sandbox}). */
|
|
3484
|
-
sandbox?: boolean;
|
|
3485
|
-
/** Built-in tool allowlist ({@link AgentConfig.tools}, resolved). */
|
|
3486
|
-
tools?: ToolName[];
|
|
3487
|
-
/**
|
|
3488
|
-
* Native tools hidden on the Cursor SDK agent because synthesized
|
|
3489
|
-
* FileSystem tools own those names. Host-default omitted `tools` only.
|
|
3490
|
-
*/
|
|
3491
|
-
disallowedTools?: ToolName[];
|
|
3492
|
-
/** Absolute path for runner-owned durable state (conversation store). */
|
|
3493
|
-
runnerStateDir: string;
|
|
3494
|
-
prompt: string;
|
|
3495
|
-
isFirstTurn: boolean;
|
|
3496
|
-
/**
|
|
3497
|
-
* Base64 images for this turn (Cursor SDK `SDKUserMessage.images`).
|
|
3498
|
-
* Set from {@link SendMessageOptions.images} / Slack attachments.
|
|
3499
|
-
*/
|
|
3500
|
-
images?: Array<{ data: string; mimeType: string }>;
|
|
3501
|
-
model?: ModelSetting;
|
|
3502
|
-
/**
|
|
3503
|
-
* Models to open the turn on, in order, after {@link model} is rejected
|
|
3504
|
-
* (catalog refusal or `resource_exhausted` / `[unavailable]`) and before
|
|
3505
|
-
* any output was streamed.
|
|
3506
|
-
*/
|
|
3507
|
-
modelFallbacks?: readonly ModelSetting[];
|
|
3508
|
-
runtime: AgentRuntime;
|
|
3509
|
-
/**
|
|
3510
|
-
* The agent's display name. Grokbot turns address the caller's hosted
|
|
3511
|
-
* Grok Bot agent of this name: every SDK session of one agent forwards
|
|
3512
|
-
* into the same hosted agent and conversation.
|
|
3513
|
-
*/
|
|
3514
|
-
agentName?: string;
|
|
3515
|
-
/** Cloud attach options for this turn, when the engine attached. */
|
|
3516
|
-
cloud?: AgentCloudOptions;
|
|
3517
|
-
/**
|
|
3518
|
-
* Composed instructions ({@link ResolvedAgent.instructions} plus identity
|
|
3519
|
-
* and tool catalog) delivered as the harness system prompt.
|
|
3520
|
-
*/
|
|
3521
|
-
instructions?: string;
|
|
3522
|
-
/**
|
|
3523
|
-
* defineAgent directory slug for personal-key cloud creates. Injected
|
|
3524
|
-
* by the engine — not part of authored {@link AgentCloudOptions}.
|
|
3525
|
-
*/
|
|
3526
|
-
agentServeAgent?: string;
|
|
3527
|
-
/** In-process tools, already bound to the session's tool context. */
|
|
3528
|
-
customTools: Record<string, SDKCustomTool>;
|
|
3529
|
-
/** MCP servers from `agent/mcp-connections/`. */
|
|
3530
|
-
mcpServers: Record<string, ConnectionTransport>;
|
|
3531
|
-
/**
|
|
3532
|
-
* Configure {@link mcpServers} on every send instead of once on the
|
|
3533
|
-
* cached SDK agent handle. Set when an attached connection has
|
|
3534
|
-
* per-session `auth`: its headers are re-evaluated at turn-build time,
|
|
3535
|
-
* and a handle-pinned copy would keep the first turn's credentials until
|
|
3536
|
-
* the handle recycles. The SDK builds the send's MCP session from exactly
|
|
3537
|
-
* this set (fresh clients each turn — stdio servers respawn per turn),
|
|
3538
|
-
* and the create/resume/prewarm options carry no `mcpServers` at all, so
|
|
3539
|
-
* the local executor cache key stays stable while credentials rotate.
|
|
3540
|
-
*/
|
|
3541
|
-
perSendMcpServers?: boolean;
|
|
3542
|
-
subagents: RunnerSubagent[];
|
|
3543
|
-
onUpdate: (update: RunnerUpdate) => void | Promise<void>;
|
|
3544
|
-
/** Called once the SDK agent is open so the engine can persist its id. */
|
|
3545
|
-
onSdkAgentId?: (sdkAgentId: string) => void | Promise<void>;
|
|
3546
|
-
/**
|
|
3547
|
-
* Called once the harness names the run, before it produces anything.
|
|
3548
|
-
* Surfaces the request id while the turn is still running rather than at
|
|
3549
|
-
* its end.
|
|
3550
|
-
*/
|
|
3551
|
-
onRequestId?: (requestId: string) => void | Promise<void>;
|
|
3552
|
-
/**
|
|
3553
|
-
* Abort the in-flight run when signalled. The engine aborts this when a
|
|
3554
|
-
* follow-up message preempts the current turn; the runner maps it to
|
|
3555
|
-
* `run.cancel()`, which tears down execution and marks the SDK run terminal.
|
|
3556
|
-
*/
|
|
3557
|
-
signal?: AbortSignal;
|
|
3558
|
-
/**
|
|
3559
|
-
* Expire any run still marked active on the SDK agent before starting this
|
|
3560
|
-
* one (local runtime `force`). Set on follow-up turns so a preempted or
|
|
3561
|
-
* crash-wedged run can never block the next send with "already has active
|
|
3562
|
-
* run".
|
|
3563
|
-
*/
|
|
3564
|
-
forceExpireActiveRun?: boolean;
|
|
3565
|
-
}
|
|
3566
|
-
|
|
3567
|
-
// ============================================================================
|
|
3568
|
-
// Serving
|
|
3569
|
-
// ============================================================================
|
|
3570
|
-
|
|
3571
|
-
export interface ServeOptions {
|
|
3572
|
-
/** Port to listen on. Defaults to 3000 (0 picks an ephemeral port). */
|
|
3573
|
-
port?: number;
|
|
3574
|
-
/** Host to bind. Defaults to 127.0.0.1. */
|
|
3575
|
-
host?: string;
|
|
3576
|
-
/**
|
|
3577
|
-
* Dev mode: mounts `POST /v1/dev/schedules/:scheduleId` and
|
|
3578
|
-
* `POST /v1/dev/reminders/:reminderId`, and disables the cron / reminder
|
|
3579
|
-
* auto-fire runners (dispatch by hand while iterating).
|
|
3580
|
-
*/
|
|
3581
|
-
dev?: boolean;
|
|
3582
|
-
/** Durable state directory. Defaults to `<rootDir>/.agent-serve`. */
|
|
3583
|
-
stateRoot?: string;
|
|
3584
|
-
/**
|
|
3585
|
-
* Cursor API key for the SDK runner and Cursor account MCP connections.
|
|
3586
|
-
* When omitted, falls back to `CURSOR_API_KEY`, then
|
|
3587
|
-
* `CURSOR_API_KEY_FILE` (hosted default `/run/cursor/secrets/CURSOR_API_KEY`
|
|
3588
|
-
* when unset), then `CURSOR_SERVICE_ACCOUNT_KEY`, then the credential
|
|
3589
|
-
* stored by `agent-sdk login`. A bind file wins over
|
|
3590
|
-
* `CURSOR_SERVICE_ACCOUNT_KEY`.
|
|
3591
|
-
*/
|
|
3592
|
-
apiKey?: string;
|
|
3593
|
-
/** Run schedules on their cron cadence. Defaults to `!dev`. */
|
|
3594
|
-
schedules?: boolean;
|
|
3595
|
-
/**
|
|
3596
|
-
* Arm reminder deadline timers automatically. Defaults to `!dev`
|
|
3597
|
-
* (same as schedules). Prompt-form reminders still persist on the
|
|
3598
|
-
* control plane in `--dev`; fire them via `POST /v1/dev/reminders/:id`
|
|
3599
|
-
* or `handle.dispatchReminder`.
|
|
3600
|
-
*/
|
|
3601
|
-
reminders?: boolean;
|
|
3602
|
-
/**
|
|
3603
|
-
* Serve the bundled web playground at `/playground` (chat, streaming,
|
|
3604
|
-
* tool calls, sessions, schedule dispatch). Defaults to true; the API
|
|
3605
|
-
* routes it drives keep their normal auth chain either way.
|
|
3606
|
-
*/
|
|
3607
|
-
playground?: boolean;
|
|
3608
|
-
/**
|
|
3609
|
-
* Serve the built documentation site at `/docs` ("docs" is a reserved
|
|
3610
|
-
* slug). Defaults to true. The site is auto-built when missing and the
|
|
3611
|
-
* vitepress toolchain is present; published installs ship it prebuilt.
|
|
3612
|
-
*/
|
|
3613
|
-
docs?: boolean;
|
|
3614
|
-
/**
|
|
3615
|
-
* Replace the default `[localDevStrict()]` route auth with
|
|
3616
|
-
* `[bearerAuth(authToken)]` on every channel that doesn't author its own
|
|
3617
|
-
* auth chain. Use when exposing the server beyond loopback (e.g. through
|
|
3618
|
-
* a tunnel, where every request arrives from 127.0.0.1 and loopback-only
|
|
3619
|
-
* policies would admit everyone). Authored `auth` arrays still win.
|
|
3620
|
-
*/
|
|
3621
|
-
authToken?: string;
|
|
3622
|
-
/**
|
|
3623
|
-
* Replace the default loopback-only route auth with `[allowAll()]` on every
|
|
3624
|
-
* channel that doesn't author its own auth chain. For temporary demos behind
|
|
3625
|
-
* a trusted network boundary (e.g. Tailscale) — do not combine with
|
|
3626
|
-
* {@link authToken}. Authored `auth` arrays still win.
|
|
3627
|
-
*/
|
|
3628
|
-
allowAnonymous?: boolean;
|
|
3629
|
-
/**
|
|
3630
|
-
* Allow {@link allowAnonymous} together with
|
|
3631
|
-
* `githubChannel({ cursorAccount })`. Without this opt-in, `serve` refuses
|
|
3632
|
-
* to start because every admitted anonymous caller could drive sessions
|
|
3633
|
-
* that hold the signed-in account's repo-scoped GitHub credential. Set it
|
|
3634
|
-
* only when the network boundary already authenticates callers (e.g. an
|
|
3635
|
-
* SSO/Okta proxy in front of the host).
|
|
3636
|
-
*/
|
|
3637
|
-
allowAnonymousCursorGithub?: boolean;
|
|
3638
|
-
/**
|
|
3639
|
-
* Allow `--allow-anonymous` together with a `runtime: "grokbot"` mount.
|
|
3640
|
-
* Off by default: grokbot turns execute on the signed-in account's hosted
|
|
3641
|
-
* Grok Bot computer, so an anonymous caller could drive Shell and other
|
|
3642
|
-
* box tools there. Set it only when the network boundary already
|
|
3643
|
-
* authenticates callers (e.g. an SSO/Okta proxy in front of the host).
|
|
3644
|
-
*/
|
|
3645
|
-
allowAnonymousGrokbot?: boolean;
|
|
3646
|
-
/**
|
|
3647
|
-
* Allow {@link allowAnonymous} together with
|
|
3648
|
-
* `defineConnection({ cursorAccount: true })`. Without this opt-in, `serve`
|
|
3649
|
-
* refuses to start because every admitted anonymous caller could drive the
|
|
3650
|
-
* signed-in account's MCP connectors. Set it only when the network boundary
|
|
3651
|
-
* already authenticates callers (e.g. an SSO/Okta proxy, or the hosted
|
|
3652
|
-
* agent-serve alias token).
|
|
3653
|
-
*/
|
|
3654
|
-
allowAnonymousCursorAccountMcp?: boolean;
|
|
3655
|
-
/**
|
|
3656
|
-
* Public base URL where this server is reachable from outside the host
|
|
3657
|
-
* (e.g. `https://agents.example.com`).
|
|
3658
|
-
*/
|
|
3659
|
-
publicUrl?: string;
|
|
3660
|
-
/**
|
|
3661
|
-
* Hosting-injected HTTP MCP URL that proxies this deployment's
|
|
3662
|
-
* `/v1/mcp/tools`. The resolved Cursor API key authenticates requests.
|
|
3663
|
-
*/
|
|
3664
|
-
cloudToolsUrl?: string;
|
|
3665
|
-
/**
|
|
3666
|
-
* Pull SCM webhook events from `/v0/scm-events` (Cursor account auth).
|
|
3667
|
-
* GitHub and Origin subscriptions are registered independently.
|
|
3668
|
-
* The stream is read as the host's Cursor user, so this requires a signed-in
|
|
3669
|
-
* host: `serve` throws when no key resolves from `apiKey` here,
|
|
3670
|
-
* {@link ServeOptions.apiKey}, `CURSOR_API_KEY`, `CURSOR_API_KEY_FILE`
|
|
3671
|
-
* (hosted default `/run/cursor/secrets/CURSOR_API_KEY` when unset),
|
|
3672
|
-
* `CURSOR_SERVICE_ACCOUNT_KEY`, or `agent-sdk login`.
|
|
3673
|
-
*/
|
|
3674
|
-
cursorEvents?: {
|
|
3675
|
-
repos: string[];
|
|
3676
|
-
baseUrl?: string;
|
|
3677
|
-
apiKey?: string;
|
|
3678
|
-
};
|
|
3679
|
-
logger?: (line: string) => void;
|
|
3680
|
-
/**
|
|
3681
|
-
* OpenTelemetry export. Pass a config object, or `false` to force-disable
|
|
3682
|
-
* even when `OTEL_EXPORTER_OTLP_*` env vars / `agent/otel.ts` are set.
|
|
3683
|
-
* When omitted, env + authored `defineOtel` still enable export.
|
|
3684
|
-
*/
|
|
3685
|
-
otel?: OtelConfig | false;
|
|
3686
|
-
}
|
|
3687
|
-
|
|
3688
|
-
/** One agent mounted on a server (its URL slug + compiled project). */
|
|
3689
|
-
export interface MountedAgentInfo {
|
|
3690
|
-
/**
|
|
3691
|
-
* URL slug the agent is mounted under. Empty string in single-agent mode
|
|
3692
|
-
* (routes at `/v1/...`); the directory name in multi-agent mode (routes at
|
|
3693
|
-
* `/<slug>/v1/...`).
|
|
3694
|
-
*/
|
|
3695
|
-
slug: string;
|
|
3696
|
-
project: AgentProject;
|
|
3697
|
-
/** Absolute base URL for this agent (server URL + `/<slug>` when slugged). */
|
|
3698
|
-
url: string;
|
|
3699
|
-
}
|
|
3700
|
-
|
|
3701
|
-
export interface AgentServeHandle {
|
|
3702
|
-
url: string;
|
|
3703
|
-
port: number;
|
|
3704
|
-
/**
|
|
3705
|
-
* The single served agent's project. In multi-agent mode this is the first
|
|
3706
|
-
* mounted agent; use {@link agents} for the full set.
|
|
3707
|
-
*/
|
|
3708
|
-
project: AgentProject;
|
|
3709
|
-
/** Every agent mounted on this server. One entry in single-agent mode. */
|
|
3710
|
-
agents: MountedAgentInfo[];
|
|
3711
|
-
/**
|
|
3712
|
-
* Dispatch a schedule by name. In multi-agent mode pass the agent slug as
|
|
3713
|
-
* the second argument to target a specific agent.
|
|
3714
|
-
*/
|
|
3715
|
-
dispatchSchedule(name: string, slug?: string): Promise<{ sessionIds: string[] }>;
|
|
3716
|
-
/**
|
|
3717
|
-
* Create a per-session reminder. In multi-agent mode pass `slug` in options.
|
|
3718
|
-
*/
|
|
3719
|
-
createReminder(input: ReminderCreateInput, slug?: string): Promise<ReminderInfo>;
|
|
3720
|
-
/** List reminders for an agent. */
|
|
3721
|
-
listReminders(
|
|
3722
|
-
filter?: {
|
|
3723
|
-
status?: ReminderStatus;
|
|
3724
|
-
purpose?: string;
|
|
3725
|
-
continuationToken?: string;
|
|
3726
|
-
},
|
|
3727
|
-
slug?: string,
|
|
3728
|
-
): Promise<ReminderInfo[]>;
|
|
3729
|
-
/** Cancel a reminder by id. */
|
|
3730
|
-
cancelReminder(
|
|
3731
|
-
id: string,
|
|
3732
|
-
options?: { reason?: string; slug?: string },
|
|
3733
|
-
): Promise<ReminderInfo | undefined>;
|
|
3734
|
-
/**
|
|
3735
|
-
* Fire a reminder immediately (same path as the deadline timer / dev route).
|
|
3736
|
-
* `outcome` is `"noop"` when the reminder was already firing or not armed.
|
|
3737
|
-
*/
|
|
3738
|
-
dispatchReminder(
|
|
3739
|
-
id: string,
|
|
3740
|
-
slug?: string,
|
|
3741
|
-
): Promise<{
|
|
3742
|
-
reminderId: string;
|
|
3743
|
-
outcome: "fired" | "noop";
|
|
3744
|
-
reason?: string;
|
|
3745
|
-
}>;
|
|
3746
|
-
/**
|
|
3747
|
-
* Call an authored server tool deterministically (no model turn). In
|
|
3748
|
-
* multi-agent mode pass the agent slug in the options to target a
|
|
3749
|
-
* specific agent.
|
|
3750
|
-
*/
|
|
3751
|
-
callTool(
|
|
3752
|
-
toolName: string,
|
|
3753
|
-
input?: unknown,
|
|
3754
|
-
options?: CallToolOptions & { slug?: string },
|
|
3755
|
-
): Promise<ToolCallOutcome>;
|
|
3756
|
-
/**
|
|
3757
|
-
* Vite HMR playground URL when `serve --dev` auto-started it (local
|
|
3758
|
-
* checkout with the vite toolchain). Prefer this over the static
|
|
3759
|
-
* `/playground` mount while iterating on the SPA. Multi-agent HMR serves
|
|
3760
|
-
* the agents index at this URL and each SPA at `/<slug>/playground`.
|
|
3761
|
-
*/
|
|
3762
|
-
playgroundDevUrl?: string;
|
|
3763
|
-
/** Where the built documentation site is mounted (`<url>/docs`), when served. */
|
|
3764
|
-
docsUrl?: string;
|
|
3765
|
-
close(): Promise<void>;
|
|
3766
|
-
}
|