@lightcone-ai/daemon 0.14.16 → 0.14.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,51 @@
1
+ export function resolveExitOfflineDetail({ code, signal, stopCause }) {
2
+ if (stopCause === 'manual_stop') return '';
3
+ if (stopCause === 'credential_revoked') return 'credential_revoked';
4
+ if (code === 0) return '';
5
+ if (signal === 'SIGTERM') return '';
6
+ if (signal === 'SIGKILL') return 'agent_timeout';
7
+ return 'spawn_session_crashed';
8
+ }
9
+
10
+ export function resolveLifecycleExitState({ runtime, code, signal, stopCause }) {
11
+ const normalizedRuntime = String(runtime ?? '').trim().toLowerCase() || 'claude';
12
+ if (stopCause === 'credential_revoked') {
13
+ return {
14
+ reachability: 'reachable',
15
+ availability: 'paused',
16
+ runtimeState: 'stopped',
17
+ reason: 'credential_revoked',
18
+ };
19
+ }
20
+ if (stopCause === 'manual_stop') {
21
+ return {
22
+ reachability: 'reachable',
23
+ availability: 'paused',
24
+ runtimeState: 'stopped',
25
+ reason: 'manual_stop',
26
+ };
27
+ }
28
+ if (normalizedRuntime === 'codex' && code === 0) {
29
+ return {
30
+ reachability: 'reachable',
31
+ availability: 'available',
32
+ runtimeState: 'standby',
33
+ reason: 'normal_exit',
34
+ };
35
+ }
36
+ const offlineDetail = resolveExitOfflineDetail({ code, signal, stopCause });
37
+ if (!offlineDetail) {
38
+ return {
39
+ reachability: 'reachable',
40
+ availability: 'available',
41
+ runtimeState: 'stopped',
42
+ reason: signal === 'SIGTERM' ? 'terminated' : 'stopped',
43
+ };
44
+ }
45
+ return {
46
+ reachability: 'reachable',
47
+ availability: 'unreachable',
48
+ runtimeState: 'crashed',
49
+ reason: offlineDetail,
50
+ };
51
+ }