UNPKG

@copilotkit/runtime

Version:

<img src="https://github.com/user-attachments/assets/0a6b64d9-e193-4940-a3f6-60334ac34084" alt="banner" style="border-radius: 12px; border: 2px solid #d6d4fa;" />

36 lines (34 loc) 1.21 kB
import "reflect-metadata"; import { isIntelligenceRuntime } from "../core/runtime.mjs"; import { parseInspectorMetadataV1 } from "@copilotkit/shared"; //#region src/v2/runtime/handlers/handle-inspector-metadata.ts const PRIVATE_NO_STORE_HEADERS = { "Cache-Control": "no-store, private" }; function emptyInspectorMetadataResponse() { return new Response(null, { status: 204, headers: PRIVATE_NO_STORE_HEADERS }); } /** * Returns trusted, sanitized Inspector metadata without exposing provider * failures or forwarding any browser request credentials to Intelligence. */ async function handleInspectorMetadata({ runtime }) { if (!isIntelligenceRuntime(runtime)) return emptyInspectorMetadataResponse(); try { const metadata = parseInspectorMetadataV1(await runtime.intelligence.getInspectorMetadata()); if (metadata === void 0) return emptyInspectorMetadataResponse(); return new Response(JSON.stringify(metadata), { status: 200, headers: { ...PRIVATE_NO_STORE_HEADERS, "Content-Type": "application/json" } }); } catch { return emptyInspectorMetadataResponse(); } } //#endregion export { handleInspectorMetadata }; //# sourceMappingURL=handle-inspector-metadata.mjs.map