mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-04-29 03:00:45 -04:00
Compare commits
3 Commits
fix-bash-c
...
clean-mark
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0de6f9699 | ||
|
|
cc4b663cf7 | ||
|
|
7f9a43e217 |
2
.github/CODEOWNERS
vendored
2
.github/CODEOWNERS
vendored
@@ -2,7 +2,7 @@
|
||||
# See https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
|
||||
|
||||
# Frontend code owners
|
||||
/frontend/ @amanape
|
||||
/frontend/ @rbren @amanape
|
||||
/openhands-ui/ @amanape
|
||||
|
||||
# Evaluation code owners
|
||||
|
||||
@@ -40,7 +40,7 @@ repos:
|
||||
hooks:
|
||||
- id: mypy
|
||||
additional_dependencies:
|
||||
[types-requests, types-setuptools, types-pyyaml, types-toml, types-docker, types-Markdown, pydantic, lxml]
|
||||
[types-requests, types-setuptools, types-pyyaml, types-toml, types-docker, pydantic, lxml]
|
||||
# To see gaps add `--html-report mypy-report/`
|
||||
entry: mypy --config-file dev_config/python/mypy.ini openhands/
|
||||
always_run: true
|
||||
|
||||
@@ -10,6 +10,7 @@ import huggingface_hub
|
||||
import pandas as pd
|
||||
from datasets import load_dataset
|
||||
from PIL import Image
|
||||
from pydantic import SecretStr
|
||||
|
||||
from evaluation.benchmarks.gaia.scorer import question_scorer
|
||||
from evaluation.benchmarks.gaia.utils import (
|
||||
@@ -79,7 +80,8 @@ def get_config(
|
||||
|
||||
config_copy = copy.deepcopy(config)
|
||||
load_from_toml(config_copy)
|
||||
config.search_api_key = config_copy.search_api_key
|
||||
if config_copy.search_api_key:
|
||||
config.search_api_key = SecretStr(config_copy.search_api_key)
|
||||
return config
|
||||
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
This folder contains the evaluation harness that we built on top of the original [SWE-Bench benchmark](https://www.swebench.com/) ([paper](https://arxiv.org/abs/2310.06770)).
|
||||
|
||||
**UPDATE (8/12/2025): We now support running SWE-rebench evaluation (see the paper [here](https://arxiv.org/abs/2505.20411))! For how to run it, checkout [this README](./SWE-rebench.md).**
|
||||
|
||||
**UPDATE (6/15/2025): We now support running SWE-bench-Live evaluation (see the paper [here](https://arxiv.org/abs/2505.23419))! For how to run it, checkout [this README](./SWE-bench-Live.md).**
|
||||
|
||||
**UPDATE (5/26/2025): We now support running interactive SWE-Bench evaluation (see the paper [here](https://arxiv.org/abs/2502.13069))! For how to run it, checkout [this README](./SWE-Interact.md).**
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
# SWE-rebench
|
||||
|
||||
<p align="center">
|
||||
<a href="https://arxiv.org/abs/2505.20411">📃 Paper</a>
|
||||
•
|
||||
<a href="https://huggingface.co/datasets/nebius/SWE-rebench">🤗 HuggingFace</a>
|
||||
•
|
||||
<a href="https://swe-rebench.com/leaderboard">📊 Leaderboard</a>
|
||||
</p>
|
||||
|
||||
SWE-rebench is a large-scale dataset for verifiable software engineering tasks.
|
||||
It comes in **two datasets**:
|
||||
|
||||
* **[`nebius/SWE-rebench-leaderboard`](https://huggingface.co/datasets/nebius/SWE-rebench-leaderboard)** – updatable benchmark used for [leaderboard evaluation](https://swe-rebench.com/leaderboard).
|
||||
* **[`nebius/SWE-rebench`](https://huggingface.co/datasets/nebius/SWE-rebench)** – full dataset with **21,302 tasks**, suitable for training or large-scale offline evaluation.
|
||||
|
||||
This document explains how to run OpenHands on SWE-rebench, using the leaderboard split as the main example.
|
||||
To run on the full dataset, simply replace the dataset name.
|
||||
|
||||
|
||||
## Setting Up
|
||||
|
||||
Set up your development environment and configure your LLM provider by following the [SWE-bench README](README.md) in this directory.
|
||||
|
||||
|
||||
## Running Inference
|
||||
|
||||
Use the existing SWE-bench inference script, changing the dataset to `nebius/SWE-rebench-leaderboard` and selecting the split (`test` for leaderboard submission):
|
||||
|
||||
```bash
|
||||
./evaluation/benchmarks/swe_bench/scripts/run_infer.sh \
|
||||
llm.your_llm HEAD CodeActAgent 30 50 1 nebius/SWE-rebench-leaderboard test
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
* `llm.your_llm` – your model configuration key
|
||||
* `HEAD` – commit reference for reproducibility
|
||||
* `CodeActAgent` – agent type
|
||||
* `10` – number of examples to evaluate
|
||||
* `50` – maximum iterations per task (increase if needed)
|
||||
* `1` – number of workers
|
||||
* `nebius/SWE-rebench-leaderboard` – Hugging Face dataset name
|
||||
* `test` – dataset split
|
||||
|
||||
**Tip:** To run on the **full 21k dataset**, replace `nebius/SWE-rebench-leaderboard` with `nebius/SWE-rebench`.
|
||||
|
||||
|
||||
## Evaluating Results
|
||||
|
||||
After inference completes, evaluate using the [SWE-bench-fork evaluation harness](https://github.com/SWE-rebench/SWE-bench-fork).
|
||||
|
||||
1. Convert the OpenHands output to SWE-bench evaluation format:
|
||||
|
||||
```bash
|
||||
python evaluation/benchmarks/swe_bench/scripts/live/convert.py \
|
||||
--output_jsonl path/to/evaluation/output.jsonl > preds.jsonl
|
||||
```
|
||||
|
||||
2. Clone the SWE-bench-fork repo (https://github.com/SWE-rebench/SWE-bench-fork) and follow its README to install dependencies.
|
||||
|
||||
|
||||
3. Run the evaluation using the fork:
|
||||
|
||||
```bash
|
||||
python -m swebench.harness.run_evaluation \
|
||||
--dataset_name nebius/SWE-rebench-leaderboard \
|
||||
--split test \
|
||||
--predictions_path preds.jsonl \
|
||||
--max_workers 10 \
|
||||
--run_id openhands
|
||||
```
|
||||
|
||||
|
||||
## Citation
|
||||
|
||||
```bibtex
|
||||
@article{badertdinov2025swerebench,
|
||||
title={SWE-rebench: An Automated Pipeline for Task Collection and Decontaminated Evaluation of Software Engineering Agents},
|
||||
author={Badertdinov, Ibragim and Golubev, Alexander and Nekrashevich, Maksim and Shevtsov, Anton and Karasik, Simon and Andriushchenko, Andrei and Trofimova, Maria and Litvintseva, Daria and Yangel, Boris},
|
||||
journal={arXiv preprint arXiv:2505.20411},
|
||||
year={2025}
|
||||
}
|
||||
```
|
||||
65
evaluation/benchmarks/swe_bench/prompts/swe_claude.j2
Normal file
65
evaluation/benchmarks/swe_bench/prompts/swe_claude.j2
Normal file
@@ -0,0 +1,65 @@
|
||||
<uploaded_files>
|
||||
/workspace/{{ workspace_dir_name }}
|
||||
</uploaded_files>
|
||||
|
||||
I've uploaded a python code repository in the directory {{ workspace_dir_name }}. Consider the following issue description:
|
||||
|
||||
<issue_description>
|
||||
{{ instance.problem_statement }}
|
||||
</issue_description>
|
||||
|
||||
Can you help me implement the necessary changes to the repository so that the requirements specified in the <issue_description> are met?
|
||||
I've already taken care of all changes to any of the test files described in the <issue_description>. This means you DON'T have to modify the testing logic or any of the tests in any way!
|
||||
Also the development Python environment is already set up for you (i.e., all dependencies already installed), so you don't need to install other packages.
|
||||
Your task is to make the minimal changes to non-test files in the /workspace/{{ workspace_dir_name }} directory to ensure the <issue_description> is satisfied.
|
||||
|
||||
Follow these phases to resolve the issue:
|
||||
|
||||
Phase 1. READING: read the problem and reword it in clearer terms
|
||||
1.1 If there are code or config snippets. Express in words any best practices or conventions in them.
|
||||
1.2 Hightlight message errors, method names, variables, file names, stack traces, and technical details.
|
||||
1.3 Explain the problem in clear terms.
|
||||
1.4 Enumerate the steps to reproduce the problem.
|
||||
1.5 Hightlight any best practices to take into account when testing and fixing the issue
|
||||
|
||||
Phase 2. RUNNING: install and run the tests on the repository
|
||||
2.1 Follow the readme
|
||||
2.2 Install the environment and anything needed
|
||||
2.2 Iterate and figure out how to run the tests
|
||||
|
||||
Phase 3. EXPLORATION: find the files that are related to the problem and possible solutions
|
||||
3.1 Use `grep` to search for relevant methods, classes, keywords and error messages.
|
||||
3.2 Identify all files related to the problem statement.
|
||||
3.3 Propose the methods and files to fix the issue and explain why.
|
||||
3.4 From the possible file locations, select the most likely location to fix the issue.
|
||||
|
||||
Phase 4. TEST CREATION: before implementing any fix, create a script to reproduce and verify the issue.
|
||||
4.1 Look at existing test files in the repository to understand the test format/structure.
|
||||
4.2 Create a minimal reproduction script that reproduces the located issue.
|
||||
4.3 Run the reproduction script to confirm you are reproducing the issue.
|
||||
4.4 Adjust the reproduction script as necessary.
|
||||
|
||||
Phase 5. FIX ANALYSIS: state clearly the problem and how to fix it
|
||||
5.1 State clearly what the problem is.
|
||||
5.2 State clearly where the problem is located.
|
||||
5.3 State clearly how the test reproduces the issue.
|
||||
5.4 State clearly the best practices to take into account in the fix.
|
||||
5.5 State clearly how to fix the problem.
|
||||
|
||||
Phase 6. FIX IMPLEMENTATION: Edit the source code to implement your chosen solution.
|
||||
6.1 Make minimal, focused changes to fix the issue.
|
||||
|
||||
Phase 7. VERIFICATION: Test your implementation thoroughly.
|
||||
7.1 Run your reproduction script to verify the fix works.
|
||||
7.2 Add edge cases to your test script to ensure comprehensive coverage.
|
||||
7.3 Run existing tests related to the modified code to ensure you haven't broken anything.
|
||||
|
||||
8. FINAL REVIEW: Carefully re-read the problem description and compare your changes with the base commit {{ instance.base_commit }}.
|
||||
8.1 Ensure you've fully addressed all requirements.
|
||||
8.2 Run any tests in the repository related to:
|
||||
8.2.1 The issue you are fixing
|
||||
8.2.2 The files you modified
|
||||
8.2.3 The functions you changed
|
||||
8.3 If any tests fail, revise your implementation until all tests pass
|
||||
|
||||
Be thorough in your exploration, testing, and reasoning. It's fine if your thinking process is lengthy - quality and completeness are more important than brevity.
|
||||
45
evaluation/benchmarks/swe_bench/prompts/swe_gemini.j2
Normal file
45
evaluation/benchmarks/swe_bench/prompts/swe_gemini.j2
Normal file
@@ -0,0 +1,45 @@
|
||||
# Task: Fix Issue in Python Repository
|
||||
|
||||
## Repository Context
|
||||
You are provided with a Python code repository that contains an issue requiring your attention. The repository is located in a sandboxed environment, and you have access to the codebase to implement the necessary changes.
|
||||
The code repository is located at: `/workspace/{{ workspace_dir_name }}`
|
||||
(This path is provided for context; use file system tools to confirm paths before access).
|
||||
|
||||
## Goal
|
||||
Your goal is to fix the issue described in the **Issue Description** section below. Implement the necessary changes to **non-test files only** within the repository, ensuring that **all relevant tests pass** after your changes.
|
||||
|
||||
## Key Requirements & Constraints
|
||||
|
||||
1. **Understand the problem** very well: it is a bug report, and you know humans don't always write good descriptions. Explore the codebase to understand the related code and the problem in depth. It is possible that the solution needs to be a bit more extensive than just the stated text. Don't exagerate though: don't do unrelated refactoring, but also don't interpret the description too strictly.
|
||||
2. **Focus on the issues:** Implement the fix focusing on non-test files related to the issue.
|
||||
2. **Environment Ready:** The Python environment is pre-configured with all dependencies. Do not install packages.
|
||||
3. **Mandatory Testing Procedure:**
|
||||
* **Create Test to Reproduce the Issue:** *Before* implementing any fix, you MUST create a *new test* (separate from existing tests) that specifically reproduces the issue.
|
||||
* Take existing tests as example to understand the testing format/structure.
|
||||
* Enhance this test with edge cases.
|
||||
* Run this test to confirm reproduction.
|
||||
* **Verify Fix:** After implementing the fix, run your test again to verify the issue is resolved.
|
||||
* **Identify ALL Relevant Tests:** You MUST perform a **dedicated search and analysis** to identify **all** existing unit tests potentially affected by your changes. This includes:
|
||||
* Tests in the same module/directory as the changed files (e.g., `tests/` subdirectories).
|
||||
* Tests explicitly importing or using the modified code/classes/functions.
|
||||
* Tests mentioned in the issue description or related documentation.
|
||||
* Tests covering functionalities that *depend on* the modified code (analyze callers/dependencies if necessary).
|
||||
**If you cannot confidently identify a specific subset, you MUST identify and plan to run the entire test suite for the modified application or module(s). State your identified test scope clearly.**
|
||||
* **Run Identified Relevant Tests:** You MUST execute the **complete set** of relevant existing unit tests you identified in the previous step. Ensure you are running the *correct and comprehensive set* of tests. You MUST NOT modify these existing tests.
|
||||
* **Final Check & Verification:** Before finishing, ensure **all** identified relevant existing tests pass. **Explicitly confirm that you have considered potential omissions in your test selection and believe the executed tests comprehensively cover the impact of your changes.** Failing to identify and run the *complete* relevant set constitutes a failure. If any identified tests fail, revise your fix. Passing all relevant tests is the primary measure of success.
|
||||
4. **Defensive Programming:** Actively practice defensive programming: anticipate and handle potential edge cases, unexpected inputs, and different ways the affected code might be called **to ensure the fix works reliably and allows relevant tests to pass.** Analyze the potential impact on other parts of the codebase.
|
||||
5. **Final Review:** Compare your solution against the original issue and the base commit ({{ instance.base_commit }}) to ensure completeness and test passage.
|
||||
|
||||
## General Workflow Guidance
|
||||
|
||||
* Prioritize understanding the problem, exploring the code, planning your fix, implementing it carefully using the required diff format, and **thoroughly testing** according to the **Mandatory Testing Procedure**.
|
||||
* Consider trade-offs between different solutions. The goal is a **robust change that makes the relevant tests pass.** Quality, correctness, and reliability are key.
|
||||
* Actively practice defensive programming: anticipate and handle potential edge cases, unexpected inputs, and different ways the affected code might be called **to ensure the fix works reliably and allows relevant tests to pass.** Analyze the potential impact on other parts of the codebase.
|
||||
|
||||
* IMPORTANT: Your solution will be tested by additional hidden tests, so do not assume the task is complete just because visible tests pass! Refine the solution until you are confident that it is robust and comprehensive according to the **Defensive Programming** requirement.
|
||||
|
||||
## Final Note
|
||||
Be thorough in your exploration, testing, and reasoning. It's fine if your thinking process is lengthy - quality and completeness are more important than brevity.
|
||||
|
||||
## Issue Description
|
||||
{{ instance.problem_statement }}
|
||||
@@ -80,8 +80,6 @@ def set_dataset_type(dataset_name: str) -> str:
|
||||
DATASET_TYPE = 'SWE-Gym'
|
||||
elif 'swe-bench-live' in name_lower:
|
||||
DATASET_TYPE = 'SWE-bench-Live'
|
||||
elif 'swe-rebench' in name_lower:
|
||||
DATASET_TYPE = 'SWE-rebench'
|
||||
elif 'multimodal' in name_lower:
|
||||
DATASET_TYPE = 'Multimodal'
|
||||
else:
|
||||
@@ -111,7 +109,9 @@ def get_instruction(instance: pd.Series, metadata: EvalMetadata) -> MessageActio
|
||||
if mode.startswith('swt'):
|
||||
template_name = 'swt.j2'
|
||||
elif mode == 'swe':
|
||||
if 'gpt-4.1' in llm_model:
|
||||
if 'claude' in llm_model:
|
||||
template_name = 'swe_default.j2'
|
||||
elif 'gpt-4.1' in llm_model:
|
||||
template_name = 'swe_gpt4.j2'
|
||||
else:
|
||||
template_name = (
|
||||
@@ -180,8 +180,6 @@ def get_instance_docker_image(
|
||||
docker_image_prefix = 'docker.io/starryzhang/'
|
||||
elif DATASET_TYPE == 'SWE-bench':
|
||||
docker_image_prefix = 'docker.io/swebench/'
|
||||
elif DATASET_TYPE == 'SWE-rebench':
|
||||
docker_image_prefix = 'docker.io/swerebench/'
|
||||
repo, name = instance_id.split('__')
|
||||
image_name = f'{docker_image_prefix.rstrip("/")}/sweb.eval.x86_64.{repo}_1776_{name}:latest'.lower()
|
||||
logger.debug(f'Using official SWE-Bench image: {image_name}')
|
||||
@@ -322,8 +320,6 @@ def initialize_runtime(
|
||||
# inject the instance swe entry
|
||||
if DATASET_TYPE == 'SWE-bench-Live':
|
||||
entry_script_path = 'instance_swe_entry_live.sh'
|
||||
elif DATASET_TYPE == 'SWE-rebench':
|
||||
entry_script_path = 'instance_swe_entry_rebench.sh'
|
||||
else:
|
||||
entry_script_path = 'instance_swe_entry.sh'
|
||||
runtime.copy_to(
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source ~/.bashrc
|
||||
SWEUTIL_DIR=/swe_util
|
||||
|
||||
# FIXME: Cannot read SWE_INSTANCE_ID from the environment variable
|
||||
# SWE_INSTANCE_ID=django__django-11099
|
||||
if [ -z "$SWE_INSTANCE_ID" ]; then
|
||||
echo "Error: SWE_INSTANCE_ID is not set." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Read the swe-bench-test-lite.json file and extract the required item based on instance_id
|
||||
item=$(jq --arg INSTANCE_ID "$SWE_INSTANCE_ID" '.[] | select(.instance_id == $INSTANCE_ID)' $SWEUTIL_DIR/eval_data/instances/swe-bench-instance.json)
|
||||
|
||||
if [[ -z "$item" ]]; then
|
||||
echo "No item found for the provided instance ID."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
WORKSPACE_NAME=$(echo "$item" | jq -r '(.repo | tostring) + "__" + (.version | tostring) | gsub("/"; "__")')
|
||||
|
||||
echo "WORKSPACE_NAME: $WORKSPACE_NAME"
|
||||
|
||||
# Clear the workspace
|
||||
if [ -d /workspace ]; then
|
||||
rm -rf /workspace/*
|
||||
else
|
||||
mkdir /workspace
|
||||
fi
|
||||
# Copy repo to workspace
|
||||
if [ -d /workspace/$WORKSPACE_NAME ]; then
|
||||
rm -rf /workspace/$WORKSPACE_NAME
|
||||
fi
|
||||
mkdir -p /workspace
|
||||
cp -r /testbed /workspace/$WORKSPACE_NAME
|
||||
|
||||
# Activate instance-specific environment
|
||||
if [ -d /opt/miniconda3 ]; then
|
||||
. /opt/miniconda3/etc/profile.d/conda.sh
|
||||
conda activate testbed
|
||||
fi
|
||||
|
||||
export PATH=/opt/conda/envs/testbed/bin:$PATH
|
||||
@@ -263,20 +263,19 @@ def prepare_dataset(
|
||||
f'Randomly sampling {eval_n_limit} unique instances with random seed 42.'
|
||||
)
|
||||
|
||||
def make_serializable(instance_dict: dict) -> dict:
|
||||
def make_serializable(instance: pd.Series) -> dict:
|
||||
import numpy as np
|
||||
|
||||
instance_dict = instance.to_dict()
|
||||
for k, v in instance_dict.items():
|
||||
if isinstance(v, np.ndarray):
|
||||
instance_dict[k] = v.tolist()
|
||||
elif isinstance(v, pd.Timestamp):
|
||||
instance_dict[k] = str(v)
|
||||
elif isinstance(v, dict):
|
||||
instance_dict[k] = make_serializable(v)
|
||||
return instance_dict
|
||||
|
||||
new_dataset = [
|
||||
make_serializable(instance.to_dict())
|
||||
make_serializable(instance)
|
||||
for _, instance in dataset.iterrows()
|
||||
if str(instance[id_column]) not in finished_ids
|
||||
]
|
||||
|
||||
@@ -85,10 +85,9 @@ describe("ConversationPanel", () => {
|
||||
vi.clearAllMocks();
|
||||
vi.restoreAllMocks();
|
||||
// Setup default mock for getUserConversations
|
||||
vi.spyOn(OpenHands, "getUserConversations").mockResolvedValue({
|
||||
results: [...mockConversations],
|
||||
next_page_id: null,
|
||||
});
|
||||
vi.spyOn(OpenHands, "getUserConversations").mockResolvedValue([
|
||||
...mockConversations,
|
||||
]);
|
||||
});
|
||||
|
||||
it("should render the conversations", async () => {
|
||||
@@ -102,10 +101,7 @@ describe("ConversationPanel", () => {
|
||||
|
||||
it("should display an empty state when there are no conversations", async () => {
|
||||
const getUserConversationsSpy = vi.spyOn(OpenHands, "getUserConversations");
|
||||
getUserConversationsSpy.mockResolvedValue({
|
||||
results: [],
|
||||
next_page_id: null,
|
||||
});
|
||||
getUserConversationsSpy.mockResolvedValue([]);
|
||||
|
||||
renderConversationPanel();
|
||||
|
||||
@@ -199,10 +195,7 @@ describe("ConversationPanel", () => {
|
||||
];
|
||||
|
||||
const getUserConversationsSpy = vi.spyOn(OpenHands, "getUserConversations");
|
||||
getUserConversationsSpy.mockImplementation(async () => ({
|
||||
results: mockData,
|
||||
next_page_id: null,
|
||||
}));
|
||||
getUserConversationsSpy.mockImplementation(async () => mockData);
|
||||
|
||||
const deleteUserConversationSpy = vi.spyOn(
|
||||
OpenHands,
|
||||
@@ -256,10 +249,7 @@ describe("ConversationPanel", () => {
|
||||
it("should refetch data on rerenders", async () => {
|
||||
const user = userEvent.setup();
|
||||
const getUserConversationsSpy = vi.spyOn(OpenHands, "getUserConversations");
|
||||
getUserConversationsSpy.mockResolvedValue({
|
||||
results: [...mockConversations],
|
||||
next_page_id: null,
|
||||
});
|
||||
getUserConversationsSpy.mockResolvedValue([...mockConversations]);
|
||||
|
||||
function PanelWithToggle() {
|
||||
const [isOpen, setIsOpen] = React.useState(true);
|
||||
@@ -353,10 +343,7 @@ describe("ConversationPanel", () => {
|
||||
];
|
||||
|
||||
const getUserConversationsSpy = vi.spyOn(OpenHands, "getUserConversations");
|
||||
getUserConversationsSpy.mockResolvedValue({
|
||||
results: mockRunningConversations,
|
||||
next_page_id: null,
|
||||
});
|
||||
getUserConversationsSpy.mockResolvedValue(mockRunningConversations);
|
||||
|
||||
renderConversationPanel();
|
||||
|
||||
@@ -420,10 +407,7 @@ describe("ConversationPanel", () => {
|
||||
];
|
||||
|
||||
const getUserConversationsSpy = vi.spyOn(OpenHands, "getUserConversations");
|
||||
getUserConversationsSpy.mockImplementation(async () => ({
|
||||
results: mockData,
|
||||
next_page_id: null,
|
||||
}));
|
||||
getUserConversationsSpy.mockImplementation(async () => mockData);
|
||||
|
||||
const stopConversationSpy = vi.spyOn(OpenHands, "stopConversation");
|
||||
stopConversationSpy.mockImplementation(async (id: string) => {
|
||||
@@ -508,10 +492,7 @@ describe("ConversationPanel", () => {
|
||||
];
|
||||
|
||||
const getUserConversationsSpy = vi.spyOn(OpenHands, "getUserConversations");
|
||||
getUserConversationsSpy.mockResolvedValue({
|
||||
results: mockMixedStatusConversations,
|
||||
next_page_id: null,
|
||||
});
|
||||
getUserConversationsSpy.mockResolvedValue(mockMixedStatusConversations);
|
||||
|
||||
renderConversationPanel();
|
||||
|
||||
|
||||
382
frontend/package-lock.json
generated
382
frontend/package-lock.json
generated
@@ -12,16 +12,16 @@
|
||||
"@heroui/use-infinite-scroll": "^2.2.10",
|
||||
"@microlink/react-json-view": "^1.26.2",
|
||||
"@monaco-editor/react": "^4.7.0-rc.0",
|
||||
"@react-router/node": "^7.8.0",
|
||||
"@react-router/serve": "^7.8.0",
|
||||
"@react-router/node": "^7.7.1",
|
||||
"@react-router/serve": "^7.7.1",
|
||||
"@react-types/shared": "^3.31.0",
|
||||
"@reduxjs/toolkit": "^2.8.2",
|
||||
"@stripe/react-stripe-js": "^3.9.0",
|
||||
"@stripe/stripe-js": "^7.8.0",
|
||||
"@tailwindcss/postcss": "^4.1.11",
|
||||
"@tailwindcss/vite": "^4.1.11",
|
||||
"@tanstack/react-query": "^5.84.2",
|
||||
"@vitejs/plugin-react": "^5.0.0",
|
||||
"@tanstack/react-query": "^5.84.1",
|
||||
"@vitejs/plugin-react": "^4.7.0",
|
||||
"@xterm/addon-fit": "^0.10.0",
|
||||
"@xterm/xterm": "^5.4.0",
|
||||
"axios": "^1.11.0",
|
||||
@@ -33,9 +33,9 @@
|
||||
"i18next-http-backend": "^3.0.2",
|
||||
"isbot": "^5.1.29",
|
||||
"jose": "^6.0.12",
|
||||
"lucide-react": "^0.539.0",
|
||||
"lucide-react": "^0.536.0",
|
||||
"monaco-editor": "^0.52.2",
|
||||
"posthog-js": "^1.259.0",
|
||||
"posthog-js": "^1.258.5",
|
||||
"react": "^19.1.1",
|
||||
"react-dom": "^19.1.1",
|
||||
"react-highlight": "^0.15.0",
|
||||
@@ -44,7 +44,7 @@
|
||||
"react-icons": "^5.5.0",
|
||||
"react-markdown": "^10.1.0",
|
||||
"react-redux": "^9.2.0",
|
||||
"react-router": "^7.8.0",
|
||||
"react-router": "^7.7.1",
|
||||
"react-select": "^5.10.2",
|
||||
"react-syntax-highlighter": "^15.6.1",
|
||||
"react-textarea-autosize": "^8.5.9",
|
||||
@@ -53,7 +53,7 @@
|
||||
"sirv-cli": "^3.0.1",
|
||||
"socket.io-client": "^4.8.1",
|
||||
"tailwind-merge": "^3.3.1",
|
||||
"vite": "^7.1.1",
|
||||
"vite": "^7.0.6",
|
||||
"web-vitals": "^5.1.0",
|
||||
"ws": "^8.18.2"
|
||||
},
|
||||
@@ -63,7 +63,7 @@
|
||||
"@babel/types": "^7.28.2",
|
||||
"@mswjs/socket.io-binding": "^0.2.0",
|
||||
"@playwright/test": "^1.54.2",
|
||||
"@react-router/dev": "^7.8.0",
|
||||
"@react-router/dev": "^7.7.1",
|
||||
"@tailwindcss/typography": "^0.5.16",
|
||||
"@tanstack/eslint-plugin-query": "^5.83.1",
|
||||
"@testing-library/dom": "^10.4.1",
|
||||
@@ -4388,10 +4388,11 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@react-router/dev": {
|
||||
"version": "7.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@react-router/dev/-/dev-7.8.0.tgz",
|
||||
"integrity": "sha512-5NA9yLZComM+kCD3zNPL3rjrAFjzzODY8hjAJlpz/6jpyXoF28W8QTSo8rxc56XVNLONM75Y5nq1wzeEcWFFKA==",
|
||||
"version": "7.7.1",
|
||||
"resolved": "https://registry.npmjs.org/@react-router/dev/-/dev-7.7.1.tgz",
|
||||
"integrity": "sha512-ByfgHmAyfx/JQYN/QwUx1sFJlBA5Z3HQAZ638wHSb+m6khWtHqSaKCvPqQh1P00wdEAeV3tX5L1aUM/ceCF6+w==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.27.7",
|
||||
"@babel/generator": "^7.27.5",
|
||||
@@ -4401,9 +4402,7 @@
|
||||
"@babel/traverse": "^7.27.7",
|
||||
"@babel/types": "^7.27.7",
|
||||
"@npmcli/package-json": "^4.0.1",
|
||||
"@react-router/node": "7.8.0",
|
||||
"@vitejs/plugin-react": "^4.5.2",
|
||||
"@vitejs/plugin-rsc": "0.4.11",
|
||||
"@react-router/node": "7.7.1",
|
||||
"arg": "^5.0.1",
|
||||
"babel-dead-code-elimination": "^1.0.6",
|
||||
"chokidar": "^4.0.0",
|
||||
@@ -4430,8 +4429,8 @@
|
||||
"node": ">=20.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@react-router/serve": "^7.8.0",
|
||||
"react-router": "^7.8.0",
|
||||
"@react-router/serve": "^7.7.1",
|
||||
"react-router": "^7.7.1",
|
||||
"typescript": "^5.1.0",
|
||||
"vite": "^5.1.0 || ^6.0.0 || ^7.0.0",
|
||||
"wrangler": "^3.28.2 || ^4.0.0"
|
||||
@@ -4448,41 +4447,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@react-router/dev/node_modules/@rolldown/pluginutils": {
|
||||
"version": "1.0.0-beta.27",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.27.tgz",
|
||||
"integrity": "sha512-+d0F4MKMCbeVUJwG96uQ4SgAznZNSq93I3V+9NHA4OpvqG8mRCpGdKmK8l/dl02h2CCDHwW2FqilnTyDcAnqjA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@react-router/dev/node_modules/@vitejs/plugin-react": {
|
||||
"version": "4.7.0",
|
||||
"resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-4.7.0.tgz",
|
||||
"integrity": "sha512-gUu9hwfWvvEDBBmgtAowQCojwZmJ5mcLn3aufeCsitijs3+f2NsrPtlAWIR6OPiqljl96GVCUbLe0HyqIpVaoA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.28.0",
|
||||
"@babel/plugin-transform-react-jsx-self": "^7.27.1",
|
||||
"@babel/plugin-transform-react-jsx-source": "^7.27.1",
|
||||
"@rolldown/pluginutils": "1.0.0-beta.27",
|
||||
"@types/babel__core": "^7.20.5",
|
||||
"react-refresh": "^0.17.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.18.0 || >=16.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@react-router/dev/node_modules/@vitejs/plugin-react/node_modules/react-refresh": {
|
||||
"version": "0.17.0",
|
||||
"resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.17.0.tgz",
|
||||
"integrity": "sha512-z6F7K9bV85EfseRCp2bzrpyQ0Gkw1uLoCel9XBVWPg/TjRj94SkJzUTGfOa4bs7iJvBWtQG0Wq7wnI0syw3EBQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@react-router/dev/node_modules/jsesc": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.0.2.tgz",
|
||||
@@ -4496,10 +4460,33 @@
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/@react-router/express": {
|
||||
"version": "7.7.1",
|
||||
"resolved": "https://registry.npmjs.org/@react-router/express/-/express-7.7.1.tgz",
|
||||
"integrity": "sha512-OEZwIM7i/KPSDjwVRg3LqeNIwG41U+SeFOwMjhZRFfyrnwghHfvWsDajf73r4ccMh+RRHcP1GIN6VSU3XZk7MA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@react-router/node": "7.7.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"express": "^4.17.1 || ^5",
|
||||
"react-router": "7.7.1",
|
||||
"typescript": "^5.1.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@react-router/node": {
|
||||
"version": "7.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@react-router/node/-/node-7.8.0.tgz",
|
||||
"integrity": "sha512-/FFN9vqI2EHPwDCHTvsMInhrYvwJ5SlCeyUr1oWUxH47JyYkooVFks5++M4VkrTgj2ZBsMjPPKy0xRNTQdtBDA==",
|
||||
"version": "7.7.1",
|
||||
"resolved": "https://registry.npmjs.org/@react-router/node/-/node-7.7.1.tgz",
|
||||
"integrity": "sha512-EHd6PEcw2nmcJmcYTPA0MmRWSqOaJ/meycfCp0ADA9T/6b7+fUHfr9XcNyf7UeZtYwu4zGyuYfPmLU5ic6Ugyg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@mjackson/node-fetch-server": "^0.2.0"
|
||||
},
|
||||
@@ -4507,7 +4494,7 @@
|
||||
"node": ">=20.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react-router": "7.8.0",
|
||||
"react-router": "7.7.1",
|
||||
"typescript": "^5.1.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
@@ -4517,12 +4504,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@react-router/serve": {
|
||||
"version": "7.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@react-router/serve/-/serve-7.8.0.tgz",
|
||||
"integrity": "sha512-DokCv1GfOMt9KHu+k3WYY9sP5nOEzq7za+Vi3dWPHoY5oP0wgv8S4DnTPU08ASY8iFaF38NAzapbSFfu6Xfr0Q==",
|
||||
"version": "7.7.1",
|
||||
"resolved": "https://registry.npmjs.org/@react-router/serve/-/serve-7.7.1.tgz",
|
||||
"integrity": "sha512-LyAiX+oI+6O6j2xWPUoKW+cgayUf3USBosSMv73Jtwi99XUhSDu2MUhM+BB+AbrYRubauZ83QpZTROiXoaf8jA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@react-router/express": "7.8.0",
|
||||
"@react-router/node": "7.8.0",
|
||||
"@react-router/express": "7.7.1",
|
||||
"@react-router/node": "7.7.1",
|
||||
"compression": "^1.7.4",
|
||||
"express": "^4.19.2",
|
||||
"get-port": "5.1.1",
|
||||
@@ -4536,28 +4524,7 @@
|
||||
"node": ">=20.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react-router": "7.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@react-router/serve/node_modules/@react-router/express": {
|
||||
"version": "7.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@react-router/express/-/express-7.8.0.tgz",
|
||||
"integrity": "sha512-lNUwux5IfMqczIL3gXZ/mauPUoVz65fSLPnUTkP7hkh/P7fcsPtYkmcixuaWb+882lY+Glf157OdoIMbcSMBaA==",
|
||||
"dependencies": {
|
||||
"@react-router/node": "7.8.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"express": "^4.17.1 || ^5",
|
||||
"react-router": "7.8.0",
|
||||
"typescript": "^5.1.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
"react-router": "7.7.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@react-stately/calendar": {
|
||||
@@ -5259,9 +5226,10 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/pluginutils": {
|
||||
"version": "1.0.0-beta.30",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.30.tgz",
|
||||
"integrity": "sha512-whXaSoNUFiyDAjkUF8OBpOm77Szdbk5lGNqFe6CbVbJFrhCCPinCbRA3NjawwlNHla1No7xvXXh+CpSxnPfUEw=="
|
||||
"version": "1.0.0-beta.27",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.27.tgz",
|
||||
"integrity": "sha512-+d0F4MKMCbeVUJwG96uQ4SgAznZNSq93I3V+9NHA4OpvqG8mRCpGdKmK8l/dl02h2CCDHwW2FqilnTyDcAnqjA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@rollup/pluginutils": {
|
||||
"version": "5.2.0",
|
||||
@@ -6104,60 +6072,6 @@
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/core": {
|
||||
"version": "1.4.3",
|
||||
"inBundle": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"@emnapi/wasi-threads": "1.0.2",
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/runtime": {
|
||||
"version": "1.4.3",
|
||||
"inBundle": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/wasi-threads": {
|
||||
"version": "1.0.2",
|
||||
"inBundle": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@napi-rs/wasm-runtime": {
|
||||
"version": "0.2.11",
|
||||
"inBundle": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"@emnapi/core": "^1.4.3",
|
||||
"@emnapi/runtime": "^1.4.3",
|
||||
"@tybys/wasm-util": "^0.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@tybys/wasm-util": {
|
||||
"version": "0.9.0",
|
||||
"inBundle": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/tslib": {
|
||||
"version": "2.8.0",
|
||||
"inBundle": true,
|
||||
"license": "0BSD",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/@tailwindcss/oxide-win32-arm64-msvc": {
|
||||
"version": "4.1.11",
|
||||
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.1.11.tgz",
|
||||
@@ -6261,9 +6175,10 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@tanstack/react-query": {
|
||||
"version": "5.84.2",
|
||||
"resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.84.2.tgz",
|
||||
"integrity": "sha512-cZadySzROlD2+o8zIfbD978p0IphuQzRWiiH3I2ugnTmz4jbjc0+TdibpwqxlzynEen8OulgAg+rzdNF37s7XQ==",
|
||||
"version": "5.84.1",
|
||||
"resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.84.1.tgz",
|
||||
"integrity": "sha512-zo7EUygcWJMQfFNWDSG7CBhy8irje/XY0RDVKKV4IQJAysb+ZJkkJPcnQi+KboyGUgT+SQebRFoTqLuTtfoDLw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tanstack/query-core": "5.83.1"
|
||||
},
|
||||
@@ -7036,19 +6951,20 @@
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/@vitejs/plugin-react": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-5.0.0.tgz",
|
||||
"integrity": "sha512-Jx9JfsTa05bYkS9xo0hkofp2dCmp1blrKjw9JONs5BTHOvJCgLbaPSuZLGSVJW6u2qe0tc4eevY0+gSNNi0YCw==",
|
||||
"version": "4.7.0",
|
||||
"resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-4.7.0.tgz",
|
||||
"integrity": "sha512-gUu9hwfWvvEDBBmgtAowQCojwZmJ5mcLn3aufeCsitijs3+f2NsrPtlAWIR6OPiqljl96GVCUbLe0HyqIpVaoA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.28.0",
|
||||
"@babel/plugin-transform-react-jsx-self": "^7.27.1",
|
||||
"@babel/plugin-transform-react-jsx-source": "^7.27.1",
|
||||
"@rolldown/pluginutils": "1.0.0-beta.30",
|
||||
"@rolldown/pluginutils": "1.0.0-beta.27",
|
||||
"@types/babel__core": "^7.20.5",
|
||||
"react-refresh": "^0.17.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
"node": "^14.18.0 || >=16.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"
|
||||
@@ -7063,32 +6979,6 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@vitejs/plugin-rsc": {
|
||||
"version": "0.4.11",
|
||||
"resolved": "https://registry.npmjs.org/@vitejs/plugin-rsc/-/plugin-rsc-0.4.11.tgz",
|
||||
"integrity": "sha512-+4H4wLi+Y9yF58znBfKgGfX8zcqUGt8ngnmNgzrdGdF1SVz7EO0sg7WnhK5fFVHt6fUxsVEjmEabsCWHKPL1Tw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@mjackson/node-fetch-server": "^0.7.0",
|
||||
"es-module-lexer": "^1.7.0",
|
||||
"estree-walker": "^3.0.3",
|
||||
"magic-string": "^0.30.17",
|
||||
"periscopic": "^4.0.2",
|
||||
"turbo-stream": "^3.1.0",
|
||||
"vitefu": "^1.1.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "*",
|
||||
"react-dom": "*",
|
||||
"vite": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@vitejs/plugin-rsc/node_modules/@mjackson/node-fetch-server": {
|
||||
"version": "0.7.0",
|
||||
"resolved": "https://registry.npmjs.org/@mjackson/node-fetch-server/-/node-fetch-server-0.7.0.tgz",
|
||||
"integrity": "sha512-un8diyEBKU3BTVj3GzlTPA1kIjCkGdD+AMYQy31Gf9JCkfoZzwgJ79GUtHrF2BN3XPNMLpubbzPcxys+a3uZEw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@vitest/coverage-v8": {
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-3.2.4.tgz",
|
||||
@@ -7271,6 +7161,7 @@
|
||||
"version": "1.3.8",
|
||||
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
|
||||
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"mime-types": "~2.1.34",
|
||||
"negotiator": "0.6.3"
|
||||
@@ -7283,6 +7174,7 @@
|
||||
"version": "0.6.3",
|
||||
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
|
||||
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
@@ -7423,7 +7315,8 @@
|
||||
"node_modules/array-flatten": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
|
||||
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
|
||||
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/array-includes": {
|
||||
"version": "3.1.9",
|
||||
@@ -7788,6 +7681,7 @@
|
||||
"version": "1.20.3",
|
||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz",
|
||||
"integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bytes": "3.1.2",
|
||||
"content-type": "~1.0.5",
|
||||
@@ -7811,6 +7705,7 @@
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
@@ -7818,7 +7713,8 @@
|
||||
"node_modules/body-parser/node_modules/ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
|
||||
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/brace-expansion": {
|
||||
"version": "2.0.2",
|
||||
@@ -8444,6 +8340,7 @@
|
||||
"version": "0.5.4",
|
||||
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
|
||||
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safe-buffer": "5.2.1"
|
||||
},
|
||||
@@ -8455,6 +8352,7 @@
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
|
||||
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
@@ -8469,6 +8367,7 @@
|
||||
"version": "0.7.1",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz",
|
||||
"integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
@@ -8476,7 +8375,8 @@
|
||||
"node_modules/cookie-signature": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
|
||||
"integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ=="
|
||||
"integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/core-js": {
|
||||
"version": "3.45.0",
|
||||
@@ -8831,6 +8731,7 @@
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
|
||||
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8",
|
||||
"npm": "1.2.8000 || >= 1.4.16"
|
||||
@@ -8956,6 +8857,7 @@
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
|
||||
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
@@ -9308,7 +9210,8 @@
|
||||
"node_modules/escape-html": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
|
||||
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow=="
|
||||
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/escape-string-regexp": {
|
||||
"version": "4.0.0",
|
||||
@@ -9981,6 +9884,7 @@
|
||||
"version": "1.8.1",
|
||||
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
|
||||
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
@@ -10019,6 +9923,7 @@
|
||||
"version": "4.21.2",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz",
|
||||
"integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"accepts": "~1.3.8",
|
||||
"array-flatten": "1.1.1",
|
||||
@@ -10064,6 +9969,7 @@
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
@@ -10071,7 +9977,8 @@
|
||||
"node_modules/express/node_modules/ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
|
||||
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/extend": {
|
||||
"version": "3.0.2",
|
||||
@@ -10196,6 +10103,7 @@
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz",
|
||||
"integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "2.6.9",
|
||||
"encodeurl": "~2.0.0",
|
||||
@@ -10213,6 +10121,7 @@
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
@@ -10220,7 +10129,8 @@
|
||||
"node_modules/finalhandler/node_modules/ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
|
||||
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/find-root": {
|
||||
"version": "1.1.0",
|
||||
@@ -10357,6 +10267,7 @@
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
|
||||
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
@@ -10406,6 +10317,7 @@
|
||||
"version": "0.5.2",
|
||||
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
|
||||
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
@@ -11018,6 +10930,7 @@
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
|
||||
"integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"depd": "2.0.0",
|
||||
"inherits": "2.0.4",
|
||||
@@ -11126,6 +11039,7 @@
|
||||
"version": "0.4.24",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
|
||||
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safer-buffer": ">= 2.1.2 < 3"
|
||||
},
|
||||
@@ -11254,6 +11168,7 @@
|
||||
"version": "1.9.1",
|
||||
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
|
||||
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.10"
|
||||
}
|
||||
@@ -11602,15 +11517,6 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/is-reference": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.3.tgz",
|
||||
"integrity": "sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/estree": "^1.0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/is-regex": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.2.1.tgz",
|
||||
@@ -12719,9 +12625,10 @@
|
||||
}
|
||||
},
|
||||
"node_modules/lucide-react": {
|
||||
"version": "0.539.0",
|
||||
"resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.539.0.tgz",
|
||||
"integrity": "sha512-VVISr+VF2krO91FeuCrm1rSOLACQUYVy7NQkzrOty52Y8TlTPcXcMdQFj9bYzBgXbWCiywlwSZ3Z8u6a+6bMlg==",
|
||||
"version": "0.536.0",
|
||||
"resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.536.0.tgz",
|
||||
"integrity": "sha512-2PgvNa9v+qz4Jt/ni8vPLt4jwoFybXHuubQT8fv4iCW5TjDxkbZjNZZHa485ad73NSEn/jdsEtU57eE1g+ma8A==",
|
||||
"license": "ISC",
|
||||
"peerDependencies": {
|
||||
"react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||
}
|
||||
@@ -13092,6 +12999,7 @@
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
||||
"integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
@@ -13106,6 +13014,7 @@
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
|
||||
"integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
@@ -13124,6 +13033,7 @@
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
|
||||
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
@@ -13709,6 +13619,7 @@
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
|
||||
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"mime": "cli.js"
|
||||
},
|
||||
@@ -14313,6 +14224,7 @@
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
|
||||
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ee-first": "1.1.1"
|
||||
},
|
||||
@@ -14515,6 +14427,7 @@
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
|
||||
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
@@ -14582,7 +14495,8 @@
|
||||
"node_modules/path-to-regexp": {
|
||||
"version": "0.1.12",
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz",
|
||||
"integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ=="
|
||||
"integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/path-type": {
|
||||
"version": "4.0.0",
|
||||
@@ -14610,17 +14524,6 @@
|
||||
"node": ">= 14.16"
|
||||
}
|
||||
},
|
||||
"node_modules/periscopic": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/periscopic/-/periscopic-4.0.2.tgz",
|
||||
"integrity": "sha512-sqpQDUy8vgB7ycLkendSKS6HnVz1Rneoc3Rc+ZBUCe2pbqlVuCC5vF52l0NJ1aiMg/r1qfYF9/myz8CZeI2rjA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/estree": "*",
|
||||
"is-reference": "^3.0.2",
|
||||
"zimmerframe": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/picocolors": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
||||
@@ -14745,9 +14648,10 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/posthog-js": {
|
||||
"version": "1.259.0",
|
||||
"resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.259.0.tgz",
|
||||
"integrity": "sha512-6usLnJshky8fQ82ask7PIJh4BSFOU0VkRbFg8Zanm/HIlYMG1VOdRWlToA63JXeO7Bzm9TuREq1wFm5U2VEVCg==",
|
||||
"version": "1.258.6",
|
||||
"resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.258.6.tgz",
|
||||
"integrity": "sha512-vL5AGG+rOoRg3LGquMfBPO55jD4bGl0CiV44SHdHAoBnOVDDAqxczRGDqMdxor+VLx3/ofTFOJ2FNprfAHp70Q==",
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"dependencies": {
|
||||
"core-js": "^3.38.1",
|
||||
"fflate": "^0.4.8",
|
||||
@@ -14921,6 +14825,7 @@
|
||||
"version": "2.0.7",
|
||||
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
|
||||
"integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"forwarded": "0.2.0",
|
||||
"ipaddr.js": "1.9.1"
|
||||
@@ -15005,6 +14910,7 @@
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
|
||||
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
@@ -15013,6 +14919,7 @@
|
||||
"version": "2.5.2",
|
||||
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz",
|
||||
"integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bytes": "3.1.2",
|
||||
"http-errors": "2.0.0",
|
||||
@@ -15219,9 +15126,10 @@
|
||||
}
|
||||
},
|
||||
"node_modules/react-router": {
|
||||
"version": "7.8.0",
|
||||
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.8.0.tgz",
|
||||
"integrity": "sha512-r15M3+LHKgM4SOapNmsH3smAizWds1vJ0Z9C4mWaKnT9/wD7+d/0jYcj6LmOvonkrO4Rgdyp4KQ/29gWN2i1eg==",
|
||||
"version": "7.7.1",
|
||||
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.7.1.tgz",
|
||||
"integrity": "sha512-jVKHXoWRIsD/qS6lvGveckwb862EekvapdHJN/cGmzw40KnJH5gg53ujOJ4qX6EKIK9LSBfFed/xiQ5yeXNrUA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cookie": "^1.0.1",
|
||||
"set-cookie-parser": "^2.6.0"
|
||||
@@ -15990,6 +15898,7 @@
|
||||
"version": "0.19.0",
|
||||
"resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz",
|
||||
"integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
@@ -16013,6 +15922,7 @@
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
@@ -16020,12 +15930,14 @@
|
||||
"node_modules/send/node_modules/debug/node_modules/ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
|
||||
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/send/node_modules/encodeurl": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
|
||||
"integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
@@ -16034,6 +15946,7 @@
|
||||
"version": "1.16.2",
|
||||
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz",
|
||||
"integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"encodeurl": "~2.0.0",
|
||||
"escape-html": "~1.0.3",
|
||||
@@ -16102,7 +16015,8 @@
|
||||
"node_modules/setprototypeof": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
|
||||
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="
|
||||
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/shebang-command": {
|
||||
"version": "2.0.0",
|
||||
@@ -17140,6 +17054,7 @@
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
|
||||
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
}
|
||||
@@ -17265,12 +17180,6 @@
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/turbo-stream": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/turbo-stream/-/turbo-stream-3.1.0.tgz",
|
||||
"integrity": "sha512-tVI25WEXl4fckNEmrq70xU1XumxUwEx/FZD5AgEcV8ri7Wvrg2o7GEq8U7htrNx3CajciGm+kDyhRf5JB6t7/A==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/type-check": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
|
||||
@@ -17301,6 +17210,7 @@
|
||||
"version": "1.6.18",
|
||||
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
|
||||
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"media-typer": "0.3.0",
|
||||
"mime-types": "~2.1.24"
|
||||
@@ -17528,6 +17438,7 @@
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
|
||||
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
@@ -17648,6 +17559,7 @@
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
|
||||
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
}
|
||||
@@ -17726,15 +17638,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "7.1.1",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-7.1.1.tgz",
|
||||
"integrity": "sha512-yJ+Mp7OyV+4S+afWo+QyoL9jFWD11QFH0i5i7JypnfTcA1rmgxCbiA8WwAICDEtZ1Z1hzrVhN8R8rGTqkTY8ZQ==",
|
||||
"version": "7.0.6",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-7.0.6.tgz",
|
||||
"integrity": "sha512-MHFiOENNBd+Bd9uvc8GEsIzdkn1JxMmEeYX35tI3fv0sJBUTfW5tQsoaOwuY4KhBI09A3dUJ/DXf2yxPVPUceg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"esbuild": "^0.25.0",
|
||||
"fdir": "^6.4.6",
|
||||
"picomatch": "^4.0.3",
|
||||
"postcss": "^8.5.6",
|
||||
"rollup": "^4.43.0",
|
||||
"rollup": "^4.40.0",
|
||||
"tinyglobby": "^0.2.14"
|
||||
},
|
||||
"bin": {
|
||||
@@ -17903,25 +17816,6 @@
|
||||
"url": "https://github.com/sponsors/jonschlinkert"
|
||||
}
|
||||
},
|
||||
"node_modules/vitefu": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/vitefu/-/vitefu-1.1.1.tgz",
|
||||
"integrity": "sha512-B/Fegf3i8zh0yFbpzZ21amWzHmuNlLlmJT6n7bu5e+pCHUKQIfXSYokrqOBGEMMe9UG2sostKQF9mml/vYaWJQ==",
|
||||
"dev": true,
|
||||
"workspaces": [
|
||||
"tests/deps/*",
|
||||
"tests/projects/*",
|
||||
"tests/projects/workspace/packages/*"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0-beta.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"vite": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/vitest": {
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://registry.npmjs.org/vitest/-/vitest-3.2.4.tgz",
|
||||
@@ -18524,12 +18418,6 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/zimmerframe": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/zimmerframe/-/zimmerframe-1.1.2.tgz",
|
||||
"integrity": "sha512-rAbqEGa8ovJy4pyBxZM70hg4pE6gDgaQ0Sl9M3enG3I0d6H4XSAM3GeNGLKnsBpuijUow064sf7ww1nutC5/3w==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/zwitch": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz",
|
||||
|
||||
@@ -11,16 +11,16 @@
|
||||
"@heroui/use-infinite-scroll": "^2.2.10",
|
||||
"@microlink/react-json-view": "^1.26.2",
|
||||
"@monaco-editor/react": "^4.7.0-rc.0",
|
||||
"@react-router/node": "^7.8.0",
|
||||
"@react-router/serve": "^7.8.0",
|
||||
"@react-router/node": "^7.7.1",
|
||||
"@react-router/serve": "^7.7.1",
|
||||
"@react-types/shared": "^3.31.0",
|
||||
"@reduxjs/toolkit": "^2.8.2",
|
||||
"@stripe/react-stripe-js": "^3.9.0",
|
||||
"@stripe/stripe-js": "^7.8.0",
|
||||
"@tailwindcss/postcss": "^4.1.11",
|
||||
"@tailwindcss/vite": "^4.1.11",
|
||||
"@tanstack/react-query": "^5.84.2",
|
||||
"@vitejs/plugin-react": "^5.0.0",
|
||||
"@tanstack/react-query": "^5.84.1",
|
||||
"@vitejs/plugin-react": "^4.7.0",
|
||||
"@xterm/addon-fit": "^0.10.0",
|
||||
"@xterm/xterm": "^5.4.0",
|
||||
"axios": "^1.11.0",
|
||||
@@ -32,9 +32,9 @@
|
||||
"i18next-http-backend": "^3.0.2",
|
||||
"isbot": "^5.1.29",
|
||||
"jose": "^6.0.12",
|
||||
"lucide-react": "^0.539.0",
|
||||
"lucide-react": "^0.536.0",
|
||||
"monaco-editor": "^0.52.2",
|
||||
"posthog-js": "^1.259.0",
|
||||
"posthog-js": "^1.258.5",
|
||||
"react": "^19.1.1",
|
||||
"react-dom": "^19.1.1",
|
||||
"react-highlight": "^0.15.0",
|
||||
@@ -43,7 +43,7 @@
|
||||
"react-icons": "^5.5.0",
|
||||
"react-markdown": "^10.1.0",
|
||||
"react-redux": "^9.2.0",
|
||||
"react-router": "^7.8.0",
|
||||
"react-router": "^7.7.1",
|
||||
"react-select": "^5.10.2",
|
||||
"react-syntax-highlighter": "^15.6.1",
|
||||
"react-textarea-autosize": "^8.5.9",
|
||||
@@ -52,7 +52,7 @@
|
||||
"sirv-cli": "^3.0.1",
|
||||
"socket.io-client": "^4.8.1",
|
||||
"tailwind-merge": "^3.3.1",
|
||||
"vite": "^7.1.1",
|
||||
"vite": "^7.0.6",
|
||||
"web-vitals": "^5.1.0",
|
||||
"ws": "^8.18.2"
|
||||
},
|
||||
@@ -87,7 +87,7 @@
|
||||
"@babel/types": "^7.28.2",
|
||||
"@mswjs/socket.io-binding": "^0.2.0",
|
||||
"@playwright/test": "^1.54.2",
|
||||
"@react-router/dev": "^7.8.0",
|
||||
"@react-router/dev": "^7.7.1",
|
||||
"@tailwindcss/typography": "^0.5.16",
|
||||
"@tanstack/eslint-plugin-query": "^5.83.1",
|
||||
"@testing-library/dom": "^10.4.1",
|
||||
|
||||
@@ -283,27 +283,17 @@ class OpenHands {
|
||||
return data;
|
||||
}
|
||||
|
||||
static async getUserConversations(
|
||||
limit: number = 20,
|
||||
pageId?: string,
|
||||
): Promise<ResultSet<Conversation>> {
|
||||
const params = new URLSearchParams();
|
||||
params.append("limit", limit.toString());
|
||||
|
||||
if (pageId) {
|
||||
params.append("page_id", pageId);
|
||||
}
|
||||
|
||||
static async getUserConversations(): Promise<Conversation[]> {
|
||||
const { data } = await openHands.get<ResultSet<Conversation>>(
|
||||
`/api/conversations?${params.toString()}`,
|
||||
"/api/conversations?limit=100",
|
||||
);
|
||||
return data;
|
||||
return data.results;
|
||||
}
|
||||
|
||||
static async searchConversations(
|
||||
selectedRepository?: string,
|
||||
conversationTrigger?: string,
|
||||
limit: number = 100,
|
||||
limit: number = 20,
|
||||
): Promise<Conversation[]> {
|
||||
const params = new URLSearchParams();
|
||||
params.append("limit", limit.toString());
|
||||
|
||||
@@ -3,8 +3,7 @@ import { NavLink, useParams, useNavigate } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { I18nKey } from "#/i18n/declaration";
|
||||
import { ConversationCard } from "./conversation-card";
|
||||
import { usePaginatedConversations } from "#/hooks/query/use-paginated-conversations";
|
||||
import { useInfiniteScroll } from "#/hooks/use-infinite-scroll";
|
||||
import { useUserConversations } from "#/hooks/query/use-user-conversations";
|
||||
import { useDeleteConversation } from "#/hooks/mutation/use-delete-conversation";
|
||||
import { useStopConversation } from "#/hooks/mutation/use-stop-conversation";
|
||||
import { ConfirmDeleteModal } from "./confirm-delete-modal";
|
||||
@@ -41,30 +40,12 @@ export function ConversationPanel({ onClose }: ConversationPanelProps) {
|
||||
string | null
|
||||
>(null);
|
||||
|
||||
const {
|
||||
data,
|
||||
isFetching,
|
||||
error,
|
||||
hasNextPage,
|
||||
isFetchingNextPage,
|
||||
fetchNextPage,
|
||||
} = usePaginatedConversations();
|
||||
|
||||
// Flatten all pages into a single array of conversations
|
||||
const conversations = data?.pages.flatMap((page) => page.results) ?? [];
|
||||
const { data: conversations, isFetching, error } = useUserConversations();
|
||||
|
||||
const { mutate: deleteConversation } = useDeleteConversation();
|
||||
const { mutate: stopConversation } = useStopConversation();
|
||||
const { mutate: updateConversation } = useUpdateConversation();
|
||||
|
||||
// Set up infinite scroll
|
||||
const scrollContainerRef = useInfiniteScroll({
|
||||
hasNextPage: !!hasNextPage,
|
||||
isFetchingNextPage,
|
||||
fetchNextPage,
|
||||
threshold: 200, // Load more when 200px from bottom
|
||||
});
|
||||
|
||||
const handleDeleteProject = (conversationId: string) => {
|
||||
setConfirmDeleteModalVisible(true);
|
||||
setSelectedConversationId(conversationId);
|
||||
@@ -121,16 +102,11 @@ export function ConversationPanel({ onClose }: ConversationPanelProps) {
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={(node) => {
|
||||
// TODO: Combine both refs somehow
|
||||
if (ref.current !== node) ref.current = node;
|
||||
if (scrollContainerRef.current !== node)
|
||||
scrollContainerRef.current = node;
|
||||
}}
|
||||
ref={ref}
|
||||
data-testid="conversation-panel"
|
||||
className="w-[350px] h-full border border-neutral-700 bg-base-secondary rounded-xl overflow-y-auto absolute"
|
||||
>
|
||||
{isFetching && conversations.length === 0 && (
|
||||
{isFetching && (
|
||||
<div className="w-full h-full absolute flex justify-center items-center">
|
||||
<LoadingSpinner size="small" />
|
||||
</div>
|
||||
@@ -180,13 +156,6 @@ export function ConversationPanel({ onClose }: ConversationPanelProps) {
|
||||
</NavLink>
|
||||
))}
|
||||
|
||||
{/* Loading indicator for fetching more conversations */}
|
||||
{isFetchingNextPage && (
|
||||
<div className="flex justify-center py-4">
|
||||
<LoadingSpinner size="small" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{confirmDeleteModalVisible && (
|
||||
<ConfirmDeleteModal
|
||||
onConfirm={() => {
|
||||
|
||||
@@ -25,7 +25,6 @@ const saveSettingsMutationFn = async (settings: Partial<PostSettings>) => {
|
||||
mcp_config: settings.MCP_CONFIG,
|
||||
enable_proactive_conversation_starters:
|
||||
settings.ENABLE_PROACTIVE_CONVERSATION_STARTERS,
|
||||
enable_solvability_analysis: settings.ENABLE_SOLVABILITY_ANALYSIS,
|
||||
search_api_key: settings.SEARCH_API_KEY?.trim() || "",
|
||||
max_budget_per_task: settings.MAX_BUDGET_PER_TASK,
|
||||
git_user_name:
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import { useInfiniteQuery } from "@tanstack/react-query";
|
||||
import OpenHands from "#/api/open-hands";
|
||||
import { useIsAuthed } from "./use-is-authed";
|
||||
|
||||
export const usePaginatedConversations = (limit: number = 20) => {
|
||||
const { data: userIsAuthenticated } = useIsAuthed();
|
||||
|
||||
return useInfiniteQuery({
|
||||
queryKey: ["user", "conversations", "paginated", limit],
|
||||
queryFn: ({ pageParam }) =>
|
||||
OpenHands.getUserConversations(limit, pageParam),
|
||||
enabled: !!userIsAuthenticated,
|
||||
getNextPageParam: (lastPage) => lastPage.next_page_id,
|
||||
initialPageParam: undefined as string | undefined,
|
||||
});
|
||||
};
|
||||
@@ -4,7 +4,7 @@ import OpenHands from "#/api/open-hands";
|
||||
export const useSearchConversations = (
|
||||
selectedRepository?: string,
|
||||
conversationTrigger?: string,
|
||||
limit: number = 100,
|
||||
limit: number = 20,
|
||||
cacheDisabled: boolean = false,
|
||||
) =>
|
||||
useQuery({
|
||||
|
||||
@@ -25,7 +25,6 @@ const getSettingsQueryFn = async (): Promise<Settings> => {
|
||||
ENABLE_SOUND_NOTIFICATIONS: apiSettings.enable_sound_notifications,
|
||||
ENABLE_PROACTIVE_CONVERSATION_STARTERS:
|
||||
apiSettings.enable_proactive_conversation_starters,
|
||||
ENABLE_SOLVABILITY_ANALYSIS: apiSettings.enable_solvability_analysis,
|
||||
USER_CONSENTS_TO_ANALYTICS: apiSettings.user_consents_to_analytics,
|
||||
SEARCH_API_KEY: apiSettings.search_api_key || "",
|
||||
MAX_BUDGET_PER_TASK: apiSettings.max_budget_per_task,
|
||||
|
||||
13
frontend/src/hooks/query/use-user-conversations.ts
Normal file
13
frontend/src/hooks/query/use-user-conversations.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import OpenHands from "#/api/open-hands";
|
||||
import { useIsAuthed } from "./use-is-authed";
|
||||
|
||||
export const useUserConversations = () => {
|
||||
const { data: userIsAuthenticated } = useIsAuthed();
|
||||
|
||||
return useQuery({
|
||||
queryKey: ["user", "conversations"],
|
||||
queryFn: OpenHands.getUserConversations,
|
||||
enabled: !!userIsAuthenticated,
|
||||
});
|
||||
};
|
||||
@@ -1,42 +0,0 @@
|
||||
import { useEffect, useRef, useCallback } from "react";
|
||||
|
||||
interface UseInfiniteScrollOptions {
|
||||
hasNextPage: boolean;
|
||||
isFetchingNextPage: boolean;
|
||||
fetchNextPage: () => void;
|
||||
threshold?: number;
|
||||
}
|
||||
|
||||
export const useInfiniteScroll = ({
|
||||
hasNextPage,
|
||||
isFetchingNextPage,
|
||||
fetchNextPage,
|
||||
threshold = 100,
|
||||
}: UseInfiniteScrollOptions) => {
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const handleScroll = useCallback(() => {
|
||||
if (!containerRef.current || isFetchingNextPage || !hasNextPage) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { scrollTop, scrollHeight, clientHeight } = containerRef.current;
|
||||
const isNearBottom = scrollTop + clientHeight >= scrollHeight - threshold;
|
||||
|
||||
if (isNearBottom) {
|
||||
fetchNextPage();
|
||||
}
|
||||
}, [hasNextPage, isFetchingNextPage, fetchNextPage, threshold]);
|
||||
|
||||
useEffect(() => {
|
||||
const container = containerRef.current;
|
||||
if (!container) return undefined;
|
||||
|
||||
container.addEventListener("scroll", handleScroll);
|
||||
return () => {
|
||||
container.removeEventListener("scroll", handleScroll);
|
||||
};
|
||||
}, [handleScroll]);
|
||||
|
||||
return containerRef;
|
||||
};
|
||||
@@ -147,12 +147,10 @@ export enum I18nKey {
|
||||
SUGGESTIONS$CLEAN_DEPENDENCIES = "SUGGESTIONS$CLEAN_DEPENDENCIES",
|
||||
SETTINGS$LLM_SETTINGS = "SETTINGS$LLM_SETTINGS",
|
||||
SETTINGS$GIT_SETTINGS = "SETTINGS$GIT_SETTINGS",
|
||||
SETTINGS$GIT_SETTINGS_DESCRIPTION = "SETTINGS$GIT_SETTINGS_DESCRIPTION",
|
||||
SETTINGS$SOUND_NOTIFICATIONS = "SETTINGS$SOUND_NOTIFICATIONS",
|
||||
SETTINGS$MAX_BUDGET_PER_TASK = "SETTINGS$MAX_BUDGET_PER_TASK",
|
||||
SETTINGS$MAX_BUDGET_PER_CONVERSATION = "SETTINGS$MAX_BUDGET_PER_CONVERSATION",
|
||||
SETTINGS$PROACTIVE_CONVERSATION_STARTERS = "SETTINGS$PROACTIVE_CONVERSATION_STARTERS",
|
||||
SETTINGS$SOLVABILITY_ANALYSIS = "SETTINGS$SOLVABILITY_ANALYSIS",
|
||||
SETTINGS$SEARCH_API_KEY = "SETTINGS$SEARCH_API_KEY",
|
||||
SETTINGS$SEARCH_API_KEY_OPTIONAL = "SETTINGS$SEARCH_API_KEY_OPTIONAL",
|
||||
SETTINGS$SEARCH_API_KEY_INSTRUCTIONS = "SETTINGS$SEARCH_API_KEY_INSTRUCTIONS",
|
||||
|
||||
@@ -2351,22 +2351,6 @@
|
||||
"tr": "Git Ayarları",
|
||||
"uk": "Git налаштування"
|
||||
},
|
||||
"SETTINGS$GIT_SETTINGS_DESCRIPTION": {
|
||||
"en": "Configure the username and email that OpenHands uses to commit changes.",
|
||||
"ja": "OpenHandsがコミットに使用するユーザー名とメールを設定します。",
|
||||
"zh-CN": "配置OpenHands用于提交更改的用户名和电子邮件。",
|
||||
"zh-TW": "配置OpenHands用於提交更改的用戶名和電子郵件。",
|
||||
"ko-KR": "OpenHands가 변경 사항을 커밋할 때 사용하는 사용자 이름과 이메일을 구성합니다.",
|
||||
"de": "Konfigurieren Sie den Benutzernamen und die E-Mail, die OpenHands zum Committen von Änderungen verwendet.",
|
||||
"no": "Konfigurer brukernavnet og e-posten som OpenHands bruker for å committe endringer.",
|
||||
"it": "Configura il nome utente e l'email che OpenHands utilizza per committare le modifiche.",
|
||||
"pt": "Configure o nome de usuário e o email que o OpenHands usa para fazer commits de alterações.",
|
||||
"es": "Configure el nombre de usuario y el correo electrónico que OpenHands utiliza para confirmar cambios.",
|
||||
"ar": "قم بتكوين اسم المستخدم والبريد الإلكتروني الذي يستخدمه OpenHands لارتكاب التغييرات.",
|
||||
"fr": "Configurez le nom d'utilisateur et l'email qu'OpenHands utilise pour valider les modifications.",
|
||||
"tr": "OpenHands'ın değişiklikleri commit etmek için kullandığı kullanıcı adını ve e-postayı yapılandırın.",
|
||||
"uk": "Налаштуйте ім'я користувача та електронну пошту, які OpenHands використовує для фіксації змін."
|
||||
},
|
||||
"SETTINGS$SOUND_NOTIFICATIONS": {
|
||||
"en": "Sound Notifications",
|
||||
"ja": "サウンド通知",
|
||||
@@ -2431,22 +2415,6 @@
|
||||
"tr": "GitHub'da Görevler Öner",
|
||||
"uk": "Запропонувати завдання на GitHub"
|
||||
},
|
||||
"SETTINGS$SOLVABILITY_ANALYSIS": {
|
||||
"en": "Enable Solvability Analysis",
|
||||
"ja": "解決可能性分析を有効にする",
|
||||
"zh-CN": "启用可解决性分析",
|
||||
"zh-TW": "啟用可解決性分析",
|
||||
"ko-KR": "해결 가능성 분석 활성화",
|
||||
"de": "Lösbarkeitsanalyse aktivieren",
|
||||
"no": "Aktiver løsningsanalyse",
|
||||
"it": "Abilita analisi di risolvibilità",
|
||||
"pt": "Ativar análise de solucionabilidade",
|
||||
"es": "Habilitar análisis de solvencia",
|
||||
"ar": "تمكين تحليل القابلية للحل",
|
||||
"fr": "Activer l'analyse de solvabilité",
|
||||
"tr": "Çözünürlük Analizini Etkinleştir",
|
||||
"uk": "Увімкнути аналіз розв'язності"
|
||||
},
|
||||
"SETTINGS$SEARCH_API_KEY": {
|
||||
"en": "Search API Key (Tavily)",
|
||||
"ja": "検索APIキー (Tavily)",
|
||||
|
||||
@@ -30,7 +30,6 @@ export const MOCK_DEFAULT_USER_SETTINGS: ApiSettings | PostApiSettings = {
|
||||
enable_sound_notifications: DEFAULT_SETTINGS.ENABLE_SOUND_NOTIFICATIONS,
|
||||
enable_proactive_conversation_starters:
|
||||
DEFAULT_SETTINGS.ENABLE_PROACTIVE_CONVERSATION_STARTERS,
|
||||
enable_solvability_analysis: DEFAULT_SETTINGS.ENABLE_SOLVABILITY_ANALYSIS,
|
||||
user_consents_to_analytics: DEFAULT_SETTINGS.USER_CONSENTS_TO_ANALYTICS,
|
||||
max_budget_per_task: DEFAULT_SETTINGS.MAX_BUDGET_PER_TASK,
|
||||
};
|
||||
|
||||
@@ -38,10 +38,6 @@ function AppSettingsScreen() {
|
||||
proactiveConversationsSwitchHasChanged,
|
||||
setProactiveConversationsSwitchHasChanged,
|
||||
] = React.useState(false);
|
||||
const [
|
||||
solvabilityAnalysisSwitchHasChanged,
|
||||
setSolvabilityAnalysisSwitchHasChanged,
|
||||
] = React.useState(false);
|
||||
const [maxBudgetPerTaskHasChanged, setMaxBudgetPerTaskHasChanged] =
|
||||
React.useState(false);
|
||||
const [gitUserNameHasChanged, setGitUserNameHasChanged] =
|
||||
@@ -65,9 +61,6 @@ function AppSettingsScreen() {
|
||||
formData.get("enable-proactive-conversations-switch")?.toString() ===
|
||||
"on";
|
||||
|
||||
const enableSolvabilityAnalysis =
|
||||
formData.get("enable-solvability-analysis-switch")?.toString() === "on";
|
||||
|
||||
const maxBudgetPerTaskValue = formData
|
||||
.get("max-budget-per-task-input")
|
||||
?.toString();
|
||||
@@ -86,7 +79,6 @@ function AppSettingsScreen() {
|
||||
user_consents_to_analytics: enableAnalytics,
|
||||
ENABLE_SOUND_NOTIFICATIONS: enableSoundNotifications,
|
||||
ENABLE_PROACTIVE_CONVERSATION_STARTERS: enableProactiveConversations,
|
||||
ENABLE_SOLVABILITY_ANALYSIS: enableSolvabilityAnalysis,
|
||||
MAX_BUDGET_PER_TASK: maxBudgetPerTask,
|
||||
GIT_USER_NAME: gitUserName,
|
||||
GIT_USER_EMAIL: gitUserEmail,
|
||||
@@ -144,13 +136,6 @@ function AppSettingsScreen() {
|
||||
);
|
||||
};
|
||||
|
||||
const checkIfSolvabilityAnalysisSwitchHasChanged = (checked: boolean) => {
|
||||
const currentSolvabilityAnalysis = !!settings?.ENABLE_SOLVABILITY_ANALYSIS;
|
||||
setSolvabilityAnalysisSwitchHasChanged(
|
||||
checked !== currentSolvabilityAnalysis,
|
||||
);
|
||||
};
|
||||
|
||||
const checkIfMaxBudgetPerTaskHasChanged = (value: string) => {
|
||||
const newValue = parseMaxBudgetPerTask(value);
|
||||
const currentValue = settings?.MAX_BUDGET_PER_TASK;
|
||||
@@ -172,7 +157,6 @@ function AppSettingsScreen() {
|
||||
!analyticsSwitchHasChanged &&
|
||||
!soundNotificationsSwitchHasChanged &&
|
||||
!proactiveConversationsSwitchHasChanged &&
|
||||
!solvabilityAnalysisSwitchHasChanged &&
|
||||
!maxBudgetPerTaskHasChanged &&
|
||||
!gitUserNameHasChanged &&
|
||||
!gitUserEmailHasChanged;
|
||||
@@ -225,17 +209,6 @@ function AppSettingsScreen() {
|
||||
</SettingsSwitch>
|
||||
)}
|
||||
|
||||
{config?.APP_MODE === "saas" && (
|
||||
<SettingsSwitch
|
||||
testId="enable-solvability-analysis-switch"
|
||||
name="enable-solvability-analysis-switch"
|
||||
defaultIsToggled={!!settings.ENABLE_SOLVABILITY_ANALYSIS}
|
||||
onToggle={checkIfSolvabilityAnalysisSwitchHasChanged}
|
||||
>
|
||||
{t(I18nKey.SETTINGS$SOLVABILITY_ANALYSIS)}
|
||||
</SettingsSwitch>
|
||||
)}
|
||||
|
||||
<SettingsInput
|
||||
testId="max-budget-per-task-input"
|
||||
name="max-budget-per-task-input"
|
||||
@@ -249,13 +222,10 @@ function AppSettingsScreen() {
|
||||
className="w-full max-w-[680px]" // Match the width of the language field
|
||||
/>
|
||||
|
||||
<div className="border-t border-t-tertiary pt-6 mt-2">
|
||||
<h3 className="text-lg font-medium mb-2">
|
||||
<div className="border-t border-t-tertiary pt-6 mt-2 hidden">
|
||||
<h3 className="text-lg font-medium mb-4">
|
||||
{t(I18nKey.SETTINGS$GIT_SETTINGS)}
|
||||
</h3>
|
||||
<p className="text-sm text-secondary mb-4">
|
||||
{t(I18nKey.SETTINGS$GIT_SETTINGS_DESCRIPTION)}
|
||||
</p>
|
||||
<div className="flex flex-col gap-6">
|
||||
<SettingsInput
|
||||
testId="git-user-name-input"
|
||||
|
||||
@@ -17,7 +17,6 @@ export const DEFAULT_SETTINGS: Settings = {
|
||||
ENABLE_SOUND_NOTIFICATIONS: false,
|
||||
USER_CONSENTS_TO_ANALYTICS: false,
|
||||
ENABLE_PROACTIVE_CONVERSATION_STARTERS: false,
|
||||
ENABLE_SOLVABILITY_ANALYSIS: false,
|
||||
SEARCH_API_KEY: "",
|
||||
IS_NEW_USER: true,
|
||||
MAX_BUDGET_PER_TASK: null,
|
||||
|
||||
@@ -43,7 +43,6 @@ export type Settings = {
|
||||
ENABLE_DEFAULT_CONDENSER: boolean;
|
||||
ENABLE_SOUND_NOTIFICATIONS: boolean;
|
||||
ENABLE_PROACTIVE_CONVERSATION_STARTERS: boolean;
|
||||
ENABLE_SOLVABILITY_ANALYSIS: boolean;
|
||||
USER_CONSENTS_TO_ANALYTICS: boolean | null;
|
||||
SEARCH_API_KEY?: string;
|
||||
IS_NEW_USER?: boolean;
|
||||
@@ -69,7 +68,6 @@ export type ApiSettings = {
|
||||
enable_default_condenser: boolean;
|
||||
enable_sound_notifications: boolean;
|
||||
enable_proactive_conversation_starters: boolean;
|
||||
enable_solvability_analysis: boolean;
|
||||
user_consents_to_analytics: boolean | null;
|
||||
search_api_key?: string;
|
||||
provider_tokens_set: Partial<Record<Provider, string | null>>;
|
||||
|
||||
@@ -66,11 +66,6 @@ Your primary role is to assist users by executing commands, modifying code, and
|
||||
* Use APIs to work with GitHub or other platforms, unless the user asks otherwise or your task requires browsing.
|
||||
</SECURITY>
|
||||
|
||||
<EXTERNAL_SERVICES>
|
||||
* When interacting with external services like GitHub, GitLab, or Bitbucket, use their respective APIs instead of browser-based interactions whenever possible.
|
||||
* Only resort to browser-based interactions with these services if specifically requested by the user or if the required operation cannot be performed via API.
|
||||
</EXTERNAL_SERVICES>
|
||||
|
||||
<ENVIRONMENT_SETUP>
|
||||
* When user asks you to run an application, don't stop if the application is not installed. Instead, please install the application and run the command again.
|
||||
* If you encounter missing dependencies:
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import re
|
||||
import sys
|
||||
|
||||
from litellm import ChatCompletionToolParam, ChatCompletionToolParamFunctionChunk
|
||||
|
||||
from openhands.agenthub.codeact_agent.tools.prompt import refine_prompt
|
||||
from openhands.llm.tool_names import EXECUTE_BASH_TOOL_NAME
|
||||
|
||||
_DETAILED_BASH_DESCRIPTION = """Execute a bash command in the terminal within a persistent shell session.
|
||||
@@ -34,6 +36,21 @@ _SHORT_BASH_DESCRIPTION = """Execute a bash command in the terminal.
|
||||
* One command at a time: You can only execute one bash command at a time. If you need to run multiple commands sequentially, you can use `&&` or `;` to chain them together."""
|
||||
|
||||
|
||||
def refine_prompt(prompt: str):
|
||||
if sys.platform == 'win32':
|
||||
# Replace 'bash' with 'powershell' including tool names like 'execute_bash'
|
||||
# First replace 'execute_bash' with 'execute_powershell' to handle tool names
|
||||
result = re.sub(
|
||||
r'\bexecute_bash\b', 'execute_powershell', prompt, flags=re.IGNORECASE
|
||||
)
|
||||
# Then replace standalone 'bash' with 'powershell'
|
||||
result = re.sub(
|
||||
r'(?<!execute_)(?<!_)\bbash\b', 'powershell', result, flags=re.IGNORECASE
|
||||
)
|
||||
return result
|
||||
return prompt
|
||||
|
||||
|
||||
def create_cmd_run_tool(
|
||||
use_short_description: bool = False,
|
||||
) -> ChatCompletionToolParam:
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
def refine_prompt(prompt: str):
|
||||
"""
|
||||
Refines the prompt based on the platform.
|
||||
|
||||
On Windows systems, replaces 'bash' with 'powershell' and 'execute_bash' with 'execute_powershell'
|
||||
to ensure commands work correctly on the Windows platform.
|
||||
|
||||
Args:
|
||||
prompt: The prompt text to refine
|
||||
|
||||
Returns:
|
||||
The refined prompt text
|
||||
"""
|
||||
if sys.platform == 'win32':
|
||||
# Replace 'bash' with 'powershell' including tool names like 'execute_bash'
|
||||
# First replace 'execute_bash' with 'execute_powershell' to handle tool names
|
||||
result = re.sub(
|
||||
r'\bexecute_bash\b', 'execute_powershell', prompt, flags=re.IGNORECASE
|
||||
)
|
||||
# Then replace standalone 'bash' with 'powershell'
|
||||
result = re.sub(
|
||||
r'(?<!execute_)(?<!_)\bbash\b', 'powershell', result, flags=re.IGNORECASE
|
||||
)
|
||||
return result
|
||||
return prompt
|
||||
@@ -5,13 +5,14 @@
|
||||
import asyncio
|
||||
import contextlib
|
||||
import datetime
|
||||
import io
|
||||
import json
|
||||
import shutil
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
from typing import Generator
|
||||
|
||||
import markdown # type: ignore
|
||||
from prompt_toolkit import PromptSession, print_formatted_text
|
||||
from prompt_toolkit.application import Application
|
||||
from prompt_toolkit.completion import CompleteEvent, Completer, Completion
|
||||
@@ -29,6 +30,8 @@ from prompt_toolkit.patch_stdout import patch_stdout
|
||||
from prompt_toolkit.shortcuts import print_container
|
||||
from prompt_toolkit.styles import Style
|
||||
from prompt_toolkit.widgets import Frame, TextArea
|
||||
from rich.console import Console
|
||||
from rich.markdown import Markdown
|
||||
|
||||
from openhands import __version__
|
||||
from openhands.core.config import OpenHandsConfig
|
||||
@@ -37,6 +40,7 @@ from openhands.events import EventSource, EventStream
|
||||
from openhands.events.action import (
|
||||
Action,
|
||||
ActionConfirmationStatus,
|
||||
AgentFinishAction,
|
||||
ChangeAgentStateAction,
|
||||
CmdRunAction,
|
||||
MCPAction,
|
||||
@@ -66,11 +70,12 @@ MAX_RECENT_THOUGHTS = 5
|
||||
# Color and styling constants
|
||||
COLOR_GOLD = '#FFD700'
|
||||
COLOR_GREY = '#808080'
|
||||
COLOR_AGENT_BLUE = '#4682B4' # Steel blue - less saturated, works well on both light and dark backgrounds
|
||||
COLOR_AGENT_BLUE = '#5FAFFF' # Soft blue for all agent outputs
|
||||
DEFAULT_STYLE = Style.from_dict(
|
||||
{
|
||||
'gold': COLOR_GOLD,
|
||||
'grey': COLOR_GREY,
|
||||
'agent-blue': COLOR_AGENT_BLUE,
|
||||
'prompt': f'{COLOR_GOLD} bold',
|
||||
}
|
||||
)
|
||||
@@ -238,19 +243,13 @@ def display_mcp_errors() -> None:
|
||||
|
||||
|
||||
# Prompt output display functions
|
||||
def display_thought_if_new(thought: str, is_agent_message: bool = False) -> None:
|
||||
"""
|
||||
Display a thought only if it hasn't been displayed recently.
|
||||
|
||||
Args:
|
||||
thought: The thought to display
|
||||
is_agent_message: If True, apply agent styling and markdown rendering
|
||||
"""
|
||||
def display_thought_if_new(thought: str) -> None:
|
||||
"""Display a thought only if it hasn't been displayed recently."""
|
||||
global recent_thoughts
|
||||
if thought and thought.strip():
|
||||
# Check if this thought was recently displayed
|
||||
if thought not in recent_thoughts:
|
||||
display_message(thought, is_agent_message=is_agent_message)
|
||||
display_message(thought)
|
||||
recent_thoughts.append(thought)
|
||||
# Keep only the most recent thoughts
|
||||
if len(recent_thoughts) > MAX_RECENT_THOUGHTS:
|
||||
@@ -260,10 +259,22 @@ def display_thought_if_new(thought: str, is_agent_message: bool = False) -> None
|
||||
def display_event(event: Event, config: OpenHandsConfig) -> None:
|
||||
global streaming_output_text_area
|
||||
with print_lock:
|
||||
if isinstance(event, CmdRunAction):
|
||||
if isinstance(event, AgentFinishAction):
|
||||
# Handle agent finish actions with special styling
|
||||
# Determine the message to display
|
||||
if event.final_thought:
|
||||
message = event.final_thought
|
||||
elif event.thought:
|
||||
message = event.thought
|
||||
else:
|
||||
message = "All done! What's next on the agenda?"
|
||||
|
||||
# Display with finish styling
|
||||
display_agent_message(message, is_finish=True)
|
||||
elif isinstance(event, CmdRunAction):
|
||||
# For CmdRunAction, display thought first, then command
|
||||
if hasattr(event, 'thought') and event.thought:
|
||||
display_thought_if_new(event.thought)
|
||||
display_message(event.thought)
|
||||
|
||||
# Only display the command if it's not already confirmed
|
||||
# Commands are always shown when AWAITING_CONFIRMATION, so we don't need to show them again when CONFIRMED
|
||||
@@ -277,15 +288,14 @@ def display_event(event: Event, config: OpenHandsConfig) -> None:
|
||||
elif isinstance(event, Action):
|
||||
# For other actions, display thoughts normally
|
||||
if hasattr(event, 'thought') and event.thought:
|
||||
display_thought_if_new(event.thought)
|
||||
display_message(event.thought)
|
||||
if hasattr(event, 'final_thought') and event.final_thought:
|
||||
# Display final thoughts with agent styling
|
||||
display_message(event.final_thought, is_agent_message=True)
|
||||
display_message(event.final_thought)
|
||||
|
||||
if isinstance(event, MessageAction):
|
||||
if event.source == EventSource.AGENT:
|
||||
# Display agent messages with styling and markdown rendering
|
||||
display_thought_if_new(event.content, is_agent_message=True)
|
||||
# Display agent messages with distinctive styling
|
||||
display_agent_message(event.content)
|
||||
elif isinstance(event, CmdOutputObservation):
|
||||
display_command_output(event.content)
|
||||
elif isinstance(event, FileEditObservation):
|
||||
@@ -300,76 +310,61 @@ def display_event(event: Event, config: OpenHandsConfig) -> None:
|
||||
display_error(event.content)
|
||||
|
||||
|
||||
def display_message(message: str, is_agent_message: bool = False) -> None:
|
||||
def process_markdown_for_terminal(text: str) -> str:
|
||||
"""
|
||||
Display a message in the terminal with markdown rendering.
|
||||
Process markdown syntax for terminal display using Rich.
|
||||
This function renders markdown as formatted text for the terminal.
|
||||
"""
|
||||
if not text:
|
||||
return text
|
||||
|
||||
# Use Rich to render the markdown without width constraints
|
||||
console = Console(file=io.StringIO(), highlight=False, width=None)
|
||||
console.print(Markdown(text))
|
||||
|
||||
# Get the rendered output
|
||||
rendered_text = console.file.getvalue() # type: ignore
|
||||
|
||||
return rendered_text.strip()
|
||||
|
||||
|
||||
def display_message(message: str) -> None:
|
||||
message = message.strip()
|
||||
|
||||
if message:
|
||||
print_formatted_text(f'\n{message}')
|
||||
|
||||
|
||||
def display_agent_message(message: str, is_finish: bool = False) -> None:
|
||||
"""
|
||||
Display a message from the agent with distinctive styling and markdown rendering.
|
||||
|
||||
Args:
|
||||
message: The message to display
|
||||
is_agent_message: If True, apply agent styling (blue color)
|
||||
message: The message content to display
|
||||
is_finish: Whether this is a finish message (changes the icon)
|
||||
"""
|
||||
message = message.strip()
|
||||
|
||||
if message:
|
||||
# Add spacing before the message
|
||||
print_formatted_text('')
|
||||
|
||||
# Process markdown in the message
|
||||
try:
|
||||
# Convert markdown to HTML for all messages
|
||||
html_content = convert_markdown_to_html(message)
|
||||
# Process markdown for terminal display
|
||||
processed_message = process_markdown_for_terminal(message)
|
||||
except Exception:
|
||||
# If markdown processing fails, use the original message
|
||||
processed_message = message
|
||||
|
||||
if is_agent_message:
|
||||
# Use prompt_toolkit's HTML renderer with the agent color
|
||||
print_formatted_text(
|
||||
HTML(f'<style fg="{COLOR_AGENT_BLUE}">{html_content}</style>')
|
||||
)
|
||||
else:
|
||||
# Regular message display with HTML rendering but default color
|
||||
print_formatted_text(HTML(html_content))
|
||||
except Exception as e:
|
||||
# If HTML rendering fails, fall back to plain text
|
||||
print(f'Warning: HTML rendering failed: {str(e)}', file=sys.stderr)
|
||||
if is_agent_message:
|
||||
print_formatted_text(
|
||||
FormattedText([('fg:' + COLOR_AGENT_BLUE, message)])
|
||||
)
|
||||
else:
|
||||
print_formatted_text(message)
|
||||
|
||||
|
||||
def convert_markdown_to_html(text: str) -> str:
|
||||
"""
|
||||
Convert markdown to HTML for prompt_toolkit's HTML renderer using the markdown library.
|
||||
|
||||
Args:
|
||||
text: Markdown text to convert
|
||||
|
||||
Returns:
|
||||
HTML formatted text with custom styling for headers and bullet points
|
||||
"""
|
||||
if not text:
|
||||
return text
|
||||
|
||||
# Use the markdown library to convert markdown to HTML
|
||||
# Enable the 'extra' extension for tables, fenced code, etc.
|
||||
html = markdown.markdown(text, extensions=['extra'])
|
||||
|
||||
# Customize headers
|
||||
for i in range(1, 7):
|
||||
# Get the appropriate number of # characters for this heading level
|
||||
prefix = '#' * i + ' '
|
||||
|
||||
# Replace <h1> with the prefix and bold text
|
||||
html = html.replace(f'<h{i}>', f'<b>{prefix}')
|
||||
html = html.replace(f'</h{i}>', '</b>\n')
|
||||
|
||||
# Customize bullet points to use dashes instead of dots with compact spacing
|
||||
html = html.replace('<ul>', '')
|
||||
html = html.replace('</ul>', '')
|
||||
html = html.replace('<li>', '- ')
|
||||
html = html.replace('</li>', '')
|
||||
|
||||
return html
|
||||
# Choose the appropriate icon based on message type
|
||||
icon = '🎯' if is_finish else '🔹'
|
||||
header_text = 'Agent Finished' if is_finish else 'Agent Message'
|
||||
|
||||
# Print a simple header
|
||||
print_formatted_text(FormattedText([('fg:' + COLOR_AGENT_BLUE, f'\n{icon} {header_text}')]))
|
||||
print_formatted_text('')
|
||||
|
||||
# Print the message content directly without any wrapping constraints
|
||||
print_formatted_text(FormattedText([('fg:' + COLOR_AGENT_BLUE, processed_message)]))
|
||||
print_formatted_text('')
|
||||
|
||||
|
||||
def display_error(error: str) -> None:
|
||||
|
||||
@@ -72,7 +72,6 @@ class OpenHandsConfig(BaseModel):
|
||||
file_store_path: str = Field(default='~/.openhands')
|
||||
file_store_web_hook_url: str | None = Field(default=None)
|
||||
file_store_web_hook_headers: dict | None = Field(default=None)
|
||||
file_store_web_hook_batch: bool = Field(default=False)
|
||||
enable_browser: bool = Field(default=True)
|
||||
save_trajectory_path: str | None = Field(default=None)
|
||||
save_screenshots_in_trajectory: bool = Field(default=False)
|
||||
|
||||
@@ -4,7 +4,6 @@ from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from openhands.controller.agent import Agent
|
||||
from openhands.memory.memory import Memory
|
||||
|
||||
|
||||
from mcp import McpError
|
||||
@@ -21,6 +20,7 @@ from openhands.events.observation.mcp import MCPObservation
|
||||
from openhands.events.observation.observation import Observation
|
||||
from openhands.mcp.client import MCPClient
|
||||
from openhands.mcp.error_collector import mcp_error_collector
|
||||
from openhands.memory.memory import Memory
|
||||
from openhands.runtime.base import Runtime
|
||||
from openhands.runtime.impl.cli.cli_runtime import CLIRuntime
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import docker
|
||||
import httpx
|
||||
import tenacity
|
||||
from docker.models.containers import Container
|
||||
from docker.types import DriverConfig, Mount
|
||||
|
||||
from openhands.core.config import OpenHandsConfig
|
||||
from openhands.core.exceptions import (
|
||||
@@ -259,9 +258,6 @@ class DockerRuntime(ActionExecutionClient):
|
||||
container_path = parts[1]
|
||||
# Default mode is 'rw' if not specified
|
||||
mount_mode = parts[2] if len(parts) > 2 else 'rw'
|
||||
# Skip overlay mounts here; they will be handled separately via Mount objects
|
||||
if 'overlay' in mount_mode:
|
||||
continue
|
||||
|
||||
volumes[host_path] = {
|
||||
'bind': container_path,
|
||||
@@ -290,72 +286,6 @@ class DockerRuntime(ActionExecutionClient):
|
||||
|
||||
return volumes
|
||||
|
||||
def _process_overlay_mounts(self) -> list[Mount]:
|
||||
"""Process overlay mounts specified in sandbox.volumes with mode containing 'overlay'.
|
||||
|
||||
Returns:
|
||||
List of docker.types.Mount objects configured with overlay driver providing
|
||||
read-only lowerdir with per-container copy-on-write upper/work layers.
|
||||
"""
|
||||
overlay_mounts: list[Mount] = []
|
||||
|
||||
# No volumes configured
|
||||
if self.config.sandbox.volumes is None:
|
||||
return overlay_mounts
|
||||
|
||||
# Base directory for overlay upper/work layers from env var
|
||||
overlay_base = os.environ.get('SANDBOX_VOLUME_OVERLAYS')
|
||||
if not overlay_base:
|
||||
# If no base path provided, skip overlay processing
|
||||
return overlay_mounts
|
||||
|
||||
os.makedirs(overlay_base, exist_ok=True)
|
||||
|
||||
mount_specs = self.config.sandbox.volumes.split(',')
|
||||
|
||||
for idx, mount_spec in enumerate(mount_specs):
|
||||
parts = mount_spec.split(':')
|
||||
if len(parts) < 2:
|
||||
continue
|
||||
host_path = os.path.abspath(parts[0])
|
||||
container_path = parts[1]
|
||||
mount_mode = parts[2] if len(parts) > 2 else 'rw'
|
||||
|
||||
if 'overlay' not in mount_mode:
|
||||
continue
|
||||
|
||||
# Prepare upper and work directories unique to this container and mount
|
||||
overlay_dir = os.path.join(overlay_base, self.container_name, f'{idx}')
|
||||
upper_dir = os.path.join(overlay_dir, 'upper')
|
||||
work_dir = os.path.join(overlay_dir, 'work')
|
||||
os.makedirs(upper_dir, exist_ok=True)
|
||||
os.makedirs(work_dir, exist_ok=True)
|
||||
|
||||
driver_cfg = DriverConfig(
|
||||
name='local',
|
||||
options={
|
||||
'type': 'overlay',
|
||||
'device': 'overlay',
|
||||
'o': f'lowerdir={host_path},upperdir={upper_dir},workdir={work_dir}',
|
||||
},
|
||||
)
|
||||
|
||||
mount = Mount(
|
||||
target=container_path,
|
||||
source='', # Anonymous volume
|
||||
type='volume',
|
||||
labels={
|
||||
'app': 'openhands',
|
||||
'role': 'worker',
|
||||
'container': self.container_name,
|
||||
},
|
||||
driver_config=driver_cfg,
|
||||
)
|
||||
|
||||
overlay_mounts.append(mount)
|
||||
|
||||
return overlay_mounts
|
||||
|
||||
def init_container(self) -> None:
|
||||
self.log('debug', 'Preparing to start container...')
|
||||
self.set_runtime_status(RuntimeStatus.STARTING_RUNTIME)
|
||||
@@ -479,9 +409,6 @@ class DockerRuntime(ActionExecutionClient):
|
||||
try:
|
||||
if self.runtime_container_image is None:
|
||||
raise ValueError('Runtime container image is not set')
|
||||
# Process overlay mounts (read-only lower with per-container COW)
|
||||
overlay_mounts = self._process_overlay_mounts()
|
||||
|
||||
self.container = self.docker_client.containers.run(
|
||||
self.runtime_container_image,
|
||||
command=command,
|
||||
@@ -494,7 +421,6 @@ class DockerRuntime(ActionExecutionClient):
|
||||
detach=True,
|
||||
environment=environment,
|
||||
volumes=volumes, # type: ignore
|
||||
mounts=overlay_mounts, # type: ignore
|
||||
device_requests=device_requests,
|
||||
**(self.config.sandbox.docker_runtime_kwargs or {}),
|
||||
)
|
||||
@@ -683,8 +609,7 @@ class DockerRuntime(ActionExecutionClient):
|
||||
|
||||
def pause(self) -> None:
|
||||
"""Pause the runtime by stopping the container.
|
||||
This is different from container.stop() as it ensures environment variables are properly preserved.
|
||||
"""
|
||||
This is different from container.stop() as it ensures environment variables are properly preserved."""
|
||||
if not self.container:
|
||||
raise RuntimeError('Container not initialized')
|
||||
|
||||
@@ -697,8 +622,7 @@ class DockerRuntime(ActionExecutionClient):
|
||||
|
||||
def resume(self) -> None:
|
||||
"""Resume the runtime by starting the container.
|
||||
This is different from container.start() as it ensures environment variables are properly restored.
|
||||
"""
|
||||
This is different from container.start() as it ensures environment variables are properly restored."""
|
||||
if not self.container:
|
||||
raise RuntimeError('Container not initialized')
|
||||
|
||||
|
||||
@@ -39,10 +39,7 @@ def split_bash_commands(commands: str) -> list[str]:
|
||||
f'[warning]: {traceback.format_exc()}\n'
|
||||
f'The original command will be returned as is.'
|
||||
)
|
||||
# If parsing fails, check if it's a comment-only command
|
||||
if _is_comment_only(commands):
|
||||
# For comment-only input, return it as a single command to preserve original behavior
|
||||
return [commands]
|
||||
# If parsing fails, return the original commands
|
||||
return [commands]
|
||||
|
||||
result: list[str] = []
|
||||
@@ -78,33 +75,7 @@ def split_bash_commands(commands: str) -> list[str]:
|
||||
if remaining:
|
||||
result.append(remaining)
|
||||
logger.debug(f'BASH PARSING result.append(remaining): {result[-1]}')
|
||||
|
||||
# Return only non-comment commands
|
||||
filtered_result = [cmd for cmd in result if not _is_comment_only(cmd)]
|
||||
|
||||
# Special case: if all commands are comments, return them as a single command
|
||||
# This preserves the original behavior for comment-only input
|
||||
if not filtered_result and result:
|
||||
# Combine all comment commands into one
|
||||
combined_comments = '\n'.join(result)
|
||||
filtered_result = [combined_comments]
|
||||
|
||||
logger.debug(f'BASH PARSING final result: {result} -> {filtered_result}')
|
||||
return filtered_result
|
||||
|
||||
|
||||
def _is_comment_only(command: str) -> bool:
|
||||
"""Check if a command consists only of comments.
|
||||
|
||||
Args:
|
||||
command: The command string to check
|
||||
|
||||
Returns:
|
||||
True if the command contains only comments, False otherwise
|
||||
"""
|
||||
# Split the command into lines and check if each line is a comment
|
||||
lines = command.strip().split('\n')
|
||||
return all(line.strip().startswith('#') for line in lines if line.strip())
|
||||
return result
|
||||
|
||||
|
||||
def escape_bash_special_chars(command: str) -> str:
|
||||
@@ -530,7 +501,6 @@ class BashSession:
|
||||
|
||||
# Check if the command is a single command or multiple commands
|
||||
splited_commands = split_bash_commands(command)
|
||||
|
||||
if len(splited_commands) > 1:
|
||||
return ErrorObservation(
|
||||
content=(
|
||||
|
||||
@@ -280,11 +280,6 @@ def prep_build_folder(
|
||||
),
|
||||
)
|
||||
|
||||
# Copy the 'microagents' directory (Microagents)
|
||||
shutil.copytree(
|
||||
Path(project_root, 'microagents'), Path(build_folder, 'code', 'microagents')
|
||||
)
|
||||
|
||||
# Copy pyproject.toml and poetry.lock files
|
||||
for file in ['pyproject.toml', 'poetry.lock']:
|
||||
src = Path(openhands_source_dir, file)
|
||||
|
||||
@@ -239,8 +239,7 @@ COPY ./code/pyproject.toml ./code/poetry.lock /openhands/code/
|
||||
# ================================================================
|
||||
RUN if [ -d /openhands/code/openhands ]; then rm -rf /openhands/code/openhands; fi
|
||||
COPY ./code/pyproject.toml ./code/poetry.lock /openhands/code/
|
||||
RUN if [ -d /openhands/code/microagents ]; then rm -rf /openhands/code/microagents; fi
|
||||
COPY ./code/microagents /openhands/code/microagents
|
||||
|
||||
COPY ./code/openhands /openhands/code/openhands
|
||||
RUN chmod a+rwx /openhands/code/openhands/__init__.py
|
||||
|
||||
|
||||
@@ -27,11 +27,10 @@ assert isinstance(server_config_interface, ServerConfig), (
|
||||
)
|
||||
server_config: ServerConfig = server_config_interface
|
||||
file_store: FileStore = get_file_store(
|
||||
file_store_type=config.file_store,
|
||||
file_store_path=config.file_store_path,
|
||||
file_store_web_hook_url=config.file_store_web_hook_url,
|
||||
file_store_web_hook_headers=config.file_store_web_hook_headers,
|
||||
file_store_web_hook_batch=config.file_store_web_hook_batch,
|
||||
config.file_store,
|
||||
config.file_store_path,
|
||||
config.file_store_web_hook_url,
|
||||
config.file_store_web_hook_headers,
|
||||
)
|
||||
|
||||
client_manager = None
|
||||
|
||||
@@ -61,12 +61,9 @@ The `WebHookFileStore` wraps another `FileStore` implementation and sends HTTP r
|
||||
**Configuration Options:**
|
||||
- `file_store_web_hook_url`: The base URL for webhook requests
|
||||
- `file_store_web_hook_headers`: HTTP headers to include in webhook requests
|
||||
- `file_store_web_hook_batch`: Whether to use batched webhook requests (default: false)
|
||||
|
||||
### Protocol Details
|
||||
|
||||
#### Standard Webhook Protocol (Non-Batched)
|
||||
|
||||
1. **File Write Operation**:
|
||||
- When a file is written, a POST request is sent to `{base_url}{path}`
|
||||
- The request body contains the file contents
|
||||
@@ -76,27 +73,6 @@ The `WebHookFileStore` wraps another `FileStore` implementation and sends HTTP r
|
||||
- When a file is deleted, a DELETE request is sent to `{base_url}{path}`
|
||||
- The operation is retried up to 3 times with a 1-second delay between attempts
|
||||
|
||||
#### Batched Webhook Protocol
|
||||
|
||||
The `BatchedWebHookFileStore` extends the webhook functionality by batching multiple file operations into a single request, which can significantly improve performance when many files are being modified in a short period of time.
|
||||
|
||||
1. **Batch Request**:
|
||||
- A single POST request is sent to `{base_url}` with a JSON array in the body
|
||||
- Each item in the array contains:
|
||||
- `method`: "POST" for write operations, "DELETE" for delete operations
|
||||
- `path`: The file path
|
||||
- `content`: The file contents (for write operations only)
|
||||
- `encoding`: "base64" if binary content was base64-encoded (optional)
|
||||
|
||||
2. **Batch Triggering**:
|
||||
- Batches are sent when one of the following conditions is met:
|
||||
- A timeout period has elapsed (defaults to 5 seconds, configurable via constructor parameter)
|
||||
- The total size of batched content exceeds a size limit (defaults to 1MB, configurable via constructor parameter)
|
||||
- The `flush()` method is explicitly called
|
||||
|
||||
3. **Error Handling**:
|
||||
- The batch request is retried up to 3 times with a 1-second delay between attempts
|
||||
|
||||
## Configuration
|
||||
|
||||
To configure the storage module in OpenHands, use the following configuration options:
|
||||
@@ -114,14 +90,4 @@ file_store_web_hook_url = "https://example.com/api/files"
|
||||
|
||||
# Optional webhook headers (JSON string)
|
||||
file_store_web_hook_headers = '{"Authorization": "Bearer token"}'
|
||||
|
||||
# Optional batched webhook mode (default: false)
|
||||
file_store_web_hook_batch = true
|
||||
```
|
||||
|
||||
**Batched Webhook Configuration:**
|
||||
The batched webhook behavior uses predefined constants with the following default values:
|
||||
- Batch timeout: 5 seconds
|
||||
- Batch size limit: 1MB (1048576 bytes)
|
||||
|
||||
These values can be customized by passing `batch_timeout_seconds` and `batch_size_limit_bytes` parameters to the `BatchedWebHookFileStore` constructor.
|
||||
|
||||
@@ -2,7 +2,6 @@ import os
|
||||
|
||||
import httpx
|
||||
|
||||
from openhands.storage.batched_web_hook import BatchedWebHookFileStore
|
||||
from openhands.storage.files import FileStore
|
||||
from openhands.storage.google_cloud import GoogleCloudFileStore
|
||||
from openhands.storage.local import LocalFileStore
|
||||
@@ -16,7 +15,6 @@ def get_file_store(
|
||||
file_store_path: str | None = None,
|
||||
file_store_web_hook_url: str | None = None,
|
||||
file_store_web_hook_headers: dict | None = None,
|
||||
file_store_web_hook_batch: bool = False,
|
||||
) -> FileStore:
|
||||
store: FileStore
|
||||
if file_store_type == 'local':
|
||||
@@ -37,21 +35,9 @@ def get_file_store(
|
||||
file_store_web_hook_headers['X-Session-API-Key'] = os.getenv(
|
||||
'SESSION_API_KEY'
|
||||
)
|
||||
|
||||
client = httpx.Client(headers=file_store_web_hook_headers or {})
|
||||
|
||||
if file_store_web_hook_batch:
|
||||
# Use batched webhook file store
|
||||
store = BatchedWebHookFileStore(
|
||||
store,
|
||||
file_store_web_hook_url,
|
||||
client,
|
||||
)
|
||||
else:
|
||||
# Use regular webhook file store
|
||||
store = WebHookFileStore(
|
||||
store,
|
||||
file_store_web_hook_url,
|
||||
client,
|
||||
)
|
||||
store = WebHookFileStore(
|
||||
store,
|
||||
file_store_web_hook_url,
|
||||
httpx.Client(headers=file_store_web_hook_headers or {}),
|
||||
)
|
||||
return store
|
||||
|
||||
@@ -1,274 +0,0 @@
|
||||
import threading
|
||||
from typing import Optional, Union
|
||||
|
||||
import httpx
|
||||
import tenacity
|
||||
|
||||
from openhands.storage.files import FileStore
|
||||
from openhands.utils.async_utils import EXECUTOR
|
||||
|
||||
# Constants for batching configuration
|
||||
WEBHOOK_BATCH_TIMEOUT_SECONDS = 5.0
|
||||
WEBHOOK_BATCH_SIZE_LIMIT_BYTES = 1048576 # 1MB
|
||||
|
||||
|
||||
class BatchedWebHookFileStore(FileStore):
|
||||
"""
|
||||
File store which batches updates before sending them to a webhook.
|
||||
|
||||
This class wraps another FileStore implementation and sends HTTP requests
|
||||
to a specified URL when files are written or deleted. Updates are batched
|
||||
and sent together after a certain amount of time passes or if the content
|
||||
size exceeds a threshold.
|
||||
|
||||
Attributes:
|
||||
file_store: The underlying FileStore implementation
|
||||
base_url: The base URL for webhook requests
|
||||
client: The HTTP client used to make webhook requests
|
||||
batch_timeout_seconds: Time in seconds after which a batch is sent (default: WEBHOOK_BATCH_TIMEOUT_SECONDS)
|
||||
batch_size_limit_bytes: Size limit in bytes after which a batch is sent (default: WEBHOOK_BATCH_SIZE_LIMIT_BYTES)
|
||||
_batch_lock: Lock for thread-safe access to the batch
|
||||
_batch: Dictionary of pending file updates
|
||||
_batch_timer: Timer for sending batches after timeout
|
||||
_batch_size: Current size of the batch in bytes
|
||||
"""
|
||||
|
||||
file_store: FileStore
|
||||
base_url: str
|
||||
client: httpx.Client
|
||||
batch_timeout_seconds: float
|
||||
batch_size_limit_bytes: int
|
||||
_batch_lock: threading.Lock
|
||||
_batch: dict[str, tuple[str, Optional[Union[str, bytes]]]]
|
||||
_batch_timer: Optional[threading.Timer]
|
||||
_batch_size: int
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
file_store: FileStore,
|
||||
base_url: str,
|
||||
client: Optional[httpx.Client] = None,
|
||||
batch_timeout_seconds: Optional[float] = None,
|
||||
batch_size_limit_bytes: Optional[int] = None,
|
||||
):
|
||||
"""
|
||||
Initialize a BatchedWebHookFileStore.
|
||||
|
||||
Args:
|
||||
file_store: The underlying FileStore implementation
|
||||
base_url: The base URL for webhook requests
|
||||
client: Optional HTTP client to use for requests. If None, a new client will be created.
|
||||
batch_timeout_seconds: Time in seconds after which a batch is sent.
|
||||
If None, uses the default constant WEBHOOK_BATCH_TIMEOUT_SECONDS.
|
||||
batch_size_limit_bytes: Size limit in bytes after which a batch is sent.
|
||||
If None, uses the default constant WEBHOOK_BATCH_SIZE_LIMIT_BYTES.
|
||||
"""
|
||||
self.file_store = file_store
|
||||
self.base_url = base_url
|
||||
if client is None:
|
||||
client = httpx.Client()
|
||||
self.client = client
|
||||
|
||||
# Use provided values or default constants
|
||||
self.batch_timeout_seconds = (
|
||||
batch_timeout_seconds or WEBHOOK_BATCH_TIMEOUT_SECONDS
|
||||
)
|
||||
self.batch_size_limit_bytes = (
|
||||
batch_size_limit_bytes or WEBHOOK_BATCH_SIZE_LIMIT_BYTES
|
||||
)
|
||||
|
||||
# Initialize batch state
|
||||
self._batch_lock = threading.Lock()
|
||||
self._batch = {} # Maps path -> (operation, content)
|
||||
self._batch_timer = None
|
||||
self._batch_size = 0
|
||||
|
||||
def write(self, path: str, contents: Union[str, bytes]) -> None:
|
||||
"""
|
||||
Write contents to a file and queue a webhook update.
|
||||
|
||||
Args:
|
||||
path: The path to write to
|
||||
contents: The contents to write
|
||||
"""
|
||||
self.file_store.write(path, contents)
|
||||
self._queue_update(path, 'write', contents)
|
||||
|
||||
def read(self, path: str) -> str:
|
||||
"""
|
||||
Read contents from a file.
|
||||
|
||||
Args:
|
||||
path: The path to read from
|
||||
|
||||
Returns:
|
||||
The contents of the file
|
||||
"""
|
||||
return self.file_store.read(path)
|
||||
|
||||
def list(self, path: str) -> list[str]:
|
||||
"""
|
||||
List files in a directory.
|
||||
|
||||
Args:
|
||||
path: The directory path to list
|
||||
|
||||
Returns:
|
||||
A list of file paths
|
||||
"""
|
||||
return self.file_store.list(path)
|
||||
|
||||
def delete(self, path: str) -> None:
|
||||
"""
|
||||
Delete a file and queue a webhook update.
|
||||
|
||||
Args:
|
||||
path: The path to delete
|
||||
"""
|
||||
self.file_store.delete(path)
|
||||
self._queue_update(path, 'delete', None)
|
||||
|
||||
def _queue_update(
|
||||
self, path: str, operation: str, contents: Optional[Union[str, bytes]]
|
||||
) -> None:
|
||||
"""
|
||||
Queue an update to be sent to the webhook.
|
||||
|
||||
Args:
|
||||
path: The path that was modified
|
||||
operation: The operation performed ("write" or "delete")
|
||||
contents: The contents that were written (None for delete operations)
|
||||
"""
|
||||
with self._batch_lock:
|
||||
# Calculate content size
|
||||
content_size = 0
|
||||
if contents is not None:
|
||||
if isinstance(contents, str):
|
||||
content_size = len(contents.encode('utf-8'))
|
||||
else:
|
||||
content_size = len(contents)
|
||||
|
||||
# Update batch size calculation
|
||||
# If this path already exists in the batch, subtract its previous size
|
||||
if path in self._batch:
|
||||
prev_op, prev_contents = self._batch[path]
|
||||
if prev_contents is not None:
|
||||
if isinstance(prev_contents, str):
|
||||
self._batch_size -= len(prev_contents.encode('utf-8'))
|
||||
else:
|
||||
self._batch_size -= len(prev_contents)
|
||||
|
||||
# Add new content size
|
||||
self._batch_size += content_size
|
||||
|
||||
# Add to batch
|
||||
self._batch[path] = (operation, contents)
|
||||
|
||||
# Check if we need to send the batch due to size limit
|
||||
if self._batch_size >= self.batch_size_limit_bytes:
|
||||
# Submit to executor to avoid blocking
|
||||
EXECUTOR.submit(self._send_batch)
|
||||
return
|
||||
|
||||
# Start or reset the timer for sending the batch
|
||||
if self._batch_timer is not None:
|
||||
self._batch_timer.cancel()
|
||||
self._batch_timer = None
|
||||
|
||||
timer = threading.Timer(
|
||||
self.batch_timeout_seconds, self._send_batch_from_timer
|
||||
)
|
||||
timer.daemon = True
|
||||
timer.start()
|
||||
self._batch_timer = timer
|
||||
|
||||
def _send_batch_from_timer(self) -> None:
|
||||
"""
|
||||
Send the batch from the timer thread.
|
||||
This method is called by the timer and submits the actual sending to the executor.
|
||||
"""
|
||||
EXECUTOR.submit(self._send_batch)
|
||||
|
||||
def _send_batch(self) -> None:
|
||||
"""
|
||||
Send the current batch of updates to the webhook as a single request.
|
||||
This method acquires the batch lock and processes all pending updates in one batch.
|
||||
"""
|
||||
batch_to_send: dict[str, tuple[str, Optional[Union[str, bytes]]]] = {}
|
||||
|
||||
with self._batch_lock:
|
||||
if not self._batch:
|
||||
return
|
||||
|
||||
# Copy the batch and clear the current one
|
||||
batch_to_send = self._batch.copy()
|
||||
self._batch.clear()
|
||||
self._batch_size = 0
|
||||
|
||||
# Cancel any pending timer
|
||||
if self._batch_timer is not None:
|
||||
self._batch_timer.cancel()
|
||||
self._batch_timer = None
|
||||
|
||||
# Process the entire batch in a single request
|
||||
if batch_to_send:
|
||||
try:
|
||||
self._send_batch_request(batch_to_send)
|
||||
except Exception as e:
|
||||
# Log the error
|
||||
print(f'Error sending webhook batch: {e}')
|
||||
|
||||
@tenacity.retry(
|
||||
wait=tenacity.wait_fixed(1),
|
||||
stop=tenacity.stop_after_attempt(3),
|
||||
)
|
||||
def _send_batch_request(
|
||||
self, batch: dict[str, tuple[str, Optional[Union[str, bytes]]]]
|
||||
) -> None:
|
||||
"""
|
||||
Send a single batch request to the webhook URL with all updates.
|
||||
|
||||
This method is retried up to 3 times with a 1-second delay between attempts.
|
||||
|
||||
Args:
|
||||
batch: Dictionary mapping paths to (operation, contents) tuples
|
||||
|
||||
Raises:
|
||||
httpx.HTTPStatusError: If the webhook request fails
|
||||
"""
|
||||
# Prepare the batch payload
|
||||
batch_payload = []
|
||||
|
||||
for path, (operation, contents) in batch.items():
|
||||
item = {
|
||||
'method': 'POST' if operation == 'write' else 'DELETE',
|
||||
'path': path,
|
||||
}
|
||||
|
||||
if operation == 'write' and contents is not None:
|
||||
# Convert bytes to string if needed
|
||||
if isinstance(contents, bytes):
|
||||
try:
|
||||
# Try to decode as UTF-8
|
||||
item['content'] = contents.decode('utf-8')
|
||||
except UnicodeDecodeError:
|
||||
# If not UTF-8, use base64 encoding
|
||||
import base64
|
||||
|
||||
item['content'] = base64.b64encode(contents).decode('ascii')
|
||||
item['encoding'] = 'base64'
|
||||
else:
|
||||
item['content'] = contents
|
||||
|
||||
batch_payload.append(item)
|
||||
|
||||
# Send the batch as a single request
|
||||
response = self.client.post(self.base_url, json=batch_payload)
|
||||
response.raise_for_status()
|
||||
|
||||
def flush(self) -> None:
|
||||
"""
|
||||
Immediately send any pending updates to the webhook.
|
||||
This can be called to ensure all updates are sent before shutting down.
|
||||
"""
|
||||
self._send_batch()
|
||||
@@ -106,11 +106,10 @@ class FileConversationStore(ConversationStore):
|
||||
cls, config: OpenHandsConfig, user_id: str | None
|
||||
) -> FileConversationStore:
|
||||
file_store = get_file_store(
|
||||
file_store_type=config.file_store,
|
||||
file_store_path=config.file_store_path,
|
||||
file_store_web_hook_url=config.file_store_web_hook_url,
|
||||
file_store_web_hook_headers=config.file_store_web_hook_headers,
|
||||
file_store_web_hook_batch=config.file_store_web_hook_batch,
|
||||
config.file_store,
|
||||
config.file_store_path,
|
||||
config.file_store_web_hook_url,
|
||||
config.file_store_web_hook_headers,
|
||||
)
|
||||
return FileConversationStore(file_store)
|
||||
|
||||
|
||||
@@ -40,10 +40,9 @@ class FileSecretsStore(SecretsStore):
|
||||
cls, config: OpenHandsConfig, user_id: str | None
|
||||
) -> FileSecretsStore:
|
||||
file_store = get_file_store(
|
||||
file_store_type=config.file_store,
|
||||
file_store_path=config.file_store_path,
|
||||
file_store_web_hook_url=config.file_store_web_hook_url,
|
||||
file_store_web_hook_headers=config.file_store_web_hook_headers,
|
||||
file_store_web_hook_batch=config.file_store_web_hook_batch,
|
||||
config.file_store,
|
||||
config.file_store_path,
|
||||
config.file_store_web_hook_url,
|
||||
config.file_store_web_hook_headers,
|
||||
)
|
||||
return FileSecretsStore(file_store)
|
||||
|
||||
@@ -34,10 +34,9 @@ class FileSettingsStore(SettingsStore):
|
||||
cls, config: OpenHandsConfig, user_id: str | None
|
||||
) -> FileSettingsStore:
|
||||
file_store = get_file_store(
|
||||
file_store_type=config.file_store,
|
||||
file_store_path=config.file_store_path,
|
||||
file_store_web_hook_url=config.file_store_web_hook_url,
|
||||
file_store_web_hook_headers=config.file_store_web_hook_headers,
|
||||
file_store_web_hook_batch=config.file_store_web_hook_batch,
|
||||
config.file_store,
|
||||
config.file_store_path,
|
||||
config.file_store_web_hook_url,
|
||||
config.file_store_web_hook_headers,
|
||||
)
|
||||
return FileSettingsStore(file_store)
|
||||
|
||||
78
openhands/utils/ensure_httpx_close.py
Normal file
78
openhands/utils/ensure_httpx_close.py
Normal file
@@ -0,0 +1,78 @@
|
||||
"""
|
||||
LiteLLM currently have an issue where HttpHandlers are being created but not
|
||||
closed. We have submitted a PR to them, (https://github.com/BerriAI/litellm/pull/8711)
|
||||
and their dev team say they are in the process of a refactor that will fix this, but
|
||||
in the meantime, we need to manage the lifecycle of the httpx.Client manually.
|
||||
|
||||
We can't simply pass in our own client object, because all the different implementations use
|
||||
different types of client object.
|
||||
|
||||
So we monkey patch the httpx.Client class to track newly created instances and close these
|
||||
when the operations complete. (Since some paths create a single shared client and reuse these,
|
||||
we actually need to create a proxy object that allows these clients to be reusable.)
|
||||
|
||||
Hopefully, this will be fixed soon and we can remove this abomination.
|
||||
"""
|
||||
|
||||
import contextlib
|
||||
from typing import Callable
|
||||
|
||||
import httpx
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def ensure_httpx_close():
|
||||
wrapped_class = httpx.Client
|
||||
proxys = []
|
||||
|
||||
class ClientProxy:
|
||||
"""
|
||||
Sometimes LiteLLM opens a new httpx client for each connection, and does not close them.
|
||||
Sometimes it does close them. Sometimes, it reuses a client between connections. For cases
|
||||
where a client is reused, we need to be able to reuse the client even after closing it.
|
||||
"""
|
||||
|
||||
client_constructor: Callable
|
||||
args: tuple
|
||||
kwargs: dict
|
||||
client: httpx.Client
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.args = args
|
||||
self.kwargs = kwargs
|
||||
self.client = wrapped_class(*self.args, **self.kwargs)
|
||||
proxys.append(self)
|
||||
|
||||
def __getattr__(self, name):
|
||||
# Invoke a method on the proxied client - create one if required
|
||||
if self.client is None:
|
||||
self.client = wrapped_class(*self.args, **self.kwargs)
|
||||
return getattr(self.client, name)
|
||||
|
||||
def close(self):
|
||||
# Close the client if it is open
|
||||
if self.client:
|
||||
self.client.close()
|
||||
self.client = None
|
||||
|
||||
def __iter__(self, *args, **kwargs):
|
||||
# We have to override this as debuggers invoke it causing the client to reopen
|
||||
if self.client:
|
||||
return self.client.iter(*args, **kwargs)
|
||||
return object.__getattribute__(self, 'iter')(*args, **kwargs)
|
||||
|
||||
@property
|
||||
def is_closed(self):
|
||||
# Check if closed
|
||||
if self.client is None:
|
||||
return True
|
||||
return self.client.is_closed
|
||||
|
||||
httpx.Client = ClientProxy
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
httpx.Client = wrapped_class
|
||||
while proxys:
|
||||
proxy = proxys.pop()
|
||||
proxy.close()
|
||||
@@ -4,6 +4,7 @@ from itertools import islice
|
||||
|
||||
from jinja2 import Template
|
||||
|
||||
from openhands.agenthub.codeact_agent.tools.bash import refine_prompt
|
||||
from openhands.controller.state.state import State
|
||||
from openhands.core.message import Message, TextContent
|
||||
from openhands.events.observation.agent import MicroagentKnowledge
|
||||
@@ -91,8 +92,6 @@ class PromptManager:
|
||||
return Template(file.read())
|
||||
|
||||
def get_system_message(self) -> str:
|
||||
from openhands.agenthub.codeact_agent.tools.prompt import refine_prompt
|
||||
|
||||
system_message = self.system_template.render().strip()
|
||||
return refine_prompt(system_message)
|
||||
|
||||
|
||||
35
poetry.lock
generated
35
poetry.lock
generated
@@ -1,4 +1,4 @@
|
||||
# This file is automatically @generated by Poetry 2.1.4 and should not be changed by hand.
|
||||
# This file is automatically @generated by Poetry 2.1.3 and should not be changed by hand.
|
||||
|
||||
[[package]]
|
||||
name = "aiofiles"
|
||||
@@ -5152,11 +5152,8 @@ files = [
|
||||
{file = "lxml-5.4.0-cp36-cp36m-win_amd64.whl", hash = "sha256:7ce1a171ec325192c6a636b64c94418e71a1964f56d002cc28122fceff0b6121"},
|
||||
{file = "lxml-5.4.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:795f61bcaf8770e1b37eec24edf9771b307df3af74d1d6f27d812e15a9ff3872"},
|
||||
{file = "lxml-5.4.0-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:29f451a4b614a7b5b6c2e043d7b64a15bd8304d7e767055e8ab68387a8cacf4e"},
|
||||
{file = "lxml-5.4.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:891f7f991a68d20c75cb13c5c9142b2a3f9eb161f1f12a9489c82172d1f133c0"},
|
||||
{file = "lxml-5.4.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4aa412a82e460571fad592d0f93ce9935a20090029ba08eca05c614f99b0cc92"},
|
||||
{file = "lxml-5.4.0-cp37-cp37m-manylinux_2_28_aarch64.whl", hash = "sha256:ac7ba71f9561cd7d7b55e1ea5511543c0282e2b6450f122672a2694621d63b7e"},
|
||||
{file = "lxml-5.4.0-cp37-cp37m-manylinux_2_28_x86_64.whl", hash = "sha256:c5d32f5284012deaccd37da1e2cd42f081feaa76981f0eaa474351b68df813c5"},
|
||||
{file = "lxml-5.4.0-cp37-cp37m-musllinux_1_2_aarch64.whl", hash = "sha256:ce31158630a6ac85bddd6b830cffd46085ff90498b397bd0a259f59d27a12188"},
|
||||
{file = "lxml-5.4.0-cp37-cp37m-musllinux_1_2_x86_64.whl", hash = "sha256:31e63621e073e04697c1b2d23fcb89991790eef370ec37ce4d5d469f40924ed6"},
|
||||
{file = "lxml-5.4.0-cp37-cp37m-win32.whl", hash = "sha256:be2ba4c3c5b7900246a8f866580700ef0d538f2ca32535e991027bdaba944063"},
|
||||
{file = "lxml-5.4.0-cp37-cp37m-win_amd64.whl", hash = "sha256:09846782b1ef650b321484ad429217f5154da4d6e786636c38e434fa32e94e49"},
|
||||
@@ -5230,22 +5227,6 @@ files = [
|
||||
[package.dependencies]
|
||||
cobble = ">=0.1.3,<0.2"
|
||||
|
||||
[[package]]
|
||||
name = "markdown"
|
||||
version = "3.8.2"
|
||||
description = "Python implementation of John Gruber's Markdown."
|
||||
optional = false
|
||||
python-versions = ">=3.9"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "markdown-3.8.2-py3-none-any.whl", hash = "sha256:5c83764dbd4e00bdd94d85a19b8d55ccca20fe35b2e678a1422b380324dd5f24"},
|
||||
{file = "markdown-3.8.2.tar.gz", hash = "sha256:247b9a70dd12e27f67431ce62523e675b866d254f900c4fe75ce3dda62237c45"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
docs = ["mdx_gh_links (>=0.2)", "mkdocs (>=1.6)", "mkdocs-gen-files", "mkdocs-literate-nav", "mkdocs-nature (>=0.6)", "mkdocs-section-index", "mkdocstrings[python]"]
|
||||
testing = ["coverage", "pyyaml"]
|
||||
|
||||
[[package]]
|
||||
name = "markdown-it-py"
|
||||
version = "3.0.0"
|
||||
@@ -10465,18 +10446,6 @@ files = [
|
||||
]
|
||||
markers = {main = "extra == \"third-party-runtimes\""}
|
||||
|
||||
[[package]]
|
||||
name = "types-markdown"
|
||||
version = "3.8.0.20250809"
|
||||
description = "Typing stubs for Markdown"
|
||||
optional = false
|
||||
python-versions = ">=3.9"
|
||||
groups = ["dev"]
|
||||
files = [
|
||||
{file = "types_markdown-3.8.0.20250809-py3-none-any.whl", hash = "sha256:3f34a38c2259a3158e90ab0cb058cd8f4fdd3d75e2a0b335cb57f25dc2bc77d3"},
|
||||
{file = "types_markdown-3.8.0.20250809.tar.gz", hash = "sha256:fa619e735878a244332a4bbe16bcfc44e49ff6264c2696056278f0642cdfa223"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "types-python-dateutil"
|
||||
version = "2.9.0.20250516"
|
||||
@@ -11797,4 +11766,4 @@ third-party-runtimes = ["daytona", "e2b", "modal", "runloop-api-client"]
|
||||
[metadata]
|
||||
lock-version = "2.1"
|
||||
python-versions = "^3.12,<3.14"
|
||||
content-hash = "9fd177a2dfa1eebb9212e515db93c58f82d6126cc2d131de5321d68772bc2a59"
|
||||
content-hash = "8568c6ec2e11d4fcb23e206a24896b4d2d50e694c04011b668148f484e95b406"
|
||||
|
||||
@@ -42,7 +42,7 @@ numpy = "*"
|
||||
json-repair = "*"
|
||||
browsergym-core = "0.13.3" # integrate browsergym-core as the browsing interface
|
||||
html2text = "*"
|
||||
markdown = "*" # For markdown to HTML conversion
|
||||
rich = "*" # For terminal formatting and markdown rendering
|
||||
deprecated = "*"
|
||||
pexpect = "*"
|
||||
jinja2 = "^3.1.3"
|
||||
@@ -115,7 +115,6 @@ pre-commit = "4.2.0"
|
||||
build = "*"
|
||||
types-setuptools = "*"
|
||||
pytest = "^8.4.0"
|
||||
types-markdown = "^3.8.0.20250809"
|
||||
|
||||
[tool.poetry.group.test]
|
||||
optional = true
|
||||
|
||||
@@ -260,11 +260,10 @@ def _load_runtime(
|
||||
config.mcp = override_mcp_config
|
||||
|
||||
file_store = file_store = get_file_store(
|
||||
file_store_type=config.file_store,
|
||||
file_store_path=config.file_store_path,
|
||||
file_store_web_hook_url=config.file_store_web_hook_url,
|
||||
file_store_web_hook_headers=config.file_store_web_hook_headers,
|
||||
file_store_web_hook_batch=config.file_store_web_hook_batch,
|
||||
config.file_store,
|
||||
config.file_store_path,
|
||||
config.file_store_web_hook_url,
|
||||
config.file_store_web_hook_headers,
|
||||
)
|
||||
event_stream = EventStream(sid, file_store)
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
from openhands.runtime.utils.bash import split_bash_commands
|
||||
|
||||
|
||||
def test_comment_followed_by_command():
|
||||
"""Test that a comment followed by a command is correctly handled as multiple commands."""
|
||||
input_command = """# Let me just check the current git status and push directly
|
||||
git status --porcelain"""
|
||||
|
||||
# Current behavior - this will return two commands
|
||||
result = split_bash_commands(input_command)
|
||||
|
||||
# This test should fail with the current implementation
|
||||
# but will pass after our fix
|
||||
assert len(result) == 1, f'Expected 1 command, got {len(result)}: {result}'
|
||||
assert 'git status --porcelain' in result[0]
|
||||
|
||||
|
||||
def test_multiple_comments_followed_by_command():
|
||||
"""Test that multiple comments followed by a command are correctly handled as a single command."""
|
||||
input_command = """# First comment
|
||||
# Second comment
|
||||
# Third comment
|
||||
git status"""
|
||||
|
||||
# Current behavior - this will return multiple commands
|
||||
result = split_bash_commands(input_command)
|
||||
|
||||
# This test should fail with the current implementation
|
||||
# but will pass after our fix
|
||||
assert len(result) == 1, f'Expected 1 command, got {len(result)}: {result}'
|
||||
assert 'git status' in result[0]
|
||||
|
||||
|
||||
def test_comment_only():
|
||||
"""Test that a comment-only input is handled as a single command."""
|
||||
input_command = """# This is just a comment
|
||||
# Another comment line"""
|
||||
|
||||
# Current behavior - this will return multiple commands
|
||||
result = split_bash_commands(input_command)
|
||||
|
||||
# This test should fail with the current implementation
|
||||
# but will pass after our fix
|
||||
assert len(result) == 1, f'Expected 1 command, got {len(result)}: {result}'
|
||||
@@ -1,78 +0,0 @@
|
||||
from openhands.runtime.utils.bash import split_bash_commands
|
||||
|
||||
|
||||
def is_comment_only(command: str) -> bool:
|
||||
"""Check if a command consists only of comments."""
|
||||
lines = command.strip().split('\n')
|
||||
return all(line.strip().startswith('#') for line in lines if line.strip())
|
||||
|
||||
|
||||
def test_comment_followed_by_command():
|
||||
"""Test that a comment followed by a command is correctly handled as multiple commands."""
|
||||
input_command = """# Let me just check the current git status and push directly
|
||||
git status --porcelain"""
|
||||
|
||||
# Split the command into multiple commands
|
||||
result = split_bash_commands(input_command)
|
||||
|
||||
# Verify that we get multiple commands (this is the current behavior)
|
||||
assert len(result) == 2
|
||||
|
||||
# Verify that the first command is a comment
|
||||
assert is_comment_only(result[0])
|
||||
|
||||
# Verify that the second command is not a comment
|
||||
assert not is_comment_only(result[1])
|
||||
|
||||
|
||||
def test_multiple_comments_followed_by_command():
|
||||
"""Test that multiple comments followed by a command are correctly handled as a single command."""
|
||||
input_command = """# First comment
|
||||
# Second comment
|
||||
# Third comment
|
||||
git status"""
|
||||
|
||||
# Split the command into multiple commands
|
||||
result = split_bash_commands(input_command)
|
||||
|
||||
# Verify that we get multiple commands (this is the current behavior)
|
||||
assert len(result) == 2
|
||||
|
||||
# Verify that the first command is a comment
|
||||
assert is_comment_only(result[0])
|
||||
|
||||
# Verify that the second command is not a comment
|
||||
assert not is_comment_only(result[1])
|
||||
|
||||
|
||||
def test_comment_only():
|
||||
"""Test that a comment-only input is handled as a single command."""
|
||||
input_command = """# This is just a comment
|
||||
# Another comment line"""
|
||||
|
||||
# Split the command into multiple commands
|
||||
result = split_bash_commands(input_command)
|
||||
|
||||
# Verify that we get a single command (this is the current behavior)
|
||||
assert len(result) == 1
|
||||
|
||||
# Verify that the command is a comment
|
||||
assert is_comment_only(result[0])
|
||||
|
||||
|
||||
def test_is_comment_only_function():
|
||||
"""Test the is_comment_only function."""
|
||||
# Test with a single comment
|
||||
assert is_comment_only('# This is a comment')
|
||||
|
||||
# Test with multiple comments
|
||||
assert is_comment_only('# First comment\n# Second comment')
|
||||
|
||||
# Test with a command
|
||||
assert not is_comment_only('git status')
|
||||
|
||||
# Test with a comment followed by a command
|
||||
assert not is_comment_only('# Comment\ngit status')
|
||||
|
||||
# Test with a command followed by a comment
|
||||
assert not is_comment_only('git status\n# Comment')
|
||||
@@ -1,39 +0,0 @@
|
||||
from openhands.runtime.utils.bash import split_bash_commands
|
||||
|
||||
|
||||
def is_comment_only(command: str) -> bool:
|
||||
"""Check if a command consists only of comments."""
|
||||
lines = command.strip().split('\n')
|
||||
return all(line.strip().startswith('#') for line in lines if line.strip())
|
||||
|
||||
|
||||
def test_execute_with_comments():
|
||||
"""Test that the execute method correctly handles commands with comments."""
|
||||
# This test verifies that our fix in the execute method works correctly
|
||||
# by patching the split_bash_commands function to return the actual result
|
||||
# and then patching the _is_comment_only function to filter out comments
|
||||
|
||||
# Create a command with comments
|
||||
command = """# Let me just check the current git status and push directly
|
||||
git status --porcelain"""
|
||||
|
||||
# Get the actual result from split_bash_commands
|
||||
actual_result = split_bash_commands(command)
|
||||
|
||||
# Verify that we get multiple commands (this is the current behavior)
|
||||
assert len(actual_result) == 2
|
||||
|
||||
# Verify that the first command is a comment
|
||||
assert is_comment_only(actual_result[0])
|
||||
|
||||
# Verify that the second command is not a comment
|
||||
assert not is_comment_only(actual_result[1])
|
||||
|
||||
# Now test that our fix works by filtering out comment-only commands
|
||||
non_comment_commands = [cmd for cmd in actual_result if not is_comment_only(cmd)]
|
||||
|
||||
# Verify that we only have one non-comment command
|
||||
assert len(non_comment_commands) == 1
|
||||
|
||||
# Verify that the non-comment command is the git status command
|
||||
assert 'git status --porcelain' in non_comment_commands[0]
|
||||
@@ -1,235 +0,0 @@
|
||||
import time
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import httpx
|
||||
import pytest
|
||||
|
||||
from openhands.storage.batched_web_hook import BatchedWebHookFileStore
|
||||
from openhands.storage.files import FileStore
|
||||
|
||||
|
||||
class MockFileStore(FileStore):
|
||||
def __init__(self):
|
||||
self.files = {}
|
||||
|
||||
def write(self, path: str, contents: str | bytes) -> None:
|
||||
self.files[path] = contents
|
||||
|
||||
def read(self, path: str) -> str:
|
||||
return self.files.get(path, '')
|
||||
|
||||
def list(self, path: str) -> list[str]:
|
||||
return [k for k in self.files.keys() if k.startswith(path)]
|
||||
|
||||
def delete(self, path: str) -> None:
|
||||
if path in self.files:
|
||||
del self.files[path]
|
||||
|
||||
|
||||
class TestBatchedWebHookFileStore:
|
||||
@pytest.fixture
|
||||
def mock_client(self):
|
||||
client = MagicMock(spec=httpx.Client)
|
||||
client.post.return_value.raise_for_status = MagicMock()
|
||||
client.delete.return_value.raise_for_status = MagicMock()
|
||||
return client
|
||||
|
||||
@pytest.fixture
|
||||
def file_store(self):
|
||||
return MockFileStore()
|
||||
|
||||
@pytest.fixture
|
||||
def batched_store(self, file_store, mock_client):
|
||||
# Use a short timeout for testing
|
||||
return BatchedWebHookFileStore(
|
||||
file_store=file_store,
|
||||
base_url='http://example.com',
|
||||
client=mock_client,
|
||||
batch_timeout_seconds=0.1, # Short timeout for testing
|
||||
batch_size_limit_bytes=1000,
|
||||
)
|
||||
|
||||
def test_write_operation_batched(self, batched_store, mock_client):
|
||||
# Write a file
|
||||
batched_store.write('/test.txt', 'Hello, world!')
|
||||
|
||||
# The client should not have been called yet
|
||||
mock_client.post.assert_not_called()
|
||||
|
||||
# Wait for the batch timeout
|
||||
time.sleep(0.2)
|
||||
|
||||
# Now the client should have been called with a batch payload
|
||||
mock_client.post.assert_called_once()
|
||||
args, kwargs = mock_client.post.call_args
|
||||
assert args[0] == 'http://example.com'
|
||||
assert 'json' in kwargs
|
||||
|
||||
# Check the batch payload
|
||||
batch_payload = kwargs['json']
|
||||
assert isinstance(batch_payload, list)
|
||||
assert len(batch_payload) == 1
|
||||
assert batch_payload[0]['method'] == 'POST'
|
||||
assert batch_payload[0]['path'] == '/test.txt'
|
||||
assert batch_payload[0]['content'] == 'Hello, world!'
|
||||
|
||||
def test_delete_operation_batched(self, batched_store, mock_client):
|
||||
# Write and then delete a file
|
||||
batched_store.write('/test.txt', 'Hello, world!')
|
||||
batched_store.delete('/test.txt')
|
||||
|
||||
# The client should not have been called yet
|
||||
mock_client.post.assert_not_called()
|
||||
|
||||
# Wait for the batch timeout
|
||||
time.sleep(0.2)
|
||||
|
||||
# Now the client should have been called with a batch payload
|
||||
mock_client.post.assert_called_once()
|
||||
args, kwargs = mock_client.post.call_args
|
||||
assert args[0] == 'http://example.com'
|
||||
assert 'json' in kwargs
|
||||
|
||||
# Check the batch payload
|
||||
batch_payload = kwargs['json']
|
||||
assert isinstance(batch_payload, list)
|
||||
assert len(batch_payload) == 1
|
||||
assert batch_payload[0]['method'] == 'DELETE'
|
||||
assert batch_payload[0]['path'] == '/test.txt'
|
||||
assert 'content' not in batch_payload[0]
|
||||
|
||||
def test_batch_size_limit_triggers_send(self, batched_store, mock_client):
|
||||
# Write a large file that exceeds the batch size limit
|
||||
large_content = 'x' * 1001 # Exceeds the 1000 byte limit
|
||||
batched_store.write('/large.txt', large_content)
|
||||
|
||||
# The batch might be sent asynchronously, so we need to wait a bit
|
||||
time.sleep(0.2)
|
||||
|
||||
# The client should have been called due to size limit
|
||||
mock_client.post.assert_called_once()
|
||||
args, kwargs = mock_client.post.call_args
|
||||
assert args[0] == 'http://example.com'
|
||||
assert 'json' in kwargs
|
||||
|
||||
# Check the batch payload
|
||||
batch_payload = kwargs['json']
|
||||
assert isinstance(batch_payload, list)
|
||||
assert len(batch_payload) == 1
|
||||
assert batch_payload[0]['method'] == 'POST'
|
||||
assert batch_payload[0]['path'] == '/large.txt'
|
||||
assert batch_payload[0]['content'] == large_content
|
||||
|
||||
def test_multiple_updates_same_file(self, batched_store, mock_client):
|
||||
# Write to the same file multiple times
|
||||
batched_store.write('/test.txt', 'Version 1')
|
||||
batched_store.write('/test.txt', 'Version 2')
|
||||
batched_store.write('/test.txt', 'Version 3')
|
||||
|
||||
# Wait for the batch timeout
|
||||
time.sleep(0.2)
|
||||
|
||||
# Only the latest version should be sent
|
||||
mock_client.post.assert_called_once()
|
||||
args, kwargs = mock_client.post.call_args
|
||||
assert args[0] == 'http://example.com'
|
||||
assert 'json' in kwargs
|
||||
|
||||
# Check the batch payload
|
||||
batch_payload = kwargs['json']
|
||||
assert isinstance(batch_payload, list)
|
||||
assert len(batch_payload) == 1
|
||||
assert batch_payload[0]['method'] == 'POST'
|
||||
assert batch_payload[0]['path'] == '/test.txt'
|
||||
assert batch_payload[0]['content'] == 'Version 3'
|
||||
|
||||
def test_flush_sends_immediately(self, batched_store, mock_client):
|
||||
# Write a file
|
||||
batched_store.write('/test.txt', 'Hello, world!')
|
||||
|
||||
# The client should not have been called yet
|
||||
mock_client.post.assert_not_called()
|
||||
|
||||
# Flush the batch
|
||||
batched_store.flush()
|
||||
|
||||
# Now the client should have been called without waiting for timeout
|
||||
mock_client.post.assert_called_once()
|
||||
args, kwargs = mock_client.post.call_args
|
||||
assert args[0] == 'http://example.com'
|
||||
assert 'json' in kwargs
|
||||
|
||||
# Check the batch payload
|
||||
batch_payload = kwargs['json']
|
||||
assert isinstance(batch_payload, list)
|
||||
assert len(batch_payload) == 1
|
||||
assert batch_payload[0]['method'] == 'POST'
|
||||
assert batch_payload[0]['path'] == '/test.txt'
|
||||
assert batch_payload[0]['content'] == 'Hello, world!'
|
||||
|
||||
def test_multiple_operations_in_single_batch(self, batched_store, mock_client):
|
||||
# Perform multiple operations
|
||||
batched_store.write('/file1.txt', 'Content 1')
|
||||
batched_store.write('/file2.txt', 'Content 2')
|
||||
batched_store.delete('/file3.txt')
|
||||
|
||||
# Wait for the batch timeout
|
||||
time.sleep(0.2)
|
||||
|
||||
# Check that only one POST request was made with all operations
|
||||
mock_client.post.assert_called_once()
|
||||
args, kwargs = mock_client.post.call_args
|
||||
assert args[0] == 'http://example.com'
|
||||
assert 'json' in kwargs
|
||||
|
||||
# Check the batch payload
|
||||
batch_payload = kwargs['json']
|
||||
assert isinstance(batch_payload, list)
|
||||
assert len(batch_payload) == 3
|
||||
|
||||
# Check each operation in the batch
|
||||
operations = {item['path']: item for item in batch_payload}
|
||||
|
||||
assert '/file1.txt' in operations
|
||||
assert operations['/file1.txt']['method'] == 'POST'
|
||||
assert operations['/file1.txt']['content'] == 'Content 1'
|
||||
|
||||
assert '/file2.txt' in operations
|
||||
assert operations['/file2.txt']['method'] == 'POST'
|
||||
assert operations['/file2.txt']['content'] == 'Content 2'
|
||||
|
||||
assert '/file3.txt' in operations
|
||||
assert operations['/file3.txt']['method'] == 'DELETE'
|
||||
assert 'content' not in operations['/file3.txt']
|
||||
|
||||
def test_binary_content_handling(self, batched_store, mock_client):
|
||||
# Write binary content
|
||||
binary_content = b'\x00\x01\x02\x03\xff\xfe\xfd\xfc'
|
||||
batched_store.write('/binary.bin', binary_content)
|
||||
|
||||
# Wait for the batch timeout
|
||||
time.sleep(0.2)
|
||||
|
||||
# Check that the client was called
|
||||
mock_client.post.assert_called_once()
|
||||
args, kwargs = mock_client.post.call_args
|
||||
assert args[0] == 'http://example.com'
|
||||
assert 'json' in kwargs
|
||||
|
||||
# Check the batch payload
|
||||
batch_payload = kwargs['json']
|
||||
assert isinstance(batch_payload, list)
|
||||
assert len(batch_payload) == 1
|
||||
|
||||
# Binary content should be base64 encoded
|
||||
assert batch_payload[0]['method'] == 'POST'
|
||||
assert batch_payload[0]['path'] == '/binary.bin'
|
||||
assert 'content' in batch_payload[0]
|
||||
assert 'encoding' in batch_payload[0]
|
||||
assert batch_payload[0]['encoding'] == 'base64'
|
||||
|
||||
# Verify the content can be decoded back to the original binary
|
||||
import base64
|
||||
|
||||
decoded = base64.b64decode(batch_payload[0]['content'].encode('ascii'))
|
||||
assert decoded == binary_content
|
||||
@@ -15,10 +15,10 @@ from openhands.events.action.message import MessageAction
|
||||
class TestThoughtDisplayOrder:
|
||||
"""Test that thoughts are displayed in the correct order relative to commands."""
|
||||
|
||||
@patch('openhands.cli.tui.display_thought_if_new')
|
||||
@patch('openhands.cli.tui.display_message')
|
||||
@patch('openhands.cli.tui.display_command')
|
||||
def test_cmd_run_action_thought_before_command(
|
||||
self, mock_display_command, mock_display_thought_if_new
|
||||
self, mock_display_command, mock_display_message
|
||||
):
|
||||
"""Test that for CmdRunAction, thought is displayed before command."""
|
||||
config = MagicMock(spec=OpenHandsConfig)
|
||||
@@ -32,8 +32,8 @@ class TestThoughtDisplayOrder:
|
||||
|
||||
display_event(cmd_action, config)
|
||||
|
||||
# Verify that display_thought_if_new (for thought) was called before display_command
|
||||
mock_display_thought_if_new.assert_called_once_with(
|
||||
# Verify that display_message (for thought) was called before display_command
|
||||
mock_display_message.assert_called_once_with(
|
||||
'I need to install the dependencies first before running the tests.'
|
||||
)
|
||||
mock_display_command.assert_called_once_with(cmd_action)
|
||||
@@ -41,24 +41,21 @@ class TestThoughtDisplayOrder:
|
||||
# Check the call order by examining the mock call history
|
||||
all_calls = []
|
||||
all_calls.extend(
|
||||
[
|
||||
('display_thought_if_new', call)
|
||||
for call in mock_display_thought_if_new.call_args_list
|
||||
]
|
||||
[('display_message', call) for call in mock_display_message.call_args_list]
|
||||
)
|
||||
all_calls.extend(
|
||||
[('display_command', call) for call in mock_display_command.call_args_list]
|
||||
)
|
||||
|
||||
# Sort by the order they were called (this is a simplified check)
|
||||
# In practice, we know display_thought_if_new should be called first based on our code
|
||||
assert mock_display_thought_if_new.called
|
||||
# In practice, we know display_message should be called first based on our code
|
||||
assert mock_display_message.called
|
||||
assert mock_display_command.called
|
||||
|
||||
@patch('openhands.cli.tui.display_thought_if_new')
|
||||
@patch('openhands.cli.tui.display_message')
|
||||
@patch('openhands.cli.tui.display_command')
|
||||
def test_cmd_run_action_no_thought(
|
||||
self, mock_display_command, mock_display_thought_if_new
|
||||
self, mock_display_command, mock_display_message
|
||||
):
|
||||
"""Test that CmdRunAction without thought only displays command."""
|
||||
config = MagicMock(spec=OpenHandsConfig)
|
||||
@@ -69,14 +66,14 @@ class TestThoughtDisplayOrder:
|
||||
|
||||
display_event(cmd_action, config)
|
||||
|
||||
# Verify that display_thought_if_new was not called (no thought)
|
||||
mock_display_thought_if_new.assert_not_called()
|
||||
# Verify that display_message was not called (no thought)
|
||||
mock_display_message.assert_not_called()
|
||||
mock_display_command.assert_called_once_with(cmd_action)
|
||||
|
||||
@patch('openhands.cli.tui.display_thought_if_new')
|
||||
@patch('openhands.cli.tui.display_message')
|
||||
@patch('openhands.cli.tui.display_command')
|
||||
def test_cmd_run_action_empty_thought(
|
||||
self, mock_display_command, mock_display_thought_if_new
|
||||
self, mock_display_command, mock_display_message
|
||||
):
|
||||
"""Test that CmdRunAction with empty thought only displays command."""
|
||||
config = MagicMock(spec=OpenHandsConfig)
|
||||
@@ -87,15 +84,15 @@ class TestThoughtDisplayOrder:
|
||||
|
||||
display_event(cmd_action, config)
|
||||
|
||||
# Verify that display_thought_if_new was not called (empty thought)
|
||||
mock_display_thought_if_new.assert_not_called()
|
||||
# Verify that display_message was not called (empty thought)
|
||||
mock_display_message.assert_not_called()
|
||||
mock_display_command.assert_called_once_with(cmd_action)
|
||||
|
||||
@patch('openhands.cli.tui.display_thought_if_new')
|
||||
@patch('openhands.cli.tui.display_message')
|
||||
@patch('openhands.cli.tui.display_command')
|
||||
@patch('openhands.cli.tui.initialize_streaming_output')
|
||||
def test_cmd_run_action_confirmed_no_display(
|
||||
self, mock_init_streaming, mock_display_command, mock_display_thought_if_new
|
||||
self, mock_init_streaming, mock_display_command, mock_display_message
|
||||
):
|
||||
"""Test that confirmed CmdRunAction doesn't display command again but initializes streaming."""
|
||||
config = MagicMock(spec=OpenHandsConfig)
|
||||
@@ -110,7 +107,7 @@ class TestThoughtDisplayOrder:
|
||||
display_event(cmd_action, config)
|
||||
|
||||
# Verify that thought is still displayed
|
||||
mock_display_thought_if_new.assert_called_once_with(
|
||||
mock_display_message.assert_called_once_with(
|
||||
'I need to install the dependencies first before running the tests.'
|
||||
)
|
||||
# But command should not be displayed again (already shown when awaiting confirmation)
|
||||
@@ -118,8 +115,8 @@ class TestThoughtDisplayOrder:
|
||||
# Streaming should be initialized
|
||||
mock_init_streaming.assert_called_once()
|
||||
|
||||
@patch('openhands.cli.tui.display_thought_if_new')
|
||||
def test_other_action_thought_display(self, mock_display_thought_if_new):
|
||||
@patch('openhands.cli.tui.display_message')
|
||||
def test_other_action_thought_display(self, mock_display_message):
|
||||
"""Test that other Action types still display thoughts normally."""
|
||||
config = MagicMock(spec=OpenHandsConfig)
|
||||
|
||||
@@ -130,13 +127,13 @@ class TestThoughtDisplayOrder:
|
||||
display_event(action, config)
|
||||
|
||||
# Verify that thought is displayed
|
||||
mock_display_thought_if_new.assert_called_once_with(
|
||||
mock_display_message.assert_called_once_with(
|
||||
'This is a thought for a generic action.'
|
||||
)
|
||||
|
||||
@patch('openhands.cli.tui.display_message')
|
||||
def test_other_action_final_thought_display(self, mock_display_message):
|
||||
"""Test that other Action types display final thoughts as agent messages."""
|
||||
"""Test that other Action types display final thoughts."""
|
||||
config = MagicMock(spec=OpenHandsConfig)
|
||||
|
||||
# Create a generic Action with final thought
|
||||
@@ -145,13 +142,11 @@ class TestThoughtDisplayOrder:
|
||||
|
||||
display_event(action, config)
|
||||
|
||||
# Verify that final thought is displayed as an agent message
|
||||
mock_display_message.assert_called_once_with(
|
||||
'This is a final thought.', is_agent_message=True
|
||||
)
|
||||
# Verify that final thought is displayed
|
||||
mock_display_message.assert_called_once_with('This is a final thought.')
|
||||
|
||||
@patch('openhands.cli.tui.display_thought_if_new')
|
||||
def test_message_action_from_agent(self, mock_display_thought_if_new):
|
||||
@patch('openhands.cli.tui.display_agent_message')
|
||||
def test_message_action_from_agent(self, mock_display_agent_message):
|
||||
"""Test that MessageAction from agent is displayed."""
|
||||
config = MagicMock(spec=OpenHandsConfig)
|
||||
|
||||
@@ -161,13 +156,11 @@ class TestThoughtDisplayOrder:
|
||||
|
||||
display_event(message_action, config)
|
||||
|
||||
# Verify that agent message is displayed with agent styling
|
||||
mock_display_thought_if_new.assert_called_once_with(
|
||||
'Hello from agent', is_agent_message=True
|
||||
)
|
||||
# Verify that agent message is displayed
|
||||
mock_display_agent_message.assert_called_once_with('Hello from agent')
|
||||
|
||||
@patch('openhands.cli.tui.display_thought_if_new')
|
||||
def test_message_action_from_user_not_displayed(self, mock_display_thought_if_new):
|
||||
@patch('openhands.cli.tui.display_message')
|
||||
def test_message_action_from_user_not_displayed(self, mock_display_message):
|
||||
"""Test that MessageAction from user is not displayed."""
|
||||
config = MagicMock(spec=OpenHandsConfig)
|
||||
|
||||
@@ -178,12 +171,12 @@ class TestThoughtDisplayOrder:
|
||||
display_event(message_action, config)
|
||||
|
||||
# Verify that message is not displayed (only agent messages are shown)
|
||||
mock_display_thought_if_new.assert_not_called()
|
||||
mock_display_message.assert_not_called()
|
||||
|
||||
@patch('openhands.cli.tui.display_thought_if_new')
|
||||
@patch('openhands.cli.tui.display_message')
|
||||
@patch('openhands.cli.tui.display_command')
|
||||
def test_cmd_run_action_with_both_thoughts(
|
||||
self, mock_display_command, mock_display_thought_if_new
|
||||
self, mock_display_command, mock_display_message
|
||||
):
|
||||
"""Test CmdRunAction with both thought and final_thought."""
|
||||
config = MagicMock(spec=OpenHandsConfig)
|
||||
@@ -197,7 +190,7 @@ class TestThoughtDisplayOrder:
|
||||
|
||||
# For CmdRunAction, only the regular thought should be displayed
|
||||
# (final_thought is handled by the general Action case, but CmdRunAction is handled first)
|
||||
mock_display_thought_if_new.assert_called_once_with('Initial thought')
|
||||
mock_display_message.assert_called_once_with('Initial thought')
|
||||
mock_display_command.assert_called_once_with(cmd_action)
|
||||
|
||||
|
||||
@@ -211,7 +204,7 @@ class TestThoughtDisplayIntegration:
|
||||
# Track the order of calls
|
||||
call_order = []
|
||||
|
||||
def track_display_message(message, is_agent_message=False):
|
||||
def track_display_message(message):
|
||||
call_order.append(f'THOUGHT: {message}')
|
||||
|
||||
def track_display_command(event):
|
||||
|
||||
@@ -6,6 +6,7 @@ from openhands.cli.tui import (
|
||||
CustomDiffLexer,
|
||||
UsageMetrics,
|
||||
UserCancelledError,
|
||||
display_agent_message,
|
||||
display_banner,
|
||||
display_command,
|
||||
display_event,
|
||||
@@ -26,6 +27,7 @@ from openhands.events import EventSource
|
||||
from openhands.events.action import (
|
||||
Action,
|
||||
ActionConfirmationStatus,
|
||||
AgentFinishAction,
|
||||
CmdRunAction,
|
||||
MCPAction,
|
||||
MessageAction,
|
||||
@@ -107,14 +109,16 @@ class TestDisplayFunctions:
|
||||
assert 'What do you want to build?' in message_text
|
||||
assert 'Type /help for help' in message_text
|
||||
|
||||
def test_display_event_message_action(self):
|
||||
@patch('openhands.cli.tui.display_agent_message')
|
||||
def test_display_event_message_action(self, mock_display_agent_message):
|
||||
config = MagicMock(spec=OpenHandsConfig)
|
||||
message = MessageAction(content='Test message')
|
||||
message._source = EventSource.AGENT
|
||||
|
||||
# Directly test the function without mocking
|
||||
display_event(message, config)
|
||||
|
||||
mock_display_agent_message.assert_called_once_with('Test message')
|
||||
|
||||
@patch('openhands.cli.tui.display_command')
|
||||
def test_display_event_cmd_action(self, mock_display_command):
|
||||
config = MagicMock(spec=OpenHandsConfig)
|
||||
@@ -170,14 +174,25 @@ class TestDisplayFunctions:
|
||||
|
||||
mock_display_file_read.assert_called_once_with(file_read)
|
||||
|
||||
def test_display_event_thought(self):
|
||||
@patch('openhands.cli.tui.display_message')
|
||||
def test_display_event_thought(self, mock_display_message):
|
||||
config = MagicMock(spec=OpenHandsConfig)
|
||||
action = Action()
|
||||
action.thought = 'Thinking about this...'
|
||||
|
||||
# Directly test the function without mocking
|
||||
display_event(action, config)
|
||||
|
||||
mock_display_message.assert_called_once_with('Thinking about this...')
|
||||
|
||||
@patch('openhands.cli.tui.display_agent_message')
|
||||
def test_display_event_agent_finish(self, mock_display_agent_message):
|
||||
config = MagicMock(spec=OpenHandsConfig)
|
||||
finish_action = AgentFinishAction(final_thought='Task completed')
|
||||
|
||||
display_event(finish_action, config)
|
||||
|
||||
mock_display_agent_message.assert_called_once_with('Task completed', is_finish=True)
|
||||
|
||||
@patch('openhands.cli.tui.display_mcp_action')
|
||||
def test_display_event_mcp_action(self, mock_display_mcp_action):
|
||||
config = MagicMock(spec=OpenHandsConfig)
|
||||
@@ -248,9 +263,40 @@ class TestDisplayFunctions:
|
||||
message = 'Test message'
|
||||
display_message(message)
|
||||
|
||||
mock_print.assert_called()
|
||||
mock_print.assert_called_once()
|
||||
args, kwargs = mock_print.call_args
|
||||
assert message in str(args[0])
|
||||
|
||||
@patch('openhands.cli.tui.shutil.get_terminal_size')
|
||||
@patch('openhands.cli.tui.print_formatted_text')
|
||||
def test_display_agent_message(self, mock_print_formatted, mock_terminal_size):
|
||||
from collections import namedtuple
|
||||
|
||||
# Mock terminal size
|
||||
Size = namedtuple('Size', ['columns', 'lines'])
|
||||
mock_terminal_size.return_value = Size(columns=80, lines=24)
|
||||
|
||||
message = 'Agent message'
|
||||
display_agent_message(message)
|
||||
|
||||
# Should be called multiple times now (header, separator, content)
|
||||
assert mock_print_formatted.call_count >= 3
|
||||
|
||||
@patch('openhands.cli.tui.shutil.get_terminal_size')
|
||||
@patch('openhands.cli.tui.print_formatted_text')
|
||||
def test_display_agent_message_with_markdown(self, mock_print_formatted, mock_terminal_size):
|
||||
from collections import namedtuple
|
||||
|
||||
# Mock terminal size
|
||||
Size = namedtuple('Size', ['columns', 'lines'])
|
||||
mock_terminal_size.return_value = Size(columns=80, lines=24)
|
||||
|
||||
# Test with markdown content
|
||||
message = '# Heading\n\nThis is **bold** text.'
|
||||
display_agent_message(message)
|
||||
|
||||
# Should be called multiple times now (header, separator, content)
|
||||
assert mock_print_formatted.call_count >= 3
|
||||
|
||||
@patch('openhands.cli.tui.print_container')
|
||||
def test_display_command_awaiting_confirmation(self, mock_print_container):
|
||||
|
||||
69
tests/unit/test_ensure_httpx_close.py
Normal file
69
tests/unit/test_ensure_httpx_close.py
Normal file
@@ -0,0 +1,69 @@
|
||||
import httpx
|
||||
|
||||
from openhands.utils.ensure_httpx_close import ensure_httpx_close
|
||||
|
||||
|
||||
def test_ensure_httpx_close_basic():
|
||||
"""Test basic functionality of ensure_httpx_close."""
|
||||
ctx = ensure_httpx_close()
|
||||
with ctx:
|
||||
# Create a client - should be tracked
|
||||
client = httpx.Client()
|
||||
|
||||
# After context exit, client should be closed
|
||||
assert client.is_closed
|
||||
|
||||
|
||||
def test_ensure_httpx_close_multiple_clients():
|
||||
"""Test ensure_httpx_close with multiple clients."""
|
||||
ctx = ensure_httpx_close()
|
||||
with ctx:
|
||||
client1 = httpx.Client()
|
||||
client2 = httpx.Client()
|
||||
|
||||
assert client1.is_closed
|
||||
assert client2.is_closed
|
||||
|
||||
|
||||
def test_ensure_httpx_close_nested():
|
||||
"""Test nested usage of ensure_httpx_close."""
|
||||
with ensure_httpx_close():
|
||||
client1 = httpx.Client()
|
||||
|
||||
with ensure_httpx_close():
|
||||
client2 = httpx.Client()
|
||||
assert not client2.is_closed
|
||||
|
||||
# After inner context, client2 should be closed
|
||||
assert client2.is_closed
|
||||
# client1 should still be open since outer context is still active
|
||||
assert not client1.is_closed
|
||||
|
||||
# After outer context, both clients should be closed
|
||||
assert client1.is_closed
|
||||
assert client2.is_closed
|
||||
|
||||
|
||||
def test_ensure_httpx_close_exception():
|
||||
"""Test ensure_httpx_close when an exception occurs."""
|
||||
client = None
|
||||
try:
|
||||
with ensure_httpx_close():
|
||||
client = httpx.Client()
|
||||
raise ValueError('Test exception')
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
# Client should be closed even if an exception occurred
|
||||
assert client is not None
|
||||
assert client.is_closed
|
||||
|
||||
|
||||
def test_ensure_httpx_close_restore_client():
|
||||
"""Test that the original client is restored after context exit."""
|
||||
original_client = httpx.Client
|
||||
with ensure_httpx_close():
|
||||
assert httpx.Client != original_client
|
||||
|
||||
# Original __init__ should be restored
|
||||
assert httpx.Client == original_client
|
||||
@@ -86,10 +86,4 @@ async def test_get_instance():
|
||||
|
||||
assert isinstance(store, FileSettingsStore)
|
||||
assert store.file_store == mock_store
|
||||
mock_get_store.assert_called_once_with(
|
||||
file_store_type='local',
|
||||
file_store_path='/test/path',
|
||||
file_store_web_hook_url=None,
|
||||
file_store_web_hook_headers=None,
|
||||
file_store_web_hook_batch=False,
|
||||
)
|
||||
mock_get_store.assert_called_once_with('local', '/test/path', None, None)
|
||||
|
||||
@@ -89,8 +89,8 @@ def test_prep_build_folder(temp_dir):
|
||||
extra_deps=None,
|
||||
)
|
||||
|
||||
# make sure that the code (openhands/) and microagents folder were copied
|
||||
assert shutil_mock.copytree.call_count == 2
|
||||
# make sure that the code was copied
|
||||
shutil_mock.copytree.assert_called_once()
|
||||
assert shutil_mock.copy2.call_count == 2
|
||||
|
||||
# Now check dockerfile is in the folder
|
||||
|
||||
Reference in New Issue
Block a user