== User stories == US1: Контекст с дашборда/датасета → /agent с URL params US2: Guardrails card — env badge, 7 risk tones, countdown, permission_denied US3: Tools optimization — retry, timeout, summarise, RBAC + context affinity == Backend == - _context.py (NEW): UIContext validation (7 checks) - _tool_filter.py (NEW): RBAC + context affinity pipeline - _confirmation.py: build_confirmation_contract_v2, permission_denied_payload - tools.py: superset_list_databases, retry/summarise/timeout wrappers - app.py: _inject_uicontext, _inject_env_id_into_tools, database prefetch в runtime context - _persistence.py: prefetch_databases() - agent_superset_explore.py: GET /databases endpoint - _llm_async_http.py, _persistence.py: fix double /v1 в LLM URL (LM Studio Unexpected endpoint) == Frontend == - AgentChatModel.svelte.ts: 5 atoms, 3 actions, countdown, context - AgentChat.svelte: production banner, process steps, debug panel - ConfirmationCard.svelte: 7 risk tones, permission_denied, countdown - ToolCallCard.svelte: retrying/timeout/cancelled states - StreamProcessor.svelte.ts: tool_retry, timeout, permission_denied - TopNavbar: sparkles icon + Ассистент - sidebarNavigation: AI section - DashboardHeader, datasets/+page: contextual AI buttons - Icon: sparkles, brain, cpu icons - tailwind: assistant category colors - i18n: en/ru nav keys == Tests == - 159 backend agent tests (+16 US3: retry, timeout, summarise, contracts) - 2544 frontend tests (+11 model + component tests) - 15 JSON fixtures (10 API + 5 model) == Specs == - specs/035-agent-chat-context/: spec, UX, plan, tasks, research, data-model, contracts, quickstart, traceability, fixtures, checklists Closes #035
2.4 KiB
2.4 KiB
#region ScreenModels [C:3] [TYPE ADR] [SEMANTICS ux,screen-models,agent-chat] @defgroup Ux Model inventory for 035-agent-chat-context — existing models extended, no new models.
Model Inventory
| Model | File | Complexity | Changes |
|---|---|---|---|
AgentChat.Model |
frontend/src/lib/models/AgentChatModel.svelte.ts |
C4 | Extend — add uiContext, toolAffinity, dangerousCountdown, prod background atoms |
AgentChat.StreamProcessor |
AgentChat.StreamProcessor.svelte.ts |
C4 | Extend — parse new metadata fields: tool_timeout, tool_retry, dangerous, permission_granted, alternatives |
AgentChat.ConnectionManager |
AgentChat.ConnectionManager.svelte.ts |
C3 | No changes |
AgentChat.LocalStorage |
AgentChat.LocalStorage.ts |
C2 | No changes |
AgentChat.Types |
AgentChatTypes.ts |
C2 | Extend — add UIContext, ToolAffinityEntry, ConfirmMetadataV2 types |
New Atoms in AgentChat.Model
// ── Context (new) ─────────────────────────────────────
uiContext: UIContext | null = $state(null);
toolAffinity: ToolAffinityEntry[] = $state([]);
dangerousCountdown: number = $state(0); // 10..0 for dangerous tool timer
dangerousCountdownActive: boolean = $state(false);
// ── Prod background (new derived) ─────────────────────
isProdContext = $derived(this.uiContext?.envId === "prod" || this._activeEnvIsProd);
showProdWarning = $derived(this.isProdContext);
New Atoms in StreamProcessor (parse new metadata)
// New metadata type handlers:
case "tool_timeout":
// → ToolCallCard state: "timeout" + retry button
case "tool_retry":
// → ToolCallCard state: "retrying" + attempt counter
case "confirm_required" (extended):
// → parse dangerous, permission_granted, required_role, alternatives
// → set dangerousCountdown = dangerous ? 10 : 0
Component Changes
| Component | Changes |
|---|---|
AgentChat.svelte |
Prod background class binding; updated process steps rendering |
ConfirmationCard.svelte |
New states: dangerous countdown, permission_denied, env badge, risk-based styling |
ToolCallCard.svelte |
New states: retrying, timeout, cancelled; retry button |
LlmStatusBanner.svelte |
No changes |
#endregion ScreenModels