beeui 0.13.0__py3-none-any.whl

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.
Files changed (71) hide show
  1. beeui-0.13.0.dist-info/METADATA +1709 -0
  2. beeui-0.13.0.dist-info/RECORD +71 -0
  3. beeui-0.13.0.dist-info/WHEEL +5 -0
  4. beeui-0.13.0.dist-info/entry_points.txt +2 -0
  5. beeui-0.13.0.dist-info/top_level.txt +1 -0
  6. beeui_module/__init__.py +0 -0
  7. beeui_module/adapters/__init__.py +0 -0
  8. beeui_module/adapters/base.py +96 -0
  9. beeui_module/adapters/beecap.py +249 -0
  10. beeui_module/adapters/envelopes.py +156 -0
  11. beeui_module/adapters/errors.py +31 -0
  12. beeui_module/adapters/ids.py +70 -0
  13. beeui_module/artifacts/__init__.py +0 -0
  14. beeui_module/artifacts/models.py +28 -0
  15. beeui_module/artifacts/preview.py +261 -0
  16. beeui_module/artifacts/redaction.py +63 -0
  17. beeui_module/artifacts/routes.py +407 -0
  18. beeui_module/blocks/__init__.py +0 -0
  19. beeui_module/blocks/models.py +48 -0
  20. beeui_module/blocks/registry.py +137 -0
  21. beeui_module/blocks/renderers.py +778 -0
  22. beeui_module/cli/__init__.py +0 -0
  23. beeui_module/cli/doctor.py +44 -0
  24. beeui_module/cli/main.py +94 -0
  25. beeui_module/cli/web.py +48 -0
  26. beeui_module/core/__init__.py +0 -0
  27. beeui_module/core/log.py +60 -0
  28. beeui_module/core/paths.py +62 -0
  29. beeui_module/core/settings.py +172 -0
  30. beeui_module/core/version.py +11 -0
  31. beeui_module/data/__init__.py +0 -0
  32. beeui_module/data/models.py +66 -0
  33. beeui_module/data/resolver.py +75 -0
  34. beeui_module/data/selectors.py +55 -0
  35. beeui_module/data/sources.py +126 -0
  36. beeui_module/pages/__init__.py +0 -0
  37. beeui_module/pages/component_catalog.py +296 -0
  38. beeui_module/pages/config.py +551 -0
  39. beeui_module/pages/models.py +75 -0
  40. beeui_module/pages/router.py +172 -0
  41. beeui_module/web/__init__.py +0 -0
  42. beeui_module/web/app.py +277 -0
  43. beeui_module/web/static/css/beeui.css +410 -0
  44. beeui_module/web/static/js/beeui.js +18 -0
  45. beeui_module/web/static/vendor/tabler/css/tabler-compatible.min.css +245 -0
  46. beeui_module/web/static/vendor/tabler/js/tabler-compatible.min.js +21 -0
  47. beeui_module/web/templates/artifacts/detail.html +147 -0
  48. beeui_module/web/templates/artifacts/list.html +84 -0
  49. beeui_module/web/templates/base.html +30 -0
  50. beeui_module/web/templates/components/alert_card.html +21 -0
  51. beeui_module/web/templates/components/catalog/index.html +25 -0
  52. beeui_module/web/templates/components/catalog/page.html +21 -0
  53. beeui_module/web/templates/components/catalog/sections/extra.html +26 -0
  54. beeui_module/web/templates/components/catalog/sections/forms.html +25 -0
  55. beeui_module/web/templates/components/catalog/sections/interface.html +31 -0
  56. beeui_module/web/templates/components/catalog/sections/layout.html +36 -0
  57. beeui_module/web/templates/components/catalog/sections/plugins.html +13 -0
  58. beeui_module/web/templates/components/empty_state.html +5 -0
  59. beeui_module/web/templates/components/footer.html +9 -0
  60. beeui_module/web/templates/components/kpi_grid.html +26 -0
  61. beeui_module/web/templates/components/links_card.html +22 -0
  62. beeui_module/web/templates/components/metric_card.html +21 -0
  63. beeui_module/web/templates/components/navbar.html +14 -0
  64. beeui_module/web/templates/components/page_header.html +12 -0
  65. beeui_module/web/templates/components/primitives/catalog_primitives.html +344 -0
  66. beeui_module/web/templates/components/progress_card.html +31 -0
  67. beeui_module/web/templates/components/sidebar.html +57 -0
  68. beeui_module/web/templates/components/status_card.html +19 -0
  69. beeui_module/web/templates/components/table_card.html +39 -0
  70. beeui_module/web/templates/components/text_card.html +16 -0
  71. beeui_module/web/templates/page.html +23 -0
@@ -0,0 +1,1709 @@
1
+ Metadata-Version: 2.4
2
+ Name: beeui
3
+ Version: 0.13.0
4
+ Summary: Reusable UI framework for Bee products
5
+ Requires-Python: >=3.14
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: fastapi>=0.135
8
+ Requires-Dist: jinja2>=3.1
9
+ Requires-Dist: pydantic>=2.11
10
+ Requires-Dist: pyyaml>=6.0
11
+ Requires-Dist: uvicorn>=0.44
12
+ Provides-Extra: dev
13
+ Requires-Dist: httpx2>=2.2.0; extra == "dev"
14
+ Requires-Dist: pytest>=9.0.3; extra == "dev"
15
+
16
+ # BeeUI — reusable UI framework для Bee-продуктов
17
+
18
+ **BeeUI** — общий Python-based UI framework для Bee-продуктов: `beecap`, `beeagent` и будущих модулей Bee ecosystem.
19
+
20
+ ## Iteration 11
21
+
22
+ Текущий deliverable — Generic artifact browser v1: read-only просмотр артефактов через `ProductUiAdapter`.
23
+
24
+ Уже работает:
25
+
26
+ - всё из Iteration 10: `create_beeui_app(...)`, `mount_beeui(...)`, adapter injection, product metadata, mount path validation;
27
+ - `uv sync --frozen --extra dev`;
28
+ - `uv run pytest -q`;
29
+ - `./start.sh doctor`;
30
+ - `./start.sh version`;
31
+ - `./start.sh routes`;
32
+ - `./start.sh web --host 127.0.0.1 --port 8780`;
33
+ - `import beeui_module`;
34
+ - schema-driven theme/layout/navigation в `config/schema.yml`;
35
+ - schema-driven literal и resolver-backed blocks в `config/schema.yml`;
36
+ - read-only `demo` data source;
37
+ - read-only `static` YAML/JSON data source;
38
+ - stable resolver envelope для controlled block value resolution;
39
+ - dashboard blocks рендерятся из top-level `blocks` и `pages[].blocks[]`;
40
+ - generic adapter contract package `src/beeui_module/adapters/`;
41
+ - stable adapter envelopes (`ok|partial|error`) and stable adapter errors;
42
+ - safe adapter ID helpers for `product_id`, `run_id`, `artifact_id`, `action_id`;
43
+ - BeeCap-compatible fixture adapter `BeeCapFixtureAdapter`;
44
+ - controlled BeeCap-like fixtures under `tests/fixtures/beecap/`;
45
+ - BeeCap adapter fixture tests in `tests/test_beecap_adapter.py`;
46
+ - integration boundary docs in `docs/INTEGRATION.md`;
47
+ - embedded BeeCap example in `examples/beecap_embedded/beeui.yml`;
48
+ - `GET /runs/{run_id}/artifacts` — HTML список артефактов;
49
+ - `GET /runs/{run_id}/artifacts/{artifact_id}` — HTML preview артефакта;
50
+ - `GET /api/runs/{run_id}/artifacts` — JSON API список артефактов;
51
+ - `GET /api/runs/{run_id}/artifacts/{artifact_id}` — JSON API preview артефакта;
52
+ - JSON preview с redaction;
53
+ - JSONL preview до 500 строк с row-level warnings;
54
+ - text preview до 100 000 символов;
55
+ - unsupported/binary artifacts отображаются как metadata-only;
56
+ - malformed JSON/JSONL не ломают страницу/API;
57
+ - large JSON/JSONL preview ограничен 512 KB;
58
+ - safe `run_id` / `artifact_id` validation;
59
+ - redaction placeholder для `secret`, `token`, `password`, `api_key`, `api_secret`;
60
+ - доступ к артефактам идёт только через `ProductUiAdapter.list_artifacts()` и `ProductUiAdapter.read_artifact()`;
61
+ - при отсутствии adapter возвращается explicit 503 unavailable state;
62
+ - `features.browser_artifact` включает/отключает HTML/API artifact routes;
63
+ - `features.api` остаётся зарезервированным для будущего stable BeeUI API и не отключает artifact browser API routes;
64
+ - `create_beeui_app(settings, ui_config, *, config_path, product_id, product_title, adapter)`;
65
+ - `mount_beeui(parent_app, *, path, ...)` для встраивания BeeUI в родительское FastAPI приложение;
66
+ - `app.state.beeui_adapter` — сохранение adapter instance;
67
+ - `app.state.beeui_product` — сохранение product metadata;
68
+ - runtime-валидация adapter на соответствие минимальному протоколу `ProductUiAdapter`;
69
+ - валидация mount path (безопасный путь, без path traversal);
70
+ - проверка коллизии маршрутов при mount;
71
+ - embedded API тесты в `tests/test_embedded.py`.
72
+
73
+ Поддерживаемые типы блоков:
74
+
75
+ - `metric_card`;
76
+ - `kpi_grid`;
77
+ - `status_card`;
78
+ - `table_card`;
79
+ - `links_card`;
80
+ - `alert_card`;
81
+ - `text_card`;
82
+ - `progress_card`.
83
+
84
+ Минимальная web surface после Iteration 11:
85
+
86
+ - `GET /`
87
+ - `GET /runs`
88
+ - `GET /components`
89
+ - `GET /components/interface`
90
+ - `GET /components/forms`
91
+ - `GET /components/layout`
92
+ - `GET /components/extra`
93
+ - `GET /components/plugins`
94
+ - `GET /health`
95
+ - `GET /static/...`
96
+ - `GET /static/vendor/tabler/css/tabler-compatible.min.css`
97
+ - `GET /static/vendor/tabler/js/tabler-compatible.min.js`
98
+ - `GET /runs/{run_id}/artifacts`
99
+ - `GET /runs/{run_id}/artifacts/{artifact_id}`
100
+ - `GET /api/runs/{run_id}/artifacts`
101
+ - `GET /api/runs/{run_id}/artifacts/{artifact_id}`
102
+
103
+ При использовании `mount_beeui(parent, path="/ui")` маршруты доступны под `/ui/`:
104
+
105
+ - `GET /ui/`
106
+ - `GET /ui/health`
107
+ - `GET /ui/static/...`
108
+ - `GET /ui/runs/{run_id}/artifacts`
109
+ - `GET /ui/runs/{run_id}/artifacts/{artifact_id}`
110
+ - `GET /ui/api/runs/{run_id}/artifacts`
111
+ - `GET /ui/api/runs/{run_id}/artifacts/{artifact_id}`
112
+
113
+ Iteration 11 добавляет только read-only artifact API routes. Stable BeeUI API для dashboard/runs/config/actions остаётся future scope.
114
+
115
+ Shell и dashboard рендерятся через component templates:
116
+
117
+ - `components/sidebar.html`;
118
+ - `components/navbar.html`;
119
+ - `components/page_header.html`;
120
+ - `components/footer.html`;
121
+ - `components/empty_state.html`.
122
+ - block component templates для literal и resolver-backed dashboard blocks.
123
+
124
+ Tabler-compatible vendor assets поставляются локально из package path:
125
+
126
+ - `src/beeui_module/web/static/vendor/tabler/css/tabler-compatible.min.css`
127
+ - `src/beeui_module/web/static/vendor/tabler/js/tabler-compatible.min.js`
128
+
129
+ BeeUI поставляет локальный Tabler-compatible subset в
130
+ `src/beeui_module/web/static/vendor/tabler/`.
131
+ Это не полный upstream Tabler demo bundle.
132
+ Preview/demo/tracking assets не поставляются.
133
+
134
+ Navigation, theme и layout shell options (title/subtitle/paths/logo_text/theme/layout) рендерятся из `config/schema.yml`.
135
+
136
+ Пока не входит в scope:
137
+
138
+ - production BeeCap/BeeAgent adapters;
139
+ - adapter-backed dashboard/runs rendering (Iteration 12+);
140
+ - run detail page;
141
+ - stable BeeUI API для dashboard/runs/config/actions;
142
+ - auth/session;
143
+ - config UI;
144
+ - no-code builder.
145
+
146
+ Проект нужен, чтобы не писать заново в каждом продукте:
147
+
148
+ - web shell;
149
+ - sidebar / navbar / layout;
150
+ - dashboard;
151
+ - KPI cards;
152
+ - tables;
153
+ - artifact browser;
154
+ - config UI;
155
+ - operator/admin pages;
156
+ - theme customization;
157
+ - bounded operator actions;
158
+ - стабильный read-only JSON API для будущего frontend.
159
+
160
+ BeeUI строится как reusable layer поверх:
161
+
162
+ - **FastAPI** — web runtime;
163
+ - **Jinja2** — server-rendered HTML templates;
164
+ - **Tabler** — UI/admin visual foundation;
165
+ - **Pydantic / dataclasses** — schema/config/read-model contracts;
166
+ - **file/API adapters** — подключение к Bee-продуктам.
167
+
168
+ BeeUI не является trading engine, agent runtime или backend core. Он не принимает domain-решения и не получает прямую execution authority.
169
+
170
+ Главное правило:
171
+
172
+ ```text
173
+ BeeUI renders.
174
+ Product decides.
175
+ ```
176
+
177
+ ## Зачем нужен BeeUI
178
+
179
+ Сейчас `beecap` и `beeagent` начинают дублировать один и тот же UI-слой:
180
+
181
+ - разные web directories;
182
+ - разные templates;
183
+ - разные CSS;
184
+ - разные dashboards;
185
+ - разные artifact viewers;
186
+ - разные admin/config pages;
187
+ - разные operator controls.
188
+
189
+ Это быстро превращается в хаос.
190
+
191
+ BeeUI решает эту проблему как общий UI/runtime package:
192
+
193
+ ```text
194
+ beecap
195
+ -> exposes read-model / artifacts / bounded actions
196
+ -> BeeUI renders dashboard, runs, artifacts, config/admin pages
197
+
198
+ beeagent
199
+ -> exposes modules / runs / capabilities / artifacts
200
+ -> BeeUI renders operator console and будущий frontend shell
201
+ ```
202
+
203
+ ## Текущий фокус проекта
204
+
205
+ Текущий фокус BeeUI:
206
+
207
+ - быстро дойти до MVP;
208
+ - подключить `beecap` как первый продукт;
209
+ - перестать расширять кастомный web UI внутри `beecap`;
210
+ - затем подключить `beeagent`;
211
+ - сохранить KISS, безопасность и read-only по умолчанию;
212
+ - подготовить основу для будущего no-code dashboard/frontend builder.
213
+
214
+ MVP не пытается сразу стать полноценным Retool/Webflow/Admin SaaS.
215
+
216
+ Целевой MVP делает controlled declarative console:
217
+
218
+ - pages описываются через schema/config;
219
+ - blocks описываются через schema/config;
220
+ - данные приходят из product adapter;
221
+ - artifacts отображаются через bounded artifact browser;
222
+ - write/control actions идут только через product-owned callbacks.
223
+
224
+ ## Что BeeUI делает
225
+
226
+ В текущем состоянии после Iteration 11 BeeUI отвечает за:
227
+
228
+ - FastAPI app factory;
229
+ - Jinja2 templates;
230
+ - Tabler layout;
231
+ - global navigation;
232
+ - reusable blocks;
233
+ - dashboard rendering;
234
+ - declarative pages/navigation/theme/layout;
235
+ - static/literal and resolver-backed dashboard blocks from `config/schema.yml`;
236
+ - generic product adapter contract v0 in `src/beeui_module/adapters/`;
237
+ - BeeCap-compatible fixture/reference adapter for contract validation;
238
+ - embedded app factory `create_beeui_app(...)`;
239
+ - mount helper `mount_beeui(...)`;
240
+ - загрузку product-specific UI config через `config_path`;
241
+ - product metadata injection;
242
+ - adapter injection, validation и сохранение в `app.state.beeui_adapter`;
243
+ - сохранение product metadata в `app.state.beeui_product`;
244
+ - проверку mount path и route collision guard;
245
+ - artifact browser — HTML/JSON list and preview через adapter;
246
+ - JSON/JSONL/text bounded preview с malformed handling, preview limits и redaction;
247
+ - read-only API routes для артефактов.
248
+
249
+ Запланированные обязанности:
250
+
251
+ - runs list / run detail pages;
252
+ - source artifact links;
253
+ - config read-model;
254
+ - config preview/apply framework;
255
+ - bounded operator actions;
256
+ - auth/session layer;
257
+ - theme customization;
258
+ - stable JSON API для будущего frontend;
259
+ - standalone mode.
260
+
261
+ ## Чего BeeUI не делает
262
+
263
+ BeeUI не должен:
264
+
265
+ - принимать торговые решения;
266
+ - запускать broker/API calls напрямую;
267
+ - читать secrets;
268
+ - менять runtime state без product callback;
269
+ - самостоятельно парсить domain logic BeeCap/BeeAgent;
270
+ - становиться вторым source of truth;
271
+ - заменять `config/settings.yml` продукта;
272
+ - заменять `storage/` artifacts продукта;
273
+ - исполнять live/broker actions;
274
+ - делать hidden fallback execution;
275
+ - обходить product validation/security boundaries.
276
+
277
+ Все domain-sensitive вещи остаются в продукте.
278
+
279
+ ## Интеграционная модель
280
+
281
+ ### MVP: embedded mode
282
+
283
+ Для MVP BeeUI подключается как dependency внутрь продукта.
284
+
285
+ ```text
286
+ beecap process
287
+ imports beeui
288
+ creates BeeCapUiAdapter
289
+ mounts BeeUI FastAPI app
290
+ ```
291
+
292
+ Для BeeAgent это пока будущий scope. Целевая структура может быть похожей:
293
+
294
+ ```text
295
+ beeagent process
296
+ imports beeui
297
+ creates BeeAgentUiAdapter
298
+ mounts BeeUI FastAPI app
299
+ ```
300
+
301
+ Плюсы:
302
+
303
+ - быстро;
304
+ - один процесс;
305
+ - проще локальная разработка;
306
+ - проще auth/session;
307
+ - нет CORS;
308
+ - нет отдельного service discovery;
309
+ - меньше deployment complexity.
310
+
311
+ Минусы:
312
+
313
+ - каждый продукт запускает свой BeeUI instance;
314
+ - обновление BeeUI идёт через dependency update.
315
+
316
+ ### Будущий `standalone` mode
317
+
318
+ Позже BeeUI сможет работать отдельным сервисом:
319
+
320
+ ```text
321
+ beeui service
322
+ -> connects to beecap API
323
+ -> connects to beeagent API
324
+ -> renders multi-product UI
325
+ ```
326
+
327
+ Плюсы:
328
+
329
+ - один UI service;
330
+ - можно сделать unified Bee dashboard;
331
+ - проще отдельный frontend;
332
+ - можно держать `beecap` и `beeagent` как backend/API services.
333
+
334
+ Минусы:
335
+
336
+ - сложнее auth;
337
+ - CORS;
338
+ - network timeouts;
339
+ - service discovery;
340
+ - deployment complexity.
341
+
342
+ Решение:
343
+
344
+ ```text
345
+ MVP: embedded.
346
+ Позже: standalone.
347
+ ```
348
+
349
+ ## Как подключать к BeeCap
350
+
351
+ На этапе разработки `beeui` лежит рядом:
352
+
353
+ ```text
354
+ ~/Projects/
355
+ beecap/
356
+ beeagent/
357
+ beeui/
358
+ ```
359
+
360
+ В `beecap/pyproject.toml` для локальной разработки:
361
+
362
+ ```toml
363
+ dependencies = [
364
+ "beeui @ file:///home/bee/Projects/beeui",
365
+ ]
366
+ ```
367
+
368
+ Или временно:
369
+
370
+ ```bash
371
+ cd ~/Projects/beecap
372
+ uv pip install -e ../beeui
373
+ ```
374
+
375
+ Целевой вариант после стабилизации:
376
+
377
+ ```toml
378
+ dependencies = [
379
+ "beeui @ git+ssh://git@github.com/beesyst/beeui.git@v0.1.0",
380
+ ]
381
+ ```
382
+
383
+ Минимальный integration point в BeeCap:
384
+
385
+ ```text
386
+ src/beecap_module/interfaces/ui/
387
+ adapter.py
388
+ read_model.py
389
+ artifacts.py
390
+ actions.py
391
+ ```
392
+
393
+ BeeCap adapter отвечает за:
394
+
395
+ - dashboard read-model;
396
+ - runs list;
397
+ - run detail;
398
+ - artifact allowlist;
399
+ - artifact reading;
400
+ - config read-model;
401
+ - config validation callback;
402
+ - bounded action callbacks.
403
+
404
+ BeeUI не должен напрямую знать внутреннюю trading-логику BeeCap.
405
+
406
+ ## Как подключать к BeeAgent
407
+
408
+ BeeAgent integration — будущий scope. Ниже оставлена только минимальная целевая структура, чтобы не создавать впечатление готовой реализации.
409
+
410
+ Целевой integration point:
411
+
412
+ ```text
413
+ src/beeagent_module/interfaces/ui/
414
+ adapter.py
415
+ read_model.py
416
+ artifacts.py
417
+ capabilities.py
418
+ actions.py
419
+ ```
420
+
421
+ BeeAgent adapter отвечает за:
422
+
423
+ - dashboard read-model;
424
+ - modules;
425
+ - runs;
426
+ - artifacts;
427
+ - capabilities;
428
+ - approvals;
429
+ - bounded actions;
430
+ - authority/capability checks.
431
+
432
+ BeeUI не должен получать прямую authority на tools/MCP/runtime actions.
433
+
434
+ ## Режимы работы BeeUI
435
+
436
+ ### `demo`
437
+
438
+ Локальный demo mode.
439
+
440
+ Используется для разработки BeeUI без BeeCap/BeeAgent.
441
+
442
+ ```bash
443
+ ./start.sh web
444
+ ```
445
+
446
+ Вариант с явным host/port:
447
+
448
+ ```bash
449
+ ./start.sh web --host 127.0.0.1 --port 8780
450
+ ```
451
+
452
+ Что показывает:
453
+
454
+ - schema-driven demo pages;
455
+ - schema-driven navigation;
456
+ - schema-driven theme/layout;
457
+ - static/literal и resolver-backed dashboard blocks из `config/schema.yml`;
458
+ - controlled read-only `demo` data source;
459
+ - controlled read-only `static` YAML/JSON data source;
460
+ - empty state для pages без block placements.
461
+
462
+ ### `embedded`
463
+
464
+ Основное направление MVP integration.
465
+
466
+ Продукт импортирует BeeUI и монтирует его в своём web process.
467
+
468
+ Текущий статус после Iteration 11:
469
+
470
+ - generic adapter contract существует;
471
+ - BeeCap fixture/reference adapter существует для contract validation;
472
+ - production BeeCap adapter остаётся ответственностью BeeCap-side;
473
+ - `create_beeui_app(...)` accepts `config_path`, product metadata and adapter;
474
+ - `mount_beeui(...)` mounts BeeUI into parent FastAPI app;
475
+ - adapter is validated and stored in `app.state.beeui_adapter`;
476
+ - product metadata is stored in `app.state.beeui_product`;
477
+ - artifact browser routes уже используют adapter для `list_artifacts()` и `read_artifact()`;
478
+ - `/api/runs/{run_id}/artifacts*` routes доступны при `features.browser_artifact: true`;
479
+ - adapter-backed dashboard/runs rendering остаётся future scope.
480
+
481
+ Embedded example:
482
+
483
+ ```python
484
+ from beeui_module.web.app import create_beeui_app
485
+ from beecap_module.interfaces.ui.adapter import BeeCapUiAdapter
486
+
487
+ app = create_beeui_app(
488
+ product_id="beecap",
489
+ product_title="BeeCap",
490
+ adapter=BeeCapUiAdapter(...),
491
+ config_path="config/beeui.yml",
492
+ )
493
+ ```
494
+
495
+ ### `standalone`
496
+
497
+ Будущий scope.
498
+
499
+ В текущем MVP standalone mode не реализован. Запуск с отдельным config-файлом будет добавлен позже, когда появится HTTP product adapter и standalone deployment contract.
500
+
501
+ ## Основные возможности
502
+
503
+ ### Declarative pages
504
+
505
+ Страницы задаются через config/schema.
506
+
507
+ ```yaml
508
+ blocks:
509
+ latest_run:
510
+ type: metric_card
511
+ title: Latest Run
512
+ value: run_demo_001
513
+ subtitle: Static demo value
514
+
515
+ pages:
516
+ - id: dashboard
517
+ path: /
518
+ title: Dashboard
519
+ subtitle: Demo operator dashboard
520
+ blocks:
521
+ - block: latest_run
522
+ width: 3
523
+ ```
524
+
525
+ Текущие declarative page rules:
526
+
527
+ - `page.id` must be unique;
528
+ - `page.path` must be unique;
529
+ - `navigation[].path` must reference declared page path;
530
+ - reserved paths `/health`, `/static`, `/static/...` are rejected;
531
+ - `blocks` in page config is a list of block placements;
532
+ - each placement references a top-level block id;
533
+ - `width` must be an integer from `1` to `12`;
534
+ - unknown block references are rejected fail-fast.
535
+
536
+ ### Blocks
537
+
538
+ Текущий block contract после Iteration 7 поддерживает literal fields и resolver-backed fields из controlled read-only `demo` / `static` data sources.
539
+
540
+ Top-level `blocks` defines reusable block definitions.
541
+ `pages[].blocks[]` defines where these blocks appear on a page.
542
+
543
+ Сейчас поддерживаются типы блоков:
544
+
545
+ - `metric_card`;
546
+ - `kpi_grid`;
547
+ - `status_card`;
548
+ - `table_card`;
549
+ - `links_card`;
550
+ - `alert_card`;
551
+ - `text_card`;
552
+ - `progress_card`.
553
+
554
+ Пример:
555
+
556
+ ```yaml
557
+ blocks:
558
+ latest_run:
559
+ type: metric_card
560
+ title: Latest Run
561
+ value: run_demo_001
562
+ subtitle: Static demo value
563
+
564
+ runtime_status:
565
+ type: status_card
566
+ title: Runtime
567
+ status: ok
568
+ value: Ready
569
+
570
+ pages:
571
+ - id: dashboard
572
+ path: /
573
+ title: Dashboard
574
+ subtitle: Demo operator dashboard
575
+ blocks:
576
+ - block: latest_run
577
+ width: 3
578
+ - block: runtime_status
579
+ width: 3
580
+ ```
581
+
582
+ Текущие правила:
583
+
584
+ - block ids must be safe identifiers;
585
+ - unknown block types are rejected;
586
+ - unknown block references are rejected;
587
+ - renderer-specific fields are validated fail-fast;
588
+ - text values are rendered through Jinja autoescape;
589
+ - no arbitrary HTML/JS/CSS from config;
590
+ - `links_card.href` accepts internal safe paths only;
591
+ - display values may be literal scalars or resolver-backed values from controlled demo/static sources;
592
+ - missing/empty page placements render an empty state.
593
+
594
+ Реализовано в Iteration 7:
595
+
596
+ - read-only data resolver;
597
+ - selector syntax with dot path and optional `[index]` lookup;
598
+ - `demo` source;
599
+ - `static` YAML/JSON source;
600
+ - stable resolver envelope;
601
+ - degraded block rendering on missing selector data.
602
+
603
+ Пока не реализовано:
604
+
605
+ - production BeeCap/BeeAgent adapters;
606
+ - adapter-backed block data in runtime;
607
+ - charts/maps;
608
+ - artifact/config/action blocks;
609
+ - arbitrary HTML/JS blocks.
610
+
611
+ ### Data sources
612
+
613
+ Iteration 7 поддерживает controlled read-only data sources в `config/schema.yml`.
614
+ Текущие supported source types:
615
+
616
+ - `demo`
617
+ - `static` with `format: yaml|json` and a safe relative `path`
618
+
619
+ Resolver envelope:
620
+
621
+ ```json
622
+ {
623
+ "status": "ok|partial|error",
624
+ "data": {},
625
+ "warnings": [
626
+ {
627
+ "code": "selector_missing",
628
+ "message": "Selector not found: dashboard.latest_run.id"
629
+ }
630
+ ],
631
+ "source": {
632
+ "type": "demo|static|unknown",
633
+ "id": "demo_dashboard"
634
+ }
635
+ }
636
+ ```
637
+
638
+ Текущая block schema остаётся backward-compatible: literal fields продолжают работать, resolver-backed fields опциональны.
639
+ Adapter-backed data sources остаются будущим scope и не входят в текущие runtime source types Iteration 7.
640
+
641
+ Resolver-backed block example:
642
+
643
+ ```yaml
644
+ data_sources:
645
+ demo_dashboard:
646
+ type: demo
647
+
648
+ blocks:
649
+ latest_run:
650
+ type: metric_card
651
+ title: Latest Run
652
+ source: demo_dashboard
653
+ value_selector: dashboard.latest_run.id
654
+ subtitle_selector: dashboard.latest_run.status
655
+ ```
656
+
657
+ Resolver envelope — внутренний block data-resolution contract в Iteration 7.
658
+ Это ещё не public `/api/*` route contract.
659
+ Public BeeUI JSON API запланирован для следующих итераций.
660
+
661
+ ### Product adapters
662
+
663
+ Product adapter contract реализован в Iteration 8 как generic boundary в `src/beeui_module/adapters/`.
664
+
665
+ Scope Iteration 8:
666
+
667
+ - generic `ProductUiAdapter` protocol/base contract;
668
+ - stable adapter envelopes for `ok|partial|error`;
669
+ - stable adapter error classes and error envelope helper;
670
+ - safe id validation helpers;
671
+ - optional write/action methods are disabled by default.
672
+
673
+ Non-goals Iteration 8:
674
+
675
+ - no production BeeCap adapter;
676
+ - no concrete BeeAgent adapter;
677
+ - no direct product filesystem crawling;
678
+ - public route surface не менялся в Iteration 8;
679
+ - no direct execution authority.
680
+
681
+ Iteration 9 добавляет BeeCap fixture/reference adapter support:
682
+
683
+ - `BeeCapFixtureAdapter` validates BeeCap-shaped dashboard/runs/artifact-reference payloads;
684
+ - fixtures live under `tests/fixtures/beecap/`;
685
+ - this adapter is not a production BeeCap integration;
686
+ - real BeeCap adapter must live on the BeeCap side under `src/beecap_module/interfaces/ui/`;
687
+ - Iteration 10 добавила app factory adapter injection и `mount_beeui(...)`;
688
+ - Iteration 11 добавила adapter-backed artifact browser routes;
689
+ - adapter-backed dashboard/runs rendering остаётся future scope.
690
+
691
+ Текущий contract v0 после Iteration 8:
692
+
693
+ ```python
694
+ class ProductUiAdapter:
695
+ # required read-only
696
+ def get_dashboard(self) -> dict: ...
697
+ def list_runs(self) -> dict: ...
698
+ def get_run(self, run_id: str) -> dict: ...
699
+ def list_artifacts(self, run_id: str) -> dict: ...
700
+ def read_artifact(self, run_id: str, artifact_id: str) -> dict: ...
701
+ def get_config_read_model(self) -> dict: ...
702
+
703
+ # optional, unavailable by default
704
+ def validate_config_candidate(self, candidate: dict) -> dict: ...
705
+ def list_actions(self) -> dict: ...
706
+ def preview_action(self, action_id: str, payload: dict) -> dict: ...
707
+ def execute_action(self, action_id: str, payload: dict) -> dict: ...
708
+ ```
709
+
710
+ После Iteration 11 BeeUI вызывает adapter через embedded mount/app factory layer для artifact browser routes.
711
+
712
+ Product adapter решает, что можно читать/делать.
713
+
714
+ ## Artifact browser
715
+
716
+ BeeUI предоставляет generic artifact browser после Iteration 11.
717
+
718
+ Он отображает:
719
+
720
+ - JSON;
721
+ - JSONL;
722
+ - text;
723
+ - metadata;
724
+ - parse warnings;
725
+ - source links;
726
+ - partial/corrupted state.
727
+
728
+ Правила:
729
+
730
+ - только allowlisted artifacts;
731
+ - никакого arbitrary filesystem browsing;
732
+ - path traversal заблокирован;
733
+ - source artifacts не мутируются;
734
+ - secrets redacted;
735
+ - corrupted artifacts не ломают page.
736
+
737
+ Routes:
738
+
739
+ ```text
740
+ GET /runs/{run_id}/artifacts
741
+ GET /runs/{run_id}/artifacts/{artifact_id}
742
+ GET /api/runs/{run_id}/artifacts
743
+ GET /api/runs/{run_id}/artifacts/{artifact_id}
744
+ ```
745
+
746
+ ## Config UI
747
+
748
+ BeeUI должен дать reusable config UI layer, но не владеть config source of truth.
749
+
750
+ Source of truth остаётся в продукте:
751
+
752
+ ```text
753
+ beecap/config/settings.yml
754
+ beeagent/config/settings.yml
755
+ ```
756
+
757
+ BeeUI config UI работает через product adapter.
758
+
759
+ ### Read-model
760
+
761
+ ```text
762
+ GET /config
763
+ GET /api/config/read-model
764
+ ```
765
+
766
+ Показывает:
767
+
768
+ - editable fields;
769
+ - non-editable fields;
770
+ - redacted fields;
771
+ - current values;
772
+ - validation metadata;
773
+ - constraints/options.
774
+
775
+ ### Preview
776
+
777
+ ```text
778
+ POST /api/config/preview
779
+ ```
780
+
781
+ Semantics:
782
+
783
+ - build candidate config in memory;
784
+ - call product validation callback;
785
+ - return diff + validation result;
786
+ - no file writes.
787
+
788
+ ### Apply
789
+
790
+ ```text
791
+ POST /api/config/apply
792
+ ```
793
+
794
+ Semantics:
795
+
796
+ - only allowlisted keys;
797
+ - stale config hash guard;
798
+ - validate candidate through product validation callback;
799
+ - backup current config;
800
+ - write canonical product config;
801
+ - create audit artifact;
802
+ - no secrets in audit;
803
+ - no runtime restart hidden behind apply.
804
+
805
+ Suggested artifacts:
806
+
807
+ ```text
808
+ storage/interfaces/config_revisions/<change_id>/settings.before.yml
809
+ storage/interfaces/config_changes/<change_id>/audit.json
810
+ ```
811
+
812
+ ## Operator actions
813
+
814
+ BeeUI can show bounded operator actions, but action execution belongs to the product.
815
+
816
+ Example actions:
817
+
818
+ - start allowed preset;
819
+ - refresh index;
820
+ - run doctor;
821
+ - create report;
822
+ - open artifact;
823
+ - create draft;
824
+ - approve safe internal action.
825
+
826
+ Forbidden by default:
827
+
828
+ - broker manual order;
829
+ - direct live execution;
830
+ - secret editing;
831
+ - arbitrary shell command;
832
+ - arbitrary config mutation;
833
+ - runtime kill/restart unless product explicitly exposes bounded callback.
834
+
835
+ All action attempts should create audit artifacts:
836
+
837
+ ```text
838
+ storage/interfaces/operator_actions/<action_id>.json
839
+ ```
840
+
841
+ ## Auth and roles
842
+
843
+ BeeUI auth layer запланирован после MVP dashboard integration.
844
+
845
+ Initial roles:
846
+
847
+ | Role | Meaning |
848
+ | ---------- | -------------------------------------------------- |
849
+ | `viewer` | read-only UI access |
850
+ | `operator` | read-only + bounded allowed actions |
851
+ | `admin` | config/admin actions inside allowlisted boundaries |
852
+
853
+ Security rules:
854
+
855
+ - auth disabled only explicitly for local/dev;
856
+ - no default admin password in repo;
857
+ - password hash only;
858
+ - signed session cookies;
859
+ - CSRF protection for POST routes;
860
+ - no secrets in logs;
861
+ - no secrets in HTML/API.
862
+
863
+ ## Theme customization
864
+
865
+ BeeUI theme config:
866
+
867
+ ```yaml
868
+ app:
869
+ theme:
870
+ mode: dark
871
+ primary: blue
872
+ font: Inter
873
+ radius: 2
874
+ density: compact
875
+ ```
876
+
877
+ Поддерживаемая кастомизация:
878
+
879
+ - dark/light;
880
+ - primary color;
881
+ - font family;
882
+ - border radius;
883
+ - density;
884
+ - product title;
885
+ - logo;
886
+ - favicon;
887
+ - compact mode.
888
+
889
+ Forbidden by default:
890
+
891
+ - arbitrary CSS editor;
892
+ - arbitrary JS;
893
+ - unsafe HTML injection;
894
+ - user-uploaded executable assets.
895
+
896
+ ## Технологический стек
897
+
898
+ - **Python 3.14+**
899
+ - **src-layout** — пакет `beeui_module` в `src/`
900
+ - **FastAPI** — web runtime
901
+ - **Jinja2** — templates
902
+ - **Tabler** — dashboard/admin UI foundation
903
+ - **PyYAML** — config/schema files
904
+ - **pytest** — тесты
905
+ - **httpx** — web route tests
906
+ - **uv** — dependency/install/runtime workflow
907
+ - **file-based artifacts** — для audits/examples/demo
908
+ - **future**: optional standalone HTTP adapter
909
+
910
+ ## Управление и запуск
911
+
912
+ Запуск — через `start.sh`.
913
+
914
+ ### Установка
915
+
916
+ После clone:
917
+
918
+ ```bash
919
+ git clone git@github.com:beesyst/beeui.git
920
+ cd beeui
921
+ ./start.sh doctor
922
+ ```
923
+
924
+ `start.sh`:
925
+
926
+ - проверяет наличие `uv`;
927
+ - если `uv` отсутствует — устанавливает его;
928
+ - ставит зависимости из `uv.lock`;
929
+ - запускает `config/start.py`;
930
+ - не должен скрыто менять runtime contracts.
931
+
932
+ ### Команды
933
+
934
+ ```bash
935
+ ./start.sh doctor
936
+ ```
937
+
938
+ Проверяет:
939
+
940
+ - Python version;
941
+ - package import;
942
+ - config files;
943
+ - templates/static availability;
944
+ - basic environment.
945
+
946
+ ```bash
947
+ ./start.sh web
948
+ ```
949
+
950
+ Запускает demo BeeUI web app.
951
+
952
+ ```bash
953
+ ./start.sh web --host 127.0.0.1 --port 8780
954
+ ```
955
+
956
+ Запускает demo web app на конкретном host/port.
957
+
958
+ ```bash
959
+ ./start.sh routes
960
+ ```
961
+
962
+ Показывает registered routes.
963
+
964
+ ```bash
965
+ ./start.sh version
966
+ ```
967
+
968
+ Показывает версию BeeUI.
969
+
970
+ ---
971
+
972
+ ## Локальная разработка
973
+
974
+ ### Установка зависимостей
975
+
976
+ ```bash
977
+ uv sync --frozen --extra dev
978
+ ```
979
+
980
+ ### Тесты
981
+
982
+ ```bash
983
+ uv run pytest -q
984
+ ```
985
+
986
+ ### Запуск demo UI
987
+
988
+ ```bash
989
+ ./start.sh web --host 127.0.0.1 --port 8780
990
+ ```
991
+
992
+ Открыть:
993
+
994
+ ```text
995
+ http://127.0.0.1:8780
996
+ ```
997
+
998
+ ### Без `start.sh`
999
+
1000
+ ```bash
1001
+ uv run --frozen --extra dev python config/start.py doctor
1002
+ uv run --frozen --extra dev python config/start.py web
1003
+ ```
1004
+
1005
+ ## Документация
1006
+
1007
+ Основная документация проекта находится в `docs/`.
1008
+
1009
+ Ключевые разделы:
1010
+
1011
+ - `docs/ROADMAP.md` — этапы и итерации;
1012
+ - `docs/SDLC.md` — lightweight process, checks, PR workflow;
1013
+ - `docs/SECURITY.md` — secure development rules;
1014
+ - `docs/WEB_UI.md` — HTML routes, layout, dashboard behavior;
1015
+
1016
+ ## Целевая структура проекта
1017
+
1018
+ Актуальные ключевые файлы после Iteration 11:
1019
+
1020
+ ```text
1021
+ config/
1022
+ settings.yml
1023
+ schema.yml
1024
+
1025
+ docs/
1026
+ INTEGRATION.md
1027
+
1028
+ examples/
1029
+ beecap_embedded/
1030
+ beeui.yml
1031
+
1032
+ tests/
1033
+ fixtures/
1034
+ beecap/
1035
+
1036
+ src/beeui_module/
1037
+ blocks/
1038
+ __init__.py
1039
+ models.py
1040
+ registry.py
1041
+ renderers.py
1042
+ cli/
1043
+ doctor.py
1044
+ main.py
1045
+ web.py
1046
+ core/
1047
+ paths.py
1048
+ settings.py
1049
+ log.py
1050
+ version.py
1051
+ data/
1052
+ __init__.py
1053
+ models.py
1054
+ resolver.py
1055
+ selectors.py
1056
+ sources.py
1057
+ adapters/
1058
+ __init__.py
1059
+ base.py
1060
+ envelopes.py
1061
+ errors.py
1062
+ ids.py
1063
+ beecap.py
1064
+ artifacts/
1065
+ __init__.py
1066
+ models.py
1067
+ preview.py
1068
+ redaction.py
1069
+ routes.py
1070
+ pages/
1071
+ config.py
1072
+ models.py
1073
+ router.py
1074
+ web/
1075
+ app.py
1076
+ templates/
1077
+ base.html
1078
+ page.html
1079
+ components/
1080
+ alert_card.html
1081
+ footer.html
1082
+ kpi_grid.html
1083
+ links_card.html
1084
+ metric_card.html
1085
+ navbar.html
1086
+ page_header.html
1087
+ progress_card.html
1088
+ sidebar.html
1089
+ status_card.html
1090
+ table_card.html
1091
+ text_card.html
1092
+ empty_state.html
1093
+ artifacts/
1094
+ list.html
1095
+ detail.html
1096
+ static/
1097
+ css/beeui.css
1098
+ js/beeui.js
1099
+ vendor/
1100
+ tabler/
1101
+ css/tabler-compatible.min.css
1102
+ js/tabler-compatible.min.js
1103
+ ```
1104
+
1105
+ Остальная структура ниже — целевая для следующих итераций.
1106
+
1107
+ ```text
1108
+ beeui/
1109
+ ├── config/
1110
+ │ ├── settings.yml
1111
+ │ └── start.py
1112
+
1113
+ ├── docs/
1114
+ │ ├── API_CONTRACT.md
1115
+ │ ├── COMPONENTS.md
1116
+ │ ├── INTEGRATION.md
1117
+ │ ├── ROADMAP.md
1118
+ │ ├── SDLC.md
1119
+ │ ├── SECURITY.md
1120
+ │ ├── THEME.md
1121
+ │ └── WEB_UI.md
1122
+
1123
+ ├── examples/
1124
+ │ ├── demo_static/
1125
+ │ ├── beecap_embedded/
1126
+ │ └── beeagent_embedded/
1127
+
1128
+ ├── logs/
1129
+ │ └── app.log
1130
+
1131
+ ├── src/
1132
+ │ └── beeui_module/
1133
+ │ ├── __init__.py
1134
+ │ ├── config.py
1135
+ │ ├── errors.py
1136
+ │ ├── server.py
1137
+ │ ├── settings.py
1138
+ │ │
1139
+ │ ├── api/
1140
+ │ │ ├── envelopes.py
1141
+ │ │ └── routes.py
1142
+ │ │
1143
+ │ ├── artifacts/
1144
+ │ │ ├── browser.py
1145
+ │ │ ├── models.py
1146
+ │ │ ├── readers.py
1147
+ │ │ └── safe_paths.py
1148
+ │ │
1149
+ │ ├── auth/
1150
+ │ │ ├── models.py
1151
+ │ │ ├── password.py
1152
+ │ │ ├── permissions.py
1153
+ │ │ ├── routes.py
1154
+ │ │ ├── service.py
1155
+ │ │ └── sessions.py
1156
+ │ │
1157
+ │ ├── adapters/
1158
+ │ │ ├── base.py
1159
+ │ │ ├── filesystem.py
1160
+ │ │ ├── http.py
1161
+ │ │ ├── product.py
1162
+ │ │ ├── beecap.py
1163
+ │ │ └── beeagent.py
1164
+ │ │
1165
+ │ ├── blocks/
1166
+ │ │ ├── models.py
1167
+ │ │ ├── registry.py
1168
+ │ │ ├── renderers.py
1169
+ │ │ └── types/
1170
+ │ │ ├── artifact_table.py
1171
+ │ │ ├── chart_card.py
1172
+ │ │ ├── json_viewer.py
1173
+ │ │ ├── kpi_grid.py
1174
+ │ │ ├── links_card.py
1175
+ │ │ ├── metric_card.py
1176
+ │ │ ├── status_card.py
1177
+ │ │ └── table_card.py
1178
+ │ │
1179
+ │ ├── cli/
1180
+ │ │ ├── doctor.py
1181
+ │ │ ├── main.py
1182
+ │ │ └── web.py
1183
+ │ │
1184
+ │ ├── config_ui/
1185
+ │ │ ├── apply.py
1186
+ │ │ ├── audit.py
1187
+ │ │ ├── preview.py
1188
+ │ │ ├── read_model.py
1189
+ │ │ └── routes.py
1190
+ │ │
1191
+ │ ├── core/
1192
+ │ │ ├── ids.py
1193
+ │ │ ├── json.py
1194
+ │ │ ├── logging.py
1195
+ │ │ ├── paths.py
1196
+ │ │ └── security.py
1197
+ │ │
1198
+ │ ├── data/
1199
+ │ │ ├── envelopes.py
1200
+ │ │ ├── resolver.py
1201
+ │ │ ├── selectors.py
1202
+ │ │ └── sources.py
1203
+ │ │
1204
+ │ ├── pages/
1205
+ │ │ ├── models.py
1206
+ │ │ ├── registry.py
1207
+ │ │ ├── renderer.py
1208
+ │ │ └── router.py
1209
+ │ │
1210
+ │ ├── web/
1211
+ │ │ ├── __init__.py
1212
+ │ │ ├── app.py
1213
+ │ │ ├── templates/
1214
+ │ │ │ ├── base.html
1215
+ │ │ │ └── page.html
1216
+ │ │ └── static/
1217
+ │ │ ├── css/
1218
+ │ │ │ └── beeui.css
1219
+ │ │ └── js/
1220
+ │ │ └── beeui.js
1221
+ │ │
1222
+ │ └── theme/
1223
+ │ ├── css.py
1224
+ │ ├── models.py
1225
+ │ └── service.py
1226
+
1227
+ ├── tests/
1228
+ │ ├── test_adapters.py
1229
+ │ ├── test_app.py
1230
+ │ ├── test_artifacts.py
1231
+ │ ├── test_blocks.py
1232
+ │ ├── test_config.py
1233
+ │ ├── test_pages.py
1234
+ │ ├── test_security.py
1235
+ │ └── test_smoke.py
1236
+
1237
+ ├── pyproject.toml
1238
+ ├── README.ru.md
1239
+ ├── start.sh
1240
+ └── uv.lock
1241
+ ```
1242
+
1243
+ ## Архитектура
1244
+
1245
+ ### 1. App/Web layer
1246
+
1247
+ Отвечает за:
1248
+
1249
+ - FastAPI app factory;
1250
+ - templates/static;
1251
+ - routes;
1252
+ - global layout;
1253
+ - API routes;
1254
+ - error pages.
1255
+
1256
+ Ключевые модули:
1257
+
1258
+ ```text
1259
+ src/beeui_module/web/app.py
1260
+ src/beeui_module/web/templates/
1261
+ src/beeui_module/web/static/
1262
+ ```
1263
+
1264
+ Planned after Iteration 2:
1265
+
1266
+ ```text
1267
+ src/beeui_module/server.py
1268
+ src/beeui_module/pages/
1269
+ ```
1270
+
1271
+ ### 2. Adapter layer
1272
+
1273
+ Отвечает за подключение к продуктам.
1274
+
1275
+ ```text
1276
+ src/beeui_module/adapters/
1277
+ ```
1278
+
1279
+ Типы adapters:
1280
+
1281
+ - `ProductUiAdapter` — base contract;
1282
+ - `BeeCapUiAdapter` — BeeCap-specific read-model adapter;
1283
+ - `BeeAgentUiAdapter` — BeeAgent-specific read-model adapter;
1284
+ - `HttpProductAdapter` — будущий standalone mode;
1285
+ - `FilesystemAdapter` — demo/local artifact reading.
1286
+
1287
+ ### 3. Data resolver layer
1288
+
1289
+ Отвечает за:
1290
+
1291
+ - source lookup;
1292
+ - selector resolution;
1293
+ - partial data;
1294
+ - warnings/errors;
1295
+ - normalized envelopes.
1296
+
1297
+ ```text
1298
+ src/beeui_module/data/
1299
+ ```
1300
+
1301
+ ### 4. Blocks layer
1302
+
1303
+ Отвечает за reusable UI blocks.
1304
+
1305
+ ```text
1306
+ src/beeui_module/blocks/
1307
+ src/beeui_module/web/templates/components/
1308
+ ```
1309
+
1310
+ ### 5. Artifact layer
1311
+
1312
+ Отвечает за safe artifact navigation.
1313
+
1314
+ ```text
1315
+ src/beeui_module/artifacts/
1316
+ ```
1317
+
1318
+ Security responsibilities:
1319
+
1320
+ - artifact allowlist;
1321
+ - safe IDs;
1322
+ - path traversal guard;
1323
+ - JSON/JSONL tolerant parsing;
1324
+ - redaction;
1325
+ - no mutation.
1326
+
1327
+ ### 6. Config UI layer
1328
+
1329
+ Отвечает за:
1330
+
1331
+ - config read-model;
1332
+ - preview;
1333
+ - apply;
1334
+ - audit;
1335
+ - backup.
1336
+
1337
+ ```text
1338
+ src/beeui_module/config_ui/
1339
+ ```
1340
+
1341
+ Важно:
1342
+
1343
+ - product config remains source of truth;
1344
+ - product validation callback is mandatory for apply;
1345
+ - BeeUI does not invent config semantics.
1346
+
1347
+ ### 7. Auth layer
1348
+
1349
+ Planned layer.
1350
+
1351
+ ```text
1352
+ src/beeui_module/auth/
1353
+ ```
1354
+
1355
+ Отвечает за:
1356
+
1357
+ - users;
1358
+ - sessions;
1359
+ - roles;
1360
+ - permissions;
1361
+ - CSRF;
1362
+ - route protection.
1363
+
1364
+ ## JSON API contract
1365
+
1366
+ BeeUI API должен использовать единый envelope.
1367
+ Resolver envelope is an internal block data-resolution contract in Iteration 7.
1368
+ It is not yet a public `/api/*` route contract.
1369
+ Public BeeUI JSON API запланирован для следующих итераций.
1370
+
1371
+ ### Success
1372
+
1373
+ ```json
1374
+ {
1375
+ "ok": true,
1376
+ "status": "ok",
1377
+ "data": {},
1378
+ "warnings": [],
1379
+ "meta": {
1380
+ "source": "adapter",
1381
+ "product": "beecap"
1382
+ }
1383
+ }
1384
+ ```
1385
+
1386
+ ### Partial
1387
+
1388
+ ```json
1389
+ {
1390
+ "ok": true,
1391
+ "status": "partial",
1392
+ "data": {},
1393
+ "warnings": [
1394
+ {
1395
+ "code": "artifact_missing",
1396
+ "message": "health.json is missing"
1397
+ }
1398
+ ],
1399
+ "meta": {
1400
+ "source": "adapter",
1401
+ "product": "beecap"
1402
+ }
1403
+ }
1404
+ ```
1405
+
1406
+ ### Error
1407
+
1408
+ ```json
1409
+ {
1410
+ "ok": false,
1411
+ "status": "error",
1412
+ "error": {
1413
+ "code": "invalid_run_id",
1414
+ "message": "Invalid run_id"
1415
+ },
1416
+ "warnings": [],
1417
+ "meta": {
1418
+ "source": "beeui"
1419
+ }
1420
+ }
1421
+ ```
1422
+
1423
+ ## Planned routes
1424
+
1425
+ ### HTML
1426
+
1427
+ ```text
1428
+ GET /
1429
+ GET /runs
1430
+ GET /runs/{run_id}
1431
+ GET /runs/{run_id}/artifacts
1432
+ GET /config
1433
+ GET /admin
1434
+ GET /login
1435
+ GET /logout
1436
+ ```
1437
+
1438
+ ### API
1439
+
1440
+ ```text
1441
+ GET /api/dashboard
1442
+ GET /api/runs
1443
+ GET /api/runs/{run_id}
1444
+ GET /api/runs/{run_id}/artifacts
1445
+ GET /api/runs/{run_id}/artifacts/{artifact_id}
1446
+ GET /api/config/read-model
1447
+ POST /api/config/preview
1448
+ POST /api/config/apply
1449
+ GET /api/actions
1450
+ POST /api/actions/{action_id}
1451
+ ```
1452
+
1453
+ Routes can be mounted under prefix:
1454
+
1455
+ ```text
1456
+ /ui
1457
+ /console
1458
+ /admin
1459
+ ```
1460
+
1461
+ depending on product integration.
1462
+
1463
+ ## Безопасность
1464
+
1465
+ BeeUI находится на trust boundary, потому что отображает:
1466
+
1467
+ - configs;
1468
+ - artifacts;
1469
+ - operator actions;
1470
+ - diagnostics;
1471
+ - product state;
1472
+ - potential admin controls.
1473
+
1474
+ Правила безопасности:
1475
+
1476
+ - read-only by default;
1477
+ - all IDs are untrusted input;
1478
+ - path traversal guard everywhere;
1479
+ - HTML autoescape enabled;
1480
+ - no arbitrary HTML/JS blocks;
1481
+ - artifact access allowlisted;
1482
+ - config write allowlisted;
1483
+ - action execution product-owned;
1484
+ - secrets redacted in HTML/API/logs/audits;
1485
+ - POST routes protected by CSRF when auth enabled;
1486
+ - no direct broker/runtime authority;
1487
+ - no hidden fallback from denied action to allowed action;
1488
+ - no automatic runtime restart after config apply.
1489
+
1490
+ Особо запрещено:
1491
+
1492
+ - отдавать `.env`;
1493
+ - отдавать raw secret values;
1494
+ - читать arbitrary path из query param;
1495
+ - делать direct shell commands из UI;
1496
+ - делать live broker calls из BeeUI;
1497
+ - писать runtime artifacts без product-owned action callback.
1498
+
1499
+ ## MVP roadmap summary
1500
+
1501
+ Критический путь к MVP:
1502
+
1503
+ ```text
1504
+ Iteration 0 — Project skeleton and startup contract
1505
+ Iteration 1 — Tabler web shell v0
1506
+ Iteration 2 — Declarative pages and navigation v0
1507
+ Iteration 3 — Local Tabler vendor/assets and layout parity v1
1508
+ Iteration 4 — Theme, layout and navigation schema v1
1509
+ Iteration 5 — Block registry and static dashboard blocks v1
1510
+ Iteration 7 — Data sources and resolver v0
1511
+ Iteration 8 — Product adapter contract v0
1512
+ Iteration 9 — BeeCap adapter MVP
1513
+ Iteration 10 — Embedded mount API v0
1514
+ Iteration 11 — Generic artifact browser v1
1515
+ Iteration 12 — BeeCap dashboard parity MVP
1516
+ Iteration 13 — Runs list and run overview MVP
1517
+ ```
1518
+
1519
+ MVP считается достигнутым, если:
1520
+
1521
+ - `beeui` запускается отдельно как demo;
1522
+ - `beeui` подключается к `beecap`;
1523
+ - BeeCap dashboard рендерится через BeeUI;
1524
+ - BeeCap current custom templates больше не расширяются вручную;
1525
+ - run list / run detail / artifact links работают;
1526
+ - UI read-only по умолчанию;
1527
+ - tests green.
1528
+
1529
+ ## Что должно остаться в BeeCap/BeeAgent после внедрения BeeUI
1530
+
1531
+ Bee-продукты сохраняют:
1532
+
1533
+ - core runtime;
1534
+ - config validation;
1535
+ - product artifacts;
1536
+ - product read-model;
1537
+ - domain-specific summaries;
1538
+ - bounded actions;
1539
+ - authority/security checks.
1540
+
1541
+ Bee-продукты больше не должны дублировать:
1542
+
1543
+ - base web shell;
1544
+ - Tabler layout;
1545
+ - sidebar/navbar;
1546
+ - reusable KPI cards;
1547
+ - generic tables;
1548
+ - generic artifact browser;
1549
+ - theme layer;
1550
+ - common config UI;
1551
+ - common admin/support pages.
1552
+
1553
+ ## Диагностика и тесты
1554
+
1555
+ ### Диагностика
1556
+
1557
+ | Команда | Что делает |
1558
+ | -------------------- | ----------------------------------------------------------- |
1559
+ | `./start.sh doctor` | Проверка окружения, структуры, imports, config availability |
1560
+ | `./start.sh web` | Запуск demo BeeUI web app |
1561
+ | `./start.sh routes` | Показ registered routes |
1562
+ | `./start.sh version` | Показ версии BeeUI |
1563
+
1564
+ ### Тесты
1565
+
1566
+ ```bash
1567
+ uv run pytest -q
1568
+ ```
1569
+
1570
+ ### Web smoke
1571
+
1572
+ ```bash
1573
+ ./start.sh web --host 127.0.0.1 --port 8780
1574
+ ```
1575
+
1576
+ Проверить:
1577
+
1578
+ ```text
1579
+ http://127.0.0.1:8780/
1580
+ http://127.0.0.1:8780/health
1581
+ ```
1582
+
1583
+ ### Security smoke
1584
+
1585
+ Проверить:
1586
+
1587
+ - no secrets in HTML;
1588
+ - no secrets in API;
1589
+ - invalid run_id rejected;
1590
+ - path traversal rejected;
1591
+ - POST routes do not work without explicit implementation;
1592
+ - static files limited to BeeUI static directory.
1593
+
1594
+ ## Deployment
1595
+
1596
+ ### MVP deployment
1597
+
1598
+ Embedded per product.
1599
+
1600
+ ```text
1601
+ container: beecap
1602
+ includes beeui dependency
1603
+ exposes beecap web
1604
+
1605
+ container: beeagent
1606
+ includes beeui dependency
1607
+ exposes beeagent web
1608
+ ```
1609
+
1610
+ Плюсы:
1611
+
1612
+ - проще;
1613
+ - меньше сетевых связей;
1614
+ - быстрее MVP;
1615
+ - меньше auth/CORS проблем.
1616
+
1617
+ ### Будущий deployment
1618
+
1619
+ Standalone BeeUI.
1620
+
1621
+ ```text
1622
+ container: beeui
1623
+ container: beecap-api
1624
+ container: beeagent-api
1625
+ ```
1626
+
1627
+ Использовать только после стабилизации:
1628
+
1629
+ - BeeUI API contracts;
1630
+ - product APIs;
1631
+ - auth/session model;
1632
+ - deployment model.
1633
+
1634
+ ## Важно
1635
+
1636
+ BeeUI — это не просто UI kit.
1637
+
1638
+ Правильное определение:
1639
+
1640
+ ```text
1641
+ BeeUI is a reusable UI/runtime framework for Bee products.
1642
+ ```
1643
+
1644
+ Он должен развиваться от простого embedded UI package к platform layer:
1645
+
1646
+ 1. server-rendered operator console;
1647
+ 2. reusable dashboard blocks;
1648
+ 3. artifact/config/admin views;
1649
+ 4. stable JSON API;
1650
+ 5. auth/RBAC;
1651
+ 6. bounded operator controls;
1652
+ 7. будущий no-code dashboard builder;
1653
+ 8. будущий standalone frontend backend.
1654
+
1655
+ Неправильное направление:
1656
+
1657
+ ```text
1658
+ Сразу делать no-code Retool/Webflow clone.
1659
+ ```
1660
+
1661
+ Это приведёт к месячной разработке без MVP.
1662
+
1663
+ Правильное направление:
1664
+
1665
+ ```text
1666
+ Declarative schema first.
1667
+ Visual builder later.
1668
+ ```
1669
+
1670
+ ## Текущий статус
1671
+
1672
+ Проект создан как отдельная repo:
1673
+
1674
+ ```text
1675
+ ~/Projects/beeui
1676
+ ```
1677
+
1678
+ Текущий статус:
1679
+
1680
+ ```text
1681
+ Iteration 11 — Generic artifact browser v1 — DONE
1682
+ ```
1683
+
1684
+ Работает:
1685
+
1686
+ ```bash
1687
+ ./start.sh doctor
1688
+ ./start.sh routes
1689
+ uv run pytest -q
1690
+ ./start.sh web --host 127.0.0.1 --port 8780
1691
+ ```
1692
+
1693
+ - `/` рендерит literal и resolver-backed dashboard blocks from schema;
1694
+ - `/runs` рендерит empty state для страницы без block placements;
1695
+ - `/components*` рендерит internal read-only catalog of controlled primitives;
1696
+ - resolver-backed blocks читают значения из controlled read-only `demo` / `static` sources;
1697
+ - missing selector data рендерит degraded/error block state вместо падения страницы;
1698
+ - generic `ProductUiAdapter` contract доступен в `src/beeui_module/adapters/`;
1699
+ - optional adapter write/action methods недоступны по умолчанию;
1700
+ - `BeeCapFixtureAdapter` валидирует BeeCap-shaped fixture payloads;
1701
+ - BeeCap-like fixtures покрывают dashboard, runs, artifact references, partial и corrupted artifact states;
1702
+ - integration boundary задокументирован в `docs/INTEGRATION.md`;
1703
+ - `create_beeui_app(...)` accepts `config_path`, product metadata and adapter;
1704
+ - `mount_beeui(...)` mounts BeeUI into parent FastAPI app;
1705
+ - adapter is validated and stored in `app.state.beeui_adapter`;
1706
+ - product metadata is stored in `app.state.beeui_product`;
1707
+ - artifact browser HTML/API routes работают через adapter;
1708
+ - `/api/runs/{run_id}/artifacts*` routes доступны при `features.browser_artifact: true`;
1709
+ - adapter-backed dashboard/runs rendering остаётся future scope.