import { readFile } from "node:fs/promises"; /** * Resolve a capability input from the sandbox input payload when configured. * * The input argument remains the fallback for compatibility with runners * that have not adopted the file-backed transport. * * @internal */ export async function resolveRuntimeInput(fallback: T): Promise { const inputPayloadPath = process.env.NOTION_INPUT_PAYLOAD_PATH; if (inputPayloadPath === undefined) { return fallback; } let serializedInput: string; try { serializedInput = await readFile(inputPayloadPath, "utf8"); } catch (error) { if (error instanceof Error && "code" in error && error.code === "ENOENT") { return fallback; } throw error; } return JSON.parse(serializedInput) as T; }