--- name: detach description: >- Run a task in the background and notify via Telegram when done. Subactions: detach (capture), list (pending/done), read (fetch result), archive (move done tasks out of sight). Triggers on: "detach", "background", "fire and forget", "list tasks", "result ", "archive tasks", "archive done tasks", "archive task". --- # Detach Four subactions: 1. **`detach`** (default) — capture a goal, write it to `workspace/tasks/inbox/`. A daemon runs the task in an isolated `nanobot agent` session and notifies the user via Telegram when done. 2. **`list`** — list pending and completed background tasks. 3. **`read`** — fetch and present the result of a completed task. 4. **`archive`** — move completed tasks from `done/` to `archive/` to keep the list clean. ## Rules - **Respond to the user in their own language** (auto-detect from their message) — this skill is written in English, but all user-facing messages adapt to the user's language. - **Do not** start solving a detached task yourself. Capture it and stop. --- ## Subaction: `detach` (capture) ### When NOT to use detach - Fast tasks (<1 min) — answer directly in chat. - **Reminders** ("remind me in an hour") — use the builtin `cron` tool. - **Recurring** tasks ("every day at 9") — use `cron` with `cron_expr` / `every_seconds`. ### Procedure (execute in this order, no need to wait for confirmation) #### 1. Identify channel and chat_id The system prompt's runtime context contains `Channel: ` and `Chat ID: `. Read both. If `Chat ID` is missing, see Failure handling. #### 2. Prepare slug, goal, and optional model - **Slug**: 3–5 words from the goal, kebab-case (`[a-z0-9-]` only). Example: "Research Qdrant vs Weaviate" → `qdrant-vs-weaviate`. - **Goal**: restate the goal so it is self-contained without chat history. State-oriented, bounded, with a clear deliverable. - **Model** (optional): only when the user explicitly names a model or preset for this task ("run it on kimi", "use the m3 model", "with glm"). Pass that spoken token verbatim as `--model ""` — the script fuzzy-matches it against the configured presets. If the user says nothing about a model, omit `--model` and the task runs on the agent default. #### 3. Create the task Run: ```bash exec skills/detach/scripts/create-task.py \ --goal "" \ --slug "" \ --channel "" \ --chat-id "" ``` Add `--constraint ""` for each extra constraint (optional). Add `--model ""` only when the user explicitly chose a model (see step 2). The script creates the task, ensures queue directories exist, and atomically moves the file into `tasks/inbox/` to trigger the daemon. #### 4. Confirm to the user Tell the user the task was queued — include the slug and the fetch hint (`result `). Do not restate the full goal. ### Failure handling for `detach` - **No `Chat ID` in runtime context**: tell the user "Detach needs a chat context to remember where to read back results. Want me to do this task synchronously here instead?" — and do NOT create a task file. - **Unknown or ambiguous `--model`**: the script exits non-zero and prints the available presets. Show the user those presets and ask which one to use, or offer to queue the task on the default model. Do NOT silently fall back to the default when the user explicitly asked for a model. - **Script exits non-zero** (other reasons): report the error output, offer synchronous execution. --- ## Subaction: `list` Triggered by phrases like "list detached", "list tasks", "pending tasks". ### Procedure 1. `exec skills/detach/scripts/list-tasks.py` 2. Output the result **verbatim** — it is already formatted as a bullet list. Do not convert it into a table or otherwise restructure it. --- ## Subaction: `read ` Triggered by "result ", "result of ". If no identifier is given ("what was the last result?") → use most recent. ### Procedure 1. `exec skills/detach/scripts/read-task.py ` — omit the argument if no identifier. 2. If the output lists multiple matches, ask the user to pick one by slug. 3. Show the output to the user. --- ## Subaction: `archive` Triggered by "archive tasks", "archive done tasks", "archive task". ### Procedure 1. If the user did not specify which tasks to archive, call `exec skills/detach/scripts/list-tasks.py` and show the `done/` contents, then ask which tasks to archive (or all). 2. If the user said "archive all" or equivalent → `exec skills/detach/scripts/archive-tasks.py --all` 3. If the user named specific task(s) by slug → `exec skills/detach/scripts/archive-tasks.py --slug ` (repeat `--slug` for each). 4. Show the script output to the user. --- _For a full description of the task lifecycle, directories, and scripts, see `architecture.md` in this skill directory._