github-webhook-rule.mjs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import z from '@deepseek-ai/schemastery'
  2. import { WebhookRuleId } from '@deepseek-ai/dsh-webhook'
  3. export const name = 'github-webhook-real-e2e-rule'
  4. export const inject = ['webhookRuntime']
  5. export const Config = z.object({
  6. source: z.string().required(),
  7. repository: z.string().required(),
  8. workspacePath: z.string().required(),
  9. marker: z.string().required(),
  10. agentPreset: z.string().required(),
  11. permissionPreset: z.string().required(),
  12. })
  13. export function apply(ctx, config) {
  14. ctx.effect(() => ctx.webhookRuntime.register({
  15. id: WebhookRuleId('github-real-e2e'),
  16. kind: 'github',
  17. run(delivery, signal) {
  18. if (delivery.source !== config.source) return null
  19. if (delivery.event.name !== 'pull_request') return null
  20. const { payload } = delivery.event
  21. if (payload.action !== 'ready_for_review') return null
  22. if (payload.repository?.full_name !== config.repository) return null
  23. signal.throwIfAborted()
  24. return {
  25. workspacePath: config.workspacePath,
  26. title: 'GitHub webhook real e2e',
  27. prompt: `Reply with exactly ${config.marker} and no other text. Do not call tools.`,
  28. agentPreset: config.agentPreset,
  29. permissionPreset: config.permissionPreset,
  30. }
  31. },
  32. }))
  33. }