botmux 3.3.0 → 3.4.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/adapters/backend/sandbox.d.ts +47 -0
- package/dist/adapters/backend/sandbox.d.ts.map +1 -1
- package/dist/adapters/backend/sandbox.js +137 -0
- package/dist/adapters/backend/sandbox.js.map +1 -1
- package/dist/adapters/cli/read-isolation.d.ts +72 -3
- package/dist/adapters/cli/read-isolation.d.ts.map +1 -1
- package/dist/adapters/cli/read-isolation.js +143 -6
- package/dist/adapters/cli/read-isolation.js.map +1 -1
- package/dist/adapters/cli/registry.d.ts.map +1 -1
- package/dist/adapters/cli/registry.js +8 -2
- package/dist/adapters/cli/registry.js.map +1 -1
- package/dist/cli/pm2-command.d.ts.map +1 -1
- package/dist/cli/pm2-command.js +6 -0
- package/dist/cli/pm2-command.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +13 -0
- package/dist/cli.js.map +1 -1
- package/dist/core/dashboard-ipc-server.d.ts.map +1 -1
- package/dist/core/dashboard-ipc-server.js +21 -0
- package/dist/core/dashboard-ipc-server.js.map +1 -1
- package/dist/core/device-isolation-activation.d.ts +56 -0
- package/dist/core/device-isolation-activation.d.ts.map +1 -0
- package/dist/core/device-isolation-activation.js +110 -0
- package/dist/core/device-isolation-activation.js.map +1 -0
- package/dist/core/device-isolation-daemon.d.ts +84 -0
- package/dist/core/device-isolation-daemon.d.ts.map +1 -0
- package/dist/core/device-isolation-daemon.js +591 -0
- package/dist/core/device-isolation-daemon.js.map +1 -0
- package/dist/core/types.d.ts +9 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/core/worker-pool.d.ts.map +1 -1
- package/dist/core/worker-pool.js +35 -0
- package/dist/core/worker-pool.js.map +1 -1
- package/dist/daemon.d.ts.map +1 -1
- package/dist/daemon.js +5 -0
- package/dist/daemon.js.map +1 -1
- package/dist/desktop/main/auto-start.d.ts +2 -0
- package/dist/desktop/main/auto-start.d.ts.map +1 -1
- package/dist/desktop/main/auto-start.js +10 -6
- package/dist/desktop/main/auto-start.js.map +1 -1
- package/dist/desktop/main/bundled-runtime.d.ts +12 -0
- package/dist/desktop/main/bundled-runtime.d.ts.map +1 -0
- package/dist/desktop/main/bundled-runtime.js +30 -0
- package/dist/desktop/main/bundled-runtime.js.map +1 -0
- package/dist/desktop/main/device-status.d.ts +15 -0
- package/dist/desktop/main/device-status.d.ts.map +1 -0
- package/dist/desktop/main/device-status.js +94 -0
- package/dist/desktop/main/device-status.js.map +1 -0
- package/dist/desktop/main/external-runtime.d.ts +9 -0
- package/dist/desktop/main/external-runtime.d.ts.map +1 -1
- package/dist/desktop/main/external-runtime.js +88 -18
- package/dist/desktop/main/external-runtime.js.map +1 -1
- package/dist/desktop/main/ipc.d.ts.map +1 -1
- package/dist/desktop/main/ipc.js +1 -0
- package/dist/desktop/main/ipc.js.map +1 -1
- package/dist/desktop/main/node-command.d.ts +21 -0
- package/dist/desktop/main/node-command.d.ts.map +1 -1
- package/dist/desktop/main/node-command.js +41 -0
- package/dist/desktop/main/node-command.js.map +1 -1
- package/dist/desktop/main/pm2-apps.d.ts +4 -2
- package/dist/desktop/main/pm2-apps.d.ts.map +1 -1
- package/dist/desktop/main/pm2-apps.js +11 -3
- package/dist/desktop/main/pm2-apps.js.map +1 -1
- package/dist/desktop/main/runtime-service.d.ts +21 -5
- package/dist/desktop/main/runtime-service.d.ts.map +1 -1
- package/dist/desktop/main/runtime-service.js +94 -10
- package/dist/desktop/main/runtime-service.js.map +1 -1
- package/dist/desktop/main/runtime-source.d.ts +2 -0
- package/dist/desktop/main/runtime-source.d.ts.map +1 -1
- package/dist/desktop/main/runtime-source.js +12 -6
- package/dist/desktop/main/runtime-source.js.map +1 -1
- package/dist/desktop/main/tray.d.ts +1 -0
- package/dist/desktop/main/tray.d.ts.map +1 -1
- package/dist/desktop/main/tray.js +3 -3
- package/dist/desktop/main/tray.js.map +1 -1
- package/dist/desktop/main.js +28 -8
- package/dist/desktop/main.js.map +1 -1
- package/dist/desktop/preload.js +3 -0
- package/dist/desktop/preload.js.map +1 -1
- package/dist/desktop/renderer/app.d.ts +2 -1
- package/dist/desktop/renderer/app.d.ts.map +1 -1
- package/dist/desktop/renderer/app.js +6 -1
- package/dist/desktop/renderer/app.js.map +1 -1
- package/dist/desktop/renderer/runtime-state.d.ts.map +1 -1
- package/dist/desktop/renderer/runtime-state.js +2 -0
- package/dist/desktop/renderer/runtime-state.js.map +1 -1
- package/dist/desktop/shared/shell-path-probes.d.ts +24 -0
- package/dist/desktop/shared/shell-path-probes.d.ts.map +1 -0
- package/dist/desktop/shared/shell-path-probes.js +38 -0
- package/dist/desktop/shared/shell-path-probes.js.map +1 -0
- package/dist/desktop/shared/types.d.ts +21 -1
- package/dist/desktop/shared/types.d.ts.map +1 -1
- package/dist/desktop/smoke.d.ts +1 -0
- package/dist/desktop/smoke.d.ts.map +1 -1
- package/dist/desktop/smoke.js +20 -5
- package/dist/desktop/smoke.js.map +1 -1
- package/dist/platform/bind.d.ts +4 -1
- package/dist/platform/bind.d.ts.map +1 -1
- package/dist/platform/bind.js +10 -1
- package/dist/platform/bind.js.map +1 -1
- package/dist/platform/binding.d.ts.map +1 -1
- package/dist/platform/binding.js +15 -9
- package/dist/platform/binding.js.map +1 -1
- package/dist/platform/device-command.d.ts +35 -0
- package/dist/platform/device-command.d.ts.map +1 -0
- package/dist/platform/device-command.js +187 -0
- package/dist/platform/device-command.js.map +1 -0
- package/dist/platform/device-enroll.d.ts +156 -0
- package/dist/platform/device-enroll.d.ts.map +1 -0
- package/dist/platform/device-enroll.js +781 -0
- package/dist/platform/device-enroll.js.map +1 -0
- package/dist/platform/device-isolation-activation-client.d.ts +28 -0
- package/dist/platform/device-isolation-activation-client.d.ts.map +1 -0
- package/dist/platform/device-isolation-activation-client.js +279 -0
- package/dist/platform/device-isolation-activation-client.js.map +1 -0
- package/dist/platform/device-isolation.d.ts +35 -0
- package/dist/platform/device-isolation.d.ts.map +1 -0
- package/dist/platform/device-isolation.js +90 -0
- package/dist/platform/device-isolation.js.map +1 -0
- package/dist/platform/device-paths.d.ts +9 -0
- package/dist/platform/device-paths.d.ts.map +1 -0
- package/dist/platform/device-paths.js +14 -0
- package/dist/platform/device-paths.js.map +1 -0
- package/dist/platform/device.d.ts +77 -0
- package/dist/platform/device.d.ts.map +1 -0
- package/dist/platform/device.js +212 -0
- package/dist/platform/device.js.map +1 -0
- package/dist/platform/host-command-context.d.ts +15 -0
- package/dist/platform/host-command-context.d.ts.map +1 -0
- package/dist/platform/host-command-context.js +26 -0
- package/dist/platform/host-command-context.js.map +1 -0
- package/dist/platform/secure-host-file.d.ts +12 -0
- package/dist/platform/secure-host-file.d.ts.map +1 -0
- package/dist/platform/secure-host-file.js +182 -0
- package/dist/platform/secure-host-file.js.map +1 -0
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/atomic-write.d.ts +13 -0
- package/dist/utils/atomic-write.d.ts.map +1 -1
- package/dist/utils/atomic-write.js +89 -9
- package/dist/utils/atomic-write.js.map +1 -1
- package/dist/worker.js +289 -19
- package/dist/worker.js.map +1 -1
- package/dist/workflows/events/payloads.d.ts +4 -4
- package/dist/workflows/events/schema.d.ts +16 -16
- package/package.json +6 -3
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export declare const DEVICE_ISOLATION_ACTIVATION_VERSION: 1;
|
|
2
|
+
export declare const DEVICE_ISOLATION_FREEZE_LEASE_MS = 30000;
|
|
3
|
+
export interface DeviceIsolationFreezeLease {
|
|
4
|
+
activationVersion: typeof DEVICE_ISOLATION_ACTIVATION_VERSION;
|
|
5
|
+
leaseId: string;
|
|
6
|
+
nonce: string;
|
|
7
|
+
inventoryGeneration: string;
|
|
8
|
+
acquiredAt: number;
|
|
9
|
+
expiresAt: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function currentDeviceIsolationFreezeLease(now?: number): DeviceIsolationFreezeLease | null;
|
|
12
|
+
export type AcquireDeviceIsolationFreezeResult = {
|
|
13
|
+
ok: true;
|
|
14
|
+
lease: DeviceIsolationFreezeLease;
|
|
15
|
+
reused: boolean;
|
|
16
|
+
} | {
|
|
17
|
+
ok: false;
|
|
18
|
+
reason: 'busy';
|
|
19
|
+
};
|
|
20
|
+
export declare function acquireDeviceIsolationFreeze(input: {
|
|
21
|
+
nonce: string;
|
|
22
|
+
inventoryGeneration: string;
|
|
23
|
+
now?: number;
|
|
24
|
+
leaseMs?: number;
|
|
25
|
+
leaseIdFactory?: () => string;
|
|
26
|
+
}): AcquireDeviceIsolationFreezeResult;
|
|
27
|
+
export declare function requireDeviceIsolationFreeze(input: {
|
|
28
|
+
nonce: string;
|
|
29
|
+
leaseId: string;
|
|
30
|
+
now?: number;
|
|
31
|
+
}): DeviceIsolationFreezeLease | null;
|
|
32
|
+
/**
|
|
33
|
+
* Bind the post-freeze inventory to the lease. Prepare must acquire the spawn
|
|
34
|
+
* barrier before it looks at sessions; otherwise a worker can appear between
|
|
35
|
+
* inventory and freeze. Only the holder may replace the provisional value.
|
|
36
|
+
*/
|
|
37
|
+
export declare function bindDeviceIsolationFreezeInventoryGeneration(input: {
|
|
38
|
+
nonce: string;
|
|
39
|
+
leaseId: string;
|
|
40
|
+
inventoryGeneration: string;
|
|
41
|
+
now?: number;
|
|
42
|
+
}): DeviceIsolationFreezeLease | null;
|
|
43
|
+
export declare function releaseDeviceIsolationFreeze(input: {
|
|
44
|
+
nonce: string;
|
|
45
|
+
leaseId: string;
|
|
46
|
+
now?: number;
|
|
47
|
+
}): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Queue only the first spawn request for a logical session. Later turns are
|
|
50
|
+
* already retained by the session's normal pending-input machinery; replaying
|
|
51
|
+
* multiple fork requests would instead kill and replace the first new worker.
|
|
52
|
+
*/
|
|
53
|
+
export declare function deferWorkerSpawnDuringDeviceIsolation(sessionId: string, callback: () => void, now?: number): boolean;
|
|
54
|
+
/** Test-only reset; production callers release through the lease protocol. */
|
|
55
|
+
export declare function resetDeviceIsolationActivationForTest(): void;
|
|
56
|
+
//# sourceMappingURL=device-isolation-activation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-isolation-activation.d.ts","sourceRoot":"","sources":["../../src/core/device-isolation-activation.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,mCAAmC,EAAG,CAAU,CAAC;AAC9D,eAAO,MAAM,gCAAgC,QAAS,CAAC;AAEvD,MAAM,WAAW,0BAA0B;IACzC,iBAAiB,EAAE,OAAO,mCAAmC,CAAC;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,mBAAmB,EAAE,MAAM,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAyBD,wBAAgB,iCAAiC,CAC/C,GAAG,SAAa,GACf,0BAA0B,GAAG,IAAI,CAGnC;AAED,MAAM,MAAM,kCAAkC,GAC1C;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,0BAA0B,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAChE;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAElC,wBAAgB,4BAA4B,CAAC,KAAK,EAAE;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,mBAAmB,EAAE,MAAM,CAAC;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,MAAM,CAAC;CAC/B,GAAG,kCAAkC,CAuBrC;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GAAG,0BAA0B,GAAG,IAAI,CAMpC;AAED;;;;GAIG;AACH,wBAAgB,4CAA4C,CAAC,KAAK,EAAE;IAClE,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GAAG,0BAA0B,GAAG,IAAI,CAIpC;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAMV;AAED;;;;GAIG;AACH,wBAAgB,qCAAqC,CACnD,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,IAAI,EACpB,GAAG,SAAa,GACf,OAAO,CAIT;AAED,8EAA8E;AAC9E,wBAAgB,qCAAqC,IAAI,IAAI,CAI5D"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Short-lived daemon barrier used while a host enables device credentials.
|
|
3
|
+
*
|
|
4
|
+
* The barrier is deliberately process-local: the host CLI acquires one lease
|
|
5
|
+
* from every online botmux daemon before it writes the one-way marker. While a
|
|
6
|
+
* lease is held, forkWorker queues at most one cold spawn per logical session;
|
|
7
|
+
* existing workers are inventoried and torn down by the authenticated daemon
|
|
8
|
+
* IPC route. A bounded lease prevents a crashed host CLI from wedging a daemon
|
|
9
|
+
* forever. No device secret is written until every daemon has committed and
|
|
10
|
+
* released its lease.
|
|
11
|
+
*/
|
|
12
|
+
import { randomUUID } from 'node:crypto';
|
|
13
|
+
export const DEVICE_ISOLATION_ACTIVATION_VERSION = 1;
|
|
14
|
+
export const DEVICE_ISOLATION_FREEZE_LEASE_MS = 30_000;
|
|
15
|
+
let lease = null;
|
|
16
|
+
let expiryTimer = null;
|
|
17
|
+
const deferredSpawns = new Map();
|
|
18
|
+
function clearExpiryTimer() {
|
|
19
|
+
if (!expiryTimer)
|
|
20
|
+
return;
|
|
21
|
+
clearTimeout(expiryTimer);
|
|
22
|
+
expiryTimer = null;
|
|
23
|
+
}
|
|
24
|
+
function flushDeferredSpawns() {
|
|
25
|
+
const callbacks = [...deferredSpawns.values()];
|
|
26
|
+
deferredSpawns.clear();
|
|
27
|
+
for (const callback of callbacks)
|
|
28
|
+
setImmediate(callback);
|
|
29
|
+
}
|
|
30
|
+
function expireIfNeeded(now = Date.now()) {
|
|
31
|
+
if (!lease || lease.expiresAt > now)
|
|
32
|
+
return;
|
|
33
|
+
lease = null;
|
|
34
|
+
clearExpiryTimer();
|
|
35
|
+
flushDeferredSpawns();
|
|
36
|
+
}
|
|
37
|
+
export function currentDeviceIsolationFreezeLease(now = Date.now()) {
|
|
38
|
+
expireIfNeeded(now);
|
|
39
|
+
return lease ? { ...lease } : null;
|
|
40
|
+
}
|
|
41
|
+
export function acquireDeviceIsolationFreeze(input) {
|
|
42
|
+
const now = input.now ?? Date.now();
|
|
43
|
+
expireIfNeeded(now);
|
|
44
|
+
if (lease) {
|
|
45
|
+
if (lease.nonce !== input.nonce)
|
|
46
|
+
return { ok: false, reason: 'busy' };
|
|
47
|
+
return { ok: true, lease: { ...lease }, reused: true };
|
|
48
|
+
}
|
|
49
|
+
const leaseMs = input.leaseMs ?? DEVICE_ISOLATION_FREEZE_LEASE_MS;
|
|
50
|
+
if (!Number.isSafeInteger(leaseMs) || leaseMs < 1_000 || leaseMs > 120_000) {
|
|
51
|
+
throw new Error('invalid device-isolation freeze lease');
|
|
52
|
+
}
|
|
53
|
+
lease = {
|
|
54
|
+
activationVersion: DEVICE_ISOLATION_ACTIVATION_VERSION,
|
|
55
|
+
leaseId: (input.leaseIdFactory ?? randomUUID)(),
|
|
56
|
+
nonce: input.nonce,
|
|
57
|
+
inventoryGeneration: input.inventoryGeneration,
|
|
58
|
+
acquiredAt: now,
|
|
59
|
+
expiresAt: now + leaseMs,
|
|
60
|
+
};
|
|
61
|
+
clearExpiryTimer();
|
|
62
|
+
expiryTimer = setTimeout(() => expireIfNeeded(), leaseMs + 1);
|
|
63
|
+
expiryTimer.unref?.();
|
|
64
|
+
return { ok: true, lease: { ...lease }, reused: false };
|
|
65
|
+
}
|
|
66
|
+
export function requireDeviceIsolationFreeze(input) {
|
|
67
|
+
const current = currentDeviceIsolationFreezeLease(input.now);
|
|
68
|
+
if (!current || current.nonce !== input.nonce || current.leaseId !== input.leaseId) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
return current;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Bind the post-freeze inventory to the lease. Prepare must acquire the spawn
|
|
75
|
+
* barrier before it looks at sessions; otherwise a worker can appear between
|
|
76
|
+
* inventory and freeze. Only the holder may replace the provisional value.
|
|
77
|
+
*/
|
|
78
|
+
export function bindDeviceIsolationFreezeInventoryGeneration(input) {
|
|
79
|
+
if (!requireDeviceIsolationFreeze(input) || !lease)
|
|
80
|
+
return null;
|
|
81
|
+
lease.inventoryGeneration = input.inventoryGeneration;
|
|
82
|
+
return { ...lease };
|
|
83
|
+
}
|
|
84
|
+
export function releaseDeviceIsolationFreeze(input) {
|
|
85
|
+
if (!requireDeviceIsolationFreeze(input))
|
|
86
|
+
return false;
|
|
87
|
+
lease = null;
|
|
88
|
+
clearExpiryTimer();
|
|
89
|
+
flushDeferredSpawns();
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Queue only the first spawn request for a logical session. Later turns are
|
|
94
|
+
* already retained by the session's normal pending-input machinery; replaying
|
|
95
|
+
* multiple fork requests would instead kill and replace the first new worker.
|
|
96
|
+
*/
|
|
97
|
+
export function deferWorkerSpawnDuringDeviceIsolation(sessionId, callback, now = Date.now()) {
|
|
98
|
+
if (!currentDeviceIsolationFreezeLease(now))
|
|
99
|
+
return false;
|
|
100
|
+
if (!deferredSpawns.has(sessionId))
|
|
101
|
+
deferredSpawns.set(sessionId, callback);
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
/** Test-only reset; production callers release through the lease protocol. */
|
|
105
|
+
export function resetDeviceIsolationActivationForTest() {
|
|
106
|
+
lease = null;
|
|
107
|
+
clearExpiryTimer();
|
|
108
|
+
deferredSpawns.clear();
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=device-isolation-activation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-isolation-activation.js","sourceRoot":"","sources":["../../src/core/device-isolation-activation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAU,CAAC;AAC9D,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAM,CAAC;AAWvD,IAAI,KAAK,GAAsC,IAAI,CAAC;AACpD,IAAI,WAAW,GAA0B,IAAI,CAAC;AAC9C,MAAM,cAAc,GAAG,IAAI,GAAG,EAAsB,CAAC;AAErD,SAAS,gBAAgB;IACvB,IAAI,CAAC,WAAW;QAAE,OAAO;IACzB,YAAY,CAAC,WAAW,CAAC,CAAC;IAC1B,WAAW,GAAG,IAAI,CAAC;AACrB,CAAC;AAED,SAAS,mBAAmB;IAC1B,MAAM,SAAS,GAAG,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/C,cAAc,CAAC,KAAK,EAAE,CAAC;IACvB,KAAK,MAAM,QAAQ,IAAI,SAAS;QAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;AAC3D,CAAC;AAED,SAAS,cAAc,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE;IACtC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,SAAS,GAAG,GAAG;QAAE,OAAO;IAC5C,KAAK,GAAG,IAAI,CAAC;IACb,gBAAgB,EAAE,CAAC;IACnB,mBAAmB,EAAE,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,iCAAiC,CAC/C,GAAG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,CAAC,CAAC;IAC5E,OAAO,IAAI,CAAC;AACd,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,qCAAqC;IACnD,KAAK,GAAG,IAAI,CAAC;IACb,gBAAgB,EAAE,CAAC;IACnB,cAAc,CAAC,KAAK,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { BackendType, SessionProbe } from '../adapters/backend/types.js';
|
|
2
|
+
import type { DaemonSession } from './types.js';
|
|
3
|
+
export declare const DEVICE_ISOLATION_PREPARE_PATH = "/api/device-isolation/activation/prepare";
|
|
4
|
+
export declare const DEVICE_ISOLATION_COMMIT_PATH = "/api/device-isolation/activation/commit";
|
|
5
|
+
export declare const DEVICE_ISOLATION_RELEASE_PATH = "/api/device-isolation/activation/release";
|
|
6
|
+
type LocalPersistentBackend = 'tmux' | 'herdr' | 'zellij';
|
|
7
|
+
type InventoryBackend = BackendType | 'unknown';
|
|
8
|
+
type ProcessIdentity = {
|
|
9
|
+
pid: number;
|
|
10
|
+
procStart: string;
|
|
11
|
+
};
|
|
12
|
+
export type DeviceIsolationBlocker = 'adopted_session' | 'unknown_backend' | 'unattested_worker' | 'stale_attestation' | 'process_identity_unavailable' | 'backend_probe_unknown' | 'backend_inconsistent';
|
|
13
|
+
export interface DeviceIsolationRuntimeSession {
|
|
14
|
+
sessionId: string;
|
|
15
|
+
adopted: boolean;
|
|
16
|
+
/** Backend stamped by daemon-owned state, if this session predates no stamp. */
|
|
17
|
+
frozenBackend?: BackendType;
|
|
18
|
+
workerPresent: boolean;
|
|
19
|
+
workerGeneration?: number;
|
|
20
|
+
worker?: ProcessIdentity;
|
|
21
|
+
attestation?: {
|
|
22
|
+
backendType: BackendType;
|
|
23
|
+
credentialIsolated: boolean;
|
|
24
|
+
cli?: ProcessIdentity;
|
|
25
|
+
workerGeneration?: number;
|
|
26
|
+
};
|
|
27
|
+
/** Opaque production handle. It is deliberately excluded from generation. */
|
|
28
|
+
source?: DaemonSession;
|
|
29
|
+
}
|
|
30
|
+
export interface DeviceIsolationInventoryEntry {
|
|
31
|
+
sessionId: string;
|
|
32
|
+
backendType: InventoryBackend;
|
|
33
|
+
disposition: 'blocked' | 'owned_local' | 'safe_remote' | 'quiescent';
|
|
34
|
+
credentialIsolated?: boolean;
|
|
35
|
+
worker?: ProcessIdentity;
|
|
36
|
+
cli?: ProcessIdentity;
|
|
37
|
+
workerGeneration?: number;
|
|
38
|
+
persistent?: {
|
|
39
|
+
backendType: LocalPersistentBackend;
|
|
40
|
+
name: string;
|
|
41
|
+
probe: SessionProbe;
|
|
42
|
+
};
|
|
43
|
+
blocker?: DeviceIsolationBlocker;
|
|
44
|
+
}
|
|
45
|
+
export interface DeviceIsolationInventory {
|
|
46
|
+
generation: string;
|
|
47
|
+
entries: DeviceIsolationInventoryEntry[];
|
|
48
|
+
blockers: Array<{
|
|
49
|
+
sessionId: string;
|
|
50
|
+
blocker: DeviceIsolationBlocker;
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
53
|
+
export interface DeviceIsolationDaemonIdentity {
|
|
54
|
+
larkAppId: string;
|
|
55
|
+
bootInstanceId: string;
|
|
56
|
+
}
|
|
57
|
+
export interface DeviceIsolationDaemonDependencies {
|
|
58
|
+
now: () => number;
|
|
59
|
+
listSessions: () => DeviceIsolationRuntimeSession[];
|
|
60
|
+
processStart: (pid: number) => string | undefined;
|
|
61
|
+
processExists: (pid: number) => boolean;
|
|
62
|
+
signalProcess: (pid: number, signal: NodeJS.Signals) => void;
|
|
63
|
+
probePersistent: (backendType: LocalPersistentBackend, name: string) => SessionProbe;
|
|
64
|
+
killPersistent: (backendType: LocalPersistentBackend, name: string) => void;
|
|
65
|
+
closeWorker: (session: DeviceIsolationRuntimeSession) => void;
|
|
66
|
+
readMarker: () => string | null;
|
|
67
|
+
sleep: (ms: number) => Promise<void>;
|
|
68
|
+
dataDir: () => string;
|
|
69
|
+
}
|
|
70
|
+
export type DeviceIsolationDaemonResult = {
|
|
71
|
+
status: 200 | 409 | 423 | 503;
|
|
72
|
+
body: Record<string, unknown>;
|
|
73
|
+
};
|
|
74
|
+
export declare function buildDeviceIsolationInventory(): DeviceIsolationInventory;
|
|
75
|
+
export declare function setDeviceIsolationDaemonIdentity(identity: DeviceIsolationDaemonIdentity | null): void;
|
|
76
|
+
export declare function prepareDeviceIsolationActivation(body: unknown): DeviceIsolationDaemonResult;
|
|
77
|
+
export declare function commitDeviceIsolationActivation(body: unknown): Promise<DeviceIsolationDaemonResult>;
|
|
78
|
+
export declare function releaseDeviceIsolationActivation(body: unknown): DeviceIsolationDaemonResult;
|
|
79
|
+
/** Test seams keep process and backend destruction out of unit tests. */
|
|
80
|
+
export declare function setDeviceIsolationDaemonDependenciesForTest(overrides: Partial<DeviceIsolationDaemonDependencies> | null): void;
|
|
81
|
+
export declare function resetDeviceIsolationDaemonForTest(): void;
|
|
82
|
+
export declare function logDeviceIsolationActivationError(error: unknown): void;
|
|
83
|
+
export {};
|
|
84
|
+
//# sourceMappingURL=device-isolation-daemon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-isolation-daemon.d.ts","sourceRoot":"","sources":["../../src/core/device-isolation-daemon.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAmB9E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,eAAO,MAAM,6BAA6B,6CAA6C,CAAC;AACxF,eAAO,MAAM,4BAA4B,4CAA4C,CAAC;AACtF,eAAO,MAAM,6BAA6B,6CAA6C,CAAC;AAExF,KAAK,sBAAsB,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAC1D,KAAK,gBAAgB,GAAG,WAAW,GAAG,SAAS,CAAC;AAChD,KAAK,eAAe,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1D,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