Widgets

From SkillfulAgents/SuperAgent · View interactive version

Widgets is an AI agent skill from the GitHub repository SkillfulAgents/SuperAgent. Give an artifact a small glanceable home-screen widget (one number, next event, a few KPIs) that refreshes itself from a script

How to use this skill

Skill file

Building Widgets

A widget is a small card on the user's home screens — the agent's home page, the app home, and the companion iOS app's home screen. It answers one question at a glance (what's next, how am I doing today, is the number up or down) and keeps itself fresh without a conversation: a script you write re-generates it, and the platform renders it everywhere.

Widgets belong to artifacts. An artifact under /workspace/artifacts/<slug>/ is one unit that can expose a dashboard (a start script — a destination the user opens), a widget (a gamut.widget block and usually a widget script — a glance), or both. A dashboard with a widget shows the widget in place of its screenshot on the home page, and tapping the widget opens the dashboard. A widget-only artifact is just the glance.

Build a widget when the user wants to keep an eye on something; build a dashboard when they want to explore it; give a dashboard a widget when they want both.

Tools

How it works

/workspace/artifacts/<slug>/
├── package.json      # scripts.widget (+ scripts.start if it's also a dashboard), gamut.widget config
├── widget.ts         # what scripts.widget runs: rewrites widget.html and widget.json
├── widget.html       # THE SNAPSHOT: self-contained, responsive, data baked in
├── widget.json       # written by the script: { "validUntil": ISO | null }
├── widget.log        # script output from each refresh
└── snapshots/        # platform-owned PNG renders + snapshot.json (never edit)
  1. You write widget.html (the look) and widget.ts (the data, and how long it stays true).
  2. A refresh runs bun run widget inside this container — the same way the dashboard half runs bun run start — with your secrets and connected accounts available, then rasterizes widget.html into light/dark PNGs for every size.
  3. The platform shows the snapshot instantly wherever the user looks and re-runs the script once validUntil has passed and the user opens the agent's page, after each of your runs, or when the user taps refresh. Nothing runs on a timer while nobody is looking.
  4. If the script fails on one of those refreshes, when no conversation is running, the platform opens an automated session that hands you the error and the log and asks you to fix it. Nobody is waiting in that session — fix the script, refresh_widget to confirm, and only ask the user something if the fix genuinely needs their decision.

A widget with no scripts.widget is static: it only changes when you rewrite widget.html during a run (e.g. "log lunch" → you update the macros widget yourself). Use withScript: false for those.

Quick start

  1. create_widget — with an existing dashboard's slug to attach, or a new slug for a standalone widget (add refreshOnTurnEnd: true if it tracks something you change in conversation)
  2. Edit widget.ts: replace loadData() with the real source (API, file under /workspace, connected account, or the dashboard's own data helpers) and return a real validUntil
  3. Edit widget.html if the template's label / value / detail layout doesn't fit
  4. refresh_widget — look at the returned light and dark renders; iterate until both read at a glance and there are no warnings
  5. Tell the user what the widget shows and when it refreshes

Manifest

{
  "name": "Nutrition",
  "description": "Meals, macros and targets",
  "scripts": {
    "start": "bun run serve.js",
    "widget": "bun run widget.ts"
  },
  "gamut": {
    "widget": { "size": "small", "timeoutSeconds": 30, "refreshOnTurnEnd": false }
  }
}

Each half of an artifact is a named script: start serves the dashboard, widget regenerates the snapshot. gamut.widget is the marker that says this artifact has a widget at all, plus the settings the platform needs:

The refresh script contract

The refresh runs bun run widget, so scripts.widget is whatever command builds the snapshot — bun run widget.ts from the template, but python3 -m tools.build or a chain with flags works just as well. It runs with cwd = the artifact directory, env WIDGET_SLUG, WIDGET_DIR, WIDGET_OUTPUT (absolute path to widget.html), WIDGET_META (absolute path to widget.json), plus everything in the agent's own environment (.env secrets, connected-account tokens, PROXY_BASE_URL). Read PROXY_BASE_URL and PROXY_TOKEN from that environment when the script runs, and never paste their values into it: your shell's PROXY_BASE_URL belongs to your current session, and the refresh is given its own.

null means "never on its own" (only a rewrite changes it). If you don't write the file the platform assumes one hour and refresh_widget warns you.

Writing the HTML

The snapshot is displayed with scripts disabled and a strict CSP: inline <style> and data: images only. Anything that needs JavaScript at display time will not work — do the work in widget.ts instead. JavaScript inside widget.ts is unrestricted.

Review checklist (every `refresh_widget`)

Look at the returned images — do not assume the HTML you wrote renders the way you pictured it.

Common failures

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.