Skip to content

Commit e8096ab

Browse files
committed
feat: add durable routines registry
Typed routine registry layered on the existing cron scheduler: durable content-addressed identity, owner and delivery target, idempotent replay-safe create/enable/disable/delete with staged recovery, live status/drift projection against the backing cron job, six operator gateway RPCs, openclaw routines CLI, and generated Swift protocol models. Cron remains the only scheduler; tasks remain the activity ledger. Squashed from the 52-commit routines stack for replay onto current main.
1 parent 79d2e56 commit e8096ab

51 files changed

Lines changed: 6539 additions & 406 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift‎

Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6419,6 +6419,260 @@ public struct CronRunLogEntry: Codable, Sendable {
64196419
}
64206420
}
64216421

6422+
public struct RoutineView: Codable, Sendable {
6423+
public let id: String
6424+
public let name: String
6425+
public let description: String?
6426+
public let enabled: Bool
6427+
public let owner: [String: AnyCodable]
6428+
public let target: [String: AnyCodable]
6429+
public let trigger: [String: AnyCodable]
6430+
public let action: AnyCodable
6431+
public let createdatms: Int
6432+
public let updatedatms: Int
6433+
public let status: [String: AnyCodable]
6434+
6435+
public init(
6436+
id: String,
6437+
name: String,
6438+
description: String?,
6439+
enabled: Bool,
6440+
owner: [String: AnyCodable],
6441+
target: [String: AnyCodable],
6442+
trigger: [String: AnyCodable],
6443+
action: AnyCodable,
6444+
createdatms: Int,
6445+
updatedatms: Int,
6446+
status: [String: AnyCodable])
6447+
{
6448+
self.id = id
6449+
self.name = name
6450+
self.description = description
6451+
self.enabled = enabled
6452+
self.owner = owner
6453+
self.target = target
6454+
self.trigger = trigger
6455+
self.action = action
6456+
self.createdatms = createdatms
6457+
self.updatedatms = updatedatms
6458+
self.status = status
6459+
}
6460+
6461+
private enum CodingKeys: String, CodingKey {
6462+
case id
6463+
case name
6464+
case description
6465+
case enabled
6466+
case owner
6467+
case target
6468+
case trigger
6469+
case action
6470+
case createdatms = "createdAtMs"
6471+
case updatedatms = "updatedAtMs"
6472+
case status
6473+
}
6474+
}
6475+
6476+
public struct RoutinesListParams: Codable, Sendable {
6477+
public let includedisabled: Bool?
6478+
public let agentid: String?
6479+
public let query: String?
6480+
public let limit: Int?
6481+
public let offset: Int?
6482+
6483+
public init(
6484+
includedisabled: Bool?,
6485+
agentid: String? = nil,
6486+
query: String?,
6487+
limit: Int?,
6488+
offset: Int?)
6489+
{
6490+
self.includedisabled = includedisabled
6491+
self.agentid = agentid
6492+
self.query = query
6493+
self.limit = limit
6494+
self.offset = offset
6495+
}
6496+
6497+
private enum CodingKeys: String, CodingKey {
6498+
case includedisabled = "includeDisabled"
6499+
case agentid = "agentId"
6500+
case query
6501+
case limit
6502+
case offset
6503+
}
6504+
}
6505+
6506+
public struct RoutinesListResult: Codable, Sendable {
6507+
public let routines: [RoutineView]
6508+
6509+
public init(
6510+
routines: [RoutineView])
6511+
{
6512+
self.routines = routines
6513+
}
6514+
6515+
private enum CodingKeys: String, CodingKey {
6516+
case routines
6517+
}
6518+
}
6519+
6520+
public struct RoutinesGetParams: Codable, Sendable {
6521+
public let id: String
6522+
6523+
public init(
6524+
id: String)
6525+
{
6526+
self.id = id
6527+
}
6528+
6529+
private enum CodingKeys: String, CodingKey {
6530+
case id
6531+
}
6532+
}
6533+
6534+
public struct RoutinesGetResult: Codable, Sendable {
6535+
public let routine: AnyCodable
6536+
6537+
public init(
6538+
routine: AnyCodable)
6539+
{
6540+
self.routine = routine
6541+
}
6542+
6543+
private enum CodingKeys: String, CodingKey {
6544+
case routine
6545+
}
6546+
}
6547+
6548+
public struct RoutinesCreateParams: Codable, Sendable {
6549+
public let id: String?
6550+
public let name: String
6551+
public let description: String?
6552+
public let enabled: Bool?
6553+
public let owner: [String: AnyCodable]?
6554+
public let target: [String: AnyCodable]?
6555+
public let trigger: [String: AnyCodable]
6556+
public let action: AnyCodable
6557+
6558+
public init(
6559+
id: String?,
6560+
name: String,
6561+
description: String?,
6562+
enabled: Bool?,
6563+
owner: [String: AnyCodable]?,
6564+
target: [String: AnyCodable]?,
6565+
trigger: [String: AnyCodable],
6566+
action: AnyCodable)
6567+
{
6568+
self.id = id
6569+
self.name = name
6570+
self.description = description
6571+
self.enabled = enabled
6572+
self.owner = owner
6573+
self.target = target
6574+
self.trigger = trigger
6575+
self.action = action
6576+
}
6577+
6578+
private enum CodingKeys: String, CodingKey {
6579+
case id
6580+
case name
6581+
case description
6582+
case enabled
6583+
case owner
6584+
case target
6585+
case trigger
6586+
case action
6587+
}
6588+
}
6589+
6590+
public struct RoutinesCreateResult: Codable, Sendable {
6591+
public let routine: RoutineView
6592+
public let created: Bool
6593+
public let idempotent: Bool
6594+
6595+
public init(
6596+
routine: RoutineView,
6597+
created: Bool,
6598+
idempotent: Bool)
6599+
{
6600+
self.routine = routine
6601+
self.created = created
6602+
self.idempotent = idempotent
6603+
}
6604+
6605+
private enum CodingKeys: String, CodingKey {
6606+
case routine
6607+
case created
6608+
case idempotent
6609+
}
6610+
}
6611+
6612+
public struct RoutinesSetEnabledParams: Codable, Sendable {
6613+
public let id: String
6614+
6615+
public init(
6616+
id: String)
6617+
{
6618+
self.id = id
6619+
}
6620+
6621+
private enum CodingKeys: String, CodingKey {
6622+
case id
6623+
}
6624+
}
6625+
6626+
public struct RoutinesSetEnabledResult: Codable, Sendable {
6627+
public let routine: RoutineView
6628+
public let changed: Bool
6629+
6630+
public init(
6631+
routine: RoutineView,
6632+
changed: Bool)
6633+
{
6634+
self.routine = routine
6635+
self.changed = changed
6636+
}
6637+
6638+
private enum CodingKeys: String, CodingKey {
6639+
case routine
6640+
case changed
6641+
}
6642+
}
6643+
6644+
public struct RoutinesDeleteParams: Codable, Sendable {
6645+
public let id: String
6646+
6647+
public init(
6648+
id: String)
6649+
{
6650+
self.id = id
6651+
}
6652+
6653+
private enum CodingKeys: String, CodingKey {
6654+
case id
6655+
}
6656+
}
6657+
6658+
public struct RoutinesDeleteResult: Codable, Sendable {
6659+
public let id: String
6660+
public let deleted: Bool
6661+
6662+
public init(
6663+
id: String,
6664+
deleted: Bool)
6665+
{
6666+
self.id = id
6667+
self.deleted = deleted
6668+
}
6669+
6670+
private enum CodingKeys: String, CodingKey {
6671+
case id
6672+
case deleted
6673+
}
6674+
}
6675+
64226676
public struct LogsTailParams: Codable, Sendable {
64236677
public let cursor: Int?
64246678
public let limit: Int?

‎docs/.i18n/glossary.zh-CN.json‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,30 @@
611611
"source": "Scheduled tasks",
612612
"target": "定时任务"
613613
},
614+
{
615+
"source": "Scheduled Tasks",
616+
"target": "定时任务"
617+
},
618+
{
619+
"source": "Background Tasks",
620+
"target": "后台任务"
621+
},
622+
{
623+
"source": "Routines",
624+
"target": "例行任务"
625+
},
626+
{
627+
"source": "Routines CLI",
628+
"target": "例行任务 CLI"
629+
},
630+
{
631+
"source": "Cron CLI",
632+
"target": "Cron CLI"
633+
},
634+
{
635+
"source": "Tasks CLI",
636+
"target": "任务 CLI"
637+
},
614638
{
615639
"source": "Configuration reference",
616640
"target": "配置参考"

‎docs/automation/cron-jobs.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ sidebarTitle: "Scheduled tasks"
1010

1111
Cron is the Gateway's built-in scheduler. It persists jobs, wakes the agent at the right time, and can deliver output back to a chat channel or webhook endpoint.
1212

13+
<Note>
14+
Use [Routines](/automation/routines) when a schedule-backed job should be a
15+
named, durable team operation with ownership, delivery target, status visibility,
16+
and idempotent create/delete semantics. Routines delegate schedule execution to
17+
cron instead of replacing it.
18+
</Note>
19+
1320
## Quick start
1421

1522
<Steps>

0 commit comments

Comments
 (0)