Commit graph

4786 commits

Author SHA1 Message Date
Steven T. Cramer
7d880f172e Remove any type assertions in DirectiveStreamingParser.ts by introducing ParameterCodeBlockHandler interface 2025-06-17 00:38:08 +07:00
Steven T. Cramer
323d647685 Remove temporary test file debug-test.js 2025-06-16 23:47:25 +07:00
Steven T. Cramer
37dddebf27 refactor: improve type safety in DirectiveStreamingParser 2025-06-16 23:30:33 +07:00
Steven T. Cramer
7471bd51cf Refine type for activeHandler in DirectiveStreamingParser 2025-06-16 23:19:12 +07:00
Steven T. Cramer
d18e110668 refactor: extract duplicated insideToolParameter logic into helper method
- Created isInsideToolParameter() helper method to eliminate code duplication
- Method handles both open and close tag scenarios with optional tagName parameter
- Maintains existing functionality while improving code maintainability
- All tests continue to pass
2025-06-16 22:56:21 +07:00
Steven T. Cramer
e7289bdc33 refactor: extract repeated code block detection logic into method
- Extract isInsideCodeBlock() method from DirectiveStreamingParser
- Replace duplicate code in onopentag and onclosetag handlers
- Add comprehensive test coverage for the extracted logic
- Improve code maintainability and follow DRY principle
2025-06-16 22:51:19 +07:00
Steven T. Cramer
b879dd21b6 Fix DirectiveStreamingParser to prevent processing nested XML tags as directives inside tool parameters
- Modified DirectiveStreamingParser to check if currently inside a tool parameter context
- Added logic to treat nested XML tags as plain text when inside tool directive parameters
- Made currentContext and currentParamName properties public in ToolDirectiveHandler for access
- Updated both onopentag and onclosetag handlers to respect tool parameter boundaries
- Fixes issue where <log_message> tags inside <attempt_completion><result> were being processed as separate directives
- All existing tests continue to pass, new test case now passes
2025-06-16 22:21:38 +07:00
Steven T. Cramer
5ef186300e Fix log message parsing inside code blocks within tool parameters
- Enhanced DirectiveStreamingParser to track code block state within tool parameters
- Fixed FallbackParser to respect code blocks and properly parse nested XML structures
- Added comprehensive tests for both streaming and fallback scenarios
- Prevents log messages inside code blocks from being processed as actual directives

Fixes issue where <log_message> tags inside code blocks within tool parameters
were being parsed as separate log directives instead of plain text content.
2025-06-16 22:01:18 +07:00
Steven T. Cramer
cc1a4df15c Add test for `xml code block scenario
- Add specific test case for `xml code blocks containing log_message directives
- Test passes, confirming the implementation handles this scenario correctly in tests
- However, runtime behavior still differs from test behavior
2025-06-16 20:36:26 +07:00
Steven T. Cramer
51440392be WIP: Implement code block detection for DirectiveStreamingParser
- Add CodeBlockState enum and extend ParseContext with code block tracking
- Create CodeBlockStateMachine to detect ` boundaries and manage state
- Update TextDirectiveHandler to integrate with state machine
- Modify DirectiveStreamingParser to suppress XML parsing inside code blocks
- Add comprehensive tests for code block handling

NOTE: Tests pass but implementation does NOT work in runtime.
The log messages still appear in Output window instead of being treated
as plain text within code blocks. The real parsing flow differs from
test scenarios and needs further investigation.
2025-06-16 20:23:26 +07:00
Steven T. Cramer
f10ab35312 Add test case for directives inside triple backticks 2025-06-16 14:12:05 +07:00
Steven T. Cramer
5efd95a8c5 Update writeToFileTool.test.ts to use specific directive types directly 2025-06-16 13:14:28 +07:00
Steven T. Cramer
4a3f3ebe25 Update useMcpToolTool.test.ts to use specific directive types directly 2025-06-16 13:14:03 +07:00
Steven T. Cramer
2550e8528f Update newTaskTool.test.ts to use specific directive types directly 2025-06-16 13:10:17 +07:00
Steven T. Cramer
2202273cc1 Update tools to use specific directive types for enhanced type safety 2025-06-16 12:24:22 +07:00
Steven T. Cramer
4090116081 Remove unused code 2025-06-16 10:18:30 +07:00
Steven T. Cramer
bdc102c7ee encapsulate/scope logLevels better and remove unused Zod stuff. 2025-06-16 08:43:58 +07:00
Steven T. Cramer
c46ce75b60 fix export 2025-06-16 07:18:51 +07:00
Steven T. Cramer
9e6c124446 Replace export * with explicit 2025-06-16 07:04:07 +07:00
Steven T. Cramer
fda123e7ee Replace wildcard exports with explicit exports in handlers index.ts 2025-06-16 01:25:30 +07:00
Steven T. Cramer
bab0d65558 removed unused import 2025-06-16 01:18:55 +07:00
Steven T. Cramer
1bfc810225 Remove duplicate tests file. 2025-06-16 01:17:17 +07:00
Steven T. Cramer
d5ac15923a Refactor: Move tool directives to individual files in tool-directives directory 2025-06-16 00:03:54 +07:00
Steven T. Cramer
d08b0d300d Rename ToolUse to ToolDirective 2025-06-15 15:14:11 +07:00
Steven T. Cramer
e6333785f3 rename assistant-message to message-parsing 2025-06-15 14:09:06 +07:00
Steven T. Cramer
8914d599cb Update imports to use handlers index.ts and reduce exports to necessary components 2025-06-15 14:00:19 +07:00
Steven T. Cramer
31c51e3109 Add index.ts to handlers directory for easier imports 2025-06-15 13:35:20 +07:00
Steven T. Cramer
6d2b212a88 Reorganize assistant-message 2025-06-15 13:31:54 +07:00
Steven T. Cramer
e3f673a064 Refactor DirectiveStreamingParser for better modularity and fix test failures across all related files 2025-06-15 11:21:23 +07:00
Steven T. Cramer
439022f720 fix: Complete DirectiveStreamingParser refactoring by adding log_message case handler
- Add missing log_message case handler in presentAssistantMessage.ts
- Fix syntax error by adding missing opening brace for tool_use case
- Make LogManager public in Task class to allow access from presentAssistantMessage
- All tests passing (11/11) and TypeScript compilation clean
- Log messages now properly displayed in Roo-Code Output window
2025-06-15 09:35:53 +07:00
Steven T. Cramer
1b9d9e65d9 refactor: Replace manual XML parsing with SAX parser in DirectiveStreamingParser
- Replace character-by-character XML parsing with robust SAX parser library
- Add sax and @types/sax dependencies for reliable XML parsing
- Implement event-driven parsing with onopentag, onclosetag, ontext handlers
- Add XML wrapping to handle multiple root elements in streaming scenarios
- Create hasIncompleteXml() method for proper partial XML detection
- Maintain backward compatibility with existing partial detection logic
- Add comprehensive test suite with 6 new test cases
- Preserve fallback to manual parsing when SAX parser fails
- Improve error handling and maintain all existing functionality

Benefits:
- More robust XML parsing with better edge case handling
- Improved performance with event-driven parsing
- Cleaner, more maintainable code
- Standards-compliant XML parsing
- Full backward compatibility
2025-06-15 08:33:21 +07:00
Steven T. Cramer
2993a3a75e Update DirectiveStreamingParser.ts to import from parsers/index.ts
- Changed imports in DirectiveStreamingParser.ts to use the index.ts file in parsers/ for a cleaner import structure
2025-06-14 17:21:23 +07:00
Steven T. Cramer
9e70691ef7 Refactor assistant message parsing: rename classes and simplify method names
- Moved StreamingParser to DirectiveStreamingParser in assistant-message/
- Renamed directives/ to parsers/
- Created new parser classes with updated names: TextContentParser, ToolUseParser, ParameterParser
- Simplified method names to parse() and finalize()
- Updated documentation in README.md
2025-06-14 17:16:11 +07:00
Steven T. Cramer
47c1dd78d5 Refactor type imports in parseAssistantMessage.ts for clarity 2025-06-14 16:35:21 +07:00
Steven T. Cramer
1d97e1f5bc refactor: break handler classes into separate files
- Extract TextContentHandler into TextContentHandler.ts
- Extract ParameterHandler into ParameterHandler.ts
- Extract ToolUseHandler into ToolUseHandler.ts
- Create types.ts for shared type definitions
- Update StreamingParser to import from separate files
- Update index.ts exports to reference correct files
- Update README.md to reflect new file structure
- Maintain backward compatibility and streaming behavior
- All tests pass, multi-contributor friendly structure
2025-06-14 16:26:28 +07:00
Steven T. Cramer
773075e66c refactor: extract directive parsing into focused classes
- Extract parsing logic from monolithic parseAssistantMessage function
- Create StreamingParser with specialized handler classes:
  - TextContentHandler: handles text content parsing
  - ToolUseHandler: manages tool directive detection and parsing
  - ParameterHandler: processes tool parameters
- Maintain original streaming behavior and backward compatibility
- All tests pass, no breaking changes
- Improve code organization and maintainability
2025-06-14 16:18:18 +07:00
Steven T. Cramer
2928dd390c refactor: rename AssistantMessageContent to Directive with type aliases
- Add TextDirective alias for TextContent
- Add ToolDirective alias for ToolUse
- Add Directive union type for TextDirective | ToolDirective
- Maintain backward compatibility with AssistantMessageContent alias
- Update internal usage to use new type names
2025-06-14 15:16:21 +07:00
Steven T. Cramer
77d9dcdc24 Change exposed port to random generated one vs default 3000 to avoid conflict with numerous other things that just use the default. 2025-06-13 22:25:29 +07:00
Steven T. Cramer
a296dfba87 Merge branch 'main' into Cramer/2025-06-12/evals 2025-06-13 22:15:10 +07:00
Sam Hoang Van
9eb9fabee0
feat(ui): sync BatchDiffApproval styling with BatchFilePermission (#4640) 2025-06-13 09:01:47 -04:00
pugazhendhi-m
2cb02d6512
Add cache breakpoints for custom vertex models on Unbound (#4585)
Co-authored-by: Pugazhendhi <pugazhendhi@unboundsecurity.ai>
2025-06-13 08:29:40 -04:00
Raffael
dc00167289
Update ContextManagementSettings.tsx (#4634)
Allow 5% threshold for context condensing (thats already 50k with gemini 1M context, enough for many tasks)
2025-06-13 06:42:55 -04:00
Steven T. Cramer
2370385655 DONT_PROMPT_WSL_INSTALL doesn't work here so remove. And no longer need increased log level 2025-06-13 16:27:14 +07:00
Steven T. Cramer
814d07dcca revert this too make PR easier. 2025-06-13 16:23:26 +07:00
Steven T. Cramer
a25adf8bbe revert to main 2025-06-13 16:03:02 +07:00
Steven T. Cramer
7a3d2039af Remove more debug code 2025-06-13 15:58:47 +07:00
Steven T. Cramer
13c02b6e59 remove more logging 2025-06-13 15:46:24 +07:00
Steven T. Cramer
341d6a86cb 1 sec backoff 2025-06-13 15:40:12 +07:00
Steven T. Cramer
f8a9d0ffb7 remove troubleshooting stuff 2025-06-13 15:37:56 +07:00
Steven T. Cramer
f4a9450092 Update reconnection logic in useEventSource to prevent excessive retries 2025-06-13 15:26:04 +07:00