Commit Graph

151 Commits

Author SHA1 Message Date
adragos
e0b67ad2f1 feat: add Security Analyzer functionality (#3058)
* feat: Initial work on security analyzer

* feat: Add remote invariant client

* chore: improve fault tolerance of client

* feat: Add button to enable Invariant Security Analyzer

* [feat] confirmation mode for bash actions

* feat: Add Invariant Tab with security risk outputs

* feat: Add modal setting for Confirmation Mode

* fix: frontend tests for confirmation mode switch

* fix: add missing CONFIRMATION_MODE value in SettingsModal.test.tsx

* fix: update test to integrate new setting

* feat: Initial work on security analyzer

* feat: Add remote invariant client

* chore: improve fault tolerance of client

* feat: Add button to enable Invariant Security Analyzer

* feat: Add Invariant Tab with security risk outputs

* feat: integrate security analyzer with confirmation mode

* feat: improve invariant analyzer tab

* feat: Implement user confirmation for running bash/python code

* fix: don't display rejected actions

* fix: make confirmation show only on assistant messages

* feat: download traces, update policy, implement settings, auto-approve based on defined risk

* Fix: low risk not being shown because it's 0

* fix: duplicate logs in tab

* fix: log duplication

* chore: prepare for merge, remove logging

* Merge confirmation_mode from OpenDevin main

* test: update tests to pass

* chore: finish merging changes, security analyzer now operational again

* feat: document Security Analyzers

* refactor: api, monitor

* chore: lint, fix risk None, revert policy

* fix: check security_risk for None

* refactor: rename instances of invariant to security analyzer

* feat: add /api/options/security-analyzers endpoint

* Move security analyzer from tab to modal

* Temporary fix lock when security analyzer is not chosen

* feat: don't show lock at all when security analyzer is not enabled

* refactor:
- Frontend:
* change type of SECURITY_ANALYZER from bool to string
* add combobox to select SECURITY_ANALYZER, current options are "invariant and "" (no security analyzer)
* Security is now a modal, lock in bottom right is visible only if there's a security analyzer selected
- Backend:
* add close to SecurityAnalyzer
* instantiate SecurityAnalyzer based on provided string from frontend

* fix: update close to be async, to be consistent with other close on resources

* fix: max height of modal (prevent overflow)

* feat: add logo

* small fixes

* update docs for creating a security analyzer module

* fix linting

* update timeout for http client

* fix: move security_analyzer config from agent to session

* feat: add security_risk to browser actions

* add optional remark on combobox

* fix: asdict not called on dataclass, remove invariant dependency

* fix: exclude None values when serializing

* feat: take default policy from invariant-server instead of being hardcoded

* fix: check if policy is None

* update image name

* test: fix some failing runs

* fix: security analyzer tests

* refactor: merge confirmation_mode and security_analyzer into SecurityConfig. Change invariant error message for docker

* test: add tests for invariant parsing actions / observations

* fix: python linting for test_security.py

* Apply suggestions from code review

Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>

* use ActionSecurityRisk | None intead of Optional

* refactor action parsing

* add extra check

* lint parser.py

* test: add field keep_prompt to test_security

* docs: add information about how to enable the analyzer

* test: Remove trailing whitespace in README.md text

---------

Co-authored-by: Mislav Balunovic <mislav.balunovic@gmail.com>
Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
Co-authored-by: Xingyao Wang <xingyao6@illinois.edu>
2024-08-13 11:29:41 +00:00
tofarr
040b9cb75c Chore Readme updates (#3302)
* Readme updates

Added explicit installation instructions to server and frontend README

* Documentation update

* WIP

* WIP

---------

Co-authored-by: Tim O'Farrell <tofarr@Tims-MacBook-Pro-2.local>
2024-08-08 18:06:58 -04:00
Xingyao Wang
90d0a62469 (arch) Switch default runtime to EventStream Runtime (#3271)
* switch default to eventstream runtime

* remove pull docker from makefile

* fix unittest

* fix file store path

* try deprecate server runtime

* remove persist sandbox

* move file utils

* remove server runtime related workflow

* remove unused method

* attempt to remove the reliance on filestore for BE

* fix async for list file

* fix list_files to post

* fix list files

* add suffix to directory

* make sure list file returns abs path;
make sure other backend endpoints accpets abs path

* remove server runtime test workflow

* set git config in runtime
2024-08-08 10:11:49 +08:00
Kaushik Deka
415843476c Feat: Add Vision Input Support for LLM with Vision Capabilities (#2848)
* add image feature

* fix-linting

* check model support for images

* add comment

* Add image support to other models

* Add images to chat

* fix linting

* fix test issues

* refactor variable names and import

* fix tests

* fix chat message tests

* fix linting

* add pydantic class message

* use message

* remove redundant comments

* remove redundant comments

* change Message class

* remove unintended change

* fix integration tests using regenerate.sh

* rename image_bas64 to images_url, fix tests

* rename Message.py to message, change reminder append logic, add unit tests

* remove comment, fix error to merge

* codeact_swe_agent

* fix f string

* update eventstream integration tests

* add missing if check in codeact_swe_agent

* update integration tests

* Update frontend/src/components/chat/ChatInput.tsx

* Update frontend/src/components/chat/ChatInput.tsx

* Update frontend/src/components/chat/ChatInput.tsx

* Update frontend/src/components/chat/ChatInput.tsx

* Update frontend/src/components/chat/ChatMessage.tsx

---------

Co-authored-by: tobitege <tobitege@gmx.de>
Co-authored-by: Xingyao Wang <xingyao6@illinois.edu>
Co-authored-by: sp.wack <83104063+amanape@users.noreply.github.com>
2024-08-04 02:26:22 +08:00
Xingyao Wang
bd68249fba [Arch] Test EventStreamRuntime to ensure its feature parity with ServerRuntime (#3157)
* Remove global config from memory

* Remove runtime global config

* Remove from storage

* Remove global config

* Fix event stream tests

* Fix sandbox issue

* Change config

* Removed transferred tests

* Add swe env box

* Fixes on testing

* Fixed some tests

* Merge with stashed changes

* Fix typing

* Fix ipython test

* Revive function

* Make temp_dir fixture

* Remove test to avoid circular import

* fix eventstream filestore for test_runtime

* fix parse arg issue that cause integration test to fail

* support swebench pull from custom namespace

* add back simple tests for runtime

* move multi-line bash tests to test_runtime;
support multi-line bash for esruntime;

* add testcase to handle PS2 prompt

* use bashlex for bash parsing to handle multi-line commands;
add testcases for multi-line commands

* revert ghcr runtime change

* Apply stash

* fix run as other user;
make test async;

* fix test runtime for run as od

* add run-as-devin to all the runtime tests

* handle the case when username is root

* move all run-as-devin tests from sandbox;
only tests a few cases on different user to save time;

* move over multi-line echo related tests to test_runtime

* fix user-specific jupyter by fixing the pypoetry virtualenv folder

* make plugin's init async;
chdir at initialization of jupyter plugin;
move ipy simple testcase to test runtime;

* support agentskills import in
move tests for jupyter pwd tests;
overload `add_env_vars` for EventStreamRuntime to update env var also in Jupyter;
make agentskills read env var lazily, in case env var is updated;

* fix ServerRuntime agentskills issue

* move agnostic image test to test_runtime

* merge runtime tests in CI

* fix enable auto lint as env var

* update warning message

* update warning message

* test for different container images

* change parsing output as debug

* add exception handling for update_pwd_decorator

* fix unit test indentation

* add plugins as default input to Runtime class;
remove init_sandbox_plugins;
implement add_env_var (include jupyter) in the base class;

* fix server runtime auto lint

* Revert "add exception handling for update_pwd_decorator"

This reverts commit 2b668b1506.

* tries to print debugging info for agentskills

* explictly setting uid (try fix permission issue)

* Revert "tries to print debugging info for agentskills"

This reverts commit 8be4c86756.

* set sandbox user id during testing to hopefully fix the permission issue

* add browser tools for server runtime

* try to debug for old pwd

* update debug cmd

* only test agnostic runtime when TEST_RUNTIME is Server

* fix temp dir mkdir

* load TEST_RUNTIME at the beginning

* remove ipython tests

* only log to file when DEBUG

* default logging to project root

* temporarily remove log to file

* fix LLM logger dir

* fix logger

* make set pwd an optional aux action

* fix prev pwd

* fix infinity recursion

* simplify

* do not import the whole od library to avoid logger folder by jupyter

* fix browsing

* increase timeout

* attempt to fix agentskills yet again

* clean up in testcases, since CI maybe run as non-root

* add _cause attribute for event.id

* remove parent

* add a bunch of debugging statement again for CI :(

* fix temp_dir fixture

* change all temp dir to follow pytest's tmp_path_factory

* remove extra bracket

* clean up error printing a bit

* jupyter chdir to self.config.workspace_mount_path_in_sandbox on initialization

* jupyter chdir to self.config.workspace_mount_path_in_sandbox on initialization

* add typing for tmp dir fixture

* clear the directory before running the test to avoid weird CI temp dir

* remove agnostic test case for server runtime

* Revert "remove agnostic test case for server runtime"

This reverts commit 30e2181c3f.

* disable agnostic tests in CI

* fix test

---------

Co-authored-by: Graham Neubig <neubig@gmail.com>
2024-07-31 04:30:59 +08:00
Engel Nyst
f07280153a restore logging of user messages when using cli (#3145) 2024-07-27 12:58:23 +00:00
Graham Neubig
275ea706cf Remove remaining global config (#3099)
* Remove global config from memory

* Remove runtime global config

* Remove from storage

* Remove global config

* Fix event stream tests

* Fix sandbox issue

* Change config

* Removed transferred tests

* Add swe env box

* Fixes on testing

* Fixed some tests

* Fix typing

* Fix ipython test

* Revive function

* Make temp_dir fixture

* Remove test to avoid circular import
2024-07-26 18:43:32 +00:00
Graham Neubig
4099e48122 Removed config from agent controller (#3038)
* Removed config from agent controller

* Fix tests

* Increase budget

* Update tests

* Update prompts

* Add missing prompt

* Fix mistaken deletions

* Fix browsing test

* Fixed browse tests
2024-07-22 17:42:57 +00:00
Xingyao Wang
6b16a5da0b [Eval,Arch] Update GPTQ eval and add headless_mode for Controller (#2994)
* update and polish gptq eval

* fix typo

* Update evaluation/gpqa/README.md

Co-authored-by: Graham Neubig <neubig@gmail.com>

* Update evaluation/gpqa/run_infer.py

Co-authored-by: Graham Neubig <neubig@gmail.com>

* add headless mode to all appropriate agent controller call

* delegate set to error when in headless mode

* try to deduplicate a bit

* make headless_mode default to True and only change it to false for AgentSession

---------

Co-authored-by: Graham Neubig <neubig@gmail.com>
2024-07-20 03:35:48 +00:00
Graham Neubig
3a21198424 Remove monologue agent (#3036)
* Remove monologue agent

* Fixes
2024-07-19 19:25:05 +00:00
tobitege
d6642c26be Session: set base_url in default_llm_config (#3003) 2024-07-18 22:28:26 -04:00
Graham Neubig
692fe21d60 Remove global config from session (#2987)
* Remove global config from session

* Fix double agent
2024-07-18 15:39:38 +00:00
Xingyao Wang
f80ecec772 [Arch] Add tests for EventStreamRuntime and fix bash parsing (#2933)
* deprecating recall action

* fix integration tests

* fix integration tests

* refractor runtime to use async

* remove search memory

* rename .initialize to .ainit

* draft of runtime image building (separate from img agnostic)

* refractor runtime build into separate file and add unit tests for it

* fix image agnostic tests

* move `split_bash_commands` into a separate util file

* fix bash pexcept parsing for env

* refractor add_env_var from sandbox to runtime;
add test runtime for env var, remove it from sandbox;

* remove unclear comment

* capture broader error

* make `add_env_var` handle multiple export at the same time

* add multi env var test

* fix tests with new config

* make runtime tests a separate ci to avoid full disk

* Update Runtime README with architecture diagram and detailed explanations

* update test

* remove dependency of global config in sandbox test

* fix sandbox typo

* runtime tests does not need ghcr build now

* remove download runtime img

* remove dependency of global config in sandbox test

* fix sandbox typo

* try to free disk before running the tests

* Update opendevin/runtime/client/README.md

Co-authored-by: Yufan Song <33971064+yufansong@users.noreply.github.com>

* Update opendevin/runtime/client/README.md

Co-authored-by: Yufan Song <33971064+yufansong@users.noreply.github.com>

* Update opendevin/runtime/client/README.md

Co-authored-by: Yufan Song <33971064+yufansong@users.noreply.github.com>

* try to reduce code duplication

* Update opendevin/runtime/client/README.md

Co-authored-by: Yufan Song <33971064+yufansong@users.noreply.github.com>

* Update opendevin/runtime/client/README.md

Co-authored-by: Yufan Song <33971064+yufansong@users.noreply.github.com>

* Update opendevin/runtime/client/README.md

Co-authored-by: Yufan Song <33971064+yufansong@users.noreply.github.com>

* Update opendevin/runtime/client/README.md

Co-authored-by: Yufan Song <33971064+yufansong@users.noreply.github.com>

* Update opendevin/runtime/client/README.md

Co-authored-by: Yufan Song <33971064+yufansong@users.noreply.github.com>

* cleanup before setup

* temporarily remove this enable lint test since env var are now handled by runtime

* linter

---------

Co-authored-by: OpenDevin <opendevin@all-hands.dev>
Co-authored-by: Yufan Song <33971064+yufansong@users.noreply.github.com>
2024-07-18 06:10:45 +08:00
Graham Neubig
9f12c77bac Fix bug with model list (#2978) 2024-07-17 15:08:31 +00:00
Graham Neubig
c897791024 Refactor LLM config (#2953)
* Add max_message_chars to LLM

* Refactor LLM config

* Fix tests

* Made some functions class functions

* Fix regression

* Fixed comments
2024-07-17 09:16:04 -04:00
Graham Neubig
01ce1e35b5 Remove global config from auth (#2962) 2024-07-17 06:25:45 -04:00
Graham Neubig
2c982582d7 Remove global config from bedrock (#2954) 2024-07-16 13:16:48 -04:00
Anush Kumar V
8f76587e5c docs: updated docstrings using ruff's autofix feature (#2923)
* Updated documentation using ruff's autofix feature

* Updated pyproject.toml to include docstring validations

* Updated documentation using ruff's autofix feature

* Updated pyproject.toml to include docstring validations

* Updated docstrings using ruff's autfix feature

* Deleted opendevin/runtime/utils/soource.py, Keeping in sync with main

---------

Co-authored-by: Graham Neubig <neubig@gmail.com>
2024-07-16 01:35:33 +00:00
Boxuan Li
f249254ba4 Fix delegator LLM config when config is set from UI (#2913) 2024-07-13 11:31:30 +02:00
Xingyao Wang
7e68de746d arch: refractor eventstream into async (#2907)
* deprecating recall action

* fix integration tests

* fix integration tests

* refractor runtime to use async

* remove search memory

* rename .initialize to .ainit
2024-07-12 20:03:28 +00:00
Xingyao Wang
e45ddeb2a2 arch: deprecating recall action and search_memory (#2900)
* deprecating recall action

* fix integration tests

* fix integration tests

* remove search memory
2024-07-12 19:23:21 +00:00
Xingyao Wang
ced7499f8d fix Runtime import (#2897) 2024-07-11 21:51:57 +00:00
Xingyao Wang
e45d46c993 [Arch] Implement EventStream Runtime Client with Jupyter Support using Agnostic Sandbox (#2879)
* support loading a particular runtime class via config.runtime (default to server to not break things)

* move image agnostic util to shared runtime util

* move dependency

* include poetry.lock in sdist

* accept port as arg for client

* make client start server with specified port

* update image agnostic utility for eventstream runtime

* make client and runtime working with REST API

* rename execute_server

* add plugin to initialize stuff inside es-runtime;
cleanup runtime methods to delegate everything to container

* remove redundant ls -alh

* fix jupyter

* improve logging in agnostic sandbox

* improve logging of test function

* add read & edit

* update agnostic sandbox

* support setting work dir at start

* fix file read/write test

* fix unit test

* update tescase

* Fix unit test again

* fix unit test again again
2024-07-12 01:52:26 +08:00
adragos
5f61885e44 feat: Implement user confirmation mode, request confirmation when running bash/python code in this mode (#2774)
* [feat] confirmation mode for bash actions

* feat: Add modal setting for Confirmation Mode

* fix: frontend tests for confirmation mode switch

* fix: add missing CONFIRMATION_MODE value in SettingsModal.test.tsx

* fix: update test to integrate new setting

* feat: Implement user confirmation for running bash/python code

* fix: don't display rejected actions

* fix: linting, rename/refactor based on feedback

* fix: add property only to commands, pass serialization tests

* fix: package-lock.json, lint test_action_serialization.py

* test: add is_confirmed to integration test outputs

---------

Co-authored-by: Mislav Balunovic <mislav.balunovic@gmail.com>
2024-07-11 14:57:21 +03:00
Boxuan Li
c68478f470 Customize LLM config per agent (#2756)
Currently, OpenDevin uses a global singleton LLM config and a global singleton agent config. This PR allows customers to configure an LLM config for each agent. A hypothetically useful scenario is to use a cheaper LLM for repo exploration / code search, and a more powerful LLM to actually do the problem solving (CodeActAgent).

Partially solves #2075 (web GUI improvement is not the goal of this PR)
2024-07-09 22:05:54 -07:00
மனோஜ்குமார் பழனிச்சாமி
34c765688b Streamline Logging Events (#2532)
* Skip duplicate log

* log user actions

* fix tests

* log all action _step

* refactor log

* revert test

* refactor log

* visual diff

* disable overriding event source

* Revert "disable overriding event source"

This reverts commit b0047cc0cd.

* Refactor logic

* refactored runtime on_event

* fix merge conflict

in Web UI, it shows as red color (seems deletion but added)

* linted

---------

Co-authored-by: Xingyao Wang <xingyao6@illinois.edu>
2024-07-08 05:34:47 +09:00
Xingyao Wang
a47713ecb0 [Arch] Remove supports for Background Commands (#2803)
* depracting docker exec box

* remove doc exec from workflow and docs

* remove background commands

* Update tests/unit/test_sandbox.py

Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>

* replace for-loop with assignment

* fix integration tests

* fix integration tests for shell script

* fix integration tests

* increase max iter to fix some monologue agent issue

* fix integration test again

* fix integration tests (seems related to run_user issue)

---------

Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
2024-07-06 03:38:05 +08:00
Xingyao Wang
0d3b3ffbf8 [Arch] Removing docker exec box (#2802)
* depracting docker exec box

* remove doc exec from workflow and docs
2024-07-04 23:15:25 +00:00
Engel Nyst
0b8d357bef Add event synchronously (#2700)
* add to event stream sync

* remove async from tests
2024-07-05 00:15:51 +02:00
மனோஜ்குமார் பழனிச்சாமி
688bd2a8fc Added local ollama models (#2433)
* added local ollama models

* add ollama_base_url config

* Update listen.py

* add docs

* Update opendevin/server/listen.py

Co-authored-by: Graham Neubig <neubig@gmail.com>

* lint

---------

Co-authored-by: Graham Neubig <neubig@gmail.com>
2024-07-04 15:56:26 +00:00
Leo
c2f557edde refactor: multiple code improvements (#2771) 2024-07-04 18:51:22 +08:00
PierrunoYT
bfa1de4a6b Refactor: Enhance file handling and code editing functionality (#2646)
* refactor: Enhance file handling and code editing functionality

# PR Summary
**refactor: Enhance file handling and code editing functionality**

## PR Description

This pull request includes improvements to file handling, error management, and code editing functionality across multiple files. The changes enhance the robustness, security, and user experience of the application.

### Changes in `listen.py`

1. **Imports and Error Handling**:
   - Removed `warnings` import and its usage with `litellm`.
   - More consistent use of `JSONResponse` and `HTTPException` for error handling.

2. **WebSocket Endpoint (`/ws`)**:
   - Simplified logic for handling events using a single `isinstance` check.

3. **New Endpoint**:
   - Added `/api/save-file` POST endpoint for saving file contents.
   - Implemented checks for agent state before allowing file edits.

4. **Code Style and Organization**:
   - Improved code formatting and organization.
   - Refactored some functions for better readability and consistency.

### Changes in `fileService.ts`

1. **Error Handling**:
   - Added try-catch blocks to all functions for better error handling and logging.

2. **Input Sanitization**:
   - Implemented `encodeURIComponent()` for file names and paths in API requests.

3. **Type Checking**:
   - Added type checks for API responses to ensure data format consistency.

4. **File Upload Improvement**:
   - Refactored `uploadFiles()` to use `Array.from(files)` instead of a for loop.

5. **New Functionality**:
   - Added `saveFile()` function to allow saving file content to a specified path.

### Changes in `CodeEditor.tsx`

1. **New Dependencies**:
   - Added imports for state management, UI components, and file operations.

2. **State Management**:
   - Introduced new state variables for tracking save status and last saved time.
   - Implemented Redux state management for code and agent state.

3. **UI Enhancements**:
   - Added a save button with dynamic colors based on save status.
   - Implemented a save notification system.
   - Added a "Last saved" timestamp display.

4. **File Saving Functionality**:
   - Implemented complete file saving feature with error handling and user feedback.

5. **Code Structure**:
   - Improved structure with additional hooks and memoized values for optimization.

### Testing Performed
- Manually tested new file saving functionality.
- Verified error handling and user feedback mechanisms.
- Checked integration between backend (`listen.py`) and frontend (`fileService.ts`, `CodeEditor.tsx`).

### Next Steps
- Conduct thorough testing of the file saving feature across different scenarios.
- Update documentation to reflect new file handling capabilities.
- Consider adding unit tests for new functions and components.

* Added Docstrings back

Added Docstrings back

* Fix

# Allow Code Editing in AWAITING_USER_INPUT State

## Description
This pull request extends the functionality of the code editor to allow editing when the agent is in the AWAITING_USER_INPUT state, in addition to the existing PAUSED and FINISHED states.

## Changes
1. Backend (`listen.py`):
   - Updated the `save_file` function to allow saving when the agent state is AWAITING_USER_INPUT.

2. Frontend (`CodeEditor.tsx`):
   - Modified the `isEditingAllowed` condition to include the AWAITING_USER_INPUT state.

## Files Changed
- `listen.py`
- `CodeEditor.tsx`

## Testing
- Verified that the save button appears when the agent is in the AWAITING_USER_INPUT state.
- Tested saving files in all three allowed states (PAUSED, FINISHED, AWAITING_USER_INPUT).
- Ensured that saving is still prohibited in other agent states.

## Additional Notes
This change improves the user experience by allowing code edits while the agent is waiting for user input, which is a common scenario in interactive coding sessions.

* Add internationalization for 'File saved successfully' message

# Add internationalization for 'File saved successfully' message

## Description
This PR adds internationalization support for the "File saved successfully" message in the CodeEditor component. It updates the translation.json file to include translations for multiple languages and modifies the CodeEditor.tsx file to use the new translation key.

## Changes
1. Updated `translation.json`:
   - Added a new key `CODE_EDITOR$FILE_SAVED_SUCCESSFULLY` with translations for multiple languages.
   - Ensured the file structure supports multiple languages per key.

2. Modified `CodeEditor.tsx`:
   - Updated the success message to use the new translation key.
   - Applied the translation to both the toast notification and the on-screen notification.

## Why
These changes improve the user experience for non-English speakers by providing localized feedback when a file is successfully saved. This aligns with our goal of making the application more accessible to a global audience.

## How to Test
1. Change the application language to different supported languages.
2. Open the CodeEditor, make changes to a file, and save it.
3. Verify that the "File saved successfully" message appears in the correct language for both the toast and on-screen notifications.

## Additional Notes
Please pay special attention to the structure of the translation.json file to ensure it follows our established patterns for internationalization.

* Add toast notifications for error handling in fileService

# Add toast notifications for error handling in fileService

## Description
This PR enhances the error handling in the `fileService.ts` file by adding toast notifications for user feedback. It maintains the existing console error logging for debugging purposes while improving the user experience by providing visible error messages in the UI.

## Changes
- Added import for the toast utility
- Implemented toast.error() calls in catch blocks for all file operations
- Kept console.error() calls for detailed logging
- Updated error messages to be more user-friendly

## Files Changed
- `src/services/fileService.ts`

## Testing
- Tested all file operations (select, upload, list, save) to ensure proper error handling
- Verified that toast notifications appear when errors are simulated
- Confirmed that console errors are still logged for debugging

## Additional Notes
This change improves error visibility for users without altering the underlying error handling logic. It should make troubleshooting easier for both users and developers.

* Add file path safety check and improve error handling in file services

# Add file path safety check and improve error handling in file services

## Description
This PR enhances the `fileService.ts` by adding a safety check for file paths in the `saveFile` function and improves error handling across all file operations. It also includes new translations for various file-related error messages.

## Changes
1. Updated `src/services/fileService.ts`:
   - Added a validation check for file paths in the saveFile function
   - Improved error handling for all file operations (select, upload, list, save)
   - Implemented toast error messages with translation support

2. Updated `src/i18n/translations.json`:
   - Added new translation keys for file service error messages:
     - FILE_SERVICE$SELECT_FILE_ERROR
     - FILE_SERVICE$UPLOAD_FILES_ERROR
     - FILE_SERVICE$LIST_FILES_ERROR
     - FILE_SERVICE$SAVE_FILE_ERROR
     - FILE_SERVICE$INVALID_FILE_PATH

## Files Changed
- `src/services/fileService.ts`
- `src/i18n/translations.json`

## Key Implementation Details
```typescript
export async function saveFile(filePath: string, content: string): Promise<void> {
  const { t } = useTranslation();
  if (!filePath || filePath.includes('..')) {
    toast.error(t(I18nKey.FILE_SERVICE$INVALID_FILE_PATH));
    throw new Error('Invalid file path');
  }
  try {
    // Existing implementation...
  } catch (error) {
    console.error('Error saving file:', error);
    toast.error(t(I18nKey.FILE_SERVICE$SAVE_FILE_ERROR), 'File Save Error');
    throw error;
  }
}
```

## Testing
- Verified that the saveFile function rejects invalid file paths (empty or containing '..')
- Confirmed that appropriate error messages are displayed using toast notifications for all file operations
- Tested with different languages to ensure translated messages appear correctly

## Security Implications
The file path check in saveFile enhances security by preventing potential directory traversal attacks.

## Next Steps
- Consider adding similar safety checks to other file operations if applicable
- Ensure thorough testing of error scenarios across all supported languages

* Add docstrings to listen.py

# Add docstrings to listen.py

## Description
This PR adds comprehensive docstrings to all functions in the `listen.py` file. These additions improve code documentation, making the file more readable and maintainable for current and future developers.

## Changes
- Added docstrings to all functions in `listen.py`
- Docstrings follow the Google Python Style Guide format
- Included descriptions, parameters, return values, and potential exceptions for each function

## Files Changed
- `src/listen.py`

## Docstring Example
Here's an example of one of the added docstrings:

```python
@app.post('/api/save-file')
async def save_file(request: Request):
    """
    Save a file to the agent's runtime file store.

    This endpoint allows saving a file when the agent is in a paused, finished,
    or awaiting user input state. It checks the agent's state before proceeding
    with the file save operation.

    Args:
        request (Request): The incoming FastAPI request object.

    Returns:
        JSONResponse: A JSON response indicating the success of the operation.

    Raises:
        HTTPException:
            - 403 error if the agent is not in an allowed state for editing.
            - 400 error if the file path or content is missing.
            - 500 error if there's an unexpected error during the save operation.
    """
    # Function implementation...
```

## Impact
- Improved code readability and maintainability
- Better understanding of function purposes, inputs, outputs, and potential errors
- Easier onboarding for new developers working on this file
- Enhanced IDE support for function descriptions and parameter information

## Testing
- No functional changes were made, so existing tests should pass without modification
- Manual review of docstrings for accuracy and completeness is recommended

## Next Steps
- Consider adding similar docstrings to other files in the project for consistency
- Review the added docstrings to ensure they accurately describe the current functionality
- Update docstrings as needed when function implementations change in the future

## Additional Notes
The existing code structure and functionality remain unchanged. This PR focuses solely on improving documentation through the addition of docstrings.

* Revert exclude_list formatting and add docstrings in listen.py

# Revert exclude_list formatting and add docstrings in listen.py

## Description
This PR makes two main changes to the `listen.py` file:
1. Reverts the `exclude_list` in the `list_files` function to its original format, with each item on a separate line.
2. Adds comprehensive docstrings to all functions in the file.

These changes improve code readability, maintain consistency with project standards, and enhance documentation for better maintainability.

## Changes
1. Updated `opendevin/server/listen.py`:
   - Reverted `exclude_list` formatting in `list_files` function
   - Added docstrings to all functions

## Detailed Changes

### 1. Reverted exclude_list formatting
```python
exclude_list = (
    '.git',
    '.DS_Store',
    '.svn',
    '.hg',
    '.idea',
    '.vscode',
    '.settings',
    '.pytest_cache',
    '__pycache__',
    'node_modules',
    'vendor',
    'build',
    'dist',
    'bin',
    'logs',
    'log',
    'tmp',
    'temp',
    'coverage',
    'venv',
    'env',
)
```

### 2. Added docstrings (example)
```python
@app.get('/api/list-files')
def list_files(request: Request, path: str = '/'):
    """
    List files in the specified path.

    This function retrieves a list of files from the agent's runtime file store,
    excluding certain system and hidden files/directories.

    Args:
        request (Request): The incoming request object.
        path (str, optional): The path to list files from. Defaults to '/'.

    Returns:
        list: A list of file names in the specified path.

    Raises:
        HTTPException: If there's an error listing the files.
    """
    # Function implementation...
```

## Rationale
- Reverting `exclude_list` formatting maintains consistency with the project's coding style and ensures proper functioning of pre-commit hooks.
- Adding docstrings improves code documentation, making it easier for developers to understand and maintain the codebase.

## Impact
- Improved code readability and consistency
- Enhanced documentation for all functions in `listen.py`
- Easier onboarding for new developers
- Better IDE support for function descriptions and parameter information

## Testing
- No functional changes were made, so existing tests should pass without modification
- Manual review of the reverted `exclude_list` and new docstrings is recommended

## Additional Notes
- The existing code functionality remains unchanged
- All functions in `listen.py` now have detailed docstrings following the Google Python Style Guide format

## Next Steps
- Review the added docstrings to ensure they accurately describe the current functionality
- Consider adding similar docstrings to other files in the project for consistency
- Update docstrings as needed when function implementations change in the future

* made code reviewable

* fixed ruff issues

* Update listen.py docstrings

* final tweaks

* re-added encodedURIComponent in selectFile

---------

Co-authored-by: tobitege <tobitege@gmx.de>
Co-authored-by: sp.wack <83104063+amanape@users.noreply.github.com>
2024-07-02 09:42:43 +02:00
Leo
5e6fb6131f refactor: Renamed variables to resolve naming conflicts and eliminate warnings (#2732)
* refactor: Renamed variables to resolve naming conflicts and eliminate warnings

Signed-off-by: ifuryst <ifuryst@gmail.com>

* Fix lint failed.

Signed-off-by: ifuryst <ifuryst@gmail.com>

* Combine set_initial_state methods, rename _filed to f, and adjust the AppConfig update codes.

Signed-off-by: ifuryst <ifuryst@gmail.com>

---------

Signed-off-by: ifuryst <ifuryst@gmail.com>
2024-07-02 15:00:58 +08:00
Engel Nyst
2d9bb56763 Add ability to restore the cli session (optional) (#2699)
* add ability to restore the main session

* add quick log

* rename to cli session
2024-06-30 06:56:55 +00:00
Boxuan Li
e45b311c35 Remove MAX_CHARS traffic control (#2694)
* Remove MAX_CHARS limiting

* More cleanup
2024-06-29 12:59:41 -07:00
tobitege
7d31057904 feat: file explorer: better sorting; .gitignore support; file upload config (#2621)
* feat: file explorer: better sorting; .gitignore support; file upload config

* resolved poetry

* move config settings (no extra file); updated uploading of files; fix exception on refresh of removed folder

* removed console cmds; fix in a toast

* attempt fix of upload toasts

* fix new options' assignments in listen.py
2024-06-28 16:36:25 +00:00
Graham Neubig
45d7a53b91 Add links to a feedback sharing site (#2580)
* Add links to a feedback sharing site

* Remove console log

---------

Co-authored-by: sp.wack <83104063+amanape@users.noreply.github.com>
2024-06-22 09:36:31 +02:00
மனோஜ்குமார் பழனிச்சாமி
c743320201 Interactive Terminal (#2493)
* Interactive Terminal

* linted

* fixed tests

* fixed tests

* refactored logic

* remove console logs
2024-06-21 20:56:54 -06:00
Aaron Xia
b5a17efc45 fix: codeact bug [If running a command that never returns, it gets stuck #1895] (#2034)
* fix: codeact bug https://github.com/OpenDevin/OpenDevin/issues/1895

* fix: add CmdRunAction timeout hint.

* Update agenthub/codeact_agent/prompt.py

Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>

* regenerate integration test

---------

Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
Co-authored-by: Graham Neubig <neubig@gmail.com>
Co-authored-by: yufansong <yufan@risingwave-labs.com>
2024-06-08 16:40:23 +00:00
tobitege
5e42f140cb fix: hide special paths; sort models (#2325) 2024-06-08 02:13:11 +00:00
மனோஜ்குமார் பழனிச்சாமி
4e479038f9 Bugfix by added config to disable plugin initialization for Persistent sandbox (#2179)
* refactored source bashrc logic

* added initialize_plugins config

---------

Co-authored-by: Graham Neubig <neubig@gmail.com>
2024-06-04 10:59:30 -04:00
Graham Neubig
74e25920da Transition to gcloud endpoint (#2240) 2024-06-04 01:20:04 +00:00
Graham Neubig
4476c250c5 Add consent dialog (#2169)
* Add consent dialog for sharing conversation histories

* Update

* Update to nextui modals

* Update

* More fixes to modal

* Updates

* Revert most changes to ChatInterface

* Update form

* Cleanup

* Update consent dialog

* Lint

* Fix toast

* Fix to be a select

* prettier

* Update frontend/src/components/chat/ChatInterface.tsx

Co-authored-by: sp.wack <83104063+amanape@users.noreply.github.com>

* Update frontend/src/components/modals/feedback/FeedbackModal.tsx

Co-authored-by: sp.wack <83104063+amanape@users.noreply.github.com>

* Update frontend/src/components/modals/feedback/FeedbackModal.tsx

Co-authored-by: sp.wack <83104063+amanape@users.noreply.github.com>

* Update frontend/src/components/chat/ChatInterface.tsx

Co-authored-by: sp.wack <83104063+amanape@users.noreply.github.com>

* Fix

---------

Co-authored-by: OpenDevin <opendevin@opendevin.ai>
Co-authored-by: sp.wack <83104063+amanape@users.noreply.github.com>
2024-06-03 14:33:53 +00:00
மனோஜ்குமார் பழனிச்சாமி
3a4dc5c68c Initialized plugins only once for persistent sandboxes (#2162) 2024-06-01 10:46:09 +05:30
Aaron Xia
42c6b506b5 Lazy launching BrowseEnv / making BrowseEnv optional (#2155)
* feat: lazy launching browser; browser optional for diffrent agents.

* style: lint

* fix: integration test fail due to browser not started.

* fix: run by cli and integration test failed.

* fix: lint

* fix: lint

---------

Co-authored-by: Graham Neubig <neubig@gmail.com>
2024-05-31 16:40:42 -04:00
Graham Neubig
6596d5c799 Fix: Feedback should be sent through the backend to avoid CORS issues (#2046)
* Fix: Feedback should be sent through the backend to avoid CORS issues

* Update

* Fix merge error

* Revert unnecessary change

* Lint

* Moved to services

* Fixed bugs

---------

Co-authored-by: OpenDevin <opendevin@opendevin.ai>
2024-05-31 15:00:09 -04:00
Graham Neubig
7a2122ebc2 Default to gpt-4o (#2158)
* Default to gpt-4o

* Fix default
2024-05-31 14:44:07 +00:00
Yoni
3c5c214d87 Fix: serve UI from fastAPI app (#2086) 2024-05-27 18:56:13 +05:30
Aaron Xia
b66a915de1 feat: auto clean session with session close called. (#1990)
* feat: auto clean session with session close called.

* fix: lint

* fix: lint

* fix: lint

---------

Co-authored-by: Graham Neubig <neubig@gmail.com>
Co-authored-by: Xingyao Wang <xingyao6@illinois.edu>
2024-05-27 11:08:24 +08:00
Robert Brennan
ea9c785075 fix session state after resuming (#1999)
* fix state resuming

* fix session reconnection

* fix lint
2024-05-23 11:47:36 -04:00