@stim-cli/core 1.13.0 → 1.15.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/README.md +15 -0
- package/dist/{core-CmZJEFj_.mjs → core-BwaxUjLX.mjs} +133 -5
- package/dist/index-DgLuTAvh.d.mts +1826 -0
- package/dist/index.d.mts +41 -1
- package/dist/index.mjs +2 -2
- package/dist/oversight.d.mts +308 -0
- package/dist/oversight.mjs +666 -0
- package/dist/ownership-claim-Xxxr9MPp.d.mts +152 -0
- package/dist/ownership-claim.d.mts +1 -151
- package/dist/phone-protocol.d.mts +434 -0
- package/dist/phone-protocol.mjs +2 -0
- package/dist/process-identity-BTyww2Xj.d.mts +37 -0
- package/dist/process-identity.d.mts +2 -30
- package/dist/process-identity.mjs +10 -2
- package/dist/protocol-BjnE921M.d.mts +1442 -0
- package/dist/protocol.d.mts +2 -0
- package/dist/protocol.mjs +372 -0
- package/dist/receive-protocol.d.mts +12 -0
- package/dist/receive-protocol.mjs +16563 -0
- package/dist/state.d.mts +2 -737
- package/dist/state.mjs +2738 -680
- package/package.json +21 -1
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { r as ProcessRecord } from "./process-identity-BTyww2Xj.mjs";
|
|
2
|
+
//#region ownership-claim.d.ts
|
|
3
|
+
type ClaimMode = "exclusive" | "shared";
|
|
4
|
+
interface ClaimDetails {
|
|
5
|
+
readonly [key: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
interface ClaimOwner {
|
|
8
|
+
pid: number;
|
|
9
|
+
processToken: string;
|
|
10
|
+
}
|
|
11
|
+
interface ClaimHolder {
|
|
12
|
+
path: string;
|
|
13
|
+
claimId: string;
|
|
14
|
+
mode: ClaimMode;
|
|
15
|
+
owner: ClaimOwner;
|
|
16
|
+
startedAt: string;
|
|
17
|
+
details: ClaimDetails;
|
|
18
|
+
child: ClaimOwner | null;
|
|
19
|
+
childDeclared: boolean;
|
|
20
|
+
}
|
|
21
|
+
interface ClaimHandle {
|
|
22
|
+
root: string;
|
|
23
|
+
path: string;
|
|
24
|
+
claimId: string;
|
|
25
|
+
mode: ClaimMode;
|
|
26
|
+
owner: ClaimOwner;
|
|
27
|
+
startedAt: string;
|
|
28
|
+
details: ClaimDetails;
|
|
29
|
+
label: string;
|
|
30
|
+
}
|
|
31
|
+
interface ClaimAttempt {
|
|
32
|
+
acquired?: ClaimHandle;
|
|
33
|
+
held?: ClaimHolder;
|
|
34
|
+
waitingFor?: ClaimHolder[];
|
|
35
|
+
pending?: ClaimHandle;
|
|
36
|
+
reaped: ClaimHolder[];
|
|
37
|
+
}
|
|
38
|
+
interface ClaimSetState {
|
|
39
|
+
exclusive: ClaimHolder | null;
|
|
40
|
+
shared: ClaimHolder[];
|
|
41
|
+
reaped: ClaimHolder[];
|
|
42
|
+
}
|
|
43
|
+
interface ClaimProblem {
|
|
44
|
+
path: string;
|
|
45
|
+
reason: string;
|
|
46
|
+
}
|
|
47
|
+
interface ClaimSurvey {
|
|
48
|
+
live: ClaimHolder[];
|
|
49
|
+
dead: ClaimHolder[];
|
|
50
|
+
unresolved: ClaimProblem[];
|
|
51
|
+
orphans: string[];
|
|
52
|
+
}
|
|
53
|
+
interface ClaimOptions {
|
|
54
|
+
root: string;
|
|
55
|
+
mode: ClaimMode;
|
|
56
|
+
details?: ClaimDetails;
|
|
57
|
+
label?: string;
|
|
58
|
+
}
|
|
59
|
+
declare const CLAIM_REFUSED = "STIM_CLAIM_REFUSED";
|
|
60
|
+
declare const CLAIM_UNAVAILABLE = "STIM_CLAIM_UNAVAILABLE";
|
|
61
|
+
declare class ClaimRefusedError extends Error {
|
|
62
|
+
readonly code: string;
|
|
63
|
+
readonly claimPath: string;
|
|
64
|
+
readonly reason: string;
|
|
65
|
+
readonly removeCommand: string;
|
|
66
|
+
constructor({ claimPath, root, reason, label, blockingFile }: {
|
|
67
|
+
claimPath: string;
|
|
68
|
+
root: string;
|
|
69
|
+
reason: string;
|
|
70
|
+
label: string;
|
|
71
|
+
blockingFile?: boolean;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
declare class ClaimUnavailableError extends Error {
|
|
75
|
+
readonly code: string;
|
|
76
|
+
readonly reason: string;
|
|
77
|
+
readonly remedy: string;
|
|
78
|
+
constructor(reason: string, { claimPath }?: {
|
|
79
|
+
claimPath?: string;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The command that clears one surveyed claim: targeted at the claim's own file when the path names one,
|
|
84
|
+
* and quoted, because this text is printed for a human to copy into a shell and a path with a space in
|
|
85
|
+
* it would otherwise name several targets.
|
|
86
|
+
*/
|
|
87
|
+
declare function claimRemoveCommand(path: string): string;
|
|
88
|
+
declare function isClaimRefusal(err: unknown): err is ClaimRefusedError;
|
|
89
|
+
declare function isClaimUnavailable(err: unknown): err is ClaimUnavailableError;
|
|
90
|
+
interface ClaimFailure {
|
|
91
|
+
code: string;
|
|
92
|
+
message: string;
|
|
93
|
+
remedy: string;
|
|
94
|
+
}
|
|
95
|
+
/** Convert an unresolved claim, unavailable identity or inaccessible warm claim store into command recovery guidance. */
|
|
96
|
+
declare function claimFailure(err: unknown, retryCommand: string | null): ClaimFailure | null;
|
|
97
|
+
declare function exclusiveClaimDir(root: string): string;
|
|
98
|
+
declare function sharedClaimDir(root: string): string;
|
|
99
|
+
/**
|
|
100
|
+
* Whether any member of the process group `pid` leads is alive. A recorded child is resolved through
|
|
101
|
+
* its group rather than through the one process, so a package manager's postinstall descendant keeps
|
|
102
|
+
* the claim after the manager exits. A pgid, unlike a ProcessRecord, carries no identity: a recycled
|
|
103
|
+
* one reads as alive, which holds a claim longer than it needs to be held and never frees a live one.
|
|
104
|
+
*/
|
|
105
|
+
declare function processGroupAlive(pid: number): boolean;
|
|
106
|
+
type Liveness = "live" | "dead" | "unknown";
|
|
107
|
+
declare function claimLiveness(holder: ClaimHolder): Liveness;
|
|
108
|
+
/** Classify every claim in a claim set without removing anything and without refusing. */
|
|
109
|
+
declare function readClaimSet(root: string): ClaimSurvey;
|
|
110
|
+
declare function inspectClaimSet(root: string, { label }?: {
|
|
111
|
+
label?: string;
|
|
112
|
+
}): ClaimSetState;
|
|
113
|
+
type ClaimSetClearance = {
|
|
114
|
+
status: "cleared";
|
|
115
|
+
} | {
|
|
116
|
+
status: "held";
|
|
117
|
+
holder: ClaimHolder | null;
|
|
118
|
+
} | {
|
|
119
|
+
status: "refused";
|
|
120
|
+
reason: string;
|
|
121
|
+
} | {
|
|
122
|
+
status: "failed";
|
|
123
|
+
reason: string;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Remove a claim set that holds nothing. Takes the set's own exclusive claim first and removes the set
|
|
127
|
+
* only through the token-verified unlink and empty-directory removals that releasing a claim performs,
|
|
128
|
+
* so a claim published between the survey that reported the set stale and this call is kept, not
|
|
129
|
+
* deleted; a set whose state cannot be established is refused rather than removed.
|
|
130
|
+
*/
|
|
131
|
+
declare function clearFreeClaimSet({ root, label }: {
|
|
132
|
+
root: string;
|
|
133
|
+
label?: string;
|
|
134
|
+
}): ClaimSetClearance;
|
|
135
|
+
declare function tryAcquireClaim({ root, mode, details, label }: ClaimOptions): ClaimAttempt;
|
|
136
|
+
declare function settleClaim(pending: ClaimHandle): ClaimAttempt;
|
|
137
|
+
declare function releaseClaim(handle: ClaimHandle | null | undefined): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Declare that this claim is about to spawn the process that does the real work, before the spawn.
|
|
140
|
+
* A claim marked this way and left without a child record reads as unresolvable rather than as free,
|
|
141
|
+
* so a parent killed between the spawn and the record cannot release a claim its child still needs.
|
|
142
|
+
*/
|
|
143
|
+
declare function markClaimChildPending(handle: ClaimHandle): void;
|
|
144
|
+
/**
|
|
145
|
+
* Record the spawned process that holds this claim. Spawn it with `detached: true` so it leads its own
|
|
146
|
+
* process group: the claim then reads as held while any member of that group is alive, which is what
|
|
147
|
+
* keeps a package manager's postinstall child covered after the manager itself exits.
|
|
148
|
+
*/
|
|
149
|
+
declare function setClaimChild(handle: ClaimHandle, record: ProcessRecord): void;
|
|
150
|
+
declare function clearClaimChild(handle: ClaimHandle): void;
|
|
151
|
+
//#endregion
|
|
152
|
+
export { setClaimChild as A, inspectClaimSet as C, processGroupAlive as D, markClaimChildPending as E, sharedClaimDir as M, tryAcquireClaim as N, readClaimSet as O, exclusiveClaimDir as S, isClaimUnavailable as T, claimFailure as _, ClaimFailure as a, clearClaimChild as b, ClaimMode as c, ClaimProblem as d, ClaimRefusedError as f, ClaimUnavailableError as g, ClaimSurvey as h, ClaimDetails as i, settleClaim as j, releaseClaim as k, ClaimOptions as l, ClaimSetState as m, CLAIM_UNAVAILABLE as n, ClaimHandle as o, ClaimSetClearance as p, ClaimAttempt as r, ClaimHolder as s, CLAIM_REFUSED as t, ClaimOwner as u, claimLiveness as v, isClaimRefusal as w, clearFreeClaimSet as x, claimRemoveCommand as y };
|
|
@@ -1,152 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region ownership-claim.d.ts
|
|
3
|
-
type ClaimMode = "exclusive" | "shared";
|
|
4
|
-
interface ClaimDetails {
|
|
5
|
-
readonly [key: string]: unknown;
|
|
6
|
-
}
|
|
7
|
-
interface ClaimOwner {
|
|
8
|
-
pid: number;
|
|
9
|
-
processToken: string;
|
|
10
|
-
}
|
|
11
|
-
interface ClaimHolder {
|
|
12
|
-
path: string;
|
|
13
|
-
claimId: string;
|
|
14
|
-
mode: ClaimMode;
|
|
15
|
-
owner: ClaimOwner;
|
|
16
|
-
startedAt: string;
|
|
17
|
-
details: ClaimDetails;
|
|
18
|
-
child: ClaimOwner | null;
|
|
19
|
-
childDeclared: boolean;
|
|
20
|
-
}
|
|
21
|
-
interface ClaimHandle {
|
|
22
|
-
root: string;
|
|
23
|
-
path: string;
|
|
24
|
-
claimId: string;
|
|
25
|
-
mode: ClaimMode;
|
|
26
|
-
owner: ClaimOwner;
|
|
27
|
-
startedAt: string;
|
|
28
|
-
details: ClaimDetails;
|
|
29
|
-
label: string;
|
|
30
|
-
}
|
|
31
|
-
interface ClaimAttempt {
|
|
32
|
-
acquired?: ClaimHandle;
|
|
33
|
-
held?: ClaimHolder;
|
|
34
|
-
waitingFor?: ClaimHolder[];
|
|
35
|
-
pending?: ClaimHandle;
|
|
36
|
-
reaped: ClaimHolder[];
|
|
37
|
-
}
|
|
38
|
-
interface ClaimSetState {
|
|
39
|
-
exclusive: ClaimHolder | null;
|
|
40
|
-
shared: ClaimHolder[];
|
|
41
|
-
reaped: ClaimHolder[];
|
|
42
|
-
}
|
|
43
|
-
interface ClaimProblem {
|
|
44
|
-
path: string;
|
|
45
|
-
reason: string;
|
|
46
|
-
}
|
|
47
|
-
interface ClaimSurvey {
|
|
48
|
-
live: ClaimHolder[];
|
|
49
|
-
dead: ClaimHolder[];
|
|
50
|
-
unresolved: ClaimProblem[];
|
|
51
|
-
orphans: string[];
|
|
52
|
-
}
|
|
53
|
-
interface ClaimOptions {
|
|
54
|
-
root: string;
|
|
55
|
-
mode: ClaimMode;
|
|
56
|
-
details?: ClaimDetails;
|
|
57
|
-
label?: string;
|
|
58
|
-
}
|
|
59
|
-
declare const CLAIM_REFUSED = "STIM_CLAIM_REFUSED";
|
|
60
|
-
declare const CLAIM_UNAVAILABLE = "STIM_CLAIM_UNAVAILABLE";
|
|
61
|
-
declare class ClaimRefusedError extends Error {
|
|
62
|
-
readonly code: string;
|
|
63
|
-
readonly claimPath: string;
|
|
64
|
-
readonly reason: string;
|
|
65
|
-
readonly removeCommand: string;
|
|
66
|
-
constructor({ claimPath, root, reason, label, blockingFile }: {
|
|
67
|
-
claimPath: string;
|
|
68
|
-
root: string;
|
|
69
|
-
reason: string;
|
|
70
|
-
label: string;
|
|
71
|
-
blockingFile?: boolean;
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
declare class ClaimUnavailableError extends Error {
|
|
75
|
-
readonly code: string;
|
|
76
|
-
readonly reason: string;
|
|
77
|
-
readonly remedy: string;
|
|
78
|
-
constructor(reason: string, { claimPath }?: {
|
|
79
|
-
claimPath?: string;
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* The command that clears one surveyed claim: targeted at the claim's own file when the path names one,
|
|
84
|
-
* and quoted, because this text is printed for a human to copy into a shell and a path with a space in
|
|
85
|
-
* it would otherwise name several targets.
|
|
86
|
-
*/
|
|
87
|
-
declare function claimRemoveCommand(path: string): string;
|
|
88
|
-
declare function isClaimRefusal(err: unknown): err is ClaimRefusedError;
|
|
89
|
-
declare function isClaimUnavailable(err: unknown): err is ClaimUnavailableError;
|
|
90
|
-
interface ClaimFailure {
|
|
91
|
-
code: string;
|
|
92
|
-
message: string;
|
|
93
|
-
remedy: string;
|
|
94
|
-
}
|
|
95
|
-
/** Convert an unresolved claim, unavailable identity or inaccessible warm claim store into command recovery guidance. */
|
|
96
|
-
declare function claimFailure(err: unknown, retryCommand: string | null): ClaimFailure | null;
|
|
97
|
-
declare function exclusiveClaimDir(root: string): string;
|
|
98
|
-
declare function sharedClaimDir(root: string): string;
|
|
99
|
-
/**
|
|
100
|
-
* Whether any member of the process group `pid` leads is alive. A recorded child is resolved through
|
|
101
|
-
* its group rather than through the one process, so a package manager's postinstall descendant keeps
|
|
102
|
-
* the claim after the manager exits. A pgid, unlike a ProcessRecord, carries no identity: a recycled
|
|
103
|
-
* one reads as alive, which holds a claim longer than it needs to be held and never frees a live one.
|
|
104
|
-
*/
|
|
105
|
-
declare function processGroupAlive(pid: number): boolean;
|
|
106
|
-
type Liveness = "live" | "dead" | "unknown";
|
|
107
|
-
declare function claimLiveness(holder: ClaimHolder): Liveness;
|
|
108
|
-
/** Classify every claim in a claim set without removing anything and without refusing. */
|
|
109
|
-
declare function readClaimSet(root: string): ClaimSurvey;
|
|
110
|
-
declare function inspectClaimSet(root: string, { label }?: {
|
|
111
|
-
label?: string;
|
|
112
|
-
}): ClaimSetState;
|
|
113
|
-
type ClaimSetClearance = {
|
|
114
|
-
status: "cleared";
|
|
115
|
-
} | {
|
|
116
|
-
status: "held";
|
|
117
|
-
holder: ClaimHolder | null;
|
|
118
|
-
} | {
|
|
119
|
-
status: "refused";
|
|
120
|
-
reason: string;
|
|
121
|
-
} | {
|
|
122
|
-
status: "failed";
|
|
123
|
-
reason: string;
|
|
124
|
-
};
|
|
125
|
-
/**
|
|
126
|
-
* Remove a claim set that holds nothing. Takes the set's own exclusive claim first and removes the set
|
|
127
|
-
* only through the token-verified unlink and empty-directory removals that releasing a claim performs,
|
|
128
|
-
* so a claim published between the survey that reported the set stale and this call is kept, not
|
|
129
|
-
* deleted; a set whose state cannot be established is refused rather than removed.
|
|
130
|
-
*/
|
|
131
|
-
declare function clearFreeClaimSet({ root, label }: {
|
|
132
|
-
root: string;
|
|
133
|
-
label?: string;
|
|
134
|
-
}): ClaimSetClearance;
|
|
135
|
-
declare function tryAcquireClaim({ root, mode, details, label }: ClaimOptions): ClaimAttempt;
|
|
136
|
-
declare function settleClaim(pending: ClaimHandle): ClaimAttempt;
|
|
137
|
-
declare function releaseClaim(handle: ClaimHandle | null | undefined): boolean;
|
|
138
|
-
/**
|
|
139
|
-
* Declare that this claim is about to spawn the process that does the real work, before the spawn.
|
|
140
|
-
* A claim marked this way and left without a child record reads as unresolvable rather than as free,
|
|
141
|
-
* so a parent killed between the spawn and the record cannot release a claim its child still needs.
|
|
142
|
-
*/
|
|
143
|
-
declare function markClaimChildPending(handle: ClaimHandle): void;
|
|
144
|
-
/**
|
|
145
|
-
* Record the spawned process that holds this claim. Spawn it with `detached: true` so it leads its own
|
|
146
|
-
* process group: the claim then reads as held while any member of that group is alive, which is what
|
|
147
|
-
* keeps a package manager's postinstall child covered after the manager itself exits.
|
|
148
|
-
*/
|
|
149
|
-
declare function setClaimChild(handle: ClaimHandle, record: ProcessRecord): void;
|
|
150
|
-
declare function clearClaimChild(handle: ClaimHandle): void;
|
|
151
|
-
//#endregion
|
|
1
|
+
import { A as setClaimChild, C as inspectClaimSet, D as processGroupAlive, E as markClaimChildPending, M as sharedClaimDir, N as tryAcquireClaim, O as readClaimSet, S as exclusiveClaimDir, T as isClaimUnavailable, _ as claimFailure, a as ClaimFailure, b as clearClaimChild, c as ClaimMode, d as ClaimProblem, f as ClaimRefusedError, g as ClaimUnavailableError, h as ClaimSurvey, i as ClaimDetails, j as settleClaim, k as releaseClaim, l as ClaimOptions, m as ClaimSetState, n as CLAIM_UNAVAILABLE, o as ClaimHandle, p as ClaimSetClearance, r as ClaimAttempt, s as ClaimHolder, t as CLAIM_REFUSED, u as ClaimOwner, v as claimLiveness, w as isClaimRefusal, x as clearFreeClaimSet, y as claimRemoveCommand } from "./ownership-claim-Xxxr9MPp.mjs";
|
|
152
2
|
export { CLAIM_REFUSED, CLAIM_UNAVAILABLE, ClaimAttempt, ClaimDetails, ClaimFailure, ClaimHandle, ClaimHolder, ClaimMode, ClaimOptions, ClaimOwner, ClaimProblem, ClaimRefusedError, ClaimSetClearance, ClaimSetState, ClaimSurvey, ClaimUnavailableError, claimFailure, claimLiveness, claimRemoveCommand, clearClaimChild, clearFreeClaimSet, exclusiveClaimDir, inspectClaimSet, isClaimRefusal, isClaimUnavailable, markClaimChildPending, processGroupAlive, readClaimSet, releaseClaim, setClaimChild, settleClaim, sharedClaimDir, tryAcquireClaim };
|