mirror of
https://github.com/BigBodyCobain/Shadowbroker.git
synced 2026-05-14 20:38:45 +02:00
b86a258535
Ship the v0.9.79 runtime refresh with transport lane isolation, Infonet secure-message address management, MeshChat MQTT controls, selected asset trail behavior, telemetry panel refinements, onboarding updates, and desktop/package metadata alignment. Also ignore local graphify work products so analysis folders do not leak into future commits.
57 lines
1.5 KiB
TypeScript
57 lines
1.5 KiB
TypeScript
import { primeAdminSession } from '@/lib/adminSession';
|
|
import type {
|
|
DesktopControlCapability,
|
|
DesktopControlSessionProfile,
|
|
} from '@/lib/desktopControlContract';
|
|
import {
|
|
canInvokeLocalControl,
|
|
hasLocalControlBridge,
|
|
localControlFetch,
|
|
} from '@/lib/localControlTransport';
|
|
|
|
type ControlPlaneOptions = RequestInit & {
|
|
requireAdminSession?: boolean;
|
|
capabilityIntent?: DesktopControlCapability;
|
|
sessionProfileHint?: DesktopControlSessionProfile;
|
|
enforceProfileHint?: boolean;
|
|
};
|
|
|
|
export async function controlPlaneFetch(
|
|
path: string,
|
|
options: ControlPlaneOptions = {},
|
|
): Promise<Response> {
|
|
const {
|
|
requireAdminSession = true,
|
|
capabilityIntent,
|
|
sessionProfileHint,
|
|
enforceProfileHint,
|
|
...init
|
|
} = options;
|
|
const nativePrivilegedPath = hasLocalControlBridge() && canInvokeLocalControl(path, init);
|
|
if (requireAdminSession && !nativePrivilegedPath) {
|
|
await primeAdminSession();
|
|
}
|
|
return localControlFetch(path, {
|
|
...init,
|
|
capabilityIntent,
|
|
sessionProfileHint,
|
|
enforceProfileHint,
|
|
});
|
|
}
|
|
|
|
export async function controlPlaneJson<T>(
|
|
path: string,
|
|
options: ControlPlaneOptions = {},
|
|
): Promise<T> {
|
|
const res = await controlPlaneFetch(path, options);
|
|
const data = await res.json().catch(() => ({}));
|
|
if (!res.ok || data?.ok === false) {
|
|
const fallback =
|
|
res.status === 429
|
|
? 'control_plane_rate_limited'
|
|
: `control_plane_request_failed:${res.status || 'unknown'}`;
|
|
throw new Error(data?.detail || data?.message || fallback);
|
|
}
|
|
return data as T;
|
|
}
|