@karmaniverous/jeeves-runner 0.5.0 → 0.7.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/dist/cli/jeeves-runner/index.js +564 -108
- package/dist/index.d.ts +68 -7
- package/dist/mjs/index.js +566 -104
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { DatabaseSync } from 'node:sqlite';
|
|
|
11
11
|
/** Full runner configuration schema. Validates and provides defaults. */
|
|
12
12
|
declare const runnerConfigSchema: z.ZodObject<{
|
|
13
13
|
port: z.ZodDefault<z.ZodNumber>;
|
|
14
|
+
host: z.ZodDefault<z.ZodString>;
|
|
14
15
|
dbPath: z.ZodDefault<z.ZodString>;
|
|
15
16
|
maxConcurrency: z.ZodDefault<z.ZodNumber>;
|
|
16
17
|
runRetentionDays: z.ZodDefault<z.ZodNumber>;
|
|
@@ -24,11 +25,11 @@ declare const runnerConfigSchema: z.ZodObject<{
|
|
|
24
25
|
}, z.core.$strip>>;
|
|
25
26
|
log: z.ZodDefault<z.ZodObject<{
|
|
26
27
|
level: z.ZodDefault<z.ZodEnum<{
|
|
27
|
-
error: "error";
|
|
28
28
|
trace: "trace";
|
|
29
29
|
debug: "debug";
|
|
30
30
|
info: "info";
|
|
31
31
|
warn: "warn";
|
|
32
|
+
error: "error";
|
|
32
33
|
fatal: "fatal";
|
|
33
34
|
}>>;
|
|
34
35
|
file: z.ZodOptional<z.ZodString>;
|
|
@@ -62,7 +63,6 @@ declare const jobSchema: z.ZodObject<{
|
|
|
62
63
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
63
64
|
overlapPolicy: z.ZodDefault<z.ZodEnum<{
|
|
64
65
|
skip: "skip";
|
|
65
|
-
queue: "queue";
|
|
66
66
|
allow: "allow";
|
|
67
67
|
}>>;
|
|
68
68
|
onFailure: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -103,9 +103,9 @@ type Queue = z.infer<typeof queueSchema>;
|
|
|
103
103
|
/** Run status enumeration schema (pending, running, ok, error, timeout, skipped). */
|
|
104
104
|
declare const runStatusSchema: z.ZodEnum<{
|
|
105
105
|
pending: "pending";
|
|
106
|
+
error: "error";
|
|
106
107
|
running: "running";
|
|
107
108
|
ok: "ok";
|
|
108
|
-
error: "error";
|
|
109
109
|
timeout: "timeout";
|
|
110
110
|
skipped: "skipped";
|
|
111
111
|
}>;
|
|
@@ -121,9 +121,9 @@ declare const runSchema: z.ZodObject<{
|
|
|
121
121
|
jobId: z.ZodString;
|
|
122
122
|
status: z.ZodEnum<{
|
|
123
123
|
pending: "pending";
|
|
124
|
+
error: "error";
|
|
124
125
|
running: "running";
|
|
125
126
|
ok: "ok";
|
|
126
|
-
error: "error";
|
|
127
127
|
timeout: "timeout";
|
|
128
128
|
skipped: "skipped";
|
|
129
129
|
}>;
|
|
@@ -151,6 +151,8 @@ type RunTrigger = z.infer<typeof runTriggerSchema>;
|
|
|
151
151
|
|
|
152
152
|
/**
|
|
153
153
|
* Main runner orchestrator. Wires up database, scheduler, API server, and handles graceful shutdown on SIGTERM/SIGINT.
|
|
154
|
+
*
|
|
155
|
+
* @module
|
|
154
156
|
*/
|
|
155
157
|
|
|
156
158
|
/** Runner interface for managing the runner lifecycle. */
|
|
@@ -172,6 +174,8 @@ declare function createRunner(config: RunnerConfig, deps?: RunnerDeps): Runner;
|
|
|
172
174
|
|
|
173
175
|
/**
|
|
174
176
|
* Queue operations module for runner client. Provides enqueue, dequeue, done, and fail operations.
|
|
177
|
+
*
|
|
178
|
+
* @module
|
|
175
179
|
*/
|
|
176
180
|
|
|
177
181
|
/** Queue item returned from dequeue operation. */
|
|
@@ -184,6 +188,8 @@ interface QueueItem {
|
|
|
184
188
|
|
|
185
189
|
/**
|
|
186
190
|
* Job client library for runner jobs. Provides state and queue operations. Opens its own DB connection via JR_DB_PATH env var.
|
|
191
|
+
*
|
|
192
|
+
* @module
|
|
187
193
|
*/
|
|
188
194
|
|
|
189
195
|
/** Client interface for job scripts to interact with runner state and queues. */
|
|
@@ -238,6 +244,8 @@ declare function createClient(dbPath?: string): RunnerClient;
|
|
|
238
244
|
|
|
239
245
|
/**
|
|
240
246
|
* Job executor. Spawns job scripts as child processes, captures output, parses result metadata, enforces timeouts.
|
|
247
|
+
*
|
|
248
|
+
* @module
|
|
241
249
|
*/
|
|
242
250
|
/** Result of a job execution. */
|
|
243
251
|
interface ExecutionResult {
|
|
@@ -279,6 +287,8 @@ interface ExecutionOptions {
|
|
|
279
287
|
timeoutMs?: number;
|
|
280
288
|
/** Optional custom command resolver (for extensibility). */
|
|
281
289
|
commandResolver?: (script: string) => ResolvedCommand;
|
|
290
|
+
/** Source type: 'path' uses script as file path, 'inline' writes script content to a temp file. */
|
|
291
|
+
sourceType?: 'path' | 'inline';
|
|
282
292
|
}
|
|
283
293
|
/**
|
|
284
294
|
* Execute a job script as a child process. Captures output, parses metadata, enforces timeout.
|
|
@@ -287,6 +297,8 @@ declare function executeJob(options: ExecutionOptions): Promise<ExecutionResult>
|
|
|
287
297
|
|
|
288
298
|
/**
|
|
289
299
|
* OpenClaw Gateway HTTP client for spawning and monitoring sessions.
|
|
300
|
+
*
|
|
301
|
+
* @module
|
|
290
302
|
*/
|
|
291
303
|
/** Options for creating a Gateway client. */
|
|
292
304
|
interface GatewayClientOptions {
|
|
@@ -345,6 +357,8 @@ declare function createGatewayClient(options: GatewayClientOptions): GatewayClie
|
|
|
345
357
|
|
|
346
358
|
/**
|
|
347
359
|
* Slack notification module. Sends job completion/failure messages via Slack Web API (chat.postMessage). Falls back gracefully if no token.
|
|
360
|
+
*
|
|
361
|
+
* @module
|
|
348
362
|
*/
|
|
349
363
|
/** Notification configuration. */
|
|
350
364
|
interface NotifyConfig {
|
|
@@ -375,7 +389,9 @@ interface Notifier {
|
|
|
375
389
|
declare function createNotifier(config: NotifyConfig): Notifier;
|
|
376
390
|
|
|
377
391
|
/**
|
|
378
|
-
*
|
|
392
|
+
* Job scheduler. Loads enabled jobs, registers schedules (cron or rrstack), manages execution, respects overlap policies and concurrency limits.
|
|
393
|
+
*
|
|
394
|
+
* @module
|
|
379
395
|
*/
|
|
380
396
|
|
|
381
397
|
/** Scheduler dependencies. */
|
|
@@ -413,8 +429,47 @@ interface Scheduler {
|
|
|
413
429
|
*/
|
|
414
430
|
declare function createScheduler(deps: SchedulerDeps): Scheduler;
|
|
415
431
|
|
|
432
|
+
/**
|
|
433
|
+
* Schedule parsing, validation, and next-fire-time computation for cron and RRStack formats.
|
|
434
|
+
*
|
|
435
|
+
* @module
|
|
436
|
+
*/
|
|
437
|
+
/** Successful schedule validation result. */
|
|
438
|
+
interface ScheduleValid {
|
|
439
|
+
/** Whether the schedule is valid. */
|
|
440
|
+
valid: true;
|
|
441
|
+
/** Detected schedule format. */
|
|
442
|
+
format: 'cron' | 'rrstack';
|
|
443
|
+
}
|
|
444
|
+
/** Failed schedule validation result. */
|
|
445
|
+
interface ScheduleInvalid {
|
|
446
|
+
/** Whether the schedule is valid. */
|
|
447
|
+
valid: false;
|
|
448
|
+
/** Descriptive error message. */
|
|
449
|
+
error: string;
|
|
450
|
+
}
|
|
451
|
+
/** Validation result for a schedule string. */
|
|
452
|
+
type ScheduleValidation = ScheduleValid | ScheduleInvalid;
|
|
453
|
+
/**
|
|
454
|
+
* Compute the next fire time for a schedule string.
|
|
455
|
+
* Supports cron expressions (via croner) and RRStack JSON (via nextEvent).
|
|
456
|
+
*
|
|
457
|
+
* @param schedule - Cron expression or RRStack JSON string.
|
|
458
|
+
* @returns Next fire time as a Date, or null if none can be determined.
|
|
459
|
+
*/
|
|
460
|
+
declare function getNextFireTime(schedule: string): Date | null;
|
|
461
|
+
/**
|
|
462
|
+
* Validate a schedule string as either a cron expression or RRStack JSON.
|
|
463
|
+
*
|
|
464
|
+
* @param schedule - Cron expression or RRStack JSON string.
|
|
465
|
+
* @returns Validation result with format on success, or error message on failure.
|
|
466
|
+
*/
|
|
467
|
+
declare function validateSchedule(schedule: string): ScheduleValidation;
|
|
468
|
+
|
|
416
469
|
/**
|
|
417
470
|
* Session executor for job type='session'. Spawns OpenClaw Gateway sessions and polls for completion.
|
|
471
|
+
*
|
|
472
|
+
* @module
|
|
418
473
|
*/
|
|
419
474
|
|
|
420
475
|
/** Options for executing a session job. */
|
|
@@ -437,6 +492,8 @@ declare function executeSession(options: SessionExecutionOptions): Promise<Execu
|
|
|
437
492
|
|
|
438
493
|
/**
|
|
439
494
|
* SQLite connection manager. Creates DB file with parent directories, enables WAL mode for concurrency.
|
|
495
|
+
*
|
|
496
|
+
* @module
|
|
440
497
|
*/
|
|
441
498
|
|
|
442
499
|
/**
|
|
@@ -451,6 +508,8 @@ declare function closeConnection(db: DatabaseSync): void;
|
|
|
451
508
|
|
|
452
509
|
/**
|
|
453
510
|
* Database maintenance tasks: run retention pruning and expired state cleanup.
|
|
511
|
+
*
|
|
512
|
+
* @module
|
|
454
513
|
*/
|
|
455
514
|
|
|
456
515
|
/** Configuration for maintenance tasks. */
|
|
@@ -476,6 +535,8 @@ declare function createMaintenance(db: DatabaseSync, config: MaintenanceConfig,
|
|
|
476
535
|
|
|
477
536
|
/**
|
|
478
537
|
* Schema migration runner. Tracks applied migrations via schema_version table, applies pending migrations idempotently.
|
|
538
|
+
*
|
|
539
|
+
* @module
|
|
479
540
|
*/
|
|
480
541
|
|
|
481
542
|
/**
|
|
@@ -483,5 +544,5 @@ declare function createMaintenance(db: DatabaseSync, config: MaintenanceConfig,
|
|
|
483
544
|
*/
|
|
484
545
|
declare function runMigrations(db: DatabaseSync): void;
|
|
485
546
|
|
|
486
|
-
export { closeConnection, createClient, createConnection, createGatewayClient, createMaintenance, createNotifier, createRunner, createScheduler, executeJob, executeSession, jobSchema, queueSchema, runMigrations, runSchema, runStatusSchema, runTriggerSchema, runnerConfigSchema };
|
|
487
|
-
export type { ExecutionOptions, ExecutionResult, GatewayClient, GatewayClientOptions, Job, Maintenance, MaintenanceConfig, Notifier, NotifyConfig, NotifyLogger, Queue, QueueItem, ResolvedCommand, Run, RunStatus, RunTrigger, Runner, RunnerClient, RunnerConfig, RunnerDeps, Scheduler, SchedulerDeps, SessionExecutionOptions, SessionInfo, SessionMessage, SpawnSessionOptions, SpawnSessionResult };
|
|
547
|
+
export { closeConnection, createClient, createConnection, createGatewayClient, createMaintenance, createNotifier, createRunner, createScheduler, executeJob, executeSession, getNextFireTime, jobSchema, queueSchema, runMigrations, runSchema, runStatusSchema, runTriggerSchema, runnerConfigSchema, validateSchedule };
|
|
548
|
+
export type { ExecutionOptions, ExecutionResult, GatewayClient, GatewayClientOptions, Job, Maintenance, MaintenanceConfig, Notifier, NotifyConfig, NotifyLogger, Queue, QueueItem, ResolvedCommand, Run, RunStatus, RunTrigger, Runner, RunnerClient, RunnerConfig, RunnerDeps, ScheduleInvalid, ScheduleValid, ScheduleValidation, Scheduler, SchedulerDeps, SessionExecutionOptions, SessionInfo, SessionMessage, SpawnSessionOptions, SpawnSessionResult };
|