{"_id":"@arvoretech/pi-scheduler","name":"@arvoretech/pi-scheduler","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@arvoretech/pi-scheduler","version":"1.0.0","description":"PI extension that schedules prompts to run automatically (cron, one-time, interval) as headless pi sessions or appended to the session they were scheduled from","main":"dist/index.js","types":"dist/index.d.ts","type":"module","scripts":{"build":"tsc","dev":"tsc --watch","lint":"tsc --noEmit"},"dependencies":{"croner":"^9.0.0"},"peerDependencies":{"@earendil-works/pi-coding-agent":">=0.74.0"},"devDependencies":{"@earendil-works/pi-coding-agent":"latest","@earendil-works/pi-ai":"latest","@types/node":"^20.10.0","typescript":"^5.3.0"},"pi":{"extensions":["./dist/index.js"]},"keywords":["pi-package","pi","extension","scheduler","cron","automation","headless"],"repository":{"type":"git","url":"git+https://github.com/arvoreeducacao/arvore-pi-extensions.git","directory":"packages/scheduler"},"author":{"name":"Arvore"},"license":"MIT","gitHead":"322a1bffd2523ebba78dc68d9c35955b8c487399","_id":"@arvoretech/pi-scheduler@1.0.0","bugs":{"url":"https://github.com/arvoreeducacao/arvore-pi-extensions/issues"},"homepage":"https://github.com/arvoreeducacao/arvore-pi-extensions#readme","_nodeVersion":"26.1.0","_npmVersion":"11.13.0","dist":{"integrity":"sha512-Wztx19tF2hOsealUg1QomC7ANxzYs3rPjA6VHlrL0aq3GMqdTnHK4ZPTA/d394ti8TaMn5rXwO98cZadfs3yYQ==","shasum":"e21dbc04971c9acf2595ca17e4842305e3895caa","tarball":"https://registry.npmjs.org/@arvoretech/pi-scheduler/-/pi-scheduler-1.0.0.tgz","fileCount":26,"unpackedSize":95676,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDYeg+bD2g+rDnw/FmVQ6TjAEoMdp/Rtv8gXIuEulormQIhAOist7kCOktQzLdGNcGRtVVtwAxczWn67BWkZXmVh/YK"}]},"_npmUser":{"name":"ricardoraposorfox","email":"ricardorbxx1@gmail.com"},"directories":{},"maintainers":[{"name":"joao.barros.arvore","email":"joao.barros@arvore.com.br"},{"name":"rafsouza","email":"rafasouza@protonmail.com"},{"name":"pedro.adas","email":"pedro.adas@gmail.com"},{"name":"guilhermebs","email":"guilhermebscontact@gmail.com"},{"name":"ricardoraposorfox","email":"ricardorbxx1@gmail.com"},{"name":"jott4","email":"jvgcunha2002@gmail.com"},{"name":"vitor.piovezan","email":"vitor.piovezan@arvore.com.br"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pi-scheduler_1.0.0_1785247167165_0.48363775535759057"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-28T13:59:26.983Z","1.0.0":"2026-07-28T13:59:27.314Z","modified":"2026-07-28T13:59:27.690Z"},"maintainers":[{"name":"joao.barros.arvore","email":"joao.barros@arvore.com.br"},{"name":"rafsouza","email":"rafasouza@protonmail.com"},{"name":"pedro.adas","email":"pedro.adas@gmail.com"},{"name":"guilhermebs","email":"guilhermebscontact@gmail.com"},{"name":"ricardoraposorfox","email":"ricardorbxx1@gmail.com"},{"name":"jott4","email":"jvgcunha2002@gmail.com"},{"name":"vitor.piovezan","email":"vitor.piovezan@arvore.com.br"}],"description":"PI extension that schedules prompts to run automatically (cron, one-time, interval) as headless pi sessions or appended to the session they were scheduled from","homepage":"https://github.com/arvoreeducacao/arvore-pi-extensions#readme","keywords":["pi-package","pi","extension","scheduler","cron","automation","headless"],"repository":{"type":"git","url":"git+https://github.com/arvoreeducacao/arvore-pi-extensions.git","directory":"packages/scheduler"},"author":{"name":"Arvore"},"bugs":{"url":"https://github.com/arvoreeducacao/arvore-pi-extensions/issues"},"license":"MIT","readme":"# @arvoretech/pi-scheduler\n\nSchedule prompts to run automatically from within pi — like a cron job for your\nagent. Tasks fire as **headless pi sessions** or get **appended to the session\nthey were scheduled from**.\n\n## Schedule types\n\n- `cron` — 5 or 6-field cron expressions, e.g. `0 9 * * 1-5` (weekdays at 9am)\n- `once` — ISO timestamp or relative delay, e.g. `+10m`, `+2h`, `2026-08-01T09:00:00Z`\n- `interval` — fixed durations, e.g. `30s`, `5m`, `1h`, `1d`\n\n## Delivery modes\n\n- `new-session` — spawns `pi --print \"<prompt>\"` as a fresh, autonomous headless\n  session. Output is captured; non-zero exit or timeout marks the run as failed.\n- `origin-session` — spawns `pi --print --session <origin-session-id> \"<prompt>\"`,\n  appending the run to the session the task was scheduled from. If that session\n  is the one currently open in this process, the prompt is instead delivered\n  in-process as a follow-up user message (avoids two writers on the same\n  session file).\n\nScheduled prompts run non-interactively — write them self-contained, with all\ncontext and file paths included.\n\n## Usage\n\nAsk the agent in natural language (\"every weekday at 9am, check the deploy\nstatus\"), or manage tasks directly:\n\n- LLM tools: `scheduler_create`, `scheduler_list`, `scheduler_get`,\n  `scheduler_update`, `scheduler_delete`, `scheduler_run_now`\n- Slash command: `/cron status|list|get|run|enable|disable|delete`\n\nThe status line shows how many enabled tasks the scheduler is holding.\n\n## How it works\n\n- Tasks persist to `<dataDir>/tasks.json` (atomic writes), so they survive\n  restarts. `dataDir` defaults to `~/.pi/agent/scheduler`, overridable via\n  `PI_SCHEDULER_DATA_DIR`.\n- A PID-based file lock (`scheduler.lock`) ensures that when several pi\n  processes are open, only one fires tasks. The status line shows\n  `scheduler: idle (lock held elsewhere)` in the others.\n- Timers are process-local and `unref`'d: tasks only fire while a pi process\n  holding the lock is running. Missed runs during downtime are not caught up.\n- A task interrupted mid-run by a crash is marked as an error on the next\n  start (`lastStatus: running` at boot ⇒ \"Process was interrupted\").\n- `once` tasks auto-disable after firing. Run history keeps the last 25 runs.\n- Headless child runs get `PI_SCHEDULED_RUN=1` (plus\n  `PI_SCHEDULED_TASK_ID`/`PI_SCHEDULED_RUN_ID`); the extension does not start\n  the scheduler inside those children, so scheduled runs never nest.\n\n## Safety notes\n\n- `new-session` runs are fully autonomous — the child pi executes its prompt\n  with the tools available in print mode. Keep prompts scoped to what you\n  would let run unattended.\n- Default timeout is 30 minutes per run (`timeoutMs` on the task overrides);\n  timed-out children are SIGTERM'd, then SIGKILL'd after 5s.\n\n## Development\n\n```bash\npnpm install\npnpm build\n```\n","readmeFilename":"README.md","_rev":"1-3db6871adef19b0fa20597ae25fe6d1a"}