hawkeye-mcp-server 2.0.9 → 2.0.11
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/CHANGELOG.md +7 -1
- package/build/utils/validation.js +2 -2
- package/build/utils/validation.js.map +1 -1
- package/package.json +1 -1
- package/build/services/investigation-tracker.d.ts +0 -74
- package/build/services/investigation-tracker.js +0 -120
- package/build/services/investigation-tracker.js.map +0 -1
- package/build/services/streaming.service.d.ts +0 -41
- package/build/services/streaming.service.js +0 -124
- package/build/services/streaming.service.js.map +0 -1
- package/build/utils/progress-tracker.d.ts +0 -64
- package/build/utils/progress-tracker.js +0 -228
- package/build/utils/progress-tracker.js.map +0 -1
- package/build/workers/stream-consumer.d.ts +0 -6
- package/build/workers/stream-consumer.js +0 -156
- package/build/workers/stream-consumer.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,7 @@ All notable changes to the Hawkeye MCP Server will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [2.0.
|
|
8
|
+
## [2.0.10] - 2025-11-24
|
|
9
9
|
|
|
10
10
|
### Changed
|
|
11
11
|
|
|
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
14
14
|
- Manual investigations now use fire-and-forget approach with API polling
|
|
15
15
|
- Users should poll with `hawkeye_inspect_session` or `hawkeye_get_chain_of_thought` to monitor progress
|
|
16
16
|
- Simplified codebase, removed memory isolation issues
|
|
17
|
+
- Cleaned build artifacts - package size reduced from 723.3 kB to 680.1 kB
|
|
17
18
|
|
|
18
19
|
### Removed
|
|
19
20
|
|
|
@@ -29,6 +30,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
29
30
|
- Investigation progress tracking now queries API directly instead of relying on isolated worker thread memory
|
|
30
31
|
- `hawkeye_get_investigation_status` now properly reflects investigation state from API
|
|
31
32
|
|
|
33
|
+
## [2.0.9] - 2025-11-24
|
|
34
|
+
|
|
35
|
+
### Note
|
|
36
|
+
- Published with stale build artifacts, superseded by 2.0.10
|
|
37
|
+
|
|
32
38
|
## [2.0.8] - 2025-11-23
|
|
33
39
|
|
|
34
40
|
### Fixed
|
|
@@ -19,12 +19,12 @@ export const CreateInvestigationInputSchema = z.object({
|
|
|
19
19
|
project_uuid: z.string().uuid().optional(),
|
|
20
20
|
});
|
|
21
21
|
export const GetInvestigationStatusInputSchema = z.object({
|
|
22
|
-
session_uuid: z.string().
|
|
22
|
+
session_uuid: z.string().min(1, 'Session UUID is required'),
|
|
23
23
|
project_uuid: z.string().uuid().optional(),
|
|
24
24
|
include_full_details: z.boolean().optional().default(true),
|
|
25
25
|
});
|
|
26
26
|
export const ContinueInvestigationInputSchema = z.object({
|
|
27
|
-
session_uuid: z.string().
|
|
27
|
+
session_uuid: z.string().min(1, 'Session UUID is required'),
|
|
28
28
|
follow_up_prompt: z.string().min(1, 'Follow-up prompt is required'),
|
|
29
29
|
project_uuid: z.string().uuid().optional(),
|
|
30
30
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,sBAAsB,CAAC;IACnD,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IAC1C,eAAe,EAAE,CAAC,CAAC,OAAO,EAAE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AK,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Investigation Tracker Service
|
|
3
|
-
* Manages in-memory state for ongoing/completed investigations
|
|
4
|
-
* Used by worker threads to update progress that can be polled by get-investigation-status
|
|
5
|
-
*/
|
|
6
|
-
export interface InvestigationState {
|
|
7
|
-
session_uuid: string;
|
|
8
|
-
project_uuid: string;
|
|
9
|
-
status: 'starting' | 'in_progress' | 'completed' | 'failed';
|
|
10
|
-
started_at: Date;
|
|
11
|
-
completed_at?: Date;
|
|
12
|
-
progress_updates: ProgressUpdate[];
|
|
13
|
-
completion_message?: string;
|
|
14
|
-
error?: string;
|
|
15
|
-
rca?: any;
|
|
16
|
-
}
|
|
17
|
-
export interface ProgressUpdate {
|
|
18
|
-
timestamp: Date;
|
|
19
|
-
message: string;
|
|
20
|
-
type: 'progress' | 'analysis' | 'completion';
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Global in-memory store for investigation states
|
|
24
|
-
* Keyed by session_uuid
|
|
25
|
-
*/
|
|
26
|
-
declare class InvestigationTracker {
|
|
27
|
-
private investigations;
|
|
28
|
-
/**
|
|
29
|
-
* Create a new investigation entry
|
|
30
|
-
*/
|
|
31
|
-
create(session_uuid: string, project_uuid: string): void;
|
|
32
|
-
/**
|
|
33
|
-
* Update investigation status
|
|
34
|
-
*/
|
|
35
|
-
updateStatus(session_uuid: string, status: InvestigationState['status']): void;
|
|
36
|
-
/**
|
|
37
|
-
* Add a progress update
|
|
38
|
-
*/
|
|
39
|
-
addProgress(session_uuid: string, update: ProgressUpdate): void;
|
|
40
|
-
/**
|
|
41
|
-
* Set completion message
|
|
42
|
-
*/
|
|
43
|
-
setCompletion(session_uuid: string, message: string): void;
|
|
44
|
-
/**
|
|
45
|
-
* Set error
|
|
46
|
-
*/
|
|
47
|
-
setError(session_uuid: string, error: string): void;
|
|
48
|
-
/**
|
|
49
|
-
* Set RCA data
|
|
50
|
-
*/
|
|
51
|
-
setRCA(session_uuid: string, rca: any): void;
|
|
52
|
-
/**
|
|
53
|
-
* Get investigation state
|
|
54
|
-
*/
|
|
55
|
-
get(session_uuid: string): InvestigationState | undefined;
|
|
56
|
-
/**
|
|
57
|
-
* Check if investigation exists
|
|
58
|
-
*/
|
|
59
|
-
has(session_uuid: string): boolean;
|
|
60
|
-
/**
|
|
61
|
-
* Remove investigation from tracker (cleanup)
|
|
62
|
-
*/
|
|
63
|
-
remove(session_uuid: string): void;
|
|
64
|
-
/**
|
|
65
|
-
* Get all active investigations
|
|
66
|
-
*/
|
|
67
|
-
getActive(): InvestigationState[];
|
|
68
|
-
/**
|
|
69
|
-
* Cleanup completed/failed investigations older than TTL
|
|
70
|
-
*/
|
|
71
|
-
cleanup(ttlMs?: number): void;
|
|
72
|
-
}
|
|
73
|
-
export declare const investigationTracker: InvestigationTracker;
|
|
74
|
-
export {};
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Investigation Tracker Service
|
|
3
|
-
* Manages in-memory state for ongoing/completed investigations
|
|
4
|
-
* Used by worker threads to update progress that can be polled by get-investigation-status
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Global in-memory store for investigation states
|
|
8
|
-
* Keyed by session_uuid
|
|
9
|
-
*/
|
|
10
|
-
class InvestigationTracker {
|
|
11
|
-
investigations = new Map();
|
|
12
|
-
/**
|
|
13
|
-
* Create a new investigation entry
|
|
14
|
-
*/
|
|
15
|
-
create(session_uuid, project_uuid) {
|
|
16
|
-
this.investigations.set(session_uuid, {
|
|
17
|
-
session_uuid,
|
|
18
|
-
project_uuid,
|
|
19
|
-
status: 'starting',
|
|
20
|
-
started_at: new Date(),
|
|
21
|
-
progress_updates: [],
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Update investigation status
|
|
26
|
-
*/
|
|
27
|
-
updateStatus(session_uuid, status) {
|
|
28
|
-
const state = this.investigations.get(session_uuid);
|
|
29
|
-
if (state) {
|
|
30
|
-
state.status = status;
|
|
31
|
-
if (status === 'completed' || status === 'failed') {
|
|
32
|
-
state.completed_at = new Date();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Add a progress update
|
|
38
|
-
*/
|
|
39
|
-
addProgress(session_uuid, update) {
|
|
40
|
-
const state = this.investigations.get(session_uuid);
|
|
41
|
-
if (state) {
|
|
42
|
-
state.progress_updates.push(update);
|
|
43
|
-
// Update status if we got progress
|
|
44
|
-
if (state.status === 'starting') {
|
|
45
|
-
state.status = 'in_progress';
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Set completion message
|
|
51
|
-
*/
|
|
52
|
-
setCompletion(session_uuid, message) {
|
|
53
|
-
const state = this.investigations.get(session_uuid);
|
|
54
|
-
if (state) {
|
|
55
|
-
state.completion_message = message;
|
|
56
|
-
state.status = 'completed';
|
|
57
|
-
state.completed_at = new Date();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Set error
|
|
62
|
-
*/
|
|
63
|
-
setError(session_uuid, error) {
|
|
64
|
-
const state = this.investigations.get(session_uuid);
|
|
65
|
-
if (state) {
|
|
66
|
-
state.error = error;
|
|
67
|
-
state.status = 'failed';
|
|
68
|
-
state.completed_at = new Date();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Set RCA data
|
|
73
|
-
*/
|
|
74
|
-
setRCA(session_uuid, rca) {
|
|
75
|
-
const state = this.investigations.get(session_uuid);
|
|
76
|
-
if (state) {
|
|
77
|
-
state.rca = rca;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Get investigation state
|
|
82
|
-
*/
|
|
83
|
-
get(session_uuid) {
|
|
84
|
-
return this.investigations.get(session_uuid);
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Check if investigation exists
|
|
88
|
-
*/
|
|
89
|
-
has(session_uuid) {
|
|
90
|
-
return this.investigations.has(session_uuid);
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Remove investigation from tracker (cleanup)
|
|
94
|
-
*/
|
|
95
|
-
remove(session_uuid) {
|
|
96
|
-
this.investigations.delete(session_uuid);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Get all active investigations
|
|
100
|
-
*/
|
|
101
|
-
getActive() {
|
|
102
|
-
return Array.from(this.investigations.values()).filter((inv) => inv.status === 'starting' || inv.status === 'in_progress');
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Cleanup completed/failed investigations older than TTL
|
|
106
|
-
*/
|
|
107
|
-
cleanup(ttlMs = 3600000) {
|
|
108
|
-
const now = Date.now();
|
|
109
|
-
for (const [uuid, state] of this.investigations.entries()) {
|
|
110
|
-
if ((state.status === 'completed' || state.status === 'failed') &&
|
|
111
|
-
state.completed_at &&
|
|
112
|
-
now - state.completed_at.getTime() > ttlMs) {
|
|
113
|
-
this.investigations.delete(uuid);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
// Global singleton instance
|
|
119
|
-
export const investigationTracker = new InvestigationTracker();
|
|
120
|
-
//# sourceMappingURL=investigation-tracker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"investigation-tracker.js","sourceRoot":"","sources":["../../src/services/investigation-tracker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoBH;;;GAGG;AACH,MAAM,oBAAoB;IAChB,cAAc,GAAG,IAAI,GAAG,EAA8B,CAAC;IAE/D;;OAEG;IACH,MAAM,CAAC,YAAoB,EAAE,YAAoB;QAC/C,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,YAAY,EAAE;YACpC,YAAY;YACZ,YAAY;YACZ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AE,CAAC;YAC1D,IACE,CAAC,KAAK,CAAC,MAAM,KAAK,WAAW,IAAI,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAC;gBAC3D,KAAK,CAAC,YAAY;gBAClB,GAAG,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,GAAG,KAAK,EAC1C,CAAC;gBACD,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAED,4BAA4B;AAC5B,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,oBAAoB,EAAE,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Streaming Service
|
|
3
|
-
* Handles Server-Sent Events (SSE) streaming from Hawkeye API
|
|
4
|
-
*/
|
|
5
|
-
import { AxiosInstance } from 'axios';
|
|
6
|
-
export interface StreamMessage {
|
|
7
|
-
session_uuid?: string;
|
|
8
|
-
message?: {
|
|
9
|
-
id: string;
|
|
10
|
-
create_time: string;
|
|
11
|
-
content: {
|
|
12
|
-
content_type: string;
|
|
13
|
-
parts: string[];
|
|
14
|
-
};
|
|
15
|
-
status?: string;
|
|
16
|
-
};
|
|
17
|
-
response?: any;
|
|
18
|
-
}
|
|
19
|
-
export interface ProgressUpdate {
|
|
20
|
-
timestamp: Date;
|
|
21
|
-
message: string;
|
|
22
|
-
type: 'progress' | 'analysis' | 'completion';
|
|
23
|
-
}
|
|
24
|
-
export declare class StreamingService {
|
|
25
|
-
private httpClient;
|
|
26
|
-
constructor(httpClient: AxiosInstance);
|
|
27
|
-
/**
|
|
28
|
-
* Stream investigation progress from Hawkeye API
|
|
29
|
-
* Returns an async generator that yields progress updates
|
|
30
|
-
*/
|
|
31
|
-
streamInvestigation(projectUuid: string, prompt: string, sessionUuid?: string): AsyncGenerator<ProgressUpdate, void, unknown>;
|
|
32
|
-
/**
|
|
33
|
-
* Stream investigation and collect all progress updates
|
|
34
|
-
* Returns when investigation completes with full progress log
|
|
35
|
-
*/
|
|
36
|
-
streamInvestigationWithProgress(projectUuid: string, prompt: string, sessionUuid?: string, onProgress?: (update: ProgressUpdate) => void): Promise<{
|
|
37
|
-
completion: string;
|
|
38
|
-
progressLog: ProgressUpdate[];
|
|
39
|
-
duration: number;
|
|
40
|
-
}>;
|
|
41
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Streaming Service
|
|
3
|
-
* Handles Server-Sent Events (SSE) streaming from Hawkeye API
|
|
4
|
-
*/
|
|
5
|
-
import { logger } from '../utils/logger.js';
|
|
6
|
-
export class StreamingService {
|
|
7
|
-
httpClient;
|
|
8
|
-
constructor(httpClient) {
|
|
9
|
-
this.httpClient = httpClient;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Stream investigation progress from Hawkeye API
|
|
13
|
-
* Returns an async generator that yields progress updates
|
|
14
|
-
*/
|
|
15
|
-
async *streamInvestigation(projectUuid, prompt, sessionUuid) {
|
|
16
|
-
logger.info('Starting investigation stream', { projectUuid, sessionUuid });
|
|
17
|
-
const payload = {
|
|
18
|
-
project_uuid: projectUuid,
|
|
19
|
-
messages: [
|
|
20
|
-
{
|
|
21
|
-
content: {
|
|
22
|
-
content_type: 'CONTENT_TYPE_CHAT_PROMPT',
|
|
23
|
-
parts: [prompt],
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
action: 'ACTION_NEXT',
|
|
28
|
-
...(sessionUuid && { session_uuid: sessionUuid }),
|
|
29
|
-
};
|
|
30
|
-
try {
|
|
31
|
-
const response = await this.httpClient.post('/v1/inference/session', payload, {
|
|
32
|
-
responseType: 'stream',
|
|
33
|
-
headers: {
|
|
34
|
-
'x-client-identifier': 'mcp-server',
|
|
35
|
-
},
|
|
36
|
-
timeout: 600000, // 10 minutes
|
|
37
|
-
});
|
|
38
|
-
let buffer = '';
|
|
39
|
-
let messageCount = 0;
|
|
40
|
-
// Process SSE stream
|
|
41
|
-
for await (const chunk of response.data) {
|
|
42
|
-
const chunkStr = chunk.toString();
|
|
43
|
-
buffer += chunkStr;
|
|
44
|
-
// Split by newlines
|
|
45
|
-
const lines = buffer.split('\n');
|
|
46
|
-
buffer = lines.pop() || ''; // Keep incomplete line in buffer
|
|
47
|
-
for (let line of lines) {
|
|
48
|
-
if (!line.trim())
|
|
49
|
-
continue;
|
|
50
|
-
// Handle SSE format: "data: {...}"
|
|
51
|
-
if (line.startsWith('data: ')) {
|
|
52
|
-
line = line.substring(6);
|
|
53
|
-
}
|
|
54
|
-
try {
|
|
55
|
-
const data = JSON.parse(line);
|
|
56
|
-
messageCount++;
|
|
57
|
-
// Parse message content
|
|
58
|
-
if (data.message?.content) {
|
|
59
|
-
const contentType = data.message.content.content_type;
|
|
60
|
-
const parts = data.message.content.parts || [];
|
|
61
|
-
if (contentType === 'CONTENT_TYPE_PROGRESS_STATUS' && parts.length > 0) {
|
|
62
|
-
yield {
|
|
63
|
-
timestamp: new Date(),
|
|
64
|
-
message: parts[0],
|
|
65
|
-
type: 'progress',
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
else if (contentType === 'CONTENT_TYPE_INTERIM_ANALYSIS' && parts.length > 0) {
|
|
69
|
-
yield {
|
|
70
|
-
timestamp: new Date(),
|
|
71
|
-
message: parts[0],
|
|
72
|
-
type: 'analysis',
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
else if (contentType === 'CONTENT_TYPE_CHAT_COMPLETION' && parts.length > 0) {
|
|
76
|
-
yield {
|
|
77
|
-
timestamp: new Date(),
|
|
78
|
-
message: parts[0],
|
|
79
|
-
type: 'completion',
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
catch (e) {
|
|
85
|
-
// Skip invalid JSON
|
|
86
|
-
logger.debug('Skipping invalid JSON line', { line: line.substring(0, 100) });
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
logger.info('Investigation stream completed', { messageCount });
|
|
91
|
-
}
|
|
92
|
-
catch (error) {
|
|
93
|
-
logger.error('Investigation stream error', { error: error.message });
|
|
94
|
-
throw error;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Stream investigation and collect all progress updates
|
|
99
|
-
* Returns when investigation completes with full progress log
|
|
100
|
-
*/
|
|
101
|
-
async streamInvestigationWithProgress(projectUuid, prompt, sessionUuid, onProgress) {
|
|
102
|
-
const startTime = Date.now();
|
|
103
|
-
const progressLog = [];
|
|
104
|
-
let completion = '';
|
|
105
|
-
for await (const update of this.streamInvestigation(projectUuid, prompt, sessionUuid)) {
|
|
106
|
-
progressLog.push(update);
|
|
107
|
-
// Call progress callback if provided
|
|
108
|
-
if (onProgress) {
|
|
109
|
-
onProgress(update);
|
|
110
|
-
}
|
|
111
|
-
// Store completion message
|
|
112
|
-
if (update.type === 'completion') {
|
|
113
|
-
completion = update.message;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
const duration = Date.now() - startTime;
|
|
117
|
-
return {
|
|
118
|
-
completion,
|
|
119
|
-
progressLog,
|
|
120
|
-
duration,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
//# sourceMappingURL=streaming.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"streaming.service.js","sourceRoot":"","sources":["../../src/services/streaming.service.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAsB5C,MAAM,OAAO,gBAAgB;IACnB,UAAU,CAAgB;IAElC,YAAY,UAAyB;QACnC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,CAAC,mBAAmB,CACxB,WAAmB,EACnB,MAAc,EACd,WAAoB;QAEpB,MAAM,CAAC,IAAI,CAAC,+BAA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CAAC;oBAC/E,CAAC;gBACH,CAAC;YACH,CAAC;YAED,MAAM,CAAC,IAAI,CAAC,gCAAgC,EAAE,EAAE,YAAY,EAAE,CAAC,CAAC;QAClE,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,CAAC,KAAK,CAAC,4BAA4B,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACrE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,+BAA+B,CACnC,WAAmB,EACnB,MAAc,EACd,WAAoB,EACpB,UAA6C;QAM7C,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,MAAM,WAAW,GAAqB,EAAE,CAAC;QACzC,IAAI,UAAU,GAAG,EAAE,CAAC;QAEpB,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,IAAI,CAAC,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,CAAC;YACtF,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAEzB,qCAAqC;YACrC,IAAI,UAAU,EAAE,CAAC;gBACf,UAAU,CAAC,MAAM,CAAC,CAAC;YACrB,CAAC;YAED,2BAA2B;YAC3B,IAAI,MAAM,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;gBACjC,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC;YAC9B,CAAC;QACH,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;QAExC,OAAO;YACL,UAAU;YACV,WAAW;YACX,QAAQ;SACT,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Progress Tracker Utility
|
|
3
|
-
* Converts raw progress messages into human-readable updates
|
|
4
|
-
*/
|
|
5
|
-
import { ProgressUpdate } from '../services/streaming.service.js';
|
|
6
|
-
export interface HumanReadableProgress {
|
|
7
|
-
emoji: string;
|
|
8
|
-
phase: string;
|
|
9
|
-
message: string;
|
|
10
|
-
elapsed: string;
|
|
11
|
-
details?: string;
|
|
12
|
-
}
|
|
13
|
-
export declare class ProgressTracker {
|
|
14
|
-
private startTime;
|
|
15
|
-
private updates;
|
|
16
|
-
private phaseCounters;
|
|
17
|
-
constructor();
|
|
18
|
-
/**
|
|
19
|
-
* Add a progress update
|
|
20
|
-
*/
|
|
21
|
-
add(update: ProgressUpdate): void;
|
|
22
|
-
/**
|
|
23
|
-
* Get all updates
|
|
24
|
-
*/
|
|
25
|
-
getAll(): ProgressUpdate[];
|
|
26
|
-
/**
|
|
27
|
-
* Get latest update
|
|
28
|
-
*/
|
|
29
|
-
getLatest(): ProgressUpdate | null;
|
|
30
|
-
/**
|
|
31
|
-
* Get elapsed time
|
|
32
|
-
*/
|
|
33
|
-
getElapsed(): number;
|
|
34
|
-
/**
|
|
35
|
-
* Format elapsed time
|
|
36
|
-
*/
|
|
37
|
-
formatElapsed(): string;
|
|
38
|
-
/**
|
|
39
|
-
* Convert raw progress message to human-readable format
|
|
40
|
-
*/
|
|
41
|
-
humanize(rawMessage: string): HumanReadableProgress;
|
|
42
|
-
/**
|
|
43
|
-
* Categorize progress by component and action
|
|
44
|
-
*/
|
|
45
|
-
private categorizeProgress;
|
|
46
|
-
/**
|
|
47
|
-
* Get phase from action
|
|
48
|
-
*/
|
|
49
|
-
private getPhase;
|
|
50
|
-
/**
|
|
51
|
-
* Get summary of investigation progress
|
|
52
|
-
*/
|
|
53
|
-
getSummary(): {
|
|
54
|
-
phase: string;
|
|
55
|
-
elapsed: string;
|
|
56
|
-
stepCount: number;
|
|
57
|
-
queryCount: number;
|
|
58
|
-
analysisCount: number;
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Get progress percentage estimate (rough estimate based on phases)
|
|
62
|
-
*/
|
|
63
|
-
getProgressPercentage(): number;
|
|
64
|
-
}
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Progress Tracker Utility
|
|
3
|
-
* Converts raw progress messages into human-readable updates
|
|
4
|
-
*/
|
|
5
|
-
export class ProgressTracker {
|
|
6
|
-
startTime;
|
|
7
|
-
updates = [];
|
|
8
|
-
phaseCounters = new Map();
|
|
9
|
-
constructor() {
|
|
10
|
-
this.startTime = new Date();
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Add a progress update
|
|
14
|
-
*/
|
|
15
|
-
add(update) {
|
|
16
|
-
this.updates.push(update);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Get all updates
|
|
20
|
-
*/
|
|
21
|
-
getAll() {
|
|
22
|
-
return this.updates;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Get latest update
|
|
26
|
-
*/
|
|
27
|
-
getLatest() {
|
|
28
|
-
return this.updates.length > 0 ? this.updates[this.updates.length - 1] : null;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Get elapsed time
|
|
32
|
-
*/
|
|
33
|
-
getElapsed() {
|
|
34
|
-
return Date.now() - this.startTime.getTime();
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Format elapsed time
|
|
38
|
-
*/
|
|
39
|
-
formatElapsed() {
|
|
40
|
-
const elapsed = this.getElapsed();
|
|
41
|
-
const seconds = Math.floor(elapsed / 1000);
|
|
42
|
-
if (seconds < 60) {
|
|
43
|
-
return `${seconds}s`;
|
|
44
|
-
}
|
|
45
|
-
const minutes = Math.floor(seconds / 60);
|
|
46
|
-
const remainingSeconds = seconds % 60;
|
|
47
|
-
return `${minutes}m ${remainingSeconds}s`;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Convert raw progress message to human-readable format
|
|
51
|
-
*/
|
|
52
|
-
humanize(rawMessage) {
|
|
53
|
-
// Parse message format: "ComponentName (Action Description)"
|
|
54
|
-
const match = rawMessage.match(/^(\w+)\s*\((.+)\)$/);
|
|
55
|
-
if (match) {
|
|
56
|
-
const [, component, action] = match;
|
|
57
|
-
return this.categorizeProgress(component, action);
|
|
58
|
-
}
|
|
59
|
-
// Fallback for messages without standard format
|
|
60
|
-
return {
|
|
61
|
-
emoji: '📝',
|
|
62
|
-
phase: 'Processing',
|
|
63
|
-
message: rawMessage,
|
|
64
|
-
elapsed: this.formatElapsed(),
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Categorize progress by component and action
|
|
69
|
-
*/
|
|
70
|
-
categorizeProgress(component, action) {
|
|
71
|
-
// Track phase occurrences
|
|
72
|
-
const phase = this.getPhase(action);
|
|
73
|
-
const count = (this.phaseCounters.get(phase) || 0) + 1;
|
|
74
|
-
this.phaseCounters.set(phase, count);
|
|
75
|
-
const elapsed = this.formatElapsed();
|
|
76
|
-
// Map to human-readable messages
|
|
77
|
-
const mapping = {
|
|
78
|
-
'Preparing Telemetry Sources': {
|
|
79
|
-
emoji: '🔧',
|
|
80
|
-
phase: 'Preparation',
|
|
81
|
-
message: 'Preparing telemetry sources',
|
|
82
|
-
elapsed,
|
|
83
|
-
details: component,
|
|
84
|
-
},
|
|
85
|
-
'Loading Context': {
|
|
86
|
-
emoji: '📚',
|
|
87
|
-
phase: 'Context Loading',
|
|
88
|
-
message: 'Loading investigation context',
|
|
89
|
-
elapsed,
|
|
90
|
-
},
|
|
91
|
-
'Loading Investigation Programs': {
|
|
92
|
-
emoji: '⚙️',
|
|
93
|
-
phase: 'Setup',
|
|
94
|
-
message: 'Loading investigation programs',
|
|
95
|
-
elapsed,
|
|
96
|
-
},
|
|
97
|
-
'Preparing Baseline': {
|
|
98
|
-
emoji: '📊',
|
|
99
|
-
phase: 'Baseline',
|
|
100
|
-
message: 'Preparing baseline data',
|
|
101
|
-
elapsed,
|
|
102
|
-
},
|
|
103
|
-
'Preparing Investigation Plan': {
|
|
104
|
-
emoji: '🗺️',
|
|
105
|
-
phase: 'Planning',
|
|
106
|
-
message: 'Preparing investigation plan',
|
|
107
|
-
elapsed,
|
|
108
|
-
},
|
|
109
|
-
'Classifying Datasources': {
|
|
110
|
-
emoji: '🔍',
|
|
111
|
-
phase: 'Discovery',
|
|
112
|
-
message: 'Classifying datasources',
|
|
113
|
-
elapsed,
|
|
114
|
-
details: `Step ${count}`,
|
|
115
|
-
},
|
|
116
|
-
'Fine-tuning Datasources For Investigation': {
|
|
117
|
-
emoji: '🎯',
|
|
118
|
-
phase: 'Discovery',
|
|
119
|
-
message: 'Fine-tuning datasources',
|
|
120
|
-
elapsed,
|
|
121
|
-
},
|
|
122
|
-
'Understanding Datasources': {
|
|
123
|
-
emoji: '📖',
|
|
124
|
-
phase: 'Analysis',
|
|
125
|
-
message: 'Understanding datasources',
|
|
126
|
-
elapsed,
|
|
127
|
-
},
|
|
128
|
-
'Generating Investigation Programs': {
|
|
129
|
-
emoji: '⚡',
|
|
130
|
-
phase: 'Query Generation',
|
|
131
|
-
message: 'Generating investigation queries',
|
|
132
|
-
elapsed,
|
|
133
|
-
details: `Query ${count}`,
|
|
134
|
-
},
|
|
135
|
-
'Routing telemetry access': {
|
|
136
|
-
emoji: '🛤️',
|
|
137
|
-
phase: 'Data Access',
|
|
138
|
-
message: 'Routing telemetry access',
|
|
139
|
-
elapsed,
|
|
140
|
-
},
|
|
141
|
-
'Consulting Telemetry': {
|
|
142
|
-
emoji: '🔎',
|
|
143
|
-
phase: 'Data Collection',
|
|
144
|
-
message: 'Consulting telemetry',
|
|
145
|
-
elapsed,
|
|
146
|
-
details: `Query ${count}`,
|
|
147
|
-
},
|
|
148
|
-
'Analyzing Telemetry': {
|
|
149
|
-
emoji: '🧠',
|
|
150
|
-
phase: 'Analysis',
|
|
151
|
-
message: 'Analyzing telemetry data',
|
|
152
|
-
elapsed,
|
|
153
|
-
details: `Analysis ${count}`,
|
|
154
|
-
},
|
|
155
|
-
'Summarizing Results': {
|
|
156
|
-
emoji: '📝',
|
|
157
|
-
phase: 'Finalization',
|
|
158
|
-
message: 'Summarizing results',
|
|
159
|
-
elapsed,
|
|
160
|
-
},
|
|
161
|
-
};
|
|
162
|
-
return mapping[action] || {
|
|
163
|
-
emoji: '⚙️',
|
|
164
|
-
phase: 'Processing',
|
|
165
|
-
message: action.toLowerCase(),
|
|
166
|
-
elapsed,
|
|
167
|
-
details: component,
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Get phase from action
|
|
172
|
-
*/
|
|
173
|
-
getPhase(action) {
|
|
174
|
-
if (action.includes('Preparing'))
|
|
175
|
-
return 'Preparation';
|
|
176
|
-
if (action.includes('Classifying') || action.includes('Fine-tuning'))
|
|
177
|
-
return 'Discovery';
|
|
178
|
-
if (action.includes('Generating'))
|
|
179
|
-
return 'Query Generation';
|
|
180
|
-
if (action.includes('Consulting'))
|
|
181
|
-
return 'Data Collection';
|
|
182
|
-
if (action.includes('Analyzing'))
|
|
183
|
-
return 'Analysis';
|
|
184
|
-
if (action.includes('Summarizing'))
|
|
185
|
-
return 'Finalization';
|
|
186
|
-
return 'Processing';
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Get summary of investigation progress
|
|
190
|
-
*/
|
|
191
|
-
getSummary() {
|
|
192
|
-
const queryCount = this.phaseCounters.get('Data Collection') || 0;
|
|
193
|
-
const analysisCount = this.phaseCounters.get('Analysis') || 0;
|
|
194
|
-
// Determine current phase
|
|
195
|
-
const latest = this.getLatest();
|
|
196
|
-
let currentPhase = 'Starting';
|
|
197
|
-
if (latest) {
|
|
198
|
-
const humanized = this.humanize(latest.message);
|
|
199
|
-
currentPhase = humanized.phase;
|
|
200
|
-
}
|
|
201
|
-
return {
|
|
202
|
-
phase: currentPhase,
|
|
203
|
-
elapsed: this.formatElapsed(),
|
|
204
|
-
stepCount: this.updates.length,
|
|
205
|
-
queryCount,
|
|
206
|
-
analysisCount,
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Get progress percentage estimate (rough estimate based on phases)
|
|
211
|
-
*/
|
|
212
|
-
getProgressPercentage() {
|
|
213
|
-
const summary = this.getSummary();
|
|
214
|
-
const phaseWeights = {
|
|
215
|
-
'Preparation': 10,
|
|
216
|
-
'Context Loading': 15,
|
|
217
|
-
'Setup': 20,
|
|
218
|
-
'Planning': 25,
|
|
219
|
-
'Discovery': 35,
|
|
220
|
-
'Query Generation': 45,
|
|
221
|
-
'Data Collection': 70,
|
|
222
|
-
'Analysis': 85,
|
|
223
|
-
'Finalization': 95,
|
|
224
|
-
};
|
|
225
|
-
return phaseWeights[summary.phase] || 0;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
//# sourceMappingURL=progress-tracker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"progress-tracker.js","sourceRoot":"","sources":["../../src/utils/progress-tracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,MAAM,OAAO,eAAe;IAClB,SAAS,CAAO;IAChB,OAAO,GAAqB,EAAE,CAAC;IAC/B,aAAa,GAAwB,IAAI,GAAG,EAAE,CAAC;IAEvD;QACE,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,MAAsB;QACxB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAChF,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE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
|
|
3
|
-
* Consumes the streaming response from /v1/inference/session
|
|
4
|
-
* Updates the investigation tracker as progress comes in
|
|
5
|
-
*/
|
|
6
|
-
import { parentPort, workerData } from 'worker_threads';
|
|
7
|
-
import axios from 'axios';
|
|
8
|
-
const data = workerData;
|
|
9
|
-
async function consumeStream() {
|
|
10
|
-
try {
|
|
11
|
-
console.error(`[Worker ${data.sessionUuid}] Starting stream consumer`);
|
|
12
|
-
console.error(`[Worker ${data.sessionUuid}] Base URL: ${data.baseUrl}`);
|
|
13
|
-
console.error(`[Worker ${data.sessionUuid}] Project: ${data.projectUuid}`);
|
|
14
|
-
// Notify parent that we're starting
|
|
15
|
-
parentPort?.postMessage({ type: 'status', status: 'starting' });
|
|
16
|
-
const client = axios.create({
|
|
17
|
-
baseURL: data.baseUrl,
|
|
18
|
-
headers: {
|
|
19
|
-
Authorization: `Bearer ${data.authToken}`,
|
|
20
|
-
'Content-Type': 'application/json',
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
console.error(`[Worker ${data.sessionUuid}] Posting to /v1/inference/session`);
|
|
24
|
-
const response = await client.post('/v1/inference/session', {
|
|
25
|
-
action: 'ACTION_NEXT',
|
|
26
|
-
session_uuid: data.sessionUuid,
|
|
27
|
-
project_uuid: data.projectUuid,
|
|
28
|
-
messages: [
|
|
29
|
-
{
|
|
30
|
-
content: {
|
|
31
|
-
content_type: 'CONTENT_TYPE_CHAT_PROMPT',
|
|
32
|
-
parts: [data.prompt],
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
request: {
|
|
37
|
-
request_id: data.requestId,
|
|
38
|
-
},
|
|
39
|
-
prompt_options: {
|
|
40
|
-
disable_replay: false,
|
|
41
|
-
source_focus_categories: [],
|
|
42
|
-
},
|
|
43
|
-
}, {
|
|
44
|
-
responseType: 'stream',
|
|
45
|
-
timeout: 600000, // 10 minutes
|
|
46
|
-
});
|
|
47
|
-
console.error(`[Worker ${data.sessionUuid}] Stream connected, starting to consume`);
|
|
48
|
-
parentPort?.postMessage({ type: 'status', status: 'streaming' });
|
|
49
|
-
let buffer = '';
|
|
50
|
-
let messageCount = 0;
|
|
51
|
-
let endTurn = false;
|
|
52
|
-
// Process stream chunks
|
|
53
|
-
response.data.on('data', (chunk) => {
|
|
54
|
-
console.error(`[Worker ${data.sessionUuid}] Received chunk of ${chunk.length} bytes`);
|
|
55
|
-
const chunkStr = chunk.toString();
|
|
56
|
-
buffer += chunkStr;
|
|
57
|
-
// Split by newlines
|
|
58
|
-
const lines = buffer.split('\n');
|
|
59
|
-
buffer = lines.pop() || ''; // Keep incomplete line in buffer
|
|
60
|
-
for (let line of lines) {
|
|
61
|
-
if (!line.trim())
|
|
62
|
-
continue;
|
|
63
|
-
// Handle SSE format: "data: {...}"
|
|
64
|
-
if (line.startsWith('data: ')) {
|
|
65
|
-
line = line.substring(6);
|
|
66
|
-
}
|
|
67
|
-
try {
|
|
68
|
-
const message = JSON.parse(line);
|
|
69
|
-
messageCount++;
|
|
70
|
-
if (message.message?.content) {
|
|
71
|
-
const contentType = message.message.content.content_type;
|
|
72
|
-
const parts = message.message.content.parts || [];
|
|
73
|
-
// Send progress update to parent
|
|
74
|
-
if (contentType === 'CONTENT_TYPE_PROGRESS_STATUS' && parts.length > 0) {
|
|
75
|
-
console.error(`[Worker ${data.sessionUuid}] Progress: ${parts[0].substring(0, 100)}`);
|
|
76
|
-
parentPort?.postMessage({
|
|
77
|
-
type: 'progress',
|
|
78
|
-
update: {
|
|
79
|
-
timestamp: new Date().toISOString(),
|
|
80
|
-
message: parts[0],
|
|
81
|
-
type: 'progress',
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
else if (contentType === 'CONTENT_TYPE_INTERIM_ANALYSIS' && parts.length > 0) {
|
|
86
|
-
console.error(`[Worker ${data.sessionUuid}] Analysis update received`);
|
|
87
|
-
parentPort?.postMessage({
|
|
88
|
-
type: 'progress',
|
|
89
|
-
update: {
|
|
90
|
-
timestamp: new Date().toISOString(),
|
|
91
|
-
message: parts[0],
|
|
92
|
-
type: 'analysis',
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
else if (contentType === 'CONTENT_TYPE_CHAT_COMPLETION' && parts.length > 0) {
|
|
97
|
-
console.error(`[Worker ${data.sessionUuid}] Completion received`);
|
|
98
|
-
parentPort?.postMessage({
|
|
99
|
-
type: 'completion',
|
|
100
|
-
message: parts[0],
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
// Check for end turn
|
|
104
|
-
if (message.message.end_turn) {
|
|
105
|
-
endTurn = true;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
// Check for errors
|
|
109
|
-
if (message.message?.status && message.message.status.code !== 0) {
|
|
110
|
-
parentPort?.postMessage({
|
|
111
|
-
type: 'error',
|
|
112
|
-
error: message.message.status.message || 'Unknown error',
|
|
113
|
-
hint: message.message.status.hint,
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
catch (e) {
|
|
118
|
-
// Skip invalid JSON
|
|
119
|
-
if (line.length > 0 && line !== '{}') {
|
|
120
|
-
console.error('[Worker] Skipping invalid JSON:', line.substring(0, 100));
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
response.data.on('end', () => {
|
|
126
|
-
console.error(`[Worker ${data.sessionUuid}] Stream ended. Messages: ${messageCount}, EndTurn: ${endTurn}`);
|
|
127
|
-
parentPort?.postMessage({
|
|
128
|
-
type: 'completed',
|
|
129
|
-
messageCount,
|
|
130
|
-
endTurn,
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
response.data.on('error', (error) => {
|
|
134
|
-
parentPort?.postMessage({
|
|
135
|
-
type: 'error',
|
|
136
|
-
error: error.message,
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
catch (error) {
|
|
141
|
-
console.error(`[Worker ${data.sessionUuid}] ERROR:`, error.message || String(error));
|
|
142
|
-
console.error(`[Worker ${data.sessionUuid}] Stack:`, error.stack);
|
|
143
|
-
parentPort?.postMessage({
|
|
144
|
-
type: 'error',
|
|
145
|
-
error: error.message || String(error),
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
// Start consuming the stream
|
|
150
|
-
consumeStream().catch((error) => {
|
|
151
|
-
parentPort?.postMessage({
|
|
152
|
-
type: 'error',
|
|
153
|
-
error: error.message || String(error),
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
//# sourceMappingURL=stream-consumer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stream-consumer.js","sourceRoot":"","sources":["../../src/workers/stream-consumer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,MAAM,IAAI,GAAG,UAAwB,CAAC;AAoBtC,KAAK,UAAU,aAAa;IAC1B,IAAI,CAAC;QACH,OAAO,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC,WAAW,4BAA4B,CAAC,CAAC;QACvE,OAAO,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC,WAAW,eAAe,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QACxE,OAAO,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC,WAAW,cAAc,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QAE3E,oCAAoC;QACpC,UAAU,EAAE,WAAW,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;QAEhE,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;YAC1B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,IAAI,CAAC,SAAS,EAAE;gBACzC,cAA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