@elizaos/plugin-scheduling 2.0.3-beta.6 → 2.0.3-beta.7

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 (57) hide show
  1. package/dist/anchors/anchor-registry.d.ts +33 -0
  2. package/dist/anchors/anchor-registry.d.ts.map +1 -0
  3. package/dist/anchors/anchor-registry.js +129 -0
  4. package/dist/anchors/anchor-registry.js.map +1 -0
  5. package/dist/dispatch-types.d.ts +28 -0
  6. package/dist/dispatch-types.d.ts.map +1 -0
  7. package/dist/dispatch-types.js +1 -0
  8. package/dist/dispatch-types.js.map +1 -0
  9. package/dist/index.d.ts +5 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +18 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/plugin.d.ts +17 -0
  14. package/dist/plugin.d.ts.map +1 -0
  15. package/dist/plugin.js +8 -0
  16. package/dist/plugin.js.map +1 -0
  17. package/dist/scheduled-task/completion-check-registry.d.ts +19 -0
  18. package/dist/scheduled-task/completion-check-registry.d.ts.map +1 -0
  19. package/dist/scheduled-task/completion-check-registry.js +113 -0
  20. package/dist/scheduled-task/completion-check-registry.js.map +1 -0
  21. package/dist/scheduled-task/consolidation-policy.d.ts +51 -0
  22. package/dist/scheduled-task/consolidation-policy.d.ts.map +1 -0
  23. package/dist/scheduled-task/consolidation-policy.js +154 -0
  24. package/dist/scheduled-task/consolidation-policy.js.map +1 -0
  25. package/dist/scheduled-task/due.d.ts +19 -0
  26. package/dist/scheduled-task/due.d.ts.map +1 -0
  27. package/dist/scheduled-task/due.js +349 -0
  28. package/dist/scheduled-task/due.js.map +1 -0
  29. package/dist/scheduled-task/escalation.d.ts +55 -0
  30. package/dist/scheduled-task/escalation.d.ts.map +1 -0
  31. package/dist/scheduled-task/escalation.js +99 -0
  32. package/dist/scheduled-task/escalation.js.map +1 -0
  33. package/dist/scheduled-task/gate-registry.d.ts +18 -0
  34. package/dist/scheduled-task/gate-registry.d.ts.map +1 -0
  35. package/dist/scheduled-task/gate-registry.js +244 -0
  36. package/dist/scheduled-task/gate-registry.js.map +1 -0
  37. package/dist/scheduled-task/index.d.ts +20 -0
  38. package/dist/scheduled-task/index.d.ts.map +1 -0
  39. package/dist/scheduled-task/index.js +83 -0
  40. package/dist/scheduled-task/index.js.map +1 -0
  41. package/dist/scheduled-task/next-fire-at.d.ts +40 -0
  42. package/dist/scheduled-task/next-fire-at.d.ts.map +1 -0
  43. package/dist/scheduled-task/next-fire-at.js +202 -0
  44. package/dist/scheduled-task/next-fire-at.js.map +1 -0
  45. package/dist/scheduled-task/runner.d.ts +263 -0
  46. package/dist/scheduled-task/runner.d.ts.map +1 -0
  47. package/dist/scheduled-task/runner.js +721 -0
  48. package/dist/scheduled-task/runner.js.map +1 -0
  49. package/dist/scheduled-task/state-log.d.ts +56 -0
  50. package/dist/scheduled-task/state-log.d.ts.map +1 -0
  51. package/dist/scheduled-task/state-log.js +87 -0
  52. package/dist/scheduled-task/state-log.js.map +1 -0
  53. package/dist/scheduled-task/types.d.ts +368 -0
  54. package/dist/scheduled-task/types.d.ts.map +1 -0
  55. package/dist/scheduled-task/types.js +14 -0
  56. package/dist/scheduled-task/types.js.map +1 -0
  57. package/package.json +5 -5
@@ -0,0 +1,368 @@
1
+ /**
2
+ * Frozen interface contract for `ScheduledTask`.
3
+ *
4
+ * The runner deliberately does NOT pattern-match on `promptInstructions` or
5
+ * on specific `kind` values — behavior is driven by the typed fields.
6
+ *
7
+ * Terminal-state vocabulary note:
8
+ * - `completed`, `skipped`, `expired`, `dismissed` are reachable via the
9
+ * public chat verbs in `ScheduledTaskVerb` (and via fire-time gate /
10
+ * completion-check decisions).
11
+ * - `failed` is a **dispatcher-runtime outcome**, not a chat verb. There is
12
+ * no public `apply("failed")` entry point. The runner enters `failed`
13
+ * when an infra-level dispatch error surfaces, when a child task
14
+ * propagates `failed` upstream, or when callers invoke
15
+ * `runner.pipeline(taskId, "failed")` directly. `pipeline.onFail` then
16
+ * propagates the outcome to children and flips the parent's state to
17
+ * `failed` so observers see one consistent terminal state per branch.
18
+ */
19
+ export type TerminalState = "completed" | "skipped" | "expired" | "failed" | "dismissed";
20
+ export type ScheduledTaskStatus = TerminalState | "scheduled" | "fired" | "acknowledged";
21
+ export type ScheduledTaskKind = "reminder" | "checkin" | "followup" | "approval" | "recap" | "watcher" | "output" | "custom";
22
+ /**
23
+ * What kind of host execution environment a scheduled task needs at fire
24
+ * time. The runner consults this against `getHostExecutionCapabilities`
25
+ * (in `@elizaos/app-core/services/local-inference/host-capabilities`) and
26
+ * substitutes `notify-only` semantics when the host can't satisfy the
27
+ * requested profile (e.g. mobile background without an FGS / BGProcessingTask).
28
+ *
29
+ * - `"foreground"`: requires the app to be foregrounded. Anything that
30
+ * would block the UI thread or needs the user present.
31
+ * - `"bg-light-30s"`: bookkeeping that fits in ~30 s. Safe in iOS
32
+ * BGAppRefreshTask windows; no LLM action.
33
+ * - `"bg-heavy-fgs"`: needs an Android foreground service OR an iOS
34
+ * BGProcessingTask. Can run LLM inference. Long-running but bounded.
35
+ * - `"notify-only"`: just deliver a local notification; the user's tap
36
+ * opens the app in foreground where the real work runs.
37
+ */
38
+ export type TaskExecutionProfile = "foreground" | "bg-light-30s" | "bg-heavy-fgs" | "notify-only";
39
+ export declare const TASK_EXECUTION_PROFILES: readonly ["foreground", "bg-light-30s", "bg-heavy-fgs", "notify-only"];
40
+ /**
41
+ * Default profile assumed when a persisted task has no `executionProfile`
42
+ * column (back-compat for tasks written before this field landed).
43
+ * Foreground is the safest default — the runner downgrades to notify-only
44
+ * if even that isn't available.
45
+ */
46
+ export declare const DEFAULT_TASK_EXECUTION_PROFILE: TaskExecutionProfile;
47
+ export type ScheduledTaskPriority = "low" | "medium" | "high";
48
+ export type ScheduledTaskSource = "default_pack" | "user_chat" | "first_run" | "plugin";
49
+ export interface ScheduledTaskContextRequest {
50
+ includeOwnerFacts?: ("preferredName" | "timezone" | "morningWindow" | "eveningWindow" | "locale")[];
51
+ includeEntities?: {
52
+ entityIds: string[];
53
+ fields?: ("preferredName" | "type" | "identities" | "state.lastInteractionPlatform")[];
54
+ };
55
+ includeRelationships?: {
56
+ relationshipIds?: string[];
57
+ forEntityIds?: string[];
58
+ types?: string[];
59
+ };
60
+ includeRecentTaskStates?: {
61
+ kind?: ScheduledTaskKind;
62
+ lookbackHours?: number;
63
+ };
64
+ includeEventPayload?: boolean;
65
+ }
66
+ export type ScheduledTaskTrigger = {
67
+ kind: "once";
68
+ atIso: string;
69
+ } | {
70
+ kind: "cron";
71
+ expression: string;
72
+ tz: string;
73
+ } | {
74
+ kind: "interval";
75
+ everyMinutes: number;
76
+ from?: string;
77
+ until?: string;
78
+ } | {
79
+ kind: "relative_to_anchor";
80
+ anchorKey: string;
81
+ offsetMinutes: number;
82
+ } | {
83
+ kind: "during_window";
84
+ windowKey: string;
85
+ } | {
86
+ kind: "event";
87
+ eventKind: string;
88
+ filter?: EventFilter;
89
+ } | {
90
+ kind: "manual";
91
+ } | {
92
+ kind: "after_task";
93
+ taskId: string;
94
+ outcome: TerminalState;
95
+ };
96
+ export type GateCompose = "all" | "any" | "first_deny";
97
+ export interface ScheduledTaskGateRef {
98
+ kind: string;
99
+ params?: GateParams;
100
+ }
101
+ export interface ScheduledTaskShouldFire {
102
+ compose?: GateCompose;
103
+ gates: ScheduledTaskGateRef[];
104
+ }
105
+ export interface ScheduledTaskCompletionCheck {
106
+ kind: string;
107
+ params?: CompletionCheckParams;
108
+ /**
109
+ * Mutually exclusive with `pipeline.onSkip`. If both set, runner uses
110
+ * `pipeline.onSkip` and ignores this.
111
+ *
112
+ * For `kind === "approval"` tasks, the runner defaults this to
113
+ * {@link APPROVAL_DEFAULT_FOLLOWUP_AFTER_MINUTES} when the curator did
114
+ * not provide an explicit value (and `pipeline.onSkip` is empty).
115
+ */
116
+ followupAfterMinutes?: number;
117
+ }
118
+ /**
119
+ * Default `completionCheck.followupAfterMinutes` for approval-kind tasks
120
+ * when the curator did not set one explicitly. Approvals stale fast; a
121
+ * 60-minute followup is the documented baseline so curators do not need
122
+ * to repeat it on every approval definition.
123
+ */
124
+ export declare const APPROVAL_DEFAULT_FOLLOWUP_AFTER_MINUTES = 60;
125
+ export interface EscalationStep {
126
+ delayMinutes: number;
127
+ channelKey: string;
128
+ intensity?: "soft" | "normal" | "urgent";
129
+ }
130
+ export interface ScheduledTaskEscalation {
131
+ ladderKey?: string;
132
+ steps?: EscalationStep[];
133
+ }
134
+ export type ScheduledTaskOutputDestination = "in_app_card" | "channel" | "apple_notes" | "gmail_draft" | "memory";
135
+ export interface ScheduledTaskOutput {
136
+ destination: ScheduledTaskOutputDestination;
137
+ target?: string;
138
+ persistAs?: "task_metadata" | "external_only";
139
+ }
140
+ export interface ScheduledTaskPipeline {
141
+ onComplete?: ScheduledTaskRef[];
142
+ onSkip?: ScheduledTaskRef[];
143
+ onFail?: ScheduledTaskRef[];
144
+ }
145
+ export type ScheduledTaskSubjectKind = "entity" | "relationship" | "thread" | "document" | "calendar_event" | "self";
146
+ export interface ScheduledTaskSubject {
147
+ kind: ScheduledTaskSubjectKind;
148
+ id: string;
149
+ }
150
+ export interface ScheduledTaskState {
151
+ status: ScheduledTaskStatus;
152
+ firedAt?: string;
153
+ acknowledgedAt?: string;
154
+ completedAt?: string;
155
+ followupCount: number;
156
+ lastFollowupAt?: string;
157
+ pipelineParentId?: string;
158
+ lastDecisionLog?: string;
159
+ }
160
+ export interface ScheduledTask {
161
+ taskId: string;
162
+ kind: ScheduledTaskKind;
163
+ promptInstructions: string;
164
+ contextRequest?: ScheduledTaskContextRequest;
165
+ trigger: ScheduledTaskTrigger;
166
+ priority: ScheduledTaskPriority;
167
+ shouldFire?: ScheduledTaskShouldFire;
168
+ completionCheck?: ScheduledTaskCompletionCheck;
169
+ escalation?: ScheduledTaskEscalation;
170
+ output?: ScheduledTaskOutput;
171
+ pipeline?: ScheduledTaskPipeline;
172
+ subject?: ScheduledTaskSubject;
173
+ idempotencyKey?: string;
174
+ respectsGlobalPause: boolean;
175
+ state: ScheduledTaskState;
176
+ source: ScheduledTaskSource;
177
+ createdBy: string;
178
+ ownerVisible: boolean;
179
+ metadata?: Record<string, unknown>;
180
+ /**
181
+ * Host execution profile required at fire time. The runner consults the
182
+ * platform's `getHostExecutionCapabilities` and substitutes `notify-only`
183
+ * delivery when the requested profile isn't available (e.g. an LLM-heavy
184
+ * `"bg-heavy-fgs"` task on an iOS build with no BGProcessingTask
185
+ * identifier registered).
186
+ *
187
+ * Optional in this interface — repository reads default to
188
+ * {@link DEFAULT_TASK_EXECUTION_PROFILE} for back-compat with rows
189
+ * persisted before this field landed. The DB column is **not** NOT NULL
190
+ * yet; the next major version should backfill and tighten the schema.
191
+ *
192
+ * Schema migration note: once rows are backfilled, make this required and
193
+ * mark the column NOT NULL in the next major scheduled-task schema update.
194
+ */
195
+ executionProfile?: TaskExecutionProfile;
196
+ }
197
+ export type ScheduledTaskRef = string | ScheduledTask;
198
+ export type EventFilter = unknown;
199
+ export type GateParams = unknown;
200
+ export type CompletionCheckParams = unknown;
201
+ export type ScheduledTaskVerb = "snooze" | "skip" | "complete" | "dismiss" | "escalate" | "acknowledge" | "edit" | "reopen";
202
+ export interface ScheduledTaskFilter {
203
+ kind?: ScheduledTaskKind;
204
+ status?: ScheduledTaskStatus | ScheduledTaskStatus[];
205
+ subject?: ScheduledTaskSubject;
206
+ source?: ScheduledTaskSource;
207
+ firedSince?: string;
208
+ ownerVisibleOnly?: boolean;
209
+ }
210
+ export interface ScheduledTaskRunner {
211
+ schedule(task: Omit<ScheduledTask, "taskId" | "state">): Promise<ScheduledTask>;
212
+ list(filter?: ScheduledTaskFilter): Promise<ScheduledTask[]>;
213
+ apply(taskId: string, verb: ScheduledTaskVerb, payload?: unknown): Promise<ScheduledTask>;
214
+ pipeline(taskId: string, outcome: TerminalState): Promise<ScheduledTask[]>;
215
+ }
216
+ export type GateDecision = {
217
+ kind: "allow";
218
+ } | {
219
+ kind: "deny";
220
+ reason: string;
221
+ } | {
222
+ kind: "defer";
223
+ until: {
224
+ offsetMinutes: number;
225
+ } | {
226
+ atIso: string;
227
+ };
228
+ reason: string;
229
+ };
230
+ /**
231
+ * Owner facts the gates / completion-checks read — the minimal surface every
232
+ * owner-fact consumer agrees to.
233
+ */
234
+ export interface OwnerFactsView {
235
+ preferredName?: string;
236
+ timezone?: string;
237
+ locale?: string;
238
+ morningWindow?: {
239
+ start?: string;
240
+ end?: string;
241
+ };
242
+ eveningWindow?: {
243
+ start?: string;
244
+ end?: string;
245
+ };
246
+ quietHours?: {
247
+ start: string;
248
+ end: string;
249
+ tz: string;
250
+ };
251
+ travelActive?: boolean;
252
+ personalBaseline?: {
253
+ sampleCount?: number;
254
+ windowDays?: number;
255
+ };
256
+ }
257
+ /**
258
+ * Activity-signal subscriber surface. The runner consumes only the read
259
+ * side — completion-checks (`subject_updated`, `health_signal_observed`)
260
+ * and `trigger.kind = "event"` listeners need "did X happen since Y?"
261
+ * lookups.
262
+ */
263
+ export interface ActivitySignalBusView {
264
+ hasSignalSince(args: {
265
+ signalKind: string;
266
+ sinceIso: string;
267
+ subject?: ScheduledTaskSubject;
268
+ }): boolean | Promise<boolean>;
269
+ }
270
+ /**
271
+ * Subject-resolution surface — the minimum the runner needs to know about a
272
+ * subject to evaluate a completion-check.
273
+ */
274
+ export interface SubjectStoreView {
275
+ wasUpdatedSince(args: {
276
+ subject: ScheduledTaskSubject;
277
+ sinceIso: string;
278
+ }): boolean | Promise<boolean>;
279
+ }
280
+ /**
281
+ * Global-pause surface (`GlobalPauseStore`). The runner consults it pre-fire;
282
+ * tasks with `respectsGlobalPause: true` skip with `reason = "global_pause"`.
283
+ */
284
+ export interface GlobalPauseView {
285
+ current(now?: Date): Promise<{
286
+ active: boolean;
287
+ startIso?: string;
288
+ endIso?: string;
289
+ reason?: string;
290
+ }>;
291
+ }
292
+ export interface GateEvaluationContext {
293
+ task: ScheduledTask;
294
+ nowIso: string;
295
+ ownerFacts: OwnerFactsView;
296
+ activity: ActivitySignalBusView;
297
+ subjectStore: SubjectStoreView;
298
+ }
299
+ export interface CompletionCheckContext {
300
+ task: ScheduledTask;
301
+ nowIso: string;
302
+ ownerFacts: OwnerFactsView;
303
+ activity: ActivitySignalBusView;
304
+ subjectStore: SubjectStoreView;
305
+ /** Whether the user explicitly acknowledged this fire (for `user_acknowledged`). */
306
+ acknowledged: boolean;
307
+ /** Whether the user replied (any inbound) since the most recent fire. */
308
+ repliedSinceFiredAt?: {
309
+ atIso: string;
310
+ };
311
+ }
312
+ export interface TaskGateContribution {
313
+ kind: string;
314
+ paramsSchema?: unknown;
315
+ evaluate(task: ScheduledTask, context: GateEvaluationContext): GateDecision | Promise<GateDecision>;
316
+ }
317
+ export interface CompletionCheckContribution {
318
+ kind: string;
319
+ paramsSchema?: unknown;
320
+ shouldComplete(task: ScheduledTask, context: CompletionCheckContext): boolean | Promise<boolean>;
321
+ }
322
+ export interface AnchorContext {
323
+ nowIso: string;
324
+ ownerFacts: OwnerFactsView;
325
+ }
326
+ export interface AnchorContribution {
327
+ anchorKey: string;
328
+ describe: {
329
+ label: string;
330
+ provider: string;
331
+ };
332
+ resolve(context: AnchorContext): {
333
+ atIso: string;
334
+ } | null | Promise<{
335
+ atIso: string;
336
+ } | null>;
337
+ }
338
+ export type AnchorConsolidationMode = "merge" | "sequential" | "parallel";
339
+ export interface AnchorConsolidationPolicy {
340
+ anchorKey: string;
341
+ mode: AnchorConsolidationMode;
342
+ staggerMinutes?: number;
343
+ maxBatchSize?: number;
344
+ sortBy?: "priority_desc" | "fired_at_asc";
345
+ }
346
+ export type ScheduledTaskLogTransition = "scheduled" | "fire_attempt" | "fired" | "acknowledged" | "completed" | "skipped" | "snoozed" | "dismissed" | "escalated" | "edited" | "reopened" | "expired" | "failed" | "rolled_up"
347
+ /**
348
+ * Emitted when the host can't satisfy the task's `executionProfile` and the
349
+ * runner downgrades dispatch to `notify-only`. The log row's `detail`
350
+ * carries `{ originalProfile, substituteProfile: "notify-only", reason }`
351
+ * so dashboards can show why a heavy task became a notification.
352
+ */
353
+ | "substituted";
354
+ export interface ScheduledTaskLogEntry {
355
+ logId: string;
356
+ taskId: string;
357
+ agentId: string;
358
+ occurredAtIso: string;
359
+ transition: ScheduledTaskLogTransition;
360
+ reason?: string;
361
+ /**
362
+ * `true` when this row is a daily-summary rollup of expired raw entries
363
+ * (per IMPL §3.1 risk-and-tradeoff "State-log volume").
364
+ */
365
+ rolledUp: boolean;
366
+ detail?: Record<string, unknown>;
367
+ }
368
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/scheduled-task/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH,MAAM,MAAM,aAAa,GACrB,WAAW,GACX,SAAS,GACT,SAAS,GACT,QAAQ,GACR,WAAW,CAAC;AAEhB,MAAM,MAAM,mBAAmB,GAC3B,aAAa,GACb,WAAW,GACX,OAAO,GACP,cAAc,CAAC;AAEnB,MAAM,MAAM,iBAAiB,GACzB,UAAU,GACV,SAAS,GACT,UAAU,GACV,UAAU,GACV,OAAO,GACP,SAAS,GACT,QAAQ,GACR,QAAQ,CAAC;AAEb;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,oBAAoB,GAC5B,YAAY,GACZ,cAAc,GACd,cAAc,GACd,aAAa,CAAC;AAElB,eAAO,MAAM,uBAAuB,wEAKgB,CAAC;AAErD;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,EAAE,oBAC/B,CAAC;AAEf,MAAM,MAAM,qBAAqB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE9D,MAAM,MAAM,mBAAmB,GAC3B,cAAc,GACd,WAAW,GACX,WAAW,GACX,QAAQ,CAAC;AAEb,MAAM,WAAW,2BAA2B;IAC1C,iBAAiB,CAAC,EAAE,CAChB,eAAe,GACf,UAAU,GACV,eAAe,GACf,eAAe,GACf,QAAQ,CACX,EAAE,C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
@@ -0,0 +1,14 @@
1
+ const TASK_EXECUTION_PROFILES = [
2
+ "foreground",
3
+ "bg-light-30s",
4
+ "bg-heavy-fgs",
5
+ "notify-only"
6
+ ];
7
+ const DEFAULT_TASK_EXECUTION_PROFILE = "foreground";
8
+ const APPROVAL_DEFAULT_FOLLOWUP_AFTER_MINUTES = 60;
9
+ export {
10
+ APPROVAL_DEFAULT_FOLLOWUP_AFTER_MINUTES,
11
+ DEFAULT_TASK_EXECUTION_PROFILE,
12
+ TASK_EXECUTION_PROFILES
13
+ };
14
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/scheduled-task/types.ts"],"sourcesContent":["/**\n * Frozen interface contract for `ScheduledTask`.\n *\n * The runner deliberately does NOT pattern-match on `promptInstructions` or\n * on specific `kind` values — behavior is driven by the typed fields.\n *\n * Terminal-state vocabulary note:\n * - `completed`, `skipped`, `expired`, `dismissed` are reachable via the\n * public chat verbs in `ScheduledTaskVerb` (and via fire-time gate /\n * completion-check decisions).\n * - `failed` is a **dispatcher-runtime outcome**, not a chat verb. There is\n * no public `apply(\"failed\")` entry point. The runner enters `failed`\n * when an infra-level dispatch error surfaces, when a child task\n * propagates `failed` upstream, or when callers invoke\n * `runner.pipeline(taskId, \"failed\")` directly. `pipeline.onFail` then\n * propagates the outcome to children and flips the parent's state to\n * `failed` so observers see one consistent terminal state per branch.\n */\n\n// ---------------------------------------------------------------------------\n// ScheduledTask schema (frozen)\n// ---------------------------------------------------------------------------\n\nexport type TerminalState =\n | \"completed\"\n | \"skipped\"\n | \"expired\"\n | \"failed\"\n | \"dismissed\";\n\nexport type ScheduledTaskStatus =\n | TerminalState\n | \"scheduled\"\n | \"fired\"\n | \"acknowledged\";\n\nexport type ScheduledTaskKind =\n | \"reminder\"\n | \"checkin\"\n | \"followup\"\n | \"approval\"\n | \"recap\"\n | \"watcher\"\n | \"output\"\n | \"custom\";\n\n/**\n * What kind of host execution environment a scheduled task needs at fire\n * time. The runner consults this against `getHostExecutionCapabilities`\n * (in `@elizaos/app-core/services/local-inference/host-capabilities`) and\n * substitutes `notify-only` semantics when the host can't satisfy the\n * requested profile (e.g. mobile background without an FGS / BGProcessingTask).\n *\n * - `\"foreground\"`: requires the app to be foregrounded. Anything that\n * would block the UI thread or needs the user present.\n * - `\"bg-light-30s\"`: bookkeeping that fits in ~30 s. Safe in iOS\n * BGAppRefreshTask windows; no LLM action.\n * - `\"bg-heavy-fgs\"`: needs an Android foreground service OR an iOS\n * BGProcessingTask. Can run LLM inference. Long-running but bounded.\n * - `\"notify-only\"`: just deliver a local notification; the user's tap\n * opens the app in foreground where the real work runs.\n */\nexport type TaskExecutionProfile =\n | \"foreground\"\n | \"bg-light-30s\"\n | \"bg-heavy-fgs\"\n | \"notify-only\";\n\nexport const TASK_EXECUTION_PROFILES = [\n \"foreground\",\n \"bg-light-30s\",\n \"bg-heavy-fgs\",\n \"notify-only\",\n] as const satisfies readonly TaskExecutionProfile[];\n\n/**\n * Default profile assumed when a persisted task has no `executionProfile`\n * column (back-compat for tasks written before this field landed).\n * Foreground is the safest default — the runner downgrades to notify-only\n * if even that isn't available.\n */\nexport const DEFAULT_TASK_EXECUTION_PROFILE: TaskExecutionProfile =\n \"foreground\";\n\nexport type ScheduledTaskPriority = \"low\" | \"medium\" | \"high\";\n\nexport type ScheduledTaskSource =\n | \"default_pack\"\n | \"user_chat\"\n | \"first_run\"\n | \"plugin\";\n\nexport interface ScheduledTaskContextRequest {\n includeOwnerFacts?: (\n | \"preferredName\"\n | \"timezone\"\n | \"morningWindow\"\n | \"eveningWindow\"\n | \"locale\"\n )[];\n includeEntities?: {\n entityIds: string[];\n fields?: (\n | \"preferredName\"\n | \"type\"\n | \"identities\"\n | \"state.lastInteractionPlatform\"\n )[];\n };\n includeRelationships?: {\n relationshipIds?: string[];\n forEntityIds?: string[];\n types?: string[];\n };\n includeRecentTaskStates?: {\n kind?: ScheduledTaskKind;\n lookbackHours?: number;\n };\n includeEventPayload?: boolean;\n}\n\nexport type ScheduledTaskTrigger =\n | { kind: \"once\"; atIso: string }\n | { kind: \"cron\"; expression: string; tz: string }\n | { kind: \"interval\"; everyMinutes: number; from?: string; until?: string }\n | { kind: \"relative_to_anchor\"; anchorKey: string; offsetMinutes: number }\n | { kind: \"during_window\"; windowKey: string }\n | { kind: \"event\"; eventKind: string; filter?: EventFilter }\n | { kind: \"manual\" }\n | { kind: \"after_task\"; taskId: string; outcome: TerminalState };\n\nexport type GateCompose = \"all\" | \"any\" | \"first_deny\";\n\nexport interface ScheduledTaskGateRef {\n kind: string;\n params?: GateParams;\n}\n\nexport interface ScheduledTaskShouldFire {\n compose?: GateCompose;\n gates: ScheduledTaskGateRef[];\n}\n\nexport interface ScheduledTaskCompletionCheck {\n kind: string;\n params?: CompletionCheckParams;\n /**\n * Mutually exclusive with `pipeline.onSkip`. If both set, runner uses\n * `pipeline.onSkip` and ignores this.\n *\n * For `kind === \"approval\"` tasks, the runner defaults this to\n * {@link APPROVAL_DEFAULT_FOLLOWUP_AFTER_MINUTES} when the curator did\n * not provide an explicit value (and `pipeline.onSkip` is empty).\n */\n followupAfterMinutes?: number;\n}\n\n/**\n * Default `completionCheck.followupAfterMinutes` for approval-kind tasks\n * when the curator did not set one explicitly. Approvals stale fast; a\n * 60-minute followup is the documented baseline so curators do not need\n * to repeat it on every approval definition.\n */\nexport const APPROVAL_DEFAULT_FOLLOWUP_AFTER_MINUTES = 60;\n\nexport interface EscalationStep {\n delayMinutes: number;\n channelKey: string;\n intensity?: \"soft\" | \"normal\" | \"urgent\";\n}\n\nexport interface ScheduledTaskEscalation {\n ladderKey?: string;\n steps?: EscalationStep[];\n}\n\nexport type ScheduledTaskOutputDestination =\n | \"in_app_card\"\n | \"channel\"\n | \"apple_notes\"\n | \"gmail_draft\"\n | \"memory\";\n\nexport interface ScheduledTaskOutput {\n destination: ScheduledTaskOutputDestination;\n target?: string;\n persistAs?: \"task_metadata\" | \"external_only\";\n}\n\nexport interface ScheduledTaskPipeline {\n onComplete?: ScheduledTaskRef[];\n onSkip?: ScheduledTaskRef[];\n onFail?: ScheduledTaskRef[];\n}\n\nexport type ScheduledTaskSubjectKind =\n | \"entity\"\n | \"relationship\"\n | \"thread\"\n | \"document\"\n | \"calendar_event\"\n | \"self\";\n\nexport interface ScheduledTaskSubject {\n kind: ScheduledTaskSubjectKind;\n id: string;\n}\n\nexport interface ScheduledTaskState {\n status: ScheduledTaskStatus;\n firedAt?: string;\n acknowledgedAt?: string;\n completedAt?: string;\n followupCount: number;\n lastFollowupAt?: string;\n pipelineParentId?: string;\n lastDecisionLog?: string;\n}\n\nexport interface ScheduledTask {\n taskId: string;\n kind: ScheduledTaskKind;\n promptInstructions: string;\n contextRequest?: ScheduledTaskContextRequest;\n trigger: ScheduledTaskTrigger;\n priority: ScheduledTaskPriority;\n shouldFire?: ScheduledTaskShouldFire;\n completionCheck?: ScheduledTaskCompletionCheck;\n escalation?: ScheduledTaskEscalation;\n output?: ScheduledTaskOutput;\n pipeline?: ScheduledTaskPipeline;\n subject?: ScheduledTaskSubject;\n idempotencyKey?: string;\n respectsGlobalPause: boolean;\n state: ScheduledTaskState;\n source: ScheduledTaskSource;\n createdBy: string;\n ownerVisible: boolean;\n metadata?: Record<string, unknown>;\n /**\n * Host execution profile required at fire time. The runner consults the\n * platform's `getHostExecutionCapabilities` and substitutes `notify-only`\n * delivery when the requested profile isn't available (e.g. an LLM-heavy\n * `\"bg-heavy-fgs\"` task on an iOS build with no BGProcessingTask\n * identifier registered).\n *\n * Optional in this interface — repository reads default to\n * {@link DEFAULT_TASK_EXECUTION_PROFILE} for back-compat with rows\n * persisted before this field landed. The DB column is **not** NOT NULL\n * yet; the next major version should backfill and tighten the schema.\n *\n * Schema migration note: once rows are backfilled, make this required and\n * mark the column NOT NULL in the next major scheduled-task schema update.\n */\n executionProfile?: TaskExecutionProfile;\n}\n\nexport type ScheduledTaskRef = string | ScheduledTask;\nexport type EventFilter = unknown; // typed via EventKindRegistry per kind\nexport type GateParams = unknown; // typed via TaskGateRegistry per kind\nexport type CompletionCheckParams = unknown; // typed via CompletionCheckRegistry per kind\n\n// ---------------------------------------------------------------------------\n// §1.2 Runner verbs (frozen)\n// ---------------------------------------------------------------------------\n\nexport type ScheduledTaskVerb =\n | \"snooze\"\n | \"skip\"\n | \"complete\"\n | \"dismiss\"\n | \"escalate\"\n | \"acknowledge\"\n | \"edit\"\n | \"reopen\";\n\nexport interface ScheduledTaskFilter {\n kind?: ScheduledTaskKind;\n status?: ScheduledTaskStatus | ScheduledTaskStatus[];\n subject?: ScheduledTaskSubject;\n source?: ScheduledTaskSource;\n firedSince?: string;\n ownerVisibleOnly?: boolean;\n}\n\nexport interface ScheduledTaskRunner {\n schedule(\n task: Omit<ScheduledTask, \"taskId\" | \"state\">,\n ): Promise<ScheduledTask>;\n list(filter?: ScheduledTaskFilter): Promise<ScheduledTask[]>;\n apply(\n taskId: string,\n verb: ScheduledTaskVerb,\n payload?: unknown,\n ): Promise<ScheduledTask>;\n pipeline(taskId: string, outcome: TerminalState): Promise<ScheduledTask[]>;\n}\n\n// ---------------------------------------------------------------------------\n// §1.3 Gate / completion-check registries (frozen)\n// ---------------------------------------------------------------------------\n\nexport type GateDecision =\n | { kind: \"allow\" }\n | { kind: \"deny\"; reason: string }\n | {\n kind: \"defer\";\n until: { offsetMinutes: number } | { atIso: string };\n reason: string;\n };\n\n/**\n * Owner facts the gates / completion-checks read — the minimal surface every\n * owner-fact consumer agrees to.\n */\nexport interface OwnerFactsView {\n preferredName?: string;\n timezone?: string;\n locale?: string;\n morningWindow?: { start?: string; end?: string };\n eveningWindow?: { start?: string; end?: string };\n quietHours?: { start: string; end: string; tz: string };\n travelActive?: boolean;\n personalBaseline?: {\n sampleCount?: number;\n windowDays?: number;\n };\n}\n\n/**\n * Activity-signal subscriber surface. The runner consumes only the read\n * side — completion-checks (`subject_updated`, `health_signal_observed`)\n * and `trigger.kind = \"event\"` listeners need \"did X happen since Y?\"\n * lookups.\n */\nexport interface ActivitySignalBusView {\n hasSignalSince(args: {\n signalKind: string;\n sinceIso: string;\n subject?: ScheduledTaskSubject;\n }): boolean | Promise<boolean>;\n}\n\n/**\n * Subject-resolution surface — the minimum the runner needs to know about a\n * subject to evaluate a completion-check.\n */\nexport interface SubjectStoreView {\n wasUpdatedSince(args: {\n subject: ScheduledTaskSubject;\n sinceIso: string;\n }): boolean | Promise<boolean>;\n}\n\n/**\n * Global-pause surface (`GlobalPauseStore`). The runner consults it pre-fire;\n * tasks with `respectsGlobalPause: true` skip with `reason = \"global_pause\"`.\n */\nexport interface GlobalPauseView {\n current(now?: Date): Promise<{\n active: boolean;\n startIso?: string;\n endIso?: string;\n reason?: string;\n }>;\n}\n\nexport interface GateEvaluationContext {\n task: ScheduledTask;\n nowIso: string;\n ownerFacts: OwnerFactsView;\n activity: ActivitySignalBusView;\n subjectStore: SubjectStoreView;\n}\n\nexport interface CompletionCheckContext {\n task: ScheduledTask;\n nowIso: string;\n ownerFacts: OwnerFactsView;\n activity: ActivitySignalBusView;\n subjectStore: SubjectStoreView;\n /** Whether the user explicitly acknowledged this fire (for `user_acknowledged`). */\n acknowledged: boolean;\n /** Whether the user replied (any inbound) since the most recent fire. */\n repliedSinceFiredAt?: { atIso: string };\n}\n\nexport interface TaskGateContribution {\n kind: string;\n paramsSchema?: unknown;\n evaluate(\n task: ScheduledTask,\n context: GateEvaluationContext,\n ): GateDecision | Promise<GateDecision>;\n}\n\nexport interface CompletionCheckContribution {\n kind: string;\n paramsSchema?: unknown;\n shouldComplete(\n task: ScheduledTask,\n context: CompletionCheckContext,\n ): boolean | Promise<boolean>;\n}\n\n// ---------------------------------------------------------------------------\n// §1.4 Anchor + consolidation registries (frozen)\n// ---------------------------------------------------------------------------\n\nexport interface AnchorContext {\n nowIso: string;\n ownerFacts: OwnerFactsView;\n}\n\nexport interface AnchorContribution {\n anchorKey: string;\n describe: { label: string; provider: string };\n resolve(\n context: AnchorContext,\n ): { atIso: string } | null | Promise<{ atIso: string } | null>;\n}\n\nexport type AnchorConsolidationMode = \"merge\" | \"sequential\" | \"parallel\";\n\nexport interface AnchorConsolidationPolicy {\n anchorKey: string;\n mode: AnchorConsolidationMode;\n staggerMinutes?: number;\n maxBatchSize?: number;\n sortBy?: \"priority_desc\" | \"fired_at_asc\";\n}\n\n// ---------------------------------------------------------------------------\n// State-log row\n// ---------------------------------------------------------------------------\n\nexport type ScheduledTaskLogTransition =\n | \"scheduled\"\n | \"fire_attempt\"\n | \"fired\"\n | \"acknowledged\"\n | \"completed\"\n | \"skipped\"\n | \"snoozed\"\n | \"dismissed\"\n | \"escalated\"\n | \"edited\"\n | \"reopened\"\n | \"expired\"\n | \"failed\"\n | \"rolled_up\"\n /**\n * Emitted when the host can't satisfy the task's `executionProfile` and the\n * runner downgrades dispatch to `notify-only`. The log row's `detail`\n * carries `{ originalProfile, substituteProfile: \"notify-only\", reason }`\n * so dashboards can show why a heavy task became a notification.\n */\n | \"substituted\";\n\nexport interface ScheduledTaskLogEntry {\n logId: string;\n taskId: string;\n agentId: string;\n occurredAtIso: string;\n transition: ScheduledTaskLogTransition;\n reason?: string;\n /**\n * `true` when this row is a daily-summary rollup of expired raw entries\n * (per IMPL §3.1 risk-and-tradeoff \"State-log volume\").\n */\n rolledUp: boolean;\n detail?: Record<string, unknown>;\n}\n"],"mappings":"AAoEO,MAAM,0BAA0B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAQO,MAAM,iCACX;AAiFK,MAAM,0CAA0C;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elizaos/plugin-scheduling",
3
- "version": "2.0.3-beta.6",
3
+ "version": "2.0.3-beta.7",
4
4
  "type": "module",
5
5
  "description": "Scheduling spine for elizaOS agents: the storage-agnostic ScheduledTask state machine — trigger evaluation (cron/interval/once/event/after_task/relative_to_anchor/during_window), gate + completion-check + escalation-ladder + anchor + consolidation registries, the due/next-fire-at math, and the runner. Persistence + owner/channel/connector deps are injected by the host (e.g. @elizaos/plugin-personal-assistant). Reminders register a tick-hook via the ports here.",
6
6
  "main": "./dist/index.js",
@@ -47,12 +47,12 @@
47
47
  }
48
48
  },
49
49
  "dependencies": {
50
- "@elizaos/core": "2.0.3-beta.6",
51
- "@elizaos/shared": "2.0.3-beta.6",
50
+ "@elizaos/core": "2.0.3-beta.7",
51
+ "@elizaos/shared": "2.0.3-beta.7",
52
52
  "drizzle-orm": "^0.45.1"
53
53
  },
54
54
  "peerDependencies": {
55
- "@elizaos/plugin-sql": "2.0.3-beta.6"
55
+ "@elizaos/plugin-sql": "2.0.3-beta.7"
56
56
  },
57
57
  "publishConfig": {
58
58
  "access": "public"
@@ -69,5 +69,5 @@
69
69
  "typescript": "^6.0.3",
70
70
  "vitest": "^4.0.17"
71
71
  },
72
- "gitHead": "990dc996172b3e0fb525a75052a5ac28a4cd4de5"
72
+ "gitHead": "61094f10458d11055c75b3dd0bae374e3f66bac5"
73
73
  }