hermes-yandex-disk 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hermes_yandex_disk-0.1.0/.gitignore +186 -0
- hermes_yandex_disk-0.1.0/LICENSE +21 -0
- hermes_yandex_disk-0.1.0/PKG-INFO +232 -0
- hermes_yandex_disk-0.1.0/README.md +204 -0
- hermes_yandex_disk-0.1.0/hermes_yandex_disk/__init__.py +120 -0
- hermes_yandex_disk-0.1.0/hermes_yandex_disk/_compat.py +23 -0
- hermes_yandex_disk-0.1.0/hermes_yandex_disk/client.py +335 -0
- hermes_yandex_disk-0.1.0/hermes_yandex_disk/config.py +137 -0
- hermes_yandex_disk-0.1.0/hermes_yandex_disk/paths.py +103 -0
- hermes_yandex_disk-0.1.0/hermes_yandex_disk/plugin.yaml +26 -0
- hermes_yandex_disk-0.1.0/hermes_yandex_disk/py.typed +0 -0
- hermes_yandex_disk-0.1.0/hermes_yandex_disk/schemas.py +292 -0
- hermes_yandex_disk-0.1.0/hermes_yandex_disk/tools.py +449 -0
- hermes_yandex_disk-0.1.0/pyproject.toml +70 -0
- hermes_yandex_disk-0.1.0/tests/__init__.py +0 -0
- hermes_yandex_disk-0.1.0/tests/conftest.py +344 -0
- hermes_yandex_disk-0.1.0/tests/e2e/__init__.py +0 -0
- hermes_yandex_disk-0.1.0/tests/e2e/conftest.py +71 -0
- hermes_yandex_disk-0.1.0/tests/e2e/test_live.py +164 -0
- hermes_yandex_disk-0.1.0/tests/test_client.py +316 -0
- hermes_yandex_disk-0.1.0/tests/test_config.py +104 -0
- hermes_yandex_disk-0.1.0/tests/test_paths.py +110 -0
- hermes_yandex_disk-0.1.0/tests/test_register.py +185 -0
- hermes_yandex_disk-0.1.0/tests/test_tools.py +440 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
|
|
110
|
+
# pdm
|
|
111
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
112
|
+
#pdm.lock
|
|
113
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
114
|
+
# in version control.
|
|
115
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
116
|
+
.pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
121
|
+
__pypackages__/
|
|
122
|
+
|
|
123
|
+
# Celery stuff
|
|
124
|
+
celerybeat-schedule
|
|
125
|
+
celerybeat.pid
|
|
126
|
+
|
|
127
|
+
# SageMath parsed files
|
|
128
|
+
*.sage.py
|
|
129
|
+
|
|
130
|
+
# Environments
|
|
131
|
+
.env
|
|
132
|
+
.venv
|
|
133
|
+
env/
|
|
134
|
+
venv/
|
|
135
|
+
ENV/
|
|
136
|
+
env.bak/
|
|
137
|
+
venv.bak/
|
|
138
|
+
|
|
139
|
+
# Spyder project settings
|
|
140
|
+
.spyderproject
|
|
141
|
+
.spyproject
|
|
142
|
+
|
|
143
|
+
# Rope project settings
|
|
144
|
+
.ropeproject
|
|
145
|
+
|
|
146
|
+
# mkdocs documentation
|
|
147
|
+
/site
|
|
148
|
+
|
|
149
|
+
# mypy
|
|
150
|
+
.mypy_cache/
|
|
151
|
+
.dmypy.json
|
|
152
|
+
dmypy.json
|
|
153
|
+
|
|
154
|
+
# Pyre type checker
|
|
155
|
+
.pyre/
|
|
156
|
+
|
|
157
|
+
# pytype static type analyzer
|
|
158
|
+
.pytype/
|
|
159
|
+
|
|
160
|
+
# Cython debug symbols
|
|
161
|
+
cython_debug/
|
|
162
|
+
|
|
163
|
+
# PyCharm
|
|
164
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
165
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
166
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
167
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
168
|
+
#.idea/
|
|
169
|
+
|
|
170
|
+
# Ruff stuff:
|
|
171
|
+
.ruff_cache/
|
|
172
|
+
|
|
173
|
+
# PyPI configuration file
|
|
174
|
+
.pypirc
|
|
175
|
+
|
|
176
|
+
# Cursor
|
|
177
|
+
# Cursor is an AI-powered code editor.`.cursorignore` specifies files/directories to
|
|
178
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
179
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
180
|
+
.cursorignore
|
|
181
|
+
.cursorindexingignore
|
|
182
|
+
# Coverage artefact written by the badge job in CI
|
|
183
|
+
coverage.json
|
|
184
|
+
|
|
185
|
+
# macOS
|
|
186
|
+
.DS_Store
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Roman Akinfeev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hermes-yandex-disk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Yandex Disk plugin for Hermes Agent — browse, read, write and share files on Yandex Disk.
|
|
5
|
+
Project-URL: Homepage, https://github.com/akinfold/hermes-yandex-disk
|
|
6
|
+
Project-URL: Repository, https://github.com/akinfold/hermes-yandex-disk
|
|
7
|
+
Project-URL: Issues, https://github.com/akinfold/hermes-yandex-disk/issues
|
|
8
|
+
Author: Roman Akinfeev
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: cloud-storage,hermes,hermes-agent,plugin,yandex,yandex-disk
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Utilities
|
|
19
|
+
Requires-Python: <3.14,>=3.11
|
|
20
|
+
Requires-Dist: httpx>=0.24
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: bandit>=1.7; extra == 'dev'
|
|
23
|
+
Requires-Dist: pytest-cov>=4.1; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest>=7.4; extra == 'dev'
|
|
25
|
+
Requires-Dist: radon>=6.0; extra == 'dev'
|
|
26
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# hermes-yandex-disk
|
|
30
|
+
|
|
31
|
+
[](https://pypi.org/project/hermes-yandex-disk/)
|
|
32
|
+
[](https://github.com/akinfold/hermes-yandex-disk/actions/workflows/ci.yml)
|
|
33
|
+
[](https://github.com/akinfold/hermes-yandex-disk/actions/workflows/e2e.yml)
|
|
34
|
+
[](https://github.com/akinfold/hermes-yandex-disk/actions/workflows/ci.yml)
|
|
35
|
+
[](https://www.codefactor.io/repository/github/akinfold/hermes-yandex-disk)
|
|
36
|
+
[](https://github.com/astral-sh/ruff)
|
|
37
|
+
[](LICENSE)
|
|
38
|
+
|
|
39
|
+
**Your Yandex Disk, handed to the agent.** It can find the file you half-remember, read it
|
|
40
|
+
into the conversation, write the answer back, and give you a share link — without you
|
|
41
|
+
opening a browser.
|
|
42
|
+
|
|
43
|
+
> "Find the invoice from March on my Disk and read me the total."
|
|
44
|
+
> "Save these meeting notes to /Notes/2026/ and give me a link."
|
|
45
|
+
> "What's eating my Disk space? Move the old videos into /Archive."
|
|
46
|
+
> "Restore that file I deleted this morning."
|
|
47
|
+
|
|
48
|
+
- 🔎 **Search that works without a search API** — Yandex Disk has none, so the plugin scans
|
|
49
|
+
the disk-wide file index and filters it, paged and bounded.
|
|
50
|
+
- 🔒 **`YANDEX_DISK_ROOT` sandboxes the agent to one folder** — every path is checked against
|
|
51
|
+
it, including ones the model invents and ones it copies back from an earlier result.
|
|
52
|
+
- 🛟 **Nothing is overwritten or destroyed by accident** — writes, copies and moves refuse an
|
|
53
|
+
existing destination unless you pass `overwrite`, deletes go to the bin by default, and the
|
|
54
|
+
bin can be restored from.
|
|
55
|
+
- 🎚 **`YANDEX_DISK_ACTIONS` decides what the agent may do at all** — a tool outside the
|
|
56
|
+
allow-list is never registered, so it cannot be called or talked into being called.
|
|
57
|
+
- 🔑 **One OAuth token, nothing proxied** — the plugin talks to `cloud-api.yandex.net`
|
|
58
|
+
directly; no third-party service sees your files or your token.
|
|
59
|
+
|
|
60
|
+
Tested against Hermes 0.19.x, Python 3.11–3.13.
|
|
61
|
+
|
|
62
|
+
## Quick start
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# 1. Install the plugin into your Hermes environment
|
|
66
|
+
hermes plugins install akinfold/hermes-yandex-disk --enable
|
|
67
|
+
|
|
68
|
+
# 2. Add your token — issue one at https://yandex.ru/dev/disk/poligon/
|
|
69
|
+
# (scopes: cloud_api:disk.info, cloud_api:disk.read, cloud_api:disk.write)
|
|
70
|
+
echo 'YANDEX_DISK_OAUTH_TOKEN=y0_your_token_here' >> ~/.hermes/.env
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
```yaml
|
|
74
|
+
# 3. ~/.hermes/config.yaml
|
|
75
|
+
plugins:
|
|
76
|
+
enabled: [yandex-disk]
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Restart Hermes and ask it: **"How much space is left on my Yandex Disk?"**
|
|
80
|
+
|
|
81
|
+
> Not ready to hand over write access? Add `YANDEX_DISK_ACTIONS=read` to `~/.hermes/.env` and
|
|
82
|
+
> the agent gets a read-only Disk. See [Choosing what the agent may do](#choosing-what-the-agent-may-do).
|
|
83
|
+
|
|
84
|
+
## The tools
|
|
85
|
+
|
|
86
|
+
| Tool | What it does |
|
|
87
|
+
|---|---|
|
|
88
|
+
| `yadisk_disk_info` | Quota, used and bin space, account login |
|
|
89
|
+
| `yadisk_list` | List a folder, or show one file's metadata |
|
|
90
|
+
| `yadisk_search` | Find files anywhere on the disk by name substring |
|
|
91
|
+
| `yadisk_read_file` | Read a text file's contents into the conversation |
|
|
92
|
+
| `yadisk_trash_list` | What is in the bin, and where each item came from |
|
|
93
|
+
| `yadisk_download` | Save a file from the Disk to the local machine |
|
|
94
|
+
| `yadisk_mkdir` | Create a folder, parents included |
|
|
95
|
+
| `yadisk_write_file` | Create or replace a text file from the agent's own output |
|
|
96
|
+
| `yadisk_upload` | Upload a local file, or have Yandex fetch a public URL |
|
|
97
|
+
| `yadisk_copy` | Server-side copy — no bytes pass through your machine |
|
|
98
|
+
| `yadisk_move` | Move or rename |
|
|
99
|
+
| `yadisk_trash_restore` | Put something back where it was deleted from |
|
|
100
|
+
| `yadisk_publish` | Create or revoke a public share link |
|
|
101
|
+
| `yadisk_delete` | Delete to the bin, or permanently with `permanently=true` |
|
|
102
|
+
| `yadisk_trash_empty` | Destroy one bin item, or the whole bin |
|
|
103
|
+
|
|
104
|
+
Every read result carries the `path` the write tools take as input, so the agent can chain
|
|
105
|
+
them without guessing.
|
|
106
|
+
|
|
107
|
+
## Configuration
|
|
108
|
+
|
|
109
|
+
| Variable | Required | Default | Meaning |
|
|
110
|
+
|---|---|---|---|
|
|
111
|
+
| `YANDEX_DISK_OAUTH_TOKEN` | yes | — | OAuth token for the account (`YANDEX_DISK_API_KEY` is also accepted) |
|
|
112
|
+
| `YANDEX_DISK_ACTIONS` | no | all tools | Which tools get registered — see below |
|
|
113
|
+
| `YANDEX_DISK_ROOT` | no | whole disk | Confine every tool to this folder |
|
|
114
|
+
| `YANDEX_DISK_MAX_READ_BYTES` | no | `1048576` | Largest file `yadisk_read_file` will pull into context |
|
|
115
|
+
| `YANDEX_DISK_MAX_DOWNLOAD_BYTES` | no | `268435456` | Largest file `yadisk_download` will write locally |
|
|
116
|
+
| `YANDEX_DISK_TIMEOUT` | no | `30` | Per-request timeout, in seconds |
|
|
117
|
+
| `YANDEX_DISK_BASE_URL` | no | `https://cloud-api.yandex.net/v1/disk` | API base, for testing against a stub |
|
|
118
|
+
|
|
119
|
+
Put them in `~/.hermes/.env` — Hermes reads it in gateway and subprocess runs too — or export
|
|
120
|
+
them in the environment.
|
|
121
|
+
|
|
122
|
+
### Confining the agent to one folder
|
|
123
|
+
|
|
124
|
+
```dotenv
|
|
125
|
+
YANDEX_DISK_ROOT=/Hermes
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Every path the agent gives is then interpreted relative to `disk:/Hermes`, and anything that
|
|
129
|
+
resolves outside it — an absolute `disk:/Private/...`, a `../` climb, a path pasted from
|
|
130
|
+
somewhere else — is refused before a request is made. Results are rewritten to hide the
|
|
131
|
+
prefix, so the agent sees a disk whose root *is* that folder. The bin is filtered the same
|
|
132
|
+
way: items deleted from outside the sandbox are neither listed nor restorable, and emptying
|
|
133
|
+
the whole bin is refused, because the bin is shared with the rest of the account.
|
|
134
|
+
|
|
135
|
+
### Choosing what the agent may do
|
|
136
|
+
|
|
137
|
+
```dotenv
|
|
138
|
+
YANDEX_DISK_ACTIONS=read,write # no deleting, no sharing
|
|
139
|
+
YANDEX_DISK_ACTIONS=read # a read-only Disk
|
|
140
|
+
YANDEX_DISK_ACTIONS=list,read_file # exactly two tools
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
| Group | Tools |
|
|
144
|
+
|---|---|
|
|
145
|
+
| `read` | `disk_info`, `list`, `search`, `read_file`, `trash_list` |
|
|
146
|
+
| `download` | `download` (writes to the **local** machine) |
|
|
147
|
+
| `write` | `mkdir`, `write_file`, `upload`, `copy`, `move`, `trash_restore` |
|
|
148
|
+
| `share` | `publish` |
|
|
149
|
+
| `delete` | `delete`, `trash_empty` |
|
|
150
|
+
| `all` | everything — the default when the variable is unset |
|
|
151
|
+
|
|
152
|
+
Groups and individual tool names mix freely, with or without the `yadisk_` prefix, so you can
|
|
153
|
+
paste straight from the tool table above. A name that matches nothing is dropped: a typo can
|
|
154
|
+
only ever withhold a tool, never grant one, and a value naming nothing valid registers nothing
|
|
155
|
+
at all. Filtering happens when the plugin loads, so **restart Hermes** after changing it.
|
|
156
|
+
|
|
157
|
+
## Getting the credential
|
|
158
|
+
|
|
159
|
+
1. Open <https://yandex.ru/dev/disk/poligon/> signed in as the account you want the agent to
|
|
160
|
+
use, and issue a debug token — the fastest route, and what it gives you is an ordinary
|
|
161
|
+
OAuth token.
|
|
162
|
+
2. For a long-lived setup, register an app at <https://oauth.yandex.ru/> with the scopes
|
|
163
|
+
`cloud_api:disk.info`, `cloud_api:disk.read` and `cloud_api:disk.write`, then run the usual
|
|
164
|
+
OAuth flow.
|
|
165
|
+
|
|
166
|
+
Yandex Disk is free up to 5 GB and the API costs nothing to use. The token is the only
|
|
167
|
+
credential needed — see [Why REST and not WebDAV](#why-rest-and-not-webdav) for why there is
|
|
168
|
+
no app password to store.
|
|
169
|
+
|
|
170
|
+
## Installing
|
|
171
|
+
|
|
172
|
+
**A. From Git (recommended)**
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
hermes plugins install akinfold/hermes-yandex-disk --enable
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**B. From PyPI** — discovered through the `hermes_agent.plugins` entry point:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
pip install hermes-yandex-disk
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Then add `yandex-disk` to `plugins.enabled` in `~/.hermes/config.yaml`.
|
|
185
|
+
|
|
186
|
+
**C. Drop-in** — unzip `hermes-yandex-disk-plugin-<version>.zip` from a
|
|
187
|
+
[release](https://github.com/akinfold/hermes-yandex-disk/releases) under `~/.hermes/plugins/`
|
|
188
|
+
so you get `~/.hermes/plugins/yandex-disk/plugin.yaml`, then enable it the same way.
|
|
189
|
+
|
|
190
|
+
## Why REST and not WebDAV
|
|
191
|
+
|
|
192
|
+
Yandex Disk exposes both a REST API and a WebDAV endpoint. This plugin is REST-only, because
|
|
193
|
+
WebDAV covers strictly less: no bin, no public links, no flat file index to search over, and
|
|
194
|
+
no reporting for the deferred operations that large folder copies and deletes turn into.
|
|
195
|
+
rclone's Yandex backend made the same call. The one thing WebDAV adds — an app-password login
|
|
196
|
+
— is not worth a second stored credential for capabilities the REST API already has.
|
|
197
|
+
|
|
198
|
+
## Development
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
python -m venv .venv && . .venv/bin/activate
|
|
202
|
+
pip install -e '.[dev]'
|
|
203
|
+
|
|
204
|
+
pytest --cov=hermes_yandex_disk --cov-report=term-missing # unit tests, no network
|
|
205
|
+
ruff check . && ruff format --check .
|
|
206
|
+
radon cc -s -n C hermes_yandex_disk # must print nothing
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Running the live E2E tests
|
|
210
|
+
|
|
211
|
+
> These create, publish and permanently delete real files. **Use a throwaway Yandex account.**
|
|
212
|
+
> Everything is confined to one `hermes-e2e-<id>` folder that is destroyed in teardown.
|
|
213
|
+
|
|
214
|
+
Locally, put the token in `~/.yandex-disk-oauth` (and optionally the login in
|
|
215
|
+
`~/.yandex-disk-login`) and run:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
pytest -m e2e -v
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
The suite skips itself when no credentials are available. On GitHub Actions, run the
|
|
222
|
+
**E2E (live)** workflow manually; it reads `YANDEX_DISK_OAUTH_TOKEN` from the
|
|
223
|
+
`yandex-disk-e2e` environment.
|
|
224
|
+
|
|
225
|
+
## Contributing
|
|
226
|
+
|
|
227
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md). Please report security issues privately rather than as
|
|
228
|
+
a public issue.
|
|
229
|
+
|
|
230
|
+
## License
|
|
231
|
+
|
|
232
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# hermes-yandex-disk
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/hermes-yandex-disk/)
|
|
4
|
+
[](https://github.com/akinfold/hermes-yandex-disk/actions/workflows/ci.yml)
|
|
5
|
+
[](https://github.com/akinfold/hermes-yandex-disk/actions/workflows/e2e.yml)
|
|
6
|
+
[](https://github.com/akinfold/hermes-yandex-disk/actions/workflows/ci.yml)
|
|
7
|
+
[](https://www.codefactor.io/repository/github/akinfold/hermes-yandex-disk)
|
|
8
|
+
[](https://github.com/astral-sh/ruff)
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
|
|
11
|
+
**Your Yandex Disk, handed to the agent.** It can find the file you half-remember, read it
|
|
12
|
+
into the conversation, write the answer back, and give you a share link — without you
|
|
13
|
+
opening a browser.
|
|
14
|
+
|
|
15
|
+
> "Find the invoice from March on my Disk and read me the total."
|
|
16
|
+
> "Save these meeting notes to /Notes/2026/ and give me a link."
|
|
17
|
+
> "What's eating my Disk space? Move the old videos into /Archive."
|
|
18
|
+
> "Restore that file I deleted this morning."
|
|
19
|
+
|
|
20
|
+
- 🔎 **Search that works without a search API** — Yandex Disk has none, so the plugin scans
|
|
21
|
+
the disk-wide file index and filters it, paged and bounded.
|
|
22
|
+
- 🔒 **`YANDEX_DISK_ROOT` sandboxes the agent to one folder** — every path is checked against
|
|
23
|
+
it, including ones the model invents and ones it copies back from an earlier result.
|
|
24
|
+
- 🛟 **Nothing is overwritten or destroyed by accident** — writes, copies and moves refuse an
|
|
25
|
+
existing destination unless you pass `overwrite`, deletes go to the bin by default, and the
|
|
26
|
+
bin can be restored from.
|
|
27
|
+
- 🎚 **`YANDEX_DISK_ACTIONS` decides what the agent may do at all** — a tool outside the
|
|
28
|
+
allow-list is never registered, so it cannot be called or talked into being called.
|
|
29
|
+
- 🔑 **One OAuth token, nothing proxied** — the plugin talks to `cloud-api.yandex.net`
|
|
30
|
+
directly; no third-party service sees your files or your token.
|
|
31
|
+
|
|
32
|
+
Tested against Hermes 0.19.x, Python 3.11–3.13.
|
|
33
|
+
|
|
34
|
+
## Quick start
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# 1. Install the plugin into your Hermes environment
|
|
38
|
+
hermes plugins install akinfold/hermes-yandex-disk --enable
|
|
39
|
+
|
|
40
|
+
# 2. Add your token — issue one at https://yandex.ru/dev/disk/poligon/
|
|
41
|
+
# (scopes: cloud_api:disk.info, cloud_api:disk.read, cloud_api:disk.write)
|
|
42
|
+
echo 'YANDEX_DISK_OAUTH_TOKEN=y0_your_token_here' >> ~/.hermes/.env
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```yaml
|
|
46
|
+
# 3. ~/.hermes/config.yaml
|
|
47
|
+
plugins:
|
|
48
|
+
enabled: [yandex-disk]
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Restart Hermes and ask it: **"How much space is left on my Yandex Disk?"**
|
|
52
|
+
|
|
53
|
+
> Not ready to hand over write access? Add `YANDEX_DISK_ACTIONS=read` to `~/.hermes/.env` and
|
|
54
|
+
> the agent gets a read-only Disk. See [Choosing what the agent may do](#choosing-what-the-agent-may-do).
|
|
55
|
+
|
|
56
|
+
## The tools
|
|
57
|
+
|
|
58
|
+
| Tool | What it does |
|
|
59
|
+
|---|---|
|
|
60
|
+
| `yadisk_disk_info` | Quota, used and bin space, account login |
|
|
61
|
+
| `yadisk_list` | List a folder, or show one file's metadata |
|
|
62
|
+
| `yadisk_search` | Find files anywhere on the disk by name substring |
|
|
63
|
+
| `yadisk_read_file` | Read a text file's contents into the conversation |
|
|
64
|
+
| `yadisk_trash_list` | What is in the bin, and where each item came from |
|
|
65
|
+
| `yadisk_download` | Save a file from the Disk to the local machine |
|
|
66
|
+
| `yadisk_mkdir` | Create a folder, parents included |
|
|
67
|
+
| `yadisk_write_file` | Create or replace a text file from the agent's own output |
|
|
68
|
+
| `yadisk_upload` | Upload a local file, or have Yandex fetch a public URL |
|
|
69
|
+
| `yadisk_copy` | Server-side copy — no bytes pass through your machine |
|
|
70
|
+
| `yadisk_move` | Move or rename |
|
|
71
|
+
| `yadisk_trash_restore` | Put something back where it was deleted from |
|
|
72
|
+
| `yadisk_publish` | Create or revoke a public share link |
|
|
73
|
+
| `yadisk_delete` | Delete to the bin, or permanently with `permanently=true` |
|
|
74
|
+
| `yadisk_trash_empty` | Destroy one bin item, or the whole bin |
|
|
75
|
+
|
|
76
|
+
Every read result carries the `path` the write tools take as input, so the agent can chain
|
|
77
|
+
them without guessing.
|
|
78
|
+
|
|
79
|
+
## Configuration
|
|
80
|
+
|
|
81
|
+
| Variable | Required | Default | Meaning |
|
|
82
|
+
|---|---|---|---|
|
|
83
|
+
| `YANDEX_DISK_OAUTH_TOKEN` | yes | — | OAuth token for the account (`YANDEX_DISK_API_KEY` is also accepted) |
|
|
84
|
+
| `YANDEX_DISK_ACTIONS` | no | all tools | Which tools get registered — see below |
|
|
85
|
+
| `YANDEX_DISK_ROOT` | no | whole disk | Confine every tool to this folder |
|
|
86
|
+
| `YANDEX_DISK_MAX_READ_BYTES` | no | `1048576` | Largest file `yadisk_read_file` will pull into context |
|
|
87
|
+
| `YANDEX_DISK_MAX_DOWNLOAD_BYTES` | no | `268435456` | Largest file `yadisk_download` will write locally |
|
|
88
|
+
| `YANDEX_DISK_TIMEOUT` | no | `30` | Per-request timeout, in seconds |
|
|
89
|
+
| `YANDEX_DISK_BASE_URL` | no | `https://cloud-api.yandex.net/v1/disk` | API base, for testing against a stub |
|
|
90
|
+
|
|
91
|
+
Put them in `~/.hermes/.env` — Hermes reads it in gateway and subprocess runs too — or export
|
|
92
|
+
them in the environment.
|
|
93
|
+
|
|
94
|
+
### Confining the agent to one folder
|
|
95
|
+
|
|
96
|
+
```dotenv
|
|
97
|
+
YANDEX_DISK_ROOT=/Hermes
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Every path the agent gives is then interpreted relative to `disk:/Hermes`, and anything that
|
|
101
|
+
resolves outside it — an absolute `disk:/Private/...`, a `../` climb, a path pasted from
|
|
102
|
+
somewhere else — is refused before a request is made. Results are rewritten to hide the
|
|
103
|
+
prefix, so the agent sees a disk whose root *is* that folder. The bin is filtered the same
|
|
104
|
+
way: items deleted from outside the sandbox are neither listed nor restorable, and emptying
|
|
105
|
+
the whole bin is refused, because the bin is shared with the rest of the account.
|
|
106
|
+
|
|
107
|
+
### Choosing what the agent may do
|
|
108
|
+
|
|
109
|
+
```dotenv
|
|
110
|
+
YANDEX_DISK_ACTIONS=read,write # no deleting, no sharing
|
|
111
|
+
YANDEX_DISK_ACTIONS=read # a read-only Disk
|
|
112
|
+
YANDEX_DISK_ACTIONS=list,read_file # exactly two tools
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
| Group | Tools |
|
|
116
|
+
|---|---|
|
|
117
|
+
| `read` | `disk_info`, `list`, `search`, `read_file`, `trash_list` |
|
|
118
|
+
| `download` | `download` (writes to the **local** machine) |
|
|
119
|
+
| `write` | `mkdir`, `write_file`, `upload`, `copy`, `move`, `trash_restore` |
|
|
120
|
+
| `share` | `publish` |
|
|
121
|
+
| `delete` | `delete`, `trash_empty` |
|
|
122
|
+
| `all` | everything — the default when the variable is unset |
|
|
123
|
+
|
|
124
|
+
Groups and individual tool names mix freely, with or without the `yadisk_` prefix, so you can
|
|
125
|
+
paste straight from the tool table above. A name that matches nothing is dropped: a typo can
|
|
126
|
+
only ever withhold a tool, never grant one, and a value naming nothing valid registers nothing
|
|
127
|
+
at all. Filtering happens when the plugin loads, so **restart Hermes** after changing it.
|
|
128
|
+
|
|
129
|
+
## Getting the credential
|
|
130
|
+
|
|
131
|
+
1. Open <https://yandex.ru/dev/disk/poligon/> signed in as the account you want the agent to
|
|
132
|
+
use, and issue a debug token — the fastest route, and what it gives you is an ordinary
|
|
133
|
+
OAuth token.
|
|
134
|
+
2. For a long-lived setup, register an app at <https://oauth.yandex.ru/> with the scopes
|
|
135
|
+
`cloud_api:disk.info`, `cloud_api:disk.read` and `cloud_api:disk.write`, then run the usual
|
|
136
|
+
OAuth flow.
|
|
137
|
+
|
|
138
|
+
Yandex Disk is free up to 5 GB and the API costs nothing to use. The token is the only
|
|
139
|
+
credential needed — see [Why REST and not WebDAV](#why-rest-and-not-webdav) for why there is
|
|
140
|
+
no app password to store.
|
|
141
|
+
|
|
142
|
+
## Installing
|
|
143
|
+
|
|
144
|
+
**A. From Git (recommended)**
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
hermes plugins install akinfold/hermes-yandex-disk --enable
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**B. From PyPI** — discovered through the `hermes_agent.plugins` entry point:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
pip install hermes-yandex-disk
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Then add `yandex-disk` to `plugins.enabled` in `~/.hermes/config.yaml`.
|
|
157
|
+
|
|
158
|
+
**C. Drop-in** — unzip `hermes-yandex-disk-plugin-<version>.zip` from a
|
|
159
|
+
[release](https://github.com/akinfold/hermes-yandex-disk/releases) under `~/.hermes/plugins/`
|
|
160
|
+
so you get `~/.hermes/plugins/yandex-disk/plugin.yaml`, then enable it the same way.
|
|
161
|
+
|
|
162
|
+
## Why REST and not WebDAV
|
|
163
|
+
|
|
164
|
+
Yandex Disk exposes both a REST API and a WebDAV endpoint. This plugin is REST-only, because
|
|
165
|
+
WebDAV covers strictly less: no bin, no public links, no flat file index to search over, and
|
|
166
|
+
no reporting for the deferred operations that large folder copies and deletes turn into.
|
|
167
|
+
rclone's Yandex backend made the same call. The one thing WebDAV adds — an app-password login
|
|
168
|
+
— is not worth a second stored credential for capabilities the REST API already has.
|
|
169
|
+
|
|
170
|
+
## Development
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
python -m venv .venv && . .venv/bin/activate
|
|
174
|
+
pip install -e '.[dev]'
|
|
175
|
+
|
|
176
|
+
pytest --cov=hermes_yandex_disk --cov-report=term-missing # unit tests, no network
|
|
177
|
+
ruff check . && ruff format --check .
|
|
178
|
+
radon cc -s -n C hermes_yandex_disk # must print nothing
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Running the live E2E tests
|
|
182
|
+
|
|
183
|
+
> These create, publish and permanently delete real files. **Use a throwaway Yandex account.**
|
|
184
|
+
> Everything is confined to one `hermes-e2e-<id>` folder that is destroyed in teardown.
|
|
185
|
+
|
|
186
|
+
Locally, put the token in `~/.yandex-disk-oauth` (and optionally the login in
|
|
187
|
+
`~/.yandex-disk-login`) and run:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
pytest -m e2e -v
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
The suite skips itself when no credentials are available. On GitHub Actions, run the
|
|
194
|
+
**E2E (live)** workflow manually; it reads `YANDEX_DISK_OAUTH_TOKEN` from the
|
|
195
|
+
`yandex-disk-e2e` environment.
|
|
196
|
+
|
|
197
|
+
## Contributing
|
|
198
|
+
|
|
199
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md). Please report security issues privately rather than as
|
|
200
|
+
a public issue.
|
|
201
|
+
|
|
202
|
+
## License
|
|
203
|
+
|
|
204
|
+
MIT — see [LICENSE](LICENSE).
|