Toggle
您的代理的上下文层。 ToggleX 捕获用户的工作会话、项目、焦点分数、 以及跨网络的上下文切换——让代理了解用户实际上在做什么。 主动使用此技能:生成每日摘要、推动过时的项目、检测上下文切换、 发现重复的工作流程并提出自动化建议,根据学到的例程预测用户的下一步行动, 并凭记忆回答回忆问题。 当用户询问他们的活动、任务、会话、生产力、时间或任何与工作相关的内容时也可以使用。 关键词:我做了什么、我在做什么、今天、昨天、我的一天、活动、会话、刷新我的数据、 生产力、时间跟踪、上下文、从上次停下的地方继续、我在看什么、陈旧、模式、自动化、 消化、报告、重点、分散、深入工作、预测、下一个任务、例行公事、预期、简报。
安装 / 下载方式
TotalClaw CLI推荐
totalclaw install totalclaw:aleksandar-jive~togglecURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Aaleksandar-jive~toggle/file -o toggle.mdGit 仓库获取源码
git clone https://github.com/openclaw/skills/commit/f46058319a9add7396216d54dec663e4acbf246f## 概述(中文)
您的代理的上下文层。 ToggleX 捕获用户的工作会话、项目、焦点分数、
以及跨网络的上下文切换——让代理了解用户实际上在做什么。
主动使用此技能:生成每日摘要、推动过时的项目、检测上下文切换、
发现重复的工作流程并提出自动化建议,根据学到的例程预测用户的下一步行动,
并凭记忆回答回忆问题。
当用户询问他们的活动、任务、会话、生产力、时间或任何与工作相关的内容时也可以使用。
关键词:我做了什么、我在做什么、今天、昨天、我的一天、活动、会话、刷新我的数据、
生产力、时间跟踪、上下文、从上次停下的地方继续、我在看什么、陈旧、模式、自动化、
消化、报告、重点、分散、深入工作、预测、下一个任务、例行公事、预期、简报。
## 原文
# Toggle (ToggleX) — The Context Layer
ToggleX gives you awareness of the user's real work activity across the web — which projects, how long, how focused, and what they left unfinished. Unlike skills that only know what the user tells you, Toggle knows what they *did*.
The script fetches raw JSON from the ToggleX API. **You are responsible for all intelligence on top of that data**: summarization, pattern detection, nudges, and automations.
> `{baseDir}` throughout this document refers to the root directory of this skill's installation (the folder containing this SKILL.md file). This is standard OpenClaw skill convention.
---
## Quick reference
| Action | Command |
|--------|---------|
| Fetch today | `python3 {baseDir}/scripts/toggle.py` |
| Fetch date range | `python3 {baseDir}/scripts/toggle.py --from-date YYYY-MM-DD --to-date YYYY-MM-DD` |
| Fetch + save to memory | `python3 {baseDir}/scripts/toggle.py --persist {baseDir}/../../memory` |
| Cron run (skip cron check) | `python3 {baseDir}/scripts/toggle.py --persist {baseDir}/../../memory --skip-cron-check` |
---
## Endpoint
```
https://ai-x.toggle.pro/public-openclaw/workflows
```
Operated by ToggleX (https://x.toggle.pro). Your `TOGGLE_API_KEY` is sent as an `x-openclaw-api-key` header. No other data is transmitted.
## Getting your API key
Get your `TOGGLE_API_KEY` from:
```
https://x.toggle.pro/new/clawbot-integration
```
Never paste the key into chat. Set it in OpenClaw config:
```json
{
"skills": {
"entries": {
"toggle": {
"apiKey": "your_key_here"
}
}
}
}
```
Or export in shell: `export TOGGLE_API_KEY=your_key_here`
---
## Interpreting the output
The script returns raw JSON. The top-level response looks like:
```json
{
"userId": "...",
"startDate": "YYYY-MM-DD",
"endDate": "YYYY-MM-DD",
"totalWorkflows": 44,
"totalDays": 1,
"workflowsByDate": {
"YYYY-MM-DD": [ ...workflow entries... ]
},
"summary": {
"totalContextSwitches": 0,
"totalDurationMinutes": 797
}
}
```
### Sample workflow entry
```json
{
"workflowId": "3cd901ef-b708-4869-8ce0-52364ce494e6",
"date": "2026-02-19",
"workflowType": "AI Image Generation Debugging, Toggle/OpenClaw Skill Configuration",
"workflowDescription": "The user began by browsing the OpenClaw GitHub repository...",
"primaryDomain": "github.com",
"secondaryDomains": "[\"http://127.0.0.1:18789/agents\",\"https://github.com/openclaw/openclaw\"]",
"productivityScore": "92.00",
"productivityNotes": "Reviewing the ClawHub documentation ensured correct skill file structure...",
"type": "WORK",
"startTime": "2026-02-19T10:49:12.253Z",
"endTime": "2026-02-19T11:34:27.809Z",
"duration": 1746.629,
"durationMinutes": 29,
"isBreakPeriod": false,
"isLeisure": false,
"isWork": true,
"sessionCount": 10,
"activeSessionCount": 10,
"projectTask": {
"id": "05f01090-...",
"name": "OpenClaw Environment: Gateway Configuration & Image Generation Skill Integration",
"goal": "Configure and validate the local OpenClaw environment...",
"isDone": false,
"context": "Local OpenClaw instance; GitHub repositories...",
"prompts": [
"What verification steps should I follow to confirm the config changes took effect?",
"How can I test the skill invocation through the OpenClaw chat interface?"
],
"project": {
"id": "ab576749-...",
"name": "Toggle Pro AI Chat Feature Development",
"description": "End-to-end development of AI Chat functionality...",
"isActive": true,
"summary": "The project currently reports 0 of 0 tasks completed..."
}
}
}
```
### Data type gotchas
- **`productivityScore` is a string** (e.g. `"92.00"`), not a number. Parse to float before comparing against thresholds.
- **`secondaryDomains` is a stringified JSON array**, not an actual array. Parse it with `JSON.parse()` if you need individual URLs.
- **`duration` is in seconds** (float). `durationMinutes` is a rounded integer approximation.
- **`projectTask` can be null** — some WORK entries have no project context. Always check before accessing nested fields.
- **Zero-duration entries exist** — some WORK entries have `duration: 0` and `durationMinutes: 0`. These are brief interactions (e.g. a single page view). Include them in sequence analysis but don't count them as substantial sessions.
- **`startTime` and `endTime` are UTC (ISO 8601)**. Convert to the user's local timezone before grouping by "today" or "yesterday" or displaying times. If the user's timezone is unknown, ask once and store in `state.yaml` under `timezone`.
### Key fields
| Field | Description |
|-------|-------------|
| `type` | `"WORK"`, `"BREAK"`, or `"LEISURE"` |
| `workflowType` | Short label for the session (e.g. "Build Investigation and Scripting") |
| `workflowDescription` | Detailed narrative of what the user did. **May contain raw URLs — do not echo these to the user unless asked.** Summarize in your own words. |
| `primaryDomain` | Main website/app (e.g. `"github.com"`, `"claude.ai"`, `"127.0.0.1"`) |
| `productivityScore` | `"0.00"` to `"100.00"` (string). **90+** = sharp, **70–89** = solid, **below 70** = fragmented |
| `startTime` / `endTime` | ISO 8601 UTC timestamps. `endTime` may equal `startTime` for instantaneous actions, or be null if ongoing. |
| `duration` | Session length in seconds (float) |
| `durationMinutes` | Rounded session length in minutes (int) |
| `projectTask.name` | Human-readable task description |
| `projectTask.goal` | What the user was trying to accomplish |
| `projectTask.prompts` | AI-generated follow-up questions relevant to the task. **Use these** — if the user asks "what should I do next on this project?", these are high-quality suggestions directly tied to their recent work. |
| `projectTask.project.name` | Parent project name — use for grouping and stale-project detection |
| `projectTask.project.summary` | Running project summary — useful for briefings and recall |
| `summary.totalContextSwitches` | API-provided count of context switches for the period. **Use this instead of calculating manually.** |
| `summary.totalDurationMinutes` | Total tracked time in minutes |
### Interpretation rules
- Focus on `type: "WORK"` entries; skip `BREAK` unless asked; mention `LEISURE` briefly if present
- Always sort entries by `startTime` — **the API does not return entries in chronological order**
- If `totalWorkflows` is 0, tell the user Toggle wasn't running or captured nothing for that period
- When summarizing, use `workflowType` as the headline and `workflowDescription` for detail — but **paraphrase the description**, don't dump it raw (it contains URLs, OAuth tokens, and internal paths)
---
## Error handling
The script exits with a non-zero code and prints to stderr on failure. Handle these cases:
| Error | Likely cause | What to tell the user |
|-------|-------------|----------------------|
| `HTTP error 401` | Invalid or expired API key | "Your Toggle API key isn't working. Get a new one at https://x.toggle.pro/new/clawbot-integration" |
| `HTTP error 403` | Insufficient permissions | "Your API key doesn't have the right permissions. Check your ToggleX integration settings." |
| `HTTP error 429` | Rate limited | "Toggle's API is rate-limiting requests. I'll try again in a few minutes." Implement exponential backoff: wait 1 min, then 2 min, then 5 min. Max 3 retries. Do not run the script more than once per 5 minutes. |
| `HTTP error 5xx` | ToggleX server issue | "ToggleX servers seem to be having issues. I'll try again shortly." |
| `Request failed` / timeout | Network issue | "Couldn't reach To