cronies-cli 0.1.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/LICENSE +21 -0
- package/README.md +33 -0
- package/dist/bin/cronies.d.ts +3 -0
- package/dist/bin/cronies.d.ts.map +1 -0
- package/dist/chunk-FVB2S2MS.js +4229 -0
- package/dist/cronies.js +331 -0
- package/dist/index.js +189 -0
- package/dist/src/adapters/index.d.ts +2 -0
- package/dist/src/adapters/index.d.ts.map +1 -0
- package/dist/src/adapters/manager.d.ts +6 -0
- package/dist/src/adapters/manager.d.ts.map +1 -0
- package/dist/src/cli/index.d.ts +3 -0
- package/dist/src/cli/index.d.ts.map +1 -0
- package/dist/src/config/index.d.ts +4 -0
- package/dist/src/config/index.d.ts.map +1 -0
- package/dist/src/config/loader.d.ts +13 -0
- package/dist/src/config/loader.d.ts.map +1 -0
- package/dist/src/config/schema.d.ts +160 -0
- package/dist/src/config/schema.d.ts.map +1 -0
- package/dist/src/config/writer.d.ts +17 -0
- package/dist/src/config/writer.d.ts.map +1 -0
- package/dist/src/daemon.d.ts +11 -0
- package/dist/src/daemon.d.ts.map +1 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/logger.d.ts +13 -0
- package/dist/src/logger.d.ts.map +1 -0
- package/dist/src/orchestrator/health.d.ts +20 -0
- package/dist/src/orchestrator/health.d.ts.map +1 -0
- package/dist/src/orchestrator/index.d.ts +2 -0
- package/dist/src/orchestrator/index.d.ts.map +1 -0
- package/dist/src/orchestrator/runner.d.ts +102 -0
- package/dist/src/orchestrator/runner.d.ts.map +1 -0
- package/dist/src/orchestrator/summary.d.ts +19 -0
- package/dist/src/orchestrator/summary.d.ts.map +1 -0
- package/dist/src/pid.d.ts +20 -0
- package/dist/src/pid.d.ts.map +1 -0
- package/dist/src/policy/engine.d.ts +41 -0
- package/dist/src/policy/engine.d.ts.map +1 -0
- package/dist/src/policy/index.d.ts +2 -0
- package/dist/src/policy/index.d.ts.map +1 -0
- package/dist/src/server.d.ts +8 -0
- package/dist/src/server.d.ts.map +1 -0
- package/dist/src/sessionHealthMonitor.d.ts +29 -0
- package/dist/src/sessionHealthMonitor.d.ts.map +1 -0
- package/dist/src/storage/database.d.ts +3 -0
- package/dist/src/storage/database.d.ts.map +1 -0
- package/dist/src/storage/index.d.ts +4 -0
- package/dist/src/storage/index.d.ts.map +1 -0
- package/dist/src/storage/migrations.d.ts +3 -0
- package/dist/src/storage/migrations.d.ts.map +1 -0
- package/dist/src/storage/store.d.ts +80 -0
- package/dist/src/storage/store.d.ts.map +1 -0
- package/dist/src/sync/connection.d.ts +37 -0
- package/dist/src/sync/connection.d.ts.map +1 -0
- package/dist/src/sync/index.d.ts +7 -0
- package/dist/src/sync/index.d.ts.map +1 -0
- package/dist/src/sync/queue.d.ts +22 -0
- package/dist/src/sync/queue.d.ts.map +1 -0
- package/dist/src/sync/reconciler.d.ts +42 -0
- package/dist/src/sync/reconciler.d.ts.map +1 -0
- package/dist/src/sync/rest-client.d.ts +62 -0
- package/dist/src/sync/rest-client.d.ts.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const DaemonConfigSchema: z.ZodObject<{
|
|
3
|
+
daemon: z.ZodDefault<z.ZodObject<{
|
|
4
|
+
port: z.ZodDefault<z.ZodNumber>;
|
|
5
|
+
logLevel: z.ZodDefault<z.ZodEnum<["debug", "info", "warn", "error"]>>;
|
|
6
|
+
dataDir: z.ZodDefault<z.ZodString>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
port: number;
|
|
9
|
+
logLevel: "debug" | "info" | "warn" | "error";
|
|
10
|
+
dataDir: string;
|
|
11
|
+
}, {
|
|
12
|
+
port?: number | undefined;
|
|
13
|
+
logLevel?: "debug" | "info" | "warn" | "error" | undefined;
|
|
14
|
+
dataDir?: string | undefined;
|
|
15
|
+
}>>;
|
|
16
|
+
cloud: z.ZodDefault<z.ZodObject<{
|
|
17
|
+
url: z.ZodDefault<z.ZodString>;
|
|
18
|
+
token: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
url: string;
|
|
21
|
+
token?: string | undefined;
|
|
22
|
+
}, {
|
|
23
|
+
url?: string | undefined;
|
|
24
|
+
token?: string | undefined;
|
|
25
|
+
}>>;
|
|
26
|
+
agents: z.ZodDefault<z.ZodObject<{
|
|
27
|
+
'claude-code': z.ZodDefault<z.ZodObject<{
|
|
28
|
+
path: z.ZodDefault<z.ZodString>;
|
|
29
|
+
defaultFlags: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
31
|
+
path: string;
|
|
32
|
+
defaultFlags: string[];
|
|
33
|
+
}, {
|
|
34
|
+
path?: string | undefined;
|
|
35
|
+
defaultFlags?: string[] | undefined;
|
|
36
|
+
}>>;
|
|
37
|
+
'codex-cli': z.ZodDefault<z.ZodObject<{
|
|
38
|
+
path: z.ZodDefault<z.ZodString>;
|
|
39
|
+
defaultFlags: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
path: string;
|
|
42
|
+
defaultFlags: string[];
|
|
43
|
+
}, {
|
|
44
|
+
path?: string | undefined;
|
|
45
|
+
defaultFlags?: string[] | undefined;
|
|
46
|
+
}>>;
|
|
47
|
+
'gemini-cli': z.ZodDefault<z.ZodObject<{
|
|
48
|
+
path: z.ZodDefault<z.ZodString>;
|
|
49
|
+
defaultFlags: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
50
|
+
}, "strip", z.ZodTypeAny, {
|
|
51
|
+
path: string;
|
|
52
|
+
defaultFlags: string[];
|
|
53
|
+
}, {
|
|
54
|
+
path?: string | undefined;
|
|
55
|
+
defaultFlags?: string[] | undefined;
|
|
56
|
+
}>>;
|
|
57
|
+
'cursor-agent': z.ZodDefault<z.ZodObject<{
|
|
58
|
+
path: z.ZodDefault<z.ZodString>;
|
|
59
|
+
defaultFlags: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
path: string;
|
|
62
|
+
defaultFlags: string[];
|
|
63
|
+
}, {
|
|
64
|
+
path?: string | undefined;
|
|
65
|
+
defaultFlags?: string[] | undefined;
|
|
66
|
+
}>>;
|
|
67
|
+
}, "strip", z.ZodTypeAny, {
|
|
68
|
+
'claude-code': {
|
|
69
|
+
path: string;
|
|
70
|
+
defaultFlags: string[];
|
|
71
|
+
};
|
|
72
|
+
'codex-cli': {
|
|
73
|
+
path: string;
|
|
74
|
+
defaultFlags: string[];
|
|
75
|
+
};
|
|
76
|
+
'gemini-cli': {
|
|
77
|
+
path: string;
|
|
78
|
+
defaultFlags: string[];
|
|
79
|
+
};
|
|
80
|
+
'cursor-agent': {
|
|
81
|
+
path: string;
|
|
82
|
+
defaultFlags: string[];
|
|
83
|
+
};
|
|
84
|
+
}, {
|
|
85
|
+
'claude-code'?: {
|
|
86
|
+
path?: string | undefined;
|
|
87
|
+
defaultFlags?: string[] | undefined;
|
|
88
|
+
} | undefined;
|
|
89
|
+
'codex-cli'?: {
|
|
90
|
+
path?: string | undefined;
|
|
91
|
+
defaultFlags?: string[] | undefined;
|
|
92
|
+
} | undefined;
|
|
93
|
+
'gemini-cli'?: {
|
|
94
|
+
path?: string | undefined;
|
|
95
|
+
defaultFlags?: string[] | undefined;
|
|
96
|
+
} | undefined;
|
|
97
|
+
'cursor-agent'?: {
|
|
98
|
+
path?: string | undefined;
|
|
99
|
+
defaultFlags?: string[] | undefined;
|
|
100
|
+
} | undefined;
|
|
101
|
+
}>>;
|
|
102
|
+
}, "strip", z.ZodTypeAny, {
|
|
103
|
+
daemon: {
|
|
104
|
+
port: number;
|
|
105
|
+
logLevel: "debug" | "info" | "warn" | "error";
|
|
106
|
+
dataDir: string;
|
|
107
|
+
};
|
|
108
|
+
cloud: {
|
|
109
|
+
url: string;
|
|
110
|
+
token?: string | undefined;
|
|
111
|
+
};
|
|
112
|
+
agents: {
|
|
113
|
+
'claude-code': {
|
|
114
|
+
path: string;
|
|
115
|
+
defaultFlags: string[];
|
|
116
|
+
};
|
|
117
|
+
'codex-cli': {
|
|
118
|
+
path: string;
|
|
119
|
+
defaultFlags: string[];
|
|
120
|
+
};
|
|
121
|
+
'gemini-cli': {
|
|
122
|
+
path: string;
|
|
123
|
+
defaultFlags: string[];
|
|
124
|
+
};
|
|
125
|
+
'cursor-agent': {
|
|
126
|
+
path: string;
|
|
127
|
+
defaultFlags: string[];
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
}, {
|
|
131
|
+
daemon?: {
|
|
132
|
+
port?: number | undefined;
|
|
133
|
+
logLevel?: "debug" | "info" | "warn" | "error" | undefined;
|
|
134
|
+
dataDir?: string | undefined;
|
|
135
|
+
} | undefined;
|
|
136
|
+
cloud?: {
|
|
137
|
+
url?: string | undefined;
|
|
138
|
+
token?: string | undefined;
|
|
139
|
+
} | undefined;
|
|
140
|
+
agents?: {
|
|
141
|
+
'claude-code'?: {
|
|
142
|
+
path?: string | undefined;
|
|
143
|
+
defaultFlags?: string[] | undefined;
|
|
144
|
+
} | undefined;
|
|
145
|
+
'codex-cli'?: {
|
|
146
|
+
path?: string | undefined;
|
|
147
|
+
defaultFlags?: string[] | undefined;
|
|
148
|
+
} | undefined;
|
|
149
|
+
'gemini-cli'?: {
|
|
150
|
+
path?: string | undefined;
|
|
151
|
+
defaultFlags?: string[] | undefined;
|
|
152
|
+
} | undefined;
|
|
153
|
+
'cursor-agent'?: {
|
|
154
|
+
path?: string | undefined;
|
|
155
|
+
defaultFlags?: string[] | undefined;
|
|
156
|
+
} | undefined;
|
|
157
|
+
} | undefined;
|
|
158
|
+
}>;
|
|
159
|
+
export type DaemonConfig = z.infer<typeof DaemonConfigSchema>;
|
|
160
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4B7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the default config file path: `~/.cronies/config.yaml`
|
|
3
|
+
* with `~` expanded to the actual home directory.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getDefaultConfigPath(): string;
|
|
6
|
+
/**
|
|
7
|
+
* Write a cloud authentication token to the Cronies config file.
|
|
8
|
+
*
|
|
9
|
+
* - Reads the existing config (if any) and preserves all other values.
|
|
10
|
+
* - Creates the `~/.cronies/` directory and file if they don't exist.
|
|
11
|
+
* - Sets `cloud.token` to the provided value and writes back as YAML.
|
|
12
|
+
*
|
|
13
|
+
* @param token - The cloud authentication token to store.
|
|
14
|
+
* @param configPath - Optional override for the config file path.
|
|
15
|
+
*/
|
|
16
|
+
export declare function writeConfigToken(token: string, configPath?: string): void;
|
|
17
|
+
//# sourceMappingURL=writer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../../src/config/writer.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CA2BzE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DaemonConfig } from './config/index.js';
|
|
2
|
+
import type { Logger } from './logger.js';
|
|
3
|
+
/**
|
|
4
|
+
* Start the Cronies daemon process.
|
|
5
|
+
*
|
|
6
|
+
* Initialises the data directory, database, adapter manager, policy engine,
|
|
7
|
+
* sync components, and job runners. Connects to the cloud if a token is
|
|
8
|
+
* configured. Registers SIGTERM/SIGINT handlers for graceful shutdown.
|
|
9
|
+
*/
|
|
10
|
+
export declare function startDaemon(config: DaemonConfig, logger: Logger): Promise<void>;
|
|
11
|
+
//# sourceMappingURL=daemon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemon.d.ts","sourceRoot":"","sources":["../../src/daemon.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAuP1C;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAySrF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { startDaemon } from './daemon.js';
|
|
2
|
+
export { loadConfig, resolveDataDir, DaemonConfigSchema, type DaemonConfig } from './config/index.js';
|
|
3
|
+
export { createLogger, type Logger, type LogLevel } from './logger.js';
|
|
4
|
+
export { writePidFile, readPidFile, removePidFile, isDaemonRunning } from './pid.js';
|
|
5
|
+
export { createDatabase } from './storage/database.js';
|
|
6
|
+
export { DaemonStore, type DaemonJob, type OutboxMessage } from './storage/store.js';
|
|
7
|
+
export { createAdapterManager } from './adapters/index.js';
|
|
8
|
+
export { LocalPolicyEngine, type PolicyVerdict } from './policy/engine.js';
|
|
9
|
+
export { JobRunner, type JobRunnerOptions, type JobRunnerCallbacks } from './orchestrator/runner.js';
|
|
10
|
+
export { SessionHealthMonitor } from './orchestrator/health.js';
|
|
11
|
+
export { SyncClient, type SyncClientOptions } from './sync/connection.js';
|
|
12
|
+
export { SyncQueue } from './sync/queue.js';
|
|
13
|
+
export { SyncReconciler } from './sync/reconciler.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtG,OAAO,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,KAAK,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACrG,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
2
|
+
export interface Logger {
|
|
3
|
+
debug(msg: string, data?: Record<string, unknown>): void;
|
|
4
|
+
info(msg: string, data?: Record<string, unknown>): void;
|
|
5
|
+
warn(msg: string, data?: Record<string, unknown>): void;
|
|
6
|
+
error(msg: string, data?: Record<string, unknown>): void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Create a structured logger that writes to stderr.
|
|
10
|
+
* Messages below the configured level are silently dropped.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createLogger(level: LogLevel): Logger;
|
|
13
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3D,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACzD,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACxD,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACxD,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC1D;AAsBD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CAepD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { OrchestratorContext, SessionHealth, HealthThresholds } from '@cronies/core';
|
|
2
|
+
export declare class SessionHealthMonitor {
|
|
3
|
+
private thresholds;
|
|
4
|
+
private lastOutputAt;
|
|
5
|
+
private processAlive;
|
|
6
|
+
private runId;
|
|
7
|
+
constructor(runId: string, thresholds?: Partial<HealthThresholds>);
|
|
8
|
+
/** Call when agent output is received to reset the idle timer. */
|
|
9
|
+
recordOutput(): void;
|
|
10
|
+
/** Call when agent process spawns or dies. */
|
|
11
|
+
setProcessAlive(alive: boolean): void;
|
|
12
|
+
/** Compute the current health snapshot from orchestrator context. */
|
|
13
|
+
compute(context: OrchestratorContext, machineState: string): SessionHealth;
|
|
14
|
+
private computeSignals;
|
|
15
|
+
private deriveStatus;
|
|
16
|
+
private countConsecutiveErrors;
|
|
17
|
+
private detectStuckLoop;
|
|
18
|
+
private buildSummary;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=health.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../../src/orchestrator/health.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EAGnB,aAAa,EAGb,gBAAgB,EAEjB,MAAM,eAAe,CAAC;AAOvB,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,UAAU,CAAmB;IACrC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,KAAK,CAAS;gBAEV,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC;IAMjE,kEAAkE;IAClE,YAAY,IAAI,IAAI;IAIpB,8CAA8C;IAC9C,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAIrC,qEAAqE;IACrE,OAAO,CAAC,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,GAAG,aAAa;IAsB1E,OAAO,CAAC,cAAc;IA4CtB,OAAO,CAAC,YAAY;IA0CpB,OAAO,CAAC,sBAAsB;IAe9B,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,YAAY;CAuCrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/orchestrator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { type SessionSummary } from './summary.js';
|
|
2
|
+
import { type OrchestratorContext, type EscalationRequest, type Checkpoint, type RunEvent, type SessionHealth, type HealthThresholds } from '@cronies/core';
|
|
3
|
+
import type { AgentAdapter, ClassificationRule } from '@cronies/adapters';
|
|
4
|
+
import { LocalPolicyEngine } from '../policy/engine.js';
|
|
5
|
+
export interface JobRunnerOptions {
|
|
6
|
+
jobId: string;
|
|
7
|
+
outcomeId: string;
|
|
8
|
+
runId: string;
|
|
9
|
+
daemonId: string;
|
|
10
|
+
adapter: AgentAdapter;
|
|
11
|
+
policy: LocalPolicyEngine;
|
|
12
|
+
prompt: string;
|
|
13
|
+
workingDirectory: string;
|
|
14
|
+
/** @deprecated All sessions now run headless (supervised). */
|
|
15
|
+
sessionMode?: 'interactive' | 'supervised';
|
|
16
|
+
classificationRules?: ClassificationRule[];
|
|
17
|
+
/** Resume from a previous checkpoint's serialised machine snapshot. */
|
|
18
|
+
checkpoint?: {
|
|
19
|
+
machineState: string;
|
|
20
|
+
machineContext: string;
|
|
21
|
+
};
|
|
22
|
+
/** Custom health thresholds for this session. */
|
|
23
|
+
healthThresholds?: Partial<HealthThresholds>;
|
|
24
|
+
}
|
|
25
|
+
export interface JobRunnerCallbacks {
|
|
26
|
+
onEscalation?: (request: EscalationRequest) => void;
|
|
27
|
+
onCheckpoint?: (checkpoint: Checkpoint) => void;
|
|
28
|
+
onRunEvent?: (event: RunEvent) => void;
|
|
29
|
+
onComplete?: (success: boolean) => void;
|
|
30
|
+
onStateChange?: (state: string) => void;
|
|
31
|
+
onSpawned?: (pid: number) => void;
|
|
32
|
+
onHealthChange?: (health: SessionHealth) => void;
|
|
33
|
+
}
|
|
34
|
+
export declare class JobRunner {
|
|
35
|
+
private actor;
|
|
36
|
+
private adapter;
|
|
37
|
+
private process;
|
|
38
|
+
private policy;
|
|
39
|
+
private prompt;
|
|
40
|
+
private workingDirectory;
|
|
41
|
+
private classificationRules;
|
|
42
|
+
private outputBuffer;
|
|
43
|
+
private lastExitCode;
|
|
44
|
+
private runId;
|
|
45
|
+
private callbacks;
|
|
46
|
+
private eventSequence;
|
|
47
|
+
private jobId;
|
|
48
|
+
private daemonId;
|
|
49
|
+
private hardTimeoutTimer;
|
|
50
|
+
private healthMonitor;
|
|
51
|
+
private healthInterval;
|
|
52
|
+
constructor(options: JobRunnerOptions, callbacks?: JobRunnerCallbacks);
|
|
53
|
+
/** Start the actor and send the JOB_ASSIGNED event to kick things off. */
|
|
54
|
+
start(): Promise<void>;
|
|
55
|
+
/** Pause the running job (checkpoints machine state). */
|
|
56
|
+
pause(): void;
|
|
57
|
+
/** Resume from a paused state. */
|
|
58
|
+
resume(): void;
|
|
59
|
+
/** Cancel the job and terminate any running agent. */
|
|
60
|
+
cancel(): void;
|
|
61
|
+
/** Forward a cloud escalation decision into the machine. */
|
|
62
|
+
deliverDecision(decision: import('@cronies/core').EscalationDecision): void;
|
|
63
|
+
/** Send ACTION_COMPLETE to advance past acting sub-states. */
|
|
64
|
+
completeAction(): void;
|
|
65
|
+
/** Return the current state value as a string. */
|
|
66
|
+
getState(): string;
|
|
67
|
+
/** Return the current agent process (for PID tracking). */
|
|
68
|
+
getProcess(): import('@cronies/adapters').AgentProcess | null;
|
|
69
|
+
/** Return the current machine context. */
|
|
70
|
+
getContext(): OrchestratorContext;
|
|
71
|
+
/** Return the run ID for this runner. */
|
|
72
|
+
getRunId(): string;
|
|
73
|
+
/** Extract a structured summary from the session's output. */
|
|
74
|
+
getSessionSummary(): SessionSummary;
|
|
75
|
+
/** Compute and return the current session health snapshot. */
|
|
76
|
+
getHealth(): import('@cronies/core').SessionHealth;
|
|
77
|
+
/** Serialise the full machine snapshot for checkpointing. */
|
|
78
|
+
getPersistedSnapshot(): string;
|
|
79
|
+
/** Stop the actor and terminate any running agent process. */
|
|
80
|
+
stop(): void;
|
|
81
|
+
/** Update the policy engine (e.g. after cloud sends a policy update). */
|
|
82
|
+
updatePolicy(snapshot: import('@cronies/core').PolicySnapshot): void;
|
|
83
|
+
private spawnAgent;
|
|
84
|
+
private terminateProcess;
|
|
85
|
+
private handleOutput;
|
|
86
|
+
private summarizeOutput;
|
|
87
|
+
private classifyAndAct;
|
|
88
|
+
private handleExit;
|
|
89
|
+
private emitHealth;
|
|
90
|
+
private emitCheckpoint;
|
|
91
|
+
private emitEscalation;
|
|
92
|
+
private emitRunEvent;
|
|
93
|
+
private inferEscalationType;
|
|
94
|
+
private inferSeverity;
|
|
95
|
+
private buildLocalAssessment;
|
|
96
|
+
/**
|
|
97
|
+
* Convert an XState state value (which can be a string or nested object)
|
|
98
|
+
* to a flat dot-separated string for logging and reporting.
|
|
99
|
+
*/
|
|
100
|
+
private serializeStateValue;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../src/orchestrator/runner.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract a structured session summary from agent output.
|
|
3
|
+
*
|
|
4
|
+
* Pattern-matches the output buffer to identify files changed, tools used,
|
|
5
|
+
* errors, and the agent's final result. Works across all agent CLI formats
|
|
6
|
+
* (Claude Code, Cursor, Gemini, Codex) by looking for common patterns.
|
|
7
|
+
*/
|
|
8
|
+
export interface SessionSummary {
|
|
9
|
+
filesCreated: string[];
|
|
10
|
+
filesModified: string[];
|
|
11
|
+
toolsUsed: string[];
|
|
12
|
+
errors: string[];
|
|
13
|
+
finalResult: string;
|
|
14
|
+
tokensUsed: number | null;
|
|
15
|
+
agentVersion: string | null;
|
|
16
|
+
model: string | null;
|
|
17
|
+
}
|
|
18
|
+
export declare function extractSessionSummary(outputBuffer: string[]): SessionSummary;
|
|
19
|
+
//# sourceMappingURL=summary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../../src/orchestrator/summary.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAuDD,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,cAAc,CAuG5E"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Write the current process PID to `<dataDir>/daemon.pid`.
|
|
3
|
+
* Creates the data directory if it does not exist.
|
|
4
|
+
*/
|
|
5
|
+
export declare function writePidFile(dataDir: string): void;
|
|
6
|
+
/**
|
|
7
|
+
* Read the PID from `<dataDir>/daemon.pid`.
|
|
8
|
+
* Returns `null` if the file does not exist or is unreadable.
|
|
9
|
+
*/
|
|
10
|
+
export declare function readPidFile(dataDir: string): number | null;
|
|
11
|
+
/**
|
|
12
|
+
* Delete the PID file. No-op if it does not exist.
|
|
13
|
+
*/
|
|
14
|
+
export declare function removePidFile(dataDir: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Check whether a daemon process is currently alive.
|
|
17
|
+
* Reads the PID file and probes the process with signal 0.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isDaemonRunning(dataDir: string): boolean;
|
|
20
|
+
//# sourceMappingURL=pid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pid.d.ts","sourceRoot":"","sources":["../../src/pid.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAGlD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAW1D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAOnD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAUxD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { PolicySnapshot, Classification } from '@cronies/core';
|
|
2
|
+
export interface PolicyVerdict {
|
|
3
|
+
allowed: boolean;
|
|
4
|
+
action: 'allow' | 'deny' | 'escalate';
|
|
5
|
+
reason: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* In-memory policy engine that evaluates agent actions against the most
|
|
9
|
+
* recent policy snapshot received from the cloud.
|
|
10
|
+
*
|
|
11
|
+
* The engine enforces deny lists, escalation patterns, risk thresholds,
|
|
12
|
+
* retry limits, time limits, and cost limits entirely locally.
|
|
13
|
+
*/
|
|
14
|
+
export declare class LocalPolicyEngine {
|
|
15
|
+
private snapshot;
|
|
16
|
+
constructor(snapshot: PolicySnapshot);
|
|
17
|
+
/** Replace the active policy snapshot (e.g. after a cloud policy update). */
|
|
18
|
+
updatePolicy(snapshot: PolicySnapshot): void;
|
|
19
|
+
/** Return the current policy snapshot. */
|
|
20
|
+
getSnapshot(): PolicySnapshot;
|
|
21
|
+
/**
|
|
22
|
+
* Evaluate whether a classified action should proceed.
|
|
23
|
+
*
|
|
24
|
+
* Order of checks:
|
|
25
|
+
* 1. Deny list (hard block)
|
|
26
|
+
* 2. Escalation patterns (regex match -> escalate)
|
|
27
|
+
* 3. Risk threshold (score exceeds limit -> escalate)
|
|
28
|
+
* 4. Allowed list (if non-empty, action must be listed)
|
|
29
|
+
* 5. Default allow
|
|
30
|
+
*/
|
|
31
|
+
evaluateAction(classification: Classification): PolicyVerdict;
|
|
32
|
+
/** True when retryCount is below the local retry threshold. */
|
|
33
|
+
canRetryLocally(retryCount: number): boolean;
|
|
34
|
+
/** True when the job is still within its maximum wall-clock duration. */
|
|
35
|
+
isWithinTimeLimit(startedAt: number): boolean;
|
|
36
|
+
/** True when accumulated agent CPU time is below the policy limit. */
|
|
37
|
+
isWithinCostLimit(totalAgentTimeMs: number): boolean;
|
|
38
|
+
private isDenied;
|
|
39
|
+
private matchesEscalationPattern;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../src/policy/engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAMpE,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,UAAU,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC;CAChB;AAMD;;;;;;GAMG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAiB;gBAErB,QAAQ,EAAE,cAAc;IAIpC,6EAA6E;IAC7E,YAAY,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAI5C,0CAA0C;IAC1C,WAAW,IAAI,cAAc;IAQ7B;;;;;;;;;OASG;IACH,cAAc,CAAC,cAAc,EAAE,cAAc,GAAG,aAAa;IAiD7D,+DAA+D;IAC/D,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAI5C,yEAAyE;IACzE,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAI7C,sEAAsE;IACtE,iBAAiB,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO;IAQpD,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,wBAAwB;CASjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/policy/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type IncomingMessage, type ServerResponse } from 'node:http';
|
|
2
|
+
import type { Logger } from './logger.js';
|
|
3
|
+
export declare function createDaemonServer(options: {
|
|
4
|
+
port: number;
|
|
5
|
+
apiToken?: string;
|
|
6
|
+
logger: Logger;
|
|
7
|
+
}): import("node:http").Server<typeof IncomingMessage, typeof ServerResponse>;
|
|
8
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAKA,OAAO,EAAgB,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAGpF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AA2L1C,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,6EA0CA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { DaemonStore } from './storage/store.js';
|
|
2
|
+
import type { RestClient } from './sync/rest-client.js';
|
|
3
|
+
import type { JobRunner } from './orchestrator/runner.js';
|
|
4
|
+
import type { Logger } from './logger.js';
|
|
5
|
+
export interface SessionHealthMonitorOptions {
|
|
6
|
+
store: DaemonStore;
|
|
7
|
+
restClient: RestClient | null;
|
|
8
|
+
runners: Map<string, JobRunner>;
|
|
9
|
+
logger: Logger;
|
|
10
|
+
}
|
|
11
|
+
export declare class DaemonSessionHealthMonitor {
|
|
12
|
+
private store;
|
|
13
|
+
private restClient;
|
|
14
|
+
private runners;
|
|
15
|
+
private logger;
|
|
16
|
+
private timer;
|
|
17
|
+
private readonly checkIntervalMs;
|
|
18
|
+
private readonly staleTimeoutMs;
|
|
19
|
+
constructor(options: SessionHealthMonitorOptions);
|
|
20
|
+
/** Start the periodic health check timer. */
|
|
21
|
+
start(): void;
|
|
22
|
+
/** Stop the health check timer for graceful shutdown. */
|
|
23
|
+
stop(): void;
|
|
24
|
+
/** Run a single health check pass. Exposed for testing. */
|
|
25
|
+
check(): void;
|
|
26
|
+
private isProcessAlive;
|
|
27
|
+
private getRunIdFromRunner;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=sessionHealthMonitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionHealthMonitor.d.ts","sourceRoot":"","sources":["../../src/sessionHealthMonitor.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,WAAW,CAAC;IACnB,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,0BAA0B;IACrC,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,UAAU,CAAoB;IACtC,OAAO,CAAC,OAAO,CAAyB;IACxC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAA+C;IAE5D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;gBAE5B,OAAO,EAAE,2BAA2B;IAiBhD,6CAA6C;IAC7C,KAAK,IAAI,IAAI;IAWb,yDAAyD;IACzD,IAAI,IAAI,IAAI;IAQZ,2DAA2D;IAC3D,KAAK,IAAI,IAAI;IAwHb,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,kBAAkB;CAO3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../src/storage/database.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAGtC,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAMhE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../../src/storage/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAE3C,wBAAgB,aAAa,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,GAAG,IAAI,CA8EzD"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type Database from 'better-sqlite3';
|
|
2
|
+
import type { RunEvent, PolicySnapshot, Checkpoint } from '@cronies/core';
|
|
3
|
+
import type { JobDefinition } from '@cronies/protocol';
|
|
4
|
+
export interface DaemonJob {
|
|
5
|
+
jobId: string;
|
|
6
|
+
outcomeId: string;
|
|
7
|
+
definition: JobDefinition;
|
|
8
|
+
machineState: string;
|
|
9
|
+
machineContext: string;
|
|
10
|
+
status: string;
|
|
11
|
+
assignedAt: number;
|
|
12
|
+
updatedAt: number;
|
|
13
|
+
syncedAt: number | null;
|
|
14
|
+
}
|
|
15
|
+
export interface OutboxMessage {
|
|
16
|
+
id: number;
|
|
17
|
+
messageType: string;
|
|
18
|
+
payload: string;
|
|
19
|
+
createdAt: number;
|
|
20
|
+
attempts: number;
|
|
21
|
+
}
|
|
22
|
+
export declare class DaemonStore {
|
|
23
|
+
private db;
|
|
24
|
+
private sequence;
|
|
25
|
+
constructor(db: Database.Database);
|
|
26
|
+
saveJob(jobId: string, outcomeId: string, definition: JobDefinition, machineState: string, machineContext: string): void;
|
|
27
|
+
getJob(jobId: string): DaemonJob | null;
|
|
28
|
+
getActiveJobs(): DaemonJob[];
|
|
29
|
+
updateJobState(jobId: string, machineState: string, machineContext: string, status: string): void;
|
|
30
|
+
deleteJob(jobId: string): void;
|
|
31
|
+
appendEvent(event: Omit<RunEvent, 'sequence'> & {
|
|
32
|
+
jobId: string;
|
|
33
|
+
}): RunEvent & {
|
|
34
|
+
jobId: string;
|
|
35
|
+
};
|
|
36
|
+
getEvents(runId: string, limit?: number): RunEvent[];
|
|
37
|
+
getEventsByJob(jobId: string, limit?: number): RunEvent[];
|
|
38
|
+
getUnsyncedEvents(limit?: number): (RunEvent & {
|
|
39
|
+
jobId: string;
|
|
40
|
+
})[];
|
|
41
|
+
markEventsSynced(upToSequence: number): void;
|
|
42
|
+
getLastSequence(): number;
|
|
43
|
+
saveCheckpoint(checkpoint: Checkpoint & {
|
|
44
|
+
jobId: string;
|
|
45
|
+
synced?: number;
|
|
46
|
+
}): void;
|
|
47
|
+
getLatestCheckpoint(jobId: string): (Checkpoint & {
|
|
48
|
+
jobId: string;
|
|
49
|
+
}) | null;
|
|
50
|
+
getCheckpoint(id: string): (Checkpoint & {
|
|
51
|
+
jobId: string;
|
|
52
|
+
}) | null;
|
|
53
|
+
markCheckpointSynced(id: string): void;
|
|
54
|
+
cachePolicy(policy: PolicySnapshot): void;
|
|
55
|
+
getCachedPolicy(): PolicySnapshot | null;
|
|
56
|
+
cacheOutcome(outcomeId: string, definition: string, version: number): void;
|
|
57
|
+
getCachedOutcome(outcomeId: string): {
|
|
58
|
+
definition: string;
|
|
59
|
+
version: number;
|
|
60
|
+
} | null;
|
|
61
|
+
enqueueMessage(messageType: string, payload: string): void;
|
|
62
|
+
dequeueMessages(limit?: number): OutboxMessage[];
|
|
63
|
+
markMessageSent(id: number): void;
|
|
64
|
+
retryMessage(id: number): void;
|
|
65
|
+
setMeta(key: string, value: string): void;
|
|
66
|
+
getMeta(key: string): string | null;
|
|
67
|
+
close(): void;
|
|
68
|
+
trackPid(pid: number, jobId: string, agent: string): void;
|
|
69
|
+
removePid(pid: number): void;
|
|
70
|
+
getTrackedPids(): Array<{
|
|
71
|
+
pid: number;
|
|
72
|
+
jobId: string;
|
|
73
|
+
agent: string;
|
|
74
|
+
}>;
|
|
75
|
+
clearAllPids(): void;
|
|
76
|
+
private mapJobRow;
|
|
77
|
+
private mapEventRow;
|
|
78
|
+
private mapCheckpointRow;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=store.d.ts.map
|