Skip to content

Conversation

@declanjackson
Copy link
Contributor

@declanjackson declanjackson commented Jan 16, 2026

Refactor of logging and clean up of E2B functionality

Summary

This PR refactors the logging system and makes several improvements to tool execution, particularly for E2B code execution. It also switches the HTML parsing library from jsdom/@mozilla/readability to cheerio for a lighter dependency footprint.

Changes

Structured Logging Overhaul (src/utils/logging/structured-logger.ts)

  • Replaced plain text logging with styled boxen boxes for assistant messages and tool results
  • Tool results now show in their own boxes with success/failure indicators (✓/✗)
  • Added tool call arguments display with formatted key-value pairs
  • Shows turn information in box titles (e.g., "Turn 2/5")
  • Dynamic terminal width support for responsive output
  • Changed from tool:start to tool:complete event for logging (shows results instead of just invocations)
  • Path normalization now prepends outputDir to relative paths in final summary

E2B Code Execution Changes (src/tools/code-exec/e2b.ts)

  • Switched from sandbox.runCode() to sandbox.commands.run() - executes via shell instead of Python interpreter
  • File reads now use format: 'bytes' for proper binary file support
  • Removed redundant error handling for "invalid argument" cases
  • Removed CDATA wrappers from stdout/stderr in XML output

Web Scraping Library Swap

  • Replaced jsdom + @mozilla/readability with cheerio
  • Lighter dependency footprint (removes ~450 lines of package-lock entries)
  • Manual content extraction by removing non-content elements (scripts, styles, nav, footer, etc.)
  • Falls back to body content if no main content area found

Agent Core Changes (src/core/agent.ts)

  • Assistant messages now emit before tool execution (correct log ordering)
  • run:complete event now includes outputDir for path resolution
  • Removed duplicate message:assistant emission from run loop

Examples & Documentation

  • Added new examples/e2b-example.ts - complete E2B usage example
  • Added examples for structured logging (Example 4) and combined events + logging (Example 5) in events-example.ts
  • Updated sub-agent.ts with E2B integration and improved system prompts
  • Added link to E2B example in documentation

Other Fixes

  • Finish tool description now emphasizes including file paths in output
  • Removed unnecessary console.log from custom-tool.ts example

Dependencies

Added:

  • cheerio ^1.1.2
  • @types/cheerio ^0.22.35

Removed:

  • jsdom ^25.0.1
  • @types/jsdom ^27.0.0
  • @mozilla/readability ^0.6.0

Logging updates:

CleanShot 2026-01-16 at 15 09 06@2x

@georgewritescode georgewritescode merged commit 575672b into main Jan 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants