@primafuture/systemd-tasks 1.0.0 → 1.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/dist/index.d.cts CHANGED
@@ -1,316 +1 @@
1
- import * as util from 'node:util';
2
-
3
- /** A deliberately small allowlist of properties that cannot replace task lifecycle policy. */
4
- interface SystemdProperty {
5
- /** The resource weight to pass to the transient service. */
6
- readonly name: 'CPUWeight' | 'IOWeight';
7
- /** The systemd D-Bus signature, independent of the transport implementation. */
8
- readonly signature: 't';
9
- /** An integer resource weight from 1 through 10000. */
10
- readonly value: number;
11
- }
12
- /** A command specification suitable for serialization before any attempt to execute it. */
13
- interface TaskSpec {
14
- /** Absolute executable path; no PATH lookup or shell is performed. */
15
- readonly executable: string;
16
- /** Literal arguments excluding argv[0], which is the executable path. */
17
- readonly argv: readonly string[];
18
- /** Absolute working directory, which must already exist at execution time. */
19
- readonly cwd: string;
20
- /** Explicit environment entries; systemd may add its own execution metadata. */
21
- readonly env: Readonly<Record<string, string>>;
22
- /** Positive integer milliseconds, or null to explicitly disable the runtime limit. */
23
- readonly runtimeLimitMs: number | null;
24
- /** Positive integer milliseconds before manager-owned SIGKILL escalation. */
25
- readonly stopGraceMs: number;
26
- /** Optional resource weights; all other low-level properties are reserved. */
27
- readonly systemdProperties?: readonly SystemdProperty[];
28
- }
29
- /** Common serializable ownership evidence, without environment or command arguments. */
30
- interface TaskIdentity {
31
- /** Serialization version understood by this library. */
32
- readonly version: 1;
33
- /** Random UUID generated before submission. */
34
- readonly id: string;
35
- /** Unique transient service name derived from the ID. */
36
- readonly unitName: string;
37
- /** Unique auxiliary service name derived from the same ID. */
38
- readonly retentionUnitName: string;
39
- /** V1 supports the local user manager only. */
40
- readonly managerScope: 'user';
41
- /** SHA-256 fingerprint of the normalized task specification. */
42
- readonly fingerprint: string;
43
- }
44
- /** A prepared intention; saving it does not imply that execution was attempted. */
45
- interface TaskIntent extends TaskIdentity {
46
- /** Execution configuration, potentially containing secrets; store accordingly. */
47
- readonly spec: TaskSpec;
48
- }
49
- /** Identity of the specific environment in which a task was observed. */
50
- interface ManagerIdentity {
51
- /** Manager privilege scope; system-manager references are not supported in V1. */
52
- readonly scope: 'user';
53
- /** Effective local UID whose user bus owns the task. */
54
- readonly uid: number;
55
- /** Machine identity reported by the manager's D-Bus peer. */
56
- readonly machineId: string;
57
- /** Local kernel boot identity, preventing cross-boot adoption. */
58
- readonly bootId: string;
59
- /** Unique identity of the user message bus. */
60
- readonly busId: string;
61
- /** Unique bus owner of org.freedesktop.systemd1 at connection time. */
62
- readonly owner: string;
63
- }
64
- /** An observed pair of unit instances; null IDs explicitly mean incomplete evidence. */
65
- interface TaskReference extends TaskIdentity {
66
- /** The manager in which the reference was obtained. */
67
- readonly manager: ManagerIdentity;
68
- /** Main service invocation, or null if no invocation was observed. */
69
- readonly invocationId: string | null;
70
- /** Auxiliary invocation, or null if it was absent or never invoked. */
71
- readonly retentionInvocationId: string | null;
72
- }
73
- /** Input from /dev/null, an existing file, or a caller-owned descriptor. */
74
- type TaskInput = {
75
- readonly type: 'null';
76
- } | {
77
- readonly type: 'file'; /** Absolute existing input path. */
78
- readonly path: string;
79
- } | {
80
- readonly type: 'fd'; /** Nonnegative Unix descriptor, held open until start settles. */
81
- readonly fd: number;
82
- };
83
- /** Output without decoding, in-memory capture, or automatic directory creation. */
84
- type TaskOutput = {
85
- readonly type: 'null';
86
- } | {
87
- readonly type: 'file'; /** Absolute output path. */
88
- readonly path: string; /** Explicit append or truncate semantics. */
89
- readonly mode: 'append' | 'truncate';
90
- } | {
91
- readonly type: 'fd'; /** Nonnegative Unix descriptor, held open until start settles. */
92
- readonly fd: number;
93
- };
94
- /** All standard descriptors are explicit and excluded from persistent task identities. */
95
- interface TaskIO {
96
- /** Input source; this library does not create an interactive terminal. */
97
- readonly stdin: TaskInput;
98
- /** Binary standard output destination. */
99
- readonly stdout: TaskOutput;
100
- /** Binary standard error destination. */
101
- readonly stderr: TaskOutput;
102
- }
103
- /** Explicit discard configuration for tasks whose output is not needed. */
104
- declare const nullIO: TaskIO;
105
- /** Whether the manager and cgroup provide evidence of finished descendant cleanup. */
106
- type CleanupState = 'pending' | 'complete' | 'incomplete' | 'unknown';
107
- /** Raw evidence retained by the specific service, with 64-bit values serialized as decimals. */
108
- interface TaskEvidence {
109
- /** Raw systemd Unit.ActiveState. */
110
- readonly activeState: string;
111
- /** Raw systemd Unit.SubState. */
112
- readonly subState: string;
113
- /** Raw systemd Service.Result, without inferred stop intent. */
114
- readonly systemdResult: string;
115
- /** CLD_* wait-status category reported by systemd. */
116
- readonly execMainCode: number;
117
- /** Exit code or signal number according to execMainCode. */
118
- readonly execMainStatus: number;
119
- /** Monotonic main-process start timestamp in microseconds; zero means absent. */
120
- readonly execMainStartUsec: string;
121
- /** Monotonic main-process exit timestamp in microseconds; zero means absent. */
122
- readonly execMainExitUsec: string;
123
- /** Retained active-entry evidence under Type=exec. */
124
- readonly activeEnterUsec: string;
125
- /** Current job ID, or zero when no job is pending. */
126
- readonly jobId: number;
127
- /** Manager-reported cgroup path, possibly empty after cleanup. */
128
- readonly controlGroup: string;
129
- /** Hierarchical cgroup population evidence; null when unavailable or unnecessary. */
130
- readonly cgroupPopulated: boolean | null;
131
- }
132
- /** A program failure is a normal result, distinct from a transport or observation error. */
133
- interface TaskResult {
134
- /** Classification based on execution and exit evidence, never just the numeric status. */
135
- readonly kind: 'exited' | 'signaled' | 'execution-failed' | 'not-executed' | 'unknown';
136
- /** Program or systemd execution status, present only for CLD_EXITED. */
137
- readonly exitCode: number | null;
138
- /** Signal number, present only for CLD_KILLED or CLD_DUMPED. */
139
- readonly signal: number | null;
140
- /** Whether Type=exec activation was confirmed by retained manager evidence. */
141
- readonly execution: 'confirmed' | 'not-confirmed';
142
- /** Raw systemd result; timeout can describe runtime, stop, or cleanup escalation. */
143
- readonly systemdResult: string;
144
- /** Cleanup must be checked independently of a successful main-process exit. */
145
- readonly cleanup: CleanupState;
146
- }
147
- /** A current state observation, not a durable event history. */
148
- interface TaskSnapshot {
149
- /** Reference captured from this observation. */
150
- readonly reference: TaskReference;
151
- /** Complete requires observed InvocationIDs for both task and retention service. */
152
- readonly identity: 'complete' | 'incomplete';
153
- /** Process phase; completed always requires confirmed cleanup. */
154
- readonly phase: 'starting' | 'running' | 'cleaning' | 'completed';
155
- /** Main PID is diagnostic only and never used as task identity. */
156
- readonly mainPid: number;
157
- /** True only for inactive/failed state without a pending job. */
158
- readonly managerTerminal: boolean;
159
- /** Current cleanup evidence. */
160
- readonly cleanup: CleanupState;
161
- /** Available main-exit or terminal evidence, possibly before cleanup finishes. */
162
- readonly result: TaskResult | null;
163
- /** Minimal raw properties needed to audit the classification. */
164
- readonly evidence: TaskEvidence;
165
- }
166
- /** Absence does not prove that a task never ran; incomplete retention is also explicit. */
167
- type LookupResult = {
168
- readonly status: 'found'; /** Reference from this read. */
169
- readonly reference: TaskReference; /** Current task state. */
170
- readonly snapshot: TaskSnapshot;
171
- } | {
172
- readonly status: 'not-found'; /** Requested identity without secrets. */
173
- readonly identity: TaskIdentity;
174
- } | {
175
- readonly status: 'incomplete'; /** Partial identity, safe to inspect and conservatively release. */
176
- readonly reference: TaskReference;
177
- };
178
- /** Start acceptance means the manager queued the creation transaction, not successful exec. */
179
- interface StartReceipt {
180
- /** Acknowledged by the manager; subsequent program failure is a separate result. */
181
- readonly outcome: 'accepted';
182
- /** Requested identity, which is already known before the call. */
183
- readonly identity: TaskIdentity;
184
- /** Manager that accepted the request. */
185
- readonly manager: ManagerIdentity;
186
- /** Diagnostic path of the accepted job; jobs are not durable identities. */
187
- readonly jobPath: string;
188
- }
189
- /** Local waiting controls; neither option changes manager-owned execution limits. */
190
- interface WaitOptions {
191
- /** Aborting affects this caller's wait only. */
192
- readonly signal?: AbortSignal;
193
- /** Positive integer local deadline, at most 2147483647 milliseconds. */
194
- readonly timeoutMs?: number;
195
- }
196
- /** Stop acceptance and optional completion waiting are separate stages. */
197
- interface StopOptions extends WaitOptions {
198
- /** When true, await terminal cleanup after manager acceptance. Defaults to false. */
199
- readonly wait?: boolean;
200
- }
201
- /** Local controls for the complete release sequence, independent of each D-Bus call. */
202
- interface ReleaseOptions extends WaitOptions {
203
- /** Total local release deadline including queueing; defaults to 5000 milliseconds. */
204
- readonly timeoutMs?: number;
205
- }
206
- /** Successful stop submission or an already-completed instance. */
207
- interface StopReceipt {
208
- /** Already-completed does not submit any stop request. */
209
- readonly outcome: 'accepted' | 'already-completed';
210
- /** The exact reference checked before stopping. */
211
- readonly reference: TaskReference;
212
- /** Accepted stop job, or null for an already-completed instance. */
213
- readonly jobPath: string | null;
214
- /** Present when completion was awaited or already known. */
215
- readonly completion: TaskSnapshot | null;
216
- }
217
- /** Explicit release affects manager retention, never application log files. */
218
- interface ReleaseReceipt {
219
- /** The auxiliary retention is no longer active. */
220
- readonly released: true;
221
- /** Both identities were already absent when release began. */
222
- readonly alreadyReleased: boolean;
223
- /** Whether both records were already garbage-collected at the final observation. */
224
- readonly collected: boolean;
225
- }
226
- /** Stable categories for callers making recovery decisions. */
227
- type ErrorCode = 'INVALID_INPUT' | 'UNSUPPORTED_ENVIRONMENT' | 'PERMISSION_DENIED' | 'MANAGER_UNAVAILABLE' | 'IDENTITY_CONFLICT' | 'START_REJECTED' | 'UNKNOWN_MUTATION_OUTCOME' | 'RESULT_UNAVAILABLE' | 'TASK_RUNNING' | 'WAIT_ABORTED' | 'WAIT_TIMEOUT' | 'DISCONNECTED';
228
- /** Metadata safe for default error formatting and diagnostic output. */
229
- interface ErrorDetails {
230
- /** Public or transport operation where the failure was observed. */
231
- readonly operation?: string;
232
- /** Known delivery state; an unknown result must never authorize automatic retry. */
233
- readonly mutationOutcome?: 'not-submitted' | 'rejected' | 'accepted' | 'unknown';
234
- /** Acknowledged cleanup calls before a release error; may be positive even when a later call is unknown. */
235
- readonly acceptedCleanupMutations?: number;
236
- /** Stable detail such as unit-not-found or incomplete-identity. */
237
- readonly reason?: string;
238
- /** Random task ID only, never the serialized intent. */
239
- readonly taskId?: string;
240
- }
241
- /** A redacted event correlated centrally with a task or connection flow. */
242
- interface DiagnosticEvent {
243
- /** Stable event name; no command, environment, or output content. */
244
- readonly event: string;
245
- /** Immutable correlation context captured at emission time. */
246
- readonly context: {
247
- /** Connection flow shared by this client's operations. */
248
- readonly connection: {
249
- readonly id: string;
250
- };
251
- /** Task scope, present for task operations. */
252
- readonly task?: {
253
- readonly id: string; /** Derived unit name. */
254
- readonly unitName: string;
255
- };
256
- };
257
- /** Stable failure category, when applicable. */
258
- readonly code?: ErrorCode;
259
- }
260
- /** Explicit user-manager connection options; no automatic provisioning is performed. */
261
- interface ConnectOptions {
262
- /** Positive local D-Bus call deadline, at most 2147483647 ms; defaults to 5000. */
263
- readonly requestTimeoutMs?: number;
264
- /** Optional redacted event sink; sync throws and async rejections are isolated, never awaited. */
265
- readonly onDiagnostic?: (event: DiagnosticEvent) => void;
266
- }
267
- /** The local client owns observation resources; systemd owns the task processes. */
268
- interface TaskClient {
269
- /** Bound manager identity for persistence and diagnosis. */
270
- readonly manager: ManagerIdentity;
271
- /** Submit exactly one creation attempt for a locally validated intention. */
272
- start(intent: TaskIntent, io: TaskIO): Promise<StartReceipt>;
273
- /** Read existing ownership evidence without starting or retrying anything. */
274
- lookup(target: TaskIntent | TaskReference): Promise<LookupResult>;
275
- /** Read the exact referenced instance or fail with explicit observation unavailability. */
276
- inspect(reference: TaskReference): Promise<TaskSnapshot>;
277
- /** Wait for cleanup, or return explicit incomplete cleanup on terminal manager failure. */
278
- wait(target: TaskIntent | TaskReference, options?: WaitOptions): Promise<TaskSnapshot>;
279
- /** Ask the manager to stop the referenced cgroup, optionally awaiting cleanup. */
280
- stop(reference: TaskReference, options?: StopOptions): Promise<StopReceipt>;
281
- /** Release only completed owned retention, preserving application files. */
282
- release(reference: TaskReference, options?: ReleaseOptions): Promise<ReleaseReceipt>;
283
- /** Close local connections and observers without stopping any task. */
284
- disconnect(): Promise<void>;
285
- }
286
-
287
- /** Connect explicitly to the local user manager; package import has no connection side effects. */
288
- declare function connect(options?: ConnectOptions): Promise<TaskClient>;
289
-
290
- /** Prepare an intention locally; no connection, file opening, or process start occurs. */
291
- declare function prepare(spec: TaskSpec): TaskIntent;
292
-
293
- /** A recoverable API error with stable categories and redacted default formatting. */
294
- declare class TaskError extends Error {
295
- /** Stable category used by applications instead of parsing human-readable messages. */
296
- readonly code: ErrorCode;
297
- /** Safe delivery and identity metadata; never contains a command specification. */
298
- readonly details: ErrorDetails;
299
- /** Preserve the original cause for explicit access while keeping default output redacted. */
300
- constructor(code: ErrorCode, message: string, details?: ErrorDetails, cause?: unknown);
301
- /** Serialization deliberately excludes raw causes, stack contents, and request payloads. */
302
- toJSON(): {
303
- /** Stable error class name for serialized consumers. */
304
- name: string;
305
- /** Public recovery category. */
306
- code: ErrorCode;
307
- /** Redacted explanation safe for default logs. */
308
- message: string;
309
- /** Safe delivery evidence without raw causes. */
310
- details: ErrorDetails;
311
- };
312
- /** Console and util.inspect must not expand a transport cause containing request data. */
313
- [util.inspect.custom](): string;
314
- }
315
-
316
- export { type CleanupState, type ConnectOptions, type DiagnosticEvent, type ErrorCode, type ErrorDetails, type LookupResult, type ManagerIdentity, type ReleaseOptions, type ReleaseReceipt, type StartReceipt, type StopOptions, type StopReceipt, type SystemdProperty, type TaskClient, TaskError, type TaskEvidence, type TaskIO, type TaskIdentity, type TaskInput, type TaskIntent, type TaskOutput, type TaskReference, type TaskResult, type TaskSnapshot, type TaskSpec, type WaitOptions, connect, nullIO, prepare };
1
+ export { CleanupState, ConnectOptions, DiagnosticEvent, ErrorCode, ErrorDetails, LookupResult, ManagerIdentity, ReleaseOptions, ReleaseReceipt, StartReceipt, StopOptions, StopReceipt, SystemdProperty, TaskClient, TaskError, TaskEvidence, TaskIO, TaskIdentity, TaskInput, TaskIntent, TaskOutput, TaskReference, TaskResult, TaskSnapshot, TaskSpec, WaitOptions, connect, nullIO, prepare } from '#runtime';
package/dist/index.d.ts CHANGED
@@ -1,316 +1 @@
1
- import * as util from 'node:util';
2
-
3
- /** A deliberately small allowlist of properties that cannot replace task lifecycle policy. */
4
- interface SystemdProperty {
5
- /** The resource weight to pass to the transient service. */
6
- readonly name: 'CPUWeight' | 'IOWeight';
7
- /** The systemd D-Bus signature, independent of the transport implementation. */
8
- readonly signature: 't';
9
- /** An integer resource weight from 1 through 10000. */
10
- readonly value: number;
11
- }
12
- /** A command specification suitable for serialization before any attempt to execute it. */
13
- interface TaskSpec {
14
- /** Absolute executable path; no PATH lookup or shell is performed. */
15
- readonly executable: string;
16
- /** Literal arguments excluding argv[0], which is the executable path. */
17
- readonly argv: readonly string[];
18
- /** Absolute working directory, which must already exist at execution time. */
19
- readonly cwd: string;
20
- /** Explicit environment entries; systemd may add its own execution metadata. */
21
- readonly env: Readonly<Record<string, string>>;
22
- /** Positive integer milliseconds, or null to explicitly disable the runtime limit. */
23
- readonly runtimeLimitMs: number | null;
24
- /** Positive integer milliseconds before manager-owned SIGKILL escalation. */
25
- readonly stopGraceMs: number;
26
- /** Optional resource weights; all other low-level properties are reserved. */
27
- readonly systemdProperties?: readonly SystemdProperty[];
28
- }
29
- /** Common serializable ownership evidence, without environment or command arguments. */
30
- interface TaskIdentity {
31
- /** Serialization version understood by this library. */
32
- readonly version: 1;
33
- /** Random UUID generated before submission. */
34
- readonly id: string;
35
- /** Unique transient service name derived from the ID. */
36
- readonly unitName: string;
37
- /** Unique auxiliary service name derived from the same ID. */
38
- readonly retentionUnitName: string;
39
- /** V1 supports the local user manager only. */
40
- readonly managerScope: 'user';
41
- /** SHA-256 fingerprint of the normalized task specification. */
42
- readonly fingerprint: string;
43
- }
44
- /** A prepared intention; saving it does not imply that execution was attempted. */
45
- interface TaskIntent extends TaskIdentity {
46
- /** Execution configuration, potentially containing secrets; store accordingly. */
47
- readonly spec: TaskSpec;
48
- }
49
- /** Identity of the specific environment in which a task was observed. */
50
- interface ManagerIdentity {
51
- /** Manager privilege scope; system-manager references are not supported in V1. */
52
- readonly scope: 'user';
53
- /** Effective local UID whose user bus owns the task. */
54
- readonly uid: number;
55
- /** Machine identity reported by the manager's D-Bus peer. */
56
- readonly machineId: string;
57
- /** Local kernel boot identity, preventing cross-boot adoption. */
58
- readonly bootId: string;
59
- /** Unique identity of the user message bus. */
60
- readonly busId: string;
61
- /** Unique bus owner of org.freedesktop.systemd1 at connection time. */
62
- readonly owner: string;
63
- }
64
- /** An observed pair of unit instances; null IDs explicitly mean incomplete evidence. */
65
- interface TaskReference extends TaskIdentity {
66
- /** The manager in which the reference was obtained. */
67
- readonly manager: ManagerIdentity;
68
- /** Main service invocation, or null if no invocation was observed. */
69
- readonly invocationId: string | null;
70
- /** Auxiliary invocation, or null if it was absent or never invoked. */
71
- readonly retentionInvocationId: string | null;
72
- }
73
- /** Input from /dev/null, an existing file, or a caller-owned descriptor. */
74
- type TaskInput = {
75
- readonly type: 'null';
76
- } | {
77
- readonly type: 'file'; /** Absolute existing input path. */
78
- readonly path: string;
79
- } | {
80
- readonly type: 'fd'; /** Nonnegative Unix descriptor, held open until start settles. */
81
- readonly fd: number;
82
- };
83
- /** Output without decoding, in-memory capture, or automatic directory creation. */
84
- type TaskOutput = {
85
- readonly type: 'null';
86
- } | {
87
- readonly type: 'file'; /** Absolute output path. */
88
- readonly path: string; /** Explicit append or truncate semantics. */
89
- readonly mode: 'append' | 'truncate';
90
- } | {
91
- readonly type: 'fd'; /** Nonnegative Unix descriptor, held open until start settles. */
92
- readonly fd: number;
93
- };
94
- /** All standard descriptors are explicit and excluded from persistent task identities. */
95
- interface TaskIO {
96
- /** Input source; this library does not create an interactive terminal. */
97
- readonly stdin: TaskInput;
98
- /** Binary standard output destination. */
99
- readonly stdout: TaskOutput;
100
- /** Binary standard error destination. */
101
- readonly stderr: TaskOutput;
102
- }
103
- /** Explicit discard configuration for tasks whose output is not needed. */
104
- declare const nullIO: TaskIO;
105
- /** Whether the manager and cgroup provide evidence of finished descendant cleanup. */
106
- type CleanupState = 'pending' | 'complete' | 'incomplete' | 'unknown';
107
- /** Raw evidence retained by the specific service, with 64-bit values serialized as decimals. */
108
- interface TaskEvidence {
109
- /** Raw systemd Unit.ActiveState. */
110
- readonly activeState: string;
111
- /** Raw systemd Unit.SubState. */
112
- readonly subState: string;
113
- /** Raw systemd Service.Result, without inferred stop intent. */
114
- readonly systemdResult: string;
115
- /** CLD_* wait-status category reported by systemd. */
116
- readonly execMainCode: number;
117
- /** Exit code or signal number according to execMainCode. */
118
- readonly execMainStatus: number;
119
- /** Monotonic main-process start timestamp in microseconds; zero means absent. */
120
- readonly execMainStartUsec: string;
121
- /** Monotonic main-process exit timestamp in microseconds; zero means absent. */
122
- readonly execMainExitUsec: string;
123
- /** Retained active-entry evidence under Type=exec. */
124
- readonly activeEnterUsec: string;
125
- /** Current job ID, or zero when no job is pending. */
126
- readonly jobId: number;
127
- /** Manager-reported cgroup path, possibly empty after cleanup. */
128
- readonly controlGroup: string;
129
- /** Hierarchical cgroup population evidence; null when unavailable or unnecessary. */
130
- readonly cgroupPopulated: boolean | null;
131
- }
132
- /** A program failure is a normal result, distinct from a transport or observation error. */
133
- interface TaskResult {
134
- /** Classification based on execution and exit evidence, never just the numeric status. */
135
- readonly kind: 'exited' | 'signaled' | 'execution-failed' | 'not-executed' | 'unknown';
136
- /** Program or systemd execution status, present only for CLD_EXITED. */
137
- readonly exitCode: number | null;
138
- /** Signal number, present only for CLD_KILLED or CLD_DUMPED. */
139
- readonly signal: number | null;
140
- /** Whether Type=exec activation was confirmed by retained manager evidence. */
141
- readonly execution: 'confirmed' | 'not-confirmed';
142
- /** Raw systemd result; timeout can describe runtime, stop, or cleanup escalation. */
143
- readonly systemdResult: string;
144
- /** Cleanup must be checked independently of a successful main-process exit. */
145
- readonly cleanup: CleanupState;
146
- }
147
- /** A current state observation, not a durable event history. */
148
- interface TaskSnapshot {
149
- /** Reference captured from this observation. */
150
- readonly reference: TaskReference;
151
- /** Complete requires observed InvocationIDs for both task and retention service. */
152
- readonly identity: 'complete' | 'incomplete';
153
- /** Process phase; completed always requires confirmed cleanup. */
154
- readonly phase: 'starting' | 'running' | 'cleaning' | 'completed';
155
- /** Main PID is diagnostic only and never used as task identity. */
156
- readonly mainPid: number;
157
- /** True only for inactive/failed state without a pending job. */
158
- readonly managerTerminal: boolean;
159
- /** Current cleanup evidence. */
160
- readonly cleanup: CleanupState;
161
- /** Available main-exit or terminal evidence, possibly before cleanup finishes. */
162
- readonly result: TaskResult | null;
163
- /** Minimal raw properties needed to audit the classification. */
164
- readonly evidence: TaskEvidence;
165
- }
166
- /** Absence does not prove that a task never ran; incomplete retention is also explicit. */
167
- type LookupResult = {
168
- readonly status: 'found'; /** Reference from this read. */
169
- readonly reference: TaskReference; /** Current task state. */
170
- readonly snapshot: TaskSnapshot;
171
- } | {
172
- readonly status: 'not-found'; /** Requested identity without secrets. */
173
- readonly identity: TaskIdentity;
174
- } | {
175
- readonly status: 'incomplete'; /** Partial identity, safe to inspect and conservatively release. */
176
- readonly reference: TaskReference;
177
- };
178
- /** Start acceptance means the manager queued the creation transaction, not successful exec. */
179
- interface StartReceipt {
180
- /** Acknowledged by the manager; subsequent program failure is a separate result. */
181
- readonly outcome: 'accepted';
182
- /** Requested identity, which is already known before the call. */
183
- readonly identity: TaskIdentity;
184
- /** Manager that accepted the request. */
185
- readonly manager: ManagerIdentity;
186
- /** Diagnostic path of the accepted job; jobs are not durable identities. */
187
- readonly jobPath: string;
188
- }
189
- /** Local waiting controls; neither option changes manager-owned execution limits. */
190
- interface WaitOptions {
191
- /** Aborting affects this caller's wait only. */
192
- readonly signal?: AbortSignal;
193
- /** Positive integer local deadline, at most 2147483647 milliseconds. */
194
- readonly timeoutMs?: number;
195
- }
196
- /** Stop acceptance and optional completion waiting are separate stages. */
197
- interface StopOptions extends WaitOptions {
198
- /** When true, await terminal cleanup after manager acceptance. Defaults to false. */
199
- readonly wait?: boolean;
200
- }
201
- /** Local controls for the complete release sequence, independent of each D-Bus call. */
202
- interface ReleaseOptions extends WaitOptions {
203
- /** Total local release deadline including queueing; defaults to 5000 milliseconds. */
204
- readonly timeoutMs?: number;
205
- }
206
- /** Successful stop submission or an already-completed instance. */
207
- interface StopReceipt {
208
- /** Already-completed does not submit any stop request. */
209
- readonly outcome: 'accepted' | 'already-completed';
210
- /** The exact reference checked before stopping. */
211
- readonly reference: TaskReference;
212
- /** Accepted stop job, or null for an already-completed instance. */
213
- readonly jobPath: string | null;
214
- /** Present when completion was awaited or already known. */
215
- readonly completion: TaskSnapshot | null;
216
- }
217
- /** Explicit release affects manager retention, never application log files. */
218
- interface ReleaseReceipt {
219
- /** The auxiliary retention is no longer active. */
220
- readonly released: true;
221
- /** Both identities were already absent when release began. */
222
- readonly alreadyReleased: boolean;
223
- /** Whether both records were already garbage-collected at the final observation. */
224
- readonly collected: boolean;
225
- }
226
- /** Stable categories for callers making recovery decisions. */
227
- type ErrorCode = 'INVALID_INPUT' | 'UNSUPPORTED_ENVIRONMENT' | 'PERMISSION_DENIED' | 'MANAGER_UNAVAILABLE' | 'IDENTITY_CONFLICT' | 'START_REJECTED' | 'UNKNOWN_MUTATION_OUTCOME' | 'RESULT_UNAVAILABLE' | 'TASK_RUNNING' | 'WAIT_ABORTED' | 'WAIT_TIMEOUT' | 'DISCONNECTED';
228
- /** Metadata safe for default error formatting and diagnostic output. */
229
- interface ErrorDetails {
230
- /** Public or transport operation where the failure was observed. */
231
- readonly operation?: string;
232
- /** Known delivery state; an unknown result must never authorize automatic retry. */
233
- readonly mutationOutcome?: 'not-submitted' | 'rejected' | 'accepted' | 'unknown';
234
- /** Acknowledged cleanup calls before a release error; may be positive even when a later call is unknown. */
235
- readonly acceptedCleanupMutations?: number;
236
- /** Stable detail such as unit-not-found or incomplete-identity. */
237
- readonly reason?: string;
238
- /** Random task ID only, never the serialized intent. */
239
- readonly taskId?: string;
240
- }
241
- /** A redacted event correlated centrally with a task or connection flow. */
242
- interface DiagnosticEvent {
243
- /** Stable event name; no command, environment, or output content. */
244
- readonly event: string;
245
- /** Immutable correlation context captured at emission time. */
246
- readonly context: {
247
- /** Connection flow shared by this client's operations. */
248
- readonly connection: {
249
- readonly id: string;
250
- };
251
- /** Task scope, present for task operations. */
252
- readonly task?: {
253
- readonly id: string; /** Derived unit name. */
254
- readonly unitName: string;
255
- };
256
- };
257
- /** Stable failure category, when applicable. */
258
- readonly code?: ErrorCode;
259
- }
260
- /** Explicit user-manager connection options; no automatic provisioning is performed. */
261
- interface ConnectOptions {
262
- /** Positive local D-Bus call deadline, at most 2147483647 ms; defaults to 5000. */
263
- readonly requestTimeoutMs?: number;
264
- /** Optional redacted event sink; sync throws and async rejections are isolated, never awaited. */
265
- readonly onDiagnostic?: (event: DiagnosticEvent) => void;
266
- }
267
- /** The local client owns observation resources; systemd owns the task processes. */
268
- interface TaskClient {
269
- /** Bound manager identity for persistence and diagnosis. */
270
- readonly manager: ManagerIdentity;
271
- /** Submit exactly one creation attempt for a locally validated intention. */
272
- start(intent: TaskIntent, io: TaskIO): Promise<StartReceipt>;
273
- /** Read existing ownership evidence without starting or retrying anything. */
274
- lookup(target: TaskIntent | TaskReference): Promise<LookupResult>;
275
- /** Read the exact referenced instance or fail with explicit observation unavailability. */
276
- inspect(reference: TaskReference): Promise<TaskSnapshot>;
277
- /** Wait for cleanup, or return explicit incomplete cleanup on terminal manager failure. */
278
- wait(target: TaskIntent | TaskReference, options?: WaitOptions): Promise<TaskSnapshot>;
279
- /** Ask the manager to stop the referenced cgroup, optionally awaiting cleanup. */
280
- stop(reference: TaskReference, options?: StopOptions): Promise<StopReceipt>;
281
- /** Release only completed owned retention, preserving application files. */
282
- release(reference: TaskReference, options?: ReleaseOptions): Promise<ReleaseReceipt>;
283
- /** Close local connections and observers without stopping any task. */
284
- disconnect(): Promise<void>;
285
- }
286
-
287
- /** Connect explicitly to the local user manager; package import has no connection side effects. */
288
- declare function connect(options?: ConnectOptions): Promise<TaskClient>;
289
-
290
- /** Prepare an intention locally; no connection, file opening, or process start occurs. */
291
- declare function prepare(spec: TaskSpec): TaskIntent;
292
-
293
- /** A recoverable API error with stable categories and redacted default formatting. */
294
- declare class TaskError extends Error {
295
- /** Stable category used by applications instead of parsing human-readable messages. */
296
- readonly code: ErrorCode;
297
- /** Safe delivery and identity metadata; never contains a command specification. */
298
- readonly details: ErrorDetails;
299
- /** Preserve the original cause for explicit access while keeping default output redacted. */
300
- constructor(code: ErrorCode, message: string, details?: ErrorDetails, cause?: unknown);
301
- /** Serialization deliberately excludes raw causes, stack contents, and request payloads. */
302
- toJSON(): {
303
- /** Stable error class name for serialized consumers. */
304
- name: string;
305
- /** Public recovery category. */
306
- code: ErrorCode;
307
- /** Redacted explanation safe for default logs. */
308
- message: string;
309
- /** Safe delivery evidence without raw causes. */
310
- details: ErrorDetails;
311
- };
312
- /** Console and util.inspect must not expand a transport cause containing request data. */
313
- [util.inspect.custom](): string;
314
- }
315
-
316
- export { type CleanupState, type ConnectOptions, type DiagnosticEvent, type ErrorCode, type ErrorDetails, type LookupResult, type ManagerIdentity, type ReleaseOptions, type ReleaseReceipt, type StartReceipt, type StopOptions, type StopReceipt, type SystemdProperty, type TaskClient, TaskError, type TaskEvidence, type TaskIO, type TaskIdentity, type TaskInput, type TaskIntent, type TaskOutput, type TaskReference, type TaskResult, type TaskSnapshot, type TaskSpec, type WaitOptions, connect, nullIO, prepare };
1
+ export { CleanupState, ConnectOptions, DiagnosticEvent, ErrorCode, ErrorDetails, LookupResult, ManagerIdentity, ReleaseOptions, ReleaseReceipt, StartReceipt, StopOptions, StopReceipt, SystemdProperty, TaskClient, TaskError, TaskEvidence, TaskIO, TaskIdentity, TaskInput, TaskIntent, TaskOutput, TaskReference, TaskResult, TaskSnapshot, TaskSpec, WaitOptions, connect, nullIO, prepare } from '#runtime';