@cursor/july 0.1.95 → 0.1.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +3 -4
- package/README.md +3 -2
- package/dist/bin/agent-serve.js +14 -3
- package/dist/channels/deployments/types.d.ts +1 -1
- package/dist/channels/deployments/types.d.ts.map +1 -1
- package/dist/channels/deployments/types.js +1 -0
- package/dist/channels/origin/api.d.ts +72 -15
- package/dist/channels/origin/api.d.ts.map +1 -1
- package/dist/channels/origin/api.js +185 -28
- package/dist/channels/origin/binding.d.ts +13 -2
- package/dist/channels/origin/binding.d.ts.map +1 -1
- package/dist/channels/origin/binding.js +41 -25
- package/dist/channels/origin/checks.d.ts +6 -6
- package/dist/channels/origin/checks.js +6 -6
- package/dist/channels/origin/cursor-account.d.ts +5 -3
- package/dist/channels/origin/cursor-account.d.ts.map +1 -1
- package/dist/channels/origin/cursor-account.js +5 -3
- package/dist/channels/origin/index.d.ts +1 -0
- package/dist/channels/origin/index.d.ts.map +1 -1
- package/dist/channels/origin/index.js +1 -0
- package/dist/channels/origin/origin-channel.d.ts.map +1 -1
- package/dist/channels/origin/origin-channel.js +3 -0
- package/dist/channels/origin/reactions.d.ts +56 -0
- package/dist/channels/origin/reactions.d.ts.map +1 -0
- package/dist/channels/origin/reactions.js +67 -0
- package/dist/channels/origin/types.d.ts +11 -0
- package/dist/channels/origin/types.d.ts.map +1 -1
- package/dist/channels/slack/api.d.ts +9 -0
- package/dist/channels/slack/api.d.ts.map +1 -1
- package/dist/channels/slack/api.js +36 -5
- package/dist/channels/slack/approvals.d.ts +16 -0
- package/dist/channels/slack/approvals.d.ts.map +1 -1
- package/dist/channels/slack/approvals.js +86 -0
- package/dist/channels/slack/cli-project.d.ts +19 -0
- package/dist/channels/slack/cli-project.d.ts.map +1 -0
- package/dist/channels/slack/cli-project.js +234 -0
- package/dist/channels/slack/defaults.d.ts.map +1 -1
- package/dist/channels/slack/defaults.js +110 -81
- package/dist/channels/slack/dispatch.d.ts +7 -1
- package/dist/channels/slack/dispatch.d.ts.map +1 -1
- package/dist/channels/slack/dispatch.js +47 -23
- package/dist/channels/slack/inbound.d.ts +8 -0
- package/dist/channels/slack/inbound.d.ts.map +1 -1
- package/dist/channels/slack/inbound.js +32 -0
- package/dist/channels/slack/init.d.ts +3 -2
- package/dist/channels/slack/init.d.ts.map +1 -1
- package/dist/channels/slack/init.js +5 -5
- package/dist/channels/slack/interactive.d.ts +2 -1
- package/dist/channels/slack/interactive.d.ts.map +1 -1
- package/dist/channels/slack/interactive.js +15 -4
- package/dist/channels/slack/live-delivery.d.ts +26 -29
- package/dist/channels/slack/live-delivery.d.ts.map +1 -1
- package/dist/channels/slack/live-delivery.js +172 -73
- package/dist/channels/slack/manifest.d.ts +1 -1
- package/dist/channels/slack/manifest.d.ts.map +1 -1
- package/dist/channels/slack/manifest.js +6 -2
- package/dist/channels/slack/nudge-carrier.d.ts +2 -0
- package/dist/channels/slack/nudge-carrier.d.ts.map +1 -1
- package/dist/channels/slack/nudge-carrier.js +48 -1
- package/dist/channels/slack/setup.d.ts +1 -1
- package/dist/channels/slack/setup.d.ts.map +1 -1
- package/dist/channels/slack/setup.js +10 -6
- package/dist/channels/slack/slack-channel.d.ts.map +1 -1
- package/dist/channels/slack/slack-channel.js +3 -2
- package/dist/channels/slack/tool-approval-events.d.ts.map +1 -1
- package/dist/channels/slack/tool-approval-events.js +91 -1
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +4 -4
- package/dist/docs/assets/{app.BBj0klBO.js → app.B3rWNYE1.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.BU9nHdnQ.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.CUEXpL78.js → VPLocalSearchBox.C1lhqJJR.js} +1 -1
- package/dist/docs/assets/chunks/{theme.DabmQnia.js → theme.B40_SXuv.js} +2 -2
- package/dist/docs/assets/{deployment.md.D9msOFOW.js → deployment.md.MFPKqsqI.js} +2 -2
- package/dist/docs/assets/{guides_mcp-oauth.md.DPYmBCbV.js → guides_mcp-oauth.md.CN-6YmTJ.js} +4 -4
- package/dist/docs/assets/{guides_mcp-oauth.md.DPYmBCbV.lean.js → guides_mcp-oauth.md.CN-6YmTJ.lean.js} +1 -1
- package/dist/docs/assets/guides_slack.md.VDXQV3ja.js +22 -0
- package/dist/docs/assets/guides_slack.md.VDXQV3ja.lean.js +1 -0
- package/dist/docs/assets/index.md.CVeRUOeZ.js +5 -0
- package/dist/docs/assets/{index.md.BoHaMdeZ.lean.js → index.md.CVeRUOeZ.lean.js} +1 -1
- package/dist/docs/assets/{reference_agent-config.md.Cp_x38Nl.js → reference_agent-config.md.BHeYMgme.js} +1 -1
- package/dist/docs/assets/{reference_cli.md.BsMOxDvh.js → reference_cli.md.RyZf5OTE.js} +10 -6
- package/dist/docs/assets/{reference_cli.md.BsMOxDvh.lean.js → reference_cli.md.RyZf5OTE.lean.js} +1 -1
- package/dist/docs/assets/{reference_connections.md.BH8Oc0D0.js → reference_connections.md.DxldvyIB.js} +4 -3
- package/dist/docs/assets/{reference_http-api.md.D89k1mdm.js → reference_http-api.md.5zOAbV86.js} +1 -1
- package/dist/docs/assets/reference_sessions.md.NxFP_CAC.js +1 -0
- package/dist/docs/assets/{reference_tools.md.BHeXn2id.js → reference_tools.md.B84gw9Ii.js} +1 -1
- package/dist/docs/assets/templates_agents-md.md.CXSMZljE.js +2 -0
- package/dist/docs/assets/templates_agents-md.md.CXSMZljE.lean.js +1 -0
- package/dist/docs/assets/templates_code-wiki.md.CDYZIBFN.js +2 -0
- package/dist/docs/assets/templates_code-wiki.md.CDYZIBFN.lean.js +1 -0
- package/dist/docs/assets/troubleshooting.md.DCiPBhYs.js +1 -0
- package/dist/docs/building-with-agents.html +4 -4
- package/dist/docs/concepts.html +4 -4
- package/dist/docs/deployment.html +7 -7
- package/dist/docs/deployment.md +5 -4
- package/dist/docs/evals.html +4 -4
- package/dist/docs/guides/agent-to-agent.html +4 -4
- package/dist/docs/guides/cloud-runtime.html +4 -4
- package/dist/docs/guides/convert-automation.html +4 -4
- package/dist/docs/guides/github.html +4 -4
- package/dist/docs/guides/human-in-the-loop.html +4 -4
- package/dist/docs/guides/mcp-oauth.html +8 -8
- package/dist/docs/guides/mcp-oauth.md +26 -8
- package/dist/docs/guides/opentelemetry.html +4 -4
- package/dist/docs/guides/slack.html +17 -33
- package/dist/docs/guides/slack.md +92 -201
- package/dist/docs/guides/webhooks.html +4 -4
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +4 -4
- package/dist/docs/index.html +6 -6
- package/dist/docs/index.md +7 -3
- package/dist/docs/llms-full.txt +398 -653
- package/dist/docs/llms.txt +3 -2
- package/dist/docs/quickstart.html +4 -4
- package/dist/docs/reference/agent-config.html +6 -6
- package/dist/docs/reference/agent-config.md +2 -2
- package/dist/docs/reference/artifacts.html +4 -4
- package/dist/docs/reference/channels.html +4 -4
- package/dist/docs/reference/cli.html +14 -10
- package/dist/docs/reference/cli.md +39 -16
- package/dist/docs/reference/connections.html +9 -8
- package/dist/docs/reference/connections.md +6 -3
- package/dist/docs/reference/hooks.html +4 -4
- package/dist/docs/reference/http-api.html +6 -6
- package/dist/docs/reference/http-api.md +2 -1
- package/dist/docs/reference/instructions.html +4 -4
- package/dist/docs/reference/playground.html +4 -4
- package/dist/docs/reference/project-layout.html +4 -4
- package/dist/docs/reference/prompt.html +4 -4
- package/dist/docs/reference/schedules.html +4 -4
- package/dist/docs/reference/sessions.html +5 -5
- package/dist/docs/reference/sessions.md +4 -2
- package/dist/docs/reference/skills.html +4 -4
- package/dist/docs/reference/subagents.html +4 -4
- package/dist/docs/reference/tools.html +6 -6
- package/dist/docs/reference/tools.md +9 -2
- package/dist/docs/scaffolding-agents.html +4 -4
- package/dist/docs/storage.html +4 -4
- package/dist/docs/templates/agentic-owners.html +4 -4
- package/dist/docs/templates/agents-md.html +28 -0
- package/dist/docs/templates/agents-md.md +105 -0
- package/dist/docs/templates/code-wiki.html +28 -0
- package/dist/docs/templates/code-wiki.md +91 -0
- package/dist/docs/templates/demo.html +5 -5
- package/dist/docs/templates/pr-autofixer.html +4 -4
- package/dist/docs/templates/security-help.html +4 -4
- package/dist/docs/templates/security-reviewer.html +5 -5
- package/dist/docs/templates/triage.html +4 -4
- package/dist/docs/troubleshooting.html +5 -5
- package/dist/docs/troubleshooting.md +2 -2
- package/dist/evals/run-facts.d.ts.map +1 -1
- package/dist/evals/run-facts.js +27 -0
- package/dist/files-backends/cursor-hosted.d.ts +26 -4
- package/dist/files-backends/cursor-hosted.d.ts.map +1 -1
- package/dist/files-backends/cursor-hosted.js +32 -4
- package/dist/internal/advertise-tools.d.ts +2 -0
- package/dist/internal/advertise-tools.d.ts.map +1 -1
- package/dist/internal/advertise-tools.js +30 -10
- package/dist/internal/approval-gate.d.ts +12 -13
- package/dist/internal/approval-gate.d.ts.map +1 -1
- package/dist/internal/approval-gate.js +16 -21
- package/dist/internal/bounded.d.ts +7 -0
- package/dist/internal/bounded.d.ts.map +1 -0
- package/dist/internal/bounded.js +32 -0
- package/dist/internal/chat-client.js +10 -0
- package/dist/internal/cli-deploy.d.ts +5 -0
- package/dist/internal/cli-deploy.d.ts.map +1 -1
- package/dist/internal/cli-deploy.js +57 -18
- package/dist/internal/cli-mcp-oauth.js +8 -18
- package/dist/internal/cli-slack-manual.d.ts +24 -2
- package/dist/internal/cli-slack-manual.d.ts.map +1 -1
- package/dist/internal/cli-slack-manual.js +251 -20
- package/dist/internal/cli-slack.d.ts +9 -2
- package/dist/internal/cli-slack.d.ts.map +1 -1
- package/dist/internal/cli-slack.js +29 -82
- package/dist/internal/conversation-mirror.d.ts +11 -8
- package/dist/internal/conversation-mirror.d.ts.map +1 -1
- package/dist/internal/conversation-mirror.js +116 -55
- package/dist/internal/cursor/account-mcp.d.ts +1 -0
- package/dist/internal/cursor/account-mcp.d.ts.map +1 -1
- package/dist/internal/cursor/account-mcp.js +17 -0
- package/dist/internal/cursor/backend-client.d.ts.map +1 -1
- package/dist/internal/cursor/backend-client.js +22 -48
- package/dist/internal/cursor/session-token.d.ts +45 -0
- package/dist/internal/cursor/session-token.d.ts.map +1 -0
- package/dist/internal/cursor/session-token.js +99 -0
- package/dist/internal/cursor-agent-template.d.ts +1 -1
- package/dist/internal/cursor-agent-template.d.ts.map +1 -1
- package/dist/internal/cursor-agent-template.js +2 -0
- package/dist/internal/deploy-client.d.ts +17 -0
- package/dist/internal/deploy-client.d.ts.map +1 -1
- package/dist/internal/deploy-client.js +31 -10
- package/dist/internal/env-file.d.ts +19 -0
- package/dist/internal/env-file.d.ts.map +1 -0
- package/dist/internal/env-file.js +90 -0
- package/dist/internal/framework-file-storage.d.ts +61 -0
- package/dist/internal/framework-file-storage.d.ts.map +1 -0
- package/dist/internal/framework-file-storage.js +210 -0
- package/dist/internal/framework-storage-selection.d.ts +11 -5
- package/dist/internal/framework-storage-selection.d.ts.map +1 -1
- package/dist/internal/framework-storage-selection.js +38 -11
- package/dist/internal/hosted-delivery-protocol.d.ts +7 -0
- package/dist/internal/hosted-delivery-protocol.d.ts.map +1 -1
- package/dist/internal/hosted-delivery-protocol.js +7 -0
- package/dist/internal/hosted-delivery.d.ts +13 -0
- package/dist/internal/hosted-delivery.d.ts.map +1 -1
- package/dist/internal/hosted-delivery.js +64 -19
- package/dist/internal/hosted-execution-diag.d.ts +48 -0
- package/dist/internal/hosted-execution-diag.d.ts.map +1 -0
- package/dist/internal/hosted-execution-diag.js +150 -0
- package/dist/internal/http-channel.d.ts.map +1 -1
- package/dist/internal/http-channel.js +81 -1
- package/dist/internal/init-project.d.ts.map +1 -1
- package/dist/internal/init-project.js +4 -0
- package/dist/internal/install-cursor-skills.d.ts.map +1 -1
- package/dist/internal/install-cursor-skills.js +1 -3
- package/dist/internal/logs-client.d.ts +5 -0
- package/dist/internal/logs-client.d.ts.map +1 -1
- package/dist/internal/logs-client.js +5 -0
- package/dist/internal/managed-delivery.d.ts +80 -0
- package/dist/internal/managed-delivery.d.ts.map +1 -0
- package/dist/internal/managed-delivery.js +86 -0
- package/dist/internal/mcp-endpoint.js +2 -3
- package/dist/internal/mcp-host.d.ts +10 -0
- package/dist/internal/mcp-host.d.ts.map +1 -1
- package/dist/internal/mcp-host.js +57 -8
- package/dist/internal/mcp-oauth-on-demand.d.ts +68 -0
- package/dist/internal/mcp-oauth-on-demand.d.ts.map +1 -0
- package/dist/internal/mcp-oauth-on-demand.js +287 -0
- package/dist/internal/mcp-oauth-persist.d.ts +42 -0
- package/dist/internal/mcp-oauth-persist.d.ts.map +1 -0
- package/dist/internal/mcp-oauth-persist.js +92 -0
- package/dist/internal/mcp-oauth.d.ts +1 -0
- package/dist/internal/mcp-oauth.d.ts.map +1 -1
- package/dist/internal/mcp-oauth.js +10 -2
- package/dist/internal/otel/collector.d.ts.map +1 -1
- package/dist/internal/otel/collector.js +22 -9
- package/dist/internal/runtime-dispatch-runner.d.ts +5 -1
- package/dist/internal/runtime-dispatch-runner.d.ts.map +1 -1
- package/dist/internal/runtime-dispatch-runner.js +7 -0
- package/dist/internal/sdk-runner.d.ts +11 -0
- package/dist/internal/sdk-runner.d.ts.map +1 -1
- package/dist/internal/sdk-runner.js +39 -8
- package/dist/internal/server.d.ts +3 -0
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +49 -21
- package/dist/internal/session-engine.d.ts +101 -3
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +577 -46
- package/dist/internal/sessions-client.d.ts +9 -7
- package/dist/internal/sessions-client.d.ts.map +1 -1
- package/dist/internal/sessions-client.js +3 -1
- package/dist/internal/steering.d.ts +15 -0
- package/dist/internal/steering.d.ts.map +1 -0
- package/dist/internal/steering.js +18 -0
- package/dist/internal/storage-coordinator.d.ts +7 -0
- package/dist/internal/storage-coordinator.d.ts.map +1 -1
- package/dist/internal/storage-coordinator.js +28 -5
- package/dist/internal/storage-roles.d.ts +5 -0
- package/dist/internal/storage-roles.d.ts.map +1 -1
- package/dist/internal/stream-progress.d.ts.map +1 -1
- package/dist/internal/stream-progress.js +10 -0
- package/dist/internal/tool-policy.d.ts +9 -1
- package/dist/internal/tool-policy.d.ts.map +1 -1
- package/dist/internal/tool-policy.js +13 -0
- package/dist/internal/trajectory.d.ts.map +1 -1
- package/dist/internal/trajectory.js +10 -0
- package/dist/internal/turn-outbox.d.ts +24 -0
- package/dist/internal/turn-outbox.d.ts.map +1 -0
- package/dist/internal/turn-outbox.js +80 -0
- package/dist/playground/assets/{index-CZA1uEWA.js → index-DrkI6y5O.js} +51 -51
- package/dist/playground/assets/index-DzNGwm7q.css +1 -0
- package/dist/playground/index.html +2 -2
- package/dist/storage-backends/cursor-hosted.d.ts +9 -6
- package/dist/storage-backends/cursor-hosted.d.ts.map +1 -1
- package/dist/storage-backends/cursor-hosted.js +16 -3
- package/dist/storage.d.ts +8 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/types.d.ts +65 -8
- package/dist/types.d.ts.map +1 -1
- package/docs/README.md +7 -3
- package/docs/deployment.md +5 -4
- package/docs/guides/mcp-oauth.md +26 -8
- package/docs/guides/slack.md +93 -202
- package/docs/reference/agent-config.md +2 -2
- package/docs/reference/cli.md +39 -16
- package/docs/reference/connections.md +6 -3
- package/docs/reference/http-api.md +2 -1
- package/docs/reference/sessions.md +4 -2
- package/docs/reference/tools.md +9 -2
- package/docs/templates/agents-md.md +110 -0
- package/docs/templates/code-wiki.md +96 -0
- package/docs/troubleshooting.md +2 -2
- package/package.json +2 -2
- package/skills/ab/SKILL.md +13 -97
- package/skills/create-agent/SKILL.md +124 -223
- package/skills/debug/SKILL.md +34 -68
- package/skills/evals/SKILL.md +55 -180
- package/skills/framework-map/SKILL.md +83 -145
- package/skills/github/SKILL.md +53 -111
- package/skills/hillclimb/SKILL.md +40 -163
- package/skills/mcp-auth/SKILL.md +51 -107
- package/skills/otel/SKILL.md +22 -68
- package/skills/setup-slack/SKILL.md +91 -212
- package/src/bin/agent-serve.ts +13 -1
- package/src/channels/deployments/types.ts +1 -0
- package/src/channels/origin/api.ts +264 -33
- package/src/channels/origin/binding.ts +57 -28
- package/src/channels/origin/checks.ts +6 -6
- package/src/channels/origin/cursor-account.ts +5 -3
- package/src/channels/origin/index.ts +1 -0
- package/src/channels/origin/origin-channel.ts +4 -0
- package/src/channels/origin/reactions.ts +82 -0
- package/src/channels/origin/types.ts +11 -0
- package/src/channels/slack/api.ts +41 -5
- package/src/channels/slack/approvals.ts +105 -0
- package/src/channels/slack/cli-project.ts +267 -0
- package/src/channels/slack/defaults.ts +122 -93
- package/src/channels/slack/dispatch.ts +56 -22
- package/src/channels/slack/inbound.ts +43 -0
- package/src/channels/slack/init.ts +10 -5
- package/src/channels/slack/interactive.ts +35 -9
- package/src/channels/slack/live-delivery.ts +235 -114
- package/src/channels/slack/manifest.ts +6 -2
- package/src/channels/slack/nudge-carrier.ts +48 -1
- package/src/channels/slack/setup.ts +10 -6
- package/src/channels/slack/slack-channel.ts +3 -0
- package/src/channels/slack/tool-approval-events.ts +93 -0
- package/src/evals/run-facts.ts +32 -0
- package/src/files-backends/cursor-hosted.ts +40 -7
- package/src/internal/advertise-tools.ts +49 -12
- package/src/internal/approval-gate.ts +20 -29
- package/src/internal/bounded.ts +28 -0
- package/src/internal/chat-client.ts +19 -0
- package/src/internal/cli-deploy.ts +91 -9
- package/src/internal/cli-mcp-oauth.ts +7 -21
- package/src/internal/cli-slack-manual.ts +350 -18
- package/src/internal/cli-slack.ts +40 -84
- package/src/internal/conversation-mirror.ts +145 -69
- package/src/internal/cursor/account-mcp.ts +21 -0
- package/src/internal/cursor/backend-client.ts +34 -58
- package/src/internal/cursor/session-token.ts +115 -0
- package/src/internal/cursor-agent-template.ts +2 -0
- package/src/internal/deploy-client.ts +43 -0
- package/src/internal/env-file.ts +84 -0
- package/src/internal/framework-file-storage.ts +228 -0
- package/src/internal/framework-storage-selection.ts +51 -11
- package/src/internal/hosted-delivery-protocol.ts +7 -0
- package/src/internal/hosted-delivery.ts +107 -24
- package/src/internal/hosted-execution-diag.ts +207 -0
- package/src/internal/http-channel.ts +99 -0
- package/src/internal/init-project.ts +4 -0
- package/src/internal/install-cursor-skills.ts +1 -4
- package/src/internal/logs-client.ts +5 -0
- package/src/internal/managed-delivery.ts +125 -0
- package/src/internal/mcp-endpoint.ts +13 -4
- package/src/internal/mcp-host.ts +77 -11
- package/src/internal/mcp-oauth-on-demand.ts +352 -0
- package/src/internal/mcp-oauth-persist.ts +127 -0
- package/src/internal/mcp-oauth.ts +17 -1
- package/src/internal/otel/collector.ts +30 -0
- package/src/internal/runtime-dispatch-runner.ts +10 -0
- package/src/internal/sdk-runner.ts +56 -8
- package/src/internal/server.ts +61 -9
- package/src/internal/session-engine.ts +723 -60
- package/src/internal/sessions-client.ts +17 -8
- package/src/internal/steering.ts +17 -0
- package/src/internal/storage-coordinator.ts +38 -8
- package/src/internal/storage-roles.ts +7 -0
- package/src/internal/stream-progress.ts +19 -0
- package/src/internal/tool-policy.ts +18 -0
- package/src/internal/trajectory.ts +10 -0
- package/src/internal/turn-outbox.ts +85 -0
- package/src/storage-backends/cursor-hosted.ts +22 -8
- package/src/storage.ts +12 -0
- package/src/types.ts +70 -9
- package/templates/agents-md/README.md +39 -0
- package/templates/agents-md/agent/agent.ts +8 -0
- package/templates/agents-md/agent/channels/github.ts +10 -0
- package/templates/agents-md/agent/channels/queue.ts +28 -0
- package/templates/agents-md/agent/channels/slack.ts +9 -0
- package/templates/agents-md/agent/instructions.md +39 -0
- package/templates/agents-md/agent/lib/collect.ts +439 -0
- package/templates/agents-md/agent/lib/config.ts +8 -0
- package/templates/agents-md/agent/lib/paths.ts +51 -0
- package/templates/agents-md/agent/schedules/weekly.ts +17 -0
- package/templates/agents-md/agent/tools/apply_agents.ts +226 -0
- package/templates/agents-md/evals/agents.eval.ts +135 -0
- package/templates/agents-md/evals/evals.config.ts +5 -0
- package/templates/agents-md/init.json +38 -0
- package/templates/agents-md/package.json +18 -0
- package/templates/agents-md/tsconfig.json +12 -0
- package/templates/code-wiki/README.md +34 -0
- package/templates/code-wiki/agent/agent.ts +8 -0
- package/templates/code-wiki/agent/channels/github.ts +144 -0
- package/templates/code-wiki/agent/instructions.md +39 -0
- package/templates/code-wiki/agent/lib/repos.ts +5 -0
- package/templates/code-wiki/agent/lib/wiki.ts +22 -0
- package/templates/code-wiki/agent/tools/apply_wiki.ts +219 -0
- package/templates/code-wiki/evals/evals.config.ts +5 -0
- package/templates/code-wiki/evals/wiki.eval.ts +132 -0
- package/templates/code-wiki/init.json +25 -0
- package/templates/code-wiki/package.json +18 -0
- package/templates/code-wiki/tsconfig.json +12 -0
- package/dist/docs/assets/chunks/@localSearchIndexroot.oqPawjiD.js +0 -1
- package/dist/docs/assets/guides_slack.md.C32HsdKk.js +0 -38
- package/dist/docs/assets/guides_slack.md.C32HsdKk.lean.js +0 -1
- package/dist/docs/assets/index.md.BoHaMdeZ.js +0 -5
- package/dist/docs/assets/reference_sessions.md.D0mIh4KK.js +0 -1
- package/dist/docs/assets/troubleshooting.md.Ctv3T8C2.js +0 -1
- package/dist/docs/design/agsh.md +0 -406
- package/dist/internal/deployment-scm-event-stream.d.ts +0 -116
- package/dist/internal/deployment-scm-event-stream.d.ts.map +0 -1
- package/dist/internal/deployment-scm-event-stream.js +0 -474
- package/dist/playground/assets/index-CF7hUDnQ.css +0 -1
- package/docs/design/agsh.md +0 -406
- package/src/internal/deployment-scm-event-stream.ts +0 -593
- /package/dist/docs/assets/{deployment.md.D9msOFOW.lean.js → deployment.md.MFPKqsqI.lean.js} +0 -0
- /package/dist/docs/assets/{reference_agent-config.md.Cp_x38Nl.lean.js → reference_agent-config.md.BHeYMgme.lean.js} +0 -0
- /package/dist/docs/assets/{reference_connections.md.BH8Oc0D0.lean.js → reference_connections.md.DxldvyIB.lean.js} +0 -0
- /package/dist/docs/assets/{reference_http-api.md.D89k1mdm.lean.js → reference_http-api.md.5zOAbV86.lean.js} +0 -0
- /package/dist/docs/assets/{reference_sessions.md.D0mIh4KK.lean.js → reference_sessions.md.NxFP_CAC.lean.js} +0 -0
- /package/dist/docs/assets/{reference_tools.md.BHeXn2id.lean.js → reference_tools.md.B84gw9Ii.lean.js} +0 -0
- /package/dist/docs/assets/{troubleshooting.md.Ctv3T8C2.lean.js → troubleshooting.md.DCiPBhYs.lean.js} +0 -0
|
@@ -1,474 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deployment-scoped SCM event intake for hosted multi-tenant agents.
|
|
3
|
-
*
|
|
4
|
-
* Instead of receiving HMAC-signed webhook forwards from the backend (which
|
|
5
|
-
* required a shared `GITHUB_WEBHOOK_SECRET` / forward-secret pair), the
|
|
6
|
-
* engine pulls its deliveries from the control plane's deployment-scoped
|
|
7
|
-
* event stream:
|
|
8
|
-
*
|
|
9
|
-
* GET /internal/agent-serve/automation-agent-sdk/events
|
|
10
|
-
*
|
|
11
|
-
* authenticated with the engine pod's `CURSOR_API_KEY` — the same
|
|
12
|
-
* credential (and server-side deployment allowlist) that authorizes the
|
|
13
|
-
* consuming agent's customer list read. The backend writes each envelope's
|
|
14
|
-
* `installationId` itself from the verified GitHub delivery, so agent-side
|
|
15
|
-
* tenant binding does not depend on an HMAC-covered payload.
|
|
16
|
-
*
|
|
17
|
-
* Each envelope is stubbed into a GitHub-shaped `pull_request` webhook body
|
|
18
|
-
* and POSTed to this process's own github channel route over loopback
|
|
19
|
-
* (admitted by the channel's no-secret `localDevStrict` policy), so the
|
|
20
|
-
* consuming agent's whole pipeline — Zod parse, cursorAccount credential
|
|
21
|
-
* lease, customer routing, tools — runs unchanged. Loopback (rather than
|
|
22
|
-
* the in-process `handleAgentServeTrigger` fan-out the `--cursor-events`
|
|
23
|
-
* relay uses) is deliberate: this stream is started from a channel's
|
|
24
|
-
* `onStart`, which cannot reach the serve-level mount/handler wiring.
|
|
25
|
-
*
|
|
26
|
-
* Offsets are client-owned (`<ms>-<seq>` Redis stream ids) and persisted
|
|
27
|
-
* under the state dir so a restart resumes where it left off instead of
|
|
28
|
-
* dropping deliveries (the old push path was fire-and-forget).
|
|
29
|
-
*
|
|
30
|
-
* INTERNAL: first-party host plumbing shared by agents in `factory/*`.
|
|
31
|
-
* Consumed via relative source imports, following
|
|
32
|
-
* `tenant-mcp/run-mcp-registry.ts`. Policy (which deliveries to act on,
|
|
33
|
-
* tenant routing) stays in the consuming agent; this module is transport
|
|
34
|
-
* only.
|
|
35
|
-
*/
|
|
36
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
// Hosted engines install the consuming agent's directory alone and load this
|
|
46
|
-
// file as raw TypeScript source. Relative and `node:` imports resolve here;
|
|
47
|
-
// this package's own npm dependencies retry against the running `@cursor/july`
|
|
48
|
-
// install (authored-alias-hooks). Do not add deps that package does not have.
|
|
49
|
-
import { createHmac } from "node:crypto";
|
|
50
|
-
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
51
|
-
import { join } from "node:path";
|
|
52
|
-
const DEFAULT_BASE_URL = "https://api.cursor.com";
|
|
53
|
-
const EVENTS_PATH = "/internal/agent-serve/automation-agent-sdk/events";
|
|
54
|
-
const POLL_WAIT_MS = 20000;
|
|
55
|
-
const POLL_LIMIT = 100;
|
|
56
|
-
const MIN_BACKOFF_MS = 1000;
|
|
57
|
-
const MAX_BACKOFF_MS = 30000;
|
|
58
|
-
// Bounded self-dispatch retry before the offset advances past a delivery
|
|
59
|
-
// (mirrors CursorRelayCore): transient loopback failures (connection
|
|
60
|
-
// reset, channel briefly unavailable at startup) get a few tries; a
|
|
61
|
-
// poison delivery still costs only DISPATCH_ATTEMPTS and is then skipped.
|
|
62
|
-
const DISPATCH_ATTEMPTS = 3;
|
|
63
|
-
const DISPATCH_RETRY_DELAYS_MS = [250, 1000];
|
|
64
|
-
/** Auth/gate failures (401/403/404) are config problems; poll slowly. */
|
|
65
|
-
const AUTH_FAILURE_BACKOFF_MS = 60000;
|
|
66
|
-
const OFFSET_SNAPSHOT_VERSION = 1;
|
|
67
|
-
function isRecord(value) {
|
|
68
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
69
|
-
}
|
|
70
|
-
function nonEmptyString(value) {
|
|
71
|
-
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
72
|
-
}
|
|
73
|
-
function optionalString(value) {
|
|
74
|
-
return value === undefined || typeof value === "string";
|
|
75
|
-
}
|
|
76
|
-
function optionalBoolean(value) {
|
|
77
|
-
return value === undefined || typeof value === "boolean";
|
|
78
|
-
}
|
|
79
|
-
function parsePullRequestMeta(value) {
|
|
80
|
-
if (!isRecord(value)) {
|
|
81
|
-
return undefined;
|
|
82
|
-
}
|
|
83
|
-
const number = value.number;
|
|
84
|
-
const url = nonEmptyString(value.url);
|
|
85
|
-
const headRef = nonEmptyString(value.headRef);
|
|
86
|
-
const headSha = nonEmptyString(value.headSha);
|
|
87
|
-
const baseRef = nonEmptyString(value.baseRef);
|
|
88
|
-
if (typeof number !== "number" ||
|
|
89
|
-
!Number.isInteger(number) ||
|
|
90
|
-
number <= 0 ||
|
|
91
|
-
url === undefined ||
|
|
92
|
-
typeof value.title !== "string" ||
|
|
93
|
-
!(value.body === undefined ||
|
|
94
|
-
value.body === null ||
|
|
95
|
-
typeof value.body === "string") ||
|
|
96
|
-
!optionalBoolean(value.draft) ||
|
|
97
|
-
!optionalBoolean(value.merged) ||
|
|
98
|
-
!optionalString(value.authorLogin) ||
|
|
99
|
-
headRef === undefined ||
|
|
100
|
-
headSha === undefined ||
|
|
101
|
-
baseRef === undefined ||
|
|
102
|
-
!optionalString(value.baseSha)) {
|
|
103
|
-
return undefined;
|
|
104
|
-
}
|
|
105
|
-
return {
|
|
106
|
-
number,
|
|
107
|
-
url,
|
|
108
|
-
title: value.title,
|
|
109
|
-
body: value.body,
|
|
110
|
-
draft: value.draft,
|
|
111
|
-
merged: value.merged,
|
|
112
|
-
authorLogin: value.authorLogin,
|
|
113
|
-
headRef,
|
|
114
|
-
headSha,
|
|
115
|
-
baseRef,
|
|
116
|
-
baseSha: value.baseSha,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
/** Unknown envelope shapes return undefined (skipped, forward compat). */
|
|
120
|
-
export function parseAgentSdkScmEventEnvelope(value) {
|
|
121
|
-
if (!isRecord(value) || value.provider !== "github") {
|
|
122
|
-
return undefined;
|
|
123
|
-
}
|
|
124
|
-
const eventName = nonEmptyString(value.eventName);
|
|
125
|
-
const deliveryId = nonEmptyString(value.deliveryId);
|
|
126
|
-
const repo = nonEmptyString(value.repo);
|
|
127
|
-
const action = nonEmptyString(value.action);
|
|
128
|
-
const installationId = value.installationId;
|
|
129
|
-
const pullRequest = parsePullRequestMeta(value.pullRequest);
|
|
130
|
-
if (eventName === undefined ||
|
|
131
|
-
deliveryId === undefined ||
|
|
132
|
-
repo === undefined ||
|
|
133
|
-
typeof value.receivedAtMs !== "number" ||
|
|
134
|
-
action === undefined ||
|
|
135
|
-
typeof installationId !== "number" ||
|
|
136
|
-
!Number.isInteger(installationId) ||
|
|
137
|
-
installationId <= 0 ||
|
|
138
|
-
pullRequest === undefined ||
|
|
139
|
-
!(value.occurredAtMs === undefined || typeof value.occurredAtMs === "number")) {
|
|
140
|
-
return undefined;
|
|
141
|
-
}
|
|
142
|
-
return {
|
|
143
|
-
provider: "github",
|
|
144
|
-
eventName,
|
|
145
|
-
deliveryId,
|
|
146
|
-
repo,
|
|
147
|
-
receivedAtMs: value.receivedAtMs,
|
|
148
|
-
action,
|
|
149
|
-
installationId,
|
|
150
|
-
pullRequest,
|
|
151
|
-
occurredAtMs: value.occurredAtMs,
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
function parsePollResponse(value) {
|
|
155
|
-
if (!isRecord(value) || !Array.isArray(value.events)) {
|
|
156
|
-
throw new Error("malformed poll response");
|
|
157
|
-
}
|
|
158
|
-
const events = [];
|
|
159
|
-
for (const entry of value.events) {
|
|
160
|
-
if (!isRecord(entry)) {
|
|
161
|
-
throw new Error("malformed poll response event");
|
|
162
|
-
}
|
|
163
|
-
const offset = nonEmptyString(entry.offset);
|
|
164
|
-
if (offset === undefined) {
|
|
165
|
-
throw new Error("malformed poll response event offset");
|
|
166
|
-
}
|
|
167
|
-
events.push({ offset, envelope: entry.envelope });
|
|
168
|
-
}
|
|
169
|
-
if (typeof value.nextOffset !== "string" ||
|
|
170
|
-
typeof value.gapDetected !== "boolean") {
|
|
171
|
-
throw new Error("malformed poll response fields");
|
|
172
|
-
}
|
|
173
|
-
return {
|
|
174
|
-
events,
|
|
175
|
-
nextOffset: value.nextOffset,
|
|
176
|
-
gapDetected: value.gapDetected,
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Marker key on self-dispatched webhook bodies so the consuming channel can
|
|
181
|
-
* tell stream deliveries apart from other senders (e.g. the serve host's
|
|
182
|
-
* cursorAccount SCM relay). Multi-tenant channels treat this stream as the
|
|
183
|
-
* single source and ignore unmarked deliveries — without that gate, one PR
|
|
184
|
-
* push reached the channel twice (relay + stream) and double-ran reviews.
|
|
185
|
-
*/
|
|
186
|
-
const EVENT_STREAM_PAYLOAD_MARKER = "cursorDeploymentEventStream";
|
|
187
|
-
/** Whether a webhook body was self-dispatched by this event stream. */
|
|
188
|
-
export function isDeploymentEventStreamPayload(payload) {
|
|
189
|
-
return isRecord(payload) && payload[EVENT_STREAM_PAYLOAD_MARKER] === true;
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Stub a GitHub-shaped `pull_request` webhook body from an envelope —
|
|
193
|
-
* enough for agent-serve's pull_request Zod schema, plus `installation.id`
|
|
194
|
-
* so the channel's `ctx.installationId` tenant binding keeps working, plus
|
|
195
|
-
* the {@link isDeploymentEventStreamPayload} source marker.
|
|
196
|
-
* Pure — exported for tests.
|
|
197
|
-
*/
|
|
198
|
-
export function envelopeToGitHubPayload(envelope) {
|
|
199
|
-
const slash = envelope.repo.indexOf("/");
|
|
200
|
-
const owner = slash === -1 ? "" : envelope.repo.slice(0, slash);
|
|
201
|
-
const name = slash === -1 ? envelope.repo : envelope.repo.slice(slash + 1);
|
|
202
|
-
const pr = envelope.pullRequest;
|
|
203
|
-
return {
|
|
204
|
-
action: envelope.action,
|
|
205
|
-
repository: {
|
|
206
|
-
full_name: envelope.repo,
|
|
207
|
-
name,
|
|
208
|
-
html_url: `https://github.com/${envelope.repo}`,
|
|
209
|
-
owner: { login: owner },
|
|
210
|
-
},
|
|
211
|
-
pull_request: {
|
|
212
|
-
number: pr.number,
|
|
213
|
-
html_url: pr.url,
|
|
214
|
-
title: pr.title,
|
|
215
|
-
body: pr.body,
|
|
216
|
-
draft: pr.draft,
|
|
217
|
-
merged: pr.merged,
|
|
218
|
-
user: pr.authorLogin === undefined ? undefined : { login: pr.authorLogin },
|
|
219
|
-
head: { ref: pr.headRef, sha: pr.headSha },
|
|
220
|
-
base: { ref: pr.baseRef, sha: pr.baseSha },
|
|
221
|
-
},
|
|
222
|
-
installation: { id: envelope.installationId },
|
|
223
|
-
[EVENT_STREAM_PAYLOAD_MARKER]: true,
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
/** Durable offset snapshot under `<stateDir>/offset.json`. */
|
|
227
|
-
class OffsetStore {
|
|
228
|
-
constructor(stateDir) {
|
|
229
|
-
this.stateDir = stateDir;
|
|
230
|
-
}
|
|
231
|
-
get filePath() {
|
|
232
|
-
return join(this.stateDir, "offset.json");
|
|
233
|
-
}
|
|
234
|
-
load() {
|
|
235
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
236
|
-
try {
|
|
237
|
-
const raw = yield readFile(this.filePath, "utf8");
|
|
238
|
-
const parsed = JSON.parse(raw);
|
|
239
|
-
if (parsed.version === OFFSET_SNAPSHOT_VERSION &&
|
|
240
|
-
typeof parsed.offset === "string" &&
|
|
241
|
-
parsed.offset !== "") {
|
|
242
|
-
return parsed.offset;
|
|
243
|
-
}
|
|
244
|
-
return undefined;
|
|
245
|
-
}
|
|
246
|
-
catch (_a) {
|
|
247
|
-
return undefined;
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
save(offset) {
|
|
252
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
253
|
-
yield mkdir(this.stateDir, { recursive: true });
|
|
254
|
-
// Write-then-rename so a crash mid-write never corrupts the snapshot.
|
|
255
|
-
const tmpPath = `${this.filePath}.tmp`;
|
|
256
|
-
yield writeFile(tmpPath, JSON.stringify({
|
|
257
|
-
version: OFFSET_SNAPSHOT_VERSION,
|
|
258
|
-
offset,
|
|
259
|
-
updatedAt: new Date().toISOString(),
|
|
260
|
-
}, null, 2), "utf8");
|
|
261
|
-
yield rename(tmpPath, this.filePath);
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Port the serve process is actually listening on, read from its own argv.
|
|
267
|
-
*
|
|
268
|
-
* The channel runs inside the serve process, so `--port <n>` / `--port=<n>`
|
|
269
|
-
* on the command line is authoritative. Hosted-platform engines start with
|
|
270
|
-
* `--port 26100` and export no `PORT` env, so guessing a fixed default posts
|
|
271
|
-
* self-dispatches at a port nothing listens on ("fetch failed" for every
|
|
272
|
-
* delivery).
|
|
273
|
-
*/
|
|
274
|
-
export function servePortFromArgv(argv) {
|
|
275
|
-
var _a;
|
|
276
|
-
const flagIndex = argv.lastIndexOf("--port");
|
|
277
|
-
if (flagIndex !== -1) {
|
|
278
|
-
const value = (_a = argv[flagIndex + 1]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
279
|
-
if (value !== undefined && /^\d+$/.test(value)) {
|
|
280
|
-
return value;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
for (let i = argv.length - 1; i >= 0; i--) {
|
|
284
|
-
const arg = argv[i];
|
|
285
|
-
if (arg !== undefined && arg.startsWith("--port=")) {
|
|
286
|
-
const value = arg.slice("--port=".length).trim();
|
|
287
|
-
if (/^\d+$/.test(value)) {
|
|
288
|
-
return value;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
return undefined;
|
|
293
|
-
}
|
|
294
|
-
function delay(ms, signal) {
|
|
295
|
-
return new Promise((resolve) => {
|
|
296
|
-
var _a;
|
|
297
|
-
const timer = setTimeout(finish, ms);
|
|
298
|
-
(_a = timer.unref) === null || _a === void 0 ? void 0 : _a.call(timer);
|
|
299
|
-
signal.addEventListener("abort", finish, { once: true });
|
|
300
|
-
function finish() {
|
|
301
|
-
clearTimeout(timer);
|
|
302
|
-
signal.removeEventListener("abort", finish);
|
|
303
|
-
resolve();
|
|
304
|
-
}
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Start the pull loop. Returns undefined (with a log line) when required
|
|
309
|
-
* config is missing so `serve` still starts — mirroring how other relays
|
|
310
|
-
* degrade instead of failing the host.
|
|
311
|
-
*/
|
|
312
|
-
export function startAgentSdkEventStream(options = {}) {
|
|
313
|
-
var _a, _b, _c, _d, _e;
|
|
314
|
-
var _f, _g, _h, _j, _k, _l, _m, _o;
|
|
315
|
-
const env = (_f = options.env) !== null && _f !== void 0 ? _f : process.env;
|
|
316
|
-
const logLabel = (_g = options.logLabel) !== null && _g !== void 0 ? _g : "agent-sdk/deployment-events";
|
|
317
|
-
const rawLog = (_h = options.logger) !== null && _h !== void 0 ? _h : (() => { });
|
|
318
|
-
const log = (message) => {
|
|
319
|
-
rawLog(`[${logLabel}] ${message}`);
|
|
320
|
-
};
|
|
321
|
-
const doFetch = (_j = options.fetch) !== null && _j !== void 0 ? _j : fetch;
|
|
322
|
-
const envPrefix = (_k = options.envPrefix) !== null && _k !== void 0 ? _k : "AGENT_SERVE";
|
|
323
|
-
const apiKey = (_a = env.CURSOR_API_KEY) === null || _a === void 0 ? void 0 : _a.trim();
|
|
324
|
-
if (apiKey === undefined || apiKey === "") {
|
|
325
|
-
log("CURSOR_API_KEY missing; deployment event stream disabled");
|
|
326
|
-
return undefined;
|
|
327
|
-
}
|
|
328
|
-
const baseRaw = ((_l = env.CURSOR_API_BASE_URL) !== null && _l !== void 0 ? _l : DEFAULT_BASE_URL).trim();
|
|
329
|
-
const base = baseRaw.endsWith("/") ? baseRaw.slice(0, -1) : baseRaw;
|
|
330
|
-
// Loopback self-dispatch into this process's github channel route, single
|
|
331
|
-
// agent mounting assumed (multi-agent mounts need the slugged path via the
|
|
332
|
-
// env var override). Port resolution: explicit env override, then `PORT`,
|
|
333
|
-
// then the serve process's own `--port` argv (hosted-platform engines run
|
|
334
|
-
// `serve --port 26100` and export no PORT), then the :3000 default of the
|
|
335
|
-
// corp hosted image.
|
|
336
|
-
const selfUrl = ((_b = env[`${envPrefix}_SELF_WEBHOOK_URL`]) === null || _b === void 0 ? void 0 : _b.trim()) ||
|
|
337
|
-
`http://127.0.0.1:${((_c = env.PORT) === null || _c === void 0 ? void 0 : _c.trim()) ||
|
|
338
|
-
servePortFromArgv((_m = options.argv) !== null && _m !== void 0 ? _m : process.argv) ||
|
|
339
|
-
"3000"}/v1/channels/github`;
|
|
340
|
-
log(`self-dispatch url: ${selfUrl}`);
|
|
341
|
-
const stateDir = ((_d = env[`${envPrefix}_EVENTS_STATE_DIR`]) === null || _d === void 0 ? void 0 : _d.trim()) ||
|
|
342
|
-
join(process.cwd(), ".agent-serve", (_o = options.stateDirName) !== null && _o !== void 0 ? _o : "deployment-events");
|
|
343
|
-
const offsetStore = new OffsetStore(stateDir);
|
|
344
|
-
const abort = new AbortController();
|
|
345
|
-
// Transition aid: while the deployment still sets GITHUB_WEBHOOK_SECRET,
|
|
346
|
-
// the channel's auth is HMAC-only (allowAll + signature check), so sign
|
|
347
|
-
// the self-dispatch with it. Once the secret is removed from the env,
|
|
348
|
-
// the channel falls back to its loopback policy and the unsigned POST is
|
|
349
|
-
// admitted — either configuration works, so rollout order doesn't matter.
|
|
350
|
-
const webhookSecret = (_e = env.GITHUB_WEBHOOK_SECRET) === null || _e === void 0 ? void 0 : _e.trim();
|
|
351
|
-
function dispatch(envelope) {
|
|
352
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
353
|
-
var _a;
|
|
354
|
-
const body = JSON.stringify(envelopeToGitHubPayload(envelope));
|
|
355
|
-
const headers = {
|
|
356
|
-
"content-type": "application/json",
|
|
357
|
-
"x-github-event": envelope.eventName,
|
|
358
|
-
"x-github-delivery": envelope.deliveryId,
|
|
359
|
-
};
|
|
360
|
-
if (webhookSecret !== undefined && webhookSecret !== "") {
|
|
361
|
-
const signature = createHmac("sha256", webhookSecret)
|
|
362
|
-
.update(body)
|
|
363
|
-
.digest("hex");
|
|
364
|
-
headers["x-hub-signature-256"] = `sha256=${signature}`;
|
|
365
|
-
}
|
|
366
|
-
const response = yield doFetch(selfUrl, {
|
|
367
|
-
method: "POST",
|
|
368
|
-
headers,
|
|
369
|
-
body,
|
|
370
|
-
signal: AbortSignal.timeout(POLL_WAIT_MS),
|
|
371
|
-
});
|
|
372
|
-
void ((_a = response.body) === null || _a === void 0 ? void 0 : _a.cancel().catch(() => { }));
|
|
373
|
-
if (!response.ok) {
|
|
374
|
-
throw new Error(`self dispatch returned ${response.status}`);
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
function run() {
|
|
379
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
380
|
-
var _a;
|
|
381
|
-
var _b;
|
|
382
|
-
let after = (_b = (yield offsetStore.load())) !== null && _b !== void 0 ? _b : "$";
|
|
383
|
-
let backoffMs = MIN_BACKOFF_MS;
|
|
384
|
-
log(`pulling ${base}${EVENTS_PATH} (after=${after})`);
|
|
385
|
-
while (!abort.signal.aborted) {
|
|
386
|
-
let parsed;
|
|
387
|
-
try {
|
|
388
|
-
const query = new URLSearchParams({
|
|
389
|
-
after,
|
|
390
|
-
limit: String(POLL_LIMIT),
|
|
391
|
-
waitMs: String(POLL_WAIT_MS),
|
|
392
|
-
});
|
|
393
|
-
const response = yield doFetch(`${base}${EVENTS_PATH}?${query}`, {
|
|
394
|
-
headers: { authorization: `Bearer ${apiKey}` },
|
|
395
|
-
signal: AbortSignal.any([
|
|
396
|
-
abort.signal,
|
|
397
|
-
AbortSignal.timeout(POLL_WAIT_MS + 10000),
|
|
398
|
-
]),
|
|
399
|
-
});
|
|
400
|
-
if (!response.ok) {
|
|
401
|
-
void ((_a = response.body) === null || _a === void 0 ? void 0 : _a.cancel().catch(() => { }));
|
|
402
|
-
const authFailure = [401, 403, 404].includes(response.status);
|
|
403
|
-
log(`poll failed (${response.status}); backing off`);
|
|
404
|
-
yield delay(authFailure ? AUTH_FAILURE_BACKOFF_MS : backoffMs, abort.signal);
|
|
405
|
-
backoffMs = Math.min(backoffMs * 2, MAX_BACKOFF_MS);
|
|
406
|
-
continue;
|
|
407
|
-
}
|
|
408
|
-
parsed = parsePollResponse(yield response.json());
|
|
409
|
-
}
|
|
410
|
-
catch (error) {
|
|
411
|
-
if (abort.signal.aborted)
|
|
412
|
-
return;
|
|
413
|
-
log(`poll error (${error instanceof Error ? error.message : String(error)}); backing off`);
|
|
414
|
-
yield delay(backoffMs, abort.signal);
|
|
415
|
-
backoffMs = Math.min(backoffMs * 2, MAX_BACKOFF_MS);
|
|
416
|
-
continue;
|
|
417
|
-
}
|
|
418
|
-
backoffMs = MIN_BACKOFF_MS;
|
|
419
|
-
if (parsed.gapDetected) {
|
|
420
|
-
log("gap detected: some deliveries were trimmed before this consumer read them");
|
|
421
|
-
}
|
|
422
|
-
for (const entry of parsed.events) {
|
|
423
|
-
if (abort.signal.aborted)
|
|
424
|
-
return;
|
|
425
|
-
const envelope = parseAgentSdkScmEventEnvelope(entry.envelope);
|
|
426
|
-
if (envelope !== undefined) {
|
|
427
|
-
for (let attempt = 1; attempt <= DISPATCH_ATTEMPTS; attempt++) {
|
|
428
|
-
if (abort.signal.aborted)
|
|
429
|
-
return;
|
|
430
|
-
try {
|
|
431
|
-
yield dispatch(envelope);
|
|
432
|
-
log(`dispatched ${envelope.repo}#${envelope.pullRequest.number} (${envelope.action}, delivery=${envelope.deliveryId})`);
|
|
433
|
-
break;
|
|
434
|
-
}
|
|
435
|
-
catch (error) {
|
|
436
|
-
if (abort.signal.aborted)
|
|
437
|
-
return;
|
|
438
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
439
|
-
if (attempt === DISPATCH_ATTEMPTS) {
|
|
440
|
-
// Skip, don't wedge: the offset advances so one poison
|
|
441
|
-
// delivery cannot stall the stream.
|
|
442
|
-
log(`dispatch failed for ${envelope.deliveryId} after ${attempt} attempts: ${message}`);
|
|
443
|
-
break;
|
|
444
|
-
}
|
|
445
|
-
log(`dispatch attempt ${attempt} failed for ${envelope.deliveryId}: ${message}; retrying`);
|
|
446
|
-
yield delay(DISPATCH_RETRY_DELAYS_MS[Math.min(attempt - 1, DISPATCH_RETRY_DELAYS_MS.length - 1)], abort.signal);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
after = entry.offset;
|
|
451
|
-
yield offsetStore.save(after).catch(() => { });
|
|
452
|
-
}
|
|
453
|
-
if (parsed.events.length === 0 && parsed.nextOffset !== after) {
|
|
454
|
-
// "$" anchor resolution. An empty stream anchors at "" (read from
|
|
455
|
-
// the beginning), which is valid in-memory but not worth persisting
|
|
456
|
-
// (a restart re-anchors at "$" anyway).
|
|
457
|
-
after = parsed.nextOffset;
|
|
458
|
-
if (after !== "") {
|
|
459
|
-
yield offsetStore.save(after).catch(() => { });
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
const done = run().catch((error) => {
|
|
466
|
-
log(`loop crashed: ${error instanceof Error ? error.message : String(error)}`);
|
|
467
|
-
});
|
|
468
|
-
return {
|
|
469
|
-
stop: () => __awaiter(this, void 0, void 0, function* () {
|
|
470
|
-
abort.abort();
|
|
471
|
-
yield done;
|
|
472
|
-
}),
|
|
473
|
-
};
|
|
474
|
-
}
|