Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 26 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/core/src/tools/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import type {
ShellOutputEvent,
} from '../services/shellExecutionService.js';
import { ShellExecutionService } from '../services/shellExecutionService.js';
import { formatMemoryUsage } from '../utils/formatters.js';
import { formatBytes } from '../utils/formatters.js';
import type { AnsiOutput } from '../utils/terminalSerializer.js';
import {
getCommandRoots,
Expand Down Expand Up @@ -221,7 +221,7 @@ export class ShellToolInvocation extends BaseToolInvocation<
break;
case 'binary_progress':
isBinaryStream = true;
cumulativeOutput = `[Receiving binary output... ${formatMemoryUsage(
cumulativeOutput = `[Receiving binary output... ${formatBytes(
event.bytesReceived,
)} received]`;
if (Date.now() - lastUpdateTime > OUTPUT_UPDATE_INTERVAL_MS) {
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/utils/formatters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { describe, it, expect } from 'vitest';

import { bytesToMB, formatMemoryUsage } from './formatters.js';
import { bytesToMB, formatBytes } from './formatters.js';

describe('bytesToMB', () => {
it('converts bytes to megabytes', () => {
Expand All @@ -16,16 +16,16 @@ describe('bytesToMB', () => {
});
});

describe('formatMemoryUsage', () => {
describe('formatBytes', () => {
it('formats values below one megabyte in KB', () => {
expect(formatMemoryUsage(512 * 1024)).toBe('512.0 KB');
expect(formatBytes(512 * 1024)).toBe('512.0 KB');
});

it('formats values below one gigabyte in MB', () => {
expect(formatMemoryUsage(5 * 1024 * 1024)).toBe('5.0 MB');
expect(formatBytes(5 * 1024 * 1024)).toBe('5.0 MB');
});

it('formats values of one gigabyte or larger in GB', () => {
expect(formatMemoryUsage(2 * 1024 * 1024 * 1024)).toBe('2.00 GB');
expect(formatBytes(2 * 1024 * 1024 * 1024)).toBe('2.00 GB');
});
});
2 changes: 1 addition & 1 deletion packages/core/src/utils/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

export const bytesToMB = (bytes: number): number => bytes / (1024 * 1024);

export const formatMemoryUsage = (bytes: number): string => {
export const formatBytes = (bytes: number): string => {
const gb = bytes / (1024 * 1024 * 1024);
if (bytes < 1024 * 1024) {
return `${(bytes / 1024).toFixed(1)} KB`;
Expand Down
Loading