{
  "$schema": "../../oss/scenecast/schemas/scene-blueprint-v1.json",
  "version": 1,
  "id": "scn_daily_brief",
  "slug": "daily-brief",
  "name": "Daily Sales Brief",
  "icon": "chart.line.uptrend.xyaxis",
  "tint": "#6366F1",
  "settings": {
    "description": "Every weekday morning, the agent diffs the Sales Pipeline against yesterday, decides which changes are material, writes a brief, and emails it to the team. The scene IS the pipeline: edit a deal and re-run to see the brief catch it."
  },
  "inputs": {
    "team_email": {
      "type": "string",
      "required": true,
      "description": "Where the daily brief is sent (e.g. 'team@acme.com')."
    }
  },
  "assets": [
    {
      "id": "intro",
      "type": "daslab/note",
      "name": "About this brief",
      "fields": {
        "content": "# Daily Sales Brief\n\nEach weekday at **08:00 UTC**, the agent:\n\n1. reads the **Sales Pipeline** below\n2. compares it to the state in the most recent **Daily Brief**\n3. decides which changes are *material to the team* (new deals, stage moves, big value changes, closed-won / lost) — and ignores noise\n4. writes the brief into **Daily Brief**\n5. emails it to `${inputs.team_email}`\n\nThe pipeline is just a scene asset — edit a deal and run **brief-now** to watch the brief catch the change.\n\n## Try\n- *\"Run the brief now.\"*\n- *\"Mark the Globex deal closed-won and re-run the brief.\"*\n- *\"What changed since the last brief?\"*"
      },
      "layout": {
        "sortOrder": 0,
        "size": "medium"
      }
    },
    {
      "id": "pipeline",
      "type": "daslab/note",
      "name": "Sales Pipeline",
      "fields": {
        "content": "| Company | Stage | Value | Owner |\n|---|---|---|---|\n| Globex | Proposal | $48k | Dana |\n| Initech | Discovery | $12k | Sam |\n| Soylent | Negotiation | $90k | Dana |\n| Umbrella | Discovery | $7k | Priya |\n| Hooli | Proposal | $150k | Sam |"
      },
      "layout": {
        "sortOrder": 1,
        "size": "large"
      }
    },
    {
      "id": "brief",
      "type": "daslab/note",
      "name": "Daily Brief",
      "fields": {
        "content": "_Not yet run. Use the **brief-now** task, or wait for the next 08:00 UTC weekday run. The first run establishes the baseline; subsequent runs report the diff._"
      },
      "layout": {
        "sortOrder": 2,
        "size": "xlarge"
      }
    }
  ],
  "linkedAssets": [
    {
      "slot": "email_acct",
      "accepts": "google/account",
      "layout": {
        "sortOrder": 98,
        "size": "icon"
      }
    }
  ],
  "schedules": [
    {
      "id": "weekday-brief",
      "title": "Weekday sales brief · 08:00 UTC",
      "cron": "0 8 * * 1-5",
      "prompt": "Produce the daily sales brief.\n\n1. Read the **Sales Pipeline** note (the current state).\n2. Read the most recent **Daily Brief** note. The 'Pipeline snapshot' block at the end of it is yesterday's state. If the brief is still the placeholder, this is the BASELINE run — there is no prior state to diff.\n3. Identify which changes are MATERIAL to the team and ignore noise. Material = new deal, stage change, owner change, value change >20%, or closed-won/closed-lost. Cosmetic edits (whitespace, reordering) are NOT material.\n4. Use daslab_note_write to replace the **Daily Brief** note. Format:\n   - `# Sales Brief — <today YYYY-MM-DD>`\n   - a short bulleted list of the material changes (or 'No material changes since the last brief.')\n   - a one-line summary (total pipeline value, # deals, # closed this period)\n   - a fenced `Pipeline snapshot` block containing the CURRENT pipeline table verbatim, so the next run can diff against it.\n5. Email the brief body to ${inputs.team_email} via gmail_send (subject: 'Daily Sales Brief — <today>'). Skip the email only on the baseline run if there are no changes to report.\n\nDo not invent deals. Only report what is in the pipeline note.",
      "assetIds": [
        "pipeline",
        "brief"
      ],
      "enabled": true,
      "checks": [
        {
          "op": "contains",
          "path": "brief.content",
          "substring": "Pipeline snapshot",
          "ci": false,
          "why": "The brief must carry the snapshot block so the next run can diff — proves a real brief, not a placeholder."
        },
        {
          "op": "lte",
          "path": "$run.cost_usd",
          "value": 0.2,
          "expose": true,
          "severity": "fail",
          "why": "Daily brief budget cap."
        }
      ]
    }
  ],
  "tasks": [
    {
      "id": "brief-now",
      "name": "Run the sales brief now",
      "prompt": "Run the weekday sales brief now. Same instructions as the scheduled run: read the Sales Pipeline, diff against the snapshot in the last Daily Brief, report material changes only, rewrite the Daily Brief note (including a fresh `Pipeline snapshot` block), and email it to ${inputs.team_email}. If the date already matches today, overwrite with fresh state.",
      "initialState": {},
      "tools": {
        "expected": [
          "daslab_note_write",
          "gmail_send"
        ]
      },
      "checks": [
        {
          "op": "contains",
          "path": "brief.content",
          "substring": "Sales Brief",
          "ci": false,
          "why": "Proves the agent wrote a real brief."
        },
        {
          "op": "lte",
          "path": "$run.cost_usd",
          "value": 0.2,
          "expose": true,
          "severity": "fail",
          "why": "Task budget cap."
        }
      ]
    }
  ],
  "members": [
    {
      "email": "labhausxyz@gmail.com",
      "role": "owner"
    }
  ],
  "meta": {
    "author": "Daslab",
    "license": "MIT",
    "source": "blueprint demo — bind --input team_email=you@example.com, connect a Google account via the placeholder tile."
  }
}
