()
| 465 | return s.replBridgeSessionUrl; |
| 466 | } |
| 467 | async 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 | } |
| 505 | export 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} />; |
no test coverage detected