import { actionTitle, deviceName, display, Fact, identityName, OrderRows, orderTitle, PageButtons, Requester, Status, statusOf, targets, when } from './order-presentation'; import { Devices } from './devices'; import { CustomerManagement } from './customer-management'; import { ErrorBox, useResource, errorText } from './resource'; import { NavIcon, type NavKey } from './navigation'; import { OrderComposer } from './order-composer'; import { ApprovalInbox, usePendingApprovals } from './approval-inbox'; import { ScriptLibrary } from './script-library'; import { McpTokenManagement } from './mcp-token-management'; import React, { useEffect, useState } from 'react'; import { createRoot } from 'react-dom/client'; import { actions, Action, ApiError, authConfig, approvalBlockers, expectedStdout, objectId, page, Page, PlanInput, pretty, record, RecordValue, request, session, Session, stringField, tenant, tenantPath, validateInput, windowsPowerShellRemoteSignedProfile, fullMaintenanceScriptProfile } from './api'; import './style.css'; import { AdminControl, Catalog, TenantControls } from './management'; import { allowed, availableActions, parseStrictJson, powerShellApprovalBlockers, powerShellPlanJobs, rootWarning, systemWarning, systemPlanJobs, validateSensitiveInput, verifyPlanIntegrity, queryLogsApprovalBlockers, queryLogsPlanJobs, windowsMsiApprovalBlockers, windowsMsiPlanJobs, verifyWindowsMsiManifest, fullMaintenanceWarning } from './safety'; import { Login } from './login'; import { ConsoleOutput, outputText } from './console-output'; import { scriptApprovalBlockers, scriptPlanJobs, verifyScriptPlan } from './script-console'; import { agentUpdateWarning, agentUpdatePlanJobs, agentUpdateApprovalBlockers, verifyAgentUpdatePlan, verifyReleaseMetadata, releaseEnvelope, uploadAgentUpdateArtifact } from './agent-updates'; export function JsonView({ value, label = 'Vollständige Daten' }: { value: unknown; label?: string }) { return
{label}
{pretty(value)}
; } export function AgentUpdatePlanNotice({ plan }: { plan: RecordValue }) { try { const jobs = agentUpdatePlanJobs(plan); if (!jobs.length) return null; return

Vollständige feste Agent-Selbstupdates ({jobs.length})

{agentUpdateWarning}

{jobs.map(job =>

Asset {job.assetId}

Agent: {job.agentId} · Job: {job.jobId} · Versuch: {job.attemptId} · Identität: {job.identity}

Release: {String(job.manifest.release_id)} · Version: {String(job.manifest.version)} · Plattform: {String(job.manifest.platform)} · Sequenz: {String(job.manifest.release_sequence)}

Manifest-SHA256: {String(job.update.manifest_sha256)} · Job-SHA256: {job.jobHash}

Die folgenden Vorgänger-, Codepaar-, Updater-, Keyring- und Peerpinbindungen stammen vollständig aus den unveränderten gespeicherten Planbytes. Gesamtbudget600s, Healthfrist180s; keine allgemeine Reparatur oder neue Freigabe.

)}
; } catch { return ; } } export function ScriptPlanNotice({ plan }: { plan: RecordValue }) { try { const jobs = scriptPlanJobs(plan); if (!jobs.length) return null; const grouped = new Map(); for (const job of jobs) { const key = JSON.stringify([job.scriptHash, job.interpreter, job.identity, job.windowsProfile, job.privilegedProfile, job.arguments, job.expectedStdout, job.notBefore, job.startBefore, job.runtimeSeconds, job.outputBytes]); const group = grouped.get(key); if (group) group.push(job); else grouped.set(key,[job]); } const names = targets(plan); return

Skriptinhalt

{[...grouped.values()].map(group => { const job = group[0]!; return
{grouped.size > 1 &&

{group.map(j => { const target = names.find(t => t.asset_id === j.assetId && t.agent_id === j.agentId); return target ? deviceName(target) : j.assetId; }).join(', ')}

}

{job.revision ? job.revision.name+' · Version '+job.revision.version : 'Einmaliges Skript'} · {job.interpreter} · {identityName(job.identity)}

{job.privilegedProfile === fullMaintenanceScriptProfile &&

{fullMaintenanceWarning}

} {job.identity === 'root' && job.privilegedProfile !== fullMaintenanceScriptProfile &&

{rootWarning}

} {job.interpreter === 'powershell' &&

Windows PowerShell 5.1 · {job.windowsProfile === windowsPowerShellRemoteSignedProfile ? 'RemoteSigned für diesen Prozess' : 'Richtlinie des Geräts'}

}
{outputText(new TextEncoder().encode(job.script)).text}
{job.arguments.length > 0 &&

Argumente {JSON.stringify(job.arguments)}

} {job.expectedStdout !== null &&

Erwartete Ausgabe {JSON.stringify(job.expectedStdout)}

}
Ausführungsdetails und Prüfsummen

{job.scriptBytes} Byte · SHA256 {job.scriptHash}

Profil {job.privilegedProfile} · {job.identity} · Laufzeit {job.runtimeSeconds}s · Ausgabe bis {job.outputBytes} Byte

{group.map(j =>

Gerät {j.assetId} · Agent {j.agentId}

Job {j.jobId} · Versuch {j.attemptId} · SHA256 {j.jobHash}

)}
; })}
; } catch { return ; } } export function SystemPlanNotice({ plan }: { plan: RecordValue }) { let jobs: RecordValue[]; try { jobs = systemPlanJobs(plan).filter(p => record(p.action).action === 'set_service_state'); } catch { return ; } if (!jobs.length) return null; return ; } export function WindowsRebootPlanNotice({ plan }: { plan: RecordValue }) { try { const jobs = systemPlanJobs(plan).filter(p => record(p.action).action === 'reboot'); if (!jobs.length) return null; return ; } catch { return ; } } export function WindowsMsiPlanNotice({ plan }: { plan: RecordValue }) { try { const jobs = windowsMsiPlanJobs(plan); if (!jobs.length) return null; return ; } catch { return ; } } export function PowerShellPlanNotice({ plan }: { plan: RecordValue }) { try { const jobs = powerShellPlanJobs(plan); if (!jobs.length) return null; return ; } catch { return ; } } export function QueryLogsPlanNotice({ plan }: { plan: RecordValue }) { try { const jobs = queryLogsPlanJobs(plan); if (!jobs.length) return null; return ; } catch { return ; } } function PageStatus({ data }: { data: Page }) { return

Listenstand: {data.as_of} · Vollständigkeit: {data.completeness} · begrenzt: {String(data.truncated)}. Fehlende Einträge sind kein Löschungsnachweis.

; } const initialParameters: Record = { run_script: {}, refresh_inventory: { scope: 'linux.base' }, query_logs: { unit: '', since: '', until: '', max_lines: 1000 }, set_service_state: { unit: '', state: 'running' }, ensure_package: { provider: 'apt', recipe_version: '', package: '', version: '', architecture: 'amd64', installation_context: 'system', apt_manifest: null }, apply_updates: { provider: 'apt', packages: [], reboot_policy: 'never', apt_manifest: null }, reboot: { reason: '', dependency_group: '', reconnect_timeout_seconds: 300 }, apt_native_acceptance: { recipe_id: 'rmm-apt-fixture-install-1.0', recipe_version: '1', apt_manifest: null }, update_agent: { release_id: '' }, }; function Planner({ tenantId, auth, selected, showPlan }: { tenantId: string; auth: Session; selected: string[]; showPlan: (id: string) => void }) { const [scriptPlatform, setScriptPlatform] = useState('linux'), [mixedVariants, setMixedVariants] = useState('[]'); const [action, setAction] = useState('run_script'), [parameters, setParameters] = useState('{}'), [error, setError] = useState(null), [busy, setBusy] = useState(false); const [identity, setIdentity] = useState('agent_service'); return

Neuen unveränderlichen Plan vorbereiten

Nur fest ausgewählte Asset-IDs. Keine Ausführung durch Planung oder Antrag; jede Aktion einschließlich Live-Inventar benötigt Genehmigung.

{ e.preventDefault(); setBusy(true); setError(null); const f = new FormData(e.currentTarget); try { const common = { execution_identity: String(f.get('identity')), timeout_seconds: Number(f.get('timeout')), max_output_bytes: Number(f.get('output')), ...(action === 'run_script' && f.get('privileged_script_profile') === fullMaintenanceScriptProfile ? { privileged_script_profile: fullMaintenanceScriptProfile } : {}) }; const params = action === 'run_script' ? { ...common, variants: scriptPlatform === 'mixed' ? parseStrictJson(mixedVariants) : [{ os_family: scriptPlatform, interpreter: String(f.get('interpreter')), encoding: 'utf-8', script_utf8: String(f.get('script')), ...(scriptPlatform === 'windows' ? { windows_execution_profile: windowsPowerShellRemoteSignedProfile } : {}) }], arguments: [], expected_stdout: expectedStdout(String(f.get('expected')), String(f.get('expected_format'))) } : { ...record(parseStrictJson(parameters)), ...common }; const input: PlanInput = { tenant_id: tenantId, action, targets: { asset_ids: [...selected] }, parameters: params, schedule: { not_before: new Date(String(f.get('not_before'))).toISOString(), start_before: new Date(String(f.get('expires'))).toISOString(), offline_policy: 'wait_until_deadline' }, rollout: { max_parallel: Number(f.get('parallel')), halt_after_failures: Number(f.get('failures')) }, reason: String(f.get('reason')) }; const ids = String(f.get('artifact_ids') ?? '').split(/[\s,]+/).filter(Boolean); if (ids.length) { if (ids.length > 16 || new Set(ids).size !== ids.length || ids.some(id => !/^[0-9a-f-]{36}$/i.test(id))) throw new Error('Maximal 16 eindeutige feste Artefakt-UUIDs'); input.artifact_ids = ids; } validateInput(input); await validateSensitiveInput(input, auth); const plan = record(await request(tenantPath(tenantId, '/operation-plans'), { body: input, csrf: auth.csrf_token })); showPlan(objectId(plan, 'plan')); } catch (e) { setError(errorText(e)); } finally { setBusy(false); } }}> {action === 'update_agent' &&

{agentUpdateWarning} Nur parameters.release_id aus dem Katalog; keine freien Vorgänger-, Dateipfad-, Artefakt- oder Policywerte. Gesamtbudget600s, Ausgabelimit höchstens65536Bytes. Fehlende frische Gerätepreview ergibt keine Planung.

} {action === 'query_logs' &&

Windows-MVP nur Quelle windows.eventlog.application.rustdiscovery-mvp-test, Kanal Application, Provider RustDiscovery-MVP-Test, agent_service. Festes UTC-Fenster höchstens24h,1–1000Events,1024–65536Bytes,äußere Joblaufzeit10–120s; inneres kooperatives Abfragebudget höchstens5000ms. Keine freie Kanal-/XPathauswahl und keine Bookmarkfortschreibung. Linux behält seine feste Journalunit.

} {action === 'apt_native_acceptance' &&

NUR SIMULIERTE DEV/TEST-NATIVABNAHME. In Vorbereitung; Backend/Helper/Scope müssen diese eigene Aktion unterstützen. Nur rmm-apt-fixture-install-1.0 oder rmm-apt-fixture-update-1.1, Rezeptversion 1, vollständiges Schema-2-Manifest. null/Platzhalter sind nicht konfiguriert, keine Produktionsaktion, keine automatische Ausführung.

} {action === 'run_script' ? <>{scriptPlatform === 'mixed' ?