Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

1.3 KB
Raw Blame
// Connector actions reach outside services, so unlike screen context only a
// successful, well-formed snapshot allows them. Every failure code
// (unresolvable, unavailable, throttled, auth context changed, and any added
// later), a malformed snapshot, and a timeout (null) are "unavailable".
function connectorPolicyState(snapshot) {
  if (!snapshot || snapshot.success !== true || typeof snapshot.managed !== "boolean") {
    return "unavailable";
  }
  if (!snapshot.managed) return "allowed";
  const features = snapshot.policy?.features;
  if (!features || typeof features !== "object") return "unavailable";
  // Connectors are agent tools: an org that turns the agent off turns them off too.
  return features.agentEnabled === false || features.connectorsEnabled === false
    ? "blocked"
    : "allowed";
}

// The reason a connector call reports for a verdict other than "allowed".
// Signing out is its own refusal (connector logins outlive it); anything
// unrecognized fails closed as unavailable.
function policyRefusal(policyState) {
  if (policyState === "allowed") return null;
  if (policyState === "blocked") return "policy_blocked";
  if (policyState === "signed_out") return "signed_out";
  return "policy_unavailable";
}

module.exports = { connectorPolicyState, policyRefusal };