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.
Files changed (45) hide show
  1. package/dist/client.d.ts +1 -1
  2. package/dist/client.js +1 -0
  3. package/dist/client.js.map +1 -1
  4. package/dist/common/actions.d.ts +13 -10
  5. package/dist/common/actions.js +1 -0
  6. package/dist/common/actions.js.map +1 -1
  7. package/dist/common/analytics.js +3 -3
  8. package/dist/common/analytics.js.map +1 -1
  9. package/dist/common/constants/tools.d.ts +1 -0
  10. package/dist/common/constants/tools.js +1 -0
  11. package/dist/common/constants/tools.js.map +1 -1
  12. package/dist/common/types/agent-state.d.ts +2 -2
  13. package/dist/common/websockets/websocket-schema.d.ts +34 -24
  14. package/dist/index.js +9 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/project-files.d.ts +11 -1
  17. package/dist/project-files.js +30 -8
  18. package/dist/project-files.js.map +1 -1
  19. package/dist/tool-handlers.d.ts +2 -1
  20. package/dist/tool-handlers.js +6 -4
  21. package/dist/tool-handlers.js.map +1 -1
  22. package/dist/update-codebuff.js +3 -2
  23. package/dist/update-codebuff.js.map +1 -1
  24. package/dist/utils/__tests__/background-process-manager.test.js +314 -276
  25. package/dist/utils/__tests__/background-process-manager.test.js.map +1 -1
  26. package/dist/utils/__tests__/file-paths.test.d.ts +1 -0
  27. package/dist/utils/__tests__/file-paths.test.js +37 -0
  28. package/dist/utils/__tests__/file-paths.test.js.map +1 -0
  29. package/dist/utils/__tests__/path.test.d.ts +1 -0
  30. package/dist/utils/__tests__/path.test.js +37 -0
  31. package/dist/utils/__tests__/path.test.js.map +1 -0
  32. package/dist/utils/file-paths.d.ts +9 -0
  33. package/dist/utils/file-paths.js +24 -0
  34. package/dist/utils/file-paths.js.map +1 -0
  35. package/dist/utils/git.d.ts +1 -0
  36. package/dist/utils/git.js +17 -0
  37. package/dist/utils/git.js.map +1 -1
  38. package/dist/utils/path.d.ts +9 -0
  39. package/dist/utils/path.js +27 -0
  40. package/dist/utils/path.js.map +1 -0
  41. package/dist/utils/terminal.js +80 -73
  42. package/dist/utils/terminal.js.map +1 -1
  43. package/dist/utils/tool-renderers.js +15 -0
  44. package/dist/utils/tool-renderers.js.map +1 -1
  45. 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
- (0, bun_test_2.describe)('getBackgroundProcessInfoString', () => {
14
- let dateNowSpy;
15
- const currentTime = 3000;
16
- (0, bun_test_2.beforeEach)(() => {
17
- (0, bun_test_2.spyOn)(Date, 'now').mockReturnValue(currentTime);
18
- });
19
- (0, bun_test_2.afterEach)(() => {
20
- bun_test_2.mock.restore();
21
- });
22
- (0, bun_test_1.test)('formats a running process correctly', () => {
23
- const startTime = 1000;
24
- const info = {
25
- pid: 123,
26
- toolCallId: 'toolCall123',
27
- command: 'npm test',
28
- process: mockChildProcess,
29
- stdoutBuffer: ['test output'],
30
- stderrBuffer: ['test error'],
31
- status: 'running',
32
- startTime,
33
- endTime: null,
34
- lastReportedStdoutLength: 0,
35
- lastReportedStderrLength: 0,
36
- lastReportedStatus: null,
37
- };
38
- const result = (0, background_process_manager_1.getBackgroundProcessInfoString)(info);
39
- (0, bun_test_2.expect)(result).toMatchSnapshot();
40
- });
41
- (0, bun_test_1.test)('formats a completed process correctly', () => {
42
- const startTime = 1000;
43
- const endTime = 2000;
44
- const mockCompletedProcess = {
45
- ...mockChildProcess,
46
- exitCode: 0,
47
- };
48
- const info = {
49
- pid: 456,
50
- toolCallId: 'toolCall456',
51
- command: 'npm build',
52
- process: mockCompletedProcess,
53
- stdoutBuffer: ['build successful'],
54
- stderrBuffer: [],
55
- status: 'completed',
56
- startTime,
57
- endTime,
58
- lastReportedStdoutLength: 0,
59
- lastReportedStderrLength: 0,
60
- lastReportedStatus: null,
61
- };
62
- const result = (0, background_process_manager_1.getBackgroundProcessInfoString)(info);
63
- (0, bun_test_2.expect)(result).toMatchSnapshot();
64
- });
65
- (0, bun_test_1.test)('formats an errored process correctly', () => {
66
- const startTime = 1000;
67
- const endTime = 2500;
68
- const mockErroredProcess = {
69
- ...mockChildProcess,
70
- exitCode: 1,
71
- signalCode: 'SIGTERM',
72
- };
73
- const info = {
74
- pid: 789,
75
- toolCallId: 'toolCall789',
76
- command: 'invalid-command',
77
- process: mockErroredProcess,
78
- stdoutBuffer: [],
79
- stderrBuffer: ['command not found'],
80
- status: 'error',
81
- startTime,
82
- endTime,
83
- lastReportedStdoutLength: 0,
84
- lastReportedStderrLength: 0,
85
- lastReportedStatus: null,
86
- };
87
- const result = (0, background_process_manager_1.getBackgroundProcessInfoString)(info);
88
- (0, bun_test_2.expect)(result).toMatchSnapshot();
89
- });
90
- (0, bun_test_1.test)('returns empty string for completed process with no changes', () => {
91
- const startTime = 1000;
92
- const endTime = 2000;
93
- const info = {
94
- pid: 101,
95
- toolCallId: 'toolCall101',
96
- command: 'echo test',
97
- process: mockChildProcess,
98
- stdoutBuffer: ['test'],
99
- stderrBuffer: [],
100
- status: 'completed',
101
- startTime,
102
- endTime,
103
- lastReportedStdoutLength: 4, // Length of 'test'
104
- lastReportedStderrLength: 0,
105
- lastReportedStatus: 'completed',
106
- };
107
- const result = (0, background_process_manager_1.getBackgroundProcessInfoString)(info);
108
- (0, bun_test_2.expect)(result).toBe('');
109
- });
110
- (0, bun_test_1.test)('handles new output since last report', () => {
111
- const startTime = 1000;
112
- const endTime = 2000;
113
- const info = {
114
- pid: 102,
115
- toolCallId: 'toolCall102',
116
- command: 'echo test',
117
- process: mockChildProcess,
118
- stdoutBuffer: ['test', ' more output'],
119
- stderrBuffer: [],
120
- status: 'completed',
121
- startTime,
122
- endTime,
123
- lastReportedStdoutLength: 4, // Only 'test' was reported
124
- lastReportedStderrLength: 0,
125
- lastReportedStatus: 'completed',
126
- };
127
- const result = (0, background_process_manager_1.getBackgroundProcessInfoString)(info);
128
- (0, bun_test_2.expect)(result).toMatchSnapshot();
129
- });
130
- (0, bun_test_1.test)('handles no new content', () => {
131
- const startTime = 1000;
132
- const endTime = 2000;
133
- const info = {
134
- pid: 103,
135
- toolCallId: 'toolCall103',
136
- command: 'echo test',
137
- process: mockChildProcess,
138
- stdoutBuffer: ['test'],
139
- stderrBuffer: [],
140
- status: 'running',
141
- startTime,
142
- endTime,
143
- lastReportedStdoutLength: 4, // All content reported
144
- lastReportedStderrLength: 0,
145
- lastReportedStatus: 'running',
146
- };
147
- const result = (0, background_process_manager_1.getBackgroundProcessInfoString)(info);
148
- (0, bun_test_2.expect)(result).toMatchSnapshot();
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
- (0, bun_test_1.test)('handles new stderr without when no previous stderr', () => {
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