MCPcopy
hub / github.com/codeaashu/claude-code / checkBridgePrerequisites

Function checkBridgePrerequisites

src/commands/bridge/bridge.tsx:467–504  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

465 return s.replBridgeSessionUrl;
466}
467async function checkBridgePrerequisites(): Promise<string | null> {
468 // Check organization policy — remote control may be disabled
469 const {
470 waitForPolicyLimitsToLoad,
471 isPolicyAllowed
472 } = await import('../../services/policyLimits/index.js');
473 await waitForPolicyLimitsToLoad();
474 if (!isPolicyAllowed('allow_remote_control')) {
475 return "Remote Control is disabled by your organization's policy.";
476 }
477 const disabledReason = await getBridgeDisabledReason();
478 if (disabledReason) {
479 return disabledReason;
480 }
481
482 // Mirror the v1/v2 branching logic in initReplBridge: env-less (v2) is used
483 // only when the flag is on AND the session is not perpetual. In assistant
484 // mode (KAIROS) useReplBridge sets perpetual=true, which forces
485 // initReplBridge onto the v1 path — so the prerequisite check must match.
486 let useV2 = isEnvLessBridgeEnabled();
487 if (feature('KAIROS') && useV2) {
488 const {
489 isAssistantMode
490 } = await import('../../assistant/index.js');
491 if (isAssistantMode()) {
492 useV2 = false;
493 }
494 }
495 const versionError = useV2 ? await checkEnvLessBridgeMinVersion() : checkBridgeMinVersion();
496 if (versionError) {
497 return versionError;
498 }
499 if (!getBridgeAccessToken()) {
500 return BRIDGE_LOGIN_INSTRUCTION;
501 }
502 logForDebugging('[bridge] Prerequisites passed, enabling bridge');
503 return null;
504}
505export async function call(onDone: LocalJSXCommandOnDone, _context: ToolUseContext & LocalJSXCommandContext, args: string): Promise<React.ReactNode> {
506 const name = args.trim() || undefined;
507 return <BridgeToggle onDone={onDone} name={name} />;

Callers 1

BridgeToggleFunction · 0.85

Calls 9

isPolicyAllowedFunction · 0.85
getBridgeDisabledReasonFunction · 0.85
isEnvLessBridgeEnabledFunction · 0.85
featureFunction · 0.85
checkBridgeMinVersionFunction · 0.85
getBridgeAccessTokenFunction · 0.85
logForDebuggingFunction · 0.85

Tested by

no test coverage detected