lockbot 2.15.1__tar.gz → 2.15.2__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.
- {lockbot-2.15.1/python/lockbot.egg-info → lockbot-2.15.2}/PKG-INFO +1 -1
- {lockbot-2.15.1 → lockbot-2.15.2}/pyproject.toml +1 -1
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/agent_skill/SKILL.md +5 -5
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/auth/dependencies.py +3 -2
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/bot_audit/router.py +21 -2
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/bots/router.py +46 -3
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/main.py +3 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/op_skill/SKILL.md +10 -7
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_api/activity.py +15 -5
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_api/commands.py +6 -4
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_api/discovery.py +5 -1
- lockbot-2.15.2/python/lockbot/backend/app/resource_api/notification_queue.py +302 -0
- lockbot-2.15.2/python/lockbot/backend/app/resource_api/notifications.py +158 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_api/operator.py +3 -2
- lockbot-2.15.2/python/lockbot/backend/app/resource_api/privacy.py +149 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_api/usage.py +4 -23
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/i18n/en.py +4 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/i18n/zh.py +1 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/message_adapter.py +7 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/platforms/infoflow.py +4 -0
- {lockbot-2.15.1 → lockbot-2.15.2/python/lockbot.egg-info}/PKG-INFO +1 -1
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot.egg-info/SOURCES.txt +2 -0
- lockbot-2.15.1/python/lockbot/backend/app/resource_api/notifications.py +0 -124
- {lockbot-2.15.1 → lockbot-2.15.2}/LICENSE +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/MANIFEST.in +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/README.md +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/__init__.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/__init__.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/__init__.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/admin/__init__.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/admin/router.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/audit/__init__.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/audit/models.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/audit/router.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/audit/service.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/auth/__init__.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/auth/models.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/auth/router.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/auth/schemas.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/backup/__init__.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/backup/router.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/backup/scheduler.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/backup/service.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/bot_audit/__init__.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/bot_audit/models.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/bot_audit/service.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/bots/__init__.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/bots/datasource.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/bots/encryption.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/bots/manager.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/bots/metrics_access.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/bots/models.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/bots/schemas.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/bots/webhook_handler.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/broadcast/__init__.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/broadcast/models.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/broadcast/router.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/broadcast/service.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/config.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/database.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/deployment.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/logs/__init__.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/managed_paths.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/rate_limit.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_api/__init__.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_api/errors.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_api/event_log.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_api/ingress.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_api/observability.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_api/op_skill.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_api/resources.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_api/rules.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_api/skill.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_api/snapshot.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_api/sources.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_api/traffic.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_api/usage_cleanup.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_api/versioning.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_api/view_links.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_api/views.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_auth/__init__.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_auth/authority.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_auth/credentials.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_auth/dependencies.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_auth/http_errors.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_auth/models.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_auth/pending.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_auth/router.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/resource_auth/service.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/service_traffic.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/settings/__init__.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/settings/models.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/settings/router.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/sqlite_paths.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/state_migration.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/state_ownership.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/backend/app/static.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/__init__.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/base_bot.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/bot_instance.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/command_context.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/config.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/device_bot.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/device_usage_alert.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/device_usage_utils.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/handler.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/i18n/__init__.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/io.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/msg_utils.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/node_bot.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/platforms/__init__.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/platforms/registry.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/queue_bot.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/queue_device_bot.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/request.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/resource_policy.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/scheduler.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/core/utils.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/metrics/__init__.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/metrics/exporter.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot/metrics/gateway.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot.egg-info/dependency_links.txt +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot.egg-info/requires.txt +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/python/lockbot.egg-info/top_level.txt +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/setup.cfg +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/tools/create_super_admin.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/tools/gen_keys.py +0 -0
- {lockbot-2.15.1 → lockbot-2.15.2}/tools/reset_super_admin_password.py +0 -0
|
@@ -480,7 +480,7 @@ the lease, optionally call `PUT /api/bots/{bot_id}/usage-declarations/node1`:
|
|
|
480
480
|
{"purpose":"Develop feature X","agent_label":"dev-agent","ttl_seconds":3600}
|
|
481
481
|
```
|
|
482
482
|
|
|
483
|
-
Other users see only the preset `task_category` / `public_task`; private notes and Agent names remain
|
|
483
|
+
Other users see only the preset `task_category` / `public_task`; private notes and Agent names remain same-verified-actor/super-administrator scoped.
|
|
484
484
|
Registrations are scoped to user authorization + resource, not individual Agent processes.
|
|
485
485
|
On DEVICE, the current registration covers the node resource; different cards on the same
|
|
486
486
|
node do **not** have independent task registrations. Do not claim that distinction exists.
|
|
@@ -597,14 +597,14 @@ resource commands execute. Select `other` when no category fits; do not ask the
|
|
|
597
597
|
operation. Choose the category that best reflects the actual work, without inventing a task.
|
|
598
598
|
|
|
599
599
|
`purpose` is an optional **private note** (up to 512 characters); `agent_label` is an optional
|
|
600
|
-
private Agent name (up to 64 characters). Only the same verified user
|
|
601
|
-
|
|
600
|
+
private Agent name (up to 64 characters). Only the same verified user and super administrators may read these details. Bot ownership,
|
|
601
|
+
ordinary management access and a bot OP key do not grant private-task read permission. Other users' Agents, shared resource pages
|
|
602
602
|
and group notifications receive the preset category, never these fields or authorization
|
|
603
603
|
labels. Agents sharing the same user's key share this privacy scope; they are not separate
|
|
604
604
|
private identities. A category still reveals the broad kind of work, so omit it if the user
|
|
605
605
|
wants no public task information at all. Do not put secrets, credentials, personal data,
|
|
606
|
-
private URLs, exact experiments or full prompts in notes: administrators and
|
|
607
|
-
|
|
606
|
+
private URLs, exact experiments or full prompts in notes: super administrators and host
|
|
607
|
+
operators with filesystem access can retain them. Prefer a short useful note and keep sensitive details locally.
|
|
608
608
|
|
|
609
609
|
Example on a server advertising this policy:
|
|
610
610
|
|
|
@@ -12,6 +12,7 @@ from datetime import datetime, timedelta, timezone
|
|
|
12
12
|
import jwt
|
|
13
13
|
from fastapi import Depends, HTTPException, status
|
|
14
14
|
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
|
|
15
|
+
from sqlalchemy import select
|
|
15
16
|
from sqlalchemy.orm import Session
|
|
16
17
|
|
|
17
18
|
from lockbot.backend.app.auth.models import User
|
|
@@ -65,9 +66,9 @@ def require_admin(user: User = Depends(get_current_user)) -> User:
|
|
|
65
66
|
return user
|
|
66
67
|
|
|
67
68
|
|
|
68
|
-
def require_super_admin(user: User = Depends(get_current_user)) -> User:
|
|
69
|
+
def require_super_admin(user: User = Depends(get_current_user), db: Session = Depends(get_db)) -> User:
|
|
69
70
|
"""Require super_admin only."""
|
|
70
|
-
if
|
|
71
|
+
if db.execute(select(User.role).where(User.id == user.id)).scalar_one_or_none() != "super_admin":
|
|
71
72
|
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="Super admin required")
|
|
72
73
|
return user
|
|
73
74
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Owner-scoped, paginated authorization history."""
|
|
2
2
|
|
|
3
|
-
from fastapi import APIRouter, Depends, Query
|
|
3
|
+
from fastapi import APIRouter, Depends, Query, Response
|
|
4
4
|
from sqlalchemy.orm import Session
|
|
5
5
|
|
|
6
6
|
from lockbot.backend.app.audit.router import AuditLogsPage, _to_out
|
|
@@ -9,6 +9,7 @@ from lockbot.backend.app.auth.models import User
|
|
|
9
9
|
from lockbot.backend.app.bot_audit.models import BotAuditLog
|
|
10
10
|
from lockbot.backend.app.bots.router import _get_user_bot
|
|
11
11
|
from lockbot.backend.app.database import get_db
|
|
12
|
+
from lockbot.backend.app.resource_api.privacy import audit_private_read, can_read_private_tasks
|
|
12
13
|
|
|
13
14
|
router = APIRouter(tags=["bots"])
|
|
14
15
|
|
|
@@ -16,11 +17,13 @@ router = APIRouter(tags=["bots"])
|
|
|
16
17
|
@router.get("/api/bots/{bot_id}/audit-logs", response_model=AuditLogsPage)
|
|
17
18
|
def bot_audit_logs(
|
|
18
19
|
bot_id: int,
|
|
20
|
+
response: Response,
|
|
19
21
|
page: int = Query(1, ge=1),
|
|
20
22
|
limit: int = Query(20, ge=1, le=100),
|
|
21
23
|
user: User = Depends(get_current_user),
|
|
22
24
|
db: Session = Depends(get_db),
|
|
23
25
|
):
|
|
26
|
+
response.headers["Cache-Control"] = "no-store"
|
|
24
27
|
_get_user_bot(bot_id, user, db)
|
|
25
28
|
query = db.query(BotAuditLog).filter(BotAuditLog.target_id == bot_id, BotAuditLog.target_type == "bot")
|
|
26
29
|
rows = (
|
|
@@ -29,4 +32,20 @@ def bot_audit_logs(
|
|
|
29
32
|
.limit(limit)
|
|
30
33
|
.all()
|
|
31
34
|
)
|
|
32
|
-
|
|
35
|
+
private = can_read_private_tasks(db, user)
|
|
36
|
+
items = [_to_out(row) for row in rows]
|
|
37
|
+
if private and items:
|
|
38
|
+
audit_private_read(db, user, bot_id=bot_id, surface="management.authorization_audit")
|
|
39
|
+
if not private:
|
|
40
|
+
for item in items:
|
|
41
|
+
detail = item.detail
|
|
42
|
+
item.detail = (
|
|
43
|
+
{
|
|
44
|
+
key: detail[key]
|
|
45
|
+
for key in ("source", "platform", "external_user_id")
|
|
46
|
+
if isinstance(detail.get(key), str)
|
|
47
|
+
}
|
|
48
|
+
if isinstance(detail, dict)
|
|
49
|
+
else None
|
|
50
|
+
)
|
|
51
|
+
return AuditLogsPage(total=query.count(), items=items)
|
|
@@ -45,6 +45,12 @@ from lockbot.backend.app.database import get_db
|
|
|
45
45
|
from lockbot.backend.app.managed_paths import get_managed_paths, sanitize_managed_overrides
|
|
46
46
|
from lockbot.backend.app.rate_limit import limiter
|
|
47
47
|
from lockbot.backend.app.resource_api import errors as api_errors
|
|
48
|
+
from lockbot.backend.app.resource_api.privacy import (
|
|
49
|
+
audit_private_read,
|
|
50
|
+
can_read_private_tasks,
|
|
51
|
+
public_log_entry,
|
|
52
|
+
visible_declarations,
|
|
53
|
+
)
|
|
48
54
|
from lockbot.backend.app.resource_api.sources import SOURCE_CHAT, SOURCE_SERVICE_KEY
|
|
49
55
|
from lockbot.backend.app.resource_auth.authority import authority_guard
|
|
50
56
|
from lockbot.backend.app.state_migration import assert_bot_state_ready
|
|
@@ -699,6 +705,10 @@ def update_bot(
|
|
|
699
705
|
)
|
|
700
706
|
db.commit()
|
|
701
707
|
db.refresh(bot)
|
|
708
|
+
if changes.get("resource_api_notify_enabled", {}).get("to") is False:
|
|
709
|
+
from lockbot.backend.app.resource_api.notifications import notification_budget
|
|
710
|
+
|
|
711
|
+
notification_budget.cancel(bot_id)
|
|
702
712
|
return bot
|
|
703
713
|
|
|
704
714
|
|
|
@@ -1101,12 +1111,14 @@ def _get_bot_data_dir(bot: Bot) -> str:
|
|
|
1101
1111
|
@router.get("/{bot_id}/state")
|
|
1102
1112
|
def get_bot_state(
|
|
1103
1113
|
bot_id: int,
|
|
1114
|
+
response: Response,
|
|
1104
1115
|
include_usage: bool = False,
|
|
1105
1116
|
user: User = Depends(get_current_user),
|
|
1106
1117
|
db: Session = Depends(get_db),
|
|
1107
1118
|
):
|
|
1108
1119
|
import os
|
|
1109
1120
|
|
|
1121
|
+
response.headers["Cache-Control"] = "no-store"
|
|
1110
1122
|
bot = _get_user_bot(bot_id, user, db)
|
|
1111
1123
|
|
|
1112
1124
|
def view(state, usage=None):
|
|
@@ -1126,7 +1138,13 @@ def get_bot_state(
|
|
|
1126
1138
|
if include_usage:
|
|
1127
1139
|
from lockbot.backend.app.resource_api.usage import active_declarations, declarations_for_state
|
|
1128
1140
|
|
|
1129
|
-
|
|
1141
|
+
private = can_read_private_tasks(db, user)
|
|
1142
|
+
usage = visible_declarations(
|
|
1143
|
+
declarations_for_state(active_declarations(db, bot, datetime.utcnow()), snapshot, captured_at),
|
|
1144
|
+
private=private,
|
|
1145
|
+
)
|
|
1146
|
+
if usage and private:
|
|
1147
|
+
audit_private_read(db, user, bot_id=bot_id, surface="management.state")
|
|
1130
1148
|
return view(snapshot, usage)
|
|
1131
1149
|
except BotNotRunning:
|
|
1132
1150
|
pass
|
|
@@ -1512,6 +1530,7 @@ def update_bot_state(
|
|
|
1512
1530
|
@router.get("/{bot_id}/logs")
|
|
1513
1531
|
def get_bot_logs(
|
|
1514
1532
|
bot_id: int,
|
|
1533
|
+
response: Response,
|
|
1515
1534
|
page: int = 1,
|
|
1516
1535
|
limit: int = 50,
|
|
1517
1536
|
level: str | None = None,
|
|
@@ -1520,6 +1539,7 @@ def get_bot_logs(
|
|
|
1520
1539
|
user: User = Depends(get_current_user),
|
|
1521
1540
|
db: Session = Depends(get_db),
|
|
1522
1541
|
):
|
|
1542
|
+
response.headers["Cache-Control"] = "no-store"
|
|
1523
1543
|
_get_user_bot(bot_id, user, db)
|
|
1524
1544
|
|
|
1525
1545
|
log_path = _get_log_file(bot_id)
|
|
@@ -1534,7 +1554,25 @@ def get_bot_logs(
|
|
|
1534
1554
|
line = line.strip()
|
|
1535
1555
|
if line:
|
|
1536
1556
|
with contextlib.suppress(json.JSONDecodeError):
|
|
1537
|
-
|
|
1557
|
+
entry = json.loads(line)
|
|
1558
|
+
if not isinstance(entry, dict):
|
|
1559
|
+
continue
|
|
1560
|
+
# Normalize metadata before filtering/sorting. Historical JSONL
|
|
1561
|
+
# may contain null or nested values; never stringify them into
|
|
1562
|
+
# public metadata or allow a malformed row to break log reads.
|
|
1563
|
+
entry = dict(entry)
|
|
1564
|
+
level_value = entry.get("level")
|
|
1565
|
+
level_value = level_value.upper() if isinstance(level_value, str) else "UNKNOWN"
|
|
1566
|
+
entry["level"] = (
|
|
1567
|
+
level_value
|
|
1568
|
+
if level_value in ("DEBUG", "INFO", "WARN", "WARNING", "ERROR", "CRITICAL")
|
|
1569
|
+
else "UNKNOWN"
|
|
1570
|
+
)
|
|
1571
|
+
if entry.get("category") not in ("command", "system"):
|
|
1572
|
+
entry["category"] = "system"
|
|
1573
|
+
if not isinstance(entry.get("created_at"), str):
|
|
1574
|
+
entry["created_at"] = ""
|
|
1575
|
+
entries.append(entry)
|
|
1538
1576
|
except OSError:
|
|
1539
1577
|
return []
|
|
1540
1578
|
|
|
@@ -1550,7 +1588,12 @@ def get_bot_logs(
|
|
|
1550
1588
|
# Sort newest first, paginate
|
|
1551
1589
|
entries.sort(key=lambda e: e.get("created_at", ""), reverse=True)
|
|
1552
1590
|
offset = (page - 1) * limit
|
|
1553
|
-
|
|
1591
|
+
selected = entries[offset : offset + limit]
|
|
1592
|
+
if can_read_private_tasks(db, user):
|
|
1593
|
+
if selected:
|
|
1594
|
+
audit_private_read(db, user, bot_id=bot_id, surface="management.logs")
|
|
1595
|
+
return selected
|
|
1596
|
+
return [public_log_entry(entry) for entry in selected]
|
|
1554
1597
|
|
|
1555
1598
|
|
|
1556
1599
|
# ── Webhook endpoint ────────────────────────────────────────
|
|
@@ -486,8 +486,10 @@ async def lifespan(app: FastAPI):
|
|
|
486
486
|
backup_scheduler.start()
|
|
487
487
|
|
|
488
488
|
from lockbot.backend.app.broadcast.service import broadcast_worker
|
|
489
|
+
from lockbot.backend.app.resource_api.notifications import notification_budget
|
|
489
490
|
from lockbot.backend.app.resource_api.usage_cleanup import usage_cleanup_loop
|
|
490
491
|
|
|
492
|
+
notification_budget.start()
|
|
491
493
|
broadcast_worker.start()
|
|
492
494
|
usage_cleanup = asyncio.create_task(usage_cleanup_loop())
|
|
493
495
|
try:
|
|
@@ -497,6 +499,7 @@ async def lifespan(app: FastAPI):
|
|
|
497
499
|
with suppress(asyncio.CancelledError):
|
|
498
500
|
await usage_cleanup
|
|
499
501
|
logger.info("Shutting down all bots…")
|
|
502
|
+
notification_budget.stop()
|
|
500
503
|
broadcast_worker.stop()
|
|
501
504
|
backup_scheduler.stop()
|
|
502
505
|
bot_manager.shutdown_all()
|
|
@@ -27,13 +27,16 @@ this instruction alone is not a permission boundary.
|
|
|
27
27
|
|
|
28
28
|
Use `GET /api/bots/{bot_id}/op/resources` for the monitoring view. It returns the bot's
|
|
29
29
|
identity/type/health, a fresh timestamp, resources, current holders, cards (DEVICE / QUEUE_DEVICE), queues
|
|
30
|
-
(QUEUE / QUEUE_DEVICE), and active usage declarations with
|
|
31
|
-
queue entry includes its source when known.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
(QUEUE / QUEUE_DEVICE), and active usage declarations with preset public task categories. Each lock or
|
|
31
|
+
queue entry includes its source when known. An OP key does not return private purposes, Agent
|
|
32
|
+
names, authorization notes or credential identifiers.
|
|
33
|
+
|
|
34
|
+
Private task read access is separate from operational release authority and `metrics:read`.
|
|
35
|
+
Only the same verified actor or a super administrator may read private task details by default.
|
|
36
|
+
A bot administrator's OP key cannot acquire that authority, even if the key was generated by a
|
|
37
|
+
super administrator. Delegated `task_private:read` service credentials are not implemented; do
|
|
38
|
+
not invent a token scope or fall back to another endpoint. Use public categories and safe
|
|
39
|
+
operational aggregates for ordinary monitoring.
|
|
37
40
|
|
|
38
41
|
Resource state is complete. Usage declarations are paginated: request `usage_limit=100`
|
|
39
42
|
and follow `usage_page.next_offset` with `usage_offset` until null. On a partial page,
|
|
@@ -7,7 +7,7 @@ import logging
|
|
|
7
7
|
import time
|
|
8
8
|
from datetime import datetime, timezone
|
|
9
9
|
|
|
10
|
-
from fastapi import APIRouter, Depends, Query, Request
|
|
10
|
+
from fastapi import APIRouter, Depends, Query, Request, Response
|
|
11
11
|
from sqlalchemy import DateTime, ForeignKey, Integer, and_, func, or_
|
|
12
12
|
from sqlalchemy.dialects.sqlite import insert
|
|
13
13
|
from sqlalchemy.orm import Mapped, Session, mapped_column
|
|
@@ -15,6 +15,7 @@ from sqlalchemy.orm import Mapped, Session, mapped_column
|
|
|
15
15
|
from lockbot.backend.app.auth.dependencies import get_current_user
|
|
16
16
|
from lockbot.backend.app.auth.models import User
|
|
17
17
|
from lockbot.backend.app.database import Base, get_db
|
|
18
|
+
from lockbot.backend.app.resource_api.privacy import audit_private_read, can_read_private_tasks
|
|
18
19
|
from lockbot.backend.app.resource_auth.models import ResourceBinding
|
|
19
20
|
|
|
20
21
|
logger = logging.getLogger(__name__)
|
|
@@ -145,9 +146,12 @@ def agent_summary(db, bots):
|
|
|
145
146
|
|
|
146
147
|
|
|
147
148
|
@router.get("/{bot_id}/agent-summary")
|
|
148
|
-
def get_agent_summary(
|
|
149
|
+
def get_agent_summary(
|
|
150
|
+
bot_id: int, response: Response, user: User = Depends(get_current_user), db: Session = Depends(get_db)
|
|
151
|
+
):
|
|
149
152
|
from lockbot.backend.app.bots.router import _get_user_bot
|
|
150
153
|
|
|
154
|
+
response.headers["Cache-Control"] = "no-store"
|
|
151
155
|
bot = _get_user_bot(bot_id, user, db)
|
|
152
156
|
return agent_summary(db, [bot])
|
|
153
157
|
|
|
@@ -155,6 +159,7 @@ def get_agent_summary(bot_id: int, user: User = Depends(get_current_user), db: S
|
|
|
155
159
|
@router.get("/{bot_id}/agent-activity")
|
|
156
160
|
def get_agent_activity(
|
|
157
161
|
bot_id: int,
|
|
162
|
+
response: Response,
|
|
158
163
|
status: str = Query("active", pattern="^(active|history|all)$"),
|
|
159
164
|
page: int = Query(1, ge=1),
|
|
160
165
|
limit: int = Query(20, ge=1, le=100),
|
|
@@ -163,6 +168,7 @@ def get_agent_activity(
|
|
|
163
168
|
):
|
|
164
169
|
from lockbot.backend.app.bots.router import _get_user_bot
|
|
165
170
|
|
|
171
|
+
response.headers["Cache-Control"] = "no-store"
|
|
166
172
|
bot = _get_user_bot(bot_id, user, db)
|
|
167
173
|
now = datetime.utcnow()
|
|
168
174
|
valid = valid_binding_filter(bot, now)
|
|
@@ -182,8 +188,9 @@ def get_agent_activity(
|
|
|
182
188
|
.limit(limit)
|
|
183
189
|
.all()
|
|
184
190
|
)
|
|
191
|
+
private = can_read_private_tasks(db, user)
|
|
185
192
|
items = []
|
|
186
|
-
for binding, activity in rows:
|
|
193
|
+
for index, (binding, activity) in enumerate(rows):
|
|
187
194
|
active = (
|
|
188
195
|
binding.revoked_at is None
|
|
189
196
|
and binding.bound_bot_uuid == bot.uuid
|
|
@@ -192,8 +199,9 @@ def get_agent_activity(
|
|
|
192
199
|
)
|
|
193
200
|
items.append(
|
|
194
201
|
dict(
|
|
195
|
-
|
|
196
|
-
|
|
202
|
+
row_key=f"{page}:{index}",
|
|
203
|
+
binding_id=binding.public_id if private else None,
|
|
204
|
+
label=binding.label if private else None,
|
|
197
205
|
platform=binding.platform,
|
|
198
206
|
external_user_id=binding.external_user_id,
|
|
199
207
|
revoked=binding.revoked_at is not None,
|
|
@@ -211,4 +219,6 @@ def get_agent_activity(
|
|
|
211
219
|
},
|
|
212
220
|
)
|
|
213
221
|
)
|
|
222
|
+
if private and items:
|
|
223
|
+
audit_private_read(db, user, bot_id=bot_id, surface="management.agent_activity")
|
|
214
224
|
return dict(bot_id=bot_id, total=total, page=page, limit=limit, items=items)
|
|
@@ -20,7 +20,7 @@ from typing import Annotated
|
|
|
20
20
|
|
|
21
21
|
from fastapi import APIRouter, Body, Depends, Request
|
|
22
22
|
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
23
|
-
from sqlalchemy.orm import Session
|
|
23
|
+
from sqlalchemy.orm import Session, sessionmaker
|
|
24
24
|
|
|
25
25
|
from lockbot.backend.app.bots.manager import (
|
|
26
26
|
AdmissionFull,
|
|
@@ -34,7 +34,7 @@ from lockbot.backend.app.config import RESOURCE_API_MAX_HELD_PER_IDENTITY
|
|
|
34
34
|
from lockbot.backend.app.database import get_db
|
|
35
35
|
from lockbot.backend.app.rate_limit import limiter
|
|
36
36
|
from lockbot.backend.app.resource_api import errors
|
|
37
|
-
from lockbot.backend.app.resource_api.notifications import notify_group, should_notify
|
|
37
|
+
from lockbot.backend.app.resource_api.notifications import notification_target, notify_group, should_notify
|
|
38
38
|
from lockbot.backend.app.resource_api.observability import record_api_command
|
|
39
39
|
from lockbot.backend.app.resource_api.traffic import credential_budget, resource_tier_gate
|
|
40
40
|
from lockbot.backend.app.resource_auth.authority import authority_guard
|
|
@@ -130,7 +130,8 @@ the lease, optionally call `PUT /api/bots/{bot_id}/usage-declarations/node1`:
|
|
|
130
130
|
{"purpose":"Develop feature X","agent_label":"dev-agent","ttl_seconds":3600}
|
|
131
131
|
```
|
|
132
132
|
|
|
133
|
-
Other users receive only preset public task categories
|
|
133
|
+
Other users receive only preset public task categories. Private notes and Agent names are scoped
|
|
134
|
+
to the same verified actor and super administrators.
|
|
134
135
|
Registrations are scoped to user authorization + resource, not individual Agent processes.
|
|
135
136
|
On DEVICE, the current registration covers the node resource; different cards on the same
|
|
136
137
|
node do **not** have independent task registrations. QUEUE_DEVICE saves tasks independently
|
|
@@ -220,7 +221,7 @@ class CommandRequest(BaseModel):
|
|
|
220
221
|
max_length=512,
|
|
221
222
|
pattern=r"^[^\r\n\x00-\x1f\x7f]+$",
|
|
222
223
|
description=(
|
|
223
|
-
"Private task note, visible only to the
|
|
224
|
+
"Private task note, visible only to the same verified actor and super administrators. "
|
|
224
225
|
"Successful lock/slock/book also registers resource usage; "
|
|
225
226
|
"other commands do not publish it in group notifications."
|
|
226
227
|
),
|
|
@@ -392,6 +393,7 @@ def execute_command_via_api(
|
|
|
392
393
|
agent_label=body.agent_label,
|
|
393
394
|
purpose=body.purpose,
|
|
394
395
|
task_category=body.task_category,
|
|
396
|
+
target=notification_target(bot_row, lease, bot_manager, sessionmaker(bind=db.get_bind())),
|
|
395
397
|
)
|
|
396
398
|
|
|
397
399
|
except (BotNotRunning, InstanceRetiring, AdmissionFull, MayHaveExecuted) as exc:
|
|
@@ -147,7 +147,11 @@ def _context_payload(request, response, db, row):
|
|
|
147
147
|
else None,
|
|
148
148
|
"usage_privacy": {
|
|
149
149
|
"private_fields": ["purpose", "agent_label", "authorization_label", "binding_id"],
|
|
150
|
-
"
|
|
150
|
+
"policy_version": 2,
|
|
151
|
+
"private_readers": ["same_verified_actor", "super_administrator"],
|
|
152
|
+
"management_private_capability": "task_private:read",
|
|
153
|
+
"ordinary_operator_private_access": False,
|
|
154
|
+
"delegated_private_access_supported": False,
|
|
151
155
|
"public_task_categories": TASK_CATEGORIES,
|
|
152
156
|
"legacy_purpose_visibility": "private",
|
|
153
157
|
},
|