opencode-windows-scheduler 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/CHANGELOG.md +24 -1
  2. package/README.md +5 -5
  3. package/ROADMAP-STRATEGY.md +2 -2
  4. package/ROADMAP.md +31 -5
  5. package/dist/core/dry-run.d.ts +5 -1
  6. package/dist/core/dry-run.d.ts.map +1 -1
  7. package/dist/core/dry-run.js +20 -4
  8. package/dist/core/one-shot.d.ts +62 -0
  9. package/dist/core/one-shot.d.ts.map +1 -0
  10. package/dist/core/one-shot.js +126 -0
  11. package/dist/core/otel.d.ts +4 -0
  12. package/dist/core/otel.d.ts.map +1 -0
  13. package/dist/core/otel.js +98 -0
  14. package/dist/core/prometheus.d.ts +23 -0
  15. package/dist/core/prometheus.d.ts.map +1 -0
  16. package/dist/core/prometheus.js +146 -0
  17. package/dist/core/ps-wrapper.d.ts +6 -2
  18. package/dist/core/ps-wrapper.d.ts.map +1 -1
  19. package/dist/core/ps-wrapper.js +25 -3
  20. package/dist/core/record-history.d.ts.map +1 -1
  21. package/dist/core/record-history.js +9 -0
  22. package/dist/core/scheduler/linux.d.ts +12 -3
  23. package/dist/core/scheduler/linux.d.ts.map +1 -1
  24. package/dist/core/scheduler/linux.js +80 -3
  25. package/dist/core/scheduler/mac.d.ts.map +1 -1
  26. package/dist/core/scheduler/mac.js +17 -3
  27. package/dist/core/scheduler/posix.d.ts.map +1 -1
  28. package/dist/core/scheduler/posix.js +3 -0
  29. package/dist/core/scheduler/registry.d.ts +4 -0
  30. package/dist/core/scheduler/registry.d.ts.map +1 -1
  31. package/dist/core/scheduler/types.d.ts +5 -3
  32. package/dist/core/scheduler/types.d.ts.map +1 -1
  33. package/dist/core/scheduler/windows.d.ts.map +1 -1
  34. package/dist/core/scheduler/windows.js +10 -1
  35. package/dist/core/session.d.ts +34 -0
  36. package/dist/core/session.d.ts.map +1 -0
  37. package/dist/core/session.js +105 -0
  38. package/dist/core/structured-log.d.ts +84 -0
  39. package/dist/core/structured-log.d.ts.map +1 -0
  40. package/dist/core/structured-log.js +137 -0
  41. package/dist/core/wrappers/bash.d.ts +9 -0
  42. package/dist/core/wrappers/bash.d.ts.map +1 -1
  43. package/dist/core/wrappers/bash.js +27 -3
  44. package/dist/db/history-repo.d.ts.map +1 -1
  45. package/dist/db/history-repo.js +63 -6
  46. package/dist/db/metrics-repo.d.ts +3 -0
  47. package/dist/db/metrics-repo.d.ts.map +1 -1
  48. package/dist/db/metrics-repo.js +16 -8
  49. package/dist/db/migrate.d.ts.map +1 -1
  50. package/dist/db/migrate.js +8 -1
  51. package/dist/db/schema.d.ts +1 -1
  52. package/dist/db/schema.d.ts.map +1 -1
  53. package/dist/db/schema.js +8 -0
  54. package/dist/history.d.ts +7 -0
  55. package/dist/history.d.ts.map +1 -1
  56. package/dist/history.js +13 -0
  57. package/dist/index.d.ts +22 -3
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +330 -41
  60. package/dist/integrations.d.ts +64 -0
  61. package/dist/integrations.d.ts.map +1 -0
  62. package/dist/integrations.js +205 -0
  63. package/dist/rpc.d.ts +81 -4
  64. package/dist/rpc.d.ts.map +1 -1
  65. package/dist/rpc.js +43 -4
  66. package/dist/server.d.ts +2 -0
  67. package/dist/server.d.ts.map +1 -1
  68. package/dist/server.js +582 -70
  69. package/dist/settings.d.ts +38 -0
  70. package/dist/settings.d.ts.map +1 -1
  71. package/dist/settings.js +68 -0
  72. package/dist/shared/jobs-view.d.ts +43 -5
  73. package/dist/shared/jobs-view.d.ts.map +1 -1
  74. package/dist/shared/jobs-view.js +125 -7
  75. package/dist/task-transfer.d.ts +19 -3
  76. package/dist/task-transfer.d.ts.map +1 -1
  77. package/dist/task-transfer.js +75 -3
  78. package/docs/FEATURES.md +101 -4
  79. package/gui-experimental.cjs +4 -4
  80. package/package.json +11 -2
  81. package/scripts/demo-dashboard.mjs +12 -2
  82. package/src/core/dry-run.ts +24 -5
  83. package/src/core/one-shot.ts +173 -0
  84. package/src/core/otel.ts +128 -0
  85. package/src/core/prometheus.ts +215 -0
  86. package/src/core/ps-wrapper.ts +29 -3
  87. package/src/core/record-history.ts +13 -0
  88. package/src/core/scheduler/linux.ts +90 -3
  89. package/src/core/scheduler/mac.ts +35 -4
  90. package/src/core/scheduler/posix.ts +3 -0
  91. package/src/core/scheduler/registry.ts +4 -0
  92. package/src/core/scheduler/types.ts +5 -3
  93. package/src/core/scheduler/windows.ts +11 -1
  94. package/src/core/session.ts +115 -0
  95. package/src/core/structured-log.ts +205 -0
  96. package/src/core/wrappers/bash.ts +38 -2
  97. package/src/db/history-repo.ts +67 -7
  98. package/src/db/metrics-repo.ts +19 -7
  99. package/src/db/migrate.ts +7 -1
  100. package/src/db/schema.ts +11 -0
  101. package/src/gui.tsx +237 -18
  102. package/src/history.ts +17 -0
  103. package/src/index.ts +426 -47
  104. package/src/integrations.ts +253 -0
  105. package/src/rpc.ts +43 -4
  106. package/src/server.ts +622 -69
  107. package/src/settings.ts +122 -0
  108. package/src/shared/jobs-view.ts +158 -8
  109. package/src/task-transfer.ts +107 -5
  110. package/src/tui.tsx +290 -14
package/docs/FEATURES.md CHANGED
@@ -39,6 +39,61 @@ triggers. Expressions `schtasks` cannot express (`L`, `#`, complex lists) or tas
39
39
  with a timezone other than the system one are registered in poll mode: the OS task
40
40
  wakes the wrapper every minute and `schedule-gate` decides whether the agent runs.
41
41
 
42
+ ### One-shot runs
43
+
44
+ `triggerType: "once"` runs a task exactly once at a specific moment. Use either
45
+ `runAt` (ISO-8601, or a local date string such as `2026-11-13 22:40`) or
46
+ `delaySeconds` (delay from now):
47
+
48
+ ```json
49
+ {
50
+ "name": "deploy-once",
51
+ "triggerType": "once",
52
+ "runAt": "2026-11-13T22:40:00+03:00",
53
+ "prompt": "Deploy the current main branch."
54
+ }
55
+ ```
56
+
57
+ ```json
58
+ { "name": "remind-later", "triggerType": "once", "delaySeconds": 3600, "prompt": "..." }
59
+ ```
60
+
61
+ `runAt` wins when both are present. `schedule` is ignored. One-shot tasks are
62
+ registered natively (`schtasks /sc ONCE`, Linux `at`, macOS launchd cleanup
63
+ agent), are not repeated after a plugin restart, and cannot be combined with a
64
+
65
+ > **Windows locale note.** `schtasks /sd` only accepts dates in the format of the
66
+ > current Windows locale. The plugin emits `DD.MM.YYYY`, which matches Russian
67
+ > (and most European) locales. On a system with an English/US locale (`MM/DD/YYYY`)
68
+ > `schtasks` rejects the date, so one-shot tasks are not available there.
69
+ matrix.
70
+
71
+ ### Session continuity
72
+
73
+ Each scheduled run can either start a fresh OpenCode session (`new`, default),
74
+ reuse a persistent session stored on the task, or continue the latest session
75
+ (`last`, mapped to `opencode --continue`). Set `session` on the task; for
76
+ `reuse` a `sessionId` is auto-generated and stored with the task definition —
77
+ it is never accepted from user input or exported as plain text.
78
+
79
+ ```json
80
+ {
81
+ "name": "nightly-analyst",
82
+ "schedule": "0 3 * * *",
83
+ "session": "reuse",
84
+ "sessionMaxRuns": 10,
85
+ "prompt": "Refresh the analysis."
86
+ }
87
+ ```
88
+
89
+ - `session`: `new` (default), `reuse` (pass `--session <id>`), `last` (pass `--continue`).
90
+ - `sessionMaxRuns` (only for `reuse`): how many runs the reused session
91
+ survives before it is deleted (`opencode session delete`) and a fresh session
92
+ is started. Unset/0 means no limit.
93
+ - `sessionId` is per machine/profile. The internal run counter
94
+ (`sessionRunCount`) is never exported.
95
+ - Old export/import files without session fields import as `new`.
96
+
42
97
  ### Timezones and launch windows
43
98
 
44
99
  - `timezone` — IANA zone per task (e.g. `Europe/Moscow`). `nextRun`/`prevRun`,
@@ -266,7 +321,47 @@ per-day buckets (UTC), success rate, token-based cost estimate, top tasks by cos
266
321
  matrix and model breakdowns — is available through `get_analytics` /
267
322
  `GET /api/analytics` and the dashboard's «📊 Аналитика за период» block. History is
268
323
  pruned automatically (age and size limits, see Settings) and can be exported as
269
- CSV/JSON (`GET /api/history/export`).
324
+ CSV/JSON (`GET /api/history/export`), or as OTLP/JSON for OpenTelemetry
325
+ (`GET /api/history/export?format=otlp`).
326
+
327
+ ### Prometheus
328
+
329
+ `GET /metrics` exposes the Prometheus text format (0.0.4): `opencode_scheduler_info`,
330
+ `up`, `queue_depth`, `history_records`, `runs_total{task,status}`,
331
+ `errors_total{task}`, `tokens_total{task}`, `cost_usd_total{task}` and the
332
+ `run_duration_seconds` histogram (1 s … 3600 s + `+Inf`). `runs_total` has
333
+ separate `success`, `error` and `partial` statuses; `errors_total` counts only
334
+ errors and timeouts, so `partial` never inflates it. Values are read from
335
+ SQLite at scrape time, so no extra agent or exporter process is required.
336
+
337
+ ### Structured logs
338
+
339
+ Every run start/finish and every webhook decision is appended to
340
+ `<PLUGIN_DIR>/logs/runs.jsonl` (one JSON object per line, 10 MiB rotation to
341
+ `runs.jsonl.1`). `GET /api/logs` returns newest-first records and supports `task`,
342
+ `status`, `event`, `since`, `until`, `limit` and `format=jsonl`. The database
343
+ `history` table remains the source of truth for aggregates; JSONL is for log
344
+ shipping and debugging and never blocks a run if writing fails.
345
+
346
+ ### Incoming webhooks
347
+
348
+ `POST /api/hooks/:task?token=…` starts a task from GitHub Actions, GitLab CI or any
349
+ external system. The request must carry an HMAC-SHA256 of the raw body in
350
+ `X-Scheduler-Signature: sha256=<hex>` (GitHub's `X-Hub-Signature-256` and a bare
351
+ hex digest are also accepted). The token may instead come from `X-Scheduler-Token`
352
+ or `X-Gitlab-Token`. An optional `X-Scheduler-Timestamp` is checked against
353
+ `timestampToleranceSeconds`. Hooks are disabled by default; enabling them with empty
354
+ credentials generates a token and secret automatically. Errors: 401 (bad
355
+ token/signature/timestamp), 403 (channel disabled or credentials missing), 404
356
+ (unknown task), 413 (body over `maxBodyBytes`). The dashboard still binds to
357
+ localhost only, so external CI needs a tunnel or self-hosted runner.
358
+
359
+ ### OpenTelemetry
360
+
361
+ History can be exported as OTLP/JSON: one span per run, deterministic 32-hex
362
+ `traceId` and 16-hex `spanId`, nanosecond timestamps, task/status/duration/tokens/
363
+ cost/model/error attributes and OK/ERROR status. The output can be posted to an
364
+ OpenTelemetry Collector or inspected directly.
270
365
 
271
366
  ### Logs
272
367
 
@@ -366,9 +461,11 @@ plugin, no installation step required.
366
461
 
367
462
  ## Limits and non-goals
368
463
 
369
- - **No one-shot scheduling yet.** Only cron, file and MCP-event triggers exist; use
370
- `run_task_now` for immediate runs. A one-shot trigger is on the roadmap.
371
- - **No session continuity.** Every run starts a fresh `opencode run` session.
464
+ - **No one-shot scheduling without `triggerType: "once"`.** One-shot runs exist
465
+ via `runAt`/`delaySeconds`; use `run_task_now` for immediate runs.
466
+ - **No session continuity beyond the built-in `session` modes.** `new`, `reuse`
467
+ and `last` cover the common cases; per-message session forking/branching is
468
+ not supported.
372
469
  - **No sandbox.** Hooks, Quality Gates and prompts run with your user privileges.
373
470
  - **No authentication on the dashboard.** Localhost only by design.
374
471
  - **Secrets are not encrypted.** Use environment variables or an external secret