_type: export
__export_format: 4
__export_source: insomnia.desktop
resources:
  # ── Workspace ──────────────────────────────────────
  - _id: wrk_hu_developer_bot
    _type: workspace
    name: hu-developer-bot
    description: API collection for hu-developer-bot service

  # ── Base Environment ───────────────────────────────
  - _id: env_base
    _type: environment
    parentId: wrk_hu_developer_bot
    name: Base
    data:
      base_url: ""
      jira_issue_key: SQDP-123
      parent_key: SQDP-3470
      assignee_email: cursor.bot@humand.co
      cursor_agent_id: bc_abc123
      repo_name: humand-main-api
      setup_task_id: ""
      pr_number: "42"
      comment_id: "2873224076"
      pr_branch: fix/SQDP-3480-test-pr
      pr_title: "[SQDP-3480] Test PR creation"
      pr_body: "Created via API for testing."
      pr_base: develop
      datadog_log_query: service:hu-agent
      slack_bot_token: xoxb-2674897455382-10640219161811-dl59R0XorN4QVY6O9XlZQHqU
      slack_channel_id: C0AKR1XLY11
      slack_thread_ts: "1234567890.123456"
      slack_message_ts: "1234567890.654321"
      slack_bot_user_id: U07XXXXXXXX

  # ── Sub-Environments ────────────────────────────────
  - _id: env_local
    _type: environment
    parentId: env_base
    name: Local
    data:
      base_url: http://localhost:3000/hu-agent

  - _id: env_prod
    _type: environment
    parentId: env_base
    name: Prod
    data:
      base_url: http://internal-private-services-1581368902.us-east-1.elb.amazonaws.com/hu-agent

  # ── Folders ────────────────────────────────────────
  - _id: fld_system
    _type: request_group
    parentId: wrk_hu_developer_bot
    name: System

  - _id: fld_jira
    _type: request_group
    parentId: wrk_hu_developer_bot
    name: Jira

  - _id: fld_repos
    _type: request_group
    parentId: wrk_hu_developer_bot
    name: Repos

  - _id: fld_cursor
    _type: request_group
    parentId: wrk_hu_developer_bot
    name: Cursor

  - _id: fld_datadog
    _type: request_group
    parentId: wrk_hu_developer_bot
    name: Datadog

  - _id: fld_github
    _type: request_group
    parentId: wrk_hu_developer_bot
    name: GitHub

  - _id: fld_pipeline
    _type: request_group
    parentId: wrk_hu_developer_bot
    name: Pipeline

  - _id: fld_reports
    _type: request_group
    parentId: wrk_hu_developer_bot
    name: Reports

  - _id: fld_slack
    _type: request_group
    parentId: wrk_hu_developer_bot
    name: Slack

  - _id: fld_pollers
    _type: request_group
    parentId: wrk_hu_developer_bot
    name: Pollers

  # ── System ─────────────────────────────────────────
  - _id: req_health
    _type: request
    parentId: fld_system
    name: Health Check
    method: GET
    url: "{{ _.base_url }}/health"

  - _id: req_metrics
    _type: request
    parentId: fld_system
    name: Metrics
    method: GET
    url: "{{ _.base_url }}/metrics"

  # ── Jira ───────────────────────────────────────────
  - _id: req_jira_issue
    _type: request
    parentId: fld_jira
    name: Get Issue Details
    method: GET
    url: "{{ _.base_url }}/api/jira/issue"
    parameters:
      - name: issueKey
        value: "{{ _.jira_issue_key }}"

  - _id: req_jira_search
    _type: request
    parentId: fld_jira
    name: Search Issues
    method: GET
    url: "{{ _.base_url }}/api/jira/search"
    parameters:
      - name: maxResults
        value: "20"
      - name: project
        value: SQDP
        disabled: true
      - name: issueType
        value: Bug
        disabled: true
      - name: excludeTypes
        value: "Dev Task"
        disabled: true
      - name: status
        value: "To Do"
        disabled: true
      - name: assignee
        value: agustin.deluca@humand.co
        disabled: true
      - name: reporter
        value: agustin.deluca@humand.co
        disabled: true
      - name: priority
        value: "High,Critical"
        disabled: true
      - name: labels
        value: "backend,urgent"
        disabled: true
      - name: component
        value: ""
        disabled: true
      - name: sprint
        value: "openSprints()"
        disabled: true
      - name: resolution
        value: Unresolved
        disabled: true
      - name: parent
        value: SQDP-100
        disabled: true
      - name: text
        value: "login error"
        disabled: true
      - name: createdAfter
        value: "2026-02-01"
        disabled: true
      - name: createdBefore
        value: "2026-02-28"
        disabled: true
      - name: updatedAfter
        value: "2026-02-20"
        disabled: true
      - name: updatedBefore
        value: ""
        disabled: true
      - name: orderBy
        value: "created DESC"
        disabled: true
      - name: jql
        value: 'project = SQDP AND issuetype = Bug AND status = "To Do" ORDER BY created DESC'
        disabled: true

  - _id: req_jira_projects
    _type: request
    parentId: fld_jira
    name: List Jira Projects (spaces)
    method: GET
    url: "{{ _.base_url }}/api/jira/projects"
    parameters:
      - name: startAt
        value: "0"
      - name: maxResults
        value: "50"

  - _id: req_jira_spaces
    _type: request
    parentId: fld_jira
    name: List Jira Spaces (alias for /projects)
    description: "Identical handler to /api/jira/projects; kept for naming consistency with other 'spaces' endpoints."
    method: GET
    url: "{{ _.base_url }}/api/jira/spaces"
    parameters:
      - name: startAt
        value: "0"
      - name: maxResults
        value: "50"

  - _id: req_jira_myself
    _type: request
    parentId: fld_jira
    name: Get Current User (myself)
    method: GET
    url: "{{ _.base_url }}/api/jira/myself"

  - _id: req_jira_user
    _type: request
    parentId: fld_jira
    name: Lookup User by Email
    method: GET
    url: "{{ _.base_url }}/api/jira/user"
    parameters:
      - name: email
        value: agustin.deluca@humand.co

  - _id: req_jira_webhook
    _type: request
    parentId: fld_jira
    name: Simulate Webhook
    method: POST
    url: "{{ _.base_url }}/jira/webhook"
    headers:
      - name: Content-Type
        value: application/json
    body:
      mimeType: application/json
      text: |
        {
          "webhookEvent": "jira:issue_updated",
          "issue": {
            "id": "10001",
            "key": "{{ _.jira_issue_key }}",
            "fields": {
              "issuetype": { "name": "Bug" },
              "status": { "name": "To Do" },
              "summary": "Login button not working on mobile",
              "description": null
            }
          }
        }

  - _id: req_jira_create_subtask
    _type: request
    parentId: fld_jira
    name: Create Subtask (body)
    method: POST
    url: "{{ _.base_url }}/api/jira/subtask"
    headers:
      - name: Content-Type
        value: application/json
    body:
      mimeType: application/json
      text: |
        {
          "parentKey": "{{ _.parent_key }}",
          "summary": "Backend | Fix segmentation AND logic",
          "assigneeEmail": "{{ _.assignee_email }}"
        }

  - _id: req_jira_comment
    _type: request
    parentId: fld_jira
    name: Add Comment
    method: POST
    url: "{{ _.base_url }}/api/jira/comment"
    headers:
      - name: Content-Type
        value: application/json
    body:
      mimeType: application/json
      text: |
        {
          "issueKey": "{{ _.jira_issue_key }}",
          "body": "This is a test comment from hu-developer-bot."
        }

  - _id: req_jira_transitions_list
    _type: request
    parentId: fld_jira
    name: List Transitions
    method: GET
    url: "{{ _.base_url }}/api/jira/transitions"
    parameters:
      - name: issueKey
        value: "{{ _.jira_issue_key }}"

  - _id: req_jira_transition
    _type: request
    parentId: fld_jira
    name: Transition Issue
    method: POST
    url: "{{ _.base_url }}/api/jira/transition"
    headers:
      - name: Content-Type
        value: application/json
    body:
      mimeType: application/json
      text: |
        {
          "issueKey": "{{ _.jira_issue_key }}",
          "targetStatus": "Done"
        }

  # ── Repos ──────────────────────────────────────────
  - _id: req_repos_list
    _type: request
    parentId: fld_repos
    name: List Repos
    method: GET
    url: "{{ _.base_url }}/api/repos"

  - _id: req_repos_match
    _type: request
    parentId: fld_repos
    name: Match Repo for Ticket
    method: POST
    url: "{{ _.base_url }}/api/repos/match"
    headers:
      - name: Content-Type
        value: application/json
    body:
      mimeType: application/json
      text: |
        {
          "summary": "Login button not working on mobile",
          "description": "Users report the login button on the React Native app is unresponsive on iOS 18. The app crashes with a null pointer in the auth module."
        }

  - _id: req_repos_check
    _type: request
    parentId: fld_repos
    name: Run Checks for Repo
    method: POST
    url: "{{ _.base_url }}/api/repos/check"
    headers:
      - name: Content-Type
        value: application/json
    body:
      mimeType: application/json
      text: |
        {
          "repo": "humand-backoffice",
          "install": true,
          "clean": false,
          "branch": "develop"
        }

  - _id: req_repos_setup
    _type: request
    parentId: fld_repos
    name: Setup Repo Environment
    description: "Launches an async setup task: clones repo, installs dependencies, and verifies critical modules. Returns a taskId immediately (202). Poll GET /api/repos/setup/:taskId for progress."
    method: POST
    url: "{{ _.base_url }}/api/repos/setup"
    headers:
      - name: Content-Type
        value: application/json
    body:
      mimeType: application/json
      text: |
        {
          "repo": "{{ _.repo_name }}",
          "branch": "develop",
          "clean": true
        }

  - _id: req_repos_setup_status
    _type: request
    parentId: fld_repos
    name: Get Setup Task Status
    description: "Poll the status of an async setup task. Returns steps completed so far, module verification, and biome config check. Status is running | completed | failed."
    method: GET
    url: "{{ _.base_url }}/api/repos/setup/{{ _.setup_task_id }}"

  - _id: req_repos_setup_list
    _type: request
    parentId: fld_repos
    name: List Setup Tasks
    description: "Lists every async setup task in memory, newest first. Optional `repo` query param filters by repo name."
    method: GET
    url: "{{ _.base_url }}/api/repos/setup"
    parameters:
      - name: repo
        value: "{{ _.repo_name }}"
        disabled: true

  - _id: req_repos_run_checks
    _type: request
    parentId: fld_repos
    name: Run Repo Check Scripts
    description: "Runs lint, tsc, test, and other check scripts defined in the repo's package.json. If no scripts are specified, auto-discovers relevant ones (lint, build, tsc, biome:*, test)."
    method: POST
    url: "{{ _.base_url }}/api/repos/run-checks"
    headers:
      - name: Content-Type
        value: application/json
    body:
      mimeType: application/json
      text: |
        {
          "repo": "{{ _.repo_name }}",
          "scripts": ["lint", "tsc:strict:diff"],
          "install": true
        }

  # ── Prompts ────────────────────────────────────────
  - _id: req_prompts_by_ticket
    _type: request
    parentId: fld_repos
    name: Get Prompt Jobs for Ticket
    description: "Lists all per-job directories for a given ticket, including whether a prompt.md exists and which asset files were saved."
    method: GET
    url: "{{ _.base_url }}/api/prompts/{{ _.jira_issue_key }}"

  - _id: req_prompts_latest_prompt
    _type: request
    parentId: fld_repos
    name: Get Latest Prompt for Ticket
    description: "Returns the raw prompt.md content from the most recent job directory for the given ticket."
    method: GET
    url: "{{ _.base_url }}/api/prompts/{{ _.jira_issue_key }}/latest/prompt"

  # ── Cursor ─────────────────────────────────────────
  - _id: req_cursor_models
    _type: request
    parentId: fld_cursor
    name: List Models
    method: GET
    url: "{{ _.base_url }}/api/cursor/models"

  - _id: req_cursor_agent
    _type: request
    parentId: fld_cursor
    name: Get Agent Details
    method: GET
    url: "{{ _.base_url }}/api/cursor/agents"
    parameters:
      - name: id
        value: "{{ _.cursor_agent_id }}"

  - _id: req_cursor_conversation
    _type: request
    parentId: fld_cursor
    name: Get Agent Conversation
    method: GET
    url: "{{ _.base_url }}/api/cursor/agents/conversation"
    parameters:
      - name: id
        value: "{{ _.cursor_agent_id }}"

  # ── Datadog ────────────────────────────────────────
  - _id: req_datadog_logs_15m
    _type: request
    parentId: fld_datadog
    name: Search Logs (last 15m)
    method: GET
    url: "{{ _.base_url }}/api/datadog/logs"
    parameters:
      - name: query
        value: "{{ _.datadog_log_query }}"
      - name: window
        value: "15m"
      - name: limit
        value: "50"
      - name: hideThinking
        value: "true"
        disabled: true

  - _id: req_datadog_logs_24h
    _type: request
    parentId: fld_datadog
    name: Search Logs (last 24h)
    method: GET
    url: "{{ _.base_url }}/api/datadog/logs"
    parameters:
      - name: query
        value: "{{ _.datadog_log_query }}"
      - name: window
        value: "24h"
      - name: limit
        value: "50"
      - name: hideThinking
        value: "true"
        disabled: true

  - _id: req_datadog_logs_range
    _type: request
    parentId: fld_datadog
    name: Search Logs (custom ISO range, max 24h)
    method: GET
    url: "{{ _.base_url }}/api/datadog/logs"
    parameters:
      - name: query
        value: "{{ _.datadog_log_query }}"
      - name: from
        value: "2026-03-25T00:00:00.000Z"
        disabled: true
      - name: to
        value: "2026-03-25T12:00:00.000Z"
        disabled: true
      - name: limit
        value: "50"
      - name: hideThinking
        value: "true"
        disabled: true

  - _id: req_datadog_logs_by_ticket
    _type: request
    parentId: fld_datadog
    name: Logs by Ticket Code
    method: GET
    url: "{{ _.base_url }}/api/datadog/logs/by-ticket"
    parameters:
      - name: ticketCode
        value: "{{ _.jira_issue_key }}"
      - name: window
        value: "24h"
      - name: limit
        value: "1000"
      - name: from
        value: "2026-03-25T00:00:00.000Z"
        disabled: true
      - name: to
        value: "2026-03-25T12:00:00.000Z"
        disabled: true
      - name: hideThinking
        value: "true"
        disabled: true

  # ── Connectivity ────────────────────────────────────
  - _id: req_connectivity
    _type: request
    parentId: wrk_hu_developer_bot
    name: Connectivity Check
    method: GET
    url: "{{ _.base_url }}/api/connectivity"

  # ── GitHub ─────────────────────────────────────────
  - _id: req_github_auth
    _type: request
    parentId: fld_github
    name: Test GitHub Auth
    method: GET
    url: "{{ _.base_url }}/api/github/auth"

  - _id: req_github_org_repos
    _type: request
    parentId: fld_github
    name: List Org Repos (API only)
    method: GET
    url: "{{ _.base_url }}/api/github/org-repos"
    parameters:
      - name: org
        value: HumandDev
      - name: git
        value: "true"
        disabled: true
        description: Enable to also run git ls-remote on each repo (slower)

  - _id: req_github_org_repos_git
    _type: request
    parentId: fld_github
    name: List Org Repos (with git access check)
    method: GET
    url: "{{ _.base_url }}/api/github/org-repos"
    parameters:
      - name: org
        value: HumandDev
      - name: git
        value: "true"

  - _id: req_github_pulls
    _type: request
    parentId: fld_github
    name: List PRs for Repo
    method: GET
    url: "{{ _.base_url }}/api/github/pulls"
    parameters:
      - name: repo
        value: "{{ _.repo_name }}"
      - name: branch
        value: ""
        disabled: true

  - _id: req_github_diff
    _type: request
    parentId: fld_github
    name: Get PR Diff
    method: GET
    url: "{{ _.base_url }}/api/github/pulls/diff"
    parameters:
      - name: repo
        value: "{{ _.repo_name }}"
      - name: pr
        value: "{{ _.pr_number }}"

  - _id: req_github_pr_comments
    _type: request
    parentId: fld_github
    name: Get PR Conversation Comments
    method: GET
    url: "{{ _.base_url }}/api/github/pulls/comments"
    parameters:
      - name: repo
        value: "{{ _.repo_name }}"
      - name: pr
        value: "{{ _.pr_number }}"
      - name: per_page
        value: "100"
        disabled: true
      - name: page
        value: "1"
        disabled: true

  - _id: req_github_pr_review_comments
    _type: request
    parentId: fld_github
    name: Get PR Review Comments (inline)
    method: GET
    url: "{{ _.base_url }}/api/github/pulls/review-comments"
    parameters:
      - name: repo
        value: "{{ _.repo_name }}"
      - name: pr
        value: "{{ _.pr_number }}"
      - name: per_page
        value: "100"
        disabled: true
      - name: page
        value: "1"
        disabled: true

  - _id: req_github_pr_review_comment_by_id
    _type: request
    parentId: fld_github
    name: Get PR Review Comment by ID
    method: GET
    url: "{{ _.base_url }}/api/github/pulls/review-comment"
    parameters:
      - name: repo
        value: "{{ _.repo_name }}"
      - name: commentId
        value: "{{ _.comment_id }}"

  - _id: req_github_pr_reviews
    _type: request
    parentId: fld_github
    name: Get PR Reviews
    method: GET
    url: "{{ _.base_url }}/api/github/pulls/reviews"
    parameters:
      - name: repo
        value: "{{ _.repo_name }}"
      - name: pr
        value: "{{ _.pr_number }}"
      - name: per_page
        value: "100"
        disabled: true
      - name: page
        value: "1"
        disabled: true

  - _id: req_github_create_pr
    _type: request
    parentId: fld_github
    name: Create PR
    method: POST
    url: "{{ _.base_url }}/api/github/pulls"
    headers:
      - name: Content-Type
        value: application/json
    body:
      mimeType: application/json
      text: |
        {
          "repo": "{{ _.repo_name }}",
          "branch": "{{ _.pr_branch }}",
          "title": "{{ _.pr_title }}",
          "body": "{{ _.pr_body }}",
          "base": "{{ _.pr_base }}"
        }

  # ── Pipeline ───────────────────────────────────────
  - _id: req_pipeline_fix
    _type: request
    parentId: fld_pipeline
    name: Fix Issue
    method: POST
    url: "{{ _.base_url }}/api/pipeline/fix"
    headers:
      - name: Content-Type
        value: application/json
    body:
      mimeType: application/json
      text: |
        {
          "issueKey": "{{ _.jira_issue_key }}"
        }

  - _id: req_pipeline_triage
    _type: request
    parentId: fld_pipeline
    name: Triage Issue
    method: POST
    url: "{{ _.base_url }}/api/pipeline/triage"
    headers:
      - name: Content-Type
        value: application/json
    body:
      mimeType: application/json
      text: |
        {
          "issueKey": "{{ _.jira_issue_key }}"
        }

  - _id: req_pipeline_trigger
    _type: request
    parentId: fld_pipeline
    name: Trigger Fix Pipeline
    method: POST
    url: "{{ _.base_url }}/api/pipeline/trigger"
    headers:
      - name: Content-Type
        value: application/json
    body:
      mimeType: application/json
      text: |
        {
          "issueKey": "{{ _.jira_issue_key }}"
        }

  # ── Reports ─────────────────────────────────────────
  - _id: req_reports_daily
    _type: request
    parentId: fld_reports
    name: Daily Report (Jira por equipo + PRs)
    method: GET
    url: "{{ _.base_url }}/api/reports/daily"
    parameters:
      - name: skip_slack
        value: "true"
        disabled: true

  # ── Slack ───────────────────────────────────────────
  - _id: req_slack_usergroups
    _type: request
    parentId: fld_slack
    name: List Slack Usergroups
    method: GET
    url: "{{ _.base_url }}/api/slack/usergroups"

  # ── Slack API (mention polling) ────────────────────
  - _id: req_slack_bot_channels
    _type: request
    parentId: fld_slack
    name: "List Bot Channels (users.conversations)"
    description: "Lists all channels the bot has joined. Used by SlackMentionPoller to discover which channels to poll."
    method: GET
    url: "https://slack.com/api/users.conversations"
    headers:
      - name: Authorization
        value: "Bearer {{ _.slack_bot_token }}"
    parameters:
      - name: types
        value: "public_channel,private_channel"
      - name: exclude_archived
        value: "true"
      - name: limit
        value: "200"

  - _id: req_slack_channel_history
    _type: request
    parentId: fld_slack
    name: "Fetch Channel History (conversations.history)"
    description: "Fetches recent messages from a channel. Used by SlackMentionPoller to find top-level mentions."
    method: GET
    url: "https://slack.com/api/conversations.history"
    headers:
      - name: Authorization
        value: "Bearer {{ _.slack_bot_token }}"
    parameters:
      - name: channel
        value: "{{ _.slack_channel_id }}"
      - name: limit
        value: "50"
      - name: oldest
        value: ""
        disabled: true

  - _id: req_slack_thread_replies
    _type: request
    parentId: fld_slack
    name: "Fetch Thread Replies (conversations.replies)"
    description: "Fetches all replies in a thread. Used by SlackMentionPoller to detect in-thread mentions and check if the bot already replied."
    method: GET
    url: "https://slack.com/api/conversations.replies"
    headers:
      - name: Authorization
        value: "Bearer {{ _.slack_bot_token }}"
    parameters:
      - name: channel
        value: "{{ _.slack_channel_id }}"
      - name: ts
        value: "{{ _.slack_thread_ts }}"
      - name: limit
        value: "100"

  - _id: req_slack_post_reply
    _type: request
    parentId: fld_slack
    name: "Reply in Thread (chat.postMessage)"
    description: "Posts a reply in a thread. Used by SlackMentionPipeline to send the bot's response back to the thread where it was mentioned."
    method: POST
    url: "https://slack.com/api/chat.postMessage"
    headers:
      - name: Authorization
        value: "Bearer {{ _.slack_bot_token }}"
      - name: Content-Type
        value: "application/json; charset=utf-8"
    body:
      mimeType: application/json
      text: |
        {
          "channel": "{{ _.slack_channel_id }}",
          "thread_ts": "{{ _.slack_thread_ts }}",
          "text": "Hello from hu-developer-bot!"
        }

  # ── Pollers (manual on-demand triggers) ────────────
  # In dev mode (NODE_ENV != production) all pollers and the daily-report
  # scheduler are force-disabled. Use these endpoints to run a single tick on
  # demand. Also useful in prod to skip the next interval wait.

  - _id: req_pollers_jira_tick
    _type: request
    parentId: fld_pollers
    name: "Tick Jira poller"
    description: "Runs JiraPoller.poll() once. Returns { ok, poller, enqueued }."
    method: POST
    url: "{{ _.base_url }}/api/pollers/jira/tick"

  - _id: req_pollers_jira_ticket_review_tick
    _type: request
    parentId: fld_pollers
    name: "Tick Jira ticket-review poller"
    description: "Runs JiraTicketReviewPoller.poll() once. Returns { ok, poller, enqueued }."
    method: POST
    url: "{{ _.base_url }}/api/pollers/jira-ticket-review/tick"

  - _id: req_pollers_pr_comment_tick
    _type: request
    parentId: fld_pollers
    name: "Tick PR comment poller"
    description: "Runs PrCommentPoller.poll() once. Returns { ok, poller, enqueued }."
    method: POST
    url: "{{ _.base_url }}/api/pollers/pr-comment/tick"

  - _id: req_pollers_pr_mention_tick
    _type: request
    parentId: fld_pollers
    name: "Tick PR mention poller"
    description: "Runs PrMentionPoller.poll() once. Returns { ok, poller, enqueued }."
    method: POST
    url: "{{ _.base_url }}/api/pollers/pr-mention/tick"

  - _id: req_pollers_slack_mention_tick
    _type: request
    parentId: fld_pollers
    name: "Tick Slack mention poller"
    description: "Runs SlackMentionPoller.poll() once. Returns 503 if slack-mention deps (SLACK_BOT_TOKEN + SLACK_BOT_USER_ID) are not set."
    method: POST
    url: "{{ _.base_url }}/api/pollers/slack-mention/tick"

  - _id: req_scheduler_daily_report_run
    _type: request
    parentId: fld_pollers
    name: "Run daily-report scheduler now"
    description: "Calls DailyReportScheduler.triggerNow(). Returns 503 if daily-report scheduler is not initialized (e.g. SLACK_BOT_TOKEN missing or DAILY_REPORT_ENABLED=false)."
    method: POST
    url: "{{ _.base_url }}/api/scheduler/daily-report/run"
