Spaces:
Runtime error
Runtime error
File size: 2,246 Bytes
cd8bd0a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | // Build-time stub for @/mitm/manager, aliased in by Turbopack during `next build`
// (the Docker image build) so native MITM modules aren't bundled. Exports that have
// a safe degraded value return it (getCachedPassword/setCachedPassword/clearCachedPassword
// β null/no-op, getAllAgentsStatus β empty list, getMitmStatus β stopped status) because
// MITM needs host access the container lacks. startMitm/stopMitm still throw since they
// cannot do anything meaningful without the real MITM process. Routes that need real MITM
// at runtime dynamic-import @/mitm/manager.runtime (the real module) instead.
// Fix #3390: getMitmStatus no longer throws β it returns running=false so the AgentBridge
// UI shows a graceful "stopped" state instead of an error banner in Docker.
const STUB_ERROR =
"MITM manager stub reached at runtime β build alias applied incorrectly. " +
"Use --webpack for production builds or verify Turbopack is not aliasing at runtime.";
export const getCachedPassword = () => null;
export const setCachedPassword = (_pwd: string) => {};
export const clearCachedPassword = () => {};
export const getMitmStatus = async () =>
({
running: false,
pid: null,
dnsConfigured: false,
certExists: false,
orphanedStateDetected: false,
}) as const;
// Repair is a no-op in the bundled (Docker) build: the container has no MITM
// system state to undo, so "repairing nothing" trivially succeeds rather than
// throwing (mirrors getMitmStatus's graceful-degradation contract). (Gap 7.)
export const repairMitm = async (_sudoPassword: string): Promise<{ repaired: string[] }> =>
({ repaired: [] });
// Must be exported or the Turbopack build fails ("Export getAllAgentsStatus doesn't
// exist") β /api/tools/agent-bridge/state imports it statically. Returns the truthful
// empty agent list in the bundled build rather than throwing (see file header). See #3066.
export const getAllAgentsStatus = (): never[] => [];
export const startMitm = async (
_apiKey: string,
_sudoPassword: string,
_options: { port?: number } = {}
): Promise<never> => {
throw new Error(STUB_ERROR);
};
export const stopMitm = async (_sudoPassword: string): Promise<never> => {
throw new Error(STUB_ERROR);
};
|