byterover-cli 1.0.5 → 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/README.md +12 -10
- package/dist/commands/hook-prompt-submit.d.ts +27 -0
- package/dist/commands/hook-prompt-submit.js +39 -0
- package/dist/commands/status.js +8 -3
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/core/domain/cipher/tools/constants.d.ts +1 -0
- package/dist/core/domain/cipher/tools/constants.js +1 -0
- package/dist/core/domain/entities/agent.d.ts +16 -0
- package/dist/core/domain/entities/agent.js +24 -0
- package/dist/core/domain/entities/connector-type.d.ts +9 -0
- package/dist/core/domain/entities/connector-type.js +8 -0
- package/dist/core/domain/entities/event.d.ts +1 -1
- package/dist/core/domain/entities/event.js +2 -0
- package/dist/core/domain/errors/task-error.d.ts +4 -0
- package/dist/core/domain/errors/task-error.js +7 -0
- package/dist/core/domain/transport/schemas.d.ts +40 -0
- package/dist/core/domain/transport/schemas.js +28 -0
- package/dist/core/interfaces/connectors/connector-types.d.ts +57 -0
- package/dist/core/interfaces/connectors/i-connector-manager.d.ts +72 -0
- package/dist/core/interfaces/connectors/i-connector-manager.js +1 -0
- package/dist/core/interfaces/connectors/i-connector.d.ts +54 -0
- package/dist/core/interfaces/connectors/i-connector.js +1 -0
- package/dist/core/interfaces/i-file-service.d.ts +7 -0
- package/dist/core/interfaces/usecase/i-connectors-use-case.d.ts +3 -0
- package/dist/core/interfaces/usecase/i-connectors-use-case.js +1 -0
- package/dist/hooks/init/update-notifier.d.ts +1 -0
- package/dist/hooks/init/update-notifier.js +10 -1
- package/dist/infra/cipher/file-system/binary-utils.d.ts +7 -12
- package/dist/infra/cipher/file-system/binary-utils.js +46 -31
- package/dist/infra/cipher/llm/context/context-manager.d.ts +2 -2
- package/dist/infra/cipher/llm/context/context-manager.js +23 -2
- package/dist/infra/cipher/llm/formatters/gemini-formatter.js +48 -9
- package/dist/infra/cipher/llm/internal-llm-service.js +2 -2
- package/dist/infra/cipher/system-prompt/contributors/context-tree-structure-contributor.d.ts +6 -7
- package/dist/infra/cipher/system-prompt/contributors/context-tree-structure-contributor.js +57 -18
- package/dist/infra/cipher/tools/implementations/curate-tool.js +20 -2
- package/dist/infra/cipher/tools/implementations/read-file-tool.js +38 -17
- package/dist/infra/cipher/tools/implementations/search-knowledge-tool.d.ts +7 -0
- package/dist/infra/cipher/tools/implementations/search-knowledge-tool.js +303 -0
- package/dist/infra/cipher/tools/index.d.ts +1 -0
- package/dist/infra/cipher/tools/index.js +1 -0
- package/dist/infra/cipher/tools/tool-manager.js +1 -0
- package/dist/infra/cipher/tools/tool-registry.js +7 -0
- package/dist/infra/connectors/connector-manager.d.ts +32 -0
- package/dist/infra/connectors/connector-manager.js +156 -0
- package/dist/infra/connectors/hook/hook-connector-config.d.ts +52 -0
- package/dist/infra/connectors/hook/hook-connector-config.js +41 -0
- package/dist/infra/connectors/hook/hook-connector.d.ts +46 -0
- package/dist/infra/connectors/hook/hook-connector.js +231 -0
- package/dist/infra/{rule → connectors/rules}/legacy-rule-detector.d.ts +2 -2
- package/dist/infra/{rule → connectors/rules}/legacy-rule-detector.js +1 -1
- package/dist/infra/connectors/rules/rules-connector-config.d.ts +95 -0
- package/dist/infra/{rule/agent-rule-config.js → connectors/rules/rules-connector-config.js} +10 -10
- package/dist/infra/connectors/rules/rules-connector.d.ts +41 -0
- package/dist/infra/connectors/rules/rules-connector.js +204 -0
- package/dist/infra/{rule/rule-template-service.d.ts → connectors/shared/template-service.d.ts} +3 -3
- package/dist/infra/{rule/rule-template-service.js → connectors/shared/template-service.js} +1 -1
- package/dist/infra/context-tree/file-context-tree-writer-service.d.ts +5 -2
- package/dist/infra/context-tree/file-context-tree-writer-service.js +20 -5
- package/dist/infra/core/executors/curate-executor.d.ts +2 -2
- package/dist/infra/core/executors/curate-executor.js +7 -7
- package/dist/infra/core/executors/query-executor.d.ts +12 -0
- package/dist/infra/core/executors/query-executor.js +62 -1
- package/dist/infra/file/fs-file-service.d.ts +7 -0
- package/dist/infra/file/fs-file-service.js +15 -1
- package/dist/infra/process/agent-worker.d.ts +2 -2
- package/dist/infra/process/agent-worker.js +626 -142
- package/dist/infra/process/constants.d.ts +1 -1
- package/dist/infra/process/constants.js +1 -1
- package/dist/infra/process/ipc-types.d.ts +17 -4
- package/dist/infra/process/ipc-types.js +3 -3
- package/dist/infra/process/parent-heartbeat.d.ts +47 -0
- package/dist/infra/process/parent-heartbeat.js +118 -0
- package/dist/infra/process/process-manager.d.ts +79 -0
- package/dist/infra/process/process-manager.js +277 -3
- package/dist/infra/process/task-queue-manager.d.ts +13 -0
- package/dist/infra/process/task-queue-manager.js +19 -0
- package/dist/infra/process/transport-handlers.d.ts +3 -0
- package/dist/infra/process/transport-handlers.js +51 -5
- package/dist/infra/process/transport-worker.js +9 -69
- package/dist/infra/repl/commands/connectors-command.d.ts +8 -0
- package/dist/infra/repl/commands/{gen-rules-command.js → connectors-command.js} +21 -10
- package/dist/infra/repl/commands/index.js +3 -2
- package/dist/infra/repl/commands/init-command.js +11 -7
- package/dist/infra/repl/commands/query-command.js +22 -2
- package/dist/infra/repl/commands/reset-command.js +1 -1
- package/dist/infra/transport/socket-io-transport-client.d.ts +68 -0
- package/dist/infra/transport/socket-io-transport-client.js +283 -7
- package/dist/infra/usecase/connectors-use-case.d.ts +59 -0
- package/dist/infra/usecase/connectors-use-case.js +203 -0
- package/dist/infra/usecase/init-use-case.d.ts +8 -43
- package/dist/infra/usecase/init-use-case.js +27 -251
- package/dist/infra/usecase/logout-use-case.js +1 -1
- package/dist/infra/usecase/pull-use-case.js +5 -5
- package/dist/infra/usecase/push-use-case.js +4 -4
- package/dist/infra/usecase/reset-use-case.js +3 -4
- package/dist/infra/usecase/space-list-use-case.js +3 -3
- package/dist/infra/usecase/space-switch-use-case.js +3 -3
- package/dist/resources/prompts/curate.yml +7 -0
- package/dist/resources/prompts/explore.yml +34 -0
- package/dist/resources/prompts/query-orchestrator.yml +112 -0
- package/dist/resources/prompts/system-prompt.yml +12 -2
- package/dist/resources/tools/search_knowledge.txt +32 -0
- package/dist/templates/sections/brv-instructions.md +98 -0
- package/dist/tui/components/onboarding/onboarding-flow.js +14 -11
- package/dist/tui/components/onboarding/welcome-box.js +1 -1
- package/dist/tui/contexts/onboarding-context.d.ts +4 -0
- package/dist/tui/contexts/onboarding-context.js +14 -2
- package/dist/tui/views/command-view.js +4 -0
- package/dist/utils/file-validator.d.ts +1 -1
- package/dist/utils/file-validator.js +25 -28
- package/dist/utils/type-guards.d.ts +5 -0
- package/dist/utils/type-guards.js +7 -0
- package/oclif.manifest.json +30 -4
- package/package.json +4 -1
- package/dist/core/interfaces/usecase/i-generate-rules-use-case.d.ts +0 -3
- package/dist/infra/repl/commands/gen-rules-command.d.ts +0 -7
- package/dist/infra/rule/agent-rule-config.d.ts +0 -19
- package/dist/infra/usecase/generate-rules-use-case.d.ts +0 -61
- package/dist/infra/usecase/generate-rules-use-case.js +0 -285
- /package/dist/core/interfaces/{usecase/i-generate-rules-use-case.js → connectors/connector-types.js} +0 -0
- /package/dist/infra/{rule → connectors/shared}/constants.d.ts +0 -0
- /package/dist/infra/{rule → connectors/shared}/constants.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const CURATE_MAX_CONCURRENT =
|
|
1
|
+
export declare const CURATE_MAX_CONCURRENT = 3;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CURATE_MAX_CONCURRENT =
|
|
1
|
+
export const CURATE_MAX_CONCURRENT = 3;
|
|
@@ -2,17 +2,22 @@
|
|
|
2
2
|
* IPC Types - Shared types for Node.js IPC between parent and child processes.
|
|
3
3
|
*
|
|
4
4
|
* Architecture v0.5.0:
|
|
5
|
-
* - IPC is used ONLY for process lifecycle (ready, ping/pong, shutdown, error)
|
|
5
|
+
* - IPC is used ONLY for process lifecycle (ready, ping/pong, shutdown, error, health-check)
|
|
6
6
|
* - Task communication uses Socket.IO (NOT IPC)
|
|
7
7
|
*
|
|
8
8
|
* Message flows:
|
|
9
|
-
* - Parent → Child: IPCCommand (ping, shutdown)
|
|
10
|
-
* - Child → Parent: IPCResponse variants (ready, pong, stopped, error)
|
|
9
|
+
* - Parent → Child: IPCCommand (ping, shutdown, health-check)
|
|
10
|
+
* - Child → Parent: IPCResponse variants (ready, pong, stopped, error, health-check-result)
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
13
|
* Commands sent from parent (ProcessManager) to child processes.
|
|
14
|
+
* - ping: Heartbeat check
|
|
15
|
+
* - shutdown: Graceful shutdown request
|
|
16
|
+
* - health-check: Fix #3 - Verify connection health after sleep/wake
|
|
14
17
|
*/
|
|
15
18
|
export type IPCCommand = {
|
|
19
|
+
type: 'health-check';
|
|
20
|
+
} | {
|
|
16
21
|
type: 'ping';
|
|
17
22
|
} | {
|
|
18
23
|
type: 'shutdown';
|
|
@@ -30,6 +35,14 @@ export type IPCErrorResponse = {
|
|
|
30
35
|
error: string;
|
|
31
36
|
type: 'error';
|
|
32
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* Health-check result response (agent-only).
|
|
40
|
+
* Sent after health-check command to inform ProcessManager of connection status.
|
|
41
|
+
*/
|
|
42
|
+
export type IPCHealthCheckResultResponse = {
|
|
43
|
+
success: boolean;
|
|
44
|
+
type: 'health-check-result';
|
|
45
|
+
};
|
|
33
46
|
/**
|
|
34
47
|
* Ready response variants.
|
|
35
48
|
* - Transport: includes port number
|
|
@@ -46,7 +59,7 @@ export type IPCReadyWithPortResponse = {
|
|
|
46
59
|
* Composite response types for each process type.
|
|
47
60
|
*/
|
|
48
61
|
export type TransportIPCResponse = IPCErrorResponse | IPCPongResponse | IPCReadyWithPortResponse | IPCStoppedResponse;
|
|
49
|
-
export type AgentIPCResponse = IPCErrorResponse | IPCPongResponse | IPCReadyResponse | IPCStoppedResponse;
|
|
62
|
+
export type AgentIPCResponse = IPCErrorResponse | IPCHealthCheckResultResponse | IPCPongResponse | IPCReadyResponse | IPCStoppedResponse;
|
|
50
63
|
/**
|
|
51
64
|
* Legacy aliases for gradual migration.
|
|
52
65
|
* @deprecated Use IPCCommand instead
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* IPC Types - Shared types for Node.js IPC between parent and child processes.
|
|
3
3
|
*
|
|
4
4
|
* Architecture v0.5.0:
|
|
5
|
-
* - IPC is used ONLY for process lifecycle (ready, ping/pong, shutdown, error)
|
|
5
|
+
* - IPC is used ONLY for process lifecycle (ready, ping/pong, shutdown, error, health-check)
|
|
6
6
|
* - Task communication uses Socket.IO (NOT IPC)
|
|
7
7
|
*
|
|
8
8
|
* Message flows:
|
|
9
|
-
* - Parent → Child: IPCCommand (ping, shutdown)
|
|
10
|
-
* - Child → Parent: IPCResponse variants (ready, pong, stopped, error)
|
|
9
|
+
* - Parent → Child: IPCCommand (ping, shutdown, health-check)
|
|
10
|
+
* - Child → Parent: IPCResponse variants (ready, pong, stopped, error, health-check-result)
|
|
11
11
|
*/
|
|
12
12
|
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parent Heartbeat Monitoring - Shared utility for worker processes.
|
|
3
|
+
*
|
|
4
|
+
* Why this is needed:
|
|
5
|
+
* - When main process receives SIGKILL, it dies immediately
|
|
6
|
+
* - SIGKILL cannot be caught, so no cleanup happens
|
|
7
|
+
* - IPC 'disconnect' event may not fire
|
|
8
|
+
* - Child processes become orphans (PPID = 1)
|
|
9
|
+
*
|
|
10
|
+
* This module provides a reusable heartbeat monitor that:
|
|
11
|
+
* - Periodically checks if parent is still alive using signal 0
|
|
12
|
+
* - Self-terminates the child process if parent dies
|
|
13
|
+
* - Uses recursive setTimeout pattern (safer than setInterval)
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Configuration for the parent heartbeat monitor.
|
|
17
|
+
*/
|
|
18
|
+
export interface ParentHeartbeatConfig {
|
|
19
|
+
/** Async cleanup function to call before exit */
|
|
20
|
+
cleanup: () => Promise<void>;
|
|
21
|
+
/** Function to log messages */
|
|
22
|
+
log: (message: string) => void;
|
|
23
|
+
/** Optional pre-cleanup function (e.g., stopInstancePolling) */
|
|
24
|
+
preCleanup?: () => void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Creates a parent heartbeat monitor.
|
|
28
|
+
*
|
|
29
|
+
* @param config - Configuration for the monitor
|
|
30
|
+
* @returns Object with start() and stop() methods
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const heartbeat = createParentHeartbeat({
|
|
35
|
+
* log: agentLog,
|
|
36
|
+
* cleanup: stopAgent,
|
|
37
|
+
* })
|
|
38
|
+
*
|
|
39
|
+
* heartbeat.start()
|
|
40
|
+
* // Later...
|
|
41
|
+
* heartbeat.stop()
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function createParentHeartbeat(config: ParentHeartbeatConfig): {
|
|
45
|
+
start: () => void;
|
|
46
|
+
stop: () => void;
|
|
47
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parent Heartbeat Monitoring - Shared utility for worker processes.
|
|
3
|
+
*
|
|
4
|
+
* Why this is needed:
|
|
5
|
+
* - When main process receives SIGKILL, it dies immediately
|
|
6
|
+
* - SIGKILL cannot be caught, so no cleanup happens
|
|
7
|
+
* - IPC 'disconnect' event may not fire
|
|
8
|
+
* - Child processes become orphans (PPID = 1)
|
|
9
|
+
*
|
|
10
|
+
* This module provides a reusable heartbeat monitor that:
|
|
11
|
+
* - Periodically checks if parent is still alive using signal 0
|
|
12
|
+
* - Self-terminates the child process if parent dies
|
|
13
|
+
* - Uses recursive setTimeout pattern (safer than setInterval)
|
|
14
|
+
*/
|
|
15
|
+
/** Parent heartbeat check interval in milliseconds */
|
|
16
|
+
const PARENT_HEARTBEAT_INTERVAL_MS = 2000;
|
|
17
|
+
/**
|
|
18
|
+
* Type guard for NodeJS.ErrnoException.
|
|
19
|
+
* Used to safely access error.code without unsafe type assertions.
|
|
20
|
+
*/
|
|
21
|
+
function isNodeError(error) {
|
|
22
|
+
return error !== null && typeof error === 'object' && 'code' in error;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates a parent heartbeat monitor.
|
|
26
|
+
*
|
|
27
|
+
* @param config - Configuration for the monitor
|
|
28
|
+
* @returns Object with start() and stop() methods
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const heartbeat = createParentHeartbeat({
|
|
33
|
+
* log: agentLog,
|
|
34
|
+
* cleanup: stopAgent,
|
|
35
|
+
* })
|
|
36
|
+
*
|
|
37
|
+
* heartbeat.start()
|
|
38
|
+
* // Later...
|
|
39
|
+
* heartbeat.stop()
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export function createParentHeartbeat(config) {
|
|
43
|
+
const state = {
|
|
44
|
+
isRunning: false,
|
|
45
|
+
parentPid: undefined,
|
|
46
|
+
};
|
|
47
|
+
const { cleanup, log, preCleanup } = config;
|
|
48
|
+
/**
|
|
49
|
+
* Check if parent is alive and schedule next check.
|
|
50
|
+
* Uses recursive setTimeout pattern:
|
|
51
|
+
* - No callback overlap possible
|
|
52
|
+
* - Clean cancellation (just set isRunning = false)
|
|
53
|
+
* - No orphan timers
|
|
54
|
+
*/
|
|
55
|
+
const checkParent = () => {
|
|
56
|
+
// Stopped - don't schedule next check
|
|
57
|
+
if (!state.isRunning || !state.parentPid)
|
|
58
|
+
return;
|
|
59
|
+
// Check if parent is still alive using signal 0
|
|
60
|
+
// Signal 0 doesn't send any signal, just checks if process exists
|
|
61
|
+
try {
|
|
62
|
+
process.kill(state.parentPid, 0);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
// Only exit on ESRCH (No such process) - parent is genuinely dead
|
|
66
|
+
// EPERM (Operation not permitted) means parent exists but different privileges
|
|
67
|
+
const code = isNodeError(error) ? error.code : undefined;
|
|
68
|
+
if (code !== 'ESRCH') {
|
|
69
|
+
log(`Parent check failed with ${code ?? 'unknown'} (not ESRCH) - continuing`);
|
|
70
|
+
// Schedule next check (don't exit)
|
|
71
|
+
if (state.isRunning) {
|
|
72
|
+
setTimeout(checkParent, PARENT_HEARTBEAT_INTERVAL_MS);
|
|
73
|
+
}
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
// Parent is dead (ESRCH) - self-terminate
|
|
77
|
+
log(`Parent process (${state.parentPid}) died - shutting down to prevent zombie`);
|
|
78
|
+
state.isRunning = false;
|
|
79
|
+
// Run pre-cleanup if provided
|
|
80
|
+
preCleanup?.();
|
|
81
|
+
// Cleanup and exit
|
|
82
|
+
cleanup()
|
|
83
|
+
.catch(() => { })
|
|
84
|
+
.finally(() => {
|
|
85
|
+
// eslint-disable-next-line n/no-process-exit, unicorn/no-process-exit
|
|
86
|
+
process.exit(0);
|
|
87
|
+
});
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
// Schedule next check (only if still running)
|
|
91
|
+
if (state.isRunning) {
|
|
92
|
+
setTimeout(checkParent, PARENT_HEARTBEAT_INTERVAL_MS);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
return {
|
|
96
|
+
/**
|
|
97
|
+
* Start the parent heartbeat monitoring.
|
|
98
|
+
* Safe to call multiple times - only starts once.
|
|
99
|
+
*/
|
|
100
|
+
start() {
|
|
101
|
+
// Already running - don't start another
|
|
102
|
+
if (state.isRunning)
|
|
103
|
+
return;
|
|
104
|
+
state.isRunning = true;
|
|
105
|
+
state.parentPid = process.ppid;
|
|
106
|
+
// Start first check after delay
|
|
107
|
+
setTimeout(checkParent, PARENT_HEARTBEAT_INTERVAL_MS);
|
|
108
|
+
log(`Parent heartbeat monitoring started (PPID: ${state.parentPid})`);
|
|
109
|
+
},
|
|
110
|
+
/**
|
|
111
|
+
* Stop the parent heartbeat monitoring.
|
|
112
|
+
* With recursive setTimeout, just set flag to false - next check won't schedule.
|
|
113
|
+
*/
|
|
114
|
+
stop() {
|
|
115
|
+
state.isRunning = false;
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
@@ -64,12 +64,30 @@ export type ProcessStartOptions = {
|
|
|
64
64
|
* - Crash recovery: respawn on exit
|
|
65
65
|
*/
|
|
66
66
|
export declare class ProcessManager {
|
|
67
|
+
/** Whether an Agent health-check is pending response */
|
|
68
|
+
private agentHealthCheckPending;
|
|
69
|
+
/** Timeout for Agent health-check response */
|
|
70
|
+
private agentHealthCheckTimeout?;
|
|
67
71
|
private currentSessionId?;
|
|
68
72
|
private healthCheckInterval?;
|
|
73
|
+
/** Guard to prevent concurrent Agent restarts */
|
|
74
|
+
private isRestartingAgent;
|
|
75
|
+
/** Guard to prevent concurrent Transport restarts */
|
|
76
|
+
private isRestartingTransport;
|
|
69
77
|
private lastHealthCheckTime;
|
|
78
|
+
/** Periodic health check interval (30s) */
|
|
79
|
+
private periodicHealthCheckInterval?;
|
|
80
|
+
/** Stored handler ref for idempotent listener setup (prevents accumulation on respawn) */
|
|
81
|
+
private runtimeMessageHandler?;
|
|
70
82
|
private readonly shutdownTimeoutMs;
|
|
71
83
|
private readonly startupTimeoutMs;
|
|
72
84
|
private state;
|
|
85
|
+
/** Stored handler ref for Transport runtime messages (prevents accumulation on respawn) */
|
|
86
|
+
private transportMessageHandler?;
|
|
87
|
+
/** Whether a Transport ping is pending response */
|
|
88
|
+
private transportPingPending;
|
|
89
|
+
/** Timeout for Transport ping response */
|
|
90
|
+
private transportPingTimeout?;
|
|
73
91
|
constructor(config?: ProcessManagerConfig);
|
|
74
92
|
/**
|
|
75
93
|
* Get current state.
|
|
@@ -109,11 +127,46 @@ export declare class ProcessManager {
|
|
|
109
127
|
* In dev mode (tsx), import.meta.url points to src/ but workers need compiled .js from dist/
|
|
110
128
|
*/
|
|
111
129
|
private getWorkerDir;
|
|
130
|
+
/**
|
|
131
|
+
* Handle runtime IPC messages from Agent process.
|
|
132
|
+
* Called by the message event handler set up in setupAgentRuntimeHandlers.
|
|
133
|
+
*/
|
|
134
|
+
private handleAgentRuntimeMessage;
|
|
112
135
|
/**
|
|
113
136
|
* Handle system wake from sleep.
|
|
114
137
|
* Verify processes are still alive and restart if needed.
|
|
138
|
+
* Triggers immediate health checks on both Transport and Agent.
|
|
115
139
|
*/
|
|
116
140
|
private handleSystemWake;
|
|
141
|
+
/**
|
|
142
|
+
* Handle runtime IPC messages from Transport process.
|
|
143
|
+
* Called by the message event handler set up in setupTransportRuntimeHandlers.
|
|
144
|
+
*/
|
|
145
|
+
private handleTransportRuntimeMessage;
|
|
146
|
+
/**
|
|
147
|
+
* Send health-check to Agent with timeout.
|
|
148
|
+
* If no response within timeout, Agent is considered stuck and restarted.
|
|
149
|
+
* Used by periodic health check and after system wake.
|
|
150
|
+
*/
|
|
151
|
+
private healthCheckAgentWithTimeout;
|
|
152
|
+
/**
|
|
153
|
+
* Send ping to Transport with timeout.
|
|
154
|
+
* If no pong received within timeout, Transport is considered zombie and restarted.
|
|
155
|
+
*/
|
|
156
|
+
private pingTransportWithTimeout;
|
|
157
|
+
/**
|
|
158
|
+
* Restart Agent process gracefully.
|
|
159
|
+
* Used when health-check fails after sleep/wake or periodic check.
|
|
160
|
+
* Guarded to prevent concurrent restart race conditions.
|
|
161
|
+
*/
|
|
162
|
+
private restartAgent;
|
|
163
|
+
/**
|
|
164
|
+
* Restart Transport process gracefully.
|
|
165
|
+
* Used when ping timeout detects zombie process after sleep/wake or periodic check.
|
|
166
|
+
* Note: Agent must also be restarted since Transport port changes.
|
|
167
|
+
* Guarded to prevent concurrent restart race conditions.
|
|
168
|
+
*/
|
|
169
|
+
private restartTransport;
|
|
117
170
|
/**
|
|
118
171
|
* Send IPC message to child process.
|
|
119
172
|
*/
|
|
@@ -122,10 +175,26 @@ export declare class ProcessManager {
|
|
|
122
175
|
* Setup Agent crash recovery.
|
|
123
176
|
*/
|
|
124
177
|
private setupAgentCrashRecovery;
|
|
178
|
+
/**
|
|
179
|
+
* Setup runtime message handlers for Agent process.
|
|
180
|
+
* Handles IPC messages that arrive during normal operation (not just startup).
|
|
181
|
+
*
|
|
182
|
+
* IMPORTANT: Uses stored handler reference to prevent listener accumulation.
|
|
183
|
+
* Each respawn calls this method, so we must remove the old listener first.
|
|
184
|
+
*/
|
|
185
|
+
private setupAgentRuntimeHandlers;
|
|
125
186
|
/**
|
|
126
187
|
* Setup Transport crash recovery.
|
|
127
188
|
*/
|
|
128
189
|
private setupTransportCrashRecovery;
|
|
190
|
+
/**
|
|
191
|
+
* Setup runtime message handlers for Transport process.
|
|
192
|
+
* Handles IPC messages that arrive during normal operation (pong for health check).
|
|
193
|
+
*
|
|
194
|
+
* IMPORTANT: Uses stored handler reference to prevent listener accumulation.
|
|
195
|
+
* Each respawn calls this method, so we must remove the old listener first.
|
|
196
|
+
*/
|
|
197
|
+
private setupTransportRuntimeHandlers;
|
|
129
198
|
/**
|
|
130
199
|
* Start Agent Process.
|
|
131
200
|
*/
|
|
@@ -135,6 +204,11 @@ export declare class ProcessManager {
|
|
|
135
204
|
* Detects system sleep by monitoring for large time gaps between checks.
|
|
136
205
|
*/
|
|
137
206
|
private startHealthCheck;
|
|
207
|
+
/**
|
|
208
|
+
* Start periodic health check for Transport and Agent.
|
|
209
|
+
* Runs every 30s to detect zombie processes mid-session (not just after wake).
|
|
210
|
+
*/
|
|
211
|
+
private startPeriodicHealthCheck;
|
|
138
212
|
/**
|
|
139
213
|
* Start Transport Process.
|
|
140
214
|
* @returns The port Transport is listening on
|
|
@@ -148,6 +222,11 @@ export declare class ProcessManager {
|
|
|
148
222
|
* Stop health check interval.
|
|
149
223
|
*/
|
|
150
224
|
private stopHealthCheck;
|
|
225
|
+
/**
|
|
226
|
+
* Stop periodic health check interval.
|
|
227
|
+
* Also clears any pending agent health check timeout.
|
|
228
|
+
*/
|
|
229
|
+
private stopPeriodicHealthCheck;
|
|
151
230
|
/**
|
|
152
231
|
* Stop Transport Process.
|
|
153
232
|
*/
|