codebuff 1.0.261 → 1.0.263
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/client.d.ts +1 -1
- package/dist/client.js +1 -0
- package/dist/client.js.map +1 -1
- package/dist/common/actions.d.ts +13 -10
- package/dist/common/actions.js +1 -0
- package/dist/common/actions.js.map +1 -1
- package/dist/common/analytics.js +3 -3
- package/dist/common/analytics.js.map +1 -1
- package/dist/common/constants/tools.d.ts +1 -0
- package/dist/common/constants/tools.js +1 -0
- package/dist/common/constants/tools.js.map +1 -1
- package/dist/common/types/agent-state.d.ts +2 -2
- package/dist/common/websockets/websocket-schema.d.ts +34 -24
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/project-files.d.ts +11 -1
- package/dist/project-files.js +30 -8
- package/dist/project-files.js.map +1 -1
- package/dist/tool-handlers.d.ts +2 -1
- package/dist/tool-handlers.js +6 -4
- package/dist/tool-handlers.js.map +1 -1
- package/dist/update-codebuff.js +3 -2
- package/dist/update-codebuff.js.map +1 -1
- package/dist/utils/__tests__/background-process-manager.test.js +314 -276
- package/dist/utils/__tests__/background-process-manager.test.js.map +1 -1
- package/dist/utils/__tests__/file-paths.test.d.ts +1 -0
- package/dist/utils/__tests__/file-paths.test.js +37 -0
- package/dist/utils/__tests__/file-paths.test.js.map +1 -0
- package/dist/utils/__tests__/path.test.d.ts +1 -0
- package/dist/utils/__tests__/path.test.js +37 -0
- package/dist/utils/__tests__/path.test.js.map +1 -0
- package/dist/utils/file-paths.d.ts +9 -0
- package/dist/utils/file-paths.js +24 -0
- package/dist/utils/file-paths.js.map +1 -0
- package/dist/utils/git.d.ts +1 -0
- package/dist/utils/git.js +17 -0
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/path.d.ts +9 -0
- package/dist/utils/path.js +27 -0
- package/dist/utils/path.js.map +1 -0
- package/dist/utils/terminal.js +80 -73
- package/dist/utils/terminal.js.map +1 -1
- package/dist/utils/tool-renderers.js +15 -0
- package/dist/utils/tool-renderers.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,289 +1,327 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
// @ts-ignore: bun:test types aren't available
|
|
4
27
|
const bun_test_1 = require("bun:test");
|
|
5
28
|
// @ts-ignore: bun:test types aren't available
|
|
6
29
|
const bun_test_2 = require("bun:test");
|
|
7
|
-
const background_process_manager_1 = require("../../background-process-manager");
|
|
8
30
|
// Mock the child process
|
|
9
31
|
const mockChildProcess = {
|
|
10
32
|
exitCode: null,
|
|
11
33
|
signalCode: null,
|
|
12
34
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
35
|
+
// Check if we are in CI/CD
|
|
36
|
+
const isCI = process.env.CODEBUFF_GITHUB_ACTIONS === 'true';
|
|
37
|
+
// Skip tests entirely in CI
|
|
38
|
+
if (!isCI) {
|
|
39
|
+
// Wrap the dynamic import and tests in an async IIFE to avoid top-level await
|
|
40
|
+
(async () => {
|
|
41
|
+
// Only import the implementation if not in CI
|
|
42
|
+
const { getBackgroundProcessInfoString } = await Promise.resolve().then(() => __importStar(require('../../background-process-manager')));
|
|
43
|
+
(0, bun_test_2.describe)('getBackgroundProcessInfoString', () => {
|
|
44
|
+
let dateNowSpy;
|
|
45
|
+
const currentTime = 3000;
|
|
46
|
+
(0, bun_test_2.beforeEach)(() => {
|
|
47
|
+
(0, bun_test_2.spyOn)(Date, 'now').mockReturnValue(currentTime);
|
|
48
|
+
});
|
|
49
|
+
(0, bun_test_2.afterEach)(() => {
|
|
50
|
+
bun_test_2.mock.restore();
|
|
51
|
+
});
|
|
52
|
+
(0, bun_test_1.test)('formats a running process correctly', () => {
|
|
53
|
+
const startTime = 1000;
|
|
54
|
+
const info = {
|
|
55
|
+
pid: 123,
|
|
56
|
+
toolCallId: 'toolCall123',
|
|
57
|
+
command: 'npm test',
|
|
58
|
+
process: mockChildProcess,
|
|
59
|
+
stdoutBuffer: ['test output'],
|
|
60
|
+
stderrBuffer: ['test error'],
|
|
61
|
+
status: 'running',
|
|
62
|
+
startTime,
|
|
63
|
+
endTime: null,
|
|
64
|
+
lastReportedStdoutLength: 0,
|
|
65
|
+
lastReportedStderrLength: 0,
|
|
66
|
+
lastReportedStatus: null,
|
|
67
|
+
};
|
|
68
|
+
const result = getBackgroundProcessInfoString(info);
|
|
69
|
+
(0, bun_test_2.expect)(result).toMatchSnapshot();
|
|
70
|
+
});
|
|
71
|
+
(0, bun_test_1.test)('formats a completed process correctly', () => {
|
|
72
|
+
const startTime = 1000;
|
|
73
|
+
const endTime = 2000;
|
|
74
|
+
const mockCompletedProcess = {
|
|
75
|
+
...mockChildProcess,
|
|
76
|
+
exitCode: 0,
|
|
77
|
+
};
|
|
78
|
+
const info = {
|
|
79
|
+
pid: 456,
|
|
80
|
+
toolCallId: 'toolCall456',
|
|
81
|
+
command: 'npm build',
|
|
82
|
+
process: mockCompletedProcess,
|
|
83
|
+
stdoutBuffer: ['build successful'],
|
|
84
|
+
stderrBuffer: [],
|
|
85
|
+
status: 'completed',
|
|
86
|
+
startTime,
|
|
87
|
+
endTime,
|
|
88
|
+
lastReportedStdoutLength: 0,
|
|
89
|
+
lastReportedStderrLength: 0,
|
|
90
|
+
lastReportedStatus: null,
|
|
91
|
+
};
|
|
92
|
+
const result = getBackgroundProcessInfoString(info);
|
|
93
|
+
(0, bun_test_2.expect)(result).toMatchSnapshot();
|
|
94
|
+
});
|
|
95
|
+
(0, bun_test_1.test)('formats an errored process correctly', () => {
|
|
96
|
+
const startTime = 1000;
|
|
97
|
+
const endTime = 2500;
|
|
98
|
+
const mockErroredProcess = {
|
|
99
|
+
...mockChildProcess,
|
|
100
|
+
exitCode: 1,
|
|
101
|
+
signalCode: 'SIGTERM',
|
|
102
|
+
};
|
|
103
|
+
const info = {
|
|
104
|
+
pid: 789,
|
|
105
|
+
toolCallId: 'toolCall789',
|
|
106
|
+
command: 'invalid-command',
|
|
107
|
+
process: mockErroredProcess,
|
|
108
|
+
stdoutBuffer: [],
|
|
109
|
+
stderrBuffer: ['command not found'],
|
|
110
|
+
status: 'error',
|
|
111
|
+
startTime,
|
|
112
|
+
endTime,
|
|
113
|
+
lastReportedStdoutLength: 0,
|
|
114
|
+
lastReportedStderrLength: 0,
|
|
115
|
+
lastReportedStatus: null,
|
|
116
|
+
};
|
|
117
|
+
const result = getBackgroundProcessInfoString(info);
|
|
118
|
+
(0, bun_test_2.expect)(result).toMatchSnapshot();
|
|
119
|
+
});
|
|
120
|
+
(0, bun_test_1.test)('returns empty string for completed process with no changes', () => {
|
|
121
|
+
const startTime = 1000;
|
|
122
|
+
const endTime = 2000;
|
|
123
|
+
const info = {
|
|
124
|
+
pid: 101,
|
|
125
|
+
toolCallId: 'toolCall101',
|
|
126
|
+
command: 'echo test',
|
|
127
|
+
process: mockChildProcess,
|
|
128
|
+
stdoutBuffer: ['test'],
|
|
129
|
+
stderrBuffer: [],
|
|
130
|
+
status: 'completed',
|
|
131
|
+
startTime,
|
|
132
|
+
endTime,
|
|
133
|
+
lastReportedStdoutLength: 4, // Length of 'test'
|
|
134
|
+
lastReportedStderrLength: 0,
|
|
135
|
+
lastReportedStatus: 'completed',
|
|
136
|
+
};
|
|
137
|
+
const result = getBackgroundProcessInfoString(info);
|
|
138
|
+
(0, bun_test_2.expect)(result).toBe('');
|
|
139
|
+
});
|
|
140
|
+
(0, bun_test_1.test)('handles new output since last report', () => {
|
|
141
|
+
const startTime = 1000;
|
|
142
|
+
const endTime = 2000;
|
|
143
|
+
const info = {
|
|
144
|
+
pid: 102,
|
|
145
|
+
toolCallId: 'toolCall102',
|
|
146
|
+
command: 'echo test',
|
|
147
|
+
process: mockChildProcess,
|
|
148
|
+
stdoutBuffer: ['test', ' more output'],
|
|
149
|
+
stderrBuffer: [],
|
|
150
|
+
status: 'completed',
|
|
151
|
+
startTime,
|
|
152
|
+
endTime,
|
|
153
|
+
lastReportedStdoutLength: 4, // Only 'test' was reported
|
|
154
|
+
lastReportedStderrLength: 0,
|
|
155
|
+
lastReportedStatus: 'completed',
|
|
156
|
+
};
|
|
157
|
+
const result = getBackgroundProcessInfoString(info);
|
|
158
|
+
(0, bun_test_2.expect)(result).toMatchSnapshot();
|
|
159
|
+
});
|
|
160
|
+
(0, bun_test_1.test)('handles no new content', () => {
|
|
161
|
+
const startTime = 1000;
|
|
162
|
+
const endTime = 2000;
|
|
163
|
+
const info = {
|
|
164
|
+
pid: 103,
|
|
165
|
+
toolCallId: 'toolCall103',
|
|
166
|
+
command: 'echo test',
|
|
167
|
+
process: mockChildProcess,
|
|
168
|
+
stdoutBuffer: ['test'],
|
|
169
|
+
stderrBuffer: [],
|
|
170
|
+
status: 'running',
|
|
171
|
+
startTime,
|
|
172
|
+
endTime,
|
|
173
|
+
lastReportedStdoutLength: 4, // All content reported
|
|
174
|
+
lastReportedStderrLength: 0,
|
|
175
|
+
lastReportedStatus: 'running',
|
|
176
|
+
};
|
|
177
|
+
const result = getBackgroundProcessInfoString(info);
|
|
178
|
+
(0, bun_test_2.expect)(result).toMatchSnapshot();
|
|
179
|
+
});
|
|
180
|
+
(0, bun_test_1.test)('handles new stderr without when no previous stderr', () => {
|
|
181
|
+
const startTime = 1000;
|
|
182
|
+
const endTime = 2000;
|
|
183
|
+
const info = {
|
|
184
|
+
pid: 104,
|
|
185
|
+
toolCallId: 'toolCall104',
|
|
186
|
+
command: 'echo test',
|
|
187
|
+
process: mockChildProcess,
|
|
188
|
+
stdoutBuffer: [],
|
|
189
|
+
stderrBuffer: ['new error'],
|
|
190
|
+
status: 'error',
|
|
191
|
+
startTime,
|
|
192
|
+
endTime,
|
|
193
|
+
lastReportedStdoutLength: 0,
|
|
194
|
+
lastReportedStderrLength: 0, // No previous stderr
|
|
195
|
+
lastReportedStatus: null,
|
|
196
|
+
};
|
|
197
|
+
const result = getBackgroundProcessInfoString(info);
|
|
198
|
+
(0, bun_test_2.expect)(result).toMatchSnapshot();
|
|
199
|
+
});
|
|
200
|
+
(0, bun_test_1.test)('handles new stdout without when no previous stdout', () => {
|
|
201
|
+
const startTime = 1000;
|
|
202
|
+
const info = {
|
|
203
|
+
pid: 105,
|
|
204
|
+
toolCallId: 'toolCall105',
|
|
205
|
+
command: 'echo test',
|
|
206
|
+
process: mockChildProcess,
|
|
207
|
+
stdoutBuffer: ['first output'],
|
|
208
|
+
stderrBuffer: [],
|
|
209
|
+
status: 'running',
|
|
210
|
+
startTime,
|
|
211
|
+
endTime: null,
|
|
212
|
+
lastReportedStdoutLength: 0, // No previous stdout
|
|
213
|
+
lastReportedStderrLength: 0,
|
|
214
|
+
lastReportedStatus: null,
|
|
215
|
+
};
|
|
216
|
+
const result = getBackgroundProcessInfoString(info);
|
|
217
|
+
(0, bun_test_2.expect)(result).toMatchSnapshot();
|
|
218
|
+
});
|
|
219
|
+
(0, bun_test_1.test)('reports completed process with new stderr even if stdout unchanged', () => {
|
|
220
|
+
const startTime = 1000;
|
|
221
|
+
const endTime = 2000;
|
|
222
|
+
const info = {
|
|
223
|
+
pid: 106,
|
|
224
|
+
toolCallId: 'toolCall106',
|
|
225
|
+
command: 'echo test',
|
|
226
|
+
process: mockChildProcess,
|
|
227
|
+
stdoutBuffer: ['test'],
|
|
228
|
+
stderrBuffer: ['new error'],
|
|
229
|
+
status: 'completed',
|
|
230
|
+
startTime,
|
|
231
|
+
endTime,
|
|
232
|
+
lastReportedStdoutLength: 4, // All stdout reported
|
|
233
|
+
lastReportedStderrLength: 0, // No stderr reported
|
|
234
|
+
lastReportedStatus: 'completed',
|
|
235
|
+
};
|
|
236
|
+
const result = getBackgroundProcessInfoString(info);
|
|
237
|
+
(0, bun_test_2.expect)(result).toMatchSnapshot();
|
|
238
|
+
});
|
|
239
|
+
(0, bun_test_1.test)('reports completed process with new stdout even if stderr unchanged', () => {
|
|
240
|
+
const startTime = 1000;
|
|
241
|
+
const endTime = 2000;
|
|
242
|
+
const info = {
|
|
243
|
+
pid: 107,
|
|
244
|
+
toolCallId: 'toolCall107',
|
|
245
|
+
command: 'echo test',
|
|
246
|
+
process: mockChildProcess,
|
|
247
|
+
stdoutBuffer: ['test', ' more'],
|
|
248
|
+
stderrBuffer: ['error'],
|
|
249
|
+
status: 'completed',
|
|
250
|
+
startTime,
|
|
251
|
+
endTime,
|
|
252
|
+
lastReportedStdoutLength: 4, // Only 'test' reported
|
|
253
|
+
lastReportedStderrLength: 5, // All stderr reported
|
|
254
|
+
lastReportedStatus: 'completed',
|
|
255
|
+
};
|
|
256
|
+
const result = getBackgroundProcessInfoString(info);
|
|
257
|
+
(0, bun_test_2.expect)(result).toMatchSnapshot();
|
|
258
|
+
});
|
|
259
|
+
(0, bun_test_1.test)('reports process when status changes even without output changes', () => {
|
|
260
|
+
const startTime = 1000;
|
|
261
|
+
const endTime = 2000;
|
|
262
|
+
const info = {
|
|
263
|
+
pid: 108,
|
|
264
|
+
toolCallId: 'toolCall108',
|
|
265
|
+
command: 'echo test',
|
|
266
|
+
process: mockChildProcess,
|
|
267
|
+
stdoutBuffer: ['test'],
|
|
268
|
+
stderrBuffer: [],
|
|
269
|
+
status: 'completed',
|
|
270
|
+
startTime,
|
|
271
|
+
endTime,
|
|
272
|
+
lastReportedStdoutLength: 4, // All output reported
|
|
273
|
+
lastReportedStderrLength: 0,
|
|
274
|
+
lastReportedStatus: 'running', // Status changed from running to completed
|
|
275
|
+
};
|
|
276
|
+
const result = getBackgroundProcessInfoString(info);
|
|
277
|
+
(0, bun_test_2.expect)(result).toMatchSnapshot();
|
|
278
|
+
});
|
|
279
|
+
(0, bun_test_1.test)('calculates duration from endTime when available', () => {
|
|
280
|
+
const startTime = 1000;
|
|
281
|
+
const endTime = 2500;
|
|
282
|
+
const info = {
|
|
283
|
+
pid: 109,
|
|
284
|
+
toolCallId: 'toolCall109',
|
|
285
|
+
command: 'echo test',
|
|
286
|
+
process: mockChildProcess,
|
|
287
|
+
stdoutBuffer: ['test'],
|
|
288
|
+
stderrBuffer: [],
|
|
289
|
+
status: 'completed',
|
|
290
|
+
startTime,
|
|
291
|
+
endTime,
|
|
292
|
+
lastReportedStdoutLength: 0,
|
|
293
|
+
lastReportedStderrLength: 0,
|
|
294
|
+
lastReportedStatus: null,
|
|
295
|
+
};
|
|
296
|
+
const result = getBackgroundProcessInfoString(info);
|
|
297
|
+
(0, bun_test_2.expect)(result).toMatchSnapshot();
|
|
298
|
+
});
|
|
299
|
+
(0, bun_test_1.test)('calculates duration from current time when no endTime', () => {
|
|
300
|
+
const startTime = 1000;
|
|
301
|
+
const info = {
|
|
302
|
+
pid: 110,
|
|
303
|
+
toolCallId: 'toolCall110',
|
|
304
|
+
command: 'echo test',
|
|
305
|
+
process: mockChildProcess,
|
|
306
|
+
stdoutBuffer: ['test'],
|
|
307
|
+
stderrBuffer: [],
|
|
308
|
+
status: 'running',
|
|
309
|
+
startTime,
|
|
310
|
+
endTime: null,
|
|
311
|
+
lastReportedStdoutLength: 0,
|
|
312
|
+
lastReportedStderrLength: 0,
|
|
313
|
+
lastReportedStatus: null,
|
|
314
|
+
};
|
|
315
|
+
const result = getBackgroundProcessInfoString(info);
|
|
316
|
+
(0, bun_test_2.expect)(result).toMatchSnapshot();
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
})();
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
// Add a skipped describe block for clarity in test reports
|
|
323
|
+
bun_test_2.describe.skip('getBackgroundProcessInfoString (skipped in CI)', () => {
|
|
324
|
+
bun_test_1.test.skip('skipped', () => { });
|
|
149
325
|
});
|
|
150
|
-
|
|
151
|
-
const startTime = 1000;
|
|
152
|
-
const endTime = 2000;
|
|
153
|
-
const info = {
|
|
154
|
-
pid: 104,
|
|
155
|
-
toolCallId: 'toolCall104',
|
|
156
|
-
command: 'echo test',
|
|
157
|
-
process: mockChildProcess,
|
|
158
|
-
stdoutBuffer: [],
|
|
159
|
-
stderrBuffer: ['new error'],
|
|
160
|
-
status: 'error',
|
|
161
|
-
startTime,
|
|
162
|
-
endTime,
|
|
163
|
-
lastReportedStdoutLength: 0,
|
|
164
|
-
lastReportedStderrLength: 0, // No previous stderr
|
|
165
|
-
lastReportedStatus: null,
|
|
166
|
-
};
|
|
167
|
-
const result = (0, background_process_manager_1.getBackgroundProcessInfoString)(info);
|
|
168
|
-
(0, bun_test_2.expect)(result).toMatchSnapshot();
|
|
169
|
-
});
|
|
170
|
-
(0, bun_test_1.test)('handles new stdout without when no previous stdout', () => {
|
|
171
|
-
const startTime = 1000;
|
|
172
|
-
const info = {
|
|
173
|
-
pid: 105,
|
|
174
|
-
toolCallId: 'toolCall105',
|
|
175
|
-
command: 'echo test',
|
|
176
|
-
process: mockChildProcess,
|
|
177
|
-
stdoutBuffer: ['first output'],
|
|
178
|
-
stderrBuffer: [],
|
|
179
|
-
status: 'running',
|
|
180
|
-
startTime,
|
|
181
|
-
endTime: null,
|
|
182
|
-
lastReportedStdoutLength: 0, // No previous stdout
|
|
183
|
-
lastReportedStderrLength: 0,
|
|
184
|
-
lastReportedStatus: null,
|
|
185
|
-
};
|
|
186
|
-
const result = (0, background_process_manager_1.getBackgroundProcessInfoString)(info);
|
|
187
|
-
(0, bun_test_2.expect)(result).toMatchSnapshot();
|
|
188
|
-
});
|
|
189
|
-
(0, bun_test_1.test)('reports completed process with new stderr even if stdout unchanged', () => {
|
|
190
|
-
const startTime = 1000;
|
|
191
|
-
const endTime = 2000;
|
|
192
|
-
const info = {
|
|
193
|
-
pid: 106,
|
|
194
|
-
toolCallId: 'toolCall106',
|
|
195
|
-
command: 'echo test',
|
|
196
|
-
process: mockChildProcess,
|
|
197
|
-
stdoutBuffer: ['test'],
|
|
198
|
-
stderrBuffer: ['new error'],
|
|
199
|
-
status: 'completed',
|
|
200
|
-
startTime,
|
|
201
|
-
endTime,
|
|
202
|
-
lastReportedStdoutLength: 4, // All stdout reported
|
|
203
|
-
lastReportedStderrLength: 0, // No stderr reported
|
|
204
|
-
lastReportedStatus: 'completed',
|
|
205
|
-
};
|
|
206
|
-
const result = (0, background_process_manager_1.getBackgroundProcessInfoString)(info);
|
|
207
|
-
(0, bun_test_2.expect)(result).toMatchSnapshot();
|
|
208
|
-
});
|
|
209
|
-
(0, bun_test_1.test)('reports completed process with new stdout even if stderr unchanged', () => {
|
|
210
|
-
const startTime = 1000;
|
|
211
|
-
const endTime = 2000;
|
|
212
|
-
const info = {
|
|
213
|
-
pid: 107,
|
|
214
|
-
toolCallId: 'toolCall107',
|
|
215
|
-
command: 'echo test',
|
|
216
|
-
process: mockChildProcess,
|
|
217
|
-
stdoutBuffer: ['test', ' more'],
|
|
218
|
-
stderrBuffer: ['error'],
|
|
219
|
-
status: 'completed',
|
|
220
|
-
startTime,
|
|
221
|
-
endTime,
|
|
222
|
-
lastReportedStdoutLength: 4, // Only 'test' reported
|
|
223
|
-
lastReportedStderrLength: 5, // All stderr reported
|
|
224
|
-
lastReportedStatus: 'completed',
|
|
225
|
-
};
|
|
226
|
-
const result = (0, background_process_manager_1.getBackgroundProcessInfoString)(info);
|
|
227
|
-
(0, bun_test_2.expect)(result).toMatchSnapshot();
|
|
228
|
-
});
|
|
229
|
-
(0, bun_test_1.test)('reports process when status changes even without output changes', () => {
|
|
230
|
-
const startTime = 1000;
|
|
231
|
-
const endTime = 2000;
|
|
232
|
-
const info = {
|
|
233
|
-
pid: 108,
|
|
234
|
-
toolCallId: 'toolCall108',
|
|
235
|
-
command: 'echo test',
|
|
236
|
-
process: mockChildProcess,
|
|
237
|
-
stdoutBuffer: ['test'],
|
|
238
|
-
stderrBuffer: [],
|
|
239
|
-
status: 'completed',
|
|
240
|
-
startTime,
|
|
241
|
-
endTime,
|
|
242
|
-
lastReportedStdoutLength: 4, // All output reported
|
|
243
|
-
lastReportedStderrLength: 0,
|
|
244
|
-
lastReportedStatus: 'running', // Status changed from running to completed
|
|
245
|
-
};
|
|
246
|
-
const result = (0, background_process_manager_1.getBackgroundProcessInfoString)(info);
|
|
247
|
-
(0, bun_test_2.expect)(result).toMatchSnapshot();
|
|
248
|
-
});
|
|
249
|
-
(0, bun_test_1.test)('calculates duration from endTime when available', () => {
|
|
250
|
-
const startTime = 1000;
|
|
251
|
-
const endTime = 2500;
|
|
252
|
-
const info = {
|
|
253
|
-
pid: 109,
|
|
254
|
-
toolCallId: 'toolCall109',
|
|
255
|
-
command: 'echo test',
|
|
256
|
-
process: mockChildProcess,
|
|
257
|
-
stdoutBuffer: ['test'],
|
|
258
|
-
stderrBuffer: [],
|
|
259
|
-
status: 'completed',
|
|
260
|
-
startTime,
|
|
261
|
-
endTime,
|
|
262
|
-
lastReportedStdoutLength: 0,
|
|
263
|
-
lastReportedStderrLength: 0,
|
|
264
|
-
lastReportedStatus: null,
|
|
265
|
-
};
|
|
266
|
-
const result = (0, background_process_manager_1.getBackgroundProcessInfoString)(info);
|
|
267
|
-
(0, bun_test_2.expect)(result).toMatchSnapshot();
|
|
268
|
-
});
|
|
269
|
-
(0, bun_test_1.test)('calculates duration from current time when no endTime', () => {
|
|
270
|
-
const startTime = 1000;
|
|
271
|
-
const info = {
|
|
272
|
-
pid: 110,
|
|
273
|
-
toolCallId: 'toolCall110',
|
|
274
|
-
command: 'echo test',
|
|
275
|
-
process: mockChildProcess,
|
|
276
|
-
stdoutBuffer: ['test'],
|
|
277
|
-
stderrBuffer: [],
|
|
278
|
-
status: 'running',
|
|
279
|
-
startTime,
|
|
280
|
-
endTime: null,
|
|
281
|
-
lastReportedStdoutLength: 0,
|
|
282
|
-
lastReportedStderrLength: 0,
|
|
283
|
-
lastReportedStatus: null,
|
|
284
|
-
};
|
|
285
|
-
const result = (0, background_process_manager_1.getBackgroundProcessInfoString)(info);
|
|
286
|
-
(0, bun_test_2.expect)(result).toMatchSnapshot();
|
|
287
|
-
});
|
|
288
|
-
});
|
|
326
|
+
}
|
|
289
327
|
//# sourceMappingURL=background-process-manager.test.js.map
|