@crewx/sdk 0.9.0-rc.110 → 0.9.0-rc.112

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.
@@ -0,0 +1,80 @@
1
+ export declare const PROCESS_LEASE_FILENAME = "process-lease.json";
2
+ export type ProcessLeaseClock = () => number;
3
+ export interface ProcessLeaseProcessProbe {
4
+ isAlive(pid: number): boolean | 'unknown';
5
+ getStartIdentity(pid: number): string | null;
6
+ }
7
+ export interface ProcessLeaseRecord {
8
+ leaseId: string;
9
+ ownerId: string;
10
+ pid: number;
11
+ pidStartIdentity: string;
12
+ host: string;
13
+ startedAt: string;
14
+ heartbeatAt: string;
15
+ }
16
+ export interface ProcessLeaseOptions {
17
+ leasePath?: string;
18
+ ownerId?: string;
19
+ pid?: number;
20
+ pidStartIdentity?: string;
21
+ host?: string;
22
+ clock?: ProcessLeaseClock;
23
+ now?: ProcessLeaseClock;
24
+ processProbe?: ProcessLeaseProcessProbe;
25
+ probe?: ProcessLeaseProcessProbe;
26
+ }
27
+ export interface ProcessLeasePathOptions {
28
+ leasePath?: string;
29
+ }
30
+ export interface ProcessLeaseMutationOptions extends ProcessLeaseOptions {
31
+ leaseId: string;
32
+ ownerId: string;
33
+ }
34
+ export interface ProcessLeaseReclaimOptions extends ProcessLeaseOptions {
35
+ leaseId: string;
36
+ expectedOwnerId?: string;
37
+ }
38
+ export type ProcessLeaseReason = 'live-owner' | 'pid-reused' | 'owner-dead' | 'identity-unknown' | 'marker-corrupt' | 'marker-unreadable' | 'contention' | 'owner-mismatch' | 'io-error' | 'invalid-options';
39
+ export type ProcessLeaseReadResult = {
40
+ status: 'absent';
41
+ } | {
42
+ status: 'present';
43
+ record: ProcessLeaseRecord;
44
+ } | {
45
+ status: 'unknown';
46
+ reason: 'marker-corrupt' | 'marker-unreadable' | 'io-error';
47
+ };
48
+ export interface ProcessLeaseHandle {
49
+ readonly leasePath: string;
50
+ readonly leaseId: string;
51
+ readonly ownerId: string;
52
+ readonly pid: number;
53
+ readonly pidStartIdentity: string;
54
+ readonly record: ProcessLeaseRecord;
55
+ renew(): boolean;
56
+ release(): boolean;
57
+ }
58
+ export type ProcessLeaseAcquireResult = {
59
+ acquired: true;
60
+ status: 'owner';
61
+ role: 'owner';
62
+ leaseId: string;
63
+ ownerId: string;
64
+ record: ProcessLeaseRecord;
65
+ lease: ProcessLeaseHandle;
66
+ } | {
67
+ acquired: false;
68
+ status: 'standby';
69
+ role: 'standby';
70
+ reason: ProcessLeaseReason;
71
+ record?: ProcessLeaseRecord;
72
+ };
73
+ export declare function resolveProcessLeasePath(input?: string | ProcessLeasePathOptions): string;
74
+ export declare function getProcessStartIdentity(pid: number): string | null;
75
+ export declare const getProcessStartTime: typeof getProcessStartIdentity;
76
+ export declare function readProcessLease(input?: string | ProcessLeasePathOptions): ProcessLeaseReadResult;
77
+ export declare function acquireProcessLease(options?: ProcessLeaseOptions): ProcessLeaseAcquireResult;
78
+ export declare function renewProcessLease(options: ProcessLeaseMutationOptions): boolean;
79
+ export declare function releaseProcessLease(options: ProcessLeaseMutationOptions): boolean;
80
+ export declare function reclaimProcessLease(options: ProcessLeaseReclaimOptions): boolean;