PicoBot/README.md
ooodc a3ae8acde5 feat: add DB-backed scheduler for heartbeat, delayed jobs, interval jobs, and cron jobs
- Add scheduler module with SQLite persistence
- Support schedule types: delay, interval, at, cron
- Support job kinds: internal_event, outbound_message
- Add scheduler_manage tool for runtime management
- Add session_cleanup internal event for expired sessions
- Update memory tool usage prompt for better context awareness
- Add chrono and cron dependencies
2026-04-22 20:32:18 +08:00

139 lines
4.1 KiB
Markdown

PicoBot
Skills (initial implementation)
Agent profile injection
PicoBot maintains a persistent agent profile file at ~/.picobot/agent/AGENT.md.
Behavior:
- The directory ~/.picobot/agent is created automatically when needed.
- If AGENT.md does not exist yet, PicoBot creates it with a default profile.
- When the active conversation is empty or has just been reset, AGENT.md is loaded as the first system message in the active history.
- After every configured number of user turns, PicoBot injects the latest AGENT.md content again before the next user message is appended.
Config:
- Set gateway.agent_prompt_reinject_every in ~/.picobot/config.json.
- Default value is 100.
- Set it to 0 to disable periodic reinjection.
This profile is persisted in session history, while the skills index system prompt is still injected dynamically by AgentLoop.
PicoBot now supports filesystem skills.
Skill discovery locations:
- Project skills: .picobot/skills/*/SKILL.md
- User skills: ~/.picobot/skills/*/SKILL.md
Minimal required SKILL.md format:
---
description: Summarize code architecture for Rust projects
---
Optional detailed instructions go here.
Notes:
- The only required frontmatter field is description.
- If name is missing, the folder name is used as the skill name.
- Invalid skill files are skipped with warning logs.
How it is injected:
- AgentLoop adds a system message containing the available skills list (name + description).
- The model can call tool skill_activate with {"name":"<skill-name>"}.
- PicoBot returns the skill body as tool output so the model can follow detailed instructions.
Skill management tool
PicoBot exposes a built-in tool named skill_manage for runtime skill administration.
PicoBot also exposes a read-only tool named skill_list for listing discovered skills without mutation.
Supported actions:
- list: List discovered skills
- get: Read one skill by name
- create: Create a skill under project or user scope
- update: Update description and/or body for an existing skill
- delete: Delete a skill directory
- reload: Re-scan skill directories and refresh the in-memory catalog
Defaults:
- scope defaults to project
- reload defaults to true for create, update, and delete
Example payloads:
skill_list takes no parameters.
{"action":"list"}
{"action":"create","scope":"project","name":"demo-skill","description":"Use when summarizing a Rust crate","body":"Step 1..."}
{"action":"update","scope":"project","name":"demo-skill","description":"Use when reviewing a Rust crate"}
{"action":"delete","scope":"project","name":"demo-skill"}
{"action":"reload"}
Config (optional)
Add skills in config.json:
{
"skills": {
"enabled": true,
"sources": ["project", "user"],
"max_index_chars": 4000,
"max_listed_skills": 32
}
}
Scheduler
PicoBot now includes a DB-backed scheduler for heartbeat, delayed jobs, interval jobs, one-shot absolute-time jobs, and cron jobs.
Current behavior:
- Scheduler runs as a background loop inside gateway lifecycle.
- Job definitions and runtime state are persisted in SQLite instead of JSON files.
- Supported schedule types: delay, interval, at, cron.
- Supported job kinds: internal_event, outbound_message.
- Built-in internal event: session_cleanup, used to clear expired in-memory channel sessions.
- Built-in management tool: scheduler_manage.
Config example:
{
"scheduler": {
"enabled": true,
"tick_resolution_ms": 1000,
"misfire_policy": "skip",
"jobs": [
{
"id": "session.cleanup",
"kind": "internal_event",
"schedule": {
"type": "interval",
"seconds": 300
},
"payload": {
"event": "session_cleanup"
}
},
{
"id": "daily.reminder",
"kind": "outbound_message",
"schedule": {
"type": "cron",
"expression": "0 9 * * *"
},
"target": {
"channel": "feishu",
"chat_id": "oc_xxx"
},
"payload": {
"content": "每日提醒"
}
}
]
}
}
Runtime management:
- Use scheduler_manage with action=list|get|put|delete|pause|resume.
- Jobs created by the tool are written into SQLite and picked up by the scheduler loop.
- Config-defined jobs are also synced into SQLite on startup.