@x-otto/schedule 0.1.0-alpha.43 → 0.3.0-beta.0

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.
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@x-otto/schedule",
3
- "version": "0.1.0-alpha.43",
3
+ "version": "0.3.0-beta.0",
4
+ "description": "会话级定时投递:at/after/every + session 事件持久化 + 冷启动 fold",
4
5
  "files": [
5
6
  "dist"
6
7
  ],
@@ -14,25 +15,15 @@
14
15
  }
15
16
  },
16
17
  "dependencies": {
17
- "@x-otto/interchange": "0.1.0-alpha.43",
18
- "@x-otto/env": "0.1.0-alpha.43",
19
- "@x-otto/runtime": "0.1.0-alpha.43",
20
- "@x-otto/persistence": "0.1.0-alpha.43"
18
+ "@x-otto/atomic-fs": "^0.3.0-beta.0",
19
+ "@x-otto/hooks": "^0.3.0-beta.0",
20
+ "@x-otto/kernel": "^0.3.0-beta.0",
21
+ "@x-otto/shared": "^0.3.0-beta.0",
22
+ "@x-otto/tool-schema": "^0.3.0-beta.0",
23
+ "@x-otto/universal": "^0.3.0-beta.0"
21
24
  },
22
- "devDependencies": {
23
- "typescript": "6.0.2",
24
- "vitest": "^3.2.4"
25
- },
26
- "private": false,
27
25
  "publishConfig": {
28
26
  "access": "public",
29
- "registry": "https://registry.npmjs.org",
30
- "tag": "alpha"
31
- },
32
- "scripts": {
33
- "build": "tsdown",
34
- "typecheck": "tsc --noEmit",
35
- "test": "vitest run",
36
- "clean": "rm -rf dist"
27
+ "tag": "beta"
37
28
  }
38
- }
29
+ }
package/README.md DELETED
@@ -1,95 +0,0 @@
1
- # @x-otto/schedule
2
-
3
- > A scheduled task system — cron expression parsing, task persistence, ticker-driven recurring/one-shot task execution, and multi-process fire-ownership arbitration.
4
-
5
- `@x-otto/schedule` provides complete lifecycle management for scheduled tasks: create a cron task → persist to
6
- disk/remote → ticker heartbeat trigger → agent job dispatch → retry/circuit-break → logging. Supports two fire
7
- ownership modes: local O_EXCL locking and remote HTTP leasing.
8
-
9
- ## Core Features
10
-
11
- | Module | Function |
12
- |------|------|
13
- | `SchedulerService` | Scheduler core: ticker loop, fire execution, retry, cancel |
14
- | `ScheduleRegistry` | In-memory task registry (Map-backed CRUD + findDue) |
15
- | `createScheduleStore` | Task persistence (local file / remote HTTP) |
16
- | `parseCron` | 5-field cron expression parser (DST-safe) |
17
- | `FireOwnership` | Multi-process fire lock arbitration (local O_EXCL / remote lease) |
18
- | `createScheduleCapability` | schedule_* capability bindings for model tool consumption |
19
-
20
- ## Installation
21
-
22
- ```bash
23
- pnpm add @x-otto/schedule
24
- ```
25
-
26
- ## Quick Start
27
-
28
- ```ts
29
- import { SchedulerService, createScheduleStore, createLocalFireOwnership, ScheduleRegistry, parseCron } from '@x-otto/schedule'
30
- import type { AgentJobRegistry } from '@x-otto/runtime'
31
-
32
- const registry = new ScheduleRegistry()
33
- const store = createScheduleStore('ws_xxxx')
34
- const ownership = createLocalFireOwnership('ws_xxxx')
35
- const scheduler = new SchedulerService({
36
- registry,
37
- store,
38
- ownership,
39
- jobRegistry,
40
- startJob: ({ title, prompt, sessionId, origin }) => jobRegistry.start({ title, prompt, sessionId, origin }),
41
- getSessionId: () => 'current-session-id',
42
- })
43
-
44
- await scheduler.start() // load tasks + start ticker (only starts if this process is the fire owner)
45
- scheduler.add({ name: 'daily-digest', prompt: 'send daily summary', recurring: true, cronExpression: '0 9 * * 1-5', origin: 'user' })
46
- scheduler.list() // all tasks, sorted by nextFireAt ascending
47
- scheduler.runNow('task-id') // run immediately
48
- scheduler.cancel('task-id') // cancel a currently running task
49
- await scheduler.stop() // stop the ticker + release the lock
50
- ```
51
-
52
- ## Directory Overview
53
-
54
- ```
55
- src/
56
- types.ts # ScheduledTask / ScheduledTaskInput / ScheduleSubscriber
57
- cron-parser.ts # 5-field cron parser
58
- registry.ts # ScheduleRegistry (Map-backed CRUD + findDue)
59
- schedule-store.ts # local ScheduleStore (FilePersistence implementation)
60
- remote-schedule-store.ts # remote ScheduleStore (RemotePersistence implementation)
61
- fire-ownership.ts # local FireOwnership (O_EXCL lockfile + liveness probe)
62
- remote-fire-ownership.ts # remote FireOwnership (HTTP lease + 30s heartbeat)
63
- schedule-lease-migrations.ts # remote lease table migration segments
64
- schedule-config.ts # ScheduleConfig 常量配置化 + applyJitter
65
- schedule-persistence.ts # 落盘咽喉点(session-local 永不落盘的唯一判断点)
66
- fire-target.ts # FireTarget 接口(内部路由契约,非对外贡献点)
67
- fire-targets/ # 三个内置投递实现:job / session / subscriber
68
- fire-logger.ts # FireLogger 写/清/读
69
- fire-executor.ts # FireExecutor:fire 准入闸门 + 路由 + one-shot 终结
70
- tick-loop.ts # TickLoop:tick 心跳 + reload + eviction(仅 cron 任务)
71
- scheduler.ts # SchedulerService(lifecycle 编排 + terminate 咽喉点)
72
- trigger.ts # EventDrivenTrigger 接口(事件监听契约)
73
- triggers/ # InProcessEventTrigger(进程内事件监听 + debounce)
74
- schedule-capability.ts # schedule_* model-tool capability adaptation layer
75
- index.ts # barrel export(仅公开真实消费面,RFC-433 D5)
76
- ```
77
-
78
- ## Key Configuration
79
-
80
- - Max task count: `MAX_TASKS = 50`
81
- - Recurring task jitter window: 30 minutes
82
- - One-shot task jitter window: 90 seconds
83
- - Local lock expiry: 5 minutes
84
- - Remote heartbeat: 30 seconds, remote lock expiry 180 seconds
85
- - Ticker interval: 1 second
86
- - Default per-task timeout: 5 minutes
87
-
88
- ## Dependencies
89
-
90
- - Internal: `@x-otto/env`, `@x-otto/persistence`, `@x-otto/runtime`
91
-
92
- ## Related
93
-
94
- - [Architecture](./ARCHITECTURE.md)(含 RFC-433 收敛后的真实架构:两个咽喉点 + 单一准入闸门 + 咽喉点清单)
95
- - RFC-433:任务生命周期咽喉点收敛(`docs/rfc/RFC-433-schedule-task-lifecycle-convergence.md`)——修复 4 个事件任务生命周期缺陷 + 收回触发侧空壳抽象