mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-03 02:23:51 +00:00
fix: load terminal AGENTS.md on Windows Open Terminal hosts (#31342)
Fixes #31340 When the attached Open Terminal runs on Windows, the AGENTS.md in its home directory was never handed to the model. The home check only accepted POSIX absolute paths, so a drive-letter or UNC home such as C:\ProgramData\OpenTerminal\inst was treated as invalid and the file was skipped without any log line. The check now also accepts Windows absolute paths. Relative and drive-relative homes are still skipped, and POSIX homes send byte-identical requests. The file path keeps its forward-slash join. Open Terminal normalises the path on the host, so C:\Users\bob/AGENTS.md opens C:\Users\bob\AGENTS.md. Picking ntpath.join for Windows homes would give native separators on the wire but adds a second branch for no change in which file gets read. Verified against Open Terminal's own path resolution with Windows semantics for drive-letter, forward-slash, drive-root, trailing-backslash and UNC homes, over both the backend request and the browser direct-connection path.
This commit is contained in:
parent
da36d149b0
commit
3f5881c520
1 changed files with 2 additions and 1 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import asyncio
|
||||
import logging
|
||||
import ntpath
|
||||
import posixpath
|
||||
from urllib.parse import quote
|
||||
|
||||
|
|
@ -195,7 +196,7 @@ async def get_terminal_agents_md(request, user, metadata: dict, extra_params: di
|
|||
async with asyncio.timeout(5):
|
||||
data = await get_terminal_json(request, user, metadata, '/files/cwd', extra_params)
|
||||
home = data.get('home') if isinstance(data, dict) else None
|
||||
if not isinstance(home, str) or not posixpath.isabs(home):
|
||||
if not isinstance(home, str) or not (posixpath.isabs(home) or ntpath.isabs(home)):
|
||||
return None
|
||||
path = quote(posixpath.join(home, 'AGENTS.md'), safe='')
|
||||
data = await get_terminal_json(request, user, metadata, f'/files/read?path={path}', extra_params)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue