Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Expose agent lifecycle scope in API access

rcourtman2d26eb8ba4aa
diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md
index 16b74b3835..dc54c8f39c 100644
--- a/docs/CONFIGURATION.md
+++ b/docs/CONFIGURATION.md
@@ -614,8 +614,12 @@ reinstalled or reconfigured with a valid token.
| `agent:report` | Agent host telemetry submission |
| `agent:config:read` | Read agent config payloads |
| `agent:manage` | Manage registered agents (unlink/delete/config) |
+| `agent:exec` | Establish agent command WebSocket connections |
+| `ai:chat` | Use Pulse Assistant chat and read knowledge |
+| `ai:execute` | Use governed Patrol plans, approvals, actions, and history |
| `settings:read` | Read configuration |
| `settings:write` | Modify configuration |
+| `audit:read` | Read audit events, verification results, summaries, and exports |
### Presets
@@ -624,7 +628,7 @@ The UI offers quick presets for common use cases:
| Preset | Scopes | Use Case |
| -------- | -------- | ---------- |
| **Kiosk / Dashboard** | `monitoring:read` | Read-only dashboard displays |
-| **Agent host** | `agent:report` | Agent host telemetry authentication |
+| **Agent host** | `agent:report`, `agent:config:read`, `agent:manage` | Agent telemetry, configuration fetch, and uninstall cleanup |
| **Docker / Podman report** | `docker:report` | Docker / Podman agent (read-only) |
| **Docker / Podman manage** | `docker:report`, `docker:manage` | Docker / Podman agent with actions |
| **Settings read** | `settings:read` | Read-only config access |
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 7eda2cfbcb..05cd3ed0d4 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -8218,6 +8218,13 @@ canonical scope constants: `apiTokenManagerModel.ts` may expose
`getAPITokenScopePresets()`, but it must not publish an eagerly evaluated
top-level preset array that can reintroduce settings-chunk initialization-order
failures in production bundles.
+The operator-created Agent preset must match the long-lived lifecycle minimum
+used by server-issued agent credentials: `agent:report`, `agent:config:read`,
+and `agent:manage`. The custom create and edit surfaces must expose
+`agent:manage` so an operator can cycle a credential without losing config
+fetch or self-unregister authority. Single-use `agent:enroll`, dedicated
+`relay:mobile:access`, and granular governed-action scopes remain backend-owned
+and must not be presented as general-purpose token choices.
That same boundary now also includes
`frontend-modern/src/utils/apiTokenPresentation.ts`, so token load/create/
update/revoke errors keep one governed customer-facing message source instead of
diff --git a/docs/release-control/v6/internal/subsystems/security-privacy.md b/docs/release-control/v6/internal/subsystems/security-privacy.md
index 72b5adf683..7f3701a341 100644
--- a/docs/release-control/v6/internal/subsystems/security-privacy.md
+++ b/docs/release-control/v6/internal/subsystems/security-privacy.md
@@ -1744,6 +1744,11 @@ canonical scope constants. `apiTokenManagerModel.ts` may expose a
`getAPITokenScopePresets()` factory, but it must not freeze preset scope data
at module-load time in a way that can break security settings initialization in
production chunks.
+Operator-created Agent tokens must default to the least authority needed for a
+long-lived agent lifecycle: `agent:report`, `agent:config:read`, and
+`agent:manage`. The custom scope chooser and in-place editor must expose
+`agent:manage`; server-minted bootstrap, mobile-relay, and granular governed-
+action scopes remain unavailable as general-purpose operator choices.
The manifest-derived full-surface preset may keep the internal
`pulse_intelligence_agent` id for route compatibility, but its visible label and
default token name must be `Patrol external agent` so API Access presents the
diff --git a/frontend-modern/browser-verification.json b/frontend-modern/browser-verification.json
index e5864f13f8..dc3987d534 100644
--- a/frontend-modern/browser-verification.json
+++ b/frontend-modern/browser-verification.json
@@ -1,39 +1,37 @@
{
"version": 1,
"base_sha": "b727bc62e4d5909e32ef81ac27cc39fa7a57f95b",
- "verified_at": "2026-08-26T09:46:10Z",
+ "verified_at": "2026-08-26T09:48:05Z",
"result": "passed",
"changed_paths": [
- "frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx",
- "frontend-modern/src/components/shared/HistoryChartOverlay.tsx"
+ "frontend-modern/src/constants/apiScopes.ts",
+ "frontend-modern/src/components/Settings/apiTokenManagerModel.ts"
],
"content_sha256": {
- "frontend-modern/src/components/Workloads/GuestDrawerHistory.tsx": "893176213ad2b8b5f876b62759443ec280135f6894db39195a7ccdd3df99051d",
- "frontend-modern/src/components/shared/HistoryChartOverlay.tsx": "942d0f601b8d8db5f8f8dacd7e08be6aa443633c16ea955a3458feee6888d705"
+ "frontend-modern/src/constants/apiScopes.ts": "fd85effc73f4791390f96d7bcc03893abe688138fe616e5b039c5e01ae9160f6",
+ "frontend-modern/src/components/Settings/apiTokenManagerModel.ts": "b1ec43891a5342da234604efecd8a32d1117c50a3ad8c00408181b3eef7006ed"
},
"routes": [
- "/proxmox/overview",
- "/proxmox/storage"
+ "/settings/security/api"
],
"viewports": [
{
- "width": 1280,
- "height": 720
- },
- {
- "width": 375,
- "height": 812
+ "width": 1440,
+ "height": 1000
}
],
"states": [
- "Node drawer History tab (Analytics B) with 30d range selected on a 7-day runtime: locked panel shows '30 days history requires a higher license plan. This instance's plan retains 7 days.' (desktop 1280)",
- "Guest drawer History tab (artifact-cache-322) with 30d range selected: same locked panel copy renders and wraps cleanly at 375px width",
- "Unlocked ranges (24h) on the same drawers still render charts, no lock panel",
- "HistoryChartOverlay locked state is unreachable live on this entitlement: Storage pool detail History range selector offers only 24h/7d because StoragePoolDetail/DiskDetail filter options via getUnlockedHistoryRangeOptions and clamp via resolveHistoryRangeWithinLimit; overlay copy change is the defensive path, covered by SharedPrimitives.guardrails and HistoryChart source-pin tests"
+ "loaded API Access token creation and inventory surface",
+ "expanded custom Agent scopes",
+ "Agent quick preset selected",
+ "generated Agent token inventory row",
+ "opened in-place token scope editor"
],
"interactions": [
- "Signed in, expanded node row Analytics B, opened History tab, changed range select 24h -> 30d, observed locked panel copy",
- "Storage pool west-f-service-pool expanded, History tab opened, confirmed range selector exposes only 24h/7d on max_history_days=7 runtime",
- "At 375x812: expanded guest artifact-cache-322, opened History tab, set range to 30d, observed locked panel copy and layout"
+ "opened Settings API Access in an isolated mock-backed development build",
+ "expanded Custom scopes and confirmed Agent lifecycle management is selectable",
+ "selected the Agent preset and confirmed agent:report, agent:config:read, and agent:manage are active while agent:exec remains opt-in",
+ "generated an isolated replacement Agent token and confirmed all three lifecycle scopes appear on its inventory row",
+ "opened Edit scopes and confirmed Agent lifecycle management is present and checked"
]
}
diff --git a/frontend-modern/public/docs/CONFIGURATION.md b/frontend-modern/public/docs/CONFIGURATION.md
index 16b74b3835..dc54c8f39c 100644
--- a/frontend-modern/public/docs/CONFIGURATION.md
+++ b/frontend-modern/public/docs/CONFIGURATION.md
@@ -614,8 +614,12 @@ reinstalled or reconfigured with a valid token.
| `agent:report` | Agent host telemetry submission |
| `agent:config:read` | Read agent config payloads |
| `agent:manage` | Manage registered agents (unlink/delete/config) |
+| `agent:exec` | Establish agent command WebSocket connections |
+| `ai:chat` | Use Pulse Assistant chat and read knowledge |
+| `ai:execute` | Use governed Patrol plans, approvals, actions, and history |
| `settings:read` | Read configuration |
| `settings:write` | Modify configuration |
+| `audit:read` | Read audit events, verification results, summaries, and exports |
### Presets
@@ -624,7 +628,7 @@ The UI offers quick presets for common use cases:
| Preset | Scopes | Use Case |
| -------- | -------- | ---------- |
| **Kiosk / Dashboard** | `monitoring:read` | Read-only dashboard displays |
-| **Agent host** | `agent:report` | Agent host telemetry authentication |
+| **Agent host** | `agent:report`, `agent:config:read`, `agent:manage` | Agent telemetry, configuration fetch, and uninstall cleanup |
| **Docker / Podman report** | `docker:report` | Docker / Podman agent (read-only) |
| **Docker / Podman manage** | `docker:report`, `docker:manage` | Docker / Podman agent with actions |
| **Settings read** | `settings:read` | Read-only config access |
diff --git a/frontend-modern/src/components/Settings/__tests__/APITokenManager.test.tsx b/frontend-modern/src/components/Settings/__tests__/APITokenManager.test.tsx
index e3274e1926..c91e99f9a0 100644
--- a/frontend-modern/src/components/Settings/__tests__/APITokenManager.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/APITokenManager.test.tsx
@@ -6,6 +6,8 @@ import type { APITokenRecord } from '@/api/security';
import type { Resource } from '@/types/resource';
import {
AI_EXECUTE_SCOPE,
+ AGENT_CONFIG_READ_SCOPE,
+ AGENT_MANAGE_SCOPE,
AGENT_REPORT_SCOPE,
AUDIT_READ_SCOPE,
DOCKER_MANAGE_SCOPE,
@@ -308,6 +310,51 @@ describe('APITokenManager', () => {
});
});
+ it('creates manually cycled agent tokens with the runtime lifecycle scopes', async () => {
+ createTokenMock.mockResolvedValue(
+ makeToken({
+ name: 'Replacement agent token',
+ scopes: [AGENT_REPORT_SCOPE, AGENT_CONFIG_READ_SCOPE, AGENT_MANAGE_SCOPE],
+ }),
+ );
+
+ render(() => <APITokenManager onTokensChanged={vi.fn()} canManage />);
+
+ fireEvent.input(screen.getByPlaceholderText('e.g. Docker / Podman automation'), {
+ target: { value: 'Replacement agent token' },
+ });
+ fireEvent.click(screen.getByRole('button', { name: 'Agent' }));
+ fireEvent.click(screen.getByRole('button', { name: 'Generate' }));
+
+ await waitFor(() => {
+ expect(createTokenMock).toHaveBeenCalledWith('Replacement agent token', [
+ AGENT_CONFIG_READ_SCOPE,
+ AGENT_MANAGE_SCOPE,
+ AGENT_REPORT_SCOPE,
+ ]);
+ });
+ });
+
+ it('offers agent lifecycle management when editing token scopes', async () => {
+ listTokensMock.mockResolvedValue([
+ makeToken({
+ id: 'agent-token-edit',
+ name: 'Agent token',
+ scopes: [AGENT_REPORT_SCOPE],
+ }),
+ ]);
+
+ render(() => <APITokenManager onTokensChanged={vi.fn()} canManage />);
+
+ const row = await findTokenTableRow('Agent token');
+ fireEvent.click(within(row).getByRole('button', { name: 'Edit scopes' }));
+
+ const dialog = await screen.findByRole('dialog', { name: 'Edit API token scopes' });
+ expect(
+ within(dialog).getByRole('checkbox', { name: /Agent lifecycle management/i }),
+ ).not.toBeChecked();
+ });
+
it('requires an explicit scope selection before generating a token', async () => {
render(() => <APITokenManager onTokensChanged={vi.fn()} canManage />);
diff --git a/frontend-modern/src/components/Settings/__tests__/apiTokenManagerModel.branchcov0713.test.ts b/frontend-modern/src/components/Settings/__tests__/apiTokenManagerModel.branchcov0713.test.ts
index e4d64c372f..ffd88c7eb5 100644
--- a/frontend-modern/src/components/Settings/__tests__/apiTokenManagerModel.branchcov0713.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/apiTokenManagerModel.branchcov0713.test.ts
@@ -3,6 +3,8 @@ import type { APITokenRecord } from '@/api/security';
import {
API_SCOPE_OPTIONS,
type APIScopeOption,
+ AGENT_CONFIG_READ_SCOPE,
+ AGENT_MANAGE_SCOPE,
AGENT_REPORT_SCOPE,
AUDIT_READ_SCOPE,
DOCKER_MANAGE_SCOPE,
@@ -515,7 +517,13 @@ describe('getAPITokenScopePresets (full structure)', () => {
description:
'Read-only access for wall displays. Use ?token=xxx&kiosk=1 in the URL to hide navigation and filters.',
});
- expect(byId.get(API_TOKEN_AGENT_PRESET_ID)?.scopes).toStrictEqual([AGENT_REPORT_SCOPE]);
+ expect(byId.get(API_TOKEN_AGENT_PRESET_ID)).toStrictEqual({
+ id: API_TOKEN_AGENT_PRESET_ID,
+ label: 'Agent',
+ scopes: [AGENT_REPORT_SCOPE, AGENT_CONFIG_READ_SCOPE, AGENT_MANAGE_SCOPE],
+ description:
+ 'Allow the Pulse agent to report host metrics, fetch its configuration, and unregister during uninstall.',
+ });
expect(byId.get(API_TOKEN_DOCKER_REPORT_PRESET_ID)).toStrictEqual({
id: API_TOKEN_DOCKER_REPORT_PRESET_ID,
label: API_TOKEN_DOCKER_REPORT_PRESET_LABEL,
diff --git a/frontend-modern/src/components/Settings/apiTokenManagerModel.ts b/frontend-modern/src/components/Settings/apiTokenManagerModel.ts
index ca46e71685..6a39f5c178 100644
--- a/frontend-modern/src/components/Settings/apiTokenManagerModel.ts
+++ b/frontend-modern/src/components/Settings/apiTokenManagerModel.ts
@@ -2,6 +2,8 @@ import { unwrap } from 'solid-js/store';
import type { APITokenRecord } from '@/api/security';
import {
AUDIT_READ_SCOPE,
+ AGENT_CONFIG_READ_SCOPE,
+ AGENT_MANAGE_SCOPE,
AGENT_REPORT_SCOPE,
API_SCOPE_OPTIONS,
DOCKER_MANAGE_SCOPE,
@@ -90,8 +92,9 @@ export const getAPITokenScopePresets = (
{
id: API_TOKEN_AGENT_PRESET_ID,
label: 'Agent',
- scopes: [AGENT_REPORT_SCOPE],
- description: 'Allow the Pulse agent to submit OS, CPU, and disk metrics.',
+ scopes: [AGENT_REPORT_SCOPE, AGENT_CONFIG_READ_SCOPE, AGENT_MANAGE_SCOPE],
+ description:
+ 'Allow the Pulse agent to report host metrics, fetch its configuration, and unregister during uninstall.',
},
{
id: API_TOKEN_DOCKER_REPORT_PRESET_ID,
diff --git a/frontend-modern/src/constants/apiScopes.ts b/frontend-modern/src/constants/apiScopes.ts
index 8dd1ae2f5b..fa5bb88b54 100644
--- a/frontend-modern/src/constants/apiScopes.ts
+++ b/frontend-modern/src/constants/apiScopes.ts
@@ -9,6 +9,7 @@ export interface APIScopeOption {
export const AGENT_REPORT_SCOPE = 'agent:report';
export const AGENT_CONFIG_READ_SCOPE = 'agent:config:read';
+export const AGENT_MANAGE_SCOPE = 'agent:manage';
export const DOCKER_REPORT_SCOPE = 'docker:report';
export const DOCKER_MANAGE_SCOPE = 'docker:manage';
export const KUBERNETES_REPORT_SCOPE = 'kubernetes:report';
@@ -86,6 +87,12 @@ export const API_SCOPE_OPTIONS: APIScopeOption[] = [
description: 'Allow the agent to retrieve its assigned configuration profile.',
group: 'Agents',
},
+ {
+ value: AGENT_MANAGE_SCOPE,
+ label: 'Agent lifecycle management',
+ description: 'Allow an agent to update its configuration or unregister during uninstall.',
+ group: 'Agents',
+ },
{
value: AGENT_EXEC_SCOPE,
label: 'Agent exec connection',