@adhdev/session-host-core 1.0.82-rc.36 → 1.0.82-rc.38
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.mts +90 -94
- package/dist/index.d.ts +90 -94
- package/dist/index.js +114 -131
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +107 -126
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/cleanup-expected.ts +114 -0
- package/src/control-plane.ts +58 -0
- package/src/index.ts +12 -2
- package/src/types.ts +40 -8
- package/src/operator-recovery.ts +0 -134
package/dist/index.d.mts
CHANGED
|
@@ -3,79 +3,6 @@ import { SpawnOptions, ChildProcess } from 'node:child_process';
|
|
|
3
3
|
import * as net from 'net';
|
|
4
4
|
export { DEFAULT_SESSION_HOST_COLS, DEFAULT_SESSION_HOST_ROWS, resolveSessionHostCols, resolveSessionHostRows } from './defaults.mjs';
|
|
5
5
|
|
|
6
|
-
/** This association is owner asserted, never a historical native receipt. */
|
|
7
|
-
declare const OPERATOR_RECOVERY_TARGET: Readonly<{
|
|
8
|
-
association: "operator_asserted";
|
|
9
|
-
taskId: "a1cdf3c0-f029-4d17-a8e9-db64e0a55501";
|
|
10
|
-
meshId: "mesh_271444af883843e9b36c67155b87b22f";
|
|
11
|
-
attemptId: "mesh_queue:mesh_271444af883843e9b36c67155b87b22f:a1cdf3c0-f029-4d17-a8e9-db64e0a55501:0";
|
|
12
|
-
generation: 0;
|
|
13
|
-
dispatchNonce: 1;
|
|
14
|
-
deliveryId: "dlv-7e259b34-b049-47ee-a466-2ca9c12bcff4";
|
|
15
|
-
ownerDaemonId: "daemon_mach_4462a75330c548be9c2e74dd9f7f6ffb";
|
|
16
|
-
nodeId: "node_d82de0cef9b042b6948986609e32142f";
|
|
17
|
-
workerDaemonId: "daemon_mach_6733c865d60f432dbeb119a6875ee303";
|
|
18
|
-
sessionId: "de321185-4ebc-40aa-8c6e-b4919e87fae3";
|
|
19
|
-
providerSessionId: "60806c79-7d77-4614-9fa6-e628533478ba";
|
|
20
|
-
namespace: "6a2ef3162182";
|
|
21
|
-
}>;
|
|
22
|
-
declare const recoveryTargetBytes: string;
|
|
23
|
-
/** Shared final admission guard for saved IDs, new aliases and provider argv.
|
|
24
|
-
* This is a permanent exact-target denial, independent of journal availability. */
|
|
25
|
-
declare function assertRecoveryLaunchIdentity(value: unknown): void;
|
|
26
|
-
type RecoveryOwnerOperation = 'anchor_recover' | 'fence_install' | 'witness_enroll';
|
|
27
|
-
interface RecoveryOwnerGrant {
|
|
28
|
-
readonly purpose: 'operator_recovery_v1';
|
|
29
|
-
readonly operation: RecoveryOwnerOperation;
|
|
30
|
-
}
|
|
31
|
-
declare function isRecoveryEndpoint(endpoint: string): boolean;
|
|
32
|
-
interface RecoveryOwnerChallenge {
|
|
33
|
-
readonly message: string;
|
|
34
|
-
}
|
|
35
|
-
interface RecoveryOwnerEnrollment {
|
|
36
|
-
/** Trusted boot dependency, provisioned outside delegated worker authority.
|
|
37
|
-
* Do not load this from daemon config, IPC arguments or an MCP credential. */
|
|
38
|
-
publicKey: string;
|
|
39
|
-
enrollmentId: string;
|
|
40
|
-
coordinatorBootId: string;
|
|
41
|
-
authEpoch: string;
|
|
42
|
-
verifyCurrent: () => boolean;
|
|
43
|
-
}
|
|
44
|
-
/** Signature possession authenticates the separately enrolled owner signer.
|
|
45
|
-
* This verifier does not enroll keys or assert user presence on their behalf. */
|
|
46
|
-
declare class RecoveryOwnerAdmission {
|
|
47
|
-
private readonly clock;
|
|
48
|
-
private readonly key;
|
|
49
|
-
private readonly enrollment;
|
|
50
|
-
private readonly pending;
|
|
51
|
-
private readonly grants;
|
|
52
|
-
private lastNow;
|
|
53
|
-
constructor(enrollment: RecoveryOwnerEnrollment, clock?: () => number);
|
|
54
|
-
private now;
|
|
55
|
-
challenge(operation?: RecoveryOwnerOperation): RecoveryOwnerChallenge;
|
|
56
|
-
authorize(message: string, signature: string): RecoveryOwnerGrant;
|
|
57
|
-
assertGrant(grant: unknown): asserts grant is RecoveryOwnerGrant;
|
|
58
|
-
/** Burn synchronously before any work or await. The private continuation
|
|
59
|
-
* rechecks the ORIGINAL deadline and revocation; it cannot mint a new grant. */
|
|
60
|
-
reserve(grant: unknown, operation: RecoveryOwnerOperation): () => void;
|
|
61
|
-
consume(grant: unknown): void;
|
|
62
|
-
}
|
|
63
|
-
interface RecoveryHostBinding {
|
|
64
|
-
namespace: string;
|
|
65
|
-
endpoint: string;
|
|
66
|
-
hostBootId: string;
|
|
67
|
-
workerDaemonId: string;
|
|
68
|
-
}
|
|
69
|
-
interface RecoveryPhysicalProof extends RecoveryHostBinding {
|
|
70
|
-
protocol: 1;
|
|
71
|
-
verdict: 'ABSENT' | 'LIVE' | 'UNKNOWN';
|
|
72
|
-
reason: string;
|
|
73
|
-
nonce: string;
|
|
74
|
-
fenceDigest: string;
|
|
75
|
-
sessionId: string;
|
|
76
|
-
providerSessionId: string;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
6
|
type SessionTransport = 'pty';
|
|
80
7
|
type SessionHostCategory = 'cli' | 'acp' | 'shell';
|
|
81
8
|
type SessionLifecycle = 'starting' | 'running' | 'stopping' | 'stopped' | 'failed' | 'interrupted';
|
|
@@ -250,6 +177,26 @@ interface ResizeSessionPayload {
|
|
|
250
177
|
interface StopSessionPayload {
|
|
251
178
|
sessionId: string;
|
|
252
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Expected logical + physical identity for a cleanup stop. Captured before any
|
|
182
|
+
* async host RPC and re-checked inside the host stop critical section.
|
|
183
|
+
* All of taskId/attemptId/generation/dispatchNonce null means expected unbound
|
|
184
|
+
* (no meshActiveAssignment) so a later claim cannot be stopped by stale cleanup.
|
|
185
|
+
*/
|
|
186
|
+
interface SessionCleanupExpectedAssignment {
|
|
187
|
+
sessionId: string;
|
|
188
|
+
hostBootId: string;
|
|
189
|
+
runtimeKey: string;
|
|
190
|
+
startedAt: number;
|
|
191
|
+
taskId: string | null;
|
|
192
|
+
attemptId: string | null;
|
|
193
|
+
generation: number | null;
|
|
194
|
+
dispatchNonce: number | null;
|
|
195
|
+
}
|
|
196
|
+
interface StopSessionIfExpectedPayload {
|
|
197
|
+
sessionId: string;
|
|
198
|
+
expected: SessionCleanupExpectedAssignment;
|
|
199
|
+
}
|
|
253
200
|
interface MeshWriterAssignment {
|
|
254
201
|
meshId: string;
|
|
255
202
|
nodeId: string;
|
|
@@ -275,6 +222,13 @@ interface DeleteSessionPayload {
|
|
|
275
222
|
/** Stop a live runtime before deleting the persisted record. */
|
|
276
223
|
force?: boolean;
|
|
277
224
|
}
|
|
225
|
+
/** Expected identity for record deletion; old hosts must refuse this distinct kind. */
|
|
226
|
+
interface DeleteSessionIfExpectedPayload {
|
|
227
|
+
sessionId: string;
|
|
228
|
+
expected: SessionCleanupExpectedAssignment;
|
|
229
|
+
/** Stop the matching live runtime before deleting that exact incarnation. */
|
|
230
|
+
force?: boolean;
|
|
231
|
+
}
|
|
278
232
|
interface ResumeSessionPayload {
|
|
279
233
|
sessionId: string;
|
|
280
234
|
}
|
|
@@ -393,6 +347,13 @@ interface SessionHostDiagnostics {
|
|
|
393
347
|
* must treat `undefined` as "unknown", never as a match.
|
|
394
348
|
*/
|
|
395
349
|
hostEntryPath?: string;
|
|
350
|
+
/**
|
|
351
|
+
* Authoritative host boot identity used by cleanup expected-assignment CAS.
|
|
352
|
+
* Same value `stop_session_if_expected` refuses against: upgrade-lease bootId
|
|
353
|
+
* when the host was launched with a native upgrade binding, otherwise `hs:<hostStartedAt>`.
|
|
354
|
+
* Optional so older hosts omit it; callers must not invent an upgrade UUID.
|
|
355
|
+
*/
|
|
356
|
+
hostBootId?: string;
|
|
396
357
|
runtimeCount: number;
|
|
397
358
|
supportedRequestTypes?: SessionHostRequestType[];
|
|
398
359
|
sessions?: SessionHostRecord[];
|
|
@@ -410,26 +371,6 @@ interface HostUpgradeLeasePayload {
|
|
|
410
371
|
token: string;
|
|
411
372
|
}
|
|
412
373
|
type SessionHostRequest = {
|
|
413
|
-
type: 'prepare_operator_recovery_fence_v1';
|
|
414
|
-
payload?: {};
|
|
415
|
-
} | {
|
|
416
|
-
type: 'install_operator_recovery_fence_v1';
|
|
417
|
-
payload: {
|
|
418
|
-
message: string;
|
|
419
|
-
signature: string;
|
|
420
|
-
};
|
|
421
|
-
} | {
|
|
422
|
-
type: 'attest_operator_recovery_v1';
|
|
423
|
-
payload: {
|
|
424
|
-
nonce: string;
|
|
425
|
-
fenceDigest: string;
|
|
426
|
-
};
|
|
427
|
-
} | {
|
|
428
|
-
type: 'get_operator_recovery_coverage_v1';
|
|
429
|
-
payload: {
|
|
430
|
-
nonce: string;
|
|
431
|
-
};
|
|
432
|
-
} | {
|
|
433
374
|
type: 'get_upgrade_lease';
|
|
434
375
|
payload?: {};
|
|
435
376
|
} | {
|
|
@@ -471,12 +412,22 @@ type SessionHostRequest = {
|
|
|
471
412
|
} | {
|
|
472
413
|
type: 'stop_session';
|
|
473
414
|
payload: StopSessionPayload;
|
|
415
|
+
}
|
|
416
|
+
/** Distinct kind: old hosts must refuse instead of stopping by session id alone. */
|
|
417
|
+
| {
|
|
418
|
+
type: 'stop_session_if_expected';
|
|
419
|
+
payload: StopSessionIfExpectedPayload;
|
|
474
420
|
} | {
|
|
475
421
|
type: 'stop_mesh_writer';
|
|
476
422
|
payload: StopMeshWriterPayload;
|
|
477
423
|
} | {
|
|
478
424
|
type: 'delete_session';
|
|
479
425
|
payload: DeleteSessionPayload;
|
|
426
|
+
}
|
|
427
|
+
/** Distinct kind: old hosts must refuse instead of deleting by session id alone. */
|
|
428
|
+
| {
|
|
429
|
+
type: 'delete_session_if_expected';
|
|
430
|
+
payload: DeleteSessionIfExpectedPayload;
|
|
480
431
|
} | {
|
|
481
432
|
type: 'resume_session';
|
|
482
433
|
payload: ResumeSessionPayload;
|
|
@@ -619,6 +570,34 @@ interface SessionHostEventEnvelope {
|
|
|
619
570
|
}
|
|
620
571
|
type SessionHostWireEnvelope = SessionHostRequestEnvelope | SessionHostResponseEnvelope | SessionHostEventEnvelope;
|
|
621
572
|
|
|
573
|
+
/** Shared cleanup expected-assignment / host-boot helpers (daemon + host). */
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Prefix on delete_session_if_expected refusals after runtime.stop was requested.
|
|
577
|
+
* Client durable fences must not abort on these — the writer may already be dying.
|
|
578
|
+
* Before-action refusals keep the bare CLEANUP_HOST_REFUSAL_CODES (abort-safe proof).
|
|
579
|
+
*/
|
|
580
|
+
declare const CLEANUP_AFTER_STOP_SIDE_EFFECT_PREFIX = "cleanup_after_stop_side_effect:";
|
|
581
|
+
declare function tagCleanupAfterStopSideEffect(code: string): string;
|
|
582
|
+
declare function stripCleanupAfterStopSideEffect(raw: string): {
|
|
583
|
+
afterStop: boolean;
|
|
584
|
+
code: string;
|
|
585
|
+
};
|
|
586
|
+
declare function hostBootIdFromStartedAt(hostStartedAt: number): string;
|
|
587
|
+
declare function resolveHostBootId(opts: {
|
|
588
|
+
upgradeBootId?: string | null;
|
|
589
|
+
hostStartedAt: number;
|
|
590
|
+
}): string | null;
|
|
591
|
+
/** Sanitized refusal codes only — never echo assignment contents. */
|
|
592
|
+
declare function refuseCleanupExpectedStop(record: SessionHostRecord | null | undefined, expected: SessionCleanupExpectedAssignment, currentHostBootId: string | null, hasRuntime: boolean): string | null;
|
|
593
|
+
/**
|
|
594
|
+
* Delete CAS: same identity/assignment proof as stop. A replaced incarnation or a
|
|
595
|
+
* newly bound writer must survive — never delete a record that no longer matches
|
|
596
|
+
* the captured expected tuple. `force` is required to stop a still-live runtime
|
|
597
|
+
* before deleting that exact incarnation.
|
|
598
|
+
*/
|
|
599
|
+
declare function refuseCleanupExpectedDelete(record: SessionHostRecord | null | undefined, expected: SessionCleanupExpectedAssignment, currentHostBootId: string | null, hasRuntime: boolean, force: boolean): string | null;
|
|
600
|
+
|
|
622
601
|
interface ClassifyTerminationInput {
|
|
623
602
|
exitCode: number | null;
|
|
624
603
|
signal?: number | null;
|
|
@@ -1083,11 +1062,28 @@ interface SessionHostSnapshot {
|
|
|
1083
1062
|
*/
|
|
1084
1063
|
interface SessionHostControlPlane {
|
|
1085
1064
|
getDiagnostics(payload?: GetHostDiagnosticsPayload): Promise<SessionHostDiagnostics>;
|
|
1065
|
+
/**
|
|
1066
|
+
* Authoritative host boot identity for idle inventory / cleanup expected CAS.
|
|
1067
|
+
* Prefers diagnostics.hostBootId (host SoT), else proves upgrade lease bootId
|
|
1068
|
+
* via get_upgrade_lease, else hs:<hostStartedAt> for non-upgrade / old hosts.
|
|
1069
|
+
* Ambiguous upgrade-lease failures fail closed (null) — never invent a UUID.
|
|
1070
|
+
*/
|
|
1071
|
+
resolveHostBootId(): Promise<string | null>;
|
|
1086
1072
|
listSessions(): Promise<SessionHostRecord[]>;
|
|
1087
1073
|
stopSession(sessionId: string): Promise<SessionHostRecord | null>;
|
|
1074
|
+
/** Host CAS stop: refuses without mutating when expected assignment/boot/incarnation drift. */
|
|
1075
|
+
stopSessionIfExpected(sessionId: string, expected: SessionCleanupExpectedAssignment): Promise<SessionHostRecord | null>;
|
|
1088
1076
|
deleteSession(sessionId: string, opts?: {
|
|
1089
1077
|
force?: boolean;
|
|
1090
1078
|
}): Promise<SessionHostRecord | null>;
|
|
1079
|
+
/** Host CAS delete: refuses without mutating when expected assignment/boot/incarnation drift. */
|
|
1080
|
+
deleteSessionIfExpected(sessionId: string, expected: SessionCleanupExpectedAssignment, opts?: {
|
|
1081
|
+
force?: boolean;
|
|
1082
|
+
}): Promise<{
|
|
1083
|
+
sessionId: string;
|
|
1084
|
+
deleted: boolean;
|
|
1085
|
+
alreadyAbsent?: boolean;
|
|
1086
|
+
} | null>;
|
|
1091
1087
|
resumeSession(sessionId: string): Promise<SessionHostRecord | null>;
|
|
1092
1088
|
restartSession(sessionId: string): Promise<SessionHostRecord | null>;
|
|
1093
1089
|
sendSignal(sessionId: string, signal: string): Promise<SessionHostRecord | null>;
|
|
@@ -1126,4 +1122,4 @@ interface SessionHostControlTransport {
|
|
|
1126
1122
|
*/
|
|
1127
1123
|
declare function createSessionHostControlPlane(transport: SessionHostControlTransport): SessionHostControlPlane;
|
|
1128
1124
|
|
|
1129
|
-
export { type AcquireWritePayload, type AttachSessionPayload, CLI_CHILD_NICE_ENV, CLI_CHILD_NICE_INCREMENT, CLI_CHILD_SCHEDULING_ENV, type ClearSessionBufferPayload, type CreateSessionPayload, DEFAULT_CONFIG_DIR_NAME, DEFAULT_SESSION_RING_BUFFER_MAX_BYTES, type DetachSessionPayload, type ForceDetachClientPayload, type GetHostDiagnosticsPayload, type GetSnapshotPayload, type GetTerminalSnapshotPayload, type HostUpgradeLeasePayload, type MeshWriterAssignment, type MeshWriterStopTarget, type NiceLaunch,
|
|
1125
|
+
export { type AcquireWritePayload, type AttachSessionPayload, CLEANUP_AFTER_STOP_SIDE_EFFECT_PREFIX, CLI_CHILD_NICE_ENV, CLI_CHILD_NICE_INCREMENT, CLI_CHILD_SCHEDULING_ENV, type ClearSessionBufferPayload, type CreateSessionPayload, DEFAULT_CONFIG_DIR_NAME, DEFAULT_SESSION_RING_BUFFER_MAX_BYTES, type DeleteSessionIfExpectedPayload, type DetachSessionPayload, type ForceDetachClientPayload, type GetHostDiagnosticsPayload, type GetSnapshotPayload, type GetTerminalSnapshotPayload, type HostUpgradeLeasePayload, type MeshWriterAssignment, type MeshWriterStopTarget, type NiceLaunch, type PruneDuplicateSessionsPayload, type ReleaseWritePayload, type ResizeSessionPayload, type RestartSessionPayload, type ResumeSessionPayload, SESSION_HOST_SUPPORTED_REQUEST_TYPES, type SendInputPayload, type SendSignalPayload, type SessionAttachedClient, type SessionBufferSnapshot, type SessionCleanupExpectedAssignment, type SessionClientType, type SessionHostCategory, type SessionHostCensus, SessionHostClient, type SessionHostClientOptions, type SessionHostControlPlane, type SessionHostControlTransport, type SessionHostDiagnostics, type SessionHostDisconnectInfo, type SessionHostDisconnectReason, type SessionHostDuplicateSessionGroup, type SessionHostEndpoint, type SessionHostEndpointOptions, type SessionHostEvent, type SessionHostEventEnvelope, type SessionHostLogEntry, type SessionHostPruneDuplicatesResult, type SessionHostRecord, SessionHostRegistry, type SessionHostRequest, type SessionHostRequestEnvelope, type SessionHostRequestTrace, type SessionHostRequestType, type SessionHostResponse, type SessionHostResponseEnvelope, type SessionHostRuntimeTransition, type SessionHostSnapshot, type SessionHostSurfaceKind, type SessionHostSurfaceRecordLike, type SessionHostWireEnvelope, type SessionLaunchCommand, type SessionLifecycle, type SessionOwnerType, SessionRingBuffer, type SessionRingBufferOptions, type SessionTerminalSnapshot, type SessionTerminalState, type SessionTermination, type SessionTransport, type SessionWriteOwner, type StopMeshWriterPayload, type StopSessionIfExpectedPayload, type StopSessionPayload, type UpdateSessionMetaPayload, applyTerminalColorEnv, assertTestStorageIsolated, buildRuntimeDisplayName, buildRuntimeKey, canonicalizeInstancePath, classifyTermination, createCliChildPriorityPolicy, createLineParser, createResponseEnvelope, createSessionHostControlPlane, disconnectSessionHostClients, ensureNodePtySpawnHelperPermissions, findConnectedSessionHostClient, formatRuntimeOwner, getDefaultSessionHostEndpoint, getSessionHostRecoveryLabel, getSessionHostSurfaceKind, getWorkspaceLabel, hiddenSpawn as hiddenSpawnProcess, hostBootIdFromStartedAt, isDefaultInstanceConfigDir, isSessionHostLiveRuntime, isSessionHostRecoverySnapshot, isTerminalRecord, niceLaunch, partitionSessionHostDiagnosticsSessions, partitionSessionHostRecords, refuseCleanupExpectedDelete, refuseCleanupExpectedStop, replayLaunchEnv, resolveAttachableRuntimeRecord, resolveHostBootId, resolveInstanceConfigDir, resolveRuntimeRecord, resolveSessionHostIpcKey, sanitizeSpawnEnv, spawnCliChild, stripCleanupAfterStopSideEffect, tagCleanupAfterStopSideEffect, validateSessionHostEndpoint, writeEnvelope };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,79 +3,6 @@ import { SpawnOptions, ChildProcess } from 'node:child_process';
|
|
|
3
3
|
import * as net from 'net';
|
|
4
4
|
export { DEFAULT_SESSION_HOST_COLS, DEFAULT_SESSION_HOST_ROWS, resolveSessionHostCols, resolveSessionHostRows } from './defaults.js';
|
|
5
5
|
|
|
6
|
-
/** This association is owner asserted, never a historical native receipt. */
|
|
7
|
-
declare const OPERATOR_RECOVERY_TARGET: Readonly<{
|
|
8
|
-
association: "operator_asserted";
|
|
9
|
-
taskId: "a1cdf3c0-f029-4d17-a8e9-db64e0a55501";
|
|
10
|
-
meshId: "mesh_271444af883843e9b36c67155b87b22f";
|
|
11
|
-
attemptId: "mesh_queue:mesh_271444af883843e9b36c67155b87b22f:a1cdf3c0-f029-4d17-a8e9-db64e0a55501:0";
|
|
12
|
-
generation: 0;
|
|
13
|
-
dispatchNonce: 1;
|
|
14
|
-
deliveryId: "dlv-7e259b34-b049-47ee-a466-2ca9c12bcff4";
|
|
15
|
-
ownerDaemonId: "daemon_mach_4462a75330c548be9c2e74dd9f7f6ffb";
|
|
16
|
-
nodeId: "node_d82de0cef9b042b6948986609e32142f";
|
|
17
|
-
workerDaemonId: "daemon_mach_6733c865d60f432dbeb119a6875ee303";
|
|
18
|
-
sessionId: "de321185-4ebc-40aa-8c6e-b4919e87fae3";
|
|
19
|
-
providerSessionId: "60806c79-7d77-4614-9fa6-e628533478ba";
|
|
20
|
-
namespace: "6a2ef3162182";
|
|
21
|
-
}>;
|
|
22
|
-
declare const recoveryTargetBytes: string;
|
|
23
|
-
/** Shared final admission guard for saved IDs, new aliases and provider argv.
|
|
24
|
-
* This is a permanent exact-target denial, independent of journal availability. */
|
|
25
|
-
declare function assertRecoveryLaunchIdentity(value: unknown): void;
|
|
26
|
-
type RecoveryOwnerOperation = 'anchor_recover' | 'fence_install' | 'witness_enroll';
|
|
27
|
-
interface RecoveryOwnerGrant {
|
|
28
|
-
readonly purpose: 'operator_recovery_v1';
|
|
29
|
-
readonly operation: RecoveryOwnerOperation;
|
|
30
|
-
}
|
|
31
|
-
declare function isRecoveryEndpoint(endpoint: string): boolean;
|
|
32
|
-
interface RecoveryOwnerChallenge {
|
|
33
|
-
readonly message: string;
|
|
34
|
-
}
|
|
35
|
-
interface RecoveryOwnerEnrollment {
|
|
36
|
-
/** Trusted boot dependency, provisioned outside delegated worker authority.
|
|
37
|
-
* Do not load this from daemon config, IPC arguments or an MCP credential. */
|
|
38
|
-
publicKey: string;
|
|
39
|
-
enrollmentId: string;
|
|
40
|
-
coordinatorBootId: string;
|
|
41
|
-
authEpoch: string;
|
|
42
|
-
verifyCurrent: () => boolean;
|
|
43
|
-
}
|
|
44
|
-
/** Signature possession authenticates the separately enrolled owner signer.
|
|
45
|
-
* This verifier does not enroll keys or assert user presence on their behalf. */
|
|
46
|
-
declare class RecoveryOwnerAdmission {
|
|
47
|
-
private readonly clock;
|
|
48
|
-
private readonly key;
|
|
49
|
-
private readonly enrollment;
|
|
50
|
-
private readonly pending;
|
|
51
|
-
private readonly grants;
|
|
52
|
-
private lastNow;
|
|
53
|
-
constructor(enrollment: RecoveryOwnerEnrollment, clock?: () => number);
|
|
54
|
-
private now;
|
|
55
|
-
challenge(operation?: RecoveryOwnerOperation): RecoveryOwnerChallenge;
|
|
56
|
-
authorize(message: string, signature: string): RecoveryOwnerGrant;
|
|
57
|
-
assertGrant(grant: unknown): asserts grant is RecoveryOwnerGrant;
|
|
58
|
-
/** Burn synchronously before any work or await. The private continuation
|
|
59
|
-
* rechecks the ORIGINAL deadline and revocation; it cannot mint a new grant. */
|
|
60
|
-
reserve(grant: unknown, operation: RecoveryOwnerOperation): () => void;
|
|
61
|
-
consume(grant: unknown): void;
|
|
62
|
-
}
|
|
63
|
-
interface RecoveryHostBinding {
|
|
64
|
-
namespace: string;
|
|
65
|
-
endpoint: string;
|
|
66
|
-
hostBootId: string;
|
|
67
|
-
workerDaemonId: string;
|
|
68
|
-
}
|
|
69
|
-
interface RecoveryPhysicalProof extends RecoveryHostBinding {
|
|
70
|
-
protocol: 1;
|
|
71
|
-
verdict: 'ABSENT' | 'LIVE' | 'UNKNOWN';
|
|
72
|
-
reason: string;
|
|
73
|
-
nonce: string;
|
|
74
|
-
fenceDigest: string;
|
|
75
|
-
sessionId: string;
|
|
76
|
-
providerSessionId: string;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
6
|
type SessionTransport = 'pty';
|
|
80
7
|
type SessionHostCategory = 'cli' | 'acp' | 'shell';
|
|
81
8
|
type SessionLifecycle = 'starting' | 'running' | 'stopping' | 'stopped' | 'failed' | 'interrupted';
|
|
@@ -250,6 +177,26 @@ interface ResizeSessionPayload {
|
|
|
250
177
|
interface StopSessionPayload {
|
|
251
178
|
sessionId: string;
|
|
252
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Expected logical + physical identity for a cleanup stop. Captured before any
|
|
182
|
+
* async host RPC and re-checked inside the host stop critical section.
|
|
183
|
+
* All of taskId/attemptId/generation/dispatchNonce null means expected unbound
|
|
184
|
+
* (no meshActiveAssignment) so a later claim cannot be stopped by stale cleanup.
|
|
185
|
+
*/
|
|
186
|
+
interface SessionCleanupExpectedAssignment {
|
|
187
|
+
sessionId: string;
|
|
188
|
+
hostBootId: string;
|
|
189
|
+
runtimeKey: string;
|
|
190
|
+
startedAt: number;
|
|
191
|
+
taskId: string | null;
|
|
192
|
+
attemptId: string | null;
|
|
193
|
+
generation: number | null;
|
|
194
|
+
dispatchNonce: number | null;
|
|
195
|
+
}
|
|
196
|
+
interface StopSessionIfExpectedPayload {
|
|
197
|
+
sessionId: string;
|
|
198
|
+
expected: SessionCleanupExpectedAssignment;
|
|
199
|
+
}
|
|
253
200
|
interface MeshWriterAssignment {
|
|
254
201
|
meshId: string;
|
|
255
202
|
nodeId: string;
|
|
@@ -275,6 +222,13 @@ interface DeleteSessionPayload {
|
|
|
275
222
|
/** Stop a live runtime before deleting the persisted record. */
|
|
276
223
|
force?: boolean;
|
|
277
224
|
}
|
|
225
|
+
/** Expected identity for record deletion; old hosts must refuse this distinct kind. */
|
|
226
|
+
interface DeleteSessionIfExpectedPayload {
|
|
227
|
+
sessionId: string;
|
|
228
|
+
expected: SessionCleanupExpectedAssignment;
|
|
229
|
+
/** Stop the matching live runtime before deleting that exact incarnation. */
|
|
230
|
+
force?: boolean;
|
|
231
|
+
}
|
|
278
232
|
interface ResumeSessionPayload {
|
|
279
233
|
sessionId: string;
|
|
280
234
|
}
|
|
@@ -393,6 +347,13 @@ interface SessionHostDiagnostics {
|
|
|
393
347
|
* must treat `undefined` as "unknown", never as a match.
|
|
394
348
|
*/
|
|
395
349
|
hostEntryPath?: string;
|
|
350
|
+
/**
|
|
351
|
+
* Authoritative host boot identity used by cleanup expected-assignment CAS.
|
|
352
|
+
* Same value `stop_session_if_expected` refuses against: upgrade-lease bootId
|
|
353
|
+
* when the host was launched with a native upgrade binding, otherwise `hs:<hostStartedAt>`.
|
|
354
|
+
* Optional so older hosts omit it; callers must not invent an upgrade UUID.
|
|
355
|
+
*/
|
|
356
|
+
hostBootId?: string;
|
|
396
357
|
runtimeCount: number;
|
|
397
358
|
supportedRequestTypes?: SessionHostRequestType[];
|
|
398
359
|
sessions?: SessionHostRecord[];
|
|
@@ -410,26 +371,6 @@ interface HostUpgradeLeasePayload {
|
|
|
410
371
|
token: string;
|
|
411
372
|
}
|
|
412
373
|
type SessionHostRequest = {
|
|
413
|
-
type: 'prepare_operator_recovery_fence_v1';
|
|
414
|
-
payload?: {};
|
|
415
|
-
} | {
|
|
416
|
-
type: 'install_operator_recovery_fence_v1';
|
|
417
|
-
payload: {
|
|
418
|
-
message: string;
|
|
419
|
-
signature: string;
|
|
420
|
-
};
|
|
421
|
-
} | {
|
|
422
|
-
type: 'attest_operator_recovery_v1';
|
|
423
|
-
payload: {
|
|
424
|
-
nonce: string;
|
|
425
|
-
fenceDigest: string;
|
|
426
|
-
};
|
|
427
|
-
} | {
|
|
428
|
-
type: 'get_operator_recovery_coverage_v1';
|
|
429
|
-
payload: {
|
|
430
|
-
nonce: string;
|
|
431
|
-
};
|
|
432
|
-
} | {
|
|
433
374
|
type: 'get_upgrade_lease';
|
|
434
375
|
payload?: {};
|
|
435
376
|
} | {
|
|
@@ -471,12 +412,22 @@ type SessionHostRequest = {
|
|
|
471
412
|
} | {
|
|
472
413
|
type: 'stop_session';
|
|
473
414
|
payload: StopSessionPayload;
|
|
415
|
+
}
|
|
416
|
+
/** Distinct kind: old hosts must refuse instead of stopping by session id alone. */
|
|
417
|
+
| {
|
|
418
|
+
type: 'stop_session_if_expected';
|
|
419
|
+
payload: StopSessionIfExpectedPayload;
|
|
474
420
|
} | {
|
|
475
421
|
type: 'stop_mesh_writer';
|
|
476
422
|
payload: StopMeshWriterPayload;
|
|
477
423
|
} | {
|
|
478
424
|
type: 'delete_session';
|
|
479
425
|
payload: DeleteSessionPayload;
|
|
426
|
+
}
|
|
427
|
+
/** Distinct kind: old hosts must refuse instead of deleting by session id alone. */
|
|
428
|
+
| {
|
|
429
|
+
type: 'delete_session_if_expected';
|
|
430
|
+
payload: DeleteSessionIfExpectedPayload;
|
|
480
431
|
} | {
|
|
481
432
|
type: 'resume_session';
|
|
482
433
|
payload: ResumeSessionPayload;
|
|
@@ -619,6 +570,34 @@ interface SessionHostEventEnvelope {
|
|
|
619
570
|
}
|
|
620
571
|
type SessionHostWireEnvelope = SessionHostRequestEnvelope | SessionHostResponseEnvelope | SessionHostEventEnvelope;
|
|
621
572
|
|
|
573
|
+
/** Shared cleanup expected-assignment / host-boot helpers (daemon + host). */
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Prefix on delete_session_if_expected refusals after runtime.stop was requested.
|
|
577
|
+
* Client durable fences must not abort on these — the writer may already be dying.
|
|
578
|
+
* Before-action refusals keep the bare CLEANUP_HOST_REFUSAL_CODES (abort-safe proof).
|
|
579
|
+
*/
|
|
580
|
+
declare const CLEANUP_AFTER_STOP_SIDE_EFFECT_PREFIX = "cleanup_after_stop_side_effect:";
|
|
581
|
+
declare function tagCleanupAfterStopSideEffect(code: string): string;
|
|
582
|
+
declare function stripCleanupAfterStopSideEffect(raw: string): {
|
|
583
|
+
afterStop: boolean;
|
|
584
|
+
code: string;
|
|
585
|
+
};
|
|
586
|
+
declare function hostBootIdFromStartedAt(hostStartedAt: number): string;
|
|
587
|
+
declare function resolveHostBootId(opts: {
|
|
588
|
+
upgradeBootId?: string | null;
|
|
589
|
+
hostStartedAt: number;
|
|
590
|
+
}): string | null;
|
|
591
|
+
/** Sanitized refusal codes only — never echo assignment contents. */
|
|
592
|
+
declare function refuseCleanupExpectedStop(record: SessionHostRecord | null | undefined, expected: SessionCleanupExpectedAssignment, currentHostBootId: string | null, hasRuntime: boolean): string | null;
|
|
593
|
+
/**
|
|
594
|
+
* Delete CAS: same identity/assignment proof as stop. A replaced incarnation or a
|
|
595
|
+
* newly bound writer must survive — never delete a record that no longer matches
|
|
596
|
+
* the captured expected tuple. `force` is required to stop a still-live runtime
|
|
597
|
+
* before deleting that exact incarnation.
|
|
598
|
+
*/
|
|
599
|
+
declare function refuseCleanupExpectedDelete(record: SessionHostRecord | null | undefined, expected: SessionCleanupExpectedAssignment, currentHostBootId: string | null, hasRuntime: boolean, force: boolean): string | null;
|
|
600
|
+
|
|
622
601
|
interface ClassifyTerminationInput {
|
|
623
602
|
exitCode: number | null;
|
|
624
603
|
signal?: number | null;
|
|
@@ -1083,11 +1062,28 @@ interface SessionHostSnapshot {
|
|
|
1083
1062
|
*/
|
|
1084
1063
|
interface SessionHostControlPlane {
|
|
1085
1064
|
getDiagnostics(payload?: GetHostDiagnosticsPayload): Promise<SessionHostDiagnostics>;
|
|
1065
|
+
/**
|
|
1066
|
+
* Authoritative host boot identity for idle inventory / cleanup expected CAS.
|
|
1067
|
+
* Prefers diagnostics.hostBootId (host SoT), else proves upgrade lease bootId
|
|
1068
|
+
* via get_upgrade_lease, else hs:<hostStartedAt> for non-upgrade / old hosts.
|
|
1069
|
+
* Ambiguous upgrade-lease failures fail closed (null) — never invent a UUID.
|
|
1070
|
+
*/
|
|
1071
|
+
resolveHostBootId(): Promise<string | null>;
|
|
1086
1072
|
listSessions(): Promise<SessionHostRecord[]>;
|
|
1087
1073
|
stopSession(sessionId: string): Promise<SessionHostRecord | null>;
|
|
1074
|
+
/** Host CAS stop: refuses without mutating when expected assignment/boot/incarnation drift. */
|
|
1075
|
+
stopSessionIfExpected(sessionId: string, expected: SessionCleanupExpectedAssignment): Promise<SessionHostRecord | null>;
|
|
1088
1076
|
deleteSession(sessionId: string, opts?: {
|
|
1089
1077
|
force?: boolean;
|
|
1090
1078
|
}): Promise<SessionHostRecord | null>;
|
|
1079
|
+
/** Host CAS delete: refuses without mutating when expected assignment/boot/incarnation drift. */
|
|
1080
|
+
deleteSessionIfExpected(sessionId: string, expected: SessionCleanupExpectedAssignment, opts?: {
|
|
1081
|
+
force?: boolean;
|
|
1082
|
+
}): Promise<{
|
|
1083
|
+
sessionId: string;
|
|
1084
|
+
deleted: boolean;
|
|
1085
|
+
alreadyAbsent?: boolean;
|
|
1086
|
+
} | null>;
|
|
1091
1087
|
resumeSession(sessionId: string): Promise<SessionHostRecord | null>;
|
|
1092
1088
|
restartSession(sessionId: string): Promise<SessionHostRecord | null>;
|
|
1093
1089
|
sendSignal(sessionId: string, signal: string): Promise<SessionHostRecord | null>;
|
|
@@ -1126,4 +1122,4 @@ interface SessionHostControlTransport {
|
|
|
1126
1122
|
*/
|
|
1127
1123
|
declare function createSessionHostControlPlane(transport: SessionHostControlTransport): SessionHostControlPlane;
|
|
1128
1124
|
|
|
1129
|
-
export { type AcquireWritePayload, type AttachSessionPayload, CLI_CHILD_NICE_ENV, CLI_CHILD_NICE_INCREMENT, CLI_CHILD_SCHEDULING_ENV, type ClearSessionBufferPayload, type CreateSessionPayload, DEFAULT_CONFIG_DIR_NAME, DEFAULT_SESSION_RING_BUFFER_MAX_BYTES, type DetachSessionPayload, type ForceDetachClientPayload, type GetHostDiagnosticsPayload, type GetSnapshotPayload, type GetTerminalSnapshotPayload, type HostUpgradeLeasePayload, type MeshWriterAssignment, type MeshWriterStopTarget, type NiceLaunch,
|
|
1125
|
+
export { type AcquireWritePayload, type AttachSessionPayload, CLEANUP_AFTER_STOP_SIDE_EFFECT_PREFIX, CLI_CHILD_NICE_ENV, CLI_CHILD_NICE_INCREMENT, CLI_CHILD_SCHEDULING_ENV, type ClearSessionBufferPayload, type CreateSessionPayload, DEFAULT_CONFIG_DIR_NAME, DEFAULT_SESSION_RING_BUFFER_MAX_BYTES, type DeleteSessionIfExpectedPayload, type DetachSessionPayload, type ForceDetachClientPayload, type GetHostDiagnosticsPayload, type GetSnapshotPayload, type GetTerminalSnapshotPayload, type HostUpgradeLeasePayload, type MeshWriterAssignment, type MeshWriterStopTarget, type NiceLaunch, type PruneDuplicateSessionsPayload, type ReleaseWritePayload, type ResizeSessionPayload, type RestartSessionPayload, type ResumeSessionPayload, SESSION_HOST_SUPPORTED_REQUEST_TYPES, type SendInputPayload, type SendSignalPayload, type SessionAttachedClient, type SessionBufferSnapshot, type SessionCleanupExpectedAssignment, type SessionClientType, type SessionHostCategory, type SessionHostCensus, SessionHostClient, type SessionHostClientOptions, type SessionHostControlPlane, type SessionHostControlTransport, type SessionHostDiagnostics, type SessionHostDisconnectInfo, type SessionHostDisconnectReason, type SessionHostDuplicateSessionGroup, type SessionHostEndpoint, type SessionHostEndpointOptions, type SessionHostEvent, type SessionHostEventEnvelope, type SessionHostLogEntry, type SessionHostPruneDuplicatesResult, type SessionHostRecord, SessionHostRegistry, type SessionHostRequest, type SessionHostRequestEnvelope, type SessionHostRequestTrace, type SessionHostRequestType, type SessionHostResponse, type SessionHostResponseEnvelope, type SessionHostRuntimeTransition, type SessionHostSnapshot, type SessionHostSurfaceKind, type SessionHostSurfaceRecordLike, type SessionHostWireEnvelope, type SessionLaunchCommand, type SessionLifecycle, type SessionOwnerType, SessionRingBuffer, type SessionRingBufferOptions, type SessionTerminalSnapshot, type SessionTerminalState, type SessionTermination, type SessionTransport, type SessionWriteOwner, type StopMeshWriterPayload, type StopSessionIfExpectedPayload, type StopSessionPayload, type UpdateSessionMetaPayload, applyTerminalColorEnv, assertTestStorageIsolated, buildRuntimeDisplayName, buildRuntimeKey, canonicalizeInstancePath, classifyTermination, createCliChildPriorityPolicy, createLineParser, createResponseEnvelope, createSessionHostControlPlane, disconnectSessionHostClients, ensureNodePtySpawnHelperPermissions, findConnectedSessionHostClient, formatRuntimeOwner, getDefaultSessionHostEndpoint, getSessionHostRecoveryLabel, getSessionHostSurfaceKind, getWorkspaceLabel, hiddenSpawn as hiddenSpawnProcess, hostBootIdFromStartedAt, isDefaultInstanceConfigDir, isSessionHostLiveRuntime, isSessionHostRecoverySnapshot, isTerminalRecord, niceLaunch, partitionSessionHostDiagnosticsSessions, partitionSessionHostRecords, refuseCleanupExpectedDelete, refuseCleanupExpectedStop, replayLaunchEnv, resolveAttachableRuntimeRecord, resolveHostBootId, resolveInstanceConfigDir, resolveRuntimeRecord, resolveSessionHostIpcKey, sanitizeSpawnEnv, spawnCliChild, stripCleanupAfterStopSideEffect, tagCleanupAfterStopSideEffect, validateSessionHostEndpoint, writeEnvelope };
|