@qilin-agent/schedule 3.1.7 → 3.1.9
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/README.i18n.yaml +72 -39
- package/README.md +180 -56
- package/README.zh.md +185 -61
- package/lib/index.js +5565 -1191
- package/lib/typert.host.js +1886 -267
- package/lib/typert.remote-client.d.ts +22 -10
- package/lib/typert.remote-client.js +1727 -190
- package/lib/types/delivery-history.d.ts +4 -6
- package/lib/types/delivery-history.js +7 -20
- package/lib/types/domain.d.ts +117 -80
- package/lib/types/domain.js +311 -797
- package/lib/types/index.d.ts +168 -80
- package/lib/types/index.js +531 -222
- package/lib/types/runtime.d.ts +92 -4
- package/lib/types/runtime.js +392 -72
- package/lib/types/storage.d.ts +126 -24
- package/lib/types/storage.js +85 -16
- package/lib/types/types.d.ts +287 -148
- package/lib/types/types.js +1 -1
- package/lib/types/update.d.ts +16 -21
- package/lib/types/update.js +72 -144
- package/package.json +38 -35
package/lib/types/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Durable and model-facing Schedule value types.
|
|
3
|
-
* @module @qilin-agent/schedule
|
|
3
|
+
* @module @qilin-agent/schedule/types
|
|
4
4
|
*/
|
|
5
5
|
import type { SessionId } from '@qilin-agent/session/types';
|
|
6
6
|
import type { MessageId } from '@qilin-agent/llm/brand';
|
|
@@ -155,59 +155,34 @@ export interface LegacyEveryScheduleRecord extends Omit<EveryScheduleRecord, 'ti
|
|
|
155
155
|
readonly title?: string;
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
158
|
-
* Frozen Session
|
|
158
|
+
* Frozen historical Session-event record types, independent of Host task storage.
|
|
159
159
|
*
|
|
160
160
|
* A version-1 event written before titles existed persists no `title` member, so
|
|
161
|
-
* `after`, `at`, and `every`
|
|
162
|
-
*
|
|
161
|
+
* `after`, `at`, and `every` retain that absence. These events never become Host
|
|
162
|
+
* tasks; every Host task record requires a title.
|
|
163
163
|
*/
|
|
164
164
|
export type LegacyScheduleRecord = LegacyAfterScheduleRecord | LegacyAtScheduleRecord | LegacyEveryScheduleRecord;
|
|
165
165
|
/** Recurring Host task variants. */
|
|
166
|
-
export type RecurringScheduleRecord = EveryScheduleRecord | DailyScheduleRecord | WeeklyScheduleRecord | CronScheduleRecord;
|
|
167
|
-
/**
|
|
168
|
-
export type ScheduleRecord = OneShotScheduleRecord | RecurringScheduleRecord;
|
|
169
|
-
/** Durable Session inbox delivery acknowledgment, not model execution completion. */
|
|
170
|
-
export interface ScheduleDeliveryReceipt {
|
|
171
|
-
/** Canonical UTC target of the delivered occurrence. */
|
|
172
|
-
readonly scheduledAt: string;
|
|
173
|
-
/** Canonical UTC time sampled after Session persistence acknowledged delivery. */
|
|
174
|
-
readonly deliveredAt: string;
|
|
175
|
-
/** Identity of the delivered message, shared by tasks in one recurring batch. */
|
|
176
|
-
readonly messageId: MessageId;
|
|
177
|
-
}
|
|
178
|
-
/** Saved inbox delivery with its immutable sent prompt when recorded by this Host. */
|
|
179
|
-
export interface ScheduleDeliveryRecord extends ScheduleDeliveryReceipt {
|
|
180
|
-
/** Prompt sent for this occurrence; unavailable for legacy receipts. */
|
|
181
|
-
readonly prompt?: string;
|
|
182
|
-
}
|
|
183
|
-
/** Browser-safe retained reminder with its original Session binding. */
|
|
184
|
-
export type ScheduleCatalogEntry = ScheduleRecord & {
|
|
185
|
-
/** Session receiving this reminder when it becomes due. */
|
|
186
|
-
readonly sessionId: SessionId;
|
|
187
|
-
/** Inactive reminders remain visible but never schedule another delivery. */
|
|
188
|
-
readonly status: 'active' | 'inactive';
|
|
189
|
-
/** Most recent durably acknowledged inbox delivery, when available. */
|
|
190
|
-
readonly lastDelivery?: ScheduleDeliveryReceipt;
|
|
191
|
-
};
|
|
192
|
-
/** Creates one durable reminder record. */
|
|
166
|
+
export type RecurringScheduleRecord = EveryScheduleRecord | DailyScheduleRecord | WeeklyScheduleRecord | CronScheduleRecord | RRuleScheduleRecord;
|
|
167
|
+
/** Historical Session-local reminder creation. */
|
|
193
168
|
export interface ScheduleCreateChange {
|
|
194
169
|
readonly version: 1;
|
|
195
170
|
readonly operation: 'create';
|
|
196
171
|
readonly schedule: LegacyScheduleRecord;
|
|
197
172
|
}
|
|
198
|
-
/**
|
|
173
|
+
/** Historical Session-local reminder deletion. */
|
|
199
174
|
export interface ScheduleDeleteChange {
|
|
200
175
|
readonly version: 1;
|
|
201
176
|
readonly operation: 'delete';
|
|
202
177
|
readonly id: ScheduleId;
|
|
203
178
|
}
|
|
204
|
-
/**
|
|
179
|
+
/** Historical one-shot reminder dispatch. */
|
|
205
180
|
export interface OneShotScheduleDispatchChange {
|
|
206
181
|
readonly version: 1;
|
|
207
182
|
readonly operation: 'dispatch';
|
|
208
183
|
readonly id: ScheduleId;
|
|
209
184
|
}
|
|
210
|
-
/**
|
|
185
|
+
/** Historical fixed-rate reminder dispatch. */
|
|
211
186
|
export interface EveryScheduleDispatchChange {
|
|
212
187
|
readonly version: 1;
|
|
213
188
|
readonly operation: 'dispatch';
|
|
@@ -215,21 +190,10 @@ export interface EveryScheduleDispatchChange {
|
|
|
215
190
|
/** Wall-clock decision time used to select the latest due occurrence. */
|
|
216
191
|
readonly acceptedAt: string;
|
|
217
192
|
}
|
|
218
|
-
/**
|
|
193
|
+
/** Frozen dispatch variants in historical Session logs. */
|
|
219
194
|
export type ScheduleDispatchChange = OneShotScheduleDispatchChange | EveryScheduleDispatchChange;
|
|
220
|
-
/**
|
|
195
|
+
/** Frozen version-1 Schedule mutation union retained in Session event types. */
|
|
221
196
|
export type ScheduleChange = ScheduleCreateChange | ScheduleDeleteChange | ScheduleDispatchChange;
|
|
222
|
-
/** Current delivery timing derived from the durable record and wall clock. */
|
|
223
|
-
export type ScheduleState = 'scheduled' | 'overdue';
|
|
224
|
-
/** Host-driven delivery resumes the original Session when needed. */
|
|
225
|
-
export type ScheduleDeliveryMode = 'host';
|
|
226
|
-
/** Complete model-facing view of one active reminder. */
|
|
227
|
-
export type ScheduleView = ScheduleRecord & {
|
|
228
|
-
/** Whether the target remains in the future. */
|
|
229
|
-
readonly state: ScheduleState;
|
|
230
|
-
/** Reminder delivery never leaves the owning session. */
|
|
231
|
-
readonly deliveryMode: ScheduleDeliveryMode;
|
|
232
|
-
};
|
|
233
197
|
/** Stable error returned for an empty, over-long, or untrimmed reminder prompt or title. */
|
|
234
198
|
export interface InvalidPromptError {
|
|
235
199
|
readonly code: 'invalid_prompt';
|
|
@@ -260,28 +224,26 @@ export interface TimeOutOfRangeError {
|
|
|
260
224
|
readonly code: 'time_out_of_range';
|
|
261
225
|
readonly message: string;
|
|
262
226
|
}
|
|
263
|
-
/** Stable error returned when a fixed-rate rule runs more often than supported. */
|
|
227
|
+
/** Stable error returned when a fixed-rate or RRULE rule runs more often than supported. */
|
|
264
228
|
export interface FrequencyTooHighError {
|
|
265
229
|
readonly code: 'frequency_too_high';
|
|
266
230
|
readonly message: string;
|
|
267
231
|
}
|
|
268
|
-
/** Stable fallback that does not disclose an internal exception. */
|
|
269
|
-
export interface InternalScheduleError {
|
|
270
|
-
readonly code: 'internal_error';
|
|
271
|
-
readonly message: string;
|
|
272
|
-
}
|
|
273
232
|
/** Stable error returned when the target Session belongs to subagent routing, which never receives reminder delivery. */
|
|
274
233
|
export interface SubagentSessionError {
|
|
275
234
|
readonly code: 'subagent_session';
|
|
276
235
|
readonly message: string;
|
|
277
236
|
}
|
|
278
|
-
/**
|
|
237
|
+
/** Stable fallback that does not disclose an internal exception. */
|
|
238
|
+
export interface InternalScheduleError {
|
|
239
|
+
readonly code: 'internal_error';
|
|
240
|
+
readonly message: string;
|
|
241
|
+
}
|
|
242
|
+
/** Schedule management error union. */
|
|
279
243
|
export type ScheduleToolError = InvalidPromptError | InvalidSelectorError | InvalidRuleError | InvalidTimeZoneError | NotFutureError | TimeOutOfRangeError | FrequencyTooHighError | SubagentSessionError | InternalScheduleError;
|
|
280
|
-
/**
|
|
281
|
-
export type
|
|
282
|
-
/**
|
|
283
|
-
export type ScheduleListValue = ScheduleView[] | ScheduleToolError;
|
|
284
|
-
/** Successful `schedule_delete` value, including the non-mutating not-found result. */
|
|
244
|
+
/** Input failure codes; every member except `internal_error` of the management error union. */
|
|
245
|
+
export type ScheduleInputErrorCode = Exclude<ScheduleToolError['code'], 'internal_error'>;
|
|
246
|
+
/** Deletion outcome, including the non-mutating not-found result. */
|
|
285
247
|
export type ScheduleDeleteResult = {
|
|
286
248
|
readonly id: ScheduleId;
|
|
287
249
|
readonly deleted: true;
|
|
@@ -290,54 +252,34 @@ export type ScheduleDeleteResult = {
|
|
|
290
252
|
readonly deleted: false;
|
|
291
253
|
readonly code: 'schedule_not_found';
|
|
292
254
|
};
|
|
293
|
-
/**
|
|
294
|
-
export
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
declare module '@qilin-agent/session/types' {
|
|
302
|
-
interface SessionEventMap {
|
|
303
|
-
/**
|
|
304
|
-
* Versioned Schedule mutation. The owning package validates the complete
|
|
305
|
-
* session-local transition stream before accepting a candidate event.
|
|
306
|
-
*/
|
|
307
|
-
'schedule/change': ScheduleChange;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
/** Reminder creation selector, shared by the model consumer and Host service. */
|
|
311
|
-
export interface ScheduleCreateRequest {
|
|
312
|
-
/** Non-empty reminder text. */
|
|
313
|
-
prompt: string;
|
|
314
|
-
/** Required task name of at most 120 characters, non-empty after trimming; names the card, detail heading, and task lists. */
|
|
315
|
-
title: string;
|
|
316
|
-
/** Relative one-shot delay in seconds. */
|
|
317
|
-
after_seconds?: number;
|
|
318
|
-
/** Absolute one-shot target. */
|
|
319
|
-
at?: AtInput;
|
|
320
|
-
/** Fixed recurrence interval in seconds. */
|
|
321
|
-
every_seconds?: number;
|
|
322
|
-
/** Daily wall-clock time in an explicit IANA zone. */
|
|
323
|
-
daily?: DailyInput;
|
|
324
|
-
/** Weekly wall-clock time and explicit ISO weekday set in an IANA zone. */
|
|
325
|
-
weekly?: WeeklyInput;
|
|
326
|
-
/** Five-field cron expression evaluated in an explicit IANA zone. */
|
|
327
|
-
cron?: CronInput;
|
|
328
|
-
}
|
|
329
|
-
/** Session-scoped task list, without Agent activation. */
|
|
330
|
-
export interface ScheduleListRequest {
|
|
331
|
-
/** Original Session binding. */
|
|
332
|
-
sessionId: SessionId;
|
|
255
|
+
/** Configured limits applied when appending one task's delivery receipt. */
|
|
256
|
+
export interface DeliveryRetentionBounds {
|
|
257
|
+
/** Retained window in days, measured back from the acknowledgment being appended. */
|
|
258
|
+
readonly days: number;
|
|
259
|
+
/** Maximum retained records per task; the newest survive. */
|
|
260
|
+
readonly records: number;
|
|
333
261
|
}
|
|
334
|
-
/**
|
|
335
|
-
export interface
|
|
336
|
-
|
|
337
|
-
|
|
262
|
+
/** RFC 5545 timing with an explicit DTSTART anchor and zone. */
|
|
263
|
+
export interface RRuleScheduleRecord {
|
|
264
|
+
readonly kind: 'rrule';
|
|
265
|
+
/** Host-generated canonical identity. */
|
|
266
|
+
readonly id: ScheduleId;
|
|
267
|
+
/** Task name; already trimmed, non-empty, and at most 120 characters. */
|
|
268
|
+
readonly title: string;
|
|
269
|
+
/** Trimmed instruction sent when an occurrence becomes due. */
|
|
270
|
+
readonly prompt: string;
|
|
271
|
+
/** One normalized DTSTART line and one RRULE line. */
|
|
272
|
+
readonly rrule: string;
|
|
273
|
+
/** Next unaccepted occurrence while active, or the final accepted occurrence when ended. */
|
|
274
|
+
readonly scheduledAt: string;
|
|
338
275
|
}
|
|
339
|
-
/**
|
|
340
|
-
export type
|
|
276
|
+
/** Current timing records; every kind is authoritative and uses the normal evaluator. */
|
|
277
|
+
export type ScheduleRecord = OneShotScheduleRecord | RecurringScheduleRecord;
|
|
278
|
+
/** Timing accepted by the shared management API. */
|
|
279
|
+
export type ScheduleTiming = {
|
|
280
|
+
readonly kind: 'after';
|
|
281
|
+
readonly after_seconds: number;
|
|
282
|
+
} | {
|
|
341
283
|
readonly kind: 'at';
|
|
342
284
|
readonly at: AtInput;
|
|
343
285
|
} | {
|
|
@@ -352,65 +294,262 @@ export type ScheduleTimingChange = {
|
|
|
352
294
|
} | {
|
|
353
295
|
readonly kind: 'cron';
|
|
354
296
|
readonly cron: CronInput;
|
|
297
|
+
} | {
|
|
298
|
+
readonly kind: 'rrule';
|
|
299
|
+
readonly rrule: string;
|
|
355
300
|
};
|
|
356
|
-
/**
|
|
357
|
-
export interface
|
|
358
|
-
/**
|
|
359
|
-
readonly
|
|
360
|
-
/**
|
|
361
|
-
readonly
|
|
362
|
-
}
|
|
363
|
-
/**
|
|
364
|
-
export
|
|
365
|
-
/**
|
|
366
|
-
readonly
|
|
367
|
-
/**
|
|
368
|
-
readonly
|
|
301
|
+
/** Values used when a target creates a Session. */
|
|
302
|
+
export interface ScheduleSessionCreateSpec {
|
|
303
|
+
/** Project directory of the created Session, which joins the Workspace registered there; omission uses the Host project directory. */
|
|
304
|
+
readonly cwd?: string;
|
|
305
|
+
/** Agent preset of the created Session; omission uses the default preset. */
|
|
306
|
+
readonly agentPreset?: string;
|
|
307
|
+
}
|
|
308
|
+
/** Stored delivery destination; it is independent of the Session that manages the task. */
|
|
309
|
+
export type ScheduleTarget = {
|
|
310
|
+
/** Every occurrence goes to one existing Session. */
|
|
311
|
+
readonly kind: 'session';
|
|
312
|
+
/** Session that receives each delivery. */
|
|
313
|
+
readonly sessionId: SessionId;
|
|
314
|
+
} | {
|
|
315
|
+
/** The first delivery creates one Session; later deliveries go to that Session. */
|
|
316
|
+
readonly kind: 'new_once';
|
|
317
|
+
/** Reserved at creation; the first delivery creates it and the target becomes `session`. */
|
|
318
|
+
readonly sessionId: SessionId;
|
|
319
|
+
/** Values used to create the reserved Session. */
|
|
320
|
+
readonly create: ScheduleSessionCreateSpec;
|
|
321
|
+
} | {
|
|
322
|
+
/** Every delivery creates a fresh Session. */
|
|
323
|
+
readonly kind: 'new';
|
|
324
|
+
/** Values used to create each Session. */
|
|
325
|
+
readonly create: ScheduleSessionCreateSpec;
|
|
326
|
+
};
|
|
327
|
+
/** Destination accepted by create and edit; the Host reserves the `new_once` Session id. */
|
|
328
|
+
export type ScheduleTargetRequest = {
|
|
329
|
+
/** Deliver to one existing Session that is not a delegated child. */
|
|
330
|
+
readonly kind: 'session';
|
|
331
|
+
/** Existing Session that receives each delivery. */
|
|
332
|
+
readonly sessionId: SessionId;
|
|
333
|
+
} | {
|
|
334
|
+
/** Create one Session at the first delivery. */
|
|
335
|
+
readonly kind: 'new_once';
|
|
336
|
+
/** Creation values; omission uses the Host defaults. */
|
|
337
|
+
readonly create?: ScheduleSessionCreateSpec;
|
|
338
|
+
} | {
|
|
339
|
+
/** Create a fresh Session at each delivery. */
|
|
340
|
+
readonly kind: 'new';
|
|
341
|
+
/** Creation values; omission uses the Host defaults. */
|
|
342
|
+
readonly create?: ScheduleSessionCreateSpec;
|
|
343
|
+
};
|
|
344
|
+
/** Durable Session inbox delivery acknowledgment, not model execution completion. */
|
|
345
|
+
export interface ScheduleDeliveryReceipt {
|
|
346
|
+
/** Canonical UTC target of the delivered occurrence. */
|
|
347
|
+
readonly scheduledAt: string;
|
|
348
|
+
/** Canonical UTC time sampled after Session persistence acknowledged delivery. */
|
|
349
|
+
readonly deliveredAt: string;
|
|
350
|
+
/** Identity of the delivered message, shared by tasks in one recurring batch. */
|
|
351
|
+
readonly messageId: MessageId;
|
|
352
|
+
/** Session that durably accepted the delivered message. */
|
|
353
|
+
readonly targetSessionId: SessionId;
|
|
369
354
|
}
|
|
370
|
-
/**
|
|
371
|
-
export interface
|
|
372
|
-
|
|
373
|
-
readonly
|
|
374
|
-
readonly code: 'schedule_not_found' | 'schedule_ended' | 'schedule_conflict';
|
|
355
|
+
/** Saved inbox delivery with its immutable sent prompt when recorded by this Host. */
|
|
356
|
+
export interface ScheduleDeliveryRecord extends ScheduleDeliveryReceipt {
|
|
357
|
+
/** Prompt sent for this occurrence; unavailable for legacy receipts. */
|
|
358
|
+
readonly prompt?: string;
|
|
375
359
|
}
|
|
376
|
-
/**
|
|
377
|
-
export
|
|
360
|
+
/** Bounded newest-first query over the saved deliveries of one task. */
|
|
361
|
+
export interface ScheduleDeliveryHistoryRequest {
|
|
362
|
+
/** Task whose saved deliveries are read. */
|
|
378
363
|
readonly id: ScheduleId;
|
|
379
|
-
readonly updated: boolean;
|
|
380
|
-
readonly record: ScheduleRecord;
|
|
381
|
-
} | ScheduleUpdateMiss | ScheduleToolError;
|
|
382
|
-
/** Canonical `schedule_update` value: the committed record as a view, or the non-mutating lookup/conflict result. */
|
|
383
|
-
export type ScheduleUpdateValue = ScheduleView | ScheduleUpdateMiss | ScheduleToolError;
|
|
384
|
-
/** Explicitly bounded saved-delivery query within one Session binding. */
|
|
385
|
-
export interface ScheduleDeliveryHistoryRequest extends ScheduleDeleteRequest {
|
|
386
364
|
/** Required safe-integer page size from 1 through 100. */
|
|
387
|
-
limit: number;
|
|
365
|
+
readonly limit: number;
|
|
388
366
|
/** Message identity of the oldest entry in the previous page; excluded from this page. */
|
|
389
|
-
before?: MessageId;
|
|
367
|
+
readonly before?: MessageId;
|
|
390
368
|
}
|
|
391
|
-
/**
|
|
392
|
-
export interface
|
|
393
|
-
/**
|
|
394
|
-
readonly days: number;
|
|
395
|
-
/** Maximum retained records per task; the newest survive. */
|
|
396
|
-
readonly records: number;
|
|
397
|
-
}
|
|
398
|
-
/** Newest-first saved deliveries, or a non-mutating task/cursor lookup failure. */
|
|
399
|
-
export type ScheduleDeliveryHistoryResult = {
|
|
369
|
+
/** One newest-first page of saved deliveries. */
|
|
370
|
+
export interface ScheduleDeliveryHistoryPage {
|
|
371
|
+
/** Task whose saved deliveries this page lists. */
|
|
400
372
|
readonly id: ScheduleId;
|
|
373
|
+
/** Saved deliveries, newest first. */
|
|
401
374
|
readonly records: ScheduleDeliveryRecord[];
|
|
402
|
-
/** Whether
|
|
375
|
+
/** Whether deliveries before the saved records may exist; the Host never reconstructs them. */
|
|
403
376
|
readonly earlierRecordsUnavailable: boolean;
|
|
404
|
-
/**
|
|
377
|
+
/** Whether a retention limit removed saved records; legacy history without that fact is false. */
|
|
405
378
|
readonly earlierRecordsPruned: boolean;
|
|
406
|
-
/** Current Host retention
|
|
379
|
+
/** Current Host retention limits; the delivery writer applies the same limits. */
|
|
407
380
|
readonly retention: DeliveryRetentionBounds;
|
|
408
|
-
/**
|
|
381
|
+
/** Cursor for the next page; present only when older saved records remain. */
|
|
409
382
|
readonly nextBefore?: MessageId;
|
|
410
|
-
}
|
|
383
|
+
}
|
|
384
|
+
/** Non-mutating miss: the task or the page cursor does not exist. */
|
|
385
|
+
export interface ScheduleDeliveryHistoryMiss {
|
|
386
|
+
/** Requested task identity. */
|
|
411
387
|
readonly id: ScheduleId;
|
|
388
|
+
/** `delivery_cursor_not_found` means `before` names no saved record of this task. */
|
|
412
389
|
readonly code: 'schedule_not_found' | 'delivery_cursor_not_found';
|
|
390
|
+
}
|
|
391
|
+
/** One saved-delivery page, or a non-mutating lookup miss. */
|
|
392
|
+
export type ScheduleDeliveryHistoryResult = ScheduleDeliveryHistoryPage | ScheduleDeliveryHistoryMiss;
|
|
393
|
+
/** Browser-safe Host task state. */
|
|
394
|
+
export type ScheduleCatalogEntry = ScheduleRecord & {
|
|
395
|
+
/** Destination of the next delivery. */
|
|
396
|
+
readonly target: ScheduleTarget;
|
|
397
|
+
/**
|
|
398
|
+
* Sessions told about later changes while their Agent is live: the creating and editing Agent Sessions and each
|
|
399
|
+
* existing or reserved target Session. Sessions created by a `new` target are excluded.
|
|
400
|
+
*/
|
|
401
|
+
readonly involvedSessionIds: SessionId[];
|
|
402
|
+
/** Only `active` tasks have a timer obligation; `paused` and `ended` tasks stay visible. */
|
|
403
|
+
readonly status: 'active' | 'paused' | 'ended';
|
|
404
|
+
/** Canonical UTC creation time. */
|
|
405
|
+
readonly createdAt?: string;
|
|
406
|
+
/** Canonical UTC time of the latest stored change; editors send it back as `expectedUpdatedAt`. */
|
|
407
|
+
readonly updatedAt?: string;
|
|
408
|
+
/**
|
|
409
|
+
* The latest delivery is queued or running in its reused target Session; a `new` target, whose deliveries run beside one
|
|
410
|
+
* another, never sets it.
|
|
411
|
+
*/
|
|
412
|
+
readonly executionActive?: true;
|
|
413
|
+
/** End of the minimum delivery interval, present while it remains in the future. */
|
|
414
|
+
readonly deliveryFloorEndsAt?: string;
|
|
415
|
+
/** Most recent durably acknowledged inbox delivery, when available. */
|
|
416
|
+
readonly lastDelivery?: ScheduleDeliveryReceipt;
|
|
413
417
|
};
|
|
418
|
+
/** Host task creation request. */
|
|
419
|
+
export interface ScheduleCreateRequest {
|
|
420
|
+
/** Task name of at most 120 characters, non-empty after trimming. */
|
|
421
|
+
readonly title: string;
|
|
422
|
+
/** Instruction sent at each occurrence; non-empty after trimming. */
|
|
423
|
+
readonly prompt: string;
|
|
424
|
+
/** Authoritative typed timing with at least one future occurrence. */
|
|
425
|
+
readonly timing: ScheduleTiming;
|
|
426
|
+
/** Delivery destination; omission creates one Session at first delivery and reuses it. */
|
|
427
|
+
readonly target?: ScheduleTargetRequest;
|
|
428
|
+
}
|
|
429
|
+
/** Host-wide task list request. */
|
|
430
|
+
export interface ScheduleListRequest {
|
|
431
|
+
/** `true` lists only active tasks; `false` lists only paused and ended tasks; omission lists all tasks. */
|
|
432
|
+
readonly active?: boolean;
|
|
433
|
+
/** Page size from 1 through 500; the default is 100. */
|
|
434
|
+
readonly limit?: number;
|
|
435
|
+
/** Number of sorted tasks to skip; the default is 0. */
|
|
436
|
+
readonly offset?: number;
|
|
437
|
+
}
|
|
438
|
+
/** One page of the Host-wide task list; active tasks come first, ordered by next occurrence. */
|
|
439
|
+
export interface ScheduleListResult {
|
|
440
|
+
/** Tasks in this page. */
|
|
441
|
+
readonly items: ScheduleCatalogEntry[];
|
|
442
|
+
/** Number of tasks in this page. */
|
|
443
|
+
readonly shown: number;
|
|
444
|
+
/** Number of tasks that match the filter. */
|
|
445
|
+
readonly total: number;
|
|
446
|
+
/** Applied page size. */
|
|
447
|
+
readonly limit: number;
|
|
448
|
+
/** Applied offset. */
|
|
449
|
+
readonly offset: number;
|
|
450
|
+
}
|
|
451
|
+
/** Read one task by canonical identity. */
|
|
452
|
+
export interface ScheduleViewRequest {
|
|
453
|
+
/** Task to read. */
|
|
454
|
+
readonly id: ScheduleId;
|
|
455
|
+
}
|
|
456
|
+
/** Non-mutating miss for an unknown task identity. */
|
|
457
|
+
export interface ScheduleNotFoundResult {
|
|
458
|
+
/** Requested task identity. */
|
|
459
|
+
readonly id: ScheduleId;
|
|
460
|
+
/** Lookup miss discriminator. */
|
|
461
|
+
readonly code: 'schedule_not_found';
|
|
462
|
+
}
|
|
463
|
+
/** Current task state, or a lookup miss. */
|
|
464
|
+
export type ScheduleViewResult = ScheduleCatalogEntry | ScheduleNotFoundResult;
|
|
465
|
+
/** Fields changed together by one atomic update; an omitted field keeps its stored value. */
|
|
466
|
+
export interface SchedulePatch {
|
|
467
|
+
/** Replacement task name. */
|
|
468
|
+
readonly title?: string;
|
|
469
|
+
/** Replacement instruction. */
|
|
470
|
+
readonly prompt?: string;
|
|
471
|
+
/** Replacement timing; a changed rule recomputes the next occurrence. */
|
|
472
|
+
readonly timing?: ScheduleTiming;
|
|
473
|
+
/** Replacement destination. */
|
|
474
|
+
readonly target?: ScheduleTargetRequest;
|
|
475
|
+
/** `false` pauses the task; `true` resumes a recurrence from its first future occurrence. */
|
|
476
|
+
readonly active?: boolean;
|
|
477
|
+
}
|
|
478
|
+
/** One closed edit operation. */
|
|
479
|
+
export type ScheduleEditRequest = {
|
|
480
|
+
/** Task to change. */
|
|
481
|
+
readonly id: ScheduleId;
|
|
482
|
+
/** Apply `patch` as one atomic change. */
|
|
483
|
+
readonly action: 'update';
|
|
484
|
+
/** Fields to change; at least one member is required. */
|
|
485
|
+
readonly patch: SchedulePatch;
|
|
486
|
+
/** `updatedAt` value that the editor read; a different stored value returns `schedule_conflict`. */
|
|
487
|
+
readonly expectedUpdatedAt?: string | null;
|
|
488
|
+
} | {
|
|
489
|
+
/** Task to remove. */
|
|
490
|
+
readonly id: ScheduleId;
|
|
491
|
+
/** Remove the task and its saved deliveries. */
|
|
492
|
+
readonly action: 'delete';
|
|
493
|
+
/** `updatedAt` value that the editor read; a different stored value returns `schedule_conflict`. */
|
|
494
|
+
readonly expectedUpdatedAt?: string | null;
|
|
495
|
+
};
|
|
496
|
+
/** Non-mutating refusal: the stored task changed after the editor read it. */
|
|
497
|
+
export interface ScheduleConflictResult {
|
|
498
|
+
/** Requested task identity. */
|
|
499
|
+
readonly id: ScheduleId;
|
|
500
|
+
/** Optimistic revision mismatch discriminator. */
|
|
501
|
+
readonly code: 'schedule_conflict';
|
|
502
|
+
}
|
|
503
|
+
/** Updated task state, a completed deletion, or a non-mutating miss or conflict. */
|
|
504
|
+
export type ScheduleEditResult = ScheduleCatalogEntry | Extract<ScheduleDeleteResult, {
|
|
505
|
+
readonly deleted: true;
|
|
506
|
+
}> | ScheduleNotFoundResult | ScheduleConflictResult;
|
|
507
|
+
/** Manual execution request from the human task manager. */
|
|
508
|
+
export interface ScheduleRunRequest {
|
|
509
|
+
/** Task to run now. */
|
|
510
|
+
readonly id: ScheduleId;
|
|
511
|
+
}
|
|
512
|
+
/** Non-mutating refusal: one execution of this task already owns its admission slot. */
|
|
513
|
+
export interface ScheduleExecutionPendingResult {
|
|
514
|
+
/** Requested task identity. */
|
|
515
|
+
readonly id: ScheduleId;
|
|
516
|
+
/** Consolidated execution discriminator. */
|
|
517
|
+
readonly code: 'schedule_execution_pending';
|
|
518
|
+
}
|
|
519
|
+
/** Task state after a manual delivery, or a non-mutating miss or refusal. */
|
|
520
|
+
export type ScheduleRunResult = ScheduleCatalogEntry | ScheduleNotFoundResult | ScheduleExecutionPendingResult;
|
|
521
|
+
declare module '@qilin-agent/typert-protocol' {
|
|
522
|
+
interface RemoteErrorDetailsMap {
|
|
523
|
+
/** The Schedule request failed validation before it was stored. */
|
|
524
|
+
'schedule/input-invalid': {
|
|
525
|
+
readonly code: ScheduleInputErrorCode;
|
|
526
|
+
};
|
|
527
|
+
/** A delivery or run reached a `session` target that the Workspace registry lists as archived. */
|
|
528
|
+
'schedule/target-archived': {
|
|
529
|
+
readonly sessionId: SessionId;
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
/** Successful Host-wide removal of every ended task, whether or not any remained. */
|
|
534
|
+
export interface ScheduleDeleteInactiveResult {
|
|
535
|
+
/** Ended task rows this call removed; zero when the Host held none. */
|
|
536
|
+
readonly deleted: number;
|
|
537
|
+
}
|
|
538
|
+
declare module '@qilin-agent/workspace/types' {
|
|
539
|
+
interface SessionActivityKindMap {
|
|
540
|
+
/** A scheduled follow-up for this session is still active. */
|
|
541
|
+
schedule: true;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
declare module '@qilin-agent/session/types' {
|
|
545
|
+
interface SessionEventMap {
|
|
546
|
+
/**
|
|
547
|
+
* Historical version-1 Session-local reminder mutation. New tasks live in Host storage;
|
|
548
|
+
* these events remain inert and never populate the Host task store.
|
|
549
|
+
*/
|
|
550
|
+
'schedule/change': ScheduleChange;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
414
553
|
declare module '@qilin-agent/kylin' {
|
|
415
554
|
interface Events {
|
|
416
555
|
/** Durable task set changed; clients refetch global task and Session-active catalogs.
|
package/lib/types/types.js
CHANGED
package/lib/types/update.d.ts
CHANGED
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ScheduleId, SchedulePatch, ScheduleRecord, ScheduleTiming } from './types.ts';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @param
|
|
8
|
-
* @
|
|
3
|
+
* Construct a current record with one authoritative timing kind and a future committed target.
|
|
4
|
+
* @param id - Host-generated task identity.
|
|
5
|
+
* @param title - Required user-facing task title.
|
|
6
|
+
* @param prompt - Non-empty instruction delivered at each occurrence.
|
|
7
|
+
* @param value - Exactly one typed timing selector.
|
|
8
|
+
* @param now - Explicit acceptance time in epoch milliseconds.
|
|
9
|
+
* @returns A validated record with its first future occurrence.
|
|
9
10
|
*/
|
|
10
|
-
export declare function
|
|
11
|
+
export declare function createScheduleRecord(id: ScheduleId, title: string, prompt: string, value: ScheduleTiming, now: number): ScheduleRecord;
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @param current - Current active Host record.
|
|
19
|
-
* @param expected - Untrusted complete record observed by the caller.
|
|
20
|
-
* @param change - Strict timing selector, whose kind may differ from the current record's kind, or undefined to keep timing.
|
|
21
|
-
* @param now - Single wall-clock sample from the accepted FIFO slot.
|
|
22
|
-
* @param content - Untrusted replacement name and instruction; each omitted field keeps its stored value.
|
|
23
|
-
* @returns Current/new record or a bounded input/conflict result; unrelated failures throw.
|
|
13
|
+
* Keep unchanged timing and committed targets, or re-arm through the same constructor as creation.
|
|
14
|
+
* @param current - Stored record before the edit.
|
|
15
|
+
* @param patch - Descriptive fields and optional typed timing replacement.
|
|
16
|
+
* @param now - Explicit edit acceptance time in epoch milliseconds.
|
|
17
|
+
* @param resume - Whether to find a future occurrence for unchanged timing.
|
|
18
|
+
* @returns The retained or revised authoritative timing record.
|
|
24
19
|
*/
|
|
25
|
-
export declare function
|
|
20
|
+
export declare function updateScheduleRecord(current: ScheduleRecord, patch: SchedulePatch, now: number, resume: boolean): ScheduleRecord;
|
|
26
21
|
//# sourceMappingURL=update.d.ts.map
|