{
  "manifest": {
    "schemaVersion": 1,
    "sdkVersion": "0.1.0",
    "id": "example.screen-recorder",
    "version": "1.0.0",
    "name": "Screen recorder",
    "description": "Record a screen or window you choose in StillMade desktop and pass the saved media to your workflow.",
    "kind": "task",
    "runtime": "javascript",
    "license": "MIT",
    "provenance": {
      "notice": "MIT License\n\nCopyright (c) 2026 StillMade SDK contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and \nassociated documentation files (the \"Software\"), to deal in the Software without restriction, including \nwithout limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell \ncopies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the \nfollowing conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial \nportions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT \nLIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO \nEVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER \nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE \nUSE OR OTHER DEALINGS IN THE SOFTWARE.\n"
    },
    "platforms": {
      "phone": {
        "supported": false,
        "reason": "Recording requires the StillMade desktop app."
      },
      "browser": {
        "supported": false,
        "reason": "Recording requires the StillMade desktop app."
      },
      "desktop": {
        "supported": true
      }
    },
    "inputs": {
      "media": {
        "type": "video",
        "primary": true
      }
    },
    "outputs": {
      "media": {
        "type": "video",
        "primary": true
      }
    },
    "permissions": {
      "project": [],
      "desktop": [
        "screen.capture"
      ]
    },
    "ui": []
  },
  "code": "return {media: input.media};",
  "view": {
    "html": "<section><h2>Screen recorder</h2><p>Record in the desktop app. You choose when recording starts and stops.</p><div><button id=\"start\" type=\"button\">Start recording</button><button id=\"stop\" type=\"button\" disabled>Stop and use recording</button><button id=\"cancel\" type=\"button\" disabled>Cancel</button></div><p id=\"status\" role=\"status\">Ready to record. Device access requires your permission.</p></section>",
    "css": "section { padding: 1.5rem; } h2 { font-style: italic; font-weight: 400; } div { display: flex; flex-wrap: wrap; gap: .6rem; } button { border: 1px solid var(--border-tok); border-radius: 999px; padding: .7rem 1rem; background: var(--bg-elev-1); color: var(--fg); } button:disabled { opacity: .5; } p { color: var(--fg-muted); }",
    "javascript": "\nconst start=document.getElementById('start');\nconst stop=document.getElementById('stop');\nconst cancel=document.getElementById('cancel');\nconst status=document.getElementById('status');\nlet saved=null;\nconst controls=active=>{ start.disabled=active; stop.disabled=!active; cancel.disabled=!active; };\nstart.addEventListener('click',async()=>{\n start.disabled=true;\n try{ await StillMade.desktop('record.start',{kind:'screen'}); saved=null; controls(true); status.textContent='Recording. Press Stop to save and use it.'; }\n catch(error){controls(false);status.textContent=error.message;}\n});\nstop.addEventListener('click',async()=>{\n stop.disabled=true;cancel.disabled=true;\n try{\n  if(!saved)saved=(await StillMade.desktop('record.stop')).asset;\n  await StillMade.run({media:saved});\n  saved=null;controls(false);stop.textContent='Stop and use recording';status.textContent='Recording saved. Its video output is ready for the next Block.';\n }catch(error){stop.disabled=false;cancel.disabled=false;stop.textContent=saved?'Retry using recording':'Stop and use recording';status.textContent=error.message;}\n});\ncancel.addEventListener('click',async()=>{\n cancel.disabled=true;\n try{if(!saved)await StillMade.desktop('record.cancel');saved=null;controls(false);stop.textContent='Stop and use recording';status.textContent='Cancelled. Ready for a new recording.';}\n catch(error){controls(false);status.textContent=error.message;}\n});"
  },
  "tests": [
    {
      "name": "Passes the complete synthetic media reference to the next Block",
      "input": {
        "media": {
          "assetId": "sample-video",
          "versionId": "sample-v1",
          "kind": "video",
          "mime": "video/webm",
          "url": "https://example.com/sample.webm"
        }
      },
      "expected": {
        "media": {
          "assetId": "sample-video",
          "versionId": "sample-v1",
          "kind": "video",
          "mime": "video/webm",
          "url": "https://example.com/sample.webm"
        }
      }
    }
  ]
}